Title: [235833] trunk
Revision
235833
Author
[email protected]
Date
2018-09-08 19:03:52 -0700 (Sat, 08 Sep 2018)

Log Message

[Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
https://bugs.webkit.org/show_bug.cgi?id=189386

Reviewed by Darin Adler.

Source/WebCore:

Implemented the "payment method changed" algorithm as defined in the Payment Request API W3C
Editor's Draft of 05 September 2018.

Payment Request says that the user agent MAY run this algorithm when the payment method
changes. In our case, we only wish to dispatch this event when a listener is registered for
it. Since PassKit requires merchants to respond to this event by calling updateWith() within
30 seconds, firing the event unconditionally would break compatibility with existing
clients.

For merchants that do not listen for this event, they can continue to use modifiers to
update details based on the selected payment method type.

Also made PaymentMethodChangeEvent.methodDetails a cached attribute in a way that avoids
potential reference cycles from holding a JSC::Strong in the wrapped object.

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

* CMakeLists.txt:
* DerivedSources.make:
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::toJSDictionary):
(WebCore::ApplePayPaymentHandler::didAuthorizePayment):
(WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
* Modules/paymentrequest/PaymentMethodChangeEvent.cpp:
(WebCore::PaymentMethodChangeEvent::PaymentMethodChangeEvent):
* Modules/paymentrequest/PaymentMethodChangeEvent.h:
* Modules/paymentrequest/PaymentMethodChangeEvent.idl:
* Modules/paymentrequest/PaymentMethodChangeEventInit.idl: Removed.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::paymentMethodChanged):
* Modules/paymentrequest/PaymentRequest.h:
* Modules/paymentrequest/PaymentRequestUpdateEvent.cpp:
(WebCore::PaymentRequestUpdateEvent::updateWith):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSPaymentMethodChangeEventCustom.cpp: Added.
(WebCore::JSPaymentMethodChangeEvent::methodDetails const):
(WebCore::JSPaymentMethodChangeEvent::visitAdditionalChildren):

LayoutTests:

* fast/dom/reference-cycle-leaks-expected.txt:
* fast/dom/reference-cycle-leaks.html:
* http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https-expected.txt: Added.
* http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https.html: Added.
* platform/ios-wk2/fast/dom/reference-cycle-leaks-expected.txt: Added.
* platform/mac-wk2/fast/dom/reference-cycle-leaks-expected.txt: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (235832 => 235833)


--- trunk/LayoutTests/ChangeLog	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/LayoutTests/ChangeLog	2018-09-09 02:03:52 UTC (rev 235833)
@@ -1,3 +1,17 @@
+2018-09-08  Andy Estes  <[email protected]>
+
+        [Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
+        https://bugs.webkit.org/show_bug.cgi?id=189386
+
+        Reviewed by Darin Adler.
+
+        * fast/dom/reference-cycle-leaks-expected.txt:
+        * fast/dom/reference-cycle-leaks.html:
+        * http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https-expected.txt: Added.
+        * http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https.html: Added.
+        * platform/ios-wk2/fast/dom/reference-cycle-leaks-expected.txt: Added.
+        * platform/mac-wk2/fast/dom/reference-cycle-leaks-expected.txt: Added.
+
 2018-09-07  Basuke Suzuki  <[email protected]>
 
         [LayoutTests] Add digest access authentication test.

Modified: trunk/LayoutTests/fast/dom/reference-cycle-leaks-expected.txt (235832 => 235833)


--- trunk/LayoutTests/fast/dom/reference-cycle-leaks-expected.txt	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/LayoutTests/fast/dom/reference-cycle-leaks-expected.txt	2018-09-09 02:03:52 UTC (rev 235833)
@@ -13,6 +13,7 @@
 PASS checkForNodeLeaks(createErrorEventDataCycle) is "did not leak"
 ---- Did not test ExtendableMessageEvent because it is not enabled.
 PASS checkForNodeLeaks(createMessageEventDataCycle) is "did not leak"
+---- Did not test PaymentMethodChangeEvent because it is not enabled.
 PASS checkForNodeLeaks(createPopStateEventStateCycle) is "did not leak"
 FAIL checkForNodeLeaks(createPromiseRejectionEventPromiseCycle) should be did not leak. Was leaked.
 PASS checkForNodeLeaks(createPromiseRejectionEventPromiseFunctionCycle) is "did not leak"

Modified: trunk/LayoutTests/fast/dom/reference-cycle-leaks.html (235832 => 235833)


--- trunk/LayoutTests/fast/dom/reference-cycle-leaks.html	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/LayoutTests/fast/dom/reference-cycle-leaks.html	2018-09-09 02:03:52 UTC (rev 235833)
@@ -83,6 +83,12 @@
     leakDetectionNode.event = new MessageEvent("x", { data: leakDetectionNode });
 }
 
