From aab330d18c86776b960a09ec324e1d1d5a008187 Mon Sep 17 00:00:00 2001 From: "aestes@apple.com" Date: Fri, 9 Feb 2018 19:07:28 +0000 Subject: [PATCH] [Payment Request] Crash in PaymentRequest::canMakePayment() when Apple Pay payment method data is missing required fields https://bugs.webkit.org/show_bug.cgi?id=182631 Reviewed by Mark Lam. Source/WebCore: PaymentRequest::canMakePayment() needs to parse each payment method's serialized data to determine if it is a supported payment method. If parsing fails by raising an exception, we intend to skip over that payment method and try the next one. If all payment method data fail to parse, we resolve the returned promise with false. At no point do we intend to propagate the parsing exception up to the calling script, however. Even though we intend to swallow any exceptions from parsing, we failed to clear the JavaScript VM's exception state. The next time WebCore tries to execute JavaScript, a release assertion is raised due to seeing an unexpected exception in the VM. Fix this by using a CatchScope in PaymentRequest::canMakePayment(), and calling CatchScope::clearException() in the places we intend to swallow exceptions. Added a test case to http/tests/paymentrequest/payment-request-canmakepayment-method.https.html. * Modules/paymentrequest/PaymentRequest.cpp: (WebCore::PaymentRequest::canMakePayment): LayoutTests: * http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt: * http/tests/paymentrequest/payment-request-canmakepayment-method.https.html: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228331 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 +++++++++ ...equest-canmakepayment-method.https-expected.txt | 1 + ...ayment-request-canmakepayment-method.https.html | 12 ++++++++++- Source/WebCore/ChangeLog | 25 ++++++++++++++++++++++ .../Modules/paymentrequest/PaymentRequest.cpp | 11 ++++++++-- 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 97c96a0..979db65 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2018-02-09 Andy Estes + + [Payment Request] Crash in PaymentRequest::canMakePayment() when Apple Pay payment method data is missing required fields + https://bugs.webkit.org/show_bug.cgi?id=182631 + + Reviewed by Mark Lam. + + * http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt: + * http/tests/paymentrequest/payment-request-canmakepayment-method.https.html: + 2018-02-09 Ryan Haddad Update TestExpectations for fast/forms/textarea/textarea-state-restore.html diff --git a/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt b/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt index 9001416..df6fb85 100644 --- a/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt +++ b/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https-expected.txt @@ -3,6 +3,7 @@ PASS If request.[[state]] is "created", then return a promise that resolves to t PASS If request.[[state]] is "interactive", then return a promise rejected with an "InvalidStateError" DOMException. PASS If request.[[state]] is "closed", then return a promise rejected with an "InvalidStateError" DOMException. PASS If payment method identifier and serialized parts are supported, resolve promise with true. +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. diff --git a/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html b/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html index 74791c4..6f4e887 100644 --- a/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html +++ b/LayoutTests/http/tests/paymentrequest/payment-request-canmakepayment-method.https.html @@ -10,7 +10,7 @@