[Payment Request] Implement Apple Pay merchant validation
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 17:48:26 +0000 (17:48 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 17:48:26 +0000 (17:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178159

Reviewed by Brady Eidson.

Source/WebCore:

When ApplePayPaymentHandler::validateMerchant() is called, dispatch the
applepayvalidatemerchant event to the PaymentRequest object.

The event object is an ApplePayMerchantValidationEvent, on which the client calls complete()
with a merchant session.

Test: http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html

* DerivedSources.make:
* Modules/applepay/ApplePayValidateMerchantEvent.h:
* Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.cpp: Added.
(WebCore::ApplePayMerchantValidationEvent::create):
(WebCore::ApplePayMerchantValidationEvent::ApplePayMerchantValidationEvent):
(WebCore::ApplePayMerchantValidationEvent::complete):
(WebCore::ApplePayMerchantValidationEvent::eventInterface const):
* Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.h: Added.
* Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl: Added.
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::validateMerchant):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/paymentrequest/PaymentRequest.idl:
* WebCore.xcodeproj/project.pbxproj:
* dom/EventNames.h:
* dom/EventNames.in:
* testing/Internals.cpp:
(WebCore::Internals::Internals):
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::MockPaymentCoordinator):
(WebCore::MockPaymentCoordinator::showPaymentUI):
* testing/MockPaymentCoordinator.h:

LayoutTests:

* http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https-expected.txt: Added.
* http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223193 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.h
Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.cpp [new file with mode: 0644]
Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.h [new file with mode: 0644]
Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl [new file with mode: 0644]
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h
Source/WebCore/Modules/paymentrequest/PaymentRequest.idl
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventNames.in
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/MockPaymentCoordinator.cpp
Source/WebCore/testing/MockPaymentCoordinator.h