+function createPaymentMethodChangeEventMethodDetailsCycle()
+{
+    const leakDetectionNode = document.createTextNode("");
+    leakDetectionNode.event = new PaymentMethodChangeEvent("x", { methodDetails: leakDetectionNode });
+}
+
 function createPromiseRejectionEventPromiseCycle()
 {
     const leakDetectionNode = document.createTextNode("");
@@ -162,6 +168,7 @@
     runLeakTest('createErrorEventDataCycle');
     runLeakTest('createExtendableMessageEventDataCycle', 'ExtendableMessageEvent');
     runLeakTest('createMessageEventDataCycle');
+    runLeakTest('createPaymentMethodChangeEventMethodDetailsCycle', 'PaymentMethodChangeEvent');
     runLeakTest('createPopStateEventStateCycle');
     runLeakTest('createPromiseRejectionEventPromiseCycle');
     runLeakTest('createPromiseRejectionEventPromiseFunctionCycle');

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


--- trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https-expected.txt	2018-09-09 02:03:52 UTC (rev 235833)
@@ -0,0 +1,34 @@
+CONSOLE MESSAGE: Unhandled Promise Rejection: AbortError: The operation was aborted.
+Test PaymentMethodChangeEvent with Apple Pay.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing that PaymentMethodChangeEvent fires after selecting a 'credit' payment method type.
+PASS event.methodName is 'https://apple.com/apple-pay'
+PASS event.methodDetails.type is 'credit'
+
+Testing that PaymentMethodChangeEvent.updateWith() updates payment details after selecting a 'credit' payment method type.
+PASS event.methodName is 'https://apple.com/apple-pay'
+PASS event.methodDetails.type is 'credit'
+PASS internals.mockPaymentCoordinator.total.label is 'Total'
+PASS internals.mockPaymentCoordinator.total.amount is '15.00'
+PASS internals.mockPaymentCoordinator.lineItems.length is 1
+PASS internals.mockPaymentCoordinator.lineItems[0].label is 'Item'
+PASS internals.mockPaymentCoordinator.lineItems[0].amount is '10.00'
+
+Testing that PaymentMethodChangeEvent.updateWith() applies modifiers after selecting a 'credit' payment method type.
+PASS event.methodName is 'https://apple.com/apple-pay'
+PASS event.methodDetails.type is 'credit'
+PASS internals.mockPaymentCoordinator.total.label is 'Credit total override'
+PASS internals.mockPaymentCoordinator.total.amount is '20.00'
+PASS internals.mockPaymentCoordinator.lineItems.length is 2
+PASS internals.mockPaymentCoordinator.lineItems[0].label is 'Item'
+PASS internals.mockPaymentCoordinator.lineItems[0].amount is '10.00'
+PASS internals.mockPaymentCoordinator.lineItems[1].label is 'Credit surcharge'
+PASS internals.mockPaymentCoordinator.lineItems[1].amount is '10.00'
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

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


--- trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https.html	2018-09-09 02:03:52 UTC (rev 235833)
@@ -0,0 +1,162 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+
+description("Test PaymentMethodChangeEvent with Apple Pay.");
+
+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: 'Total',
+            amount: {
+                currency: 'USD',
+                value: '10.00',
+            },
+        },
+        displayItems: [{
+            label: 'Item',
+            amount: {
+                currency: 'USD',
+                value: '10.00',
+            },
+        }],
+    }
+}
+
+async function runTests() {
+    await new Promise((resolve, reject) => {
+        debug("Testing that PaymentMethodChangeEvent fires after selecting a 'credit' payment method type.");
+
+        activateThen(() => {
+            var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+            try {
+                paymentRequest._onpaymentmethodchange_ = (event) => {
+                    shouldBe("event.methodName", "'https://apple.com/apple-pay'");
+                    shouldBe("event.methodDetails.type", "'credit'");
+                    paymentRequest.abort();
+                    resolve();
+                };
+
+                paymentRequest.show();
+                internals.mockPaymentCoordinator.changePaymentMethod({ type: 'credit' });
+            } catch (error) {
+            }
+        });
+    });
+    debug("");
+
+    await new Promise((resolve, reject) => {
+        debug("Testing that PaymentMethodChangeEvent.updateWith() updates payment details after selecting a 'credit' payment method type.");
+
+        activateThen(() => {
+            var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+
+            paymentRequest._onpaymentmethodchange_ = (event) => {
+                shouldBe("event.methodName", "'https://apple.com/apple-pay'");
+                shouldBe("event.methodDetails.type", "'credit'");
+
+                var detailsUpdate = validPaymentDetails();
+                detailsUpdate.total.amount.value = '15.00';
+                event.updateWith(detailsUpdate);
+                internals.mockPaymentCoordinator.acceptPayment();
+            };
+
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.total.label", "'Total'");
+                shouldBe("internals.mockPaymentCoordinator.total.amount", "'15.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems.length", "1");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].label", "'Item'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].amount", "'10.00'");
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.changePaymentMethod({ type: 'credit' });
+        });
+    });
+    debug("");
+
+    await new Promise((resolve, reject) => {
+        debug("Testing that PaymentMethodChangeEvent.updateWith() applies modifiers after selecting a 'credit' payment method type.");
+
+        activateThen(() => {
+            var paymentRequest = new PaymentRequest([validPaymentMethod()], validPaymentDetails());
+
+            paymentRequest._onpaymentmethodchange_ = (event) => {
+                shouldBe("event.methodName", "'https://apple.com/apple-pay'");
+                shouldBe("event.methodDetails.type", "'credit'");
+
+                var detailsUpdate = validPaymentDetails();
+                detailsUpdate.total.amount.value = '15.00';
+                detailsUpdate.modifiers = [{
+                    supportedMethods: 'https://apple.com/apple-pay',
+                    total: {
+                        label: 'Credit total override',
+                        amount: {
+                            currency: 'USD',
+                            value: '20.00',
+                        },
+                    },
+                    additionalDisplayItems: [{
+                        label: 'Credit surcharge',
+                        amount: {
+                            currency: 'USD',
+                            value: '10.00',
+                        },
+                    }],
+                    data: {
+                        paymentMethodType: 'credit',
+                    },
+                }];
+
+                event.updateWith(detailsUpdate);
+                internals.mockPaymentCoordinator.acceptPayment();
+            };
+
+            paymentRequest.show().then((response) => {
+                shouldBe("internals.mockPaymentCoordinator.total.label", "'Credit total override'");
+                shouldBe("internals.mockPaymentCoordinator.total.amount", "'20.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems.length", "2");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].label", "'Item'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[0].amount", "'10.00'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[1].label", "'Credit surcharge'");
+                shouldBe("internals.mockPaymentCoordinator.lineItems[1].amount", "'10.00'");
+                response.complete("success");
+                resolve();
+            });
+
+            internals.mockPaymentCoordinator.changePaymentMethod({ type: 'credit' });
+        });
+    });
+    debug("");
+
+    finishJSTest();
+}
+
+runTests();
+</script>
+<script src=""
+</body>
+</html>

