Changeset 237594 in webkit
- Timestamp:
- Oct 30, 2018, 11:12:21 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r237592 r237594 1 2018-10-30 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] PaymentRequest.canMakePayment() should resolve to true whenever Apple Pay is available 4 https://bugs.webkit.org/show_bug.cgi?id=191039 5 6 Reviewed by Megan Gardner. 7 8 * http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt: 9 * http/tests/paymentrequest/payment-request-canmakepayment-method.https.html: 10 1 11 2018-10-30 Dawei Fenton <realdawei@apple.com> 2 12 -
trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt
r228331 r237594 7 7 PASS If payment method identifier is unknown, resolve promise with false. 8 8 PASS Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException. 9 PASS Return a promise that resolves to true when Apple Pay is available, even if there isn't an active card. 9 10 -
trunk/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html
r228331 r237594 10 10 <script src="/resources/testharness.js"></script> 11 11 <script src="/resources/testharnessreport.js"></script> 12 <body> 12 13 <script> 13 14 const applePay = Object.freeze({ … … 183 184 } 184 185 }, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`); 186 187 promise_test(async t => { 188 internals.mockPaymentCoordinator.setCanMakePaymentsWithActiveCard(false); 189 const request = new PaymentRequest(defaultMethods, defaultDetails); 190 assert_true( 191 await request.canMakePayment(), 192 `canMakePaymentPromise should be true` 193 ); 194 internals.mockPaymentCoordinator.setCanMakePaymentsWithActiveCard(true); 195 }, `Return a promise that resolves to true when Apple Pay is available, even if there isn't an active card.`); 185 196 </script> -
trunk/Source/WebCore/ChangeLog
r237591 r237594 1 2018-10-30 Andy Estes <aestes@apple.com> 2 3 [Apple Pay] PaymentRequest.canMakePayment() should resolve to true whenever Apple Pay is available 4 https://bugs.webkit.org/show_bug.cgi?id=191039 5 6 Reviewed by Megan Gardner. 7 8 During a recent Web Payments WG F2F, we decided that canMakePayment() should return true 9 whenever the user agent supports one or more of the specified payment methods, even if those 10 payment methods do not have active instruments. 11 12 Change WebKit's implementation of canMakePayment() for Apple Pay to resolve with the value 13 of ApplePaySession.canMakePayments() rather than ApplePaySession.canMakePaymentsWithActiveCard(). 14 15 Added a test case to http/tests/paymentrequest/payment-request-canmakepayment-method.https.html. 16 17 * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp: 18 (WebCore::ApplePayPaymentHandler::canMakePayment): 19 (WebCore::shouldDiscloseApplePayCapability): Deleted. 20 * testing/MockPaymentCoordinator.cpp: 21 (WebCore::MockPaymentCoordinator::canMakePayments): 22 (WebCore::MockPaymentCoordinator::canMakePaymentsWithActiveCard): 23 * testing/MockPaymentCoordinator.h: 24 * testing/MockPaymentCoordinator.idl: 25 1 26 2018-10-30 Sihui Liu <sihui_liu@apple.com> 2 27 -
trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
r237521 r237594 226 226 } 227 227 228 static bool shouldDiscloseApplePayCapability(Document& document)229 {230 auto* page = document.page();231 if (!page || page->usesEphemeralSession())232 return false;233 234 return document.settings().applePayCapabilityDisclosureAllowed();235 }236 237 228 void ApplePayPaymentHandler::canMakePayment(Function<void(bool)>&& completionHandler) 238 229 { 239 if (!shouldDiscloseApplePayCapability(document())) { 240 completionHandler(paymentCoordinator().canMakePayments()); 241 return; 242 } 243 244 paymentCoordinator().canMakePaymentsWithActiveCard(m_applePayRequest->merchantIdentifier, document().domain(), WTFMove(completionHandler)); 245 } 246 230 completionHandler(paymentCoordinator().canMakePayments()); 231 } 232 247 233 ExceptionOr<Vector<ApplePaySessionPaymentRequest::ShippingMethod>> ApplePayPaymentHandler::computeShippingMethods() 248 234 { -
trunk/Source/WebCore/testing/MockPaymentCoordinator.cpp
r237238 r237594 78 78 bool MockPaymentCoordinator::canMakePayments() 79 79 { 80 return true;80 return m_canMakePayments; 81 81 } 82 82 83 83 void MockPaymentCoordinator::canMakePaymentsWithActiveCard(const String&, const String&, Function<void(bool)>&& completionHandler) 84 84 { 85 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler) ] {86 completionHandler( true);85 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), canMakePaymentsWithActiveCard = m_canMakePaymentsWithActiveCard] { 86 completionHandler(canMakePaymentsWithActiveCard); 87 87 }); 88 88 } -
trunk/Source/WebCore/testing/MockPaymentCoordinator.h
r237142 r237594 45 45 explicit MockPaymentCoordinator(Page&); 46 46 47 void setCanMakePayments(bool canMakePayments) { m_canMakePayments = canMakePayments; } 48 void setCanMakePaymentsWithActiveCard(bool canMakePaymentsWithActiveCard) { m_canMakePaymentsWithActiveCard = canMakePaymentsWithActiveCard; } 47 49 void setShippingAddress(MockPaymentAddress&& shippingAddress) { m_shippingAddress = WTFMove(shippingAddress); } 48 50 void changeShippingOption(String&& shippingOption); … … 78 80 79 81 Page& m_page; 82 bool m_canMakePayments { true }; 83 bool m_canMakePaymentsWithActiveCard { true }; 80 84 ApplePayPaymentContact m_shippingAddress; 81 85 ApplePayLineItem m_total; -
trunk/Source/WebCore/testing/MockPaymentCoordinator.idl
r237142 r237594 28 28 NoInterfaceObject, 29 29 ] interface MockPaymentCoordinator { 30 void setCanMakePayments(boolean canMakePayments); 31 void setCanMakePaymentsWithActiveCard(boolean canMakePaymentsWithActiveCard); 30 32 void setShippingAddress(MockPaymentAddress shippingAddress); 31 33 void changeShippingOption(DOMString shippingOption);
Note:
See TracChangeset
for help on using the changeset viewer.