<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[243324] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/243324">243324</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2019-03-21 13:51:56 -0700 (Thu, 21 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Apple Pay should be available in documents with no user agent scripts
https://bugs.webkit.org/show_bug.cgi?id=196061
<rdar://problem/48649391>

Reviewed by Brady Eidson.

Source/WebCore:

On platforms that support APPLE_PAY_REMOTE_UI, we can enable Apple Pay JS and Payment Request
by default in all WebKit clients.

In order to protect the privacy of Apple Pay transactions, this patch implements the
following restrictions on API usage:

1. If user agent scripts have been evaluated in a document, Apple Pay APIs will no longer be
available for the duration of the document's lifetime.
2. If an Apple Pay transaction has started in a document, user agent scripts will no longer
be evaluated for the duration of the document's lifetime.

These restrictions are disabled for clients with the
com.apple.private.WebKit.UnrestrictedApplePay entitlement and platforms that do support
Apple Pay but don't support APPLE_PAY_REMOTE_UI.

Added new API tests.

* Modules/applepay/ApplePayRequestBase.cpp:
(WebCore::convertAndValidate):
* Modules/applepay/ApplePayRequestBase.h:
* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
(WebCore::ApplePaySession::create):
(WebCore::ApplePaySession::supportsVersion):
(WebCore::ApplePaySession::canMakePayments):
(WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
(WebCore::ApplePaySession::openPaymentSetup):
(WebCore::ApplePaySession::begin):
* Modules/applepay/ApplePaySession.h:
* Modules/applepay/ApplePaySession.idl:
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::supportsVersion const):
(WebCore::PaymentCoordinator::canMakePayments):
(WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard):
(WebCore::PaymentCoordinator::openPaymentSetup):
(WebCore::PaymentCoordinator::beginPaymentSession):
(WebCore::PaymentCoordinator::validatedPaymentNetwork const):
(WebCore::PaymentCoordinator::shouldAllowApplePay const):
(WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const):
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentCoordinatorClient.h:
(WebCore::PaymentCoordinatorClient::supportsUnrestrictedApplePay const):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::show):
(WebCore::ApplePayPaymentHandler::canMakePayment):
(WebCore::ApplePayPaymentHandler::version const):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/paymentrequest/PaymentHandler.h:
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::show):
(WebCore::PaymentRequest::canMakePayment):

Plumbed a Document& through to the various places that call into PaymentCoordinator for use
by shouldAllowApplePay and shouldAllowUserAgentScripts.

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::executeUserAgentScriptInWorld):
(WebCore::ScriptController::shouldAllowUserAgentScripts const):
* bindings/js/ScriptController.h:

Added executeUserAgentScriptInWorld, which calls executeScriptInWorld if allowed.

* dom/Document.cpp:
(WebCore::Document::ensurePlugInsInjectedScript):

Changed to only evaluate the chrome client's plug-in extra script if allowed, and to mark
the document as having evaluated user agent scripts.

(WebCore::Document::hasEvaluatedUserAgentScripts const):
(WebCore::Document::isRunningUserScripts const):
(WebCore::Document::setAsRunningUserScripts):
(WebCore::Document::setHasEvaluatedUserAgentScripts):
(WebCore::Document::hasStartedApplePaySession const):
(WebCore::Document::setHasStartedApplePaySession):
* dom/Document.h:

Added helper functions to set state on the top document.

* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):

Removed call to topDocument() now that isRunningUserScripts() always checks the top document.

* page/Frame.cpp:
(WebCore::Frame::injectUserScriptImmediately):

Changed to only inject the user script if allowed.

* page/Settings.yaml:
* page/SettingsDefaultValues.h:

Enabled Apple Pay by default on platforms that enable APPLE_PAY_REMOTE_UI.

* testing/Internals.cpp:
(WebCore::Internals::setAsRunningUserScripts):
(WebCore::Internals::setHasStartedApplePaySession):
* testing/Internals.h:
* testing/Internals.idl:
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.idl:

Added some internal interfaces for use by TestWebKitAPI.

Source/WebKit:

* Shared/AuxiliaryProcess.h:
* Shared/Cocoa/AuxiliaryProcessCocoa.mm:
(WebKit::AuxiliaryProcess::parentProcessHasEntitlement):

Added a convenience function for checking parent process entitlements.

* Shared/WebPreferences.yaml:
* Shared/WebPreferencesDefaultValues.h:
* UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
(-[WKWebViewConfiguration init]):

Enabled Apple Pay by default on platforms that enable APPLE_PAY_REMOTE_UI.

* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::supportsUnrestrictedApplePay const):
* WebProcess/ApplePay/WebPaymentCoordinator.h:

Implemented supportsUnrestrictedApplePay by checking for the
com.apple.private.WebKit.UnrestrictedApplePay entitlement on platforms that enable
APPLE_PAY_REMOTE_UI.

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h:
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(didClearWindowObjectForFrame):
(setUpPageLoaderClient):

Added injected bundle SPI that TestWebKitAPI uses to inject the WebCore Internals interface.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runJavaScript):

Changed to call ScriptController::executeUserAgentScriptInWorld.

Source/WebKitLegacy/mac:

* WebView/WebFrame.mm:
(-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):

Tools:

Added API tests and related infrastructure.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm: Added.
(-[TestApplePayScriptMessageHandler initWithExpectation:]):
(-[TestApplePayScriptMessageHandler userContentController:didReceiveScriptMessage:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html: Added.
* TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html: Added.
* TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html: Added.
* TestWebKitAPI/cocoa/TestProtocol.mm:
(-[TestProtocol startLoading]):
* TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h: Added.
* TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm: Added.
(-[WebProcessPlugInWithInternals webProcessPlugIn:didCreateBrowserContextController:]):
(-[WebProcessPlugInWithInternals webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayApplePayRequestBasecpp">trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayApplePayRequestBaseh">trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.h</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayApplePaySessioncpp">trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayApplePaySessionh">trunk/Source/WebCore/Modules/applepay/ApplePaySession.h</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayApplePaySessionidl">trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayPaymentCoordinatorcpp">trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayPaymentCoordinatorh">trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepayPaymentCoordinatorClienth">trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepaypaymentrequestApplePayPaymentHandlercpp">trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesapplepaypaymentrequestApplePayPaymentHandlerh">trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h</a></li>
<li><a href="#trunkSourceWebCoreModulespaymentrequestPaymentHandlerh">trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h</a></li>
<li><a href="#trunkSourceWebCoreModulespaymentrequestPaymentRequestcpp">trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptControllercpp">trunk/Source/WebCore/bindings/js/ScriptController.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsScriptControllerh">trunk/Source/WebCore/bindings/js/ScriptController.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentThreadableLoadercpp">trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFramecpp">trunk/Source/WebCore/page/Frame.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsyaml">trunk/Source/WebCore/page/Settings.yaml</a></li>
<li><a href="#trunkSourceWebCorepageSettingsDefaultValuesh">trunk/Source/WebCore/page/SettingsDefaultValues.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkSourceWebCoretestingMockPaymentCoordinatorh">trunk/Source/WebCore/testing/MockPaymentCoordinator.h</a></li>
<li><a href="#trunkSourceWebCoretestingMockPaymentCoordinatoridl">trunk/Source/WebCore/testing/MockPaymentCoordinator.idl</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitSharedAuxiliaryProcessh">trunk/Source/WebKit/Shared/AuxiliaryProcess.h</a></li>
<li><a href="#trunkSourceWebKitSharedCocoaAuxiliaryProcessCocoamm">trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitSharedWebPreferencesyaml">trunk/Source/WebKit/Shared/WebPreferences.yaml</a></li>
<li><a href="#trunkSourceWebKitSharedWebPreferencesDefaultValuesh">trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewConfigurationmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessApplePayWebPaymentCoordinatorcpp">trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessApplePayWebPaymentCoordinatorh">trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleAPICocoaWKWebProcessPlugInLoadDelegateh">trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessInjectedBundleAPImacWKWebProcessPlugInBrowserContextControllermm">trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitLegacymacChangeLog">trunk/Source/WebKitLegacy/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitLegacymacWebViewWebFramemm">trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPIcocoaTestProtocolmm">trunk/Tools/TestWebKitAPI/cocoa/TestProtocol.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaApplePaymm">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaapplepayactivesessionhtml">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaapplepayavailabilityiniframehtml">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKitCocoaapplepayavailabilityhtml">trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html</a></li>
<li><a href="#trunkToolsTestWebKitAPIcocoaWebProcessPlugInWebProcessPlugInWithInternalsh">trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h</a></li>
<li><a href="#trunkToolsTestWebKitAPIcocoaWebProcessPlugInWebProcessPlugInWithInternalsmm">trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/ChangeLog      2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,3 +1,114 @@
</span><ins>+2019-03-21  Andy Estes  <aestes@apple.com>
+
+        [iOS] Apple Pay should be available in documents with no user agent scripts
+        https://bugs.webkit.org/show_bug.cgi?id=196061
+        <rdar://problem/48649391>
+
+        Reviewed by Brady Eidson.
+
+        On platforms that support APPLE_PAY_REMOTE_UI, we can enable Apple Pay JS and Payment Request
+        by default in all WebKit clients.
+
+        In order to protect the privacy of Apple Pay transactions, this patch implements the
+        following restrictions on API usage:
+
+        1. If user agent scripts have been evaluated in a document, Apple Pay APIs will no longer be
+        available for the duration of the document's lifetime.
+        2. If an Apple Pay transaction has started in a document, user agent scripts will no longer
+        be evaluated for the duration of the document's lifetime.
+
+        These restrictions are disabled for clients with the
+        com.apple.private.WebKit.UnrestrictedApplePay entitlement and platforms that do support
+        Apple Pay but don't support APPLE_PAY_REMOTE_UI.
+
+        Added new API tests.
+
+        * Modules/applepay/ApplePayRequestBase.cpp:
+        (WebCore::convertAndValidate):
+        * Modules/applepay/ApplePayRequestBase.h:
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::convertAndValidate):
+        (WebCore::ApplePaySession::create):
+        (WebCore::ApplePaySession::supportsVersion):
+        (WebCore::ApplePaySession::canMakePayments):
+        (WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
+        (WebCore::ApplePaySession::openPaymentSetup):
+        (WebCore::ApplePaySession::begin):
+        * Modules/applepay/ApplePaySession.h:
+        * Modules/applepay/ApplePaySession.idl:
+        * Modules/applepay/PaymentCoordinator.cpp:
+        (WebCore::PaymentCoordinator::supportsVersion const):
+        (WebCore::PaymentCoordinator::canMakePayments):
+        (WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard):
+        (WebCore::PaymentCoordinator::openPaymentSetup):
+        (WebCore::PaymentCoordinator::beginPaymentSession):
+        (WebCore::PaymentCoordinator::validatedPaymentNetwork const):
+        (WebCore::PaymentCoordinator::shouldAllowApplePay const):
+        (WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const):
+        * Modules/applepay/PaymentCoordinator.h:
+        * Modules/applepay/PaymentCoordinatorClient.h:
+        (WebCore::PaymentCoordinatorClient::supportsUnrestrictedApplePay const):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::show):
+        (WebCore::ApplePayPaymentHandler::canMakePayment):
+        (WebCore::ApplePayPaymentHandler::version const):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+        * Modules/paymentrequest/PaymentHandler.h:
+        * Modules/paymentrequest/PaymentRequest.cpp:
+        (WebCore::PaymentRequest::show):
+        (WebCore::PaymentRequest::canMakePayment):
+
+        Plumbed a Document& through to the various places that call into PaymentCoordinator for use
+        by shouldAllowApplePay and shouldAllowUserAgentScripts.
+
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::executeUserAgentScriptInWorld):
+        (WebCore::ScriptController::shouldAllowUserAgentScripts const):
+        * bindings/js/ScriptController.h:
+
+        Added executeUserAgentScriptInWorld, which calls executeScriptInWorld if allowed.
+
+        * dom/Document.cpp:
+        (WebCore::Document::ensurePlugInsInjectedScript):
+
+        Changed to only evaluate the chrome client's plug-in extra script if allowed, and to mark
+        the document as having evaluated user agent scripts.
+
+        (WebCore::Document::hasEvaluatedUserAgentScripts const):
+        (WebCore::Document::isRunningUserScripts const):
+        (WebCore::Document::setAsRunningUserScripts):
+        (WebCore::Document::setHasEvaluatedUserAgentScripts):
+        (WebCore::Document::hasStartedApplePaySession const):
+        (WebCore::Document::setHasStartedApplePaySession):
+        * dom/Document.h:
+
+        Added helper functions to set state on the top document.
+
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+
+        Removed call to topDocument() now that isRunningUserScripts() always checks the top document.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::injectUserScriptImmediately):
+
+        Changed to only inject the user script if allowed.
+
+        * page/Settings.yaml:
+        * page/SettingsDefaultValues.h:
+
+        Enabled Apple Pay by default on platforms that enable APPLE_PAY_REMOTE_UI.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::setAsRunningUserScripts):
+        (WebCore::Internals::setHasStartedApplePaySession):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * testing/MockPaymentCoordinator.h:
+        * testing/MockPaymentCoordinator.idl:
+
+        Added some internal interfaces for use by TestWebKitAPI.
+
</ins><span class="cx"> 2019-03-21  Alex Christensen  <achristensen@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Add SPI to inform applications of WKContentRuleList actions
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayApplePayRequestBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static ExceptionOr<Vector<String>> convertAndValidate(unsigned version, const Vector<String>& supportedNetworks, const PaymentCoordinator& paymentCoordinator)
</del><ins>+static ExceptionOr<Vector<String>> convertAndValidate(Document& document, unsigned version, const Vector<String>& supportedNetworks, const PaymentCoordinator& paymentCoordinator)
</ins><span class="cx"> {
</span><span class="cx">     if (supportedNetworks.isEmpty())
</span><span class="cx">         return Exception { TypeError, "At least one supported network must be provided." };
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx">     Vector<String> result;
</span><span class="cx">     result.reserveInitialCapacity(supportedNetworks.size());
</span><span class="cx">     for (auto& supportedNetwork : supportedNetworks) {
</span><del>-        auto validatedNetwork = paymentCoordinator.validatedPaymentNetwork(version, supportedNetwork);
</del><ins>+        auto validatedNetwork = paymentCoordinator.validatedPaymentNetwork(document, version, supportedNetwork);
</ins><span class="cx">         if (!validatedNetwork)
</span><span class="cx">             return Exception { TypeError, makeString("\"", supportedNetwork, "\" is not a valid payment network.") };
</span><span class="cx">         result.uncheckedAppend(*validatedNetwork);
</span><span class="lines">@@ -50,9 +50,9 @@
</span><span class="cx">     return WTFMove(result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayRequestBase& request, const PaymentCoordinator& paymentCoordinator)
</del><ins>+ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document, unsigned version, ApplePayRequestBase& request, const PaymentCoordinator& paymentCoordinator)
</ins><span class="cx"> {
</span><del>-    if (!version || !paymentCoordinator.supportsVersion(version))
</del><ins>+    if (!version || !paymentCoordinator.supportsVersion(document, version))
</ins><span class="cx">         return Exception { InvalidAccessError, makeString('"', version, "\" is not a supported version.") };
</span><span class="cx"> 
</span><span class="cx">     ApplePaySessionPaymentRequest result;
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">         return merchantCapabilities.releaseException();
</span><span class="cx">     result.setMerchantCapabilities(merchantCapabilities.releaseReturnValue());
</span><span class="cx"> 
</span><del>-    auto supportedNetworks = convertAndValidate(version, request.supportedNetworks, paymentCoordinator);
</del><ins>+    auto supportedNetworks = convertAndValidate(document, version, request.supportedNetworks, paymentCoordinator);
</ins><span class="cx">     if (supportedNetworks.hasException())
</span><span class="cx">         return supportedNetworks.releaseException();
</span><span class="cx">     result.setSupportedNetworks(supportedNetworks.releaseReturnValue());
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayApplePayRequestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.h      2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.h 2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class Document;
</ins><span class="cx"> class PaymentCoordinator;
</span><span class="cx"> 
</span><span class="cx"> struct ApplePayRequestBase {
</span><span class="lines">@@ -50,7 +51,7 @@
</span><span class="cx">     Vector<String> supportedCountries;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayRequestBase&, const PaymentCoordinator&);
</del><ins>+ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document&, unsigned version, ApplePayRequestBase&, const PaymentCoordinator&);
</ins><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayApplePaySessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -207,9 +207,9 @@
</span><span class="cx">     return WTFMove(result);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayPaymentRequest&& paymentRequest, const PaymentCoordinator& paymentCoordinator)
</del><ins>+static ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document, unsigned version, ApplePayPaymentRequest&& paymentRequest, const PaymentCoordinator& paymentCoordinator)
</ins><span class="cx"> {
</span><del>-    auto convertedRequest = convertAndValidate(version, paymentRequest, paymentCoordinator);
</del><ins>+    auto convertedRequest = convertAndValidate(document, version, paymentRequest, paymentCoordinator);
</ins><span class="cx">     if (convertedRequest.hasException())
</span><span class="cx">         return convertedRequest.releaseException();
</span><span class="cx"> 
</span><span class="lines">@@ -399,7 +399,7 @@
</span><span class="cx">     if (!document.page())
</span><span class="cx">         return Exception { InvalidAccessError, "Frame is detached" };
</span><span class="cx"> 
</span><del>-    auto convertedPaymentRequest = convertAndValidate(version, WTFMove(paymentRequest), document.page()->paymentCoordinator());
</del><ins>+    auto convertedPaymentRequest = convertAndValidate(document, version, WTFMove(paymentRequest), document.page()->paymentCoordinator());
</ins><span class="cx">     if (convertedPaymentRequest.hasException())
</span><span class="cx">         return convertedPaymentRequest.releaseException();
</span><span class="cx"> 
</span><span class="lines">@@ -411,19 +411,17 @@
</span><span class="cx">     , m_paymentRequest { WTFMove(paymentRequest) }
</span><span class="cx">     , m_version { version }
</span><span class="cx"> {
</span><del>-    ASSERT(document.page()->paymentCoordinator().supportsVersion(version));
</del><ins>+    ASSERT(document.page()->paymentCoordinator().supportsVersion(document, version));
</ins><span class="cx">     suspendIfNeeded();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ApplePaySession::~ApplePaySession() = default;
</span><span class="cx"> 
</span><del>-ExceptionOr<bool> ApplePaySession::supportsVersion(ScriptExecutionContext& scriptExecutionContext, unsigned version)
</del><ins>+ExceptionOr<bool> ApplePaySession::supportsVersion(Document& document, unsigned version)
</ins><span class="cx"> {
</span><span class="cx">     if (!version)
</span><span class="cx">         return Exception { InvalidAccessError };
</span><span class="cx"> 
</span><del>-    auto& document = downcast<Document>(scriptExecutionContext);
-
</del><span class="cx">     auto canCall = canCreateSession(document);
</span><span class="cx">     if (canCall.hasException())
</span><span class="cx">         return canCall.releaseException();
</span><span class="lines">@@ -432,7 +430,7 @@
</span><span class="cx">     if (!page)
</span><span class="cx">         return Exception { InvalidAccessError };
</span><span class="cx"> 
</span><del>-    return page->paymentCoordinator().supportsVersion(version);
</del><ins>+    return page->paymentCoordinator().supportsVersion(document, version);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static bool shouldDiscloseApplePayCapability(Document& document)
</span><span class="lines">@@ -444,10 +442,8 @@
</span><span class="cx">     return document.settings().applePayCapabilityDisclosureAllowed();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<bool> ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionContext)
</del><ins>+ExceptionOr<bool> ApplePaySession::canMakePayments(Document& document)
</ins><span class="cx"> {
</span><del>-    auto& document = downcast<Document>(scriptExecutionContext);
-
</del><span class="cx">     auto canCall = canCreateSession(document);
</span><span class="cx">     if (canCall.hasException())
</span><span class="cx">         return canCall.releaseException();
</span><span class="lines">@@ -456,13 +452,11 @@
</span><span class="cx">     if (!page)
</span><span class="cx">         return Exception { InvalidAccessError };
</span><span class="cx"> 
</span><del>-    return page->paymentCoordinator().canMakePayments();
</del><ins>+    return page->paymentCoordinator().canMakePayments(document);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
</del><ins>+ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(Document& document, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
</ins><span class="cx"> {
</span><del>-    auto& document = downcast<Document>(scriptExecutionContext);
-
</del><span class="cx">     auto canCall = canCreateSession(document);
</span><span class="cx">     if (canCall.hasException())
</span><span class="cx">         return canCall.releaseException();
</span><span class="lines">@@ -474,7 +468,7 @@
</span><span class="cx">             return Exception { InvalidAccessError };
</span><span class="cx"> 
</span><span class="cx">         auto& paymentCoordinator = page->paymentCoordinator();
</span><del>-        bool canMakePayments = paymentCoordinator.canMakePayments();
</del><ins>+        bool canMakePayments = paymentCoordinator.canMakePayments(document);
</ins><span class="cx"> 
</span><span class="cx">         RunLoop::main().dispatch([promise, canMakePayments]() mutable {
</span><span class="cx">             promise->resolve<IDLBoolean>(canMakePayments);
</span><span class="lines">@@ -488,16 +482,14 @@
</span><span class="cx"> 
</span><span class="cx">     auto& paymentCoordinator = page->paymentCoordinator();
</span><span class="cx"> 
</span><del>-    paymentCoordinator.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), [promise](bool canMakePayments) mutable {
</del><ins>+    paymentCoordinator.canMakePaymentsWithActiveCard(document, merchantIdentifier, [promise](bool canMakePayments) mutable {
</ins><span class="cx">         promise->resolve<IDLBoolean>(canMakePayments);
</span><span class="cx">     });
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<void> ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
</del><ins>+ExceptionOr<void> ApplePaySession::openPaymentSetup(Document& document, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
</ins><span class="cx"> {
</span><del>-    auto& document = downcast<Document>(scriptExecutionContext);
-
</del><span class="cx">     auto canCall = canCreateSession(document);
</span><span class="cx">     if (canCall.hasException())
</span><span class="cx">         return canCall.releaseException();
</span><span class="lines">@@ -512,7 +504,7 @@
</span><span class="cx">     auto& paymentCoordinator = page->paymentCoordinator();
</span><span class="cx"> 
</span><span class="cx">     RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
</span><del>-    paymentCoordinator.openPaymentSetup(merchantIdentifier, document.domain(), [promise](bool result) mutable {
</del><ins>+    paymentCoordinator.openPaymentSetup(document, merchantIdentifier, [promise](bool result) mutable {
</ins><span class="cx">         promise->resolve<IDLBoolean>(result);
</span><span class="cx">     });
</span><span class="cx"> 
</span><span class="lines">@@ -519,7 +511,7 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<void> ApplePaySession::begin()
</del><ins>+ExceptionOr<void> ApplePaySession::begin(Document& document)
</ins><span class="cx"> {
</span><span class="cx">     if (!canBegin())
</span><span class="cx">         return Exception { InvalidAccessError, "Payment session is already active." };
</span><span class="lines">@@ -527,13 +519,7 @@
</span><span class="cx">     if (paymentCoordinator().hasActiveSession())
</span><span class="cx">         return Exception { InvalidAccessError, "Page already has an active payment session." };
</span><span class="cx"> 
</span><del>-    auto& document = *downcast<Document>(scriptExecutionContext());
-
-    Vector<URL> linkIconURLs;
-    for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
-        linkIconURLs.append(icon.url);
-
-    if (!paymentCoordinator().beginPaymentSession(*this, document.url(), linkIconURLs, m_paymentRequest))
</del><ins>+    if (!paymentCoordinator().beginPaymentSession(document, *this, m_paymentRequest))
</ins><span class="cx">         return Exception { InvalidAccessError, "There is already has an active payment session." };
</span><span class="cx"> 
</span><span class="cx">     m_state = State::Active;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayApplePaySessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.h  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.h     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -71,12 +71,12 @@
</span><span class="cx">     static const unsigned short STATUS_PIN_INCORRECT = 6;
</span><span class="cx">     static const unsigned short STATUS_PIN_LOCKOUT = 7;
</span><span class="cx"> 
</span><del>-    static ExceptionOr<bool> supportsVersion(ScriptExecutionContext&, unsigned version);
-    static ExceptionOr<bool> canMakePayments(ScriptExecutionContext&);
-    static ExceptionOr<void> canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
-    static ExceptionOr<void> openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
</del><ins>+    static ExceptionOr<bool> supportsVersion(Document&, unsigned version);
+    static ExceptionOr<bool> canMakePayments(Document&);
+    static ExceptionOr<void> canMakePaymentsWithActiveCard(Document&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
+    static ExceptionOr<void> openPaymentSetup(Document&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
</ins><span class="cx"> 
</span><del>-    ExceptionOr<void> begin();
</del><ins>+    ExceptionOr<void> begin(Document&);
</ins><span class="cx">     ExceptionOr<void> abort();
</span><span class="cx">     ExceptionOr<void> completeMerchantValidation(JSC::ExecState&, JSC::JSValue merchantSession);
</span><span class="cx">     ExceptionOr<void> completeShippingMethodSelection(ApplePayShippingMethodUpdate&&);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayApplePaySessionidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -40,12 +40,12 @@
</span><span class="cx">     const unsigned short STATUS_PIN_INCORRECT = 6;
</span><span class="cx">     const unsigned short STATUS_PIN_LOCKOUT = 7;
</span><span class="cx"> 
</span><del>-    [CallWith=ScriptExecutionContext, MayThrowException] static boolean supportsVersion(unsigned long version);
-    [CallWith=ScriptExecutionContext, MayThrowException] static boolean canMakePayments();
-    [CallWith=ScriptExecutionContext, MayThrowException] static Promise<boolean> canMakePaymentsWithActiveCard(DOMString merchantIdentifier);
-    [CallWith=ScriptExecutionContext, MayThrowException] static Promise<boolean> openPaymentSetup(DOMString merchantIdentifier);
</del><ins>+    [CallWith=Document, MayThrowException] static boolean supportsVersion(unsigned long version);
+    [CallWith=Document, MayThrowException] static boolean canMakePayments();
+    [CallWith=Document, MayThrowException] static Promise<boolean> canMakePaymentsWithActiveCard(DOMString merchantIdentifier);
+    [CallWith=Document, MayThrowException] static Promise<boolean> openPaymentSetup(DOMString merchantIdentifier);
</ins><span class="cx"> 
</span><del>-    [MayThrowException] void begin();
</del><ins>+    [CallWith=Document, MayThrowException] void begin();
</ins><span class="cx">     [MayThrowException] void abort();
</span><span class="cx">     [MayThrowException, CallWith=ExecState] void completeMerchantValidation(any merchantSession);
</span><span class="cx">     [MayThrowException, Conditional=APPLE_PAY_SESSION_V3] void completeShippingMethodSelection(ApplePayShippingMethodUpdate update);
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayPaymentCoordinatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp     2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp        2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,6 +28,8 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(APPLE_PAY)
</span><span class="cx"> 
</span><ins>+#include "Document.h"
+#include "LinkIconCollector.h"
</ins><span class="cx"> #include "PaymentAuthorizationStatus.h"
</span><span class="cx"> #include "PaymentCoordinatorClient.h"
</span><span class="cx"> #include "PaymentSession.h"
</span><span class="lines">@@ -46,34 +48,50 @@
</span><span class="cx">     m_client.paymentCoordinatorDestroyed();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PaymentCoordinator::supportsVersion(unsigned version) const
</del><ins>+bool PaymentCoordinator::supportsVersion(Document& document, unsigned version) const
</ins><span class="cx"> {
</span><ins>+    if (!shouldAllowApplePay(document))
+        return false;
</ins><span class="cx">     return m_client.supportsVersion(version);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PaymentCoordinator::canMakePayments()
</del><ins>+bool PaymentCoordinator::canMakePayments(Document& document)
</ins><span class="cx"> {
</span><ins>+    if (!shouldAllowApplePay(document))
+        return false;
</ins><span class="cx">     return m_client.canMakePayments();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PaymentCoordinator::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
</del><ins>+void PaymentCoordinator::canMakePaymentsWithActiveCard(Document& document, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    m_client.canMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler));
</del><ins>+    if (!shouldAllowApplePay(document))
+        return completionHandler(false);
+    m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void PaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
</del><ins>+void PaymentCoordinator::openPaymentSetup(Document& document, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    m_client.openPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler));
</del><ins>+    if (!shouldAllowApplePay(document))
+        return completionHandler(false);
+    m_client.openPaymentSetup(merchantIdentifier, document.domain(), WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool PaymentCoordinator::beginPaymentSession(PaymentSession& paymentSession, const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest& paymentRequest)
</del><ins>+bool PaymentCoordinator::beginPaymentSession(Document& document, PaymentSession& paymentSession, const ApplePaySessionPaymentRequest& paymentRequest)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_activeSession);
</span><span class="cx"> 
</span><del>-    if (!m_client.showPaymentUI(originatingURL, linkIconURLs, paymentRequest))
</del><ins>+    if (!shouldAllowApplePay(document))
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    Vector<URL> linkIconURLs;
+    for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
+        linkIconURLs.append(icon.url);
+
+    if (!m_client.showPaymentUI(document.url(), linkIconURLs, paymentRequest))
+        return false;
+
</ins><span class="cx">     m_activeSession = &paymentSession;
</span><ins>+    document.setHasStartedApplePaySession();
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -195,8 +213,11 @@
</span><span class="cx">     m_activeSession = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-Optional<String> PaymentCoordinator::validatedPaymentNetwork(unsigned version, const String& paymentNetwork) const
</del><ins>+Optional<String> PaymentCoordinator::validatedPaymentNetwork(Document& document, unsigned version, const String& paymentNetwork) const
</ins><span class="cx"> {
</span><ins>+    if (!shouldAllowApplePay(document))
+        return WTF::nullopt;
+
</ins><span class="cx">     if (version < 2 && equalIgnoringASCIICase(paymentNetwork, "jcb"))
</span><span class="cx">         return WTF::nullopt;
</span><span class="cx"> 
</span><span class="lines">@@ -206,6 +227,32 @@
</span><span class="cx">     return m_client.validatedPaymentNetwork(paymentNetwork);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool PaymentCoordinator::shouldAllowApplePay(Document& document) const
+{
+    if (m_client.supportsUnrestrictedApplePay())
+        return true;
+
+    if (document.hasEvaluatedUserAgentScripts() || document.isRunningUserScripts()) {
+        ASSERT(shouldAllowUserAgentScripts(document));
+        return false;
+    }
+
+    return true;
+}
+
+bool PaymentCoordinator::shouldAllowUserAgentScripts(Document& document) const
+{
+    if (m_client.supportsUnrestrictedApplePay())
+        return true;
+
+    if (document.hasStartedApplePaySession()) {
+        ASSERT(shouldAllowApplePay(document));
+        return false;
+    }
+
+    return true;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(APPLE_PAY)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayPaymentCoordinatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h       2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h  2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class Document;
</ins><span class="cx"> class Payment;
</span><span class="cx"> class PaymentCoordinatorClient;
</span><span class="cx"> class PaymentContact;
</span><span class="lines">@@ -52,14 +53,14 @@
</span><span class="cx"> 
</span><span class="cx">     PaymentCoordinatorClient& client() { return m_client; }
</span><span class="cx"> 
</span><del>-    bool supportsVersion(unsigned version) const;
-    bool canMakePayments();
-    void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
-    void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
</del><ins>+    bool supportsVersion(Document&, unsigned version) const;
+    bool canMakePayments(Document&);
+    void canMakePaymentsWithActiveCard(Document&, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler);
+    void openPaymentSetup(Document&, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler);
</ins><span class="cx"> 
</span><span class="cx">     bool hasActiveSession() const { return m_activeSession; }
</span><span class="cx"> 
</span><del>-    bool beginPaymentSession(PaymentSession&, const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest&);
</del><ins>+    bool beginPaymentSession(Document&, PaymentSession&, const ApplePaySessionPaymentRequest&);
</ins><span class="cx">     void completeMerchantValidation(const PaymentMerchantSession&);
</span><span class="cx">     void completeShippingMethodSelection(Optional<ShippingMethodUpdate>&&);
</span><span class="cx">     void completeShippingContactSelection(Optional<ShippingContactUpdate>&&);
</span><span class="lines">@@ -75,8 +76,11 @@
</span><span class="cx">     WEBCORE_EXPORT void didSelectShippingContact(const PaymentContact&);
</span><span class="cx">     WEBCORE_EXPORT void didCancelPaymentSession();
</span><span class="cx"> 
</span><del>-    Optional<String> validatedPaymentNetwork(unsigned version, const String&) const;
</del><ins>+    Optional<String> validatedPaymentNetwork(Document&, unsigned version, const String&) const;
</ins><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT bool shouldAllowApplePay(Document&) const;
+    WEBCORE_EXPORT bool shouldAllowUserAgentScripts(Document&) const;
+
</ins><span class="cx"> private:
</span><span class="cx">     PaymentCoordinatorClient& m_client;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepayPaymentCoordinatorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h 2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h    2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class Document;
</ins><span class="cx"> class PaymentMerchantSession;
</span><span class="cx"> struct PaymentAuthorizationResult;
</span><span class="cx"> struct PaymentMethodUpdate;
</span><span class="lines">@@ -65,6 +66,8 @@
</span><span class="cx">     virtual bool isMockPaymentCoordinator() const { return false; }
</span><span class="cx">     virtual bool isWebPaymentCoordinator() const { return false; }
</span><span class="cx"> 
</span><ins>+    virtual bool supportsUnrestrictedApplePay() const { return true; }
+
</ins><span class="cx"> protected:
</span><span class="cx">     virtual ~PaymentCoordinatorClient() = default;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepaypaymentrequestApplePayPaymentHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -185,9 +185,9 @@
</span><span class="cx">         request.setShippingType(convert(options.shippingType));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-ExceptionOr<void> ApplePayPaymentHandler::show()
</del><ins>+ExceptionOr<void> ApplePayPaymentHandler::show(Document& document)
</ins><span class="cx"> {
</span><del>-    auto validatedRequest = convertAndValidate(m_applePayRequest->version, *m_applePayRequest, paymentCoordinator());
</del><ins>+    auto validatedRequest = convertAndValidate(document, m_applePayRequest->version, *m_applePayRequest, paymentCoordinator());
</ins><span class="cx">     if (validatedRequest.hasException())
</span><span class="cx">         return validatedRequest.releaseException();
</span><span class="cx"> 
</span><span class="lines">@@ -217,11 +217,9 @@
</span><span class="cx">     if (exception.hasException())
</span><span class="cx">         return exception.releaseException();
</span><span class="cx"> 
</span><del>-    Vector<URL> linkIconURLs;
-    for (auto& icon : LinkIconCollector { document() }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
-        linkIconURLs.append(icon.url);
</del><ins>+    if (!paymentCoordinator().beginPaymentSession(document, *this, request))
+        return Exception { AbortError };
</ins><span class="cx"> 
</span><del>-    paymentCoordinator().beginPaymentSession(*this, document().url(), linkIconURLs, request);
</del><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -230,9 +228,9 @@
</span><span class="cx">     paymentCoordinator().abortPaymentSession();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ApplePayPaymentHandler::canMakePayment(Function<void(bool)>&& completionHandler)
</del><ins>+void ApplePayPaymentHandler::canMakePayment(Document& document, Function<void(bool)>&& completionHandler)
</ins><span class="cx"> {
</span><del>-    completionHandler(paymentCoordinator().canMakePayments());
</del><ins>+    completionHandler(paymentCoordinator().canMakePayments(document));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ExceptionOr<Vector<ApplePaySessionPaymentRequest::ShippingMethod>> ApplePayPaymentHandler::computeShippingMethods()
</span><span class="lines">@@ -532,12 +530,7 @@
</span><span class="cx"> 
</span><span class="cx"> unsigned ApplePayPaymentHandler::version() const
</span><span class="cx"> {
</span><del>-    if (!m_applePayRequest)
-        return 0;
-    
-    auto version = m_applePayRequest->version;
-    ASSERT(paymentCoordinator().supportsVersion(version));
-    return version;
</del><ins>+    return m_applePayRequest ? m_applePayRequest->version : 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ApplePayPaymentHandler::validateMerchant(URL&& validationURL)
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesapplepaypaymentrequestApplePayPaymentHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -65,9 +65,9 @@
</span><span class="cx"> 
</span><span class="cx">     // PaymentHandler
</span><span class="cx">     ExceptionOr<void> convertData(JSC::JSValue&&) final;
</span><del>-    ExceptionOr<void> show() final;
</del><ins>+    ExceptionOr<void> show(Document&) final;
</ins><span class="cx">     void hide() final;
</span><del>-    void canMakePayment(WTF::Function<void(bool)>&& completionHandler) final;
</del><ins>+    void canMakePayment(Document&, WTF::Function<void(bool)>&& completionHandler) final;
</ins><span class="cx">     ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) final;
</span><span class="cx">     ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) final;
</span><span class="cx">     void complete(Optional<PaymentComplete>&&) final;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespaymentrequestPaymentHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h     2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h        2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -49,9 +49,9 @@
</span><span class="cx">     static bool hasActiveSession(Document&);
</span><span class="cx"> 
</span><span class="cx">     virtual ExceptionOr<void> convertData(JSC::JSValue&&) = 0;
</span><del>-    virtual ExceptionOr<void> show() = 0;
</del><ins>+    virtual ExceptionOr<void> show(Document&) = 0;
</ins><span class="cx">     virtual void hide() = 0;
</span><del>-    virtual void canMakePayment(WTF::Function<void(bool)>&& completionHandler) = 0;
</del><ins>+    virtual void canMakePayment(Document&, WTF::Function<void(bool)>&& completionHandler) = 0;
</ins><span class="cx">     virtual ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) = 0;
</span><span class="cx">     virtual ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) = 0;
</span><span class="cx">     virtual void complete(Optional<PaymentComplete>&&) = 0;
</span></span></pre></div>
<a id="trunkSourceWebCoreModulespaymentrequestPaymentRequestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp   2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp      2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -428,7 +428,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    auto exception = selectedPaymentHandler->show();
</del><ins>+    auto exception = selectedPaymentHandler->show(document);
</ins><span class="cx">     if (exception.hasException()) {
</span><span class="cx">         settleShowPromise(exception.releaseException());
</span><span class="cx">         return;
</span><span class="lines">@@ -506,7 +506,7 @@
</span><span class="cx">         if (!handler)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        handler->canMakePayment([promise = WTFMove(promise)](bool canMakePayment) mutable {
</del><ins>+        handler->canMakePayment(document, [promise = WTFMove(promise)](bool canMakePayment) mutable {
</ins><span class="cx">             promise.resolve(canMakePayment);
</span><span class="cx">         });
</span><span class="cx">         return;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptController.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptController.cpp    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/bindings/js/ScriptController.cpp       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
</span><span class="cx">  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
</span><del>- *  Copyright (C) 2006-2017 Apple Inc. All rights reserved.
</del><ins>+ *  Copyright (C) 2006-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  *  This library is free software; you can redistribute it and/or
</span><span class="cx">  *  modify it under the terms of the GNU Lesser General Public
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #include "Page.h"
</span><span class="cx"> #include "PageConsoleClient.h"
</span><span class="cx"> #include "PageGroup.h"
</span><ins>+#include "PaymentCoordinator.h"
</ins><span class="cx"> #include "PluginViewBase.h"
</span><span class="cx"> #include "RuntimeApplicationChecks.h"
</span><span class="cx"> #include "ScriptDisallowedScope.h"
</span><span class="lines">@@ -554,6 +555,25 @@
</span><span class="cx">     return evaluateInWorld(sourceCode, world, exceptionDetails);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue ScriptController::executeUserAgentScriptInWorld(DOMWrapperWorld& world, const String& script, bool forceUserGesture, ExceptionDetails* exceptionDetails)
+{
+    auto& document = *m_frame.document();
+    if (!shouldAllowUserAgentScripts(document))
+        return { };
+
+    document.setHasEvaluatedUserAgentScripts();
+    return executeScriptInWorld(world, script, forceUserGesture, exceptionDetails);
+}
+
+bool ScriptController::shouldAllowUserAgentScripts(Document& document) const
+{
+#if ENABLE(APPLE_PAY)
+    if (auto page = m_frame.page())
+        return page->paymentCoordinator().shouldAllowUserAgentScripts(document);
+#endif
+    return true;
+}
+
</ins><span class="cx"> bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reason)
</span><span class="cx"> {
</span><span class="cx">     if (reason == AboutToExecuteScript)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsScriptControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/ScriptController.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/ScriptController.h      2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/bindings/js/ScriptController.h 2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  *  Copyright (C) 1999 Harri Porten (porten@kde.org)
</span><span class="cx">  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
</span><del>- *  Copyright (C) 2008-2017 Apple Inc. All rights reserved.
</del><ins>+ *  Copyright (C) 2008-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *  Copyright (C) 2008 Eric Seidel <eric@webkit.org>
</span><span class="cx">  *
</span><span class="cx">  *  This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -90,8 +90,11 @@
</span><span class="cx"> 
</span><span class="cx">     JSC::JSValue executeScript(const ScriptSourceCode&, ExceptionDetails* = nullptr);
</span><span class="cx">     WEBCORE_EXPORT JSC::JSValue executeScript(const String& script, bool forceUserGesture = false, ExceptionDetails* = nullptr);
</span><del>-    WEBCORE_EXPORT JSC::JSValue executeScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture = false, ExceptionDetails* = nullptr);
</del><ins>+    JSC::JSValue executeScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture = false, ExceptionDetails* = nullptr);
+    WEBCORE_EXPORT JSC::JSValue executeUserAgentScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture, ExceptionDetails* = nullptr);
</ins><span class="cx"> 
</span><ins>+    bool shouldAllowUserAgentScripts(Document&) const;
+
</ins><span class="cx">     // Returns true if argument is a JavaScript URL.
</span><span class="cx">     bool executeIfJavaScriptURL(const URL&, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/dom/Document.cpp       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -7549,12 +7549,15 @@
</span><span class="cx">     if (m_hasInjectedPlugInsScript)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    auto& scriptController = frame()->script();
+
</ins><span class="cx">     // Use the JS file provided by the Chrome client, or fallback to the default one.
</span><span class="cx">     String jsString = page()->chrome().client().plugInExtraScript();
</span><del>-    if (!jsString)
</del><ins>+    if (!jsString || !scriptController.shouldAllowUserAgentScripts(*this))
</ins><span class="cx">         jsString = String(plugInsJavaScript, sizeof(plugInsJavaScript));
</span><span class="cx"> 
</span><del>-    frame()->script().evaluateInWorld(ScriptSourceCode(jsString), world);
</del><ins>+    setHasEvaluatedUserAgentScripts();
+    scriptController.evaluateInWorld(ScriptSourceCode(jsString), world);
</ins><span class="cx"> 
</span><span class="cx">     m_hasInjectedPlugInsScript = true;
</span><span class="cx"> }
</span><span class="lines">@@ -8726,4 +8729,53 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+bool Document::hasEvaluatedUserAgentScripts() const
+{
+    auto& top = topDocument();
+    return this == &top ? m_hasEvaluatedUserAgentScripts : top.hasEvaluatedUserAgentScripts();
+}
+
+bool Document::isRunningUserScripts() const
+{
+    auto& top = topDocument();
+    return this == &top ? m_isRunningUserScripts : top.isRunningUserScripts();
+}
+
+void Document::setAsRunningUserScripts()
+{
+    auto& top = topDocument();
+    if (this == &top)
+        m_isRunningUserScripts = true;
+    else
+        top.setAsRunningUserScripts();
+}
+
+void Document::setHasEvaluatedUserAgentScripts()
+{
+    auto& top = topDocument();
+    if (this == &top)
+        m_hasEvaluatedUserAgentScripts = true;
+    else
+        top.setHasEvaluatedUserAgentScripts();
+}
+
+#if ENABLE(APPLE_PAY)
+
+bool Document::hasStartedApplePaySession() const
+{
+    auto& top = topDocument();
+    return this == &top ? m_hasStartedApplePaySession : top.hasStartedApplePaySession();
+}
+
+void Document::setHasStartedApplePaySession()
+{
+    auto& top = topDocument();
+    if (this == &top)
+        m_hasStartedApplePaySession = true;
+    else
+        top.setHasStartedApplePaySession();
+}
+
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h      2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/dom/Document.h 2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -3,7 +3,7 @@
</span><span class="cx">  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><span class="cx">  *           (C) 2001 Dirk Mueller (mueller@kde.org)
</span><span class="cx">  *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
</span><del>- * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
</span><span class="cx">  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx">  * Copyright (C) 2011 Google Inc. All rights reserved.
</span><span class="lines">@@ -1537,8 +1537,14 @@
</span><span class="cx">     void setPaintWorkletGlobalScopeForName(const String& name, Ref<PaintWorkletGlobalScope>&&);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    void setAsRunningUserScripts() { m_isRunningUserScripts = true; }
-    bool isRunningUserScripts() const { return m_isRunningUserScripts; }
</del><ins>+    WEBCORE_EXPORT bool hasEvaluatedUserAgentScripts() const;
+    WEBCORE_EXPORT bool isRunningUserScripts() const;
+    WEBCORE_EXPORT void setAsRunningUserScripts();
+    void setHasEvaluatedUserAgentScripts();
+#if ENABLE(APPLE_PAY)
+    WEBCORE_EXPORT bool hasStartedApplePaySession() const;
+    WEBCORE_EXPORT void setHasStartedApplePaySession();
+#endif
</ins><span class="cx"> 
</span><span class="cx">     void frameWasDisconnectedFromOwner();
</span><span class="cx"> 
</span><span class="lines">@@ -2095,7 +2101,11 @@
</span><span class="cx">     HashMap<String, Ref<PaintWorkletGlobalScope>> m_paintWorkletGlobalScopes;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    bool m_hasEvaluatedUserAgentScripts { false };
</ins><span class="cx">     bool m_isRunningUserScripts { false };
</span><ins>+#if ENABLE(APPLE_PAY)
+    bool m_hasStartedApplePaySession { false };
+#endif
</ins><span class="cx"> 
</span><span class="cx">     Ref<UndoManager> m_undoManager;
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentThreadableLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp    2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -147,7 +147,7 @@
</span><span class="cx">     if (shouldSetHTTPHeadersToKeep())
</span><span class="cx">         m_options.httpHeadersToKeep = httpHeadersToKeepFromCleaning(request.httpHeaderFields());
</span><span class="cx"> 
</span><del>-    if (document.topDocument().isRunningUserScripts() && SchemeRegistry::isUserExtensionScheme(request.url().protocol().toStringWithoutCopying())) {
</del><ins>+    if (document.isRunningUserScripts() && SchemeRegistry::isUserExtensionScheme(request.url().protocol().toStringWithoutCopying())) {
</ins><span class="cx">         m_options.mode = FetchOptions::Mode::NoCors;
</span><span class="cx">         m_options.filteringPolicy = ResponseFilteringPolicy::Disable;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorepageFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Frame.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Frame.cpp      2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/page/Frame.cpp 2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx">  *                     2000 Simon Hausmann <hausmann@kde.org>
</span><span class="cx">  *                     2000 Stefan Schimanski <1Stein@gmx.de>
</span><span class="cx">  *                     2001 George Staikos <staikos@kde.org>
</span><del>- * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
</span><span class="cx">  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
</span><span class="cx">  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
</span><span class="lines">@@ -769,8 +769,10 @@
</span><span class="cx">         return;
</span><span class="cx">     if (!UserContentURLPattern::matchesPatterns(document->url(), script.whitelist(), script.blacklist()))
</span><span class="cx">         return;
</span><ins>+    if (!m_script->shouldAllowUserAgentScripts(*document))
+        return;
</ins><span class="cx"> 
</span><del>-    document->topDocument().setAsRunningUserScripts();
</del><ins>+    document->setAsRunningUserScripts();
</ins><span class="cx">     loader().client().willInjectUserScript(world);
</span><span class="cx">     m_script->evaluateInWorld(ScriptSourceCode(script.source(), URL(script.url())), world);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsyaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.yaml (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.yaml  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/page/Settings.yaml     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -662,7 +662,7 @@
</span><span class="cx">   initial: true
</span><span class="cx"> applePayEnabled:
</span><span class="cx">   conditional: APPLE_PAY
</span><del>-  initial: false
</del><ins>+  initial: defaultApplePayEnabled
</ins><span class="cx"> applePayRemoteUIEnabled:
</span><span class="cx">   conditional: APPLE_PAY_REMOTE_UI
</span><span class="cx">   initial: true
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsDefaultValuesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/SettingsDefaultValues.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/SettingsDefaultValues.h        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/page/SettingsDefaultValues.h   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -109,5 +109,11 @@
</span><span class="cx"> #else
</span><span class="cx"> static const bool defaultConicGradient = false;
</span><span class="cx"> #endif
</span><ins>+    
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+static const bool defaultApplePayEnabled = true;
+#else
+static const bool defaultApplePayEnabled = false;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp       2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/testing/Internals.cpp  2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -4541,9 +4541,16 @@
</span><span class="cx"> 
</span><span class="cx"> void Internals::setAsRunningUserScripts(Document& document)
</span><span class="cx"> {
</span><del>-    document.topDocument().setAsRunningUserScripts();
</del><ins>+    document.setAsRunningUserScripts();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(APPLE_PAY)
+void Internals::setHasStartedApplePaySession(Document& document)
+{
+    document.setHasStartedApplePaySession();
+}
+#endif
+
</ins><span class="cx"> #if ENABLE(WEBGL)
</span><span class="cx"> void Internals::simulateWebGLContextChanged(WebGLRenderingContext& context)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h 2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/testing/Internals.h    2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -667,6 +667,9 @@
</span><span class="cx">     void setQuickLookPassword(const String&);
</span><span class="cx"> 
</span><span class="cx">     void setAsRunningUserScripts(Document&);
</span><ins>+#if ENABLE(APPLE_PAY)
+    void setHasStartedApplePaySession(Document&);
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBGL)
</span><span class="cx">     void simulateWebGLContextChanged(WebGLRenderingContext&);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl       2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/testing/Internals.idl  2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -651,6 +651,7 @@
</span><span class="cx">     void setQuickLookPassword(DOMString password);
</span><span class="cx"> 
</span><span class="cx">     [CallWith=Document] void setAsRunningUserScripts();
</span><ins>+    [CallWith=Document, Conditional=APPLE_PAY] void setHasStartedApplePaySession();
</ins><span class="cx"> 
</span><span class="cx">     void disableTileSizeUpdateDelay();
</span><span class="cx">     void setSpeculativeTilingDelayDisabledForTesting(boolean disabled);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockPaymentCoordinatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockPaymentCoordinator.h    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.h       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -60,6 +60,9 @@
</span><span class="cx">     const MockPaymentContactFields& requiredBillingContactFields() const { return m_requiredBillingContactFields; }
</span><span class="cx">     const MockPaymentContactFields& requiredShippingContactFields() const { return m_requiredShippingContactFields; }
</span><span class="cx"> 
</span><ins>+    bool supportsUnrestrictedApplePay() const final { return m_supportsUnrestrictedApplePay; }
+    void setSupportsUnrestrictedApplePay(bool supports) { m_supportsUnrestrictedApplePay = supports; }
+
</ins><span class="cx">     void ref() const { }
</span><span class="cx">     void deref() const { }
</span><span class="cx"> 
</span><span class="lines">@@ -66,8 +69,8 @@
</span><span class="cx"> private:
</span><span class="cx">     Optional<String> validatedPaymentNetwork(const String&) final;
</span><span class="cx">     bool canMakePayments() final;
</span><del>-    void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&&);
-    void openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&&);
</del><ins>+    void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&&) final;
+    void openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&&) final;
</ins><span class="cx">     bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final;
</span><span class="cx">     void completeMerchantValidation(const PaymentMerchantSession&) final;
</span><span class="cx">     void completeShippingMethodSelection(Optional<ShippingMethodUpdate>&&) final;
</span><span class="lines">@@ -93,6 +96,7 @@
</span><span class="cx">     HashSet<String, ASCIICaseInsensitiveHash> m_availablePaymentNetworks;
</span><span class="cx">     MockPaymentContactFields m_requiredBillingContactFields;
</span><span class="cx">     MockPaymentContactFields m_requiredShippingContactFields;
</span><ins>+    bool m_supportsUnrestrictedApplePay { true };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoretestingMockPaymentCoordinatoridl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.idl (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/MockPaymentCoordinator.idl  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.idl     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -41,4 +41,6 @@
</span><span class="cx">     readonly attribute sequence<ApplePayShippingMethod> shippingMethods;
</span><span class="cx">     readonly attribute MockPaymentContactFields requiredBillingContactFields;
</span><span class="cx">     readonly attribute MockPaymentContactFields requiredShippingContactFields;
</span><ins>+
+    attribute boolean supportsUnrestrictedApplePay;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/ChangeLog       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2019-03-21  Andy Estes  <aestes@apple.com>
+
+        [iOS] Apple Pay should be available in documents with no user agent scripts
+        https://bugs.webkit.org/show_bug.cgi?id=196061
+        <rdar://problem/48649391>
+
+        Reviewed by Brady Eidson.
+
+        * Shared/AuxiliaryProcess.h:
+        * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
+        (WebKit::AuxiliaryProcess::parentProcessHasEntitlement):
+
+        Added a convenience function for checking parent process entitlements.
+
+        * Shared/WebPreferences.yaml:
+        * Shared/WebPreferencesDefaultValues.h:
+        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+        (-[WKWebViewConfiguration init]):
+
+        Enabled Apple Pay by default on platforms that enable APPLE_PAY_REMOTE_UI.
+
+        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
+        (WebKit::WebPaymentCoordinator::supportsUnrestrictedApplePay const):
+        * WebProcess/ApplePay/WebPaymentCoordinator.h:
+
+        Implemented supportsUnrestrictedApplePay by checking for the
+        com.apple.private.WebKit.UnrestrictedApplePay entitlement on platforms that enable
+        APPLE_PAY_REMOTE_UI.
+
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h:
+        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
+        (didClearWindowObjectForFrame):
+        (setUpPageLoaderClient):
+
+        Added injected bundle SPI that TestWebKitAPI uses to inject the WebCore Internals interface.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::runJavaScript):
+
+        Changed to call ScriptController::executeUserAgentScriptInWorld.
+
</ins><span class="cx"> 2019-03-21  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         WebKit should throw when trying to create a WKWebView with a related view that is using a different data store
</span></span></pre></div>
<a id="trunkSourceWebKitSharedAuxiliaryProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/AuxiliaryProcess.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/AuxiliaryProcess.h    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/Shared/AuxiliaryProcess.h       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -78,6 +78,10 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     static bool isSystemWebKit();
</span><span class="cx"> #endif
</span><ins>+    
+#if PLATFORM(COCOA)
+    bool parentProcessHasEntitlement(const char* entitlement);
+#endif
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     explicit AuxiliaryProcess();
</span></span></pre></div>
<a id="trunkSourceWebKitSharedCocoaAuxiliaryProcessCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2017 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #import "AuxiliaryProcess.h"
</span><span class="cx"> 
</span><span class="cx"> #import "WKCrashReporter.h"
</span><ins>+#import <wtf/cocoa/Entitlements.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="lines">@@ -36,4 +37,9 @@
</span><span class="cx">     CRASH();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool AuxiliaryProcess::parentProcessHasEntitlement(const char* entitlement)
+{
+    return WTF::hasEntitlement(m_connection->xpcConnection(), entitlement);
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitSharedWebPreferencesyaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPreferences.yaml   2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml      2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -678,7 +678,7 @@
</span><span class="cx"> 
</span><span class="cx"> ApplePayEnabled:
</span><span class="cx">   type: bool
</span><del>-  defaultValue: false
</del><ins>+  defaultValue: DEFAULT_APPLE_PAY_ENABLED
</ins><span class="cx">   condition: ENABLE(APPLE_PAY)
</span><span class="cx"> 
</span><span class="cx"> ApplePayCapabilityDisclosureAllowed:
</span></span></pre></div>
<a id="trunkSourceWebKitSharedWebPreferencesDefaultValuesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h    2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -259,3 +259,9 @@
</span><span class="cx"> #define DEFAULT_FAST_CLICKS_EVERYWHERE true
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><ins>+
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+#define DEFAULT_APPLE_PAY_ENABLED true
+#else
+#define DEFAULT_APPLE_PAY_ENABLED false
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewConfigurationmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -249,6 +249,10 @@
</span><span class="cx">     _editableImagesEnabled = NO;
</span><span class="cx">     _undoManagerAPIEnabled = NO;
</span><span class="cx"> 
</span><ins>+#if ENABLE(APPLE_PAY)
+    _applePayEnabled = DEFAULT_APPLE_PAY_ENABLED;
+#endif
+
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessApplePayWebPaymentCoordinatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -157,6 +157,16 @@
</span><span class="cx">     delete this;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebPaymentCoordinator::supportsUnrestrictedApplePay() const
+{
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+    static bool hasEntitlement = WebProcess::singleton().parentProcessHasEntitlement("com.apple.private.WebKit.UnrestrictedApplePay");
+    return hasEntitlement;
+#else
+    return true;
+#endif
+}
+
</ins><span class="cx"> IPC::Connection* WebPaymentCoordinator::messageSenderConnection() const
</span><span class="cx"> {
</span><span class="cx"> #if ENABLE(APPLE_PAY_REMOTE_UI)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessApplePayWebPaymentCoordinatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -78,9 +78,11 @@
</span><span class="cx"> 
</span><span class="cx">     bool isWebPaymentCoordinator() const override { return true; }
</span><span class="cx"> 
</span><ins>+    bool supportsUnrestrictedApplePay() const override;
+
</ins><span class="cx">     // IPC::MessageReceiver.
</span><span class="cx">     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
</span><del>-    
</del><ins>+
</ins><span class="cx">     // IPC::MessageSender.
</span><span class="cx">     IPC::Connection* messageSenderConnection() const final;
</span><span class="cx">     uint64_t messageSenderDestinationID() const final;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleAPICocoaWKWebProcessPlugInLoadDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h 2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h    2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didFailLoadWithErrorForFrame:(WKWebProcessPlugInFrame *)frame error:(NSError *)error;
</span><span class="cx"> - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didFinishLoadForFrame:(WKWebProcessPlugInFrame *)frame;
</span><span class="cx"> - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didSameDocumentNavigation:(_WKSameDocumentNavigationType)navigationType forFrame:(WKWebProcessPlugInFrame *)frame;
</span><ins>+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didClearWindowObjectForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld;
</ins><span class="cx"> - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller globalObjectIsAvailableForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld;
</span><span class="cx"> - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didRemoveFrameFromHierarchy:(WKWebProcessPlugInFrame *)frame;
</span><span class="cx"> - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didHandleOnloadEventsForFrame:(WKWebProcessPlugInFrame *)frame;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessInjectedBundleAPImacWKWebProcessPlugInBrowserContextControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm      2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm 2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -104,6 +104,15 @@
</span><span class="cx">         [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFinishLoadForFrame:wrapper(*WebKit::toImpl(frame))];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void didClearWindowObjectForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void* clientInfo)
+{
+    auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo;
+    auto loadDelegate = pluginContextController->_loadDelegate.get();
+    
+    if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:)])
+        [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didClearWindowObjectForFrame:wrapper(*WebKit::toImpl(frame)) inScriptWorld:wrapper(*WebKit::toImpl(scriptWorld))];
+}
+
</ins><span class="cx"> static void globalObjectIsAvailableForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void* clientInfo)
</span><span class="cx"> {
</span><span class="cx">     auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo;
</span><span class="lines">@@ -235,6 +244,7 @@
</span><span class="cx">     client.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
</span><span class="cx">     client.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame;
</span><span class="cx">     client.didFinishLoadForFrame = didFinishLoadForFrame;
</span><ins>+    client.didClearWindowObjectForFrame = didClearWindowObjectForFrame;
</ins><span class="cx">     client.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrame;
</span><span class="cx">     client.didRemoveFrameFromHierarchy = didRemoveFrameFromHierarchy;
</span><span class="cx">     client.didHandleOnloadEventsForFrame = didHandleOnloadEventsForFrame;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -3289,7 +3289,7 @@
</span><span class="cx">     ExceptionDetails details;
</span><span class="cx">     auto* world = worldName ? InjectedBundleScriptWorld::find(worldName.value()) : &InjectedBundleScriptWorld::normalWorld();
</span><span class="cx">     if (world) {
</span><del>-        if (JSValue resultValue = m_mainFrame->coreFrame()->script().executeScriptInWorld(world->coreWorld(), script, forceUserGesture, &details)) {
</del><ins>+        if (JSValue resultValue = m_mainFrame->coreFrame()->script().executeUserAgentScriptInWorld(world->coreWorld(), script, forceUserGesture, &details)) {
</ins><span class="cx">             hadException = false;
</span><span class="cx">             serializedResultValue = SerializedScriptValue::create(m_mainFrame->jsContextForWorld(world),
</span><span class="cx">                 toRef(m_mainFrame->coreFrame()->script().globalObject(world->coreWorld())->globalExec(), resultValue), nullptr);
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/ChangeLog  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2019-03-21  Andy Estes  <aestes@apple.com>
+
+        [iOS] Apple Pay should be available in documents with no user agent scripts
+        https://bugs.webkit.org/show_bug.cgi?id=196061
+        <rdar://problem/48649391>
+
+        Reviewed by Brady Eidson.
+
+        * WebView/WebFrame.mm:
+        (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
+
</ins><span class="cx"> 2019-03-20  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Rename ENABLE_ACCELERATED_OVERFLOW_SCROLLING macro to ENABLE_OVERFLOW_SCROLLING_TOUCH
</span></span></pre></div>
<a id="trunkSourceWebKitLegacymacWebViewWebFramemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -2102,7 +2102,7 @@
</span><span class="cx">     ASSERT(frame->document());
</span><span class="cx">     RetainPtr<WebFrame> webFrame(kit(frame)); // Running arbitrary JavaScript can destroy the frame.
</span><span class="cx"> 
</span><del>-    JSC::JSValue result = frame->script().executeScriptInWorld(*core(world), string, true);
</del><ins>+    JSC::JSValue result = frame->script().executeUserAgentScriptInWorld(*core(world), string, true);
</ins><span class="cx"> 
</span><span class="cx">     if (!webFrame->_private->coreFrame) // In case the script removed our frame from the page.
</span><span class="cx">         return @"";
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Tools/ChangeLog       2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2019-03-21  Andy Estes  <aestes@apple.com>
+
+        [iOS] Apple Pay should be available in documents with no user agent scripts
+        https://bugs.webkit.org/show_bug.cgi?id=196061
+        <rdar://problem/48649391>
+
+        Reviewed by Brady Eidson.
+
+        Added API tests and related infrastructure.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm: Added.
+        (-[TestApplePayScriptMessageHandler initWithExpectation:]):
+        (-[TestApplePayScriptMessageHandler userContentController:didReceiveScriptMessage:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html: Added.
+        * TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html: Added.
+        * TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html: Added.
+        * TestWebKitAPI/cocoa/TestProtocol.mm:
+        (-[TestProtocol startLoading]):
+        * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h: Added.
+        * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm: Added.
+        (-[WebProcessPlugInWithInternals webProcessPlugIn:didCreateBrowserContextController:]):
+        (-[WebProcessPlugInWithInternals webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
+
</ins><span class="cx"> 2019-03-21  Jonathan Bedard  <jbedard@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSSION (r243297): webkitpy tests broken
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -702,6 +702,12 @@
</span><span class="cx">          A155022A1E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm in Sources */ = {isa = PBXBuildFile; fileRef = A15502281E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm */; };
</span><span class="cx">          A155022C1E050D0300A24C57 /* duplicate-completion-handler-calls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A155022B1E050BC500A24C57 /* duplicate-completion-handler-calls.html */; };
</span><span class="cx">          A16F66BA1C40EB4F00BD4D24 /* ContentFiltering.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */; };
</span><ins>+               A1798B7F22431D2B000764BD /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */; };
+               A1798B8222431D65000764BD /* ApplePay.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1798B8122431D65000764BD /* ApplePay.mm */; };
+               A1798B8522433647000764BD /* WebProcessPlugInWithInternals.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1798B8422433647000764BD /* WebProcessPlugInWithInternals.mm */; };
+               A1798B872243449B000764BD /* apple-pay-availability.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1798B862243446B000764BD /* apple-pay-availability.html */; };
+               A1798B8922435E29000764BD /* apple-pay-availability-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1798B8822435D2E000764BD /* apple-pay-availability-in-iframe.html */; };
+               A1798B8B224361A4000764BD /* apple-pay-active-session.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1798B8A2243611A000764BD /* apple-pay-active-session.html */; };
</ins><span class="cx">           A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A17991861E1C994E00A505ED /* SharedBuffer.mm */; };
</span><span class="cx">          A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17991891E1CA24100A505ED /* SharedBufferTest.cpp */; };
</span><span class="cx">          A17EAC55208305A00084B41B /* find.pdf in Copy Resources */ = {isa = PBXBuildFile; fileRef = A17EAC542083056E0084B41B /* find.pdf */; };
</span><span class="lines">@@ -1018,6 +1024,9 @@
</span><span class="cx">                          1A63479F183D72A4005B1707 /* all-content-in-one-iframe.html in Copy Resources */,
</span><span class="cx">                          C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
</span><span class="cx">                          F4A9202F1FEE34E900F59590 /* apple-data-url.html in Copy Resources */,
</span><ins>+                               A1798B8B224361A4000764BD /* apple-pay-active-session.html in Copy Resources */,
+                               A1798B8922435E29000764BD /* apple-pay-availability-in-iframe.html in Copy Resources */,
+                               A1798B872243449B000764BD /* apple-pay-availability.html in Copy Resources */,
</ins><span class="cx">                           F46A095A1ED8A6E600D4AA55 /* apple.gif in Copy Resources */,
</span><span class="cx">                          5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */,
</span><span class="cx">                          5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */,
</span><span class="lines">@@ -1956,6 +1965,13 @@
</span><span class="cx">          A15502281E05020B00A24C57 /* DuplicateCompletionHandlerCalls.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DuplicateCompletionHandlerCalls.mm; sourceTree = "<group>"; };
</span><span class="cx">          A155022B1E050BC500A24C57 /* duplicate-completion-handler-calls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "duplicate-completion-handler-calls.html"; sourceTree = "<group>"; };
</span><span class="cx">          A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContentFiltering.html; sourceTree = "<group>"; };
</span><ins>+               A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
+               A1798B8122431D65000764BD /* ApplePay.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplePay.mm; sourceTree = "<group>"; };
+               A1798B8322433647000764BD /* WebProcessPlugInWithInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebProcessPlugInWithInternals.h; sourceTree = "<group>"; };
+               A1798B8422433647000764BD /* WebProcessPlugInWithInternals.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessPlugInWithInternals.mm; sourceTree = "<group>"; };
+               A1798B862243446B000764BD /* apple-pay-availability.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-pay-availability.html"; sourceTree = "<group>"; };
+               A1798B8822435D2E000764BD /* apple-pay-availability-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-pay-availability-in-iframe.html"; sourceTree = "<group>"; };
+               A1798B8A2243611A000764BD /* apple-pay-active-session.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-pay-active-session.html"; sourceTree = "<group>"; };
</ins><span class="cx">           A17991861E1C994E00A505ED /* SharedBuffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SharedBuffer.mm; sourceTree = "<group>"; };
</span><span class="cx">          A17991891E1CA24100A505ED /* SharedBufferTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBufferTest.cpp; sourceTree = "<group>"; };
</span><span class="cx">          A179918A1E1CA24100A505ED /* SharedBufferTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferTest.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -2364,6 +2380,14 @@
</span><span class="cx">                  );
</span><span class="cx">                  runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">          };
</span><ins>+               A1798B7D22431D18000764BD /* Frameworks */ = {
+                       isa = PBXFrameworksBuildPhase;
+                       buildActionMask = 2147483647;
+                       files = (
+                               A1798B7F22431D2B000764BD /* libWebCoreTestSupport.dylib in Frameworks */,
+                       );
+                       runOnlyForDeploymentPostprocessing = 0;
+               };
</ins><span class="cx">           BC57597E126E74AF006F0F12 /* Frameworks */ = {
</span><span class="cx">                  isa = PBXFrameworksBuildPhase;
</span><span class="cx">                  buildActionMask = 2147483647;
</span><span class="lines">@@ -2485,6 +2509,7 @@
</span><span class="cx">                          55A817FB218100E00004A39A /* AdditionalSupportedImageTypes.mm */,
</span><span class="cx">                          A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
</span><span class="cx">                          2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */,
</span><ins>+                               A1798B8122431D65000764BD /* ApplePay.mm */,
</ins><span class="cx">                           63F668201F97C3AA0032EE51 /* ApplicationManifest.mm */,
</span><span class="cx">                          834138C6203261B900F26960 /* AsyncPolicyForNavigationResponse.mm */,
</span><span class="cx">                          3760C4F0211249AF00233ACC /* AttrStyle.mm */,
</span><span class="lines">@@ -2811,6 +2836,7 @@
</span><span class="cx">                          0F4FFAA01ED3D0DE00F7111F /* ImageIO.framework */,
</span><span class="cx">                          CDA3159C1ED5643F009F60D3 /* IOKit.framework */,
</span><span class="cx">                          7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */,
</span><ins>+                               A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */,
</ins><span class="cx">                           4135FB862011FABF00332139 /* libWebCoreTestSupport.dylib */,
</span><span class="cx">                          7C83E0291D0A5CDF00FEBCF3 /* libWTF.a */,
</span><span class="cx">                          578CBD66204FB2C70083B9F2 /* LocalAuthentication.framework */,
</span><span class="lines">@@ -2847,6 +2873,8 @@
</span><span class="cx">                  children = (
</span><span class="cx">                          A13EBB541B8734E000097110 /* Info.plist */,
</span><span class="cx">                          A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */,
</span><ins>+                               A1798B8322433647000764BD /* WebProcessPlugInWithInternals.h */,
+                               A1798B8422433647000764BD /* WebProcessPlugInWithInternals.mm */,
</ins><span class="cx">                   );
</span><span class="cx">                  name = WebProcessPlugIn;
</span><span class="cx">                  path = cocoa/WebProcessPlugIn;
</span><span class="lines">@@ -2859,6 +2887,9 @@
</span><span class="cx">                          55A817FD218101DF0004A39A /* 400x400-green.png */,
</span><span class="cx">                          C25CCA0C1E5140E50026CB8A /* AllAhem.svg */,
</span><span class="cx">                          F4A9202E1FEE34C800F59590 /* apple-data-url.html */,
</span><ins>+                               A1798B8A2243611A000764BD /* apple-pay-active-session.html */,
+                               A1798B8822435D2E000764BD /* apple-pay-availability-in-iframe.html */,
+                               A1798B862243446B000764BD /* apple-pay-availability.html */,
</ins><span class="cx">                           F47D30EB1ED28619000482E1 /* apple.gif */,
</span><span class="cx">                          5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */,
</span><span class="cx">                          5C9E593F1D3EB1DE00E3C62E /* ApplicationCache.db-shm */,
</span><span class="lines">@@ -3766,6 +3797,7 @@
</span><span class="cx">                  buildConfigurationList = A13EBB4C1B87339E00097110 /* Build configuration list for PBXNativeTarget "WebProcessPlugIn" */;
</span><span class="cx">                  buildPhases = (
</span><span class="cx">                          A13EBB451B87339E00097110 /* Sources */,
</span><ins>+                               A1798B7D22431D18000764BD /* Frameworks */,
</ins><span class="cx">                   );
</span><span class="cx">                  buildRules = (
</span><span class="cx">                  );
</span><span class="lines">@@ -3966,6 +3998,7 @@
</span><span class="cx">                          A1DF74321C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm in Sources */,
</span><span class="cx">                          2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */,
</span><span class="cx">                          57152B5E21CC2045000C37CA /* ApduTest.cpp in Sources */,
</span><ins>+                               A1798B8222431D65000764BD /* ApplePay.mm in Sources */,
</ins><span class="cx">                           63F668221F97F7F90032EE51 /* ApplicationManifest.mm in Sources */,
</span><span class="cx">                          6354F4D11F7C3AB500D89DF3 /* ApplicationManifestParser.cpp in Sources */,
</span><span class="cx">                          834138C7203261CA00F26960 /* AsyncPolicyForNavigationResponse.mm in Sources */,
</span><span class="lines">@@ -4455,6 +4488,7 @@
</span><span class="cx">                          7C882E091C80C630006BF731 /* UserContentWorldPlugIn.mm in Sources */,
</span><span class="cx">                          7C83E03D1D0A60D600FEBCF3 /* UtilitiesCocoa.mm in Sources */,
</span><span class="cx">                          A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
</span><ins>+                               A1798B8522433647000764BD /* WebProcessPlugInWithInternals.mm in Sources */,
</ins><span class="cx">                   );
</span><span class="cx">                  runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">          };
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaApplePaymm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm (0 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm                          (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -0,0 +1,158 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if ENABLE(APPLE_PAY_REMOTE_UI)
+
+#import "PlatformUtilities.h"
+#import "Test.h"
+#import "TestNavigationDelegate.h"
+#import "TestProtocol.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKUserContentControllerPrivate.h>
+#import <WebKit/WebKit.h>
+
+static bool isDone;
+
+@interface TestApplePayScriptMessageHandler : NSObject <WKScriptMessageHandler>
+
+- (instancetype)init NS_UNAVAILABLE;
+- (instancetype)initWithExpectation:(BOOL)expectation;
+
+@end
+
+@implementation TestApplePayScriptMessageHandler {
+    BOOL _expectation;
+}
+
+- (instancetype)initWithExpectation:(BOOL)expectation
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _expectation = expectation;
+    return self;
+}
+
+- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
+{
+    EXPECT_EQ(_expectation, [[message.body objectForKey:@"supportsVersion"] boolValue]);
+    EXPECT_EQ(_expectation, [[message.body objectForKey:@"canMakePayments"] boolValue]);
+    EXPECT_EQ(_expectation, [[message.body objectForKey:@"canMakePaymentsWithActiveCard"] boolValue]);
+    EXPECT_EQ(_expectation, [[message.body objectForKey:@"canMakePayment"] boolValue]);
+    isDone = true;
+}
+
+@end
+
+namespace TestWebKitAPI {
+    
+TEST(ApplePay, ApplePayAvailableByDefault)
+{
+    [TestProtocol registerWithScheme:@"https"];
+
+    auto messageHandler = adoptNS([[TestApplePayScriptMessageHandler alloc] initWithExpectation:YES]);
+
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals"];
+    [configuration.userContentController addScriptMessageHandler:messageHandler.get() name:@"testApplePay"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectZero configuration:configuration]);
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://bundle-html-file/apple-pay-availability"]]];
+
+    Util::run(&isDone);
+
+    [TestProtocol unregister];
+}
+
+TEST(ApplePay, UserScriptDisablesApplePay)
+{
+    [TestProtocol registerWithScheme:@"https"];
+
+    auto messageHandler = adoptNS([[TestApplePayScriptMessageHandler alloc] initWithExpectation:NO]);
+    auto userScript = adoptNS([[WKUserScript alloc] initWithSource:@"window.wkUserScriptInjected = true" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES]);
+
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals"];
+    [configuration.userContentController addUserScript:userScript.get()];
+    [configuration.userContentController addScriptMessageHandler:messageHandler.get() name:@"testApplePay"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectZero configuration:configuration]);
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://bundle-html-file/apple-pay-availability"]]];
+
+    Util::run(&isDone);
+
+    EXPECT_EQ(YES, [[webView objectByEvaluatingJavaScript:@"window.wkUserScriptInjected"] boolValue]);
+
+    [TestProtocol unregister];
+}
+
+TEST(ApplePay, UserAgentScriptEvaluationDisablesApplePay)
+{
+    [TestProtocol registerWithScheme:@"https"];
+
+    auto messageHandler = adoptNS([[TestApplePayScriptMessageHandler alloc] initWithExpectation:NO]);
+
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals"];
+    [configuration.userContentController addScriptMessageHandler:messageHandler.get() name:@"testApplePay"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectZero configuration:configuration]);
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://bundle-html-file/apple-pay-availability-in-iframe"]]];
+    [webView _test_waitForDidFinishNavigation];
+    [webView evaluateJavaScript:@"window.wkScriptEvaluated = true; loadApplePayFrame();" completionHandler:nil];
+
+    Util::run(&isDone);
+
+    EXPECT_EQ(YES, [[webView objectByEvaluatingJavaScript:@"window.wkScriptEvaluated"] boolValue]);
+
+    [TestProtocol unregister];
+}
+
+TEST(ApplePay, ActiveSessionBlocksUserAgentScripts)
+{
+    [TestProtocol registerWithScheme:@"https"];
+
+    auto userScript = adoptNS([[WKUserScript alloc] initWithSource:@"window.wkUserScriptInjected = true" injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES]);
+
+    WKWebViewConfiguration *configuration = [WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals"];
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectZero configuration:configuration]);
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://bundle-html-file/apple-pay-active-session"]]];
+    [webView _test_waitForDidFinishNavigation];
+
+    [configuration.userContentController _addUserScriptImmediately:userScript.get()];
+    [webView evaluateJavaScript:@"window.wkUserScriptInjected" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
+        EXPECT_NULL(result);
+        EXPECT_NOT_NULL(error);
+        isDone = true;
+    }];
+    Util::run(&isDone);
+
+    [TestProtocol unregister];
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(APPLE_PAY_REMOTE_UI)
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaapplepayactivesessionhtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html (0 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+<!DOCTYPE html>
+<body>
+<script>
+    internals.mockPaymentCoordinator.supportsUnrestrictedApplePay = false;
+    internals.setHasStartedApplePaySession();
+</script>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaapplepayavailabilityiniframehtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html (0 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+<!DOCTYPE html>
+<body>
+<script>
+    loadApplePayFrame = () => {
+        const iframe = document.createElement('iframe');
+        iframe.src = 'https://bundle-html-file/apple-pay-availability';
+        document.body.appendChild(iframe);
+    };
+</script>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKitCocoaapplepayavailabilityhtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html (0 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html                          (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+<!DOCTYPE html>
+<body>
+<script>
+    const applePayRequestBase = () => {
+        return {
+            merchantCapabilities: ['supports3DS'],
+            supportedNetworks: ['visa'],
+            countryCode: 'US',
+        };
+    };
+
+    const applePayPaymentRequest = () => {
+        const request = applePayRequestBase();
+        request.total = { label: 'total', amount: '0.00' };
+        request.currencyCode = 'USD';
+        return request;
+    };
+
+    const applePayMethod = () => {
+        const request = applePayRequestBase();
+        request.version = 1;
+        request.merchantIdentifier = '';
+        return {
+            supportedMethods: 'https://apple.com/apple-pay',
+            data: request,
+        };
+    };
+
+    window.addEventListener('load', async () => {
+        internals.mockPaymentCoordinator.supportsUnrestrictedApplePay = false;
+
+        const supportsVersion = ApplePaySession.supportsVersion(1);
+        const canMakePayments = ApplePaySession.canMakePayments();
+        const canMakePaymentsWithActiveCard = await ApplePaySession.canMakePaymentsWithActiveCard('');
+
+        const paymentRequest = new PaymentRequest([applePayMethod()], {
+            total: {
+                label: 'total',
+                amount: { currency: 'USD', value: '0.00' },
+            },
+        });
+
+        const canMakePayment = await paymentRequest.canMakePayment();
+
+        window.webkit.messageHandlers.testApplePay.postMessage({
+            supportsVersion,
+            canMakePayments,
+            canMakePaymentsWithActiveCard,
+            canMakePayment,
+        });
+    });
+</script>
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaTestProtocolmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/cocoa/TestProtocol.mm (243323 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/TestProtocol.mm  2019-03-21 20:47:34 UTC (rev 243323)
+++ trunk/Tools/TestWebKitAPI/cocoa/TestProtocol.mm     2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -86,7 +86,12 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    NSData *data = [@"PASS" dataUsingEncoding:NSASCIIStringEncoding];
</del><ins>+    NSData *data;
+    if ([requestURL.host isEqualToString:@"bundle-html-file"])
+        data = [NSData dataWithContentsOfURL:[NSBundle.mainBundle URLForResource:requestURL.lastPathComponent.stringByDeletingPathExtension withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    else
+        data = [@"PASS" dataUsingEncoding:NSASCIIStringEncoding];
+
</ins><span class="cx">     RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:requestURL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil]);
</span><span class="cx"> 
</span><span class="cx">     if ([requestURL.host isEqualToString:@"redirect"]) {
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaWebProcessPlugInWebProcessPlugInWithInternalshfromrev243323trunkSourceWebKitSharedCocoaAuxiliaryProcessCocoamm"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h (from rev 243323, trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm) (0 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h                         (rev 0)
+++ trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h    2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <WebKit/WKWebProcessPlugIn.h>
+
+@interface WebProcessPlugInWithInternals : NSObject <WKWebProcessPlugIn>
+@end
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPIcocoaWebProcessPlugInWebProcessPlugInWithInternalsmmfromrev243323trunkSourceWebKitSharedCocoaAuxiliaryProcessCocoamm"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm (from rev 243323, trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm) (0 => 243324)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm   2019-03-21 20:51:56 UTC (rev 243324)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebProcessPlugInWithInternals.h"
+
+#import "WebCoreTestSupport.h"
+#import <WebKit/WKWebProcessPlugInBrowserContextController.h>
+#import <WebKit/WKWebProcessPlugInFrame.h>
+#import <WebKit/WKWebProcessPlugInLoadDelegate.h>
+
+@interface WebProcessPlugInWithInternals () <WKWebProcessPlugInLoadDelegate>
+
+@end
+
+@implementation WebProcessPlugInWithInternals
+
+- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
+{
+    browserContextController.loadDelegate = self;
+}
+
+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didClearWindowObjectForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld
+{
+    WebCoreTestSupport::injectInternalsObject([frame jsContextForWorld:scriptWorld].JSGlobalContextRef);
+}
+
+@end
</ins></span></pre>
</div>
</div>

</body>
</html>