Copied: trunk/LayoutTests/platform/ios-wk2/fast/dom/reference-cycle-leaks-expected.txt (from rev 235832, trunk/LayoutTests/fast/dom/reference-cycle-leaks-expected.txt) (0 => 235833)


--- trunk/LayoutTests/platform/ios-wk2/fast/dom/reference-cycle-leaks-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/fast/dom/reference-cycle-leaks-expected.txt	2018-09-09 02:03:52 UTC (rev 235833)
@@ -0,0 +1,25 @@
+Tests for leaks caused by reference cycles that pass through the DOM implementation
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS checkForNodeLeaks(emptyFunction) is "did not leak"
+PASS checkForNodeLeaks(createNode) is "did not leak"
+PASS checkForNodeLeaks(createEventListenerCycle) is "did not leak"
+PASS checkForNodeLeaks(createTreeWalkerNodeCycle) is "did not leak"
+PASS checkForNodeLeaks(createTreeWalkerFilterCycle) is "did not leak"
+PASS checkForNodeLeaks(createPromiseCycle) is "did not leak"
+PASS checkForNodeLeaks(createCustomEventDetailsCycle) is "did not leak"
+PASS checkForNodeLeaks(createErrorEventDataCycle) is "did not leak"
+---- Did not test ExtendableMessageEvent because it is not enabled.
+PASS checkForNodeLeaks(createMessageEventDataCycle) is "did not leak"
+PASS checkForNodeLeaks(createPaymentMethodChangeEventMethodDetailsCycle) is "did not leak"
+PASS checkForNodeLeaks(createPopStateEventStateCycle) is "did not leak"
+FAIL checkForNodeLeaks(createPromiseRejectionEventPromiseCycle) should be did not leak. Was leaked.
+PASS checkForNodeLeaks(createPromiseRejectionEventPromiseFunctionCycle) is "did not leak"
+PASS checkForNodeLeaks(createPromiseRejectionEventReasonCycle) is "did not leak"
+PASS successfullyParsed is true
+Some tests failed.
+
+TEST COMPLETE
+

Copied: trunk/LayoutTests/platform/mac-wk2/fast/dom/reference-cycle-leaks-expected.txt (from rev 235832, trunk/LayoutTests/fast/dom/reference-cycle-leaks-expected.txt) (0 => 235833)


--- trunk/LayoutTests/platform/mac-wk2/fast/dom/reference-cycle-leaks-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/fast/dom/reference-cycle-leaks-expected.txt	2018-09-09 02:03:52 UTC (rev 235833)
@@ -0,0 +1,25 @@
+Tests for leaks caused by reference cycles that pass through the DOM implementation
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS checkForNodeLeaks(emptyFunction) is "did not leak"
+PASS checkForNodeLeaks(createNode) is "did not leak"
+PASS checkForNodeLeaks(createEventListenerCycle) is "did not leak"
+PASS checkForNodeLeaks(createTreeWalkerNodeCycle) is "did not leak"
+PASS checkForNodeLeaks(createTreeWalkerFilterCycle) is "did not leak"
+PASS checkForNodeLeaks(createPromiseCycle) is "did not leak"
+PASS checkForNodeLeaks(createCustomEventDetailsCycle) is "did not leak"
+PASS checkForNodeLeaks(createErrorEventDataCycle) is "did not leak"
+---- Did not test ExtendableMessageEvent because it is not enabled.
+PASS checkForNodeLeaks(createMessageEventDataCycle) is "did not leak"
+PASS checkForNodeLeaks(createPaymentMethodChangeEventMethodDetailsCycle) is "did not leak"
+PASS checkForNodeLeaks(createPopStateEventStateCycle) is "did not leak"
+FAIL checkForNodeLeaks(createPromiseRejectionEventPromiseCycle) should be did not leak. Was leaked.
+PASS checkForNodeLeaks(createPromiseRejectionEventPromiseFunctionCycle) is "did not leak"
+PASS checkForNodeLeaks(createPromiseRejectionEventReasonCycle) is "did not leak"
+PASS successfullyParsed is true
+Some tests failed.
+
+TEST COMPLETE
+

