Title: [223945] trunk
Revision
223945
Author
aes...@apple.com
Date
2017-10-24 17:52:04 -0700 (Tue, 24 Oct 2017)

Log Message

[Apple Pay] Implement a paymentmethodselected event for PaymentRequest
https://bugs.webkit.org/show_bug.cgi?id=178765

Reviewed by Tim Horton.

Source/WebCore:

When the Apple Pay payment method changes, fire an applepaypaymentmethodchanged event on the
PaymentRequest object. The event has a paymentMethod property and an updateWith() method
which behaves identically to PaymentRequestUpdateEvent.updateWith().

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

* DerivedSources.make:
* Modules/applepay/ApplePayPaymentMethod.idl:
* Modules/applepay/ApplePayPaymentMethodSelectedEvent.h:
* Modules/applepay/PaymentMethod.h:
(WebCore::PaymentMethod::PaymentMethod): Deleted.
(WebCore::PaymentMethod::pkPaymentMethod const): Deleted.
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::detailsUpdated):
(WebCore::ApplePayPaymentHandler::paymentMethodUpdated):
(WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp: Added.
(WebCore::ApplePayPaymentMethodUpdateEvent::ApplePayPaymentMethodUpdateEvent):
(WebCore::ApplePayPaymentMethodUpdateEvent::eventInterface const):
* Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h: Added.
* Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl: Added.
* Modules/paymentrequest/PaymentHandler.h:
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged):
(WebCore::PaymentRequest::shippingOptionChanged):
(WebCore::PaymentRequest::dispatchEvent):
(WebCore::PaymentRequest::updateWith):
(WebCore::PaymentRequest::settleDetailsPromise):
(WebCore::PaymentRequest::dispatchUpdateEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h:
* Modules/paymentrequest/PaymentRequest.idl:
* Modules/paymentrequest/PaymentRequestUpdateEvent.cpp:
(WebCore::PaymentRequestUpdateEvent::updateWith):
* Modules/paymentrequest/PaymentRequestUpdateEvent.h:
* WebCore.xcodeproj/project.pbxproj:
* dom/EventNames.h:
* dom/EventNames.in:
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::changePaymentMethod):
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.idl:
* testing/MockPaymentMethod.h: Added.

LayoutTests:

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (223944 => 223945)


--- trunk/LayoutTests/ChangeLog	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/LayoutTests/ChangeLog	2017-10-25 00:52:04 UTC (rev 223945)
@@ -1,3 +1,13 @@
+2017-10-24  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Implement a paymentmethodselected event for PaymentRequest
+        https://bugs.webkit.org/show_bug.cgi?id=178765
+
+        Reviewed by Tim Horton.
+
+        * http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt: Added.
+        * http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html: Added.
+
 2017-10-24  Daniel Bates  <daba...@apple.com>
 
         Test fast/writing-mode/english-bt-text-with-spelling-marker.html should wait for editing commands to complete

Added: trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt (0 => 223945)


--- trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https-expected.txt	2017-10-25 00:52:04 UTC (rev 223945)
@@ -0,0 +1,19 @@
+Test the applepaypaymentmethodchanged event.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing ApplePayMerchantValidationEvent
+
+PASS event.paymentMethod.displayName is expectedPaymentMethod.displayName
+PASS event.paymentMethod.network is expectedPaymentMethod.network
+PASS event.paymentMethod.type is expectedPaymentMethod.type
+PASS event.paymentMethod.paymentPass.primaryAccountIdentifier is expectedPaymentMethod.paymentPass.primaryAccountIdentifier
+PASS event.paymentMethod.paymentPass.primaryAccountNumberSuffix is expectedPaymentMethod.paymentPass.primaryAccountNumberSuffix
+PASS event.paymentMethod.paymentPass.deviceAccountIdentifier is expectedPaymentMethod.paymentPass.deviceAccountIdentifier
+PASS event.paymentMethod.paymentPass.deviceAccountNumberSuffix is expectedPaymentMethod.paymentPass.deviceAccountNumberSuffix
+PASS event.paymentMethod.paymentPass.activationState is expectedPaymentMethod.paymentPass.activationState
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html (0 => 223945)


--- trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html	2017-10-25 00:52:04 UTC (rev 223945)
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test the applepaypaymentmethodchanged 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' } },
+    }
+}
+
+async function go() {
+    debug("Testing ApplePayMerchantValidationEvent");
+    debug("");
+
+    expectedPaymentMethod = {
+        displayName: 'test',
+        network: 'test',
+        type: 'prepaid',
+        paymentPass: {
+            primaryAccountIdentifier: 'test',
+            primaryAccountNumberSuffix: 'test',
+            deviceAccountIdentifier: 'test',
+            deviceAccountNumberSuffix: 'test',
+            activationState: 'requiresActivation',
+        },
+    };
+
+    var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+    paymentRequest._onapplepaypaymentmethodchanged_ = (event) => {
+        shouldBe("event.paymentMethod.displayName", "expectedPaymentMethod.displayName");
+        shouldBe("event.paymentMethod.network", "expectedPaymentMethod.network");
+        shouldBe("event.paymentMethod.type", "expectedPaymentMethod.type");
+        shouldBe("event.paymentMethod.paymentPass.primaryAccountIdentifier", "expectedPaymentMethod.paymentPass.primaryAccountIdentifier");
+        shouldBe("event.paymentMethod.paymentPass.primaryAccountNumberSuffix", "expectedPaymentMethod.paymentPass.primaryAccountNumberSuffix");
+        shouldBe("event.paymentMethod.paymentPass.deviceAccountIdentifier", "expectedPaymentMethod.paymentPass.deviceAccountIdentifier");
+        shouldBe("event.paymentMethod.paymentPass.deviceAccountNumberSuffix", "expectedPaymentMethod.paymentPass.deviceAccountNumberSuffix");
+        shouldBe("event.paymentMethod.paymentPass.activationState", "expectedPaymentMethod.paymentPass.activationState");
+
+        document.querySelector("button").remove();
+        finishJSTest();
+    };
+    
+    paymentRequest.show();
+    internals.mockPaymentCoordinator.changePaymentMethod(expectedPaymentMethod);
+}
+
+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=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (223944 => 223945)