index b7f7974..11dc66f 100644 (file)
@@ -1,3 +1,13 @@
+2017-10-11  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Implement Apple Pay merchant validation
+        https://bugs.webkit.org/show_bug.cgi?id=178159
+
+        Reviewed by Brady Eidson.
+
+        * http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https-expected.txt: Added.
+        * http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html: Added.
+
 2017-10-11  Brady Eidson  <beidson@apple.com>
 
         Add a SW context process (where SW scripts will actually execute).
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https-expected.txt b/LayoutTests/http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https-expected.txt
new file mode 100644 (file)
index 0000000..3665dd1
--- /dev/null
@@ -0,0 +1,20 @@
+Test the applepayvalidatemerchant event.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing ApplePayMerchantValidationEvent
+
+PASS () => event.complete(undefined) threw exception TypeError: Type error.
+PASS () => event.complete(null) threw exception TypeError: Type error.
+PASS () => event.complete([]) threw exception TypeError: Type error.
+PASS () => event.complete('') threw exception TypeError: Type error.
+PASS () => event.complete(7) threw exception TypeError: Type error.
+PASS () => { event.complete({}); event.complete({}); } threw exception InvalidStateError: The object is in an invalid state..
+PASS () => { paymentRequest.abort(); event.complete({}); } threw exception InvalidStateError: The object is in an invalid state..
+PASS () => event.complete({}) did not throw exception.
+PASS event.validationURL is 'https://webkit.org/'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html b/LayoutTests/http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html
new file mode 100644 (file)
index 0000000..7119ca7
--- /dev/null
@@ -0,0 +1,75 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src="/js-test-resources/ui-helper.js"></script>
+<script src="/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+
+description("Test the applepayvalidatemerchant event.");
+
+window.jsTestIsAsync = true;
+
+function validPaymentMethod() {
+    return {
+        supportedMethods: 'https://apple.com/apple-pay',
+        data: {
+            version: 2,
+            merchantIdentifier: '',
+            countryCode: 'US',
+            supportedNetworks: ['visa', 'masterCard'],
+            merchantCapabilities: ['supports3DS'],
+        },
+    }
+}
+
+function validPaymentDetails() {
+    return {
+        total: { label: 'Your label', amount: { currency: 'USD', value: '10.00' } },
+    }
+}
+
+function runTest(test) {
+    return new Promise((resolve, reject) => {
+        var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+        paymentRequest.onapplepayvalidatemerchant = (event) => {
+            test(event, paymentRequest);
+            paymentRequest.abort();
+            resolve();
+        };
+        paymentRequest.show().catch(() => {});
+    });
+}
+
+async function go() {
+    debug("Testing ApplePayMerchantValidationEvent")
+    debug("")
+
+    await runTest(event => shouldThrow(() => event.complete(undefined)));
+    await runTest(event => shouldThrow(() => event.complete(null)));
+    await runTest(event => shouldThrow(() => event.complete([])));
+    await runTest(event => shouldThrow(() => event.complete('')));
+    await runTest(event => shouldThrow(() => event.complete(7)));
+    await runTest(event => shouldThrow(() => { event.complete({}); event.complete({}); }));
+    await runTest((event, paymentRequest) => shouldThrow(() => { paymentRequest.abort(); event.complete({}); }));
+    await runTest(event => shouldNotThrow(() => event.complete({})));
+    await runTest(event => shouldBe("event.validationURL", "'https://webkit.org/'"));
+
+    document.querySelector("button").remove();
+    finishJSTest();
+}
+
+window.onload = function() {
+    var button = document.querySelector("button");
+    let x = button.offsetLeft + 2;
+    let y = button.offsetTop + 2;
+    UIHelper.activateAt(x, y);
+}
+
+</script>
+<button onclick='go()'>Go</button>
+<script src="/resources/js-test-post.js"></script>
+</body>
+</html>
index 1faf32a..1a572d0 100644 (file)
@@ -1,3 +1,41 @@
+2017-10-11  Andy Estes  <aestes@apple.com>
+
+        [Payment Request] Implement Apple Pay merchant validation
+        https://bugs.webkit.org/show_bug.cgi?id=178159
+
+        Reviewed by Brady Eidson.
+
+        When ApplePayPaymentHandler::validateMerchant() is called, dispatch the
+        applepayvalidatemerchant event to the PaymentRequest object.
+
+        The event object is an ApplePayMerchantValidationEvent, on which the client calls complete()
+        with a merchant session.
+
+        Test: http/tests/ssl/applepay/ApplePayMerchantValidationEvent.https.html
+
+        * DerivedSources.make:
+        * Modules/applepay/ApplePayValidateMerchantEvent.h:
+        * Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.cpp: Added.
+        (WebCore::ApplePayMerchantValidationEvent::create):
+        (WebCore::ApplePayMerchantValidationEvent::ApplePayMerchantValidationEvent):
+        (WebCore::ApplePayMerchantValidationEvent::complete):
+        (WebCore::ApplePayMerchantValidationEvent::eventInterface const):
+        * Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.h: Added.
+        * Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl: Added.
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::validateMerchant):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+        * Modules/paymentrequest/PaymentRequest.idl:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/EventNames.h:
+        * dom/EventNames.in:
+        * testing/Internals.cpp:
+        (WebCore::Internals::Internals):
+        * testing/MockPaymentCoordinator.cpp:
+        (WebCore::MockPaymentCoordinator::MockPaymentCoordinator):
+        (WebCore::MockPaymentCoordinator::showPaymentUI):
+        * testing/MockPaymentCoordinator.h:
+
 2017-10-11  Chris Dumez  <cdumez@apple.com>
 
         Modernize Geolocation code
index 57de18e..dacc708 100644 (file)
@@ -107,6 +107,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/applepay/ApplePayShippingMethodSelectedEvent.idl \
        $(WebCore)/Modules/applepay/ApplePayShippingMethodUpdate.idl \
     $(WebCore)/Modules/applepay/ApplePayValidateMerchantEvent.idl \