Modified: trunk/Source/WebCore/CMakeLists.txt (235832 => 235833)


--- trunk/Source/WebCore/CMakeLists.txt	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-09-09 02:03:52 UTC (rev 235833)
@@ -346,7 +346,6 @@
     Modules/paymentrequest/PaymentDetailsUpdate.idl
     Modules/paymentrequest/PaymentItem.idl
     Modules/paymentrequest/PaymentMethodChangeEvent.idl
-    Modules/paymentrequest/PaymentMethodChangeEventInit.idl
     Modules/paymentrequest/PaymentMethodData.idl
     Modules/paymentrequest/PaymentOptions.idl
     Modules/paymentrequest/PaymentRequest.idl

Modified: trunk/Source/WebCore/ChangeLog (235832 => 235833)


--- trunk/Source/WebCore/ChangeLog	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/ChangeLog	2018-09-09 02:03:52 UTC (rev 235833)
@@ -1,3 +1,49 @@
+2018-09-08  Andy Estes  <[email protected]>
+
+        [Apple Pay] Dispatch a paymentmethodchange event when the payment method changes
+        https://bugs.webkit.org/show_bug.cgi?id=189386
+
+        Reviewed by Darin Adler.
+
+        Implemented the "payment method changed" algorithm as defined in the Payment Request API W3C
+        Editor's Draft of 05 September 2018.
+
+        Payment Request says that the user agent MAY run this algorithm when the payment method
+        changes. In our case, we only wish to dispatch this event when a listener is registered for
+        it. Since PassKit requires merchants to respond to this event by calling updateWith() within
+        30 seconds, firing the event unconditionally would break compatibility with existing
+        clients.
+
+        For merchants that do not listen for this event, they can continue to use modifiers to
+        update details based on the selected payment method type.
+        
+        Also made PaymentMethodChangeEvent.methodDetails a cached attribute in a way that avoids
+        potential reference cycles from holding a JSC::Strong in the wrapped object.
+
+        Test: http/tests/ssl/applepay/ApplePayPaymentMethodChangeEvent.https.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::toJSDictionary):
+        (WebCore::ApplePayPaymentHandler::didAuthorizePayment):
+        (WebCore::ApplePayPaymentHandler::didSelectPaymentMethod):
+        * Modules/paymentrequest/PaymentMethodChangeEvent.cpp:
+        (WebCore::PaymentMethodChangeEvent::PaymentMethodChangeEvent):
+        * Modules/paymentrequest/PaymentMethodChangeEvent.h:
+        * Modules/paymentrequest/PaymentMethodChangeEvent.idl:
+        * Modules/paymentrequest/PaymentMethodChangeEventInit.idl: Removed.
+        * Modules/paymentrequest/PaymentRequest.cpp:
+        (WebCore::PaymentRequest::paymentMethodChanged):
+        * Modules/paymentrequest/PaymentRequest.h:
+        * Modules/paymentrequest/PaymentRequestUpdateEvent.cpp:
+        (WebCore::PaymentRequestUpdateEvent::updateWith):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSPaymentMethodChangeEventCustom.cpp: Added.
+        (WebCore::JSPaymentMethodChangeEvent::methodDetails const):
+        (WebCore::JSPaymentMethodChangeEvent::visitAdditionalChildren):
+
 2018-09-08  Simon Fraser  <[email protected]>
 
         Clean up code related to Document node removal

Modified: trunk/Source/WebCore/DerivedSources.make (235832 => 235833)


--- trunk/Source/WebCore/DerivedSources.make	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/DerivedSources.make	2018-09-09 02:03:52 UTC (rev 235833)
@@ -266,7 +266,6 @@
     $(WebCore)/Modules/paymentrequest/PaymentDetailsUpdate.idl \
     $(WebCore)/Modules/paymentrequest/PaymentItem.idl \
     $(WebCore)/Modules/paymentrequest/PaymentMethodChangeEvent.idl \
-    $(WebCore)/Modules/paymentrequest/PaymentMethodChangeEventInit.idl \
     $(WebCore)/Modules/paymentrequest/PaymentMethodData.idl \
     $(WebCore)/Modules/paymentrequest/PaymentOptions.idl \
     $(WebCore)/Modules/paymentrequest/PaymentRequest.idl \

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


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2018-09-09 02:03:52 UTC (rev 235833)
@@ -37,6 +37,7 @@
 #include "EventNames.h"
 #include "Frame.h"
 #include "JSApplePayPayment.h"
+#include "JSApplePayPaymentMethod.h"
 #include "JSApplePayRequest.h"
 #include "LinkIconCollector.h"
 #include "MerchantValidationEvent.h"
@@ -440,14 +441,19 @@
     return PaymentAddress::create(contact.countryCode, contact.addressLines.value_or(Vector<String>()), contact.administrativeArea, contact.locality, contact.subLocality, contact.postalCode, String(), String(), contact.localizedName, contact.phoneNumber);
 }
 