--- trunk/Source/WebCore/ChangeLog	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/ChangeLog	2017-10-25 00:52:04 UTC (rev 223945)
@@ -1,3 +1,54 @@
+2017-10-24  Andy Estes  <aes...@apple.com>
+
+        [Apple Pay] Implement a paymentmethodselected event for PaymentRequest
+        https://bugs.webkit.org/show_bug.cgi?id=178765
+
+        Reviewed by Tim Horton.
+
+        When the Apple Pay payment method changes, fire an applepaypaymentmethodchanged event on the
+        PaymentRequest object. The event has a paymentMethod property and an updateWith() method
+        which behaves identically to PaymentRequestUpdateEvent.updateWith().
+
+        Test: http/tests/ssl/applepay/ApplePayPaymentMethodUpdateEvent.https.html
+
+        * DerivedSources.make:
+        * Modules/applepay/ApplePayPaymentMethod.idl:
+        * Modules/applepay/ApplePayPaymentMethodSelectedEvent.h:
+        * Modules/applepay/PaymentMethod.h:
+        (WebCore::PaymentMethod::PaymentMethod): Deleted.
+        (WebCore::PaymentMethod::pkPaymentMethod const): Deleted.
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::detailsUpdated):
+        (WebCore::ApplePayPaymentHandler::paymentMethodUpdated):
+        (WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+        * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp: Added.
+        (WebCore::ApplePayPaymentMethodUpdateEvent::ApplePayPaymentMethodUpdateEvent):
+        (WebCore::ApplePayPaymentMethodUpdateEvent::eventInterface const):
+        * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h: Added.
+        * Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl: Added.
+        * Modules/paymentrequest/PaymentHandler.h:
+        * Modules/paymentrequest/PaymentRequest.cpp:
+        (WebCore::PaymentRequest::shippingAddressChanged):
+        (WebCore::PaymentRequest::shippingOptionChanged):
+        (WebCore::PaymentRequest::dispatchEvent):
+        (WebCore::PaymentRequest::updateWith):
+        (WebCore::PaymentRequest::settleDetailsPromise):
+        (WebCore::PaymentRequest::dispatchUpdateEvent): Deleted.
+        * Modules/paymentrequest/PaymentRequest.h:
+        * Modules/paymentrequest/PaymentRequest.idl:
+        * Modules/paymentrequest/PaymentRequestUpdateEvent.cpp:
+        (WebCore::PaymentRequestUpdateEvent::updateWith):
+        * Modules/paymentrequest/PaymentRequestUpdateEvent.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/EventNames.h:
+        * dom/EventNames.in:
+        * testing/MockPaymentCoordinator.cpp:
+        (WebCore::MockPaymentCoordinator::changePaymentMethod):
+        * testing/MockPaymentCoordinator.h:
+        * testing/MockPaymentCoordinator.idl:
+        * testing/MockPaymentMethod.h: Added.
+
 2017-10-24  Youenn Fablet  <you...@apple.com>
 
         ServiceWorkerClientFetch should return an error that is not null in case of failure

Modified: trunk/Source/WebCore/DerivedSources.make (223944 => 223945)


--- trunk/Source/WebCore/DerivedSources.make	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/DerivedSources.make	2017-10-25 00:52:04 UTC (rev 223945)
@@ -108,6 +108,7 @@
 	$(WebCore)/Modules/applepay/ApplePayShippingMethodUpdate.idl \
     $(WebCore)/Modules/applepay/ApplePayValidateMerchantEvent.idl \
     $(WebCore)/Modules/applepay/paymentrequest/ApplePayMerchantValidationEvent.idl \
+    $(WebCore)/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl \
     $(WebCore)/Modules/applepay/paymentrequest/ApplePayRequest.idl \
     $(WebCore)/Modules/beacon/NavigatorBeacon.idl \
     $(WebCore)/Modules/cache/DOMWindowCaches.idl \

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethod.idl (223944 => 223945)


--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethod.idl	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethod.idl	2017-10-25 00:52:04 UTC (rev 223945)
@@ -34,6 +34,7 @@
 
 [
     Conditional=APPLE_PAY,
+    ExportMacro=WEBCORE_EXPORT,
     JSGenerateToJSObject
 ] dictionary ApplePayPaymentMethod {
     DOMString displayName;

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethodSelectedEvent.h (223944 => 223945)


--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethodSelectedEvent.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethodSelectedEvent.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -34,7 +34,7 @@
 
 class PaymentMethod;
 
-class ApplePayPaymentMethodSelectedEvent final : public Event {
+class ApplePayPaymentMethodSelectedEvent : public Event {
 public:
     static Ref<ApplePayPaymentMethodSelectedEvent> create(const AtomicString& type, const PaymentMethod& paymentMethod)
     {
@@ -45,12 +45,13 @@
 
     const ApplePayPaymentMethod& paymentMethod() { return m_paymentMethod; }
 
-private:
+protected:
     ApplePayPaymentMethodSelectedEvent(const AtomicString& type, const PaymentMethod&);
 
     // Event.
     EventInterface eventInterface() const override;
 
+private:
     const ApplePayPaymentMethod m_paymentMethod;
 };
 

Modified: trunk/Source/WebCore/Modules/applepay/PaymentMethod.h (223944 => 223945)


--- trunk/Source/WebCore/Modules/applepay/PaymentMethod.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/applepay/PaymentMethod.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -35,11 +35,10 @@
 
 struct ApplePayPaymentMethod;
 
-class PaymentMethod {
+class WEBCORE_EXPORT PaymentMethod {
 public:
-    PaymentMethod()
-    {
-    }
+    PaymentMethod() = default;
+    virtual ~PaymentMethod() = default;
 
     explicit PaymentMethod(PKPaymentMethod *pkPaymentMethod)
         : m_pkPaymentMethod(pkPaymentMethod)
@@ -46,7 +45,7 @@
     {
     }
 
-    ApplePayPaymentMethod toApplePayPaymentMethod() const;
+    virtual ApplePayPaymentMethod toApplePayPaymentMethod() const;
 
     PKPaymentMethod *pkPaymentMethod() const { return m_pkPaymentMethod.get(); }
 

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (223944 => 223945)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2017-10-25 00:52:04 UTC (rev 223945)
@@ -32,6 +32,7 @@
 #include "ApplePayMerchantCapability.h"
 #include "ApplePayMerchantValidationEvent.h"
 #include "ApplePayPayment.h"
+#include "ApplePayPaymentMethodUpdateEvent.h"
 #include "ApplePaySessionPaymentRequest.h"
 #include "Document.h"
 #include "EventNames.h"
@@ -44,6 +45,7 @@
 #include "PaymentAuthorizationStatus.h"
 #include "PaymentContact.h"
 #include "PaymentCoordinator.h"
+#include "PaymentMethod.h"
 #include "PaymentRequestValidator.h"
 #include "PaymentResponse.h"
 #include "Settings.h"
@@ -267,6 +269,21 @@
     return ApplePaySessionPaymentRequest::TotalAndLineItems { total.releaseReturnValue(), lineItems.releaseReturnValue() };
 }
 
+ExceptionOr<void> ApplePayPaymentHandler::detailsUpdated(const AtomicString& eventType, const String& error)
+{
+    if (eventType == eventNames().shippingaddresschangeEvent)
+        return shippingAddressUpdated(error);
+
+    if (eventType == eventNames().shippingoptionchangeEvent)
+        return shippingOptionUpdated();
+
+    if (eventType == eventNames().applepaypaymentmethodchangedEvent)
+        return paymentMethodUpdated();
+
+    ASSERT_NOT_REACHED();
+    return { };
+}
+
 ExceptionOr<void> ApplePayPaymentHandler::shippingAddressUpdated(const String& error)
 {
     ShippingContactUpdate update;
@@ -300,6 +317,19 @@
     return { };
 }
 
+ExceptionOr<void> ApplePayPaymentHandler::paymentMethodUpdated()
+{
+    PaymentMethodUpdate update;
+
+    auto newTotalAndLineItems = convertAndValidate(m_paymentRequest->paymentDetails());
+    if (newTotalAndLineItems.hasException())
+        return newTotalAndLineItems.releaseException();
+    update.newTotalAndLineItems = newTotalAndLineItems.releaseReturnValue();
+
+    paymentCoordinator().completePaymentMethodSelection(WTFMove(update));
+    return { };
+}
+
 void ApplePayPaymentHandler::complete(std::optional<PaymentComplete>&& result)
 {
     if (!result) {
@@ -353,6 +383,12 @@
     m_paymentRequest->shippingAddressChanged(convert(shippingContact.toApplePayPaymentContact()));
 }
 
+void ApplePayPaymentHandler::didSelectPaymentMethod(const PaymentMethod& paymentMethod)
+{
+    auto event = ApplePayPaymentMethodUpdateEvent::create(eventNames().applepaypaymentmethodchangedEvent, paymentMethod.toApplePayPaymentMethod(), m_paymentRequest.get());
+    m_paymentRequest->dispatchEvent(event.get());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (223944 => 223945)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -51,13 +51,16 @@
     Document& document();
     PaymentCoordinator& paymentCoordinator();
 
+    ExceptionOr<void> shippingAddressUpdated(const String& error);
+    ExceptionOr<void> shippingOptionUpdated();
+    ExceptionOr<void> paymentMethodUpdated();
+
     // PaymentHandler
     ExceptionOr<void> convertData(JSC::JSValue&&) final;
     ExceptionOr<void> show() final;
     void hide() final;
     void canMakePayment(WTF::Function<void(bool)>&& completionHandler) final;
-    ExceptionOr<void> shippingAddressUpdated(const String& error) final;
-    ExceptionOr<void> shippingOptionUpdated() final;
+    ExceptionOr<void> detailsUpdated(const AtomicString& eventType, const String& error) final;
     void complete(std::optional<PaymentComplete>&&) final;
 
     // PaymentSession
@@ -65,7 +68,7 @@
     void didAuthorizePayment(const Payment&) final;
     void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final;
     void didSelectShippingContact(const PaymentContact&) final;
-    void didSelectPaymentMethod(const PaymentMethod&) final { }
+    void didSelectPaymentMethod(const PaymentMethod&) final;
     void didCancelPaymentSession() final { }
 
     PaymentRequest::MethodIdentifier m_identifier;

Copied: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp (from rev 223944, trunk/Source/WebCore/testing/MockPaymentCoordinator.idl) (0 => 223945)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.cpp	2017-10-25 00:52:04 UTC (rev 223945)
@@ -0,0 +1,48 @@
+/*
+ * 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 "ApplePayPaymentMethodUpdateEvent.h"
+
+#if ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
+
+#include "PaymentRequest.h"
+
+namespace WebCore {
+
+ApplePayPaymentMethodUpdateEvent::ApplePayPaymentMethodUpdateEvent(const AtomicString& type, const ApplePayPaymentMethod& paymentMethod, PaymentRequest& paymentRequest)
+    : PaymentRequestUpdateEvent { type, paymentRequest }
+    , m_paymentMethod { paymentMethod }
+{
+}
+
+EventInterface ApplePayPaymentMethodUpdateEvent::eventInterface() const
+{
+    return ApplePayPaymentMethodUpdateEventInterfaceType;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)

Copied: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h (from rev 223944, trunk/Source/WebCore/Modules/applepay/ApplePayPaymentMethodSelectedEvent.h) (0 => 223945)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -0,0 +1,55 @@
+/*
+ * 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 "ApplePayPaymentMethod.h"
+#include "PaymentRequestUpdateEvent.h"
+
+namespace WebCore {
+
+class ApplePayPaymentMethodUpdateEvent final : public PaymentRequestUpdateEvent {
+public:
+    template <typename... Args> static Ref<ApplePayPaymentMethodUpdateEvent> create(Args&&... args)
+    {
+        return adoptRef(*new ApplePayPaymentMethodUpdateEvent(std::forward<Args>(args)...));
+    }
+
+    const ApplePayPaymentMethod& paymentMethod() const { return m_paymentMethod; }
+
+private:
+    ApplePayPaymentMethodUpdateEvent(const AtomicString& type, const ApplePayPaymentMethod&, PaymentRequest&);
+
+    // Event
+    EventInterface eventInterface() const final;
+
+    const ApplePayPaymentMethod m_paymentMethod;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)

Copied: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl (from rev 223944, trunk/Source/WebCore/testing/MockPaymentCoordinator.idl) (0 => 223945)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentMethodUpdateEvent.idl	2017-10-25 00:52:04 UTC (rev 223945)
@@ -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 ApplePayPaymentMethodUpdateEvent : PaymentRequestUpdateEvent {
+    [CachedAttribute] readonly attribute ApplePayPaymentMethod paymentMethod;
+};

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h (223944 => 223945)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -48,8 +48,7 @@
     virtual ExceptionOr<void> show() = 0;
     virtual void hide() = 0;
     virtual void canMakePayment(WTF::Function<void(bool)>&& completionHandler) = 0;
-    virtual ExceptionOr<void> shippingAddressUpdated(const String& error) = 0;
-    virtual ExceptionOr<void> shippingOptionUpdated() = 0;
+    virtual ExceptionOr<void> detailsUpdated(const AtomicString& eventType, const String& error) = 0;
     virtual void complete(std::optional<PaymentComplete>&&) = 0;
 };
 

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (223944 => 223945)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2017-10-25 00:52:04 UTC (rev 223945)
@@ -524,7 +524,8 @@
 {
     ASSERT(m_state == State::Interactive);
     m_shippingAddress = WTFMove(shippingAddress);
-    dispatchUpdateEvent(eventNames().shippingaddresschangeEvent);
+    auto event = PaymentRequestUpdateEvent::create(eventNames().shippingaddresschangeEvent, *this);
+    dispatchEvent(event.get());
 }
 
 void PaymentRequest::shippingOptionChanged(const String& shippingOption)
@@ -531,29 +532,26 @@
 {
     ASSERT(m_state == State::Interactive);
     m_shippingOption = shippingOption;
-    dispatchUpdateEvent(eventNames().shippingoptionchangeEvent);
+    auto event = PaymentRequestUpdateEvent::create(eventNames().shippingoptionchangeEvent, *this);
+    dispatchEvent(event.get());
 }
 
-void PaymentRequest::dispatchUpdateEvent(const AtomicString& type)
+bool PaymentRequest::dispatchEvent(Event& event)
 {
+    if (!event.isTrusted())
+        return EventTargetWithInlineData::dispatchEvent(event);
+
     if (m_isUpdating)
-        return;
+        return false;
 
     if (m_state != State::Interactive)
-        return;
+        return false;
 
-    auto event = PaymentRequestUpdateEvent::create(type, *this);
-    dispatchEvent(event.get());
+    return EventTargetWithInlineData::dispatchEvent(event);
 }
 
-ExceptionOr<void> PaymentRequest::updateWith(PaymentRequestUpdateEvent& event, Ref<DOMPromise>&& promise)
+ExceptionOr<void> PaymentRequest::updateWith(Event& event, Ref<DOMPromise>&& promise)
 {
-    if (!event.isTrusted())
-        return Exception { InvalidStateError };
-
-    if (event.waitForUpdate())
-        return Exception { InvalidStateError };
-
     if (m_state != State::Interactive)
         return Exception { InvalidStateError };
 
@@ -562,7 +560,6 @@
 
     event.stopPropagation();
     event.stopImmediatePropagation();
-    event.setWaitForUpdate(true);
     m_isUpdating = true;
 
     m_detailsPromise = WTFMove(promise);
@@ -579,6 +576,9 @@
         m_isUpdating = false;
     });
 
+    if (m_state != State::Interactive)
+        return;
+
     if (m_detailsPromise->status() == DOMPromise::Status::Rejected) {
         stop();
         return;
@@ -616,12 +616,11 @@
     m_details.modifiers = WTFMove(paymentDetailsUpdate.modifiers);
     m_serializedModifierData = WTFMove(std::get<1>(shippingOptionAndModifierData));
 
-    if (type == eventNames().shippingaddresschangeEvent)
-        m_activePaymentHandler->shippingAddressUpdated(paymentDetailsUpdate.error);
-    else if (type == eventNames().shippingoptionchangeEvent)
-        m_activePaymentHandler->shippingOptionUpdated();
-    else
-        ASSERT_NOT_REACHED();
+    auto result = m_activePaymentHandler->detailsUpdated(type, paymentDetailsUpdate.error);
+    if (result.hasException()) {
+        abortWithException(result.releaseException());
+        return;
+    }
 }
 
 void PaymentRequest::accept(const String& methodName, JSC::Strong<JSC::JSObject>&& details, Ref<PaymentAddress>&& shippingAddress, const String& payerName, const String& payerEmail, const String& payerPhone)

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (223944 => 223945)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -39,9 +39,9 @@
 namespace WebCore {
 
 class Document;
+class Event;
 class PaymentAddress;
 class PaymentHandler;
-class PaymentRequestUpdateEvent;
 class PaymentResponse;
 enum class PaymentComplete;
 enum class PaymentShippingType;
@@ -70,10 +70,13 @@
 
     void shippingAddressChanged(Ref<PaymentAddress>&&);
     void shippingOptionChanged(const String& shippingOption);
-    ExceptionOr<void> updateWith(PaymentRequestUpdateEvent&, Ref<DOMPromise>&&);
+    ExceptionOr<void> updateWith(Event&, Ref<DOMPromise>&&);
     void accept(const String& methodName, JSC::Strong<JSC::JSObject>&& details, Ref<PaymentAddress>&& shippingAddress, const String& payerName, const String& payerEmail, const String& payerPhone);
     void complete(std::optional<PaymentComplete>&&);
 
+    // EventTarget
+    bool dispatchEvent(Event&) final;
+
     using MethodIdentifier = Variant<String, URL>;
     using RefCounted<PaymentRequest>::ref;
     using RefCounted<PaymentRequest>::deref;
@@ -92,7 +95,6 @@
 
     PaymentRequest(Document&, PaymentOptions&&, PaymentDetailsInit&&, Vector<String>&& serializedModifierData, Vector<Method>&& serializedMethodData, String&& selectedShippingOption);
 
-    void dispatchUpdateEvent(const AtomicString& type);
     void settleDetailsPromise(const AtomicString& type);
     void abortWithException(Exception&&);
 

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl (223944 => 223945)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.idl	2017-10-25 00:52:04 UTC (rev 223945)
@@ -45,4 +45,5 @@
     attribute EventHandler onshippingoptionchange;
 
     [Conditional=APPLE_PAY] attribute EventHandler onapplepayvalidatemerchant;
+    [Conditional=APPLE_PAY] attribute EventHandler onapplepaypaymentmethodchanged;
 };

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp (223944 => 223945)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp	2017-10-25 00:52:04 UTC (rev 223945)
@@ -47,7 +47,18 @@
 
 ExceptionOr<void> PaymentRequestUpdateEvent::updateWith(Ref<DOMPromise>&& detailsPromise)
 {
-    return m_paymentRequest->updateWith(*this, WTFMove(detailsPromise));
+    if (!isTrusted())
+        return Exception { InvalidStateError };
+
+    if (m_waitForUpdate)
+        return Exception { InvalidStateError };
+
+    auto exception = m_paymentRequest->updateWith(*this, WTFMove(detailsPromise));
+    if (exception.hasException())
+        return exception.releaseException();
+
+    m_waitForUpdate = true;
+    return { };
 }
 
 EventInterface PaymentRequestUpdateEvent::eventInterface() const

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.h (223944 => 223945)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -36,7 +36,7 @@
 class PaymentRequest;
 struct PaymentRequestUpdateEventInit;
 
-class PaymentRequestUpdateEvent final : public Event {
+class PaymentRequestUpdateEvent : public Event {
 public:
     template <typename... Args> static Ref<PaymentRequestUpdateEvent> create(Args&&... args)
     {
@@ -45,16 +45,15 @@
     ~PaymentRequestUpdateEvent();
     ExceptionOr<void> updateWith(Ref<DOMPromise>&&);
 
-    bool waitForUpdate() const { return m_waitForUpdate; }
-    void setWaitForUpdate(bool waitForUpdate) { m_waitForUpdate = waitForUpdate; }
+protected:
+    PaymentRequestUpdateEvent(const AtomicString& type, PaymentRequest&);
 
+    // Event
+    EventInterface eventInterface() const override;
+
 private:
     PaymentRequestUpdateEvent(const AtomicString& type, PaymentRequestUpdateEventInit&&);
-    PaymentRequestUpdateEvent(const AtomicString& type, PaymentRequest&);
 
-    // Event
-    EventInterface eventInterface() const final;
-
     RefPtr<PaymentRequest> m_paymentRequest;
     bool m_waitForUpdate { false };
 };

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223944 => 223945)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-25 00:52:04 UTC (rev 223945)
@@ -3635,6 +3635,11 @@
 		A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BF6B811AA96C7D00AF4A8A /* MockContentFilter.h */; };
 		A1C150791E3F2B3E0032C98C /* PreviewConverter.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1C150771E3F2B3E0032C98C /* PreviewConverter.mm */; };
 		A1C1507A1E3F2B3E0032C98C /* PreviewConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C150781E3F2B3E0032C98C /* PreviewConverter.h */; };
+		A1CBEF531F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CBEF501F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h */; };
+		A1CBEF541F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1CBEF511F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp */; };
+		A1CBEF611F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1CBEF5F1F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp */; };
+		A1CBEF621F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CBEF601F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.h */; };
+		A1CBEF641F9F11290028DE7C /* MockPaymentMethod.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CBEF631F9F11290028DE7C /* MockPaymentMethod.h */; };
 		A1CC11641E493D0100EFA69C /* FileSystemMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1CC11621E493D0100EFA69C /* FileSystemMac.mm */; };
 		A1CC56671F46147A00A4555B /* JSPaymentAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CC56651F46146800A4555B /* JSPaymentAddress.h */; };
 		A1CC56691F46148000A4555B /* JSPaymentComplete.h in Headers */ = {isa = PBXBuildFile; fileRef = A1CC564E1F46145200A4555B /* JSPaymentComplete.h */; };
