- Revision
- 237594
- Author
- [email protected]
- Date
- 2018-10-30 11:12:21 -0700 (Tue, 30 Oct 2018)
Log Message
[Apple Pay] PaymentRequest.canMakePayment() should resolve to true whenever Apple Pay is available
https://bugs.webkit.org/show_bug.cgi?id=191039
Reviewed by Megan Gardner.
Source/WebCore:
During a recent Web Payments WG F2F, we decided that canMakePayment() should return true
whenever the user agent supports one or more of the specified payment methods, even if those
payment methods do not have active instruments.
Change WebKit's implementation of canMakePayment() for Apple Pay to resolve with the value
of ApplePaySession.canMakePayments() rather than ApplePaySession.canMakePaymentsWithActiveCard().
Added a test case to http/tests/paymentrequest/payment-request-canmakepayment-method.https.html.
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::canMakePayment):
(WebCore::shouldDiscloseApplePayCapability): Deleted.
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::canMakePayments):
(WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard):
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.idl:
LayoutTests:
* http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt:
* http/tests/paymentrequest/payment-request-canmakepayment-method.https.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (237593 => 237594)
--- trunk/LayoutTests/ChangeLog 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/LayoutTests/ChangeLog 2018-10-30 18:12:21 UTC (rev 237594)
@@ -1,3 +1,13 @@
+2018-10-30 Andy Estes <[email protected]>
+
+ [Apple Pay] PaymentRequest.canMakePayment() should resolve to true whenever Apple Pay is available
+ https://bugs.webkit.org/show_bug.cgi?id=191039
+
+ Reviewed by Megan Gardner.
+
+ * http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt:
+ * http/tests/paymentrequest/payment-request-canmakepayment-method.https.html:
+
2018-10-30 Dawei Fenton <[email protected]>
[ Mojave Debug ] Layout Test http/tests/workers/service/self_registration.html is flaky
Modified: trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt (237593 => 237594)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt 2018-10-30 18:12:21 UTC (rev 237594)
@@ -6,4 +6,5 @@
PASS If a payment method identifier is supported but its serialized parts are not, resolve promise with false.
PASS If payment method identifier is unknown, resolve promise with false.
PASS Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.
+PASS Return a promise that resolves to true when Apple Pay is available, even if there isn't an active card.
Modified: trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html (237593 => 237594)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html 2018-10-30 18:12:21 UTC (rev 237594)
@@ -9,6 +9,7 @@
<script src=""
<script src=""
<script src=""
+<body>
<script>
const applePay = Object.freeze({
supportedMethods: "https://apple.com/apple-pay",
@@ -182,4 +183,14 @@
}
}
}, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`);
+
+promise_test(async t => {
+ internals.mockPaymentCoordinator.setCanMakePaymentsWithActiveCard(false);
+ const request = new PaymentRequest(defaultMethods, defaultDetails);
+ assert_true(
+ await request.canMakePayment(),
+ `canMakePaymentPromise should be true`
+ );
+ internals.mockPaymentCoordinator.setCanMakePaymentsWithActiveCard(true);
+}, `Return a promise that resolves to true when Apple Pay is available, even if there isn't an active card.`);
</script>
Modified: trunk/Source/WebCore/ChangeLog (237593 => 237594)
--- trunk/Source/WebCore/ChangeLog 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/Source/WebCore/ChangeLog 2018-10-30 18:12:21 UTC (rev 237594)
@@ -1,3 +1,28 @@
+2018-10-30 Andy Estes <[email protected]>
+
+ [Apple Pay] PaymentRequest.canMakePayment() should resolve to true whenever Apple Pay is available
+ https://bugs.webkit.org/show_bug.cgi?id=191039
+
+ Reviewed by Megan Gardner.
+
+ During a recent Web Payments WG F2F, we decided that canMakePayment() should return true
+ whenever the user agent supports one or more of the specified payment methods, even if those
+ payment methods do not have active instruments.
+
+ Change WebKit's implementation of canMakePayment() for Apple Pay to resolve with the value
+ of ApplePaySession.canMakePayments() rather than ApplePaySession.canMakePaymentsWithActiveCard().
+
+ Added a test case to http/tests/paymentrequest/payment-request-canmakepayment-method.https.html.
+
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+ (WebCore::ApplePayPaymentHandler::canMakePayment):
+ (WebCore::shouldDiscloseApplePayCapability): Deleted.
+ * testing/MockPaymentCoordinator.cpp:
+ (WebCore::MockPaymentCoordinator::canMakePayments):
+ (WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard):
+ * testing/MockPaymentCoordinator.h:
+ * testing/MockPaymentCoordinator.idl:
+
2018-10-30 Sihui Liu <[email protected]>
Add a deprecation warning to console for Web SQL
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (237593 => 237594)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2018-10-30 18:12:21 UTC (rev 237594)
@@ -225,25 +225,11 @@
paymentCoordinator().abortPaymentSession();
}
-static bool shouldDiscloseApplePayCapability(Document& document)
+void ApplePayPaymentHandler::canMakePayment(Function<void(bool)>&& completionHandler)
{
- auto* page = document.page();
- if (!page || page->usesEphemeralSession())
- return false;
-
- return document.settings().applePayCapabilityDisclosureAllowed();
+ completionHandler(paymentCoordinator().canMakePayments());
}
-void ApplePayPaymentHandler::canMakePayment(Function<void(bool)>&& completionHandler)
-{
- if (!shouldDiscloseApplePayCapability(document())) {
- completionHandler(paymentCoordinator().canMakePayments());
- return;
- }
-
- paymentCoordinator().canMakePaymentsWithActiveCard(m_applePayRequest->merchantIdentifier, document().domain(), WTFMove(completionHandler));
-}
-
ExceptionOr<Vector<ApplePaySessionPaymentRequest::ShippingMethod>> ApplePayPaymentHandler::computeShippingMethods()
{
auto& details = m_paymentRequest->paymentDetails();
Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp (237593 => 237594)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp 2018-10-30 18:12:21 UTC (rev 237594)
@@ -77,13 +77,13 @@
bool MockPaymentCoordinator::canMakePayments()
{
- return true;
+ return m_canMakePayments;
}
void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, Function<void(bool)>&& completionHandler)
{
- RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler)] {
- completionHandler(true);
+ RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), canMakePaymentsWithActiveCard = m_canMakePaymentsWithActiveCard] {
+ completionHandler(canMakePaymentsWithActiveCard);
});
}
Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.h (237593 => 237594)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.h 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.h 2018-10-30 18:12:21 UTC (rev 237594)
@@ -44,6 +44,8 @@
public:
explicit MockPaymentCoordinator(Page&);
+ void setCanMakePayments(bool canMakePayments) { m_canMakePayments = canMakePayments; }
+ void setCanMakePaymentsWithActiveCard(bool canMakePaymentsWithActiveCard) { m_canMakePaymentsWithActiveCard = canMakePaymentsWithActiveCard; }
void setShippingAddress(MockPaymentAddress&& shippingAddress) { m_shippingAddress = WTFMove(shippingAddress); }
void changeShippingOption(String&& shippingOption);
void changePaymentMethod(ApplePayPaymentMethod&&);
@@ -77,6 +79,8 @@
void updateTotalAndLineItems(const ApplePaySessionPaymentRequest::TotalAndLineItems&);
Page& m_page;
+ bool m_canMakePayments { true };
+ bool m_canMakePaymentsWithActiveCard { true };
ApplePayPaymentContact m_shippingAddress;
ApplePayLineItem m_total;
Vector<ApplePayLineItem> m_lineItems;
Modified: trunk/Source/WebCore/testing/MockPaymentCoordinator.idl (237593 => 237594)
--- trunk/Source/WebCore/testing/MockPaymentCoordinator.idl 2018-10-30 17:48:15 UTC (rev 237593)
+++ trunk/Source/WebCore/testing/MockPaymentCoordinator.idl 2018-10-30 18:12:21 UTC (rev 237594)
@@ -27,6 +27,8 @@
Conditional=APPLE_PAY,
NoInterfaceObject,
] interface MockPaymentCoordinator {
+ void setCanMakePayments(boolean canMakePayments);
+ void setCanMakePaymentsWithActiveCard(boolean canMakePaymentsWithActiveCard);
void setShippingAddress(MockPaymentAddress shippingAddress);
void changeShippingOption(DOMString shippingOption);
void changePaymentMethod(ApplePayPaymentMethod paymentMethod);