+template<typename T>
+static JSC::Strong<JSC::JSObject> toJSDictionary(JSC::ExecState& execState, const T& value)
+{
+    JSC::JSLockHolder lock { &execState };
+    return { execState.vm(), asObject(toJS<IDLDictionary<T>>(execState, *JSC::jsCast<JSDOMGlobalObject*>(execState.lexicalGlobalObject()), value)) };
+}
+
 void ApplePayPaymentHandler::didAuthorizePayment(const Payment& payment)
 {
     ASSERT(!m_isUpdating);
 
     auto applePayPayment = payment.toApplePayPayment(version());
-    auto& execState = *document().execState();
-    auto lock = JSC::JSLockHolder { &execState };
-    auto details = JSC::Strong<JSC::JSObject> { execState.vm(), asObject(toJS<IDLDictionary<ApplePayPayment>>(execState, *JSC::jsCast<JSDOMGlobalObject*>(execState.lexicalGlobalObject()), applePayPayment)) };
+    auto details = toJSDictionary(*document().execState(), applePayPayment);
     const auto& shippingContact = applePayPayment.shippingContact.value_or(ApplePayPaymentContact());
     m_paymentRequest->accept(WTF::get<URL>(m_identifier).string(), WTFMove(details), convert(shippingContact), shippingContact.localizedName, shippingContact.emailAddress, shippingContact.phoneNumber);
 }
@@ -473,8 +479,11 @@
     ASSERT(!m_isUpdating);
     m_isUpdating = true;
 
