[Payment Request] Implement PaymentRequest.canMakePayment()
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 00:37:49 +0000 (00:37 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Oct 2017 00:37:49 +0000 (00:37 +0000)
commitce2ab0ba05de44ef893d26770b6b9c51910a8d93
tree38a987ebd76838db0fefade5d89e1e789c34edaf
parent2ad84e64798ad13fc40720ddf015f2aecf79cd13
[Payment Request] Implement PaymentRequest.canMakePayment()
https://bugs.webkit.org/show_bug.cgi?id=178048

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/payment-request/payment-request-canmakepayment-method.https-expected.txt: Removed.

Source/WebCore:

Test: http/tests/paymentrequest/payment-request-canmakepayment-method.https.html

* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::convertData): Moved
ApplePayRequest-to-ApplePaySessionPaymentRequest conversion from here to show().
(WebCore::ApplePayPaymentHandler::show): Returned an exception if
ApplePaySessionPaymentRequest conversion fails.
(WebCore::shouldDiscloseApplePayCapability): Checked if we are in an ephimeral session or if
Settings::applePayCapabilityDisclosureAllowed() is false.
(WebCore::ApplePayPaymentHandler::canMakePayment): Called
PaymentCoordinator::canMakePayments() or PaymentCoordinator::canMakePaymentsWithActiveCard()
depending on shouldDiscloseApplePayCapability().
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/applepay/paymentrequest/ApplePayRequest.h:
* Modules/applepay/paymentrequest/ApplePayRequest.idl: Defined merchantIdentifier.
* Modules/paymentrequest/PaymentHandler.h:
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::parse): Moved JSON-parsing to here from show().
(WebCore::PaymentRequest::show): Returned the exception from PaymentHandler::show().
(WebCore::PaymentRequest::canMakePayment): For each payment method, try to create a
PaymentHandler.
For the first valid PaymentHandler, call canMakePayment() and pass a lambda that resolves
the promise.
* Modules/paymentrequest/PaymentRequest.h:
* Modules/paymentrequest/PaymentRequest.idl: Added CallWith=Document annotations to show()
and canMakePayment().

LayoutTests:

* http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt: Added.
* http/tests/paymentrequest/payment-request-canmakepayment-method.https.html: Added.
* http/tests/ssl/applepay/PaymentRequest.https.html:
* platform/ios-wk2/TestExpectations:
* platform/mac-wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223160 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/paymentrequest/payment-request-abort-method.https.html
LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html [new file with mode: 0644]
LayoutTests/http/tests/paymentrequest/payment-request-show-method.https.html
LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-canmakepayment-method.https-expected.txt [deleted file]
LayoutTests/platform/ios-wk2/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h
Source/WebCore/Modules/applepay/paymentrequest/ApplePayRequest.h
Source/WebCore/Modules/applepay/paymentrequest/ApplePayRequest.idl
Source/WebCore/Modules/paymentrequest/PaymentHandler.h
Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp
Source/WebCore/Modules/paymentrequest/PaymentRequest.h
Source/WebCore/Modules/paymentrequest/PaymentRequest.idl