WebKit Bugzilla
Attachment 348156 Details for
Bug 188985
: [Payment Request] Update payment-request web platform tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-188985-20180827100416.patch (text/plain), 53.83 KB, created by
Andy Estes
on 2018-08-27 10:04:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andy Estes
Created:
2018-08-27 10:04:17 PDT
Size:
53.83 KB
patch
obsolete
>Subversion Revision: 235367 >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index cd12c8d77fabcb9d392c865c33ce6e3cac11d54c..add8a60b8f4fc03f826a58d06a02146343cbcca8 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2018-08-27 Andy Estes <aestes@apple.com> >+ >+ [Payment Request] Update payment-request web platform tests >+ https://bugs.webkit.org/show_bug.cgi?id=188985 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * platform/mac-wk2/TestExpectations: >+ > 2018-08-27 Per Arne Vollan <pvollan@apple.com> > > Layout Test fast/events/dblclick-event-getModifierState.html is failing >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index ed33a5fd8ceda1ff94d34ace8ec4a5e4b233eee0..5fb0adc5769840e14b0147bcfbd1ac17c6d9a294 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,34 @@ >+2018-08-27 Andy Estes <aestes@apple.com> >+ >+ [Payment Request] Update payment-request web platform tests >+ https://bugs.webkit.org/show_bug.cgi?id=188985 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/payment-request/PaymentAddress/w3c-import.log: >+ * web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https-expected.txt: Added. >+ * web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https.html: Added. >+ * web-platform-tests/payment-request/PaymentCurrencyAmount/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log. >+ * web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt: Added. >+ * web-platform-tests/payment-request/PaymentItem/type_member.https.html: Added. >+ * web-platform-tests/payment-request/PaymentItem/w3c-import.log: Copied from LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log. >+ * web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log: >+ * web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html: Added. >+ * web-platform-tests/payment-request/payment-request-insecure.http-expected.txt: Added. >+ * web-platform-tests/payment-request/payment-request-insecure.http.html: Added. >+ * web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt: Added. >+ * web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html: Added. >+ * web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js: Added. >+ (test): >+ * web-platform-tests/payment-request/payment-request-show-method-manual.https.html: Added. >+ * web-platform-tests/payment-request/payment-response/w3c-import.log: >+ * web-platform-tests/payment-request/resources/w3c-import.log: >+ * web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html: Added. >+ * web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html: Added. >+ * web-platform-tests/payment-request/show-method-postmessage-iframe.html: Added. >+ * web-platform-tests/payment-request/show-method-postmessage-manual.https.html: Added. >+ * web-platform-tests/payment-request/w3c-import.log: >+ > 2018-08-27 Rob Buis <rbuis@igalia.com> > > XMLHTTPRequest.send for Document should have same Content-Type processing rules as String >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log >index 8ccdd3931bd37f3e1b45d53c2bfe2ccc832107df..4d9043c2812a09702a8fe37f0cba3d9cd3503833 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentAddress/w3c-import.log >@@ -1,7 +1,7 @@ > The tests in this directory were imported from the W3C repository. > Do NOT modify these tests directly in WebKit. > Instead, create a pull request on the WPT github: >- https://github.com/w3c/web-platform-tests >+ https://github.com/web-platform-tests/wpt > > Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..20783a79c1128e45fff5e0bd2dd1a67c5c96a6ba >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https-expected.txt >@@ -0,0 +1,15 @@ >+ >+FAIL Must throw if it encounters an unknown currencySystem assert_throws: function "() => { >+ const invalidAmount = { >+ ...validAmount, >+ currencySystem: "this will cause the TypeError" >+ } >+ const invalidDetails = { >+ total: { >+ label: "", >+ amount: invalidAmount, >+ }, >+ }; >+ const request = new PaymentRequest(validMethods, invalidDetails); >+ }" did not throw >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..c79fb0fadc56d528f9e78da0a719d00989e86bbe >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https.html >@@ -0,0 +1,39 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>Tests for PaymentCurrencyAmount's currencySystem</title> >+<link rel="help" href="https://www.w3.org/TR/payment-request/#dom-paymentcurrencyamount-currencysystem"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+test(() => { >+ const validAmount = { >+ value: "0", >+ currency: "USD", >+ currencySystem: "urn:iso:std:iso:4217", >+ } >+ const validMethods = [{ supportedMethods: "valid-method" }]; >+ const validDetails = { >+ total: { >+ label: "", >+ amount: validAmount, >+ }, >+ }; >+ // smoke test >+ const request = new PaymentRequest(validMethods, validDetails); >+ >+ // real test >+ assert_throws(new TypeError(), () => { >+ const invalidAmount = { >+ ...validAmount, >+ currencySystem: "this will cause the TypeError" >+ } >+ const invalidDetails = { >+ total: { >+ label: "", >+ amount: invalidAmount, >+ }, >+ }; >+ const request = new PaymentRequest(validMethods, invalidDetails); >+ }) >+}, "Must throw if it encounters an unknown currencySystem"); >+</script> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/w3c-import.log >new file mode 100644 >index 0000000000000000000000000000000000000000..887361b0218bd7b52d60e46aaaa118b6208e7040 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/w3c-import.log >@@ -0,0 +1,17 @@ >+The tests in this directory were imported from the W3C repository. >+Do NOT modify these tests directly in WebKit. >+Instead, create a pull request on the WPT github: >+ https://github.com/web-platform-tests/wpt >+ >+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport >+ >+Do NOT modify or remove this file. >+ >+------------------------------------------------------------------------ >+Properties requiring vendor prefixes: >+None >+Property values requiring vendor prefixes: >+None >+------------------------------------------------------------------------ >+List of files: >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentCurrencyAmount/currencySystem-member.https.html >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..e6b02017170325ef29703ae2427db5bcdc00925b >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https-expected.txt >@@ -0,0 +1,10 @@ >+ >+PASS Smoke test >+FAIL An invalid enum value for PaymentDetailsInit.total's type throws TypeError assert_throws: function "() => { >+ new PaymentRequest(validMethods, invalidDetails); >+ }" did not throw >+FAIL Invalid enum value for PaymentItem.type member throws a TypeError assert_throws: function "() => { >+ new PaymentRequest(validMethods, invalidDetails); >+ }" did not throw >+PASS Valid enum values for PaymentItem.type member does not throw >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..dc62a83f597a0b53c686689fb8f549130982242a >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html >@@ -0,0 +1,77 @@ >+<!doctype html> >+<meta charset="utf8"> >+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentitem-type"> >+<title> >+ PaymentItem type member >+</title> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+const validMethods = [ >+ { supportedMethods: "basic-card" }, >+ { supportedMethods: "https://apple.com/apple-pay" }, >+]; >+const validTotal = { >+ label: "Total", >+ amount: { >+ currency: "USD", >+ value: "5.00", >+ }, >+}; >+const validDisplayItem = { >+ label: "Item", >+ amount: { >+ currency: "USD", >+ value: "1.00", >+ }, >+}; >+const validDetails = { >+ total: validTotal, >+ displayItems: [validDisplayItem], >+}; >+ >+test(() => { >+ new PaymentRequest(validMethods, validDetails); >+}, "Smoke test"); >+ >+test(() => { >+ // Let's make an invalid DisplayItem for the total >+ const invalidTotal = Object.assign({}, validTotal, { >+ type: "this is not valid", >+ }); >+ const invalidDetails = Object.assign({}, validDetails, { >+ total: invalidTotal, >+ }); >+ assert_throws(new TypeError(), () => { >+ new PaymentRequest(validMethods, invalidDetails); >+ }); >+}, "An invalid enum value for PaymentDetailsInit.total's type throws TypeError"); >+ >+test(() => { >+ // Let's make an invalid DisplayItem to add to displayItems >+ const invalidDisplayItem = Object.assign({}, validDisplayItem, { >+ type: "this is not valid", >+ }); >+ const invalidDetails = Object.assign({}, validDetails, { >+ displayItems: [invalidDisplayItem, validDisplayItem], >+ }); >+ assert_throws(new TypeError(), () => { >+ new PaymentRequest(validMethods, invalidDetails); >+ }); >+}, "Invalid enum value for PaymentItem.type member throws a TypeError"); >+ >+test(() => { >+ // Let's make an invalid DisplayItem to add to displayItems >+ const taxDisplayItem = Object.assign({}, validDisplayItem, { type: "tax" }); >+ const taxTotal = Object.assign({}, validTotal, { type: "tax" }); >+ const validDetailsWithType = Object.assign({}, validDetails, { >+ total: taxTotal, >+ displayItems: [taxDisplayItem], >+ }); >+ try { >+ new PaymentRequest(validMethods, validDetailsWithType); >+ } catch (err) { >+ assert_unexpected(err.message); >+ } >+}, "Valid enum values for PaymentItem.type member does not throw"); >+</script> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/w3c-import.log >new file mode 100644 >index 0000000000000000000000000000000000000000..fc269594a740f67fc8d756a26562290286397e9b >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/w3c-import.log >@@ -0,0 +1,17 @@ >+The tests in this directory were imported from the W3C repository. >+Do NOT modify these tests directly in WebKit. >+Instead, create a pull request on the WPT github: >+ https://github.com/web-platform-tests/wpt >+ >+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport >+ >+Do NOT modify or remove this file. >+ >+------------------------------------------------------------------------ >+Properties requiring vendor prefixes: >+None >+Property values requiring vendor prefixes: >+None >+------------------------------------------------------------------------ >+List of files: >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/PaymentItem/type_member.https.html >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log >index 4f0acc0e4c3eefe82d4cedc62db8bc750f662253..632f466af7cbc9778ddc1aab3ca64dd4d57dd2cd 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/allowpaymentrequest/w3c-import.log >@@ -1,7 +1,7 @@ > The tests in this directory were imported from the W3C repository. > Do NOT modify these tests directly in WebKit. > Instead, create a pull request on the WPT github: >- https://github.com/w3c/web-platform-tests >+ https://github.com/web-platform-tests/wpt > > Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..c8e23aa3e6bd17bebb8707b858df0c378fa98605 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html >@@ -0,0 +1,92 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>Test for PaymentDetailsBase's shippingOptions member</title> >+<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentdetailsbase-shippingoptions"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+setup({ explicit_done: true, explicit_timeout: true }); >+const validMethods = Object.freeze([ >+ { supportedMethods: "basic-card" }, >+ { supportedMethods: "https://apple.com/pay" }, >+]); >+const validAmount = Object.freeze({ currency: "USD", value: "5.00" }); >+const validTotal = Object.freeze({ >+ label: "label", >+ amount: validAmount, >+}); >+const validDetails = Object.freeze({ total: validTotal }); >+ >+const validShippingOption1 = Object.freeze({ >+ id: "fail-if-selected-1", >+ label: "FAIL if selected 1", >+ amount: validAmount, >+ selected: true, >+}); >+ >+const validShippingOption2 = Object.freeze({ >+ id: "fail-if-selected-2", >+ label: "FAIL if selected 2", >+ amount: validAmount, >+ selected: false, >+}); >+ >+const validShippingOption3 = Object.freeze({ >+ id: "pass-if-selected", >+ label: "THIS MUST BE AUTOMATICALLY SELECTED", >+ amount: validAmount, >+ selected: true, >+}); >+ >+function testShippingOptionChanged(button) { >+ button.disabled = true; >+ promise_test(async t => { >+ const detailsWithShippingOptions = { >+ ...validDetails, >+ shippingOptions: [ >+ validShippingOption1, >+ validShippingOption2, >+ validShippingOption3, >+ ], >+ }; >+ const request = new PaymentRequest( >+ validMethods, >+ detailsWithShippingOptions, >+ { requestShipping: true } >+ ); >+ assert_equals( >+ request.shippingOption, >+ "pass-if-selected", >+ "Must be 'pass-if-selected', as the selected member is true" >+ ); >+ request.onshippingoptionchange = () => { >+ assert_unreached("onshippingoptionchange fired unexpectedly"); >+ }; >+ const response = await request.show(); >+ assert_equals(response.shippingOption, "pass-if-selected"); >+ response.complete(); >+ }, button.textContent.trim()); >+ done(); >+} >+</script> >+ >+<h2>PaymentRequest shippingOption attribute</h2> >+<p> >+ Click on each button in sequence from top to bottom without refreshing the page. >+ Each button will bring up the Payment Request UI window. >+</p> >+<p> >+ When the payment sheet is presented, hit pay. >+</p> >+<ol> >+ <li> >+ <button onclick="testShippingOptionChanged(this)"> >+ When default shipping option is pre-selected, must not fire onshippingoptionchange >+ and PaymentResponse must reflect the pre-selected option. >+ </button> >+ </li> >+</ol> >+<small> >+ If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a> >+ and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>. >+</small> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..9c35c876bffecea75e25ff30634878334af39124 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http-expected.txt >@@ -0,0 +1,3 @@ >+ >+FAIL PaymentRequest constructor must not be exposed in insecure context assert_false: expected false got true >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html >new file mode 100644 >index 0000000000000000000000000000000000000000..02122203d51eaff6c6639c9762b1495173bbf66e >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html >@@ -0,0 +1,13 @@ >+<!DOCTYPE html> >+<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> >+<meta charset="utf-8"> >+<title>Test for PaymentRequest Constructor (insecure)</title> >+<link rel="help" href="https://w3c.github.io/payment-request/#paymentrequest-interface"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+test(() => { >+ assert_false(isSecureContext); >+ assert_false("PaymentRequest" in window); >+}, "PaymentRequest constructor must not be exposed in insecure context"); >+</script> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..ef2fdc3821fa12c005a0699db0c7a44a17a22ab8 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker-expected.txt >@@ -0,0 +1,3 @@ >+ >+PASS PaymentRequest constructor must not be exposed in worker global scope >+ >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html >new file mode 100644 >index 0000000000000000000000000000000000000000..2382913528e693b3a5d56c660a45060980b548c3 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.html >@@ -0,0 +1 @@ >+<!-- This file is required for WebKit test infrastructure to run the templated test --> >\ No newline at end of file >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js >new file mode 100644 >index 0000000000000000000000000000000000000000..df20f801e9d664d96520e50856ac990ff2c7dacd >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js >@@ -0,0 +1,11 @@ >+importScripts("/resources/testharness.js"); >+ >+test(function() { >+ assert_true(isSecureContext); >+ assert_false('PaymentRequest' in self); >+ assert_false('PaymentRequestUpdateEvent' in self); >+ assert_false('PaymentResponse' in self); >+ assert_false('PaymentAddress' in self); >+}, "PaymentRequest constructor must not be exposed in worker global scope"); >+ >+done(); >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method-manual.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..fab78f43fd6d497a51f461937da0665aa8464784 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method-manual.https.html >@@ -0,0 +1,95 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>Test for PaymentRequest.show() method</title> >+<link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+"use strict"; >+setup({ >+ explicit_done: true, >+ explicit_timeout: true, >+}); >+const basicCard = Object.freeze({ supportedMethods: "basic-card" }); >+const defaultMethods = Object.freeze([basicCard]); >+const defaultDetails = Object.freeze({ >+ total: { >+ label: "Total", >+ amount: { >+ currency: "USD", >+ value: "1.00", >+ }, >+ }, >+}); >+ >+test(() => { >+ try { >+ new PaymentRequest(defaultMethods, defaultDetails); >+ } catch (err) { >+ done(); >+ throw err; >+ } >+}, "Must be possible to construct a payment request"); >+ >+function manualTest1(button){ >+ button.disabled = true; >+ promise_test(async t => { >+ const request = new PaymentRequest(defaultMethods, defaultDetails); >+ const acceptPromise = request.show(); // Sets state to "interactive" >+ await promise_rejects(t, "InvalidStateError", request.show()); >+ await request.abort(); >+ await promise_rejects(t, "AbortError", acceptPromise); >+ }, button.textContent.trim()); >+} >+ >+function manualTest2(button){ >+ button.disabled = true; >+ promise_test(async t => { >+ const request1 = new PaymentRequest(defaultMethods, defaultDetails); >+ const request2 = new PaymentRequest(defaultMethods, defaultDetails); >+ const acceptPromise1 = request1.show(); >+ const acceptPromise2 = request2.show(); >+ await promise_rejects(t, "AbortError", acceptPromise2); >+ await request1.abort(); >+ await promise_rejects(t, "AbortError", acceptPromise1); >+ }, button.textContent.trim()); >+} >+ >+function manualTest3(button){ >+ button.disabled = true; >+ promise_test(async t => { >+ const request = new PaymentRequest( >+ [{ supportedMethods: "this-is-not-supported" }], >+ defaultDetails); >+ const acceptPromise = request.show(); >+ await promise_rejects(t, "NotSupportedError", acceptPromise); >+ }, button.textContent.trim()); >+ done(); >+} >+</script> >+ >+<h2>Test for PaymentRequest.show() method</h2> >+<p> >+ Click on each button in sequence from top to bottom without refreshing the page. >+</p> >+<ol> >+ <li> >+ <button onclick="manualTest1(this)"> >+ Throws if the promise [[state]] is not "created" >+ </button> >+ </li> >+ <li> >+ <button onclick="manualTest2(this)"> >+ If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. >+ </button> >+ </li> >+ <li> >+ <button onclick="manualTest3(this)"> >+ If payment method consultation produces no supported method of payment, then return a promise rejected with a "NotSupportedError" DOMException. >+ </button> >+ </li> >+</ol> >+<small> >+ If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a> >+ and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>. >+</small> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/w3c-import.log >index 5125feb146b6187fb2538980c4c606c9387d3baa..b64ca22a1d51d0e9890dbf4fe920d9bfe42ceb18 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/w3c-import.log >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-response/w3c-import.log >@@ -1,7 +1,7 @@ > The tests in this directory were imported from the W3C repository. > Do NOT modify these tests directly in WebKit. > Instead, create a pull request on the WPT github: >- https://github.com/w3c/web-platform-tests >+ https://github.com/web-platform-tests/wpt > > Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/resources/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/resources/w3c-import.log >index 3d11dd1ada2a1ceabacb70b335d5c21f4ed3c793..149fb58cd24c7505f908d515f3a6404b3fa45063 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/payment-request/resources/w3c-import.log >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/resources/w3c-import.log >@@ -1,7 +1,7 @@ > The tests in this directory were imported from the W3C repository. > Do NOT modify these tests directly in WebKit. > Instead, create a pull request on the WPT github: >- https://github.com/w3c/web-platform-tests >+ https://github.com/web-platform-tests/wpt > > Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..ab89d7ec413549eb5715bab435292653291182ce >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html >@@ -0,0 +1,281 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>Test for PaymentRequest.show(optional detailsPromise) method</title> >+<link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+ // See function testBadUpdate() for test details! >+ setup({ >+ allow_uncaught_exception: true, >+ explicit_done: true, >+ explicit_timeout: true, >+ }); >+ >+ // == TEST DATA === >+ // PaymentMethod >+ const validMethod = Object.freeze({ >+ supportedMethods: "valid-but-wont-ever-match", >+ }); >+ >+ const validMethodBasicCard = Object.freeze({ >+ supportedMethods: "basic-card", >+ }); >+ >+ const validMethodApplePay = Object.freeze({ >+ supportedMethods: "https://apple.com/pay", >+ }); >+ >+ // Methods >+ const validMethods = Object.freeze([ >+ validMethodBasicCard, >+ validMethod, >+ validMethodApplePay, >+ ]); >+ >+ // Amounts >+ const validAmount = Object.freeze({ >+ currency: "USD", >+ value: "1.00", >+ }); >+ >+ const invalidAmount = Object.freeze({ >+ currency: "¡INVALID!", >+ value: "A1.0", >+ }); >+ >+ const negativeAmount = Object.freeze({ >+ currency: "USD", >+ value: "-1.00", >+ }); >+ >+ // Totals >+ const validTotal = Object.freeze({ >+ label: "Valid Total", >+ amount: validAmount, >+ }); >+ >+ const invalidTotal = Object.freeze({ >+ label: "Invalid Total", >+ amount: invalidAmount, >+ }); >+ >+ const invalidNegativeTotal = Object.freeze({ >+ label: "Invalid negative total", >+ amount: negativeAmount, >+ }); >+ >+ // PaymentDetailsInit >+ const validDetails = Object.freeze({ >+ total: validTotal, >+ }); >+ >+ const invalidDetailsNegativeTotal = Object.freeze({ >+ total: invalidNegativeTotal, >+ }); >+ >+ // PaymentOptions >+ const validOptions = Object.freeze({ >+ requestShipping: true, >+ }); >+ >+ // PaymentItem >+ const validPaymentItem = Object.freeze({ >+ amount: validAmount, >+ label: "Valid payment item", >+ }); >+ >+ const invalidPaymentItem = Object.freeze({ >+ amount: invalidAmount, >+ label: "Invalid payment item", >+ }); >+ >+ // PaymentItem >+ const validPaymentItems = Object.freeze([validPaymentItem]); >+ const invalidPaymentItems = Object.freeze([invalidPaymentItem]); >+ >+ // PaymentShippingOption >+ const invalidShippingOption = Object.freeze({ >+ id: "abc", >+ label: "Invalid shipping option", >+ amount: invalidAmount, >+ selected: true, >+ }); >+ >+ // PaymentShippingOptions >+ const validShippingOption = Object.freeze({ >+ id: "abc", >+ label: "valid shipping option", >+ amount: validAmount, >+ }); >+ >+ const validShippingOptions = Object.freeze([validShippingOption]); >+ const invalidShippingOptions = Object.freeze([invalidShippingOption]); >+ >+ // PaymentDetailsModifier >+ const validModifier = Object.freeze({ >+ additionalDisplayItems: validPaymentItems, >+ supportedMethods: "valid-but-wont-ever-match", >+ total: validTotal, >+ }); >+ >+ const modifierWithInvalidDisplayItems = Object.freeze({ >+ additionalDisplayItems: invalidPaymentItems, >+ supportedMethods: "basic-card", >+ total: validTotal, >+ }); >+ >+ const modifierWithValidDisplayItems = Object.freeze({ >+ additionalDisplayItems: validPaymentItems, >+ supportedMethods: "basic-card", >+ total: validTotal, >+ }); >+ >+ const modifierWithInvalidTotal = Object.freeze({ >+ additionalDisplayItems: validPaymentItems, >+ supportedMethods: "basic-card", >+ total: invalidTotal, >+ }); >+ >+ const recursiveData = {}; >+ recursiveData.foo = recursiveData; >+ Object.freeze(recursiveData); >+ >+ const modifierWithRecursiveData = Object.freeze({ >+ supportedMethods: validMethodBasicCard, >+ total: validTotal, >+ data: recursiveData, >+ }); >+ // == END OF TEST DATA === >+ /* >+ These test work by creating a "valid" payment request and then >+ performing a bad update via `show(detailsPromise)`. >+ The `badDetails` cause detailsPromise to reject with `expectedError`. >+ */ >+ function testBadUpdate(testAssertion, badDetails, expectedError) { >+ promise_test(async t => { >+ const request = new PaymentRequest( >+ validMethods, >+ validDetails, >+ validOptions >+ ); >+ const detailsPromise = Promise.resolve(badDetails); >+ const acceptPromise = request.show(detailsPromise); >+ await promise_rejects( >+ t, >+ expectedError, >+ acceptPromise, >+ "badDetails must cause acceptPromise to reject with expectedError" >+ ); >+ }, testAssertion); >+ } >+</script> >+<h2> >+ PaymentRequest <code>.show(optional detailsPromise)</code> tests >+</h2> >+<h3> >+ Bad details - causes `detailsPromise` to reject. >+</h3> >+<p> >+ Click on each button in sequence from top to bottom without refreshing the page. >+ No payment sheet should be shown, as all provided values cause an error. >+</p> >+<p> >+ <strong> >+ If you see a payment sheet, it means the test has failed. >+ </strong> >+</p> >+<ol> >+ <li><button onclick=" >+ const rejectedPromise = Promise.reject(new SyntaxError('test')) >+ .catch(err => err); >+ testBadUpdate(this.textContent, rejectedPromise, 'AbortError'); >+ "> >+ Rejection of detailsPromise must abort the update with an 'AbortError' DOMException. >+ </button></li> >+ >+ <li><button onclick=" >+ const invalidDetails = { total: `this will cause a TypeError!` }; >+ testBadUpdate(this.textContent, invalidDetails, new TypeError()); >+ "> >+ Total in the update is a string, so converting to IDL must abort the update with a TypeError. >+ </button></li> >+ >+ <li><button onclick=" >+ const invalidDetails = { total: recursiveData }; >+ testBadUpdate(this.textContent, invalidDetails, new TypeError()); >+ "> >+ Total is recursive, so converting to IDL must abort the update with a TypeError. >+ </button></li> >+ >+ <li><button onclick=" >+ testBadUpdate(this.textContent, invalidDetailsNegativeTotal, new TypeError()); >+ "> >+ Updating with a negative total results in a TypeError. >+ </button></li> >+ >+ <li><button onclick=" >+ const badDetails = Object.assign({}, validDetails, { >+ displayItems: invalidPaymentItems >+ }); >+ testBadUpdate(this.textContent, badDetails, new RangeError()); >+ "> >+ Updating with a displayItem with an invalid currency results in RangeError. >+ </button></li> >+ >+ <li><button onclick=" >+ const duplicateShippingOptions = [validShippingOption, validShippingOption]; >+ const badDetails = Object.assign({}, validDetails, { >+ shippingOptions: duplicateShippingOptions, >+ }); >+ testBadUpdate(this.textContent, badDetails, new TypeError()); >+ "> >+ Updating with duplicate shippingOptions (same IDs) results in a TypeError. >+ </button></li> >+ <li><button onclick=" >+ const badDetails = Object.assign({}, validDetails, { >+ shippingOptions: invalidShippingOptions, >+ }); >+ testBadUpdate(this.textContent, badDetails, new RangeError()); >+ "> >+ Updating with a shippingOption with an invalid currency value results in a RangError. >+ </button></li> >+ >+ <li><button onclick=" >+ // validModifier is there as to avoid false positives >+ const badModifiers = { modifiers: [modifierWithInvalidTotal, validModifier] }; >+ const badDetails = Object.assign({}, validDetails, badModifiers); >+ testBadUpdate(this.textContent, badDetails, new RangeError()); >+ "> >+ Must throw a RangeError when a modifier's total item has an invalid currency. >+ </button></li> >+ >+ <li><button onclick=" >+ // validModifier is there as to avoid false positives >+ const badModifiers = { >+ modifiers: [modifierWithInvalidDisplayItems, validModifier], >+ }; >+ const badDetails = Object.assign({}, validDetails, badModifiers); >+ testBadUpdate(this.textContent, badDetails, new RangeError()); >+ "> >+ Must throw a RangeError when a modifier display item has an invalid currency. >+ </button></li> >+ >+ <li><button onclick=" >+ // validModifier is there as to avoid false positives >+ const badModifiers = { >+ modifiers: [modifierWithRecursiveData, validModifier], >+ }; >+ const badDetails = Object.assign({}, validDetails, badModifiers); >+ testBadUpdate(this.textContent, badDetails, new TypeError()); >+ "> >+ Must throw as Modifier has a recursive dictionary. >+ </button></li> >+ >+ <li><button onclick="done();">Done!</button></li> >+</ol> >+ >+<small> >+ If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a> >+ and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>. >+</small> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..623db1531b3df372121b0688d63652aa2e35a045 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html >@@ -0,0 +1,319 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>Test for PaymentRequest.show(optional promise) method</title> >+<link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+"use strict"; >+setup({ >+ allow_uncaught_exception: true, >+ explicit_done: true, >+ explicit_timeout: true, >+}); >+ >+// DATA USED BY TESTS >+// PaymentMethods >+const validMethods = Object.freeze([ >+ { >+ supportedMethods: "valid-but-wont-ever-match", >+ }, >+ { >+ supportedMethods: "basic-card", >+ }, >+ { >+ supportedMethods: "https://apple.com/pay", >+ }, >+]); >+ >+// Amounts >+const failAmount = Object.freeze({ >+ currency: "USD", >+ value: "1.00", >+}); >+const passAmount = Object.freeze({ >+ currency: "CAD", >+ value: "50.00", >+}); >+const neutralAmount = Object.freeze({ >+ currency: "AUD", >+ value: "0.00", >+}); >+ >+// Labels >+const failLabel = "ð¥ TEST HAS FAILED ð¥"; >+const passLabel = "â TEST HAS PASSED â "; >+const neutralLabel = "Ignore this label"; >+// Totals >+const failTotal = Object.freeze({ >+ label: failLabel, >+ amount: failAmount, >+}); >+const passTotal = Object.freeze({ >+ label: passLabel, >+ amount: passAmount, >+}); >+const neutralTotal = Object.freeze({ >+ label: neutralLabel, >+ amount: passAmount, >+}); >+ >+// PaymentItem >+const failPaymentItem = Object.freeze({ >+ amount: failAmount, >+ label: failLabel, >+}); >+const failPaymentItems = Object.freeze([failPaymentItem]); >+ >+const passPaymentItem = Object.freeze({ >+ amount: passAmount, >+ label: passLabel, >+}); >+const passPaymentItems = Object.freeze([passPaymentItem]); >+ >+// PaymentShippingOptions >+const failShippingOption = Object.freeze({ >+ id: "fail", >+ label: failLabel, >+ amount: failAmount, >+}); >+const failShippingOptions = Object.freeze([failShippingOption]); >+ >+const neutralShippingOption = Object.freeze({ >+ id: "neutral", >+ label: neutralLabel, >+ amount: neutralAmount, >+}); >+ >+const updatedShippingOption1 = Object.freeze({ >+ id: "updated-1", >+ label: `${passLabel} - option 1`, >+ amount: passAmount, >+}); >+const updatedShippingOption2 = Object.freeze({ >+ id: "updated-2", >+ label: `${passLabel} - option 2 (MUST BE SELECTED!)`, >+ amount: passAmount, >+ selected: true, >+}); >+const passShippingOptions = Object.freeze([ >+ updatedShippingOption1, >+ updatedShippingOption2, >+]); >+ >+// Modifiers >+// create a modifier objects for each validMethods >+// and single additional display item >+const failModifiers = validMethods.map(modifier => { >+ const label = `${failLabel} - (${modifier.supportedMethods})`; >+ return { >+ ...modifier, >+ total: { >+ ...failTotal, >+ label, >+ }, >+ additionalDisplayItems: [ >+ { >+ ...failPaymentItem, >+ label, >+ }, >+ ], >+ }; >+}); >+// Updates the total for each, and changes the additionalDisplayItems >+const passModifiers = failModifiers.map(modifier => { >+ const label = `${passLabel} - (${modifier.supportedMethods})`; >+ return { >+ ...modifier, >+ total: { >+ ...passTotal, >+ label, >+ }, >+ additionalDisplayItems: [ >+ { >+ ...passPaymentItem, >+ label, >+ }, >+ ], >+ }; >+}); >+ >+// PaymentDetailsInit >+const failDetails = Object.freeze({ >+ displayItems: failPaymentItems, >+ id: "this cannot be changed", >+ modifiers: failModifiers, >+ shippingOptions: failShippingOptions, >+ total: failTotal, >+}); >+ >+const neutralDetails = Object.freeze({ >+ displayItems: [], >+ modifiers: [], >+ shippingOptions: [neutralShippingOption], >+ total: neutralTotal, >+}); >+ >+function smokeTest() { >+ promise_test(async t => { >+ const request = new PaymentRequest(validMethods, failDetails); >+ await promise_rejects( >+ t, >+ new TypeError(), >+ request.show({ >+ total: "This throws a TypeError", >+ }), >+ "expected TypeError" >+ ); >+ }, "smoke test - checks if the optional details are supported on show() method"); >+} >+ >+function runUpdateDetailsAlgorithm( >+ buttonElement, >+ details, >+ options = { >+ requestShipping: true, >+ } >+) { >+ const testAssertion = buttonElement.textContent.trim(); >+ buttonElement.disabled = true; >+ promise_test(async t => { >+ const request = new PaymentRequest(validMethods, failDetails, options); >+ const detailsPromise = Promise.resolve(details); >+ const acceptPromise = request.show(detailsPromise); >+ assert_equals(request.id, "this cannot be changed", "id must never change."); >+ await promise_rejects( >+ t, >+ "AbortError", >+ acceptPromise, >+ "expected AbortError" >+ ); >+ }, testAssertion); >+} >+</script> >+<h2> >+ PaymentRequest <code>.show(optional detailsPromise)</code> tests >+</h2> >+<p> >+ These test cause <code>detailsPromise</code> to resolve successfully with some updated value. As such, that will cause >+ something in the payment sheet to change. Each test describes what is expected to change - if anything. >+</p> >+<p> >+ <strong>Instructions:</strong> Click on each button in sequence from top to bottom without refreshing the page. The payment >+ sheet will be shown. If required, confirm that the expected value appears in the payment sheet. Finally, manually abort/cancel >+ the payment request by closing the payment sheet. >+</p> >+<ol> >+ <li><button onclick="smokeTest()">If the payment sheet is shown, the test has failed.</button></li> >+ <li><button onclick=" >+ const details = { >+ ...neutralDetails, >+ id: 'fail', >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, the provided `id` must have no effect on the payment request. >+ </button></li> >+ <li><button onclick=" >+ const details = { >+ ...neutralDetails, >+ total: passTotal >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, the total must be CAD$50 with the label "â TEST HAS PASSED â ". >+ </button></li> >+ <li><button onclick=" >+ const details = { >+ ...neutralDetails, >+ displayItems: passPaymentItems, >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, there must be a one display item with a value of CAD$50 with the label "â TEST HAS PASSED â ". >+ </button> >+ </li> >+ <li><button onclick=" >+ const auItem = { >+ ...passPaymentItem, >+ amount: { value: '40', currency: 'AUD'}, >+ pending: true >+ } >+ const details = { >+ ...neutralDetails, >+ displayItems: passPaymentItems.concat(auItem), >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, there must be >+ two display items: One with a value of CAD$50, another with >+ value AUD$40 that is pending. >+ </button> >+ </li> >+ <li><button onclick=" >+ const details = { >+ ...neutralDetails, >+ shippingOptions: [updatedShippingOption1], >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, there must be a one shipping option >+ with a value of CAD$50. >+ </button> >+ </li> >+ <li><button onclick=" >+ const details = { >+ ...neutralDetails, >+ shippingOptions: passShippingOptions, >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, there must be >+ two shipping options: One with a value of CAD$50, another with >+ value AUD$40 that is selected. >+ </button> >+ </li> >+ <li><button onclick=" >+ const details = { >+ ...neutralDetails, >+ modifiers: passModifiers, >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, the total should be CAD$50. >+ </button> >+ </li> >+ <li> >+ <button onclick=" >+ const details = { >+ ...neutralDetails, >+ shippingOptions: [], >+ error: passLabel, >+ }; >+ runUpdateDetailsAlgorithm(this, details); >+ "> >+ When the payment sheet is shown, the string "â TEST HAS PASSED â " should be shown >+ somewhere in the user interface. Alternatively, the payment sheet must indicate to the >+ end user that it's not possible to ship their order. >+ </button> >+ </li> >+ <li> >+ <button onclick=" >+ const details = { >+ ...neutralDetails, >+ error: failLabel, >+ }; >+ runUpdateDetailsAlgorithm(this, details, {requestShipping: false}); >+ "> >+ When the payment sheet is shown, there should not be any errors shown. >+ </button> >+ </li> >+ <li> >+ <button onclick="done();">Done!</button> >+ </li> >+</ol> >+ >+<small> >+ If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a> >+ and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>. >+</small> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html >new file mode 100644 >index 0000000000000000000000000000000000000000..fd73d6bfa5ad5eb15e0a0a384bff0743da8a0513 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html >@@ -0,0 +1,40 @@ >+<h1>This iframe calls shows() via postMessage()</h1> >+<script> >+"use strict"; >+const defaultMethods = Object.freeze([ >+ { supportedMethods: "basic-card" }, >+ { supportedMethods: "https://apple.com/pay" }, >+]); >+ >+const defaultDetails = Object.freeze({ >+ id: "fail", >+ total: { >+ label: "Total", >+ amount: { >+ currency: "USD", >+ value: "1.00", >+ }, >+ }, >+}); >+ >+// We are going to use the id to prove that this works >+// which we will pass back to the caller >+window.onmessage = async event => { >+ const { source, data: { id, request } } = event; >+ switch (request) { >+ case "show-payment-request": { >+ const details = Object.assign({}, defaultDetails, { id }); >+ const request = new PaymentRequest(defaultMethods, details); >+ try { >+ const response = await request.show(); >+ source.postMessage(response.toJSON(), window.location.origin); >+ await response.complete(); >+ } catch (err) { >+ source.postMessage({ requestId: "fail" }, window.location.origin); >+ await request.abort(); >+ } >+ } >+ } >+}; >+ >+</script> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html >new file mode 100644 >index 0000000000000000000000000000000000000000..1067fb3cd58890d333283564413686455eaf4a46 >--- /dev/null >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html >@@ -0,0 +1,81 @@ >+<!DOCTYPE html> >+<meta charset="utf-8"> >+<title>Test for PaymentRequest.show() method</title> >+<link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method"> >+<script src="/resources/testharness.js"></script> >+<script src="/resources/testharnessreport.js"></script> >+<script> >+"use strict"; >+setup({ >+ explicit_done: true, >+ explicit_timeout: true, >+ allow_uncaught_exception: true, >+}); >+ >+const defaultMethods = Object.freeze([ >+ { supportedMethods: "basic-card" }, >+ { supportedMethods: "https://apple.com/pay" }, >+]); >+ >+const defaultDetails = Object.freeze({ >+ id: "fail", >+ total: { >+ label: "Total", >+ amount: { >+ currency: "USD", >+ value: "1.00", >+ }, >+ }, >+}); >+ >+test(() => { >+ assert_throws( >+ "SecurityError", >+ () => { >+ const request = new PaymentRequest(defaultMethods, defaultDetails); >+ request.show(); // <--- should throw here >+ request.abort(); >+ }, >+ "throws a SecurityError if not triggered by user activation" >+ ); >+}); >+ >+async function runUserActivation(button) { >+ button.disabled = true; >+ const { contentWindow: iframeWindow } = document.getElementById("iframe"); >+ const expectedId = "pass123"; >+ await Promise.resolve(); // next tick >+ const promiseForResponse = new Promise(resolve => { >+ window.onmessage = ({ data: { requestId } }) => resolve(requestId); >+ }); >+ const ops = { id: expectedId, request: "show-payment-request" }; >+ iframeWindow.postMessage(ops, window.location.origin); >+ promise_test(async () => { >+ const actualId = await promiseForResponse; >+ assert_equals(actualId, expectedId, "ids must match"); >+ }, button.textContent.trim()); >+ done(); >+} >+ >+</script> >+<h2>Test PaymentRequest.show() triggered by user activation using postMessage()</h2> >+<p> >+ Tests that user activation works over postMessage(). >+</p> >+<p> >+ Click on bottom below. Hit "Pay". >+</p> >+<ol> >+ <li> >+ <button onclick="runUserActivation(this)"> >+ show() is triggered by user activation passed through postMessage() and a promise >+ </button> >+ </li> >+</ol> >+<iframe width="100%" id="iframe" src="show-method-postmessage-iframe.html" allowpaymentrequest></iframe> >+<p> >+ <small> >+ If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a> >+ and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>. >+ </small> >+</p> >diff --git a/LayoutTests/imported/w3c/web-platform-tests/payment-request/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/payment-request/w3c-import.log >index dfabbd2ad85007f0cc5b1b1a1219805e5caa8178..86844db303f86480f3527aa1f2d91d90adc7e03f 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/payment-request/w3c-import.log >+++ b/LayoutTests/imported/w3c/web-platform-tests/payment-request/w3c-import.log >@@ -1,7 +1,7 @@ > The tests in this directory were imported from the W3C repository. > Do NOT modify these tests directly in WebKit. > Instead, create a pull request on the WPT github: >- https://github.com/w3c/web-platform-tests >+ https://github.com/web-platform-tests/wpt > > Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport > >@@ -17,6 +17,7 @@ List of files: > /LayoutTests/imported/w3c/web-platform-tests/payment-request/OWNERS > /LayoutTests/imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/historical.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/interfaces.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-abort-method-manual.https.html >@@ -26,14 +27,21 @@ List of files: > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-ctor-currency-code-checks.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-ctor-pmi-handling.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-id-attribute.https.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-insecure.http.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-not-exposed.https.worker.js > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-onshippingaddresschange-attribute.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-onshippingoptionchange-attribute.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-shippingAddress-attribute.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-shippingOption-attribute.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-shippingType-attribute.https.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method-manual.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/payment-request-show-method.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/shipping-address-changed-manual.https.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-iframe.html >+/LayoutTests/imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/user-abort-algorithm-manual.https.html > /LayoutTests/imported/w3c/web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html >diff --git a/LayoutTests/platform/mac-wk2/TestExpectations b/LayoutTests/platform/mac-wk2/TestExpectations >index 555d7e19eda01f47184ec7ac922e0c38bacc4bd4..f64e2cc718a2a2357718a35347aa5104bce62c7a 100644 >--- a/LayoutTests/platform/mac-wk2/TestExpectations >+++ b/LayoutTests/platform/mac-wk2/TestExpectations >@@ -48,6 +48,8 @@ imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html > # skip manual payment-request tests > imported/w3c/web-platform-tests/payment-request/algorithms-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/change-shipping-option-manual.https.html [ Skip ] >+imported/w3c/web-platform-tests/payment-request/change-shipping-option-select-last-manual.https.html [ Skip ] >+imported/w3c/web-platform-tests/payment-request/payment-request-show-method-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/payment-response/complete-method-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/payment-response/methodName-attribute-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/payment-response/payerEmail-attribute-manual.https.html [ Skip ] >@@ -58,6 +60,9 @@ imported/w3c/web-platform-tests/payment-request/payment-response/shippingAddress > imported/w3c/web-platform-tests/payment-request/payment-response/shippingOption-attribute-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/shipping-address-changed-manual.https.html [ Skip ] >+imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-rejects-manual.https.html [ Skip ] >+imported/w3c/web-platform-tests/payment-request/show-method-optional-promise-resolves-manual.https.html [ Skip ] >+imported/w3c/web-platform-tests/payment-request/show-method-postmessage-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/updateWith-method-pmi-handling-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/user-abort-algorithm-manual.https.html [ Skip ] > imported/w3c/web-platform-tests/payment-request/user-accepts-payment-request-algo-manual.https.html [ Skip ]
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 188985
:
348156
|
348157