-    m_selectedPaymentMethodType = paymentMethod.toApplePayPaymentMethod().type;
-    m_paymentRequest->paymentMethodChanged();
+    auto applePayPaymentMethod = paymentMethod.toApplePayPaymentMethod();
+    m_selectedPaymentMethodType = applePayPaymentMethod.type;
+    m_paymentRequest->paymentMethodChanged(WTF::get<URL>(m_identifier).string(), [applePayPaymentMethod = WTFMove(applePayPaymentMethod)](JSC::ExecState& execState) {
+        return toJSDictionary(execState, applePayPaymentMethod);
+    });
 }
 
 void ApplePayPaymentHandler::didCancelPaymentSession()

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.cpp (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.cpp	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.cpp	2018-09-09 02:03:52 UTC (rev 235833)
@@ -28,8 +28,6 @@
 
 #if ENABLE(PAYMENT_REQUEST)
 
-#include "PaymentMethodChangeEventInit.h"
-
 namespace WebCore {
 
 EventInterface PaymentMethodChangeEvent::eventInterface() const
@@ -37,13 +35,20 @@
     return PaymentMethodChangeEventInterfaceType;
 }
 
-PaymentMethodChangeEvent::PaymentMethodChangeEvent(const AtomicString& type, const PaymentMethodChangeEventInit& eventInit)
+PaymentMethodChangeEvent::PaymentMethodChangeEvent(const AtomicString& type, Init&& eventInit)
     : PaymentRequestUpdateEvent { type, eventInit }
-    , m_methodName { eventInit.methodName }
-    , m_methodDetails { eventInit.methodDetails }
+    , m_methodName { WTFMove(eventInit.methodName) }
+    , m_methodDetails { JSValueInWrappedObject { eventInit.methodDetails.get() } }
 {
 }
 
+PaymentMethodChangeEvent::PaymentMethodChangeEvent(const AtomicString& type, PaymentRequest& request, const String& methodName, MethodDetailsFunction&& methodDetailsFunction)
+    : PaymentRequestUpdateEvent { type, request }
+    , m_methodName { methodName }
+    , m_methodDetails { WTFMove(methodDetailsFunction) }
+{
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(PAYMENT_REQUEST)

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.h (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.h	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.h	2018-09-09 02:03:52 UTC (rev 235833)
@@ -27,8 +27,10 @@
 
 #if ENABLE(PAYMENT_REQUEST)
 
+#include "JSValueInWrappedObject.h"
 #include "PaymentRequestUpdateEvent.h"
 #include <_javascript_Core/Strong.h>
+#include <wtf/Variant.h>
 #include <wtf/text/WTFString.h>
 
 namespace JSC {
@@ -36,8 +38,6 @@
 }
 
 namespace WebCore {
-    
-struct PaymentMethodChangeEventInit;
 
 class PaymentMethodChangeEvent final : public PaymentRequestUpdateEvent {
 public:
@@ -46,17 +46,28 @@
         return adoptRef(*new PaymentMethodChangeEvent(std::forward<Args>(args)...));
     }
 
+    using MethodDetailsFunction = std::function<JSC::Strong<JSC::JSObject>(JSC::ExecState&)>;
+    using MethodDetailsType = Variant<JSValueInWrappedObject, MethodDetailsFunction>;
+
     const String& methodName() const { return m_methodName; }
-    const JSC::Strong<JSC::JSObject>& methodDetails() const { return m_methodDetails; }
+    const MethodDetailsType& methodDetails() const { return m_methodDetails; }
+    JSValueInWrappedObject& cachedMethodDetails() { return m_cachedMethodDetails; }
 
     // Event
     EventInterface eventInterface() const override;
+    
+    struct Init final : PaymentRequestUpdateEventInit {
+        String methodName;
+        JSC::Strong<JSC::JSObject> methodDetails;
+    };
 
 private:
-    PaymentMethodChangeEvent(const AtomicString& type, const PaymentMethodChangeEventInit&);
+    PaymentMethodChangeEvent(const AtomicString& type, Init&&);
+    PaymentMethodChangeEvent(const AtomicString& type, PaymentRequest&, const String& methodName, MethodDetailsFunction&&);
 
     String m_methodName;
-    JSC::Strong<JSC::JSObject> m_methodDetails;
+    MethodDetailsType m_methodDetails;
+    JSValueInWrappedObject m_cachedMethodDetails;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.idl (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.idl	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.idl	2018-09-09 02:03:52 UTC (rev 235833)
@@ -28,8 +28,16 @@
     Constructor(DOMString type, optional PaymentMethodChangeEventInit eventInitDict),
     EnabledBySetting=PaymentRequest,
     Exposed=Window,
+    JSCustomMarkFunction,
     SecureContext,
 ] interface PaymentMethodChangeEvent : PaymentRequestUpdateEvent {
     readonly attribute DOMString methodName;
-    readonly attribute object? methodDetails;
+    [CustomGetter] readonly attribute object? methodDetails;
 };
+
+[
+    Conditional=PAYMENT_REQUEST,
+] dictionary PaymentMethodChangeEventInit : PaymentRequestUpdateEventInit {
+    DOMString methodName = "";
+    object? methodDetails;
+};

Deleted: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.h (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.h	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.h	2018-09-09 02:03:52 UTC (rev 235833)
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2018 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(PAYMENT_REQUEST)
-
-#include "PaymentRequestUpdateEventInit.h"
-#include <_javascript_Core/Strong.h>
-
-namespace JSC {
-class JSObject;
-}
-
-namespace WebCore {
-
-struct PaymentMethodChangeEventInit final : PaymentRequestUpdateEventInit {
-    String methodName;
-    JSC::Strong<JSC::JSObject> methodDetails;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(PAYMENT_REQUEST)

Deleted: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.idl (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.idl	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.idl	2018-09-09 02:03:52 UTC (rev 235833)
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2018 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=PAYMENT_REQUEST,
-] dictionary PaymentMethodChangeEventInit : PaymentRequestUpdateEventInit {
-    DOMString methodName = "";
-    object? methodDetails;
-};

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-09-09 02:03:52 UTC (rev 235833)
@@ -38,6 +38,7 @@
 #include "PaymentCurrencyAmount.h"
 #include "PaymentDetailsInit.h"
 #include "PaymentHandler.h"
+#include "PaymentMethodChangeEvent.h"
 #include "PaymentMethodData.h"
 #include "PaymentOptions.h"
 #include "PaymentRequestUpdateEvent.h"
@@ -552,10 +553,14 @@
     });
 }
 
-void PaymentRequest::paymentMethodChanged()
+void PaymentRequest::paymentMethodChanged(const String& methodName, PaymentMethodChangeEvent::MethodDetailsFunction&& methodDetailsFunction)
 {
-    whenDetailsSettled([this, protectedThis = makeRefPtr(this)] {
-        m_activePaymentHandler->detailsUpdated(UpdateReason::PaymentMethodChanged, { });
+    whenDetailsSettled([this, protectedThis = makeRefPtr(this), methodName, methodDetailsFunction = WTFMove(methodDetailsFunction)]() mutable {
+        auto& eventName = eventNames().paymentmethodchangeEvent;
+        if (hasEventListeners(eventName))
+            dispatchEvent(PaymentMethodChangeEvent::create(eventName, *this, methodName, WTFMove(methodDetailsFunction)));
+        else
+            m_activePaymentHandler->detailsUpdated(UpdateReason::PaymentMethodChanged, { });
     });
 }
 

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h	2018-09-09 02:03:52 UTC (rev 235833)
@@ -32,6 +32,7 @@
 #include "ExceptionOr.h"
 #include "JSDOMPromiseDeferred.h"
 #include "PaymentDetailsInit.h"
+#include "PaymentMethodChangeEvent.h"
 #include "PaymentOptions.h"
 #include "URL.h"
 #include <wtf/Variant.h>
@@ -87,7 +88,7 @@
 
     void shippingAddressChanged(Ref<PaymentAddress>&&);
     void shippingOptionChanged(const String& shippingOption);
-    void paymentMethodChanged();
+    void paymentMethodChanged(const String& methodName, PaymentMethodChangeEvent::MethodDetailsFunction&&);
     ExceptionOr<void> updateWith(UpdateReason, Ref<DOMPromise>&&);
     ExceptionOr<void> completeMerchantValidation(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);

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp (235832 => 235833)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp	2018-09-09 02:03:52 UTC (rev 235833)
@@ -36,6 +36,7 @@
 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type, const PaymentRequestUpdateEventInit& eventInit)
     : Event { type, eventInit, IsTrusted::No }
 {
+    ASSERT(!isTrusted());
 }
 
 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type, PaymentRequest& paymentRequest)
@@ -42,6 +43,7 @@
     : Event { type, CanBubble::No, IsCancelable::No }
     , m_paymentRequest { &paymentRequest }
 {
+    ASSERT(isTrusted());
 }
 
 PaymentRequestUpdateEvent::~PaymentRequestUpdateEvent() = default;
@@ -51,6 +53,8 @@
     if (!isTrusted())
         return Exception { InvalidStateError };
 
+    ASSERT(m_paymentRequest);
+
     if (m_waitForUpdate)
         return Exception { InvalidStateError };
 
@@ -62,6 +66,8 @@
         reason = PaymentRequest::UpdateReason::ShippingAddressChanged;
     else if (type() == eventNames().shippingoptionchangeEvent)
         reason = PaymentRequest::UpdateReason::ShippingOptionChanged;
+    else if (type() == eventNames().paymentmethodchangeEvent)
+        reason = PaymentRequest::UpdateReason::PaymentMethodChanged;
     else {
         ASSERT_NOT_REACHED();
         return Exception { TypeError };

Modified: trunk/Source/WebCore/Sources.txt (235832 => 235833)


--- trunk/Source/WebCore/Sources.txt	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/Sources.txt	2018-09-09 02:03:52 UTC (rev 235833)
@@ -429,6 +429,7 @@
 bindings/js/JSNodeIteratorCustom.cpp
 bindings/js/JSNodeListCustom.cpp
 bindings/js/JSOffscreenCanvasRenderingContext2DCustom.cpp
+bindings/js/JSPaymentMethodChangeEventCustom.cpp
 bindings/js/JSPerformanceEntryCustom.cpp
 bindings/js/JSPerformanceObserverCustom.cpp
 bindings/js/JSPluginElementFunctions.cpp
@@ -2823,7 +2824,6 @@
 JSPaymentDetailsUpdate.cpp
 JSPaymentItem.cpp
 JSPaymentMethodChangeEvent.cpp
-JSPaymentMethodChangeEventInit.cpp
 JSPaymentMethodData.cpp
 JSPaymentOptions.cpp
 JSPaymentRequest.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (235832 => 235833)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-09-08 21:29:49 UTC (rev 235832)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-09-09 02:03:52 UTC (rev 235833)
@@ -2925,9 +2925,7 @@
 		A15E31F41E0CB0B5004B371C /* QuickLook.h in Headers */ = {isa = PBXBuildFile; fileRef = A15E31F11E0CB0AA004B371C /* QuickLook.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A15E6BF11E212A6A0080AF34 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A15E6BF01E212A6A0080AF34 /* Foundation.framework */; };
 		A164A2472134BC7100509156 /* PaymentMethodChangeEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A164A2442134BC7100509156 /* PaymentMethodChangeEvent.h */; };
-		A164A24E2134BDD800509156 /* PaymentMethodChangeEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A164A24B2134BDD800509156 /* PaymentMethodChangeEventInit.h */; };
 		A164A2552134C1CC00509156 /* JSPaymentMethodChangeEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A164A2512134C1CB00509156 /* JSPaymentMethodChangeEvent.h */; };
-		A164A2562134C1CC00509156 /* JSPaymentMethodChangeEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A164A2522134C1CB00509156 /* JSPaymentMethodChangeEventInit.h */; };
 		A1677DE9213CDFAA00A08C34 /* MerchantValidationEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677DE6213CDFAA00A08C34 /* MerchantValidationEventInit.h */; };
 		A1677DF0213CE0B100A08C34 /* JSMerchantValidationEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677DEE213CE0B000A08C34 /* JSMerchantValidationEventInit.h */; };
 		A1677DFD213E006600A08C34 /* PaymentValidationErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677DFA213E006600A08C34 /* PaymentValidationErrors.h */; };