@@ -11832,6 +11837,12 @@
 		A1C150771E3F2B3E0032C98C /* PreviewConverter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreviewConverter.mm; sourceTree = "<group>"; };
 		A1C150781E3F2B3E0032C98C /* PreviewConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreviewConverter.h; sourceTree = "<group>"; };
 		A1C7FAA1133A5D3500D6732D /* JSXPathResultCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXPathResultCustom.cpp; sourceTree = "<group>"; };
+		A1CBEF501F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ApplePayPaymentMethodUpdateEvent.h; sourceTree = "<group>"; };
+		A1CBEF511F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ApplePayPaymentMethodUpdateEvent.cpp; sourceTree = "<group>"; };
+		A1CBEF521F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ApplePayPaymentMethodUpdateEvent.idl; sourceTree = "<group>"; };
+		A1CBEF5F1F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSApplePayPaymentMethodUpdateEvent.cpp; sourceTree = "<group>"; };
+		A1CBEF601F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSApplePayPaymentMethodUpdateEvent.h; sourceTree = "<group>"; };
+		A1CBEF631F9F11290028DE7C /* MockPaymentMethod.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentMethod.h; sourceTree = "<group>"; };
 		A1CC11621E493D0100EFA69C /* FileSystemMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystemMac.mm; sourceTree = "<group>"; };
 		A1CC564C1F46145000A4555B /* JSPaymentMethodData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentMethodData.h; sourceTree = "<group>"; };
 		A1CC564D1F46145100A4555B /* JSPaymentMethodData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentMethodData.cpp; sourceTree = "<group>"; };
@@ -16497,6 +16508,8 @@
 				1AE96A7D1D1A0A8000B86768 /* JSApplePayPaymentMethodSelectedEvent.h */,
 				1ADFDFE51E71DCA0008F5D34 /* JSApplePayPaymentMethodUpdate.cpp */,
 				1ADFDFE61E71DCA0008F5D34 /* JSApplePayPaymentMethodUpdate.h */,
