⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243324 in webkit


Ignore:
Timestamp:
Mar 21, 2019, 1:51:56 PM (7 years ago)
Author:
aestes@apple.com
Message:

[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.

  1. 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:]):

Location:
trunk
Files:
4 added
42 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243319 r243324  
     12019-03-21  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Apple Pay should be available in documents with no user agent scripts
     4        https://bugs.webkit.org/show_bug.cgi?id=196061
     5        <rdar://problem/48649391>
     6
     7        Reviewed by Brady Eidson.
     8
     9        On platforms that support APPLE_PAY_REMOTE_UI, we can enable Apple Pay JS and Payment Request
     10        by default in all WebKit clients.
     11
     12        In order to protect the privacy of Apple Pay transactions, this patch implements the
     13        following restrictions on API usage:
     14
     15        1. If user agent scripts have been evaluated in a document, Apple Pay APIs will no longer be
     16        available for the duration of the document's lifetime.
     17        2. If an Apple Pay transaction has started in a document, user agent scripts will no longer
     18        be evaluated for the duration of the document's lifetime.
     19
     20        These restrictions are disabled for clients with the
     21        com.apple.private.WebKit.UnrestrictedApplePay entitlement and platforms that do support
     22        Apple Pay but don't support APPLE_PAY_REMOTE_UI.
     23
     24        Added new API tests.
     25
     26        * Modules/applepay/ApplePayRequestBase.cpp:
     27        (WebCore::convertAndValidate):
     28        * Modules/applepay/ApplePayRequestBase.h:
     29        * Modules/applepay/ApplePaySession.cpp:
     30        (WebCore::convertAndValidate):
     31        (WebCore::ApplePaySession::create):
     32        (WebCore::ApplePaySession::supportsVersion):
     33        (WebCore::ApplePaySession::canMakePayments):
     34        (WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
     35        (WebCore::ApplePaySession::openPaymentSetup):
     36        (WebCore::ApplePaySession::begin):
     37        * Modules/applepay/ApplePaySession.h:
     38        * Modules/applepay/ApplePaySession.idl:
     39        * Modules/applepay/PaymentCoordinator.cpp:
     40        (WebCore::PaymentCoordinator::supportsVersion const):
     41        (WebCore::PaymentCoordinator::canMakePayments):
     42        (WebCore::PaymentCoordinator::canMakePaymentsWithActiveCard):
     43        (WebCore::PaymentCoordinator::openPaymentSetup):
     44        (WebCore::PaymentCoordinator::beginPaymentSession):
     45        (WebCore::PaymentCoordinator::validatedPaymentNetwork const):
     46        (WebCore::PaymentCoordinator::shouldAllowApplePay const):
     47        (WebCore::PaymentCoordinator::shouldAllowUserAgentScripts const):
     48        * Modules/applepay/PaymentCoordinator.h:
     49        * Modules/applepay/PaymentCoordinatorClient.h:
     50        (WebCore::PaymentCoordinatorClient::supportsUnrestrictedApplePay const):
     51        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
     52        (WebCore::ApplePayPaymentHandler::show):
     53        (WebCore::ApplePayPaymentHandler::canMakePayment):
     54        (WebCore::ApplePayPaymentHandler::version const):
     55        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
     56        * Modules/paymentrequest/PaymentHandler.h:
     57        * Modules/paymentrequest/PaymentRequest.cpp:
     58        (WebCore::PaymentRequest::show):
     59        (WebCore::PaymentRequest::canMakePayment):
     60
     61        Plumbed a Document& through to the various places that call into PaymentCoordinator for use
     62        by shouldAllowApplePay and shouldAllowUserAgentScripts.
     63
     64        * bindings/js/ScriptController.cpp:
     65        (WebCore::ScriptController::executeUserAgentScriptInWorld):
     66        (WebCore::ScriptController::shouldAllowUserAgentScripts const):
     67        * bindings/js/ScriptController.h:
     68
     69        Added executeUserAgentScriptInWorld, which calls executeScriptInWorld if allowed.
     70
     71        * dom/Document.cpp:
     72        (WebCore::Document::ensurePlugInsInjectedScript):
     73
     74        Changed to only evaluate the chrome client's plug-in extra script if allowed, and to mark
     75        the document as having evaluated user agent scripts.
     76
     77        (WebCore::Document::hasEvaluatedUserAgentScripts const):
     78        (WebCore::Document::isRunningUserScripts const):
     79        (WebCore::Document::setAsRunningUserScripts):
     80        (WebCore::Document::setHasEvaluatedUserAgentScripts):
     81        (WebCore::Document::hasStartedApplePaySession const):
     82        (WebCore::Document::setHasStartedApplePaySession):
     83        * dom/Document.h:
     84
     85        Added helper functions to set state on the top document.
     86
     87        * loader/DocumentThreadableLoader.cpp:
     88        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
     89
     90        Removed call to topDocument() now that isRunningUserScripts() always checks the top document.
     91
     92        * page/Frame.cpp:
     93        (WebCore::Frame::injectUserScriptImmediately):
     94
     95        Changed to only inject the user script if allowed.
     96
     97        * page/Settings.yaml:
     98        * page/SettingsDefaultValues.h:
     99
     100        Enabled Apple Pay by default on platforms that enable APPLE_PAY_REMOTE_UI.
     101
     102        * testing/Internals.cpp:
     103        (WebCore::Internals::setAsRunningUserScripts):
     104        (WebCore::Internals::setHasStartedApplePaySession):
     105        * testing/Internals.h:
     106        * testing/Internals.idl:
     107        * testing/MockPaymentCoordinator.h:
     108        * testing/MockPaymentCoordinator.idl:
     109
     110        Added some internal interfaces for use by TestWebKitAPI.
     111
    11122019-03-21  Alex Christensen  <achristensen@webkit.org>
    2113
  • trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp

    r241105 r243324  
    3434namespace WebCore {
    3535
    36 static ExceptionOr<Vector<String>> convertAndValidate(unsigned version, const Vector<String>& supportedNetworks, const PaymentCoordinator& paymentCoordinator)
     36static ExceptionOr<Vector<String>> convertAndValidate(Document& document, unsigned version, const Vector<String>& supportedNetworks, const PaymentCoordinator& paymentCoordinator)
    3737{
    3838    if (supportedNetworks.isEmpty())
     
    4242    result.reserveInitialCapacity(supportedNetworks.size());
    4343    for (auto& supportedNetwork : supportedNetworks) {
    44         auto validatedNetwork = paymentCoordinator.validatedPaymentNetwork(version, supportedNetwork);
     44        auto validatedNetwork = paymentCoordinator.validatedPaymentNetwork(document, version, supportedNetwork);
    4545        if (!validatedNetwork)
    4646            return Exception { TypeError, makeString("\"", supportedNetwork, "\" is not a valid payment network.") };
     
    5151}
    5252
    53 ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayRequestBase& request, const PaymentCoordinator& paymentCoordinator)
     53ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document, unsigned version, ApplePayRequestBase& request, const PaymentCoordinator& paymentCoordinator)
    5454{
    55     if (!version || !paymentCoordinator.supportsVersion(version))
     55    if (!version || !paymentCoordinator.supportsVersion(document, version))
    5656        return Exception { InvalidAccessError, makeString('"', version, "\" is not a supported version.") };
    5757
     
    6565    result.setMerchantCapabilities(merchantCapabilities.releaseReturnValue());
    6666
    67     auto supportedNetworks = convertAndValidate(version, request.supportedNetworks, paymentCoordinator);
     67    auto supportedNetworks = convertAndValidate(document, version, request.supportedNetworks, paymentCoordinator);
    6868    if (supportedNetworks.hasException())
    6969        return supportedNetworks.releaseException();
  • trunk/Source/WebCore/Modules/applepay/ApplePayRequestBase.h

    r241105 r243324  
    3434namespace WebCore {
    3535
     36class Document;
    3637class PaymentCoordinator;
    3738
     
    5152};
    5253
    53 ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayRequestBase&, const PaymentCoordinator&);
     54ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document&, unsigned version, ApplePayRequestBase&, const PaymentCoordinator&);
    5455
    5556} // namespace WebCore
  • trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp

    r241130 r243324  
    208208}
    209209
    210 static ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayPaymentRequest&& paymentRequest, const PaymentCoordinator& paymentCoordinator)
    211 {
    212     auto convertedRequest = convertAndValidate(version, paymentRequest, paymentCoordinator);
     210static ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(Document& document, unsigned version, ApplePayPaymentRequest&& paymentRequest, const PaymentCoordinator& paymentCoordinator)
     211{
     212    auto convertedRequest = convertAndValidate(document, version, paymentRequest, paymentCoordinator);
    213213    if (convertedRequest.hasException())
    214214        return convertedRequest.releaseException();
     
    400400        return Exception { InvalidAccessError, "Frame is detached" };
    401401
    402     auto convertedPaymentRequest = convertAndValidate(version, WTFMove(paymentRequest), document.page()->paymentCoordinator());
     402    auto convertedPaymentRequest = convertAndValidate(document, version, WTFMove(paymentRequest), document.page()->paymentCoordinator());
    403403    if (convertedPaymentRequest.hasException())
    404404        return convertedPaymentRequest.releaseException();
     
    412412    , m_version { version }
    413413{
    414     ASSERT(document.page()->paymentCoordinator().supportsVersion(version));
     414    ASSERT(document.page()->paymentCoordinator().supportsVersion(document, version));
    415415    suspendIfNeeded();
    416416}
     
    418418ApplePaySession::~ApplePaySession() = default;
    419419
    420 ExceptionOr<bool> ApplePaySession::supportsVersion(ScriptExecutionContext& scriptExecutionContext, unsigned version)
     420ExceptionOr<bool> ApplePaySession::supportsVersion(Document& document, unsigned version)
    421421{
    422422    if (!version)
    423423        return Exception { InvalidAccessError };
    424 
    425     auto& document = downcast<Document>(scriptExecutionContext);
    426424
    427425    auto canCall = canCreateSession(document);
     
    433431        return Exception { InvalidAccessError };
    434432
    435     return page->paymentCoordinator().supportsVersion(version);
     433    return page->paymentCoordinator().supportsVersion(document, version);
    436434}
    437435
     
    445443}
    446444
    447 ExceptionOr<bool> ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionContext)
    448 {
    449     auto& document = downcast<Document>(scriptExecutionContext);
    450 
     445ExceptionOr<bool> ApplePaySession::canMakePayments(Document& document)
     446{
    451447    auto canCall = canCreateSession(document);
    452448    if (canCall.hasException())
     
    457453        return Exception { InvalidAccessError };
    458454
    459     return page->paymentCoordinator().canMakePayments();
    460 }
    461 
    462 ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
    463 {
    464     auto& document = downcast<Document>(scriptExecutionContext);
    465 
     455    return page->paymentCoordinator().canMakePayments(document);
     456}
     457
     458ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(Document& document, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
     459{
    466460    auto canCall = canCreateSession(document);
    467461    if (canCall.hasException())
     
    475469
    476470        auto& paymentCoordinator = page->paymentCoordinator();
    477         bool canMakePayments = paymentCoordinator.canMakePayments();
     471        bool canMakePayments = paymentCoordinator.canMakePayments(document);
    478472
    479473        RunLoop::main().dispatch([promise, canMakePayments]() mutable {
     
    489483    auto& paymentCoordinator = page->paymentCoordinator();
    490484
    491     paymentCoordinator.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), [promise](bool canMakePayments) mutable {
     485    paymentCoordinator.canMakePaymentsWithActiveCard(document, merchantIdentifier, [promise](bool canMakePayments) mutable {
    492486        promise->resolve<IDLBoolean>(canMakePayments);
    493487    });
     
    495489}
    496490
    497 ExceptionOr<void> ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
    498 {
    499     auto& document = downcast<Document>(scriptExecutionContext);
    500 
     491ExceptionOr<void> ApplePaySession::openPaymentSetup(Document& document, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise)
     492{
    501493    auto canCall = canCreateSession(document);
    502494    if (canCall.hasException())
     
    513505
    514506    RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
    515     paymentCoordinator.openPaymentSetup(merchantIdentifier, document.domain(), [promise](bool result) mutable {
     507    paymentCoordinator.openPaymentSetup(document, merchantIdentifier, [promise](bool result) mutable {
    516508        promise->resolve<IDLBoolean>(result);
    517509    });
     
    520512}
    521513
    522 ExceptionOr<void> ApplePaySession::begin()
     514ExceptionOr<void> ApplePaySession::begin(Document& document)
    523515{
    524516    if (!canBegin())
     
    528520        return Exception { InvalidAccessError, "Page already has an active payment session." };
    529521
    530     auto& document = *downcast<Document>(scriptExecutionContext());
    531 
    532     Vector<URL> linkIconURLs;
    533     for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
    534         linkIconURLs.append(icon.url);
    535 
    536     if (!paymentCoordinator().beginPaymentSession(*this, document.url(), linkIconURLs, m_paymentRequest))
     522    if (!paymentCoordinator().beginPaymentSession(document, *this, m_paymentRequest))
    537523        return Exception { InvalidAccessError, "There is already has an active payment session." };
    538524
  • trunk/Source/WebCore/Modules/applepay/ApplePaySession.h

    r238771 r243324  
    11/*
    2  * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7272    static const unsigned short STATUS_PIN_LOCKOUT = 7;
    7373
    74     static ExceptionOr<bool> supportsVersion(ScriptExecutionContext&, unsigned version);
    75     static ExceptionOr<bool> canMakePayments(ScriptExecutionContext&);
    76     static ExceptionOr<void> canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
    77     static ExceptionOr<void> openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
     74    static ExceptionOr<bool> supportsVersion(Document&, unsigned version);
     75    static ExceptionOr<bool> canMakePayments(Document&);
     76    static ExceptionOr<void> canMakePaymentsWithActiveCard(Document&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
     77    static ExceptionOr<void> openPaymentSetup(Document&, const String& merchantIdentifier, Ref<DeferredPromise>&&);
    7878
    79     ExceptionOr<void> begin();
     79    ExceptionOr<void> begin(Document&);
    8080    ExceptionOr<void> abort();
    8181    ExceptionOr<void> completeMerchantValidation(JSC::ExecState&, JSC::JSValue merchantSession);
  • trunk/Source/WebCore/Modules/applepay/ApplePaySession.idl

    r237717 r243324  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4141    const unsigned short STATUS_PIN_LOCKOUT = 7;
    4242
    43     [CallWith=ScriptExecutionContext, MayThrowException] static boolean supportsVersion(unsigned long version);
    44     [CallWith=ScriptExecutionContext, MayThrowException] static boolean canMakePayments();
    45     [CallWith=ScriptExecutionContext, MayThrowException] static Promise<boolean> canMakePaymentsWithActiveCard(DOMString merchantIdentifier);
    46     [CallWith=ScriptExecutionContext, MayThrowException] static Promise<boolean> openPaymentSetup(DOMString merchantIdentifier);
     43    [CallWith=Document, MayThrowException] static boolean supportsVersion(unsigned long version);
     44    [CallWith=Document, MayThrowException] static boolean canMakePayments();
     45    [CallWith=Document, MayThrowException] static Promise<boolean> canMakePaymentsWithActiveCard(DOMString merchantIdentifier);
     46    [CallWith=Document, MayThrowException] static Promise<boolean> openPaymentSetup(DOMString merchantIdentifier);
    4747
    48     [MayThrowException] void begin();
     48    [CallWith=Document, MayThrowException] void begin();
    4949    [MayThrowException] void abort();
    5050    [MayThrowException, CallWith=ExecState] void completeMerchantValidation(any merchantSession);
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp

    r242681 r243324  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2929#if ENABLE(APPLE_PAY)
    3030
     31#include "Document.h"
     32#include "LinkIconCollector.h"
    3133#include "PaymentAuthorizationStatus.h"
    3234#include "PaymentCoordinatorClient.h"
     
    4749}
    4850
    49 bool PaymentCoordinator::supportsVersion(unsigned version) const
    50 {
     51bool PaymentCoordinator::supportsVersion(Document& document, unsigned version) const
     52{
     53    if (!shouldAllowApplePay(document))
     54        return false;
    5155    return m_client.supportsVersion(version);
    5256}
    5357
    54 bool PaymentCoordinator::canMakePayments()
    55 {
     58bool PaymentCoordinator::canMakePayments(Document& document)
     59{
     60    if (!shouldAllowApplePay(document))
     61        return false;
    5662    return m_client.canMakePayments();
    5763}
    5864
    59 void PaymentCoordinator::canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
    60 {
    61     m_client.canMakePaymentsWithActiveCard(merchantIdentifier, domainName, WTFMove(completionHandler));
    62 }
    63 
    64 void PaymentCoordinator::openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler)
    65 {
    66     m_client.openPaymentSetup(merchantIdentifier, domainName, WTFMove(completionHandler));
    67 }
    68 
    69 bool PaymentCoordinator::beginPaymentSession(PaymentSession& paymentSession, const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest& paymentRequest)
     65void PaymentCoordinator::canMakePaymentsWithActiveCard(Document& document, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler)
     66{
     67    if (!shouldAllowApplePay(document))
     68        return completionHandler(false);
     69    m_client.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), WTFMove(completionHandler));
     70}
     71
     72void PaymentCoordinator::openPaymentSetup(Document& document, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler)
     73{
     74    if (!shouldAllowApplePay(document))
     75        return completionHandler(false);
     76    m_client.openPaymentSetup(merchantIdentifier, document.domain(), WTFMove(completionHandler));
     77}
     78
     79bool PaymentCoordinator::beginPaymentSession(Document& document, PaymentSession& paymentSession, const ApplePaySessionPaymentRequest& paymentRequest)
    7080{
    7181    ASSERT(!m_activeSession);
    7282
    73     if (!m_client.showPaymentUI(originatingURL, linkIconURLs, paymentRequest))
     83    if (!shouldAllowApplePay(document))
     84        return false;
     85
     86    Vector<URL> linkIconURLs;
     87    for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
     88        linkIconURLs.append(icon.url);
     89
     90    if (!m_client.showPaymentUI(document.url(), linkIconURLs, paymentRequest))
    7491        return false;
    7592
    7693    m_activeSession = &paymentSession;
     94    document.setHasStartedApplePaySession();
    7795    return true;
    7896}
     
    196214}
    197215
    198 Optional<String> PaymentCoordinator::validatedPaymentNetwork(unsigned version, const String& paymentNetwork) const
    199 {
     216Optional<String> PaymentCoordinator::validatedPaymentNetwork(Document& document, unsigned version, const String& paymentNetwork) const
     217{
     218    if (!shouldAllowApplePay(document))
     219        return WTF::nullopt;
     220
    200221    if (version < 2 && equalIgnoringASCIICase(paymentNetwork, "jcb"))
    201222        return WTF::nullopt;
     
    207228}
    208229
     230bool PaymentCoordinator::shouldAllowApplePay(Document& document) const
     231{
     232    if (m_client.supportsUnrestrictedApplePay())
     233        return true;
     234
     235    if (document.hasEvaluatedUserAgentScripts() || document.isRunningUserScripts()) {
     236        ASSERT(shouldAllowUserAgentScripts(document));
     237        return false;
     238    }
     239
     240    return true;
     241}
     242
     243bool PaymentCoordinator::shouldAllowUserAgentScripts(Document& document) const
     244{
     245    if (m_client.supportsUnrestrictedApplePay())
     246        return true;
     247
     248    if (document.hasStartedApplePaySession()) {
     249        ASSERT(shouldAllowApplePay(document));
     250        return false;
     251    }
     252
     253    return true;
     254}
     255
    209256} // namespace WebCore
    210257
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h

    r241183 r243324  
    11/*
    2  * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3333namespace WebCore {
    3434
     35class Document;
    3536class Payment;
    3637class PaymentCoordinatorClient;
     
    5354    PaymentCoordinatorClient& client() { return m_client; }
    5455
    55     bool supportsVersion(unsigned version) const;
    56     bool canMakePayments();
    57     void canMakePaymentsWithActiveCard(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
    58     void openPaymentSetup(const String& merchantIdentifier, const String& domainName, WTF::Function<void (bool)>&& completionHandler);
     56    bool supportsVersion(Document&, unsigned version) const;
     57    bool canMakePayments(Document&);
     58    void canMakePaymentsWithActiveCard(Document&, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler);
     59    void openPaymentSetup(Document&, const String& merchantIdentifier, WTF::Function<void(bool)>&& completionHandler);
    5960
    6061    bool hasActiveSession() const { return m_activeSession; }
    6162
    62     bool beginPaymentSession(PaymentSession&, const URL& originatingURL, const Vector<URL>& linkIconURLs, const ApplePaySessionPaymentRequest&);
     63    bool beginPaymentSession(Document&, PaymentSession&, const ApplePaySessionPaymentRequest&);
    6364    void completeMerchantValidation(const PaymentMerchantSession&);
    6465    void completeShippingMethodSelection(Optional<ShippingMethodUpdate>&&);
     
    7677    WEBCORE_EXPORT void didCancelPaymentSession();
    7778
    78     Optional<String> validatedPaymentNetwork(unsigned version, const String&) const;
     79    Optional<String> validatedPaymentNetwork(Document&, unsigned version, const String&) const;
     80
     81    WEBCORE_EXPORT bool shouldAllowApplePay(Document&) const;
     82    WEBCORE_EXPORT bool shouldAllowUserAgentScripts(Document&) const;
    7983
    8084private:
  • trunk/Source/WebCore/Modules/applepay/PaymentCoordinatorClient.h

    r242748 r243324  
    3838namespace WebCore {
    3939
     40class Document;
    4041class PaymentMerchantSession;
    4142struct PaymentAuthorizationResult;
     
    6667    virtual bool isWebPaymentCoordinator() const { return false; }
    6768
     69    virtual bool supportsUnrestrictedApplePay() const { return true; }
     70
    6871protected:
    6972    virtual ~PaymentCoordinatorClient() = default;
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp

    r241105 r243324  
    186186}
    187187
    188 ExceptionOr<void> ApplePayPaymentHandler::show()
    189 {
    190     auto validatedRequest = convertAndValidate(m_applePayRequest->version, *m_applePayRequest, paymentCoordinator());
     188ExceptionOr<void> ApplePayPaymentHandler::show(Document& document)
     189{
     190    auto validatedRequest = convertAndValidate(document, m_applePayRequest->version, *m_applePayRequest, paymentCoordinator());
    191191    if (validatedRequest.hasException())
    192192        return validatedRequest.releaseException();
     
    218218        return exception.releaseException();
    219219
    220     Vector<URL> linkIconURLs;
    221     for (auto& icon : LinkIconCollector { document() }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
    222         linkIconURLs.append(icon.url);
    223 
    224     paymentCoordinator().beginPaymentSession(*this, document().url(), linkIconURLs, request);
     220    if (!paymentCoordinator().beginPaymentSession(document, *this, request))
     221        return Exception { AbortError };
     222
    225223    return { };
    226224}
     
    231229}
    232230
    233 void ApplePayPaymentHandler::canMakePayment(Function<void(bool)>&& completionHandler)
    234 {
    235     completionHandler(paymentCoordinator().canMakePayments());
     231void ApplePayPaymentHandler::canMakePayment(Document& document, Function<void(bool)>&& completionHandler)
     232{
     233    completionHandler(paymentCoordinator().canMakePayments(document));
    236234}
    237235
     
    533531unsigned ApplePayPaymentHandler::version() const
    534532{
    535     if (!m_applePayRequest)
    536         return 0;
    537    
    538     auto version = m_applePayRequest->version;
    539     ASSERT(paymentCoordinator().supportsVersion(version));
    540     return version;
     533    return m_applePayRequest ? m_applePayRequest->version : 0;
    541534}
    542535
  • trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h

    r239427 r243324  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    6666    // PaymentHandler
    6767    ExceptionOr<void> convertData(JSC::JSValue&&) final;
    68     ExceptionOr<void> show() final;
     68    ExceptionOr<void> show(Document&) final;
    6969    void hide() final;
    70     void canMakePayment(WTF::Function<void(bool)>&& completionHandler) final;
     70    void canMakePayment(Document&, WTF::Function<void(bool)>&& completionHandler) final;
    7171    ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) final;
    7272    ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) final;
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h

    r239427 r243324  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5050
    5151    virtual ExceptionOr<void> convertData(JSC::JSValue&&) = 0;
    52     virtual ExceptionOr<void> show() = 0;
     52    virtual ExceptionOr<void> show(Document&) = 0;
    5353    virtual void hide() = 0;
    54     virtual void canMakePayment(WTF::Function<void(bool)>&& completionHandler) = 0;
     54    virtual void canMakePayment(Document&, WTF::Function<void(bool)>&& completionHandler) = 0;
    5555    virtual ExceptionOr<void> detailsUpdated(PaymentRequest::UpdateReason, String&& error, AddressErrors&&, PayerErrorFields&&, JSC::JSObject* paymentMethodErrors) = 0;
    5656    virtual ExceptionOr<void> merchantValidationCompleted(JSC::JSValue&&) = 0;
  • trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp

    r241130 r243324  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    429429    }
    430430
    431     auto exception = selectedPaymentHandler->show();
     431    auto exception = selectedPaymentHandler->show(document);
    432432    if (exception.hasException()) {
    433433        settleShowPromise(exception.releaseException());
     
    507507            continue;
    508508
    509         handler->canMakePayment([promise = WTFMove(promise)](bool canMakePayment) mutable {
     509        handler->canMakePayment(document, [promise = WTFMove(promise)](bool canMakePayment) mutable {
    510510            promise.resolve(canMakePayment);
    511511        });
  • trunk/Source/WebCore/bindings/js/ScriptController.cpp

    r242991 r243324  
    22 *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
    33 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    4  *  Copyright (C) 2006-2017 Apple Inc. All rights reserved.
     4 *  Copyright (C) 2006-2019 Apple Inc. All rights reserved.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    4545#include "PageConsoleClient.h"
    4646#include "PageGroup.h"
     47#include "PaymentCoordinator.h"
    4748#include "PluginViewBase.h"
    4849#include "RuntimeApplicationChecks.h"
     
    555556}
    556557
     558JSValue ScriptController::executeUserAgentScriptInWorld(DOMWrapperWorld& world, const String& script, bool forceUserGesture, ExceptionDetails* exceptionDetails)
     559{
     560    auto& document = *m_frame.document();
     561    if (!shouldAllowUserAgentScripts(document))
     562        return { };
     563
     564    document.setHasEvaluatedUserAgentScripts();
     565    return executeScriptInWorld(world, script, forceUserGesture, exceptionDetails);
     566}
     567
     568bool ScriptController::shouldAllowUserAgentScripts(Document& document) const
     569{
     570#if ENABLE(APPLE_PAY)
     571    if (auto page = m_frame.page())
     572        return page->paymentCoordinator().shouldAllowUserAgentScripts(document);
     573#endif
     574    return true;
     575}
     576
    557577bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reason)
    558578{
  • trunk/Source/WebCore/bindings/js/ScriptController.h

    r241906 r243324  
    22 *  Copyright (C) 1999 Harri Porten (porten@kde.org)
    33 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    4  *  Copyright (C) 2008-2017 Apple Inc. All rights reserved.
     4 *  Copyright (C) 2008-2019 Apple Inc. All rights reserved.
    55 *  Copyright (C) 2008 Eric Seidel <eric@webkit.org>
    66 *
     
    9191    JSC::JSValue executeScript(const ScriptSourceCode&, ExceptionDetails* = nullptr);
    9292    WEBCORE_EXPORT JSC::JSValue executeScript(const String& script, bool forceUserGesture = false, ExceptionDetails* = nullptr);
    93     WEBCORE_EXPORT JSC::JSValue executeScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture = false, ExceptionDetails* = nullptr);
     93    JSC::JSValue executeScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture = false, ExceptionDetails* = nullptr);
     94    WEBCORE_EXPORT JSC::JSValue executeUserAgentScriptInWorld(DOMWrapperWorld&, const String& script, bool forceUserGesture, ExceptionDetails* = nullptr);
     95
     96    bool shouldAllowUserAgentScripts(Document&) const;
    9497
    9598    // Returns true if argument is a JavaScript URL.
  • trunk/Source/WebCore/dom/Document.cpp

    r243195 r243324  
    75507550        return;
    75517551
     7552    auto& scriptController = frame()->script();
     7553
    75527554    // Use the JS file provided by the Chrome client, or fallback to the default one.
    75537555    String jsString = page()->chrome().client().plugInExtraScript();
    7554     if (!jsString)
     7556    if (!jsString || !scriptController.shouldAllowUserAgentScripts(*this))
    75557557        jsString = String(plugInsJavaScript, sizeof(plugInsJavaScript));
    75567558
    7557     frame()->script().evaluateInWorld(ScriptSourceCode(jsString), world);
     7559    setHasEvaluatedUserAgentScripts();
     7560    scriptController.evaluateInWorld(ScriptSourceCode(jsString), world);
    75587561
    75597562    m_hasInjectedPlugInsScript = true;
     
    87278730#endif
    87288731
     8732bool Document::hasEvaluatedUserAgentScripts() const
     8733{
     8734    auto& top = topDocument();
     8735    return this == &top ? m_hasEvaluatedUserAgentScripts : top.hasEvaluatedUserAgentScripts();
     8736}
     8737
     8738bool Document::isRunningUserScripts() const
     8739{
     8740    auto& top = topDocument();
     8741    return this == &top ? m_isRunningUserScripts : top.isRunningUserScripts();
     8742}
     8743
     8744void Document::setAsRunningUserScripts()
     8745{
     8746    auto& top = topDocument();
     8747    if (this == &top)
     8748        m_isRunningUserScripts = true;
     8749    else
     8750        top.setAsRunningUserScripts();
     8751}
     8752
     8753void Document::setHasEvaluatedUserAgentScripts()
     8754{
     8755    auto& top = topDocument();
     8756    if (this == &top)
     8757        m_hasEvaluatedUserAgentScripts = true;
     8758    else
     8759        top.setHasEvaluatedUserAgentScripts();
     8760}
     8761
     8762#if ENABLE(APPLE_PAY)
     8763
     8764bool Document::hasStartedApplePaySession() const
     8765{
     8766    auto& top = topDocument();
     8767    return this == &top ? m_hasStartedApplePaySession : top.hasStartedApplePaySession();
     8768}
     8769
     8770void Document::setHasStartedApplePaySession()
     8771{
     8772    auto& top = topDocument();
     8773    if (this == &top)
     8774        m_hasStartedApplePaySession = true;
     8775    else
     8776        top.setHasStartedApplePaySession();
     8777}
     8778
     8779#endif
     8780
    87298781} // namespace WebCore
  • trunk/Source/WebCore/dom/Document.h

    r243124 r243324  
    44 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    55 *           (C) 2006 Alexey Proskuryakov (ap@webkit.org)
    6  * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
     6 * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
    77 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
    88 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
     
    15381538#endif
    15391539
    1540     void setAsRunningUserScripts() { m_isRunningUserScripts = true; }
    1541     bool isRunningUserScripts() const { return m_isRunningUserScripts; }
     1540    WEBCORE_EXPORT bool hasEvaluatedUserAgentScripts() const;
     1541    WEBCORE_EXPORT bool isRunningUserScripts() const;
     1542    WEBCORE_EXPORT void setAsRunningUserScripts();
     1543    void setHasEvaluatedUserAgentScripts();
     1544#if ENABLE(APPLE_PAY)
     1545    WEBCORE_EXPORT bool hasStartedApplePaySession() const;
     1546    WEBCORE_EXPORT void setHasStartedApplePaySession();
     1547#endif
    15421548
    15431549    void frameWasDisconnectedFromOwner();
     
    20962102#endif
    20972103
     2104    bool m_hasEvaluatedUserAgentScripts { false };
    20982105    bool m_isRunningUserScripts { false };
     2106#if ENABLE(APPLE_PAY)
     2107    bool m_hasStartedApplePaySession { false };
     2108#endif
    20992109
    21002110    Ref<UndoManager> m_undoManager;
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r239427 r243324  
    148148        m_options.httpHeadersToKeep = httpHeadersToKeepFromCleaning(request.httpHeaderFields());
    149149
    150     if (document.topDocument().isRunningUserScripts() && SchemeRegistry::isUserExtensionScheme(request.url().protocol().toStringWithoutCopying())) {
     150    if (document.isRunningUserScripts() && SchemeRegistry::isUserExtensionScheme(request.url().protocol().toStringWithoutCopying())) {
    151151        m_options.mode = FetchOptions::Mode::NoCors;
    152152        m_options.filteringPolicy = ResponseFilteringPolicy::Disable;
  • trunk/Source/WebCore/page/Frame.cpp

    r242340 r243324  
    66 *                     2000 Stefan Schimanski <1Stein@gmx.de>
    77 *                     2001 George Staikos <staikos@kde.org>
    8  * Copyright (C) 2004-2016 Apple Inc. All rights reserved.
     8 * Copyright (C) 2004-2019 Apple Inc. All rights reserved.
    99 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
    1010 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
     
    770770    if (!UserContentURLPattern::matchesPatterns(document->url(), script.whitelist(), script.blacklist()))
    771771        return;
    772 
    773     document->topDocument().setAsRunningUserScripts();
     772    if (!m_script->shouldAllowUserAgentScripts(*document))
     773        return;
     774
     775    document->setAsRunningUserScripts();
    774776    loader().client().willInjectUserScript(world);
    775777    m_script->evaluateInWorld(ScriptSourceCode(script.source(), URL(script.url())), world);
  • trunk/Source/WebCore/page/Settings.yaml

    r243318 r243324  
    663663applePayEnabled:
    664664  conditional: APPLE_PAY
    665   initial: false
     665  initial: defaultApplePayEnabled
    666666applePayRemoteUIEnabled:
    667667  conditional: APPLE_PAY_REMOTE_UI
  • trunk/Source/WebCore/page/SettingsDefaultValues.h

    r240644 r243324  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    110110static const bool defaultConicGradient = false;
    111111#endif
     112   
     113#if ENABLE(APPLE_PAY_REMOTE_UI)
     114static const bool defaultApplePayEnabled = true;
     115#else
     116static const bool defaultApplePayEnabled = false;
     117#endif
    112118
    113119}
  • trunk/Source/WebCore/testing/Internals.cpp

    r243276 r243324  
    45424542void Internals::setAsRunningUserScripts(Document& document)
    45434543{
    4544     document.topDocument().setAsRunningUserScripts();
    4545 }
     4544    document.setAsRunningUserScripts();
     4545}
     4546
     4547#if ENABLE(APPLE_PAY)
     4548void Internals::setHasStartedApplePaySession(Document& document)
     4549{
     4550    document.setHasStartedApplePaySession();
     4551}
     4552#endif
    45464553
    45474554#if ENABLE(WEBGL)
  • trunk/Source/WebCore/testing/Internals.h

    r243276 r243324  
    668668
    669669    void setAsRunningUserScripts(Document&);
     670#if ENABLE(APPLE_PAY)
     671    void setHasStartedApplePaySession(Document&);
     672#endif
    670673
    671674#if ENABLE(WEBGL)
  • trunk/Source/WebCore/testing/Internals.idl

    r243276 r243324  
    652652
    653653    [CallWith=Document] void setAsRunningUserScripts();
     654    [CallWith=Document, Conditional=APPLE_PAY] void setHasStartedApplePaySession();
    654655
    655656    void disableTileSizeUpdateDelay();
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.h

    r242681 r243324  
    6161    const MockPaymentContactFields& requiredShippingContactFields() const { return m_requiredShippingContactFields; }
    6262
     63    bool supportsUnrestrictedApplePay() const final { return m_supportsUnrestrictedApplePay; }
     64    void setSupportsUnrestrictedApplePay(bool supports) { m_supportsUnrestrictedApplePay = supports; }
     65
    6366    void ref() const { }
    6467    void deref() const { }
     
    6770    Optional<String> validatedPaymentNetwork(const String&) final;
    6871    bool canMakePayments() final;
    69     void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&&);
    70     void openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&&);
     72    void canMakePaymentsWithActiveCard(const String&, const String&, CompletionHandler<void(bool)>&&) final;
     73    void openPaymentSetup(const String&, const String&, CompletionHandler<void(bool)>&&) final;
    7174    bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final;
    7275    void completeMerchantValidation(const PaymentMerchantSession&) final;
     
    9497    MockPaymentContactFields m_requiredBillingContactFields;
    9598    MockPaymentContactFields m_requiredShippingContactFields;
     99    bool m_supportsUnrestrictedApplePay { true };
    96100};
    97101
  • trunk/Source/WebCore/testing/MockPaymentCoordinator.idl

    r241105 r243324  
    4242    readonly attribute MockPaymentContactFields requiredBillingContactFields;
    4343    readonly attribute MockPaymentContactFields requiredShippingContactFields;
     44
     45    attribute boolean supportsUnrestrictedApplePay;
    4446};
  • trunk/Source/WebKit/ChangeLog

    r243320 r243324  
     12019-03-21  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Apple Pay should be available in documents with no user agent scripts
     4        https://bugs.webkit.org/show_bug.cgi?id=196061
     5        <rdar://problem/48649391>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * Shared/AuxiliaryProcess.h:
     10        * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
     11        (WebKit::AuxiliaryProcess::parentProcessHasEntitlement):
     12
     13        Added a convenience function for checking parent process entitlements.
     14
     15        * Shared/WebPreferences.yaml:
     16        * Shared/WebPreferencesDefaultValues.h:
     17        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     18        (-[WKWebViewConfiguration init]):
     19
     20        Enabled Apple Pay by default on platforms that enable APPLE_PAY_REMOTE_UI.
     21
     22        * WebProcess/ApplePay/WebPaymentCoordinator.cpp:
     23        (WebKit::WebPaymentCoordinator::supportsUnrestrictedApplePay const):
     24        * WebProcess/ApplePay/WebPaymentCoordinator.h:
     25
     26        Implemented supportsUnrestrictedApplePay by checking for the
     27        com.apple.private.WebKit.UnrestrictedApplePay entitlement on platforms that enable
     28        APPLE_PAY_REMOTE_UI.
     29
     30        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h:
     31        * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
     32        (didClearWindowObjectForFrame):
     33        (setUpPageLoaderClient):
     34
     35        Added injected bundle SPI that TestWebKitAPI uses to inject the WebCore Internals interface.
     36
     37        * WebProcess/WebPage/WebPage.cpp:
     38        (WebKit::WebPage::runJavaScript):
     39
     40        Changed to call ScriptController::executeUserAgentScriptInWorld.
     41
    1422019-03-21  Chris Dumez  <cdumez@apple.com>
    243
  • trunk/Source/WebKit/Shared/AuxiliaryProcess.h

    r240955 r243324  
    11/*
    2  * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7878#if PLATFORM(MAC)
    7979    static bool isSystemWebKit();
     80#endif
     81   
     82#if PLATFORM(COCOA)
     83    bool parentProcessHasEntitlement(const char* entitlement);
    8084#endif
    8185
  • trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm

    r240683 r243324  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828
    2929#import "WKCrashReporter.h"
     30#import <wtf/cocoa/Entitlements.h>
    3031
    3132namespace WebKit {
     
    3738}
    3839
     40bool AuxiliaryProcess::parentProcessHasEntitlement(const char* entitlement)
     41{
     42    return WTF::hasEntitlement(m_connection->xpcConnection(), entitlement);
    3943}
     44
     45}
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r243318 r243324  
    679679ApplePayEnabled:
    680680  type: bool
    681   defaultValue: false
     681  defaultValue: DEFAULT_APPLE_PAY_ENABLED
    682682  condition: ENABLE(APPLE_PAY)
    683683
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r243292 r243324  
    11/*
    2  * Copyright (C) 2010-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    260260#endif
    261261#endif
     262
     263#if ENABLE(APPLE_PAY_REMOTE_UI)
     264#define DEFAULT_APPLE_PAY_ENABLED true
     265#else
     266#define DEFAULT_APPLE_PAY_ENABLED false
     267#endif
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r242339 r243324  
    250250    _undoManagerAPIEnabled = NO;
    251251
     252#if ENABLE(APPLE_PAY)
     253    _applePayEnabled = DEFAULT_APPLE_PAY_ENABLED;
     254#endif
     255
    252256    return self;
    253257}
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.cpp

    r242748 r243324  
    158158}
    159159
     160bool WebPaymentCoordinator::supportsUnrestrictedApplePay() const
     161{
     162#if ENABLE(APPLE_PAY_REMOTE_UI)
     163    static bool hasEntitlement = WebProcess::singleton().parentProcessHasEntitlement("com.apple.private.WebKit.UnrestrictedApplePay");
     164    return hasEntitlement;
     165#else
     166    return true;
     167#endif
     168}
     169
    160170IPC::Connection* WebPaymentCoordinator::messageSenderConnection() const
    161171{
  • trunk/Source/WebKit/WebProcess/ApplePay/WebPaymentCoordinator.h

    r242748 r243324  
    7979    bool isWebPaymentCoordinator() const override { return true; }
    8080
     81    bool supportsUnrestrictedApplePay() const override;
     82
    8183    // IPC::MessageReceiver.
    8284    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
    83    
     85
    8486    // IPC::MessageSender.
    8587    IPC::Connection* messageSenderConnection() const final;
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h

    r242375 r243324  
    4545- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didFinishLoadForFrame:(WKWebProcessPlugInFrame *)frame;
    4646- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didSameDocumentNavigation:(_WKSameDocumentNavigationType)navigationType forFrame:(WKWebProcessPlugInFrame *)frame;
     47- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didClearWindowObjectForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld;
    4748- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller globalObjectIsAvailableForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld;
    4849- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didRemoveFrameFromHierarchy:(WKWebProcessPlugInFrame *)frame;
  • trunk/Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm

    r242375 r243324  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    105105}
    106106
     107static void didClearWindowObjectForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void* clientInfo)
     108{
     109    auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo;
     110    auto loadDelegate = pluginContextController->_loadDelegate.get();
     111   
     112    if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:)])
     113        [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didClearWindowObjectForFrame:wrapper(*WebKit::toImpl(frame)) inScriptWorld:wrapper(*WebKit::toImpl(scriptWorld))];
     114}
     115
    107116static void globalObjectIsAvailableForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void* clientInfo)
    108117{
     
    236245    client.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame;
    237246    client.didFinishLoadForFrame = didFinishLoadForFrame;
     247    client.didClearWindowObjectForFrame = didClearWindowObjectForFrame;
    238248    client.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrame;
    239249    client.didRemoveFrameFromHierarchy = didRemoveFrameFromHierarchy;
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r243195 r243324  
    32903290    auto* world = worldName ? InjectedBundleScriptWorld::find(worldName.value()) : &InjectedBundleScriptWorld::normalWorld();
    32913291    if (world) {
    3292         if (JSValue resultValue = m_mainFrame->coreFrame()->script().executeScriptInWorld(world->coreWorld(), script, forceUserGesture, &details)) {
     3292        if (JSValue resultValue = m_mainFrame->coreFrame()->script().executeUserAgentScriptInWorld(world->coreWorld(), script, forceUserGesture, &details)) {
    32933293            hadException = false;
    32943294            serializedResultValue = SerializedScriptValue::create(m_mainFrame->jsContextForWorld(world),
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r243275 r243324  
     12019-03-21  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Apple Pay should be available in documents with no user agent scripts
     4        https://bugs.webkit.org/show_bug.cgi?id=196061
     5        <rdar://problem/48649391>
     6
     7        Reviewed by Brady Eidson.
     8
     9        * WebView/WebFrame.mm:
     10        (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]):
     11
    1122019-03-20  Simon Fraser  <simon.fraser@apple.com>
    213
  • trunk/Source/WebKitLegacy/mac/WebView/WebFrame.mm

    r240912 r243324  
    21032103    RetainPtr<WebFrame> webFrame(kit(frame)); // Running arbitrary JavaScript can destroy the frame.
    21042104
    2105     JSC::JSValue result = frame->script().executeScriptInWorld(*core(world), string, true);
     2105    JSC::JSValue result = frame->script().executeUserAgentScriptInWorld(*core(world), string, true);
    21062106
    21072107    if (!webFrame->_private->coreFrame) // In case the script removed our frame from the page.
  • trunk/Tools/ChangeLog

    r243321 r243324  
     12019-03-21  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Apple Pay should be available in documents with no user agent scripts
     4        https://bugs.webkit.org/show_bug.cgi?id=196061
     5        <rdar://problem/48649391>
     6
     7        Reviewed by Brady Eidson.
     8
     9        Added API tests and related infrastructure.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebKitCocoa/ApplePay.mm: Added.
     13        (-[TestApplePayScriptMessageHandler initWithExpectation:]):
     14        (-[TestApplePayScriptMessageHandler userContentController:didReceiveScriptMessage:]):
     15        (TestWebKitAPI::TEST):
     16        * TestWebKitAPI/Tests/WebKitCocoa/apple-pay-active-session.html: Added.
     17        * TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability-in-iframe.html: Added.
     18        * TestWebKitAPI/Tests/WebKitCocoa/apple-pay-availability.html: Added.
     19        * TestWebKitAPI/cocoa/TestProtocol.mm:
     20        (-[TestProtocol startLoading]):
     21        * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h: Added.
     22        * TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm: Added.
     23        (-[WebProcessPlugInWithInternals webProcessPlugIn:didCreateBrowserContextController:]):
     24        (-[WebProcessPlugInWithInternals webProcessPlugInBrowserContextController:didClearWindowObjectForFrame:inScriptWorld:]):
     25
    1262019-03-21  Jonathan Bedard  <jbedard@apple.com>
    227
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r243110 r243324  
    703703                A155022C1E050D0300A24C57 /* duplicate-completion-handler-calls.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A155022B1E050BC500A24C57 /* duplicate-completion-handler-calls.html */; };
    704704                A16F66BA1C40EB4F00BD4D24 /* ContentFiltering.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */; };
     705                A1798B7F22431D2B000764BD /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */; };
     706                A1798B8222431D65000764BD /* ApplePay.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1798B8122431D65000764BD /* ApplePay.mm */; };
     707                A1798B8522433647000764BD /* WebProcessPlugInWithInternals.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1798B8422433647000764BD /* WebProcessPlugInWithInternals.mm */; };
     708                A1798B872243449B000764BD /* apple-pay-availability.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1798B862243446B000764BD /* apple-pay-availability.html */; };
     709                A1798B8922435E29000764BD /* apple-pay-availability-in-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1798B8822435D2E000764BD /* apple-pay-availability-in-iframe.html */; };
     710                A1798B8B224361A4000764BD /* apple-pay-active-session.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A1798B8A2243611A000764BD /* apple-pay-active-session.html */; };
    705711                A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A17991861E1C994E00A505ED /* SharedBuffer.mm */; };
    706712                A179918B1E1CA24100A505ED /* SharedBufferTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17991891E1CA24100A505ED /* SharedBufferTest.cpp */; };
     
    10191025                                C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
    10201026                                F4A9202F1FEE34E900F59590 /* apple-data-url.html in Copy Resources */,
     1027                                A1798B8B224361A4000764BD /* apple-pay-active-session.html in Copy Resources */,
     1028                                A1798B8922435E29000764BD /* apple-pay-availability-in-iframe.html in Copy Resources */,
     1029                                A1798B872243449B000764BD /* apple-pay-availability.html in Copy Resources */,
    10211030                                F46A095A1ED8A6E600D4AA55 /* apple.gif in Copy Resources */,
    10221031                                5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */,
     
    19571966                A155022B1E050BC500A24C57 /* duplicate-completion-handler-calls.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "duplicate-completion-handler-calls.html"; sourceTree = "<group>"; };
    19581967                A16F66B91C40EA2000BD4D24 /* ContentFiltering.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContentFiltering.html; sourceTree = "<group>"; };
     1968                A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; path = libWebCoreTestSupport.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
     1969                A1798B8122431D65000764BD /* ApplePay.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ApplePay.mm; sourceTree = "<group>"; };
     1970                A1798B8322433647000764BD /* WebProcessPlugInWithInternals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebProcessPlugInWithInternals.h; sourceTree = "<group>"; };
     1971                A1798B8422433647000764BD /* WebProcessPlugInWithInternals.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessPlugInWithInternals.mm; sourceTree = "<group>"; };
     1972                A1798B862243446B000764BD /* apple-pay-availability.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-pay-availability.html"; sourceTree = "<group>"; };
     1973                A1798B8822435D2E000764BD /* apple-pay-availability-in-iframe.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-pay-availability-in-iframe.html"; sourceTree = "<group>"; };
     1974                A1798B8A2243611A000764BD /* apple-pay-active-session.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "apple-pay-active-session.html"; sourceTree = "<group>"; };
    19591975                A17991861E1C994E00A505ED /* SharedBuffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SharedBuffer.mm; sourceTree = "<group>"; };
    19601976                A17991891E1CA24100A505ED /* SharedBufferTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedBufferTest.cpp; sourceTree = "<group>"; };
     
    23652381                        runOnlyForDeploymentPostprocessing = 0;
    23662382                };
     2383                A1798B7D22431D18000764BD /* Frameworks */ = {
     2384                        isa = PBXFrameworksBuildPhase;
     2385                        buildActionMask = 2147483647;
     2386                        files = (
     2387                                A1798B7F22431D2B000764BD /* libWebCoreTestSupport.dylib in Frameworks */,
     2388                        );
     2389                        runOnlyForDeploymentPostprocessing = 0;
     2390                };
    23672391                BC57597E126E74AF006F0F12 /* Frameworks */ = {
    23682392                        isa = PBXFrameworksBuildPhase;
     
    24862510                                A1DF74301C41B65800A2F4D0 /* AlwaysRevalidatedURLSchemes.mm */,
    24872511                                2DE71AFD1D49C0BD00904094 /* AnimatedResize.mm */,
     2512                                A1798B8122431D65000764BD /* ApplePay.mm */,
    24882513                                63F668201F97C3AA0032EE51 /* ApplicationManifest.mm */,
    24892514                                834138C6203261B900F26960 /* AsyncPolicyForNavigationResponse.mm */,
     
    28122837                                CDA3159C1ED5643F009F60D3 /* IOKit.framework */,
    28132838                                7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */,
     2839                                A1798B7E22431D2B000764BD /* libWebCoreTestSupport.dylib */,
    28142840                                4135FB862011FABF00332139 /* libWebCoreTestSupport.dylib */,
    28152841                                7C83E0291D0A5CDF00FEBCF3 /* libWTF.a */,
     
    28482874                                A13EBB541B8734E000097110 /* Info.plist */,
    28492875                                A13EBBA91B87428D00097110 /* WebProcessPlugIn.mm */,
     2876                                A1798B8322433647000764BD /* WebProcessPlugInWithInternals.h */,
     2877                                A1798B8422433647000764BD /* WebProcessPlugInWithInternals.mm */,
    28502878                        );
    28512879                        name = WebProcessPlugIn;
     
    28602888                                C25CCA0C1E5140E50026CB8A /* AllAhem.svg */,
    28612889                                F4A9202E1FEE34C800F59590 /* apple-data-url.html */,
     2890                                A1798B8A2243611A000764BD /* apple-pay-active-session.html */,
     2891                                A1798B8822435D2E000764BD /* apple-pay-availability-in-iframe.html */,
     2892                                A1798B862243446B000764BD /* apple-pay-availability.html */,
    28622893                                F47D30EB1ED28619000482E1 /* apple.gif */,
    28632894                                5C9E593E1D3EB1DE00E3C62E /* ApplicationCache.db */,
     
    37673798                        buildPhases = (
    37683799                                A13EBB451B87339E00097110 /* Sources */,
     3800                                A1798B7D22431D18000764BD /* Frameworks */,
    37693801                        );
    37703802                        buildRules = (
     
    39673999                                2DE71AFE1D49C0BD00904094 /* AnimatedResize.mm in Sources */,
    39684000                                57152B5E21CC2045000C37CA /* ApduTest.cpp in Sources */,
     4001                                A1798B8222431D65000764BD /* ApplePay.mm in Sources */,
    39694002                                63F668221F97F7F90032EE51 /* ApplicationManifest.mm in Sources */,
    39704003                                6354F4D11F7C3AB500D89DF3 /* ApplicationManifestParser.cpp in Sources */,
     
    44564489                                7C83E03D1D0A60D600FEBCF3 /* UtilitiesCocoa.mm in Sources */,
    44574490                                A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
     4491                                A1798B8522433647000764BD /* WebProcessPlugInWithInternals.mm in Sources */,
    44584492                        );
    44594493                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Tools/TestWebKitAPI/cocoa/TestProtocol.mm

    r242339 r243324  
    8787    }
    8888
    89     NSData *data = [@"PASS" dataUsingEncoding:NSASCIIStringEncoding];
     89    NSData *data;
     90    if ([requestURL.host isEqualToString:@"bundle-html-file"])
     91        data = [NSData dataWithContentsOfURL:[NSBundle.mainBundle URLForResource:requestURL.lastPathComponent.stringByDeletingPathExtension withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
     92    else
     93        data = [@"PASS" dataUsingEncoding:NSASCIIStringEncoding];
     94
    9095    RetainPtr<NSURLResponse> response = adoptNS([[NSURLResponse alloc] initWithURL:requestURL MIMEType:@"text/html" expectedContentLength:data.length textEncodingName:nil]);
    9196
  • trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.h

    r243323 r243324  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #import "config.h"
    27 #import "AuxiliaryProcess.h"
     26#import <WebKit/WKWebProcessPlugIn.h>
    2827
    29 #import "WKCrashReporter.h"
    30 
    31 namespace WebKit {
    32 
    33 void AuxiliaryProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
    34 {
    35     setCrashReportApplicationSpecificInformation((__bridge CFStringRef)[NSString stringWithFormat:@"Received invalid message: '%s::%s'", messageReceiverName.toString().data(), messageName.toString().data()]);
    36     CRASH();
    37 }
    38 
    39 }
     28@interface WebProcessPlugInWithInternals : NSObject <WKWebProcessPlugIn>
     29@end
  • trunk/Tools/TestWebKitAPI/cocoa/WebProcessPlugIn/WebProcessPlugInWithInternals.mm

    r243323 r243324  
    11/*
    2  * Copyright (C) 2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#import "config.h"
    27 #import "AuxiliaryProcess.h"
     27#import "WebProcessPlugInWithInternals.h"
    2828
    29 #import "WKCrashReporter.h"
     29#import "WebCoreTestSupport.h"
     30#import <WebKit/WKWebProcessPlugInBrowserContextController.h>
     31#import <WebKit/WKWebProcessPlugInFrame.h>
     32#import <WebKit/WKWebProcessPlugInLoadDelegate.h>
    3033
    31 namespace WebKit {
     34@interface WebProcessPlugInWithInternals () <WKWebProcessPlugInLoadDelegate>
    3235
    33 void AuxiliaryProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
     36@end
     37
     38@implementation WebProcessPlugInWithInternals
     39
     40- (void)webProcessPlugIn:(WKWebProcessPlugInController *)plugInController didCreateBrowserContextController:(WKWebProcessPlugInBrowserContextController *)browserContextController
    3441{
    35     setCrashReportApplicationSpecificInformation((__bridge CFStringRef)[NSString stringWithFormat:@"Received invalid message: '%s::%s'", messageReceiverName.toString().data(), messageName.toString().data()]);
    36     CRASH();
     42    browserContextController.loadDelegate = self;
    3743}
    3844
     45- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didClearWindowObjectForFrame:(WKWebProcessPlugInFrame *)frame inScriptWorld:(WKWebProcessPlugInScriptWorld *)scriptWorld
     46{
     47    WebCoreTestSupport::injectInternalsObject([frame jsContextForWorld:scriptWorld].JSGlobalContextRef);
    3948}
     49
     50@end
Note: See TracChangeset for help on using the changeset viewer.