+    $(WebCore)/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl \
     $(WebCore)/Modules/applepay/paymentrequest/ApplePayRequest.idl \
     $(WebCore)/Modules/beacon/NavigatorBeacon.idl \
     $(WebCore)/Modules/cache/DOMWindowCaches.idl \
index 4515598..0435831 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace WebCore {
 
-class ApplePayValidateMerchantEvent final : public Event {
+class ApplePayValidateMerchantEvent : public Event {
 public:
     static Ref<ApplePayValidateMerchantEvent> create(const AtomicString& type, const URL& validationURL)
     {
@@ -43,12 +43,13 @@ public:
 
     const String& validationURL() const { return m_validationURL.string(); }
 
-private:
+protected:
     ApplePayValidateMerchantEvent(const AtomicString& type, const URL& validationURL);
 
     // Event.
     EventInterface eventInterface() const override;
 
+private:
     const URL m_validationURL;
 };
 
diff --git a/Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.cpp b/Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.cpp
new file mode 100644 (file)
index 0000000..f9b1c59
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#include "config.h"
+#include "ApplePayMerchantValidationEvent.h"
+
+#if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
+
+#include "Document.h"
+#include "MainFrame.h"
+#include "PaymentCoordinator.h"
+#include "PaymentMerchantSession.h"
+#include <runtime/JSCJSValueInlines.h>
+#include <runtime/JSObject.h>
+
+namespace WebCore {
+
+Ref<ApplePayMerchantValidationEvent> ApplePayMerchantValidationEvent::create(const AtomicString& type, const URL& validationURL)
+{
+    return adoptRef(*new ApplePayMerchantValidationEvent(type, validationURL));
+}
+
+ApplePayMerchantValidationEvent::ApplePayMerchantValidationEvent(const AtomicString& type, const URL& validationURL)
+    : ApplePayValidateMerchantEvent { type, validationURL }
+{
+}
+
+ExceptionOr<void> ApplePayMerchantValidationEvent::complete(Document& document, JSC::JSValue merchantSessionValue)
+{
+    if (m_isCompleted)
+        return Exception { InvalidStateError };
+    m_isCompleted = true;
+
+    auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
+    if (!paymentCoordinator.hasActiveSession())
+        return Exception { InvalidStateError };
+
+    if (!merchantSessionValue.isObject())
+        return Exception { TypeError };
+
+    String errorMessage;
+    auto merchantSession = PaymentMerchantSession::fromJS(*document.execState(), asObject(merchantSessionValue), errorMessage);
+    if (!merchantSession)
+        return Exception { TypeError, WTFMove(errorMessage) };
+
+    paymentCoordinator.completeMerchantValidation(*merchantSession);
+    return { };
+}
+
+EventInterface ApplePayMerchantValidationEvent::eventInterface() const
+{
+    return ApplePayMerchantValidationEventInterfaceType;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
diff --git a/Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.h b/Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.h
new file mode 100644 (file)
index 0000000..d57401a
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+#pragma once
+
+#if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
+
+#include "ApplePayValidateMerchantEvent.h"
+
+namespace JSC {
+class JSValue;
+}
+
+namespace WebCore {
+
+class Document;
+
+class ApplePayMerchantValidationEvent final : public ApplePayValidateMerchantEvent {
+public:
+    static Ref<ApplePayMerchantValidationEvent> create(const AtomicString&, const URL&);
+    ExceptionOr<void> complete(Document&, JSC::JSValue);
+
+private:
+    ApplePayMerchantValidationEvent(const AtomicString&, const URL&);
+
+    // Event
+    EventInterface eventInterface() const final;
+
+    bool m_isCompleted { false };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
diff --git a/Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl b/Source/WebCore/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl
new file mode 100644 (file)
index 0000000..afbd74a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 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.
+ */
+
+[
+    Conditional=APPLE_PAY&PAYMENT_REQUEST,
+    NoInterfaceObject,
+] interface ApplePayMerchantValidationEvent : ApplePayValidateMerchantEvent {
+    [MayThrowException, CallWith=Document] void complete(any merchantSession);
+};
index 3af2348..1b89de0 100644 (file)
 
 #include "ApplePayContactField.h"
 #include "ApplePayMerchantCapability.h"
+#include "ApplePayMerchantValidationEvent.h"
 #include "ApplePaySessionPaymentRequest.h"
 #include "Document.h"
+#include "EventNames.h"
 #include "JSApplePayRequest.h"
 #include "LinkIconCollector.h"
 #include "MainFrame.h"
@@ -232,6 +234,12 @@ void ApplePayPaymentHandler::canMakePayment(Document& document, WTF::Function<vo
     paymentCoordinator(document).canMakePaymentsWithActiveCard(m_applePayRequest->merchantIdentifier, document.domain(), WTFMove(completionHandler));
 }
 
+void ApplePayPaymentHandler::validateMerchant(const URL& validationURL)
+{
+    if (validationURL.isValid())
+        m_paymentRequest->dispatchEvent(ApplePayMerchantValidationEvent::create(eventNames().applepayvalidatemerchantEvent, validationURL).get());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
index 1e1a194..7f719eb 100644 (file)
@@ -53,7 +53,7 @@ private:
     void canMakePayment(Document&, WTF::Function<void(bool)>&& completionHandler) final;
 
     // PaymentSession
-    void validateMerchant(const URL&) final { }
+    void validateMerchant(const URL&) final;
     void didAuthorizePayment(const Payment&) final { }
     void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final { }
     void didSelectShippingContact(const PaymentContact&) final { }
index c95fe8e..7fa399a 100644 (file)
@@ -42,6 +42,7 @@
     readonly attribute PaymentShippingType? shippingType;
 
     attribute EventHandler onshippingaddresschange;
-
     attribute EventHandler onshippingoptionchange;
+
+    [Conditional=APPLE_PAY] attribute EventHandler onapplepayvalidatemerchant;
 };
index 0be0c85..524ed16 100644 (file)
                A1F76B551F44D2C70014C318 /* PaymentShippingOption.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F76B521F44D2C70014C318 /* PaymentShippingOption.h */; };
                A1F76B5B1F44D3B20014C318 /* PaymentComplete.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F76B581F44D3B20014C318 /* PaymentComplete.h */; };
                A1F78D0C1C25424C00245446 /* ResourceResponseCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1F78D0B1C25422C00245446 /* ResourceResponseCocoa.mm */; };
+               A1F929691F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F929661F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h */; };
+               A1F9296A1F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1F929671F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp */; };
+               A1F9296F1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1F9296D1F8D9F5A00523AF3 /* JSApplePayMerchantValidationEvent.cpp */; };
+               A1F929701F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F9296E1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h */; };
                A2B9217316C5CC420041DCD9 /* IntRectExtent.h in Headers */ = {isa = PBXBuildFile; fileRef = A2B9217216C5CC420041DCD9 /* IntRectExtent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A31C4E4D16E02AA6002F7957 /* OESTextureHalfFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A31C4E4C16E02AA6002F7957 /* OESTextureHalfFloat.cpp */; };
                A31C4E4F16E02AB4002F7957 /* OESTextureHalfFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = A31C4E4E16E02AB4002F7957 /* OESTextureHalfFloat.h */; };
                A1F76B581F44D3B20014C318 /* PaymentComplete.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentComplete.h; sourceTree = "<group>"; };
                A1F76B5A1F44D3B20014C318 /* PaymentComplete.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PaymentComplete.idl; sourceTree = "<group>"; };
                A1F78D0B1C25422C00245446 /* ResourceResponseCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResourceResponseCocoa.mm; sourceTree = "<group>"; };
+               A1F929661F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayMerchantValidationEvent.h; sourceTree = "<group>"; };
+               A1F929671F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ApplePayMerchantValidationEvent.cpp; sourceTree = "<group>"; };
+               A1F929681F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayMerchantValidationEvent.idl; sourceTree = "<group>"; };
+               A1F9296D1F8D9F5A00523AF3 /* JSApplePayMerchantValidationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayMerchantValidationEvent.cpp; sourceTree = "<group>"; };
+               A1F9296E1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayMerchantValidationEvent.h; sourceTree = "<group>"; };
                A208E222A56A0C7575F2A72E /* RenderMathMLMenclose.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMathMLMenclose.h; sourceTree = "<group>"; };
                A2B9217216C5CC420041DCD9 /* IntRectExtent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntRectExtent.h; sourceTree = "<group>"; };
                A31C4E4C16E02AA6002F7957 /* OESTextureHalfFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OESTextureHalfFloat.cpp; sourceTree = "<group>"; };
                                7C6579EA1E00856600E3A27A /* JSApplePayLineItem.h */,
                                A1DF5A891F7EC0000058A477 /* JSApplePayMerchantCapability.cpp */,
                                A1DF5A8A1F7EC0000058A477 /* JSApplePayMerchantCapability.h */,