+				A1CBEF5F1F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp */,
+				A1CBEF601F9F09020028DE7C /* JSApplePayPaymentMethodUpdateEvent.h */,
 				7C65230F1E00DBB400677F22 /* JSApplePayPaymentPass.cpp */,
 				7C6523101E00DBB400677F22 /* JSApplePayPaymentPass.h */,
 				7C6579EB1E00856600E3A27A /* JSApplePayPaymentRequest.cpp */,
@@ -17277,6 +17290,7 @@
 				A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */,
 				A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */,
 				A146D3161F99B53D00D29196 /* MockPaymentCoordinator.idl */,
+				A1CBEF631F9F11290028DE7C /* MockPaymentMethod.h */,
 				A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */,
 				A140618A1E2ECA0A0032B34E /* MockPreviewLoaderClient.h */,
 				EB081CD81696084400553730 /* TypeConversions.h */,
@@ -21179,6 +21193,9 @@
 				A1F929681F8D9CDB00523AF3 /* ApplePayMerchantValidationEvent.idl */,
 				A1DF5AA11F7EE1130058A477 /* ApplePayPaymentHandler.cpp */,
 				A1DF5AA01F7EE1130058A477 /* ApplePayPaymentHandler.h */,
+				A1CBEF511F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp */,
+				A1CBEF501F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h */,
+				A1CBEF521F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.idl */,
 				A1DF5A7C1F7EBD0B0058A477 /* ApplePayRequest.h */,
 				A1DF5A7E1F7EBD0B0058A477 /* ApplePayRequest.idl */,
 			);