@@ -10960,12 +10958,8 @@
 		A164A2442134BC7100509156 /* PaymentMethodChangeEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentMethodChangeEvent.h; sourceTree = "<group>"; };
 		A164A2452134BC7100509156 /* PaymentMethodChangeEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = PaymentMethodChangeEvent.cpp; sourceTree = "<group>"; };
 		A164A2462134BC7100509156 /* PaymentMethodChangeEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PaymentMethodChangeEvent.idl; sourceTree = "<group>"; };
-		A164A24B2134BDD800509156 /* PaymentMethodChangeEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentMethodChangeEventInit.h; sourceTree = "<group>"; };
-		A164A24D2134BDD800509156 /* PaymentMethodChangeEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PaymentMethodChangeEventInit.idl; sourceTree = "<group>"; };
 		A164A2512134C1CB00509156 /* JSPaymentMethodChangeEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentMethodChangeEvent.h; sourceTree = "<group>"; };
-		A164A2522134C1CB00509156 /* JSPaymentMethodChangeEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentMethodChangeEventInit.h; sourceTree = "<group>"; };
 		A164A2532134C1CB00509156 /* JSPaymentMethodChangeEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentMethodChangeEvent.cpp; sourceTree = "<group>"; };
-		A164A2542134C1CC00509156 /* JSPaymentMethodChangeEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentMethodChangeEventInit.cpp; sourceTree = "<group>"; };
 		A1677DE6213CDFAA00A08C34 /* MerchantValidationEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MerchantValidationEventInit.h; sourceTree = "<group>"; };
 		A1677DE8213CDFAA00A08C34 /* MerchantValidationEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MerchantValidationEventInit.idl; sourceTree = "<group>"; };
 		A1677DED213CE0AF00A08C34 /* JSMerchantValidationEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMerchantValidationEventInit.cpp; sourceTree = "<group>"; };
@@ -10982,6 +10976,7 @@
 		A1677E12213E03C600A08C34 /* JSAddressErrors.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAddressErrors.cpp; sourceTree = "<group>"; };
 		A1677E15213E03F000A08C34 /* JSPayerErrorFields.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPayerErrorFields.h; sourceTree = "<group>"; };
 		A1677E16213E03F000A08C34 /* JSPayerErrorFields.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPayerErrorFields.cpp; sourceTree = "<group>"; };
+		A1677E242144532800A08C34 /* JSPaymentMethodChangeEventCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentMethodChangeEventCustom.cpp; sourceTree = "<group>"; };
 		A1763F3C1E205234001D58DE /* WebArchiveDumpSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebArchiveDumpSupport.mm; sourceTree = "<group>"; };
 		A1763F3D1E205234001D58DE /* WebArchiveDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebArchiveDumpSupport.h; sourceTree = "<group>"; };
 		A1763F401E20586E001D58DE /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
@@ -19947,6 +19942,7 @@
 				4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */,
 				BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
 				410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