+                               A1F9296D1F8D9F5A00523AF3 /* JSApplePayMerchantValidationEvent.cpp */,
+                               A1F9296E1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h */,
                                7C65231D1E018B5A00677F22 /* JSApplePayPayment.cpp */,
                                7C65230A1E00DBB400677F22 /* JSApplePayPayment.h */,
                                1ADFDFE31E71DCA0008F5D34 /* JSApplePayPaymentAuthorizationResult.cpp */,
                A1DF5A9F1F7EE0F10058A477 /* paymentrequest */ = {
                        isa = PBXGroup;
                        children = (
+                               A1F929671F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp */,
+                               A1F929661F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h */,
+                               A1F929681F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.idl */,
                                A1DF5AA11F7EE1130058A477 /* ApplePayPaymentHandler.cpp */,
                                A1DF5AA01F7EE1130058A477 /* ApplePayPaymentHandler.h */,
                                A1DF5A7C1F7EBD0B0058A477 /* ApplePayRequest.h */,
                                A1DF5A941F7EC4320058A477 /* ApplePayContactField.h in Headers */,
                                7C6579E31E00827000E3A27A /* ApplePayLineItem.h in Headers */,
                                A1DF5A861F7EBDF20058A477 /* ApplePayMerchantCapability.h in Headers */,
+                               A1F929691F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.h in Headers */,
                                7C6523011E00D03400677F22 /* ApplePayPayment.h in Headers */,
                                1A8A64521D19FCFB00D0E00F /* ApplePayPaymentAuthorizedEvent.h in Headers */,
                                7C6522FB1E00C90900677F22 /* ApplePayPaymentContact.h in Headers */,
                                A1DF5A991F7EC8C00058A477 /* JSApplePayContactField.h in Headers */,
                                7C6579F01E00856600E3A27A /* JSApplePayLineItem.h in Headers */,
                                A1DF5A8E1F7EC0020058A477 /* JSApplePayMerchantCapability.h in Headers */,
+                               A1F929701F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.h in Headers */,
                                7C6523141E00DBB400677F22 /* JSApplePayPayment.h in Headers */,
                                1AE96A8B1D1A0DDD00B86768 /* JSApplePayPaymentAuthorizedEvent.h in Headers */,
                                7C6523161E00DBB500677F22 /* JSApplePayPaymentContact.h in Headers */,
                                A1DF5AB51F8078F30058A477 /* ApplePayContactField.cpp in Sources */,
                                1ADFDFE01E71D8EE008F5D34 /* ApplePayError.cpp in Sources */,
                                A1DF5AA91F8070D40058A477 /* ApplePayMerchantCapability.cpp in Sources */,
+                               A1F9296A1F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.cpp in Sources */,
                                1A8A64511D19FCFB00D0E00F /* ApplePayPaymentAuthorizedEvent.cpp in Sources */,
                                A1DF5AA31F7EE1130058A477 /* ApplePayPaymentHandler.cpp in Sources */,
                                1A8A64541D19FCFC00D0E00F /* ApplePayPaymentMethodSelectedEvent.cpp in Sources */,
                                1ADFDFEC1E71E455008F5D34 /* JSApplePayError.cpp in Sources */,
                                7C6579EF1E00856600E3A27A /* JSApplePayLineItem.cpp in Sources */,
                                A1DF5A8D1F7EC0020058A477 /* JSApplePayMerchantCapability.cpp in Sources */,
+                               A1F9296F1F8D9F5B00523AF3 /* JSApplePayMerchantValidationEvent.cpp in Sources */,
                                7C65231E1E018B5A00677F22 /* JSApplePayPayment.cpp in Sources */,
                                1ADFDFF01E71E4AC008F5D34 /* JSApplePayPaymentAuthorizationResult.cpp in Sources */,
                                1AE96A8A1D1A0DDD00B86768 /* JSApplePayPaymentAuthorizedEvent.cpp in Sources */,
index afd0987..9f49570 100644 (file)
@@ -53,6 +53,7 @@ namespace WebCore {
     macro(animationend) \
     macro(animationiteration) \
     macro(animationstart) \
+    macro(applepayvalidatemerchant) \
     macro(audioend) \
     macro(audioprocess) \
     macro(audiostart) \
index 78f78de..79ff3fc 100644 (file)
@@ -35,6 +35,7 @@ WebKitAnimationEvent
 WebKitTransitionEvent
 WheelEvent
 XMLHttpRequestProgressEvent
+ApplePayMerchantValidationEvent conditional=APPLE_PAY
 ApplePayPaymentAuthorizedEvent conditional=APPLE_PAY
 ApplePayPaymentMethodSelectedEvent conditional=APPLE_PAY
 ApplePayShippingContactSelectedEvent conditional=APPLE_PAY
index d9f61ff..b05758d 100644 (file)
@@ -508,7 +508,7 @@ Internals::Internals(Document& document)
 
 #if ENABLE(APPLE_PAY)
     if (auto frame = document.frame())
-        frame->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*new MockPaymentCoordinator()));
+        frame->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*new MockPaymentCoordinator(frame->mainFrame())));
 #endif
 }
 