@@ -26616,6 +26633,7 @@
 				A146D3211F99CB1A00D29196 /* MockPaymentAddress.h in Headers */,
 				A146D3251F99D69800D29196 /* MockPaymentContact.h in Headers */,
 				A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */,
+				A1CBEF641F9F11290028DE7C /* MockPaymentMethod.h in Headers */,
 				A140618C1E2ECA0A0032B34E /* MockPreviewLoaderClient.h in Headers */,
 				AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */,
 				A1763F3F1E205234001D58DE /* WebArchiveDumpSupport.h in Headers */,
@@ -26694,6 +26712,7 @@
 				A1DF5AA21F7EE1130058A477 /* ApplePayPaymentHandler.h in Headers */,
 				7C6522EF1E00A4C700677F22 /* ApplePayPaymentMethod.h in Headers */,
 				1A8A64561D19FCFC00D0E00F /* ApplePayPaymentMethodSelectedEvent.h in Headers */,
+				A1CBEF531F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.h in Headers */,
 				7C6522F51E00A51700677F22 /* ApplePayPaymentPass.h in Headers */,
 				7C6579E01E0079F900E3A27A /* ApplePayPaymentRequest.h in Headers */,
 				A1DF5A7F1F7EBD0B0058A477 /* ApplePayRequest.h in Headers */,
