Diff
Modified: trunk/LayoutTests/ChangeLog (223075 => 223076)
--- trunk/LayoutTests/ChangeLog 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/ChangeLog 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,3 +1,23 @@
+2017-10-09 Andy Estes <[email protected]>
+
+ [Payment Request] Implement PaymentRequest.show() and PaymentRequest.hide()
+ https://bugs.webkit.org/show_bug.cgi?id=178043
+ <rdar://problem/34076639>
+
+ Reviewed by Tim Horton.
+
+ Copied payment-request-abort-method.https.html and payment-request-show-method.https.html
+ from web-platform-tests/payment-request/ and changed the payment method from basic-card to
+ Apple Pay. This needs to eventually be upstreamed back to WPT.
+
+ * TestExpectations:
+ * http/tests/paymentrequest/payment-request-abort-method.https-expected.txt: Added.
+ * http/tests/paymentrequest/payment-request-abort-method.https.html: Added.
+ * http/tests/paymentrequest/payment-request-show-method.https-expected.txt: Added.
+ * http/tests/paymentrequest/payment-request-show-method.https.html: Added.
+ * platform/ios-wk2/TestExpectations:
+ * platform/mac-wk2/TestExpectations:
+
2017-10-09 Youenn Fablet <[email protected]>
Add quota to cache API
Modified: trunk/LayoutTests/TestExpectations (223075 => 223076)
--- trunk/LayoutTests/TestExpectations 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/TestExpectations 2017-10-09 22:40:58 UTC (rev 223076)
@@ -148,6 +148,7 @@
fast/text/font-lookup-dot-prefix-case-sensitive.html [ Skip ]
# Payment Request is only enabled on Cocoa platforms.
+http/tests/paymentrequest [ Skip ]
imported/w3c/web-platform-tests/payment-request [ Skip ]
imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html [ ImageOnlyFailure ]
Added: trunk/LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https-expected.txt (0 => 223076)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https-expected.txt 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,5 @@
+
+PASS Throws if the promise [[state]] is not "interactive"
+PASS Calling abort must not change the [[state]] until after "interactive"
+PASS calling .abort() causes acceptPromise to reject and closes the request.
+
Added: trunk/LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https.html (0 => 223076)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https.html 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
+<!-- Copyright (C) 2017 Apple Inc. All rights reserved. -->
+<!-- FIXME: Upstream this test to web-platform-tests/payment-request/. -->
+<meta charset="utf-8">
+<title>Test for PaymentRequest.abort() method</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script>
+"use strict";
+setup(() => {}, {
+ // Ignore unhandled rejections resulting from .show()'s acceptPromise
+ // not being explicitly handled.
+ allow_uncaught_exception: true,
+});
+const applePay = Object.freeze({
+ supportedMethods: "https://apple.com/apple-pay",
+ data: {
+ version: 2,
+ merchantCapabilities: ['supports3DS'],
+ supportedNetworks: ['visa', 'masterCard'],
+ countryCode: 'US',
+ currencyCode: 'USD',
+ },
+});
+const defaultMethods = Object.freeze([applePay]);
+const defaultDetails = Object.freeze({
+ total: {
+ label: "Total",
+ amount: {
+ currency: "USD",
+ value: "1.00",
+ },
+ },
+});
+
+promise_test(async t => {
+ // request is in "created" state
+ const request = new PaymentRequest(defaultMethods, defaultDetails);
+ await promise_rejects(t, "InvalidStateError", request.abort());
+}, `Throws if the promise [[state]] is not "interactive"`);
+
+promise_test(async t => {
+ // request is in "created" state.
+ const request = new PaymentRequest(defaultMethods, defaultDetails);
+ await promise_rejects(t, "InvalidStateError", request.abort());
+ // Call it again, for good measure.
+ await promise_rejects(t, "InvalidStateError", request.abort());
+ // The request's state is "created", so let's show it
+ // which changes the state to "interactive.".
+ request.show();
+ // Let's set request the state to "closed" by calling .abort()
+ try {
+ await request.abort();
+ } catch (err) {
+ assert_true(false, "Unexpected promise rejection: " + err.message);
+ }
+ // The request is now "closed", so...
+ await promise_rejects(t, "InvalidStateError", request.abort());
+}, `Calling abort must not change the [[state]] until after "interactive"`);
+
+promise_test(async t => {
+ const request = new PaymentRequest(defaultMethods, defaultDetails);
+ const acceptPromise = request.show();
+ try {
+ await request.abort();
+ } catch (err) {
+ assert_true(false, "Unexpected promise rejection: " + err.message);
+ }
+ await promise_rejects(t, "AbortError", acceptPromise);
+ // As request is now "closed", trying to show it will fail
+ await promise_rejects(t, "InvalidStateError", request.show());
+}, "calling .abort() causes acceptPromise to reject and closes the request.");
+
+</script>
Added: trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt (0 => 223076)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https-expected.txt 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,6 @@
+
+PASS Must be possible to construct a payment request
+PASS Throws if the promise [[state]] is not "created"
+PASS If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.
+PASS If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.
+
Added: trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html (0 => 223076)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
+<!-- Copyright (C) 2017 Apple Inc. All rights reserved. -->
+<!-- FIXME: Upstream this test to web-platform-tests/payment-request/. -->
+<meta charset="utf-8">
+<title>Test for PaymentRequest.show() method</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script>
+'use strict';
+const applePay = Object.freeze({
+ supportedMethods: "https://apple.com/apple-pay",
+ data: {
+ version: 2,
+ merchantCapabilities: ['supports3DS'],
+ supportedNetworks: ['visa', 'masterCard'],
+ countryCode: 'US',
+ currencyCode: 'USD',
+ },
+});
+const defaultMethods = Object.freeze([applePay]);
+const defaultDetails = Object.freeze({
+ total: {
+ label: "Total",
+ amount: {
+ currency: "USD",
+ value: "1.00",
+ },
+ },
+});
+
+test(() => {
+ try {
+ new PaymentRequest(defaultMethods, defaultDetails);
+ } catch (err) {
+ done();
+ throw err;
+ }
+}, "Must be possible to construct a payment request");
+
+
+promise_test(async t => {
+ const request = new PaymentRequest(defaultMethods, defaultDetails);
+ const acceptPromise = request.show(); // Sets state to "interactive"
+ await promise_rejects(t, "InvalidStateError", request.show());
+ await request.abort();
+ await promise_rejects(t, "AbortError", acceptPromise);
+}, `Throws if the promise [[state]] is not "created"`);
+
+promise_test(async t => {
+ const request1 = new PaymentRequest(defaultMethods, defaultDetails);
+ const request2 = new PaymentRequest(defaultMethods, defaultDetails);
+ const acceptPromise1 = request1.show();
+ const acceptPromise2 = request2.show();
+ await promise_rejects(t, "AbortError", acceptPromise2);
+ await request1.abort();
+ await promise_rejects(t, "AbortError", acceptPromise1);
+}, `If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.`);
+
+promise_test(async t => {
+ const request = new PaymentRequest(
+ [{ supportedMethods: "this-is-not-supported" }],
+ defaultDetails);
+ const acceptPromise = request.show();
+ await promise_rejects(t, "NotSupportedError", acceptPromise);
+}, `If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.`);
+</script>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (223075 => 223076)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,3 +1,14 @@
+2017-10-09 Andy Estes <[email protected]>
+
+ [Payment Request] Implement PaymentRequest.show() and PaymentRequest.hide()
+ https://bugs.webkit.org/show_bug.cgi?id=178043
+ <rdar://problem/34076639>
+
+ Reviewed by Tim Horton.
+
+ * web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt: Removed.
+ * web-platform-tests/payment-request/payment-request-show-method.https-expected.txt: Removed.
+
2017-10-09 Youenn Fablet <[email protected]>
REGRESSION: Some bots fail to run LayoutTests due to a WPT Server error
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt (223075 => 223076)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https-expected.txt 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,5 +0,0 @@
-
-PASS Throws if the promise [[state]] is not "interactive"
-PASS Calling abort must not change the [[state]] until after "interactive"
-FAIL calling .abort() causes acceptPromise to reject and closes the request. assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException AbortError: property "code" is equal to 9, expected 20
-
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https-expected.txt (223075 => 223076)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https-expected.txt 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https-expected.txt 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,6 +0,0 @@
-
-PASS Must be possible to construct a payment request
-FAIL Throws if the promise [[state]] is not "created" assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException AbortError: property "code" is equal to 9, expected 20
-FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "NotSupportedError: The operation is not supported." that is not a DOMException AbortError: property "code" is equal to 9, expected 20
-PASS If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException.
-
Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (223075 => 223076)
--- trunk/LayoutTests/platform/ios-wk2/TestExpectations 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2017-10-09 22:40:58 UTC (rev 223076)
@@ -28,6 +28,7 @@
fast/viewport/ios/viewport-fit-cover.html [ Skip ]
fast/viewport/ios/viewport-fit-auto.html [ Skip ]
+http/tests/paymentrequest [ Pass ]
imported/w3c/web-platform-tests/payment-request [ Pass ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/allowpaymentrequest-attribute-cross-origin-bc-containers.https.html [ Skip ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/no-attribute-cross-origin-bc-containers.https.html [ Skip ]
@@ -34,9 +35,11 @@
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html [ Skip ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html [ Skip ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html [ Skip ]
-webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ Pass Failure ]
-webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ Pass Failure ]
+# skip in favor of tests in http/tests/paymentrequest
+imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ WontFix ]
+imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ WontFix ]
+
# skip manual payment-request tests
imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html [ Skip ]
imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html [ Skip ]
Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (223075 => 223076)
--- trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations 2017-10-09 22:40:58 UTC (rev 223076)
@@ -25,7 +25,8 @@
fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]
fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ]
-imported/w3c/web-platform-tests/payment-request [ Pass ]
+[ Sierra+ ] http/tests/paymentrequest [ Pass ]
+[ Sierra+ ] imported/w3c/web-platform-tests/payment-request [ Pass ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/allowpaymentrequest-attribute-cross-origin-bc-containers.https.html [ Skip ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/no-attribute-cross-origin-bc-containers.https.html [ Skip ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/removing-allowpaymentrequest.https.sub.html [ Skip ]
@@ -32,9 +33,11 @@
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest-timing.https.sub.html [ Skip ]
webkit.org/b/175611 imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/setting-allowpaymentrequest.https.sub.html [ Skip ]
webkit.org/b/177783 imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html [ Skip ]
-webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ Pass Failure ]
-webkit.org/b/177391 imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ Pass Failure ]
+# skip in favor of tests in http/tests/paymentrequest
+imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html [ WontFix ]
+imported/w3c/web-platform-tests/payment-request/payment-request-abort-method.https.html [ WontFix ]
+
# skip manual payment-request tests
imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html [ Skip ]
imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (223075 => 223076)
--- trunk/Source/WebCore/ChangeLog 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/ChangeLog 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,3 +1,61 @@
+2017-10-09 Andy Estes <[email protected]>
+
+ [Payment Request] Implement PaymentRequest.show() and PaymentRequest.hide()
+ https://bugs.webkit.org/show_bug.cgi?id=178043
+ <rdar://problem/34076639>
+
+ Reviewed by Tim Horton.
+
+ Tests: http/tests/paymentrequest/payment-request-abort-method.https.html
+ http/tests/paymentrequest/payment-request-show-method.https.html
+
+ * Modules/applepay/PaymentCoordinator.h:
+ * Modules/applepay/PaymentSession.h: Virtually inherited from PaymentSessionBase to
+ accommodate ApplePayPaymentHandler inheriting from both this and PaymentHandler.
+ (WebCore::PaymentSession::~PaymentSession): Deleted.
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+ (WebCore::paymentCoordinator): Virtually inherited from PaymentSessionBase to accommodate
+ ApplePayPaymentHandler inheriting from both this and PaymentSession.
+ (WebCore::ApplePayPaymentHandler::hasActiveSession): Added. Calls PaymentCoordinator::hasActiveSession().
+ (WebCore::ApplePayPaymentHandler::show): Added. Calls PaymentCoordinator::beginPaymentSession().
+ (WebCore::ApplePayPaymentHandler::hide): Added. Calls PaymentCoordinator::abortPaymentSession().
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h: Inherited from PaymentSession in
+ addition to PaymentHandler so that this can be PaymentCoordinator active session.
+ * Modules/paymentrequest/PaymentHandler.cpp:
+ (WebCore::PaymentHandler::create):
+ (WebCore::PaymentHandler::hasActiveSession):
+ * Modules/paymentrequest/PaymentHandler.h:
+ * Modules/paymentrequest/PaymentRequest.cpp:
+ (WebCore::PaymentRequest::~PaymentRequest):
+ (WebCore::PaymentRequest::show): Rejected the promise if PaymentCoordinator has an active session.
+ (WebCore::PaymentRequest::abort): Called stop().
+ (WebCore::PaymentRequest::canSuspendForDocumentSuspension const): Returned true if state is
+ Interactive and there is an active handler showing.
+ (WebCore::PaymentRequest::stop): Hid the active session if it's showing, then set state to
+ Closed and rejected the show promise.
+ * Modules/paymentrequest/PaymentRequest.h:
+ * Modules/paymentrequest/PaymentSessionBase.h: Added. Inherits from
+ RefCounted<PaymentSessionBase> and defines a virtual destructor. This allows subclasses to
+ virtually inherit a single ref-count to support multiple inheritance.
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GetGnuVTableOffsetForType): Added ApplePaySession to the list of classes that need a vtable
+ offset of 3.
+ * page/MainFrame.cpp:
+ (WebCore::MainFrame::setPaymentCoordinator): Added a setter for m_paymentCoordinator.
+ * page/MainFrame.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::Internals): Set the main frame's payment coordinator to a new
+ PaymentCoordinator with MockPaymentCoordinator as its client.
+ * testing/MockPaymentCoordinator.cpp: Added a mock PaymentCoordinatorClient for testing.
+ (WebCore::MockPaymentCoordinator::supportsVersion):
+ (WebCore::MockPaymentCoordinator::canMakePayments):
+ (WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard):
+ (WebCore::MockPaymentCoordinator::openPaymentSetup):
+ (WebCore::MockPaymentCoordinator::showPaymentUI):
+ (WebCore::MockPaymentCoordinator::paymentCoordinatorDestroyed):
+ * testing/MockPaymentCoordinator.h: Added.
+
2017-10-09 Youenn Fablet <[email protected]>
Add quota to cache API
Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (223075 => 223076)
--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-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
@@ -47,8 +47,8 @@
class PaymentCoordinator {
public:
- explicit PaymentCoordinator(PaymentCoordinatorClient&);
- ~PaymentCoordinator();
+ WEBCORE_EXPORT explicit PaymentCoordinator(PaymentCoordinatorClient&);
+ WEBCORE_EXPORT ~PaymentCoordinator();
bool supportsVersion(unsigned version);
bool canMakePayments();
Modified: trunk/Source/WebCore/Modules/applepay/PaymentSession.h (223075 => 223076)
--- trunk/Source/WebCore/Modules/applepay/PaymentSession.h 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/applepay/PaymentSession.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -28,7 +28,7 @@
#if ENABLE(APPLE_PAY)
#include "ApplePaySessionPaymentRequest.h"
-#include <wtf/RefCounted.h>
+#include "PaymentSessionBase.h"
namespace WebCore {
@@ -37,10 +37,8 @@
class PaymentMethod;
class URL;
-class PaymentSession : public RefCounted<PaymentSession> {
+class PaymentSession : public virtual PaymentSessionBase {
public:
- virtual ~PaymentSession() { }
-
virtual void validateMerchant(const URL&) = 0;
virtual void didAuthorizePayment(const Payment&) = 0;
virtual void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) = 0;
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (223075 => 223076)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2017-10-09 22:40:58 UTC (rev 223076)
@@ -34,6 +34,7 @@
#include "Document.h"
#include "Frame.h"
#include "JSApplePayRequest.h"
+#include "LinkIconCollector.h"
#include "MainFrame.h"
#include "PaymentContact.h"
#include "PaymentCoordinator.h"
@@ -50,6 +51,16 @@
return url.host() == "apple.com" && url.path() == "/apple-pay";
}
+static inline PaymentCoordinator& paymentCoordinator(Document& document)
+{
+ return document.frame()->mainFrame().paymentCoordinator();
+}
+
+bool ApplePayPaymentHandler::hasActiveSession(Document& document)
+{
+ return paymentCoordinator(document).hasActiveSession();
+}
+
ApplePayPaymentHandler::ApplePayPaymentHandler(PaymentRequest& paymentRequest)
: m_paymentRequest { paymentRequest }
{
@@ -147,11 +158,20 @@
return { };
}
-void ApplePayPaymentHandler::show()
+void ApplePayPaymentHandler::show(Document& document)
{
- // FIXME: Call PaymentCoordinator::beginPaymentSession() with m_applePayRequest
+ Vector<URL> linkIconURLs;
+ for (auto& icon : LinkIconCollector { document }.iconsOfTypes({ LinkIconType::TouchIcon, LinkIconType::TouchPrecomposedIcon }))
+ linkIconURLs.append(icon.url);
+
+ paymentCoordinator(document).beginPaymentSession(*this, document.url(), linkIconURLs, *m_applePayRequest);
}
+void ApplePayPaymentHandler::hide(Document& document)
+{
+ paymentCoordinator(document).abortPaymentSession();
+}
+
} // namespace WebCore
#endif // ENABLE(APPLE_PAY) && ENABLE(PAYMENT_REQUEST)
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (223075 => 223076)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -29,26 +29,36 @@
#include "ApplePaySessionPaymentRequest.h"
#include "PaymentHandler.h"
+#include "PaymentSession.h"
#include <wtf/Noncopyable.h>
#include <wtf/Ref.h>
namespace WebCore {
-class Document;
class PaymentRequest;
-class ApplePayPaymentHandler final : public PaymentHandler {
- WTF_MAKE_NONCOPYABLE(ApplePayPaymentHandler);
+class ApplePayPaymentHandler final : public PaymentHandler, public PaymentSession {
public:
static bool handlesIdentifier(const PaymentRequest::MethodIdentifier&);
+ static bool hasActiveSession(Document&);
private:
- friend std::unique_ptr<ApplePayPaymentHandler> std::make_unique<ApplePayPaymentHandler>(PaymentRequest&);
+ friend class PaymentHandler;
explicit ApplePayPaymentHandler(PaymentRequest&);
+ // PaymentHandler
ExceptionOr<void> convertData(JSC::ExecState&, JSC::JSValue&&) final;
- void show() final;
+ void show(Document&) final;
+ void hide(Document&) final;
+ // PaymentSession
+ void validateMerchant(const URL&) final { }
+ void didAuthorizePayment(const Payment&) final { }
+ void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final { }
+ void didSelectShippingContact(const PaymentContact&) final { }
+ void didSelectPaymentMethod(const PaymentMethod&) final { }
+ void didCancelPaymentSession() final { }
+
Ref<PaymentRequest> m_paymentRequest;
std::optional<ApplePaySessionPaymentRequest> m_applePayRequest;
};
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp (223075 => 223076)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp 2017-10-09 22:40:58 UTC (rev 223076)
@@ -34,11 +34,11 @@
namespace WebCore {
-std::unique_ptr<PaymentHandler> PaymentHandler::create(PaymentRequest& paymentRequest, const PaymentRequest::MethodIdentifier& identifier)
+RefPtr<PaymentHandler> PaymentHandler::create(PaymentRequest& paymentRequest, const PaymentRequest::MethodIdentifier& identifier)
{
#if ENABLE(APPLE_PAY)
if (ApplePayPaymentHandler::handlesIdentifier(identifier))
- return std::make_unique<ApplePayPaymentHandler>(paymentRequest);
+ return adoptRef(new ApplePayPaymentHandler(paymentRequest));
#else
UNUSED_PARAM(paymentRequest);
UNUSED_PARAM(identifier);
@@ -47,6 +47,16 @@
return nullptr;
}
+bool PaymentHandler::hasActiveSession(Document& document)
+{
+#if ENABLE(APPLE_PAY)
+ return ApplePayPaymentHandler::hasActiveSession(document);
+#else
+ UNUSED_PARAM(document);
+ return false;
+#endif
+}
+
} // namespace WebCore
#endif // ENABLE(PAYMENT_REQUEST)
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h (223075 => 223076)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -28,6 +28,7 @@
#if ENABLE(PAYMENT_REQUEST)
#include "PaymentRequest.h"
+#include "PaymentSessionBase.h"
namespace JSC {
class ExecState;
@@ -36,13 +37,16 @@
namespace WebCore {
-class PaymentHandler {
+class Document;
+
+class PaymentHandler : public virtual PaymentSessionBase {
public:
- static std::unique_ptr<PaymentHandler> create(PaymentRequest&, const PaymentRequest::MethodIdentifier&);
- virtual ~PaymentHandler() = default;
+ static RefPtr<PaymentHandler> create(PaymentRequest&, const PaymentRequest::MethodIdentifier&);
+ static bool hasActiveSession(Document&);
virtual ExceptionOr<void> convertData(JSC::ExecState&, JSC::JSValue&&) = 0;
- virtual void show() = 0;
+ virtual void show(Document&) = 0;
+ virtual void hide(Document&) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (223075 => 223076)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2017-10-09 22:40:58 UTC (rev 223076)
@@ -336,6 +336,8 @@
PaymentRequest::~PaymentRequest()
{
+ ASSERT(!hasPendingActivity());
+ ASSERT(!m_activePaymentHandler);
}
// https://www.w3.org/TR/payment-request/#show()-method
@@ -349,16 +351,20 @@
return;
}
- // FIXME: Reject promise with AbortError if PaymentCoordinator already has an active session.
+ auto& document = downcast<Document>(*scriptExecutionContext());
+ if (PaymentHandler::hasActiveSession(document)) {
+ promise.reject(Exception { AbortError });
+ return;
+ }
m_state = State::Interactive;
ASSERT(!m_showPromise);
m_showPromise = WTFMove(promise);
- std::unique_ptr<PaymentHandler> selectedPaymentHandler;
+ RefPtr<PaymentHandler> selectedPaymentHandler;
for (auto& paymentMethod : m_serializedMethodData) {
- auto scope = DECLARE_THROW_SCOPE(scriptExecutionContext()->vm());
- JSC::JSValue data = "" paymentMethod.serializedData);
+ auto scope = DECLARE_THROW_SCOPE(document.vm());
+ JSC::JSValue data = "" paymentMethod.serializedData);
if (scope.exception()) {
m_showPromise->reject(Exception { ExistingExceptionError });
return;
@@ -368,7 +374,7 @@
if (!handler)
continue;
- auto result = handler->convertData(*scriptExecutionContext()->execState(), WTFMove(data));
+ auto result = handler->convertData(*document.execState(), WTFMove(data));
if (result.hasException()) {
m_showPromise->reject(result.releaseException());
return;
@@ -383,7 +389,11 @@
return;
}
- selectedPaymentHandler->show();
+ ASSERT(!m_activePaymentHandler);
+ m_activePaymentHandler = WTFMove(selectedPaymentHandler);
+
+ m_activePaymentHandler->show(document);
+ setPendingActivity(this);
}
// https://www.w3.org/TR/payment-request/#abort()-method
@@ -392,9 +402,7 @@
if (m_state != State::Interactive)
return Exception { InvalidStateError };
- m_state = State::Closed;
- ASSERT(m_showPromise);
- m_showPromise->reject(Exception { AbortError });
+ stop();
promise.resolve();
return { };
}
@@ -423,6 +431,33 @@
return std::nullopt;
}
+bool PaymentRequest::canSuspendForDocumentSuspension() const
+{
+ switch (m_state) {
+ case State::Created:
+ case State::Closed:
+ ASSERT(!m_activePaymentHandler);
+ return true;
+ case State::Interactive:
+ return !m_activePaymentHandler;
+ }
+}
+
+void PaymentRequest::stop()
+{
+ if (m_state != State::Interactive)
+ return;
+
+ if (auto paymentHandler = std::exchange(m_activePaymentHandler, nullptr)) {
+ unsetPendingActivity(this);
+ paymentHandler->hide(downcast<Document>(*scriptExecutionContext()));
+ }
+
+ ASSERT(m_state == State::Interactive);
+ m_state = State::Closed;
+ m_showPromise->reject(Exception { AbortError });
+}
+
} // namespace WebCore
#endif // ENABLE(PAYMENT_REQUEST)
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (223075 => 223076)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -40,6 +40,7 @@
class Document;
class PaymentAddress;
+class PaymentHandler;
class PaymentResponse;
enum class PaymentShippingType;
struct PaymentMethodData;
@@ -85,8 +86,8 @@
// ActiveDOMObject
const char* activeDOMObjectName() const final { return "PaymentRequest"; }
- bool canSuspendForDocumentSuspension() const final { return true; }
- void stop() final { }
+ bool canSuspendForDocumentSuspension() const final;
+ void stop() final;
// EventTarget
EventTargetInterface eventTargetInterface() const final { return PaymentRequestEventTargetInterfaceType; }
@@ -102,8 +103,8 @@
RefPtr<PaymentAddress> m_shippingAddress;
State m_state { State::Created };
std::optional<ShowPromise> m_showPromise;
- std::optional<AbortPromise> m_abortPromise;
std::optional<CanMakePaymentPromise> m_canMakePaymentPromise;
+ RefPtr<PaymentHandler> m_activePaymentHandler;
};
std::optional<PaymentRequest::MethodIdentifier> convertAndValidatePaymentMethodIdentifier(const String& identifier);
Copied: trunk/Source/WebCore/Modules/paymentrequest/PaymentSessionBase.h (from rev 223073, trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.h) (0 => 223076)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentSessionBase.h (rev 0)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentSessionBase.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,40 @@
+/*
+ * 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 <wtf/RefCounted.h>
+
+namespace WebCore {
+
+struct PaymentSessionBase : RefCounted<PaymentSessionBase> {
+ virtual ~PaymentSessionBase() = default;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY) || ENABLE(PAYMENT_REQUEST)
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223075 => 223076)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-09 22:40:58 UTC (rev 223076)
@@ -2347,7 +2347,6 @@
517A534E1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */; };
517A534F1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B51C89912600A7E715 /* FetchLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
517A63C31B74318700E7DCDC /* KeyedDecoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */; };
@@ -4438,6 +4437,7 @@
A17C81220F2A5CF7005DAAEB /* HTMLElementFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */; };
A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */; };
A17D275E1EAC579800BF01E7 /* MediaSelectionOption.h in Headers */ = {isa = PBXBuildFile; fileRef = A17D275D1EAC579800BF01E7 /* MediaSelectionOption.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ A17FEE641F8893220021E811 /* PaymentSessionBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A17FEE631F8893220021E811 /* PaymentSessionBase.h */; };
A182D5B71BE722670087A7CC /* SettingsCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A182D5B61BE722620087A7CC /* SettingsCocoa.mm */; };
A185B4291E8211A100DC9118 /* PreviewLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = A185B4271E8211A100DC9118 /* PreviewLoader.mm */; };
A185B42A1E8211A100DC9118 /* PreviewLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A185B4281E8211A100DC9118 /* PreviewLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4449,6 +4449,8 @@
A19D934A1AA11B1E00B46C24 /* NetworkExtensionContentFilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = A19D93481AA11B1E00B46C24 /* NetworkExtensionContentFilter.mm */; };
A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */; };
A1AA9AB91D23911500FEADB3 /* ContentFilterBlockedPage.html in Resources */ = {isa = PBXBuildFile; fileRef = A1AA9AB81D23911500FEADB3 /* ContentFilterBlockedPage.html */; };
+ A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */; };
+ A1AFEDE71F8BFF6D0087013F /* MockPaymentCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */; };
A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */; };
A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */; };
@@ -12922,6 +12924,7 @@
A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLElementFactory.cpp; sourceTree = "<group>"; };
A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLElementFactory.h; sourceTree = "<group>"; };
A17D275D1EAC579800BF01E7 /* MediaSelectionOption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaSelectionOption.h; sourceTree = "<group>"; };
+ A17FEE631F8893220021E811 /* PaymentSessionBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentSessionBase.h; sourceTree = "<group>"; };
A182D5B61BE722620087A7CC /* SettingsCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SettingsCocoa.mm; sourceTree = "<group>"; };
A185B4271E8211A100DC9118 /* PreviewLoader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PreviewLoader.mm; sourceTree = "<group>"; };
A185B4281E8211A100DC9118 /* PreviewLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PreviewLoader.h; sourceTree = "<group>"; };
@@ -12934,6 +12937,8 @@
A19D93481AA11B1E00B46C24 /* NetworkExtensionContentFilter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkExtensionContentFilter.mm; sourceTree = "<group>"; };
A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkExtensionContentFilter.h; sourceTree = "<group>"; };
A1AA9AB81D23911500FEADB3 /* ContentFilterBlockedPage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = ContentFilterBlockedPage.html; sourceTree = "<group>"; };
+ A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockPaymentCoordinator.h; sourceTree = "<group>"; };
+ A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockPaymentCoordinator.cpp; sourceTree = "<group>"; };
A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockContentFilterSettings.cpp; sourceTree = "<group>"; };
A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockContentFilterSettings.h; sourceTree = "<group>"; };
A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockContentFilter.cpp; sourceTree = "<group>"; };
@@ -18226,6 +18231,8 @@
2D6F3E8C1C1ECB1C0061DBD4 /* MockPageOverlay.idl */,
2DAAE32C19DCAF6000E002D2 /* MockPageOverlayClient.cpp */,
2DAAE32D19DCAF6000E002D2 /* MockPageOverlayClient.h */,
+ A1AFEDE51F8BFF6D0087013F /* MockPaymentCoordinator.cpp */,
+ A1AFEDE41F8BFF6D0087013F /* MockPaymentCoordinator.h */,
A14061891E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp */,
A140618A1E2ECA0A0032B34E /* MockPreviewLoaderClient.h */,
EB081CD81696084400553730 /* TypeConversions.h */,
@@ -21764,6 +21771,7 @@
A1F76B3B1F44CF240014C318 /* PaymentResponse.cpp */,
A1F76B3A1F44CF240014C318 /* PaymentResponse.h */,
A1F76B3C1F44CF240014C318 /* PaymentResponse.idl */,
+ A17FEE631F8893220021E811 /* PaymentSessionBase.h */,
A1F76B521F44D2C70014C318 /* PaymentShippingOption.h */,
A1F76B541F44D2C70014C318 /* PaymentShippingOption.idl */,
A1F76B461F44D07A0014C318 /* PaymentShippingType.h */,
@@ -22171,12 +22179,12 @@
6E4ABCD3138EA0B70071D291 /* JSHTMLUnknownElement.h */,
E446140E0CD6826900FADA75 /* JSHTMLVideoElement.cpp */,
E446140F0CD6826900FADA75 /* JSHTMLVideoElement.h */,
- 7C7903B71F86FDE400463A70 /* JSImageBitmapRenderingContext.cpp */,
- 7C7903B81F86FDE600463A70 /* JSImageBitmapRenderingContext.h */,
31D26BC61F86D269008FF255 /* JSImageBitmap.cpp */,
31D26BC31F86D265008FF255 /* JSImageBitmap.h */,
31D26BC41F86D266008FF255 /* JSImageBitmapOptions.cpp */,
31D26BC51F86D268008FF255 /* JSImageBitmapOptions.h */,
+ 7C7903B71F86FDE400463A70 /* JSImageBitmapRenderingContext.cpp */,
+ 7C7903B81F86FDE600463A70 /* JSImageBitmapRenderingContext.h */,
A77979240D6B9E64003851B9 /* JSImageData.cpp */,
A77979250D6B9E64003851B9 /* JSImageData.h */,
7C193BFB1F5E10C40088F3E6 /* JSImageSmoothingQuality.cpp */,
@@ -27142,6 +27150,7 @@
4157EBFB1E3AB67F00AC9FE9 /* MockLibWebRTCPeerConnection.h in Headers */,
2D6F3E911C1ECB2F0061DBD4 /* MockPageOverlay.h in Headers */,
2D97F04819DD4140001EE9C3 /* MockPageOverlayClient.h in Headers */,
+ A1AFEDE61F8BFF6D0087013F /* MockPaymentCoordinator.h in Headers */,
A140618C1E2ECA0A0032B34E /* MockPreviewLoaderClient.h in Headers */,
AA5F3B8D16CC33D100455EB0 /* PlatformSpeechSynthesizerMock.h in Headers */,
A1763F3F1E205234001D58DE /* WebArchiveDumpSupport.h in Headers */,
@@ -27971,8 +27980,10 @@
84730D851248F0B300D3A9C9 /* FEMorphology.h in Headers */,
84730D871248F0B300D3A9C9 /* FEOffset.h in Headers */,
84730D891248F0B300D3A9C9 /* FESpecularLighting.h in Headers */,
+ 517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */,
4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */,
41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */,
+ 517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */,
41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */,
7CE1914D1F2A9AFB00272F78 /* FetchReferrerPolicy.h in Headers */,
7CE1915A1F2A9B3400272F78 /* FetchRequestCache.h in Headers */,
@@ -28190,7 +28201,6 @@
93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
977B3867122883E900B81FF8 /* HTMLDocumentParser.h in Headers */,
93F198E608245E59001E9ABC /* HTMLElement.h in Headers */,
- 517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */,
A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */,
977B37241228721700B81FF8 /* HTMLElementStack.h in Headers */,
B562DB6017D3CD630010AF96 /* HTMLElementTypeHelpers.h in Headers */,
@@ -28818,6 +28828,7 @@
B6566270120B1227006EA85C /* JSIDBTransaction.h in Headers */,
838EF53C1DC14A7C008F0C39 /* JSIDBTransactionMode.h in Headers */,
269239961505E1AA009E57FC /* JSIDBVersionChangeEvent.h in Headers */,
+ 7C7761AA1F878AA500F869FC /* JSImageBitmapRenderingContext.h in Headers */,
A77979290D6B9E64003851B9 /* JSImageData.h in Headers */,
7C193C011F5E11050088F3E6 /* JSImageSmoothingQuality.h in Headers */,
A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */,
@@ -29368,7 +29379,6 @@
FA654A6C1108ABED002626F1 /* MathMLUnderOverElement.h in Headers */,
37C738EF1EDBD71B003F2B0B /* MathMLUnknownElement.h in Headers */,
439046EA12DA25E812AF80AC /* MathOperator.h in Headers */,
- 517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */,
49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
49E911C70EF86D47009D0CAF /* MatrixTransformOperation.h in Headers */,
5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */,
@@ -29442,7 +29452,6 @@
CDC8B5A7180474F70016E685 /* MediaSourcePrivateAVFObjC.h in Headers */,
CDDC1E7A18A952F30027A9D4 /* MediaSourcePrivateClient.h in Headers */,
CD61FE681794AADB004101EB /* MediaSourceRegistry.h in Headers */,
- 7C7761AA1F878AA500F869FC /* JSImageBitmapRenderingContext.h in Headers */,
078E091517D14D1C00420AA1 /* MediaStream.h in Headers */,
078E094C17D1709600420AA1 /* MediaStreamAudioDestinationNode.h in Headers */,
0783228518013ED800999E0C /* MediaStreamAudioSource.h in Headers */,
@@ -29525,7 +29534,6 @@
656D37430ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h in Headers */,
A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */,
628D214C12131ED10055DCFC /* NetworkingContext.h in Headers */,
- 517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
8A81BF8511DCFD9000DA2B98 /* NetworkLoadMetrics.h in Headers */,
59C27F07138D28CF0079B7E2 /* NetworkResourcesData.h in Headers */,
1A7FA6190DDA3B3A0028F8A5 /* NetworkStateNotifier.h in Headers */,
@@ -29658,6 +29666,7 @@
1A8A64681D19FDFF00D0E00F /* PaymentRequestValidator.h in Headers */,
A1F76B3D1F44CF240014C318 /* PaymentResponse.h in Headers */,
A1491DA31F859D870095F5D4 /* PaymentSession.h in Headers */,
+ A17FEE641F8893220021E811 /* PaymentSessionBase.h in Headers */,
A1F76B551F44D2C70014C318 /* PaymentShippingOption.h in Headers */,
A1F76B491F44D07A0014C318 /* PaymentShippingType.h in Headers */,
B27535650B053814002CE64F /* PDFDocumentImage.h in Headers */,
@@ -30143,6 +30152,7 @@
2D93AEE319DF5641002A86C3 /* ServicesOverlayController.h in Headers */,
51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */,
51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */,
+ 517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */,
51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */,
51F175641F3EBC8300C74950 /* ServiceWorkerJobClient.h in Headers */,
@@ -31340,6 +31350,7 @@
4157EBFA1E3AB67900AC9FE9 /* MockLibWebRTCPeerConnection.cpp in Sources */,
2D6F3E901C1ECB270061DBD4 /* MockPageOverlay.cpp in Sources */,
2D97F04719DD413C001EE9C3 /* MockPageOverlayClient.cpp in Sources */,
+ A1AFEDE71F8BFF6D0087013F /* MockPaymentCoordinator.cpp in Sources */,
A140618B1E2ECA0A0032B34E /* MockPreviewLoaderClient.cpp in Sources */,
AA5F3B8F16CC4B3900455EB0 /* PlatformSpeechSynthesizerMock.cpp in Sources */,
A1763F3E1E205234001D58DE /* WebArchiveDumpSupport.mm in Sources */,
@@ -31749,7 +31760,6 @@
4A6E9FC313C17D1D0046A7F8 /* CSSFontFeatureValue.cpp in Sources */,
BC64B4DB0CB4298A005F2B62 /* CSSFontSelector.cpp in Sources */,
C2E38F011E84573500CA3ADF /* CSSFontStyleRangeValue.cpp in Sources */,
- 7C7761A81F878A8B00F869FC /* JSImageBitmapRenderingContext.cpp in Sources */,
C2E38EFD1E8396FD00CA3ADF /* CSSFontStyleValue.cpp in Sources */,
A80E6CF10A1989CA007FB8C5 /* CSSFontValue.cpp in Sources */,
C21DF2E91D9E4E9900F5B24C /* CSSFontVariationValue.cpp in Sources */,
@@ -32392,8 +32402,8 @@
C3CF17A415B0063F00276D39 /* IdTargetObserver.cpp in Sources */,
C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */,
B275356F0B053814002CE64F /* Image.cpp in Sources */,
+ 31D26BCB1F87065B008FF255 /* ImageBitmap.cpp in Sources */,
7C7903B41F86F95C00463A70 /* ImageBitmapRenderingContext.cpp in Sources */,
- 31D26BCB1F87065B008FF255 /* ImageBitmap.cpp in Sources */,
43D2597713C816F400608559 /* ImageBuffer.cpp in Sources */,
B2A10B940B3818D700099AA4 /* ImageBufferCG.cpp in Sources */,
2292B27C1356669400CF11EF /* ImageBufferDataCG.cpp in Sources */,
@@ -32865,6 +32875,7 @@
511EF2CB17F0FD3500E4FA16 /* JSIDBVersionChangeEvent.cpp in Sources */,
31D26BC81F87063D008FF255 /* JSImageBitmap.cpp in Sources */,
31D26BCA1F870645008FF255 /* JSImageBitmapOptions.cpp in Sources */,
+ 7C7761A81F878A8B00F869FC /* JSImageBitmapRenderingContext.cpp in Sources */,
A77979280D6B9E64003851B9 /* JSImageData.cpp in Sources */,
A7D0318E0E93540300E24ACD /* JSImageDataCustom.cpp in Sources */,
7C193C001F5E11050088F3E6 /* JSImageSmoothingQuality.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (223075 => 223076)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2017-10-09 22:40:58 UTC (rev 223076)
@@ -3522,7 +3522,8 @@
sub GetGnuVTableOffsetForType
{
my $typename = shift;
- if ($typename eq "SVGAElement"
+ if ($typename eq "ApplePaySession"
+ || $typename eq "SVGAElement"
|| $typename eq "SVGCircleElement"
|| $typename eq "SVGClipPathElement"
|| $typename eq "SVGDefsElement"
Modified: trunk/Source/WebCore/page/MainFrame.cpp (223075 => 223076)
--- trunk/Source/WebCore/page/MainFrame.cpp 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/page/MainFrame.cpp 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-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
@@ -137,4 +137,11 @@
}
#endif
+#if ENABLE(APPLE_PAY)
+void MainFrame::setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&& paymentCoordinator)
+{
+ m_paymentCoordinator = WTFMove(paymentCoordinator);
}
+#endif
+
+}
Modified: trunk/Source/WebCore/page/MainFrame.h (223075 => 223076)
--- trunk/Source/WebCore/page/MainFrame.h 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/page/MainFrame.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-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
@@ -64,6 +64,7 @@
#if ENABLE(APPLE_PAY)
PaymentCoordinator& paymentCoordinator() const { return *m_paymentCoordinator; }
+ WEBCORE_EXPORT void setPaymentCoordinator(std::unique_ptr<PaymentCoordinator>&&);
#endif
PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
Modified: trunk/Source/WebCore/testing/Internals.cpp (223075 => 223076)
--- trunk/Source/WebCore/testing/Internals.cpp 2017-10-09 22:30:43 UTC (rev 223075)
+++ trunk/Source/WebCore/testing/Internals.cpp 2017-10-09 22:40:58 UTC (rev 223076)
@@ -241,6 +241,11 @@
#include "PreviewLoader.h"
#endif
+#if ENABLE(APPLE_PAY)
+#include "MockPaymentCoordinator.h"
+#include "PaymentCoordinator.h"
+#endif
+
using JSC::CallData;
using JSC::CallType;
using JSC::CodeBlock;
@@ -500,6 +505,10 @@
}
setConsoleMessageListener(nullptr);
+
+#if ENABLE(APPLE_PAY)
+ document.frame()->mainFrame().setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*new MockPaymentCoordinator()));
+#endif
}
Document* Internals::contextDocument() const
Copied: trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp (from rev 223073, trunk/Source/WebCore/Modules/paymentrequest/PaymentHandler.cpp) (0 => 223076)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp (rev 0)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockPaymentCoordinator.h"
+
+#if ENABLE(APPLE_PAY)
+
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+bool MockPaymentCoordinator::supportsVersion(unsigned version)
+{
+ ASSERT(version > 0);
+
+#if !ENABLE(APPLE_PAY_SESSION_V3)
+ static const unsigned currentVersion = 2;
+#else
+ static const unsigned currentVersion = 3;
+#endif
+
+ return version <= currentVersion;
+}
+
+bool MockPaymentCoordinator::canMakePayments()
+{
+ return true;
+}
+
+void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&& completionHandler)
+{
+ RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() {
+ completionHandler(true);
+ });
+}
+
+void MockPaymentCoordinator::openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&& completionHandler)
+{
+ RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)]() {
+ completionHandler(true);
+ });
+}
+
+bool MockPaymentCoordinator::showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&)
+{
+ return true;
+}
+
+void MockPaymentCoordinator::paymentCoordinatorDestroyed()
+{
+ delete this;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)
Copied: trunk/Source/WebCore/testing/MockPaymentCoordinator.h (from rev 223073, trunk/Source/WebCore/Modules/applepay/PaymentSession.h) (0 => 223076)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.h (rev 0)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.h 2017-10-09 22:40:58 UTC (rev 223076)
@@ -0,0 +1,53 @@
+/*
+ * 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 "PaymentCoordinatorClient.h"
+
+namespace WebCore {
+
+class MockPaymentCoordinator final : public PaymentCoordinatorClient {
+private:
+ bool supportsVersion(unsigned) final;
+ bool canMakePayments() final;
+ void canMakePaymentsWithActiveCard(const String&, const String&, WTF::Function<void(bool)>&&);
+ void openPaymentSetup(const String&, const String&, WTF::Function<void(bool)>&&);
+ bool showPaymentUI(const URL&, const Vector<URL>&, const ApplePaySessionPaymentRequest&) final;
+ void completeMerchantValidation(const PaymentMerchantSession&) final { }
+ void completeShippingMethodSelection(std::optional<ShippingMethodUpdate>&&) final { }
+ void completeShippingContactSelection(std::optional<ShippingContactUpdate>&&) final { }
+ void completePaymentMethodSelection(std::optional<PaymentMethodUpdate>&&) final { }
+ void completePaymentSession(std::optional<PaymentAuthorizationResult>&&) final { }
+ void abortPaymentSession() final { }
+ void cancelPaymentSession() final { }
+ void paymentCoordinatorDestroyed() final;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(APPLE_PAY)