index ff7a4a4..9794b28 100644 (file)
 
 #if ENABLE(APPLE_PAY)
 
+#include "MainFrame.h"
+#include "PaymentCoordinator.h"
+#include "URL.h"
 #include <wtf/RunLoop.h>
 
 namespace WebCore {
 
+MockPaymentCoordinator::MockPaymentCoordinator(MainFrame& mainFrame)
+    : m_mainFrame { mainFrame }
+{
+}
+
 bool MockPaymentCoordinator::supportsVersion(unsigned version)
 {
     ASSERT(version > 0);
@@ -66,6 +74,9 @@ void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, WTF:
 
 bool MockPaymentCoordinator::showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&)
 {
+    RunLoop::main().dispatch([mainFrame = makeRef(m_mainFrame)]() {
+        mainFrame->paymentCoordinator().validateMerchant({ URL(), ASCIILiteral("https://webkit.org/") });
+    });
     return true;
 }
 
index a9ca7ee..22be9b3 100644 (file)
 #include "PaymentCoordinatorClient.h"
 
 namespace WebCore {
+    
+class MainFrame;
 
 class MockPaymentCoordinator final : public PaymentCoordinatorClient {
+public:
+    explicit MockPaymentCoordinator(MainFrame&);
+
 private:
     bool supportsVersion(unsigned) final;
     bool canMakePayments() final;
@@ -46,6 +51,8 @@ private:
     void abortPaymentSession() final { }
     void cancelPaymentSession() final { }
     void paymentCoordinatorDestroyed() final;
+
+    MainFrame& m_mainFrame;
 };
 
 } // namespace WebCore