@@ -27959,6 +27978,7 @@
 				7C6523161E00DBB500677F22 /* JSApplePayPaymentContact.h in Headers */,
 				7C6523181E00DBB500677F22 /* JSApplePayPaymentMethod.h in Headers */,
 				1AE96A8D1D1A0DDD00B86768 /* JSApplePayPaymentMethodSelectedEvent.h in Headers */,
+				A1CBEF621F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.h in Headers */,
 				7C65231A1E00DBB500677F22 /* JSApplePayPaymentPass.h in Headers */,
 				7C6579F21E00856600E3A27A /* JSApplePayPaymentRequest.h in Headers */,
 				A1DF5A8F1F7EC0020058A477 /* JSApplePayRequest.h in Headers */,
@@ -30882,6 +30902,7 @@
 				1A8A64511D19FCFB00D0E00F /* ApplePayPaymentAuthorizedEvent.cpp in Sources */,
 				A1DF5AA31F7EE1130058A477 /* ApplePayPaymentHandler.cpp in Sources */,
 				1A8A64541D19FCFC00D0E00F /* ApplePayPaymentMethodSelectedEvent.cpp in Sources */,
+				A1CBEF541F9EEE750028DE7C /* ApplePayPaymentMethodUpdateEvent.cpp in Sources */,
 				A1DF5AAE1F8075F10058A477 /* ApplePayRequestBase.cpp in Sources */,
 				1A8A64581D19FCFC00D0E00F /* ApplePaySession.cpp in Sources */,
 				1A58E8671D19D80E00C0EA73 /* ApplePaySessionPaymentRequest.cpp in Sources */,
@@ -31519,6 +31540,7 @@
 				7C6523171E00DBB500677F22 /* JSApplePayPaymentMethod.cpp in Sources */,
 				1AE96A8C1D1A0DDD00B86768 /* JSApplePayPaymentMethodSelectedEvent.cpp in Sources */,
 				1ADFDFED1E71E475008F5D34 /* JSApplePayPaymentMethodUpdate.cpp in Sources */,