+				A1677E242144532800A08C34 /* JSPaymentMethodChangeEventCustom.cpp */,
 				A85F22081430377D007CC884 /* JSPopStateEventCustom.cpp */,
 				BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
 			);
@@ -21336,8 +21332,6 @@
 				A1CC564F1F46145200A4555B /* JSPaymentItem.h */,
 				A164A2532134C1CB00509156 /* JSPaymentMethodChangeEvent.cpp */,
 				A164A2512134C1CB00509156 /* JSPaymentMethodChangeEvent.h */,
-				A164A2542134C1CC00509156 /* JSPaymentMethodChangeEventInit.cpp */,
-				A164A2522134C1CB00509156 /* JSPaymentMethodChangeEventInit.h */,
 				A1CC564D1F46145100A4555B /* JSPaymentMethodData.cpp */,
 				A1CC564C1F46145000A4555B /* JSPaymentMethodData.h */,
 				A1CC56531F46145600A4555B /* JSPaymentOptions.cpp */,
@@ -21407,8 +21401,6 @@
 				A164A2452134BC7100509156 /* PaymentMethodChangeEvent.cpp */,
 				A164A2442134BC7100509156 /* PaymentMethodChangeEvent.h */,
 				A164A2462134BC7100509156 /* PaymentMethodChangeEvent.idl */,
-				A164A24B2134BDD800509156 /* PaymentMethodChangeEventInit.h */,
-				A164A24D2134BDD800509156 /* PaymentMethodChangeEventInit.idl */,
 				A1F76B161F44C3900014C318 /* PaymentMethodData.h */,
 				A1F76B181F44C3900014C318 /* PaymentMethodData.idl */,
 				A1F76B281F44C4EF0014C318 /* PaymentOptions.h */,
@@ -28896,7 +28888,6 @@
 				A1F6005A1F4765050077E83F /* JSPaymentDetailsUpdate.h in Headers */,
 				A1CC56731F46149800A4555B /* JSPaymentItem.h in Headers */,
 				A164A2552134C1CC00509156 /* JSPaymentMethodChangeEvent.h in Headers */,
-				A164A2562134C1CC00509156 /* JSPaymentMethodChangeEventInit.h in Headers */,
 				A1CC56751F46149D00A4555B /* JSPaymentMethodData.h in Headers */,
 				A1CC56771F4614A200A4555B /* JSPaymentOptions.h in Headers */,
 				A1CC56791F4614A700A4555B /* JSPaymentRequest.h in Headers */,
@@ -29682,7 +29673,6 @@
 				1AE96A891D1A0CEB00B86768 /* PaymentMerchantSession.h in Headers */,
 				1A8A643C1D19FC5300D0E00F /* PaymentMethod.h in Headers */,
 				A164A2472134BC7100509156 /* PaymentMethodChangeEvent.h in Headers */,
-				A164A24E2134BDD800509156 /* PaymentMethodChangeEventInit.h in Headers */,
 				A1F76B191F44C3900014C318 /* PaymentMethodData.h in Headers */,
 				A1F76B2B1F44C4EF0014C318 /* PaymentOptions.h in Headers */,
 				A1F76B131F44C2450014C318 /* PaymentRequest.h in Headers */,

Copied: trunk/Source/WebCore/bindings/js/JSPaymentMethodChangeEventCustom.cpp (from rev 235832, trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEventInit.h) (0 => 235833)


--- trunk/Source/WebCore/bindings/js/JSPaymentMethodChangeEventCustom.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSPaymentMethodChangeEventCustom.cpp	2018-09-09 02:03:52 UTC (rev 235833)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2018 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 "JSPaymentMethodChangeEvent.h"
+
+#if ENABLE(PAYMENT_REQUEST)
+
+namespace WebCore {
+
+JSC::JSValue JSPaymentMethodChangeEvent::methodDetails(JSC::ExecState& state) const
+{
+    return cachedPropertyValue(state, *this, wrapped().cachedMethodDetails(), [this, &state] {
+        return WTF::switchOn(wrapped().methodDetails(), [](JSC::JSValue methodDetails) {
+            return methodDetails ? methodDetails : JSC::jsNull();
+        }, [&state](const PaymentMethodChangeEvent::MethodDetailsFunction& function) {
+            return function(state).get();
+        });
+    });
+}
+
+void JSPaymentMethodChangeEvent::visitAdditionalChildren(JSC::SlotVisitor& visitor)
+{
+    WTF::switchOn(wrapped().methodDetails(), [&visitor](const JSValueInWrappedObject& methodDetails) {
+        methodDetails.visit(visitor);
+    }, [](const PaymentMethodChangeEvent::MethodDetailsFunction&) {
+    });
+
+    wrapped().cachedMethodDetails().visit(visitor);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(PAYMENT_REQUEST)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to