WebKit Bugzilla
Attachment 348106 Details for
Bug 188954
: [Apple Pay] PaymentRequest.show() should reject when an unsupported ApplePayRequest version is specified
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188954-20180826175511.patch (text/plain), 6.66 KB, created by
Andy Estes
on 2018-08-26 17:55:12 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2018-08-26 17:55:12 PDT
Size:
6.66 KB
patch
obsolete
>Subversion Revision: 235338 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 302c942a8cb7e43d5dfc46d5cbb1895e79b4b176..92df4f7ac2d6554b5f137cca52600283cd32a6cf 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,26 @@ >+2018-08-26 Andy Estes <aestes@apple.com> >+ >+ [Apple Pay] PaymentRequest.show() should reject when an unsupported ApplePayRequest version is specified >+ https://bugs.webkit.org/show_bug.cgi?id=188954 >+ >+ Reviewed by Darin Adler. >+ >+ In Apple Pay JS, calling the ApplePaySession constructor with an unsupported version results >+ in an exception being thrown. We need to do something similar for Payment Request. >+ >+ This patch moves the logic for validating the version from ApplePaySession to a common >+ routine in ApplePayRequestBase that both APIs call to convert requests into a common format. >+ >+ In Apple Pay JS, an exception will still be thrown when constructing an ApplePaySession. In >+ Payment Request, the promise returned by show() will be rejected. >+ >+ Added test cases to http/tests/ssl/applepay/PaymentRequest.https.html. >+ >+ * Modules/applepay/ApplePayRequestBase.cpp: >+ (WebCore::convertAndValidate): >+ * Modules/applepay/ApplePaySession.cpp: >+ (WebCore::ApplePaySession::create): >+ > 2018-08-24 Ryosuke Niwa <rniwa@webkit.org> > > Click event from click() is not composed >diff --git a/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp b/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp >index 0ec8d12242d1be1c30af7ac186a04c470084126c..198ece7cdda8cda6fce1d161fe3ff0a44661d440 100644 >--- a/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp >+++ b/Source/WebCore/Modules/applepay/ApplePayRequestBase.cpp >@@ -29,6 +29,7 @@ > #if ENABLE(APPLE_PAY) > > #include "PaymentCoordinator.h" >+#include <wtf/text/StringConcatenateNumbers.h> > > namespace WebCore { > >@@ -51,6 +52,9 @@ static ExceptionOr<Vector<String>> convertAndValidate(unsigned version, const Ve > > ExceptionOr<ApplePaySessionPaymentRequest> convertAndValidate(unsigned version, ApplePayRequestBase& request, const PaymentCoordinator& paymentCoordinator) > { >+ if (!version || !paymentCoordinator.supportsVersion(version)) >+ return Exception { InvalidAccessError, makeString("\"", version, "\" is not a supported version.") }; >+ > ApplePaySessionPaymentRequest result; > result.setVersion(version); > result.setCountryCode(request.countryCode); >diff --git a/Source/WebCore/Modules/applepay/ApplePaySession.cpp b/Source/WebCore/Modules/applepay/ApplePaySession.cpp >index 46dfac959b6ca9a7435b642227d527b8aa5139b3..bbb7c8b01653eec108eee1cc7b304545542c2345 100644 >--- a/Source/WebCore/Modules/applepay/ApplePaySession.cpp >+++ b/Source/WebCore/Modules/applepay/ApplePaySession.cpp >@@ -406,12 +406,7 @@ ExceptionOr<Ref<ApplePaySession>> ApplePaySession::create(Document& document, un > if (!document.page()) > return Exception { InvalidAccessError, "Frame is detached" }; > >- auto& paymentCoordinator = document.page()->paymentCoordinator(); >- >- if (!version || !paymentCoordinator.supportsVersion(version)) >- return Exception { InvalidAccessError, makeString("\"" + String::number(version), "\" is not a supported version.") }; >- >- auto convertedPaymentRequest = convertAndValidate(version, WTFMove(paymentRequest), paymentCoordinator); >+ auto convertedPaymentRequest = convertAndValidate(version, WTFMove(paymentRequest), document.page()->paymentCoordinator()); > if (convertedPaymentRequest.hasException()) > return convertedPaymentRequest.releaseException(); > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index ff519068a297bd58d180b0f70dd1dda9c5b69c89..4262502de35dcd33721d460e9127718f20e70f47 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2018-08-26 Andy Estes <aestes@apple.com> >+ >+ [Apple Pay] PaymentRequest.show() should reject when an unsupported ApplePayRequest version is specified >+ https://bugs.webkit.org/show_bug.cgi?id=188954 >+ >+ Reviewed by Darin Adler. >+ >+ * http/tests/ssl/applepay/PaymentRequest.https-expected.txt: >+ * http/tests/ssl/applepay/PaymentRequest.https.html: >+ > 2018-08-24 Jer Noble <jer.noble@apple.com> > > Using Touch Bar to scrub video on Youtube results in video playback freeze >diff --git a/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt b/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt >index 91feb2b4e4c9d92be39c19806444620c3fafad6f..f26c86851a03d3a2cf49d78dd926674e7f6e6fb4 100644 >--- a/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt >+++ b/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https-expected.txt >@@ -8,6 +8,13 @@ Testing PaymentRequest > PASS new PaymentRequest(null, null) threw exception TypeError: Value is not a sequence. > PASS new PaymentRequest([validPaymentMethod()], validPaymentDetails()) did not throw exception. > >+Testing ApplePayRequest.version >+ >+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.version = 0; >+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise with InvalidAccessError: "0" is not a supported version.. >+SETUP: paymentMethod = validPaymentMethod(); paymentMethod.data.version = 1000; >+PASS request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show() rejected promise with InvalidAccessError: "1000" is not a supported version.. >+ > Testing ApplePayRequest.countryCode > > SETUP: paymentMethod = validPaymentMethod(); delete paymentMethod.data.countryCode; >diff --git a/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html b/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html >index cd2ab984e1765db7a0935a12b080c96db105bf5b..94825233a120d445bad58e84a5bc05c858f5628b 100644 >--- a/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html >+++ b/LayoutTests/http/tests/ssl/applepay/PaymentRequest.https.html >@@ -55,6 +55,12 @@ async function go() { > shouldThrow("new PaymentRequest(null, null)") > shouldNotThrow("new PaymentRequest([validPaymentMethod()], validPaymentDetails())") > debug("") >+ >+ debug("Testing ApplePayRequest.version") >+ debug("") >+ await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.version = 0;", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()") >+ await logAndShouldReject("paymentMethod = validPaymentMethod(); paymentMethod.data.version = 1000;", "request = new PaymentRequest([paymentMethod], validPaymentDetails()); request.show()") >+ debug("") > > debug("Testing ApplePayRequest.countryCode") > debug("")
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188954
:
348098
| 348106