+				A1CBEF611F9F09040028DE7C /* JSApplePayPaymentMethodUpdateEvent.cpp in Sources */,
 				7C6523191E00DBB500677F22 /* JSApplePayPaymentPass.cpp in Sources */,
 				7C6579F11E00856600E3A27A /* JSApplePayPaymentRequest.cpp in Sources */,
 				A1DF5A901F7EC0020058A477 /* JSApplePayRequest.cpp in Sources */,

Modified: trunk/Source/WebCore/dom/EventNames.h (223944 => 223945)


--- trunk/Source/WebCore/dom/EventNames.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/dom/EventNames.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -53,6 +53,7 @@
     macro(animationend) \
     macro(animationiteration) \
     macro(animationstart) \
+    macro(applepaypaymentmethodchanged) \
     macro(applepayvalidatemerchant) \
     macro(audioend) \
     macro(audioprocess) \

Modified: trunk/Source/WebCore/dom/EventNames.in (223944 => 223945)


--- trunk/Source/WebCore/dom/EventNames.in	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/dom/EventNames.in	2017-10-25 00:52:04 UTC (rev 223945)
@@ -41,6 +41,7 @@
 ApplePayMerchantValidationEvent conditional=APPLE_PAY
 ApplePayPaymentAuthorizedEvent conditional=APPLE_PAY
 ApplePayPaymentMethodSelectedEvent conditional=APPLE_PAY
+ApplePayPaymentMethodUpdateEvent conditional=APPLE_PAY
 ApplePayShippingContactSelectedEvent conditional=APPLE_PAY
 ApplePayShippingMethodSelectedEvent conditional=APPLE_PAY
 ApplePayValidateMerchantEvent conditional=APPLE_PAY

Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp (223944 => 223945)


--- trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp	2017-10-25 00:52:04 UTC (rev 223945)
@@ -31,6 +31,7 @@
 #include "MainFrame.h"
 #include "MockPayment.h"
 #include "MockPaymentContact.h"
+#include "MockPaymentMethod.h"
 #include "PaymentCoordinator.h"
 #include "URL.h"
 #include <wtf/RunLoop.h>
@@ -113,6 +114,13 @@
     });
 }
 
+void MockPaymentCoordinator::changePaymentMethod(ApplePayPaymentMethod&& paymentMethod)
+{
+    dispatchIfShowing([mainFrame = makeRef(m_mainFrame), paymentMethod = WTFMove(paymentMethod)]() mutable {
+        mainFrame->paymentCoordinator().didSelectPaymentMethod(MockPaymentMethod { WTFMove(paymentMethod) });
+    });
+}
+
 void MockPaymentCoordinator::acceptPayment()
 {
     dispatchIfShowing([mainFrame = makeRef(m_mainFrame), shippingAddress = m_shippingAddress]() mutable {

Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.h (223944 => 223945)


--- trunk/Source/WebCore/testing/MockPaymentCoordinator.h	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -31,8 +31,9 @@
 #include "PaymentCoordinatorClient.h"
 
 namespace WebCore {
-    
+
 class MainFrame;
+struct ApplePayPaymentMethod;
 
 class MockPaymentCoordinator final : public PaymentCoordinatorClient {
 public:
@@ -40,6 +41,7 @@
 
     void setShippingAddress(MockPaymentAddress&& shippingAddress) { m_shippingAddress = WTFMove(shippingAddress); }
     void changeShippingOption(String&& shippingOption);
+    void changePaymentMethod(ApplePayPaymentMethod&&);
     void acceptPayment();
 
     void ref() const { }

Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.idl (223944 => 223945)


--- trunk/Source/WebCore/testing/MockPaymentCoordinator.idl	2017-10-25 00:47:27 UTC (rev 223944)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.idl	2017-10-25 00:52:04 UTC (rev 223945)
@@ -29,5 +29,6 @@
 ] interface MockPaymentCoordinator {
     void setShippingAddress(MockPaymentAddress shippingAddress);
     void changeShippingOption(DOMString shippingOption);
+    void changePaymentMethod(ApplePayPaymentMethod paymentMethod);
     void acceptPayment();
 };

Copied: trunk/Source/WebCore/testing/MockPaymentMethod.h (from rev 223944, trunk/Source/WebCore/Modules/applepay/PaymentMethod.h) (0 => 223945)


--- trunk/Source/WebCore/testing/MockPaymentMethod.h	                        (rev 0)
+++ trunk/Source/WebCore/testing/MockPaymentMethod.h	2017-10-25 00:52:04 UTC (rev 223945)
@@ -0,0 +1,50 @@
+/*
+ * 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)
+
+#include "ApplePayPaymentMethod.h"
+#include "PaymentMethod.h"
+
+namespace WebCore {
+
+class MockPaymentMethod final : public PaymentMethod {
+public:
+    explicit MockPaymentMethod(ApplePayPaymentMethod&& applePayPaymentMethod)
+        : m_applePayPaymentMethod { WTFMove(applePayPaymentMethod) }
+    {
+    }
+
+    ApplePayPaymentMethod toApplePayPaymentMethod() const final { return m_applePayPaymentMethod; }
+
+private:
+    ApplePayPaymentMethod m_applePayPaymentMethod;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to