From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- .../attributes-and-toJSON-method-manual.https.html | 109 +++++++ .../updateWith-call-immediate-manual.https.html | 206 +++++++++++++ ...th-duplicate-shipping-options-manual.https.html | 106 +++++++ ...updateWith-incremental-update-manual.https.html | 196 ++++++++++++ ...pdateWith-method-abort-update-manual.https.html | 286 +++++++++++++++++ .../updateWith-state-checks-manual.https.html | 125 ++++++++ .../updatewith-method.https.html | 8 +- ...-shows-shippingAddress-member-manual.https.html | 103 +++++++ .../payment-request/algorithms-manual.https.html | 176 +++++++++++ .../billing-address-changed-manual.https.html | 115 +++++++ .../change-shipping-option-manual.https.html | 104 +++++++ ...e-shipping-option-select-last-manual.https.html | 101 ++++++ ...cally-change-shipping-options-manual.https.html | 142 +++++++++ .../tests/payment-request/historical.https.html | 4 +- .../payment-request-constructor-thcrash.https.html | 254 +++++++++++++++ .../payment-request-constructor.https.sub.html | 222 +++++++++++++- ...equest-ctor-currency-code-checks.https.sub.html | 57 ++++ ...st-onshippingaddresschange-attribute.https.html | 78 +++++ ...est-onshippingoptionchange-attribute.https.html | 79 +++++ ...nt-request-shippingAddress-attribute.https.html | 28 ++ ...ent-request-shippingOption-attribute.https.html | 100 ++++++ ...yment-request-shippingType-attribute.https.html | 72 +++++ .../payment-request/payment-response/helpers.js | 40 +++ .../retry-method-manual.https.html | 296 ++++++++++++++++++ .../retry-method-warnings-manual.https.html | 158 ++++++++++ .../shippingAddress-attribute-manual.https.html | 101 ++++++ .../shippingOption-attribute-manual.https.html | 43 +++ .../shipping-address-changed-manual.https.html | 99 ++++++ ...show-method-optional-promise-rejects.https.html | 40 ++- ...hod-optional-promise-resolves-manual.https.html | 339 +++++++++++++++++++++ ...pdateWith-method-pmi-handling-manual.https.html | 140 +++++++++ ...-accepts-payment-request-algo-manual.https.html | 230 ++++++++++++++ 32 files changed, 4151 insertions(+), 6 deletions(-) create mode 100644 testing/web-platform/tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-duplicate-shipping-options-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-incremental-update-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-method-abort-update-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-state-checks-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/algorithms-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/billing-address-changed-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/change-shipping-option-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/change-shipping-option-select-last-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/dynamically-change-shipping-options-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-request-constructor-thcrash.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-request-onshippingaddresschange-attribute.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-request-onshippingoptionchange-attribute.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-request-shippingAddress-attribute.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-request-shippingOption-attribute.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-request-shippingType-attribute.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-response/retry-method-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-response/retry-method-warnings-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/payment-response/shippingOption-attribute-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/shipping-address-changed-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/show-method-optional-promise-resolves-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/updateWith-method-pmi-handling-manual.https.html create mode 100644 testing/web-platform/tests/payment-request/user-accepts-payment-request-algo-manual.https.html (limited to 'testing/web-platform/tests/payment-request') diff --git a/testing/web-platform/tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html b/testing/web-platform/tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html new file mode 100644 index 0000000000..fc1ce3523e --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html @@ -0,0 +1,109 @@ + + + + + PaymentResponse.prototype.shippingAddress + + + + + +

ContactAddress interface

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When prompted, please enter addresses as follows... +

+
    +
  1. + + Please use: +
    +
    Recipient:
    +
    web platform test
    +
    Address line:
    +
    55 test st
    +
    Country
    +
    Australia
    +
    City
    +
    Chapel Hill
    +
    State/Region
    +
    Queensland
    +
    postal code
    +
    6095
    +
    organization
    +
    w3c
    +
    Phone number
    +
    +61 7 3378 0000
    +
    +
  2. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html new file mode 100644 index 0000000000..1365ecefeb --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html @@ -0,0 +1,206 @@ + + + + + + PaymentRequestUpdateEvent.updateWith() needs to be called immediately + + + + +

updateWith() method

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is shown, select a different shipping address once. Then pay. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + When the payment sheet is shown, select a different shipping address once, then change shipping option once. Then pay. +
  6. +
  7. + +
  8. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-duplicate-shipping-options-manual.https.html b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-duplicate-shipping-options-manual.https.html new file mode 100644 index 0000000000..a4a7afd7f6 --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-duplicate-shipping-options-manual.https.html @@ -0,0 +1,106 @@ + + + + + updateWith() method - duplicate shippingOption ids + + + + +

updateWith() method - duplicate shippingOptions ids

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is shown, select a different shipping address. + If you have to manually abort the test from the payment sheet, then the + test has failed. +

+
    +
  1. + +
  2. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-incremental-update-manual.https.html b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-incremental-update-manual.https.html new file mode 100644 index 0000000000..c1ed1b5f68 --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-incremental-update-manual.https.html @@ -0,0 +1,196 @@ + + + + + Incremental updates via updateWith() + + + + +

+ Incremental updates +

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ Unless stated otherwise, each test will update some part of the displayed payment sheet in + a manner indicated below. When prompted, please change or enter a new + shipping address, look for the tested change, and complete the payment. +

+

+ If the payment request locks up or otherwise aborts, the test has failed. +

+
    +
  1. + +
  2. +
+ +
+

Incremental updates via PaymentDetailsUpdate.total

+
    +
  1. + +
  2. +
+
+ +
+

Incremental updates via PaymentDetailsBase.displayItems

+
    +
  1. + +
  2. +
+
+ +
+

Incremental updates via PaymentDetailsBase.shippingOptions

+
    +
  1. + +
  2. +
+
+ +
+

Incremental updates via PaymentDetailsBase.modifiers

+
    +
  1. + +
  2. +
  3. + +
  4. +
+
+ + + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-method-abort-update-manual.https.html b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-method-abort-update-manual.https.html new file mode 100644 index 0000000000..e24452c2a9 --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-method-abort-update-manual.https.html @@ -0,0 +1,286 @@ + + + + + updateWith() method - "abort the update" + + + + +

updateWith() method - "abort the update"

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is shown, change the shipping address. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
  9. + +
  10. +
  11. + +
  12. +
  13. + +
  14. +
  15. + +
  16. +
  17. + +
  18. +
  19. + +
  20. +
  21. + +
  22. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-state-checks-manual.https.html b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-state-checks-manual.https.html new file mode 100644 index 0000000000..fb16de5699 --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updateWith-state-checks-manual.https.html @@ -0,0 +1,125 @@ + + + +updateWith() method - state machine checks + + + +

updateWith() method - state machine checks

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is shown, select a different shipping address once. Then pay. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html index 9a60fe7a4c..fffd3b3ec5 100644 --- a/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html +++ b/testing/web-platform/tests/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html @@ -29,7 +29,9 @@ test(() => { // Github issue: https://github.com/w3c/browser-payment-api/issues/546 test(() => { const untrustedEvents = [ - new PaymentRequestUpdateEvent("just a test") + new PaymentRequestUpdateEvent("just a test"), + new PaymentRequestUpdateEvent("shippingaddresschange"), + new PaymentRequestUpdateEvent("shippingoptionchange"), ].forEach(ev => { assert_throws_dom( "InvalidStateError", @@ -45,7 +47,9 @@ test(() => { test(() => { const request = new PaymentRequest(defaultMethods, defaultDetails); const untrustedEvents = [ - new PaymentRequestUpdateEvent("just a test") + new PaymentRequestUpdateEvent("just a test"), + new PaymentRequestUpdateEvent("shippingaddresschange"), + new PaymentRequestUpdateEvent("shippingoptionchange"), ].map(ev => { request.dispatchEvent(ev); // set .target and dispatch flag // unstrusted event. diff --git a/testing/web-platform/tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html b/testing/web-platform/tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html new file mode 100644 index 0000000000..94e6fa5105 --- /dev/null +++ b/testing/web-platform/tests/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html @@ -0,0 +1,103 @@ + + + + + PaymentValidationErrors' `shippingAddress` member (AddressErrors) + + + + + +

+ Manual Test for PaymentValidationErrors' `shippingAddress` member - Please run in order! +

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When presented with the payment sheet, use any card and select to "Pay". + You will be asked to retry the payment and an error should be shown somewhere + in the UI. The expected error string is described in each individual test. + If you see the error, hit "Pay" again. If you don't see the error, + abort the payment request by hitting "esc" - which means that particular test + has failed. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
  9. + +
  10. +
  11. + +
  12. +
  13. + +
  14. +
  15. + +
  16. +
  17. + +
  18. +
  19. + +
  20. +
  21. + +
  22. +
  23. + +
  24. +
+ + If you find a buggy test, please file a bug + and tag one of the owners. + diff --git a/testing/web-platform/tests/payment-request/algorithms-manual.https.html b/testing/web-platform/tests/payment-request/algorithms-manual.https.html new file mode 100644 index 0000000000..b90c312aba --- /dev/null +++ b/testing/web-platform/tests/payment-request/algorithms-manual.https.html @@ -0,0 +1,176 @@ + + + + + Payment Request algorithms + + + + +

+ Tests for "algorithms" section +

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+
+

+ User aborts the payment request algorithm +

+ +

+ When presented with the payment sheet, abort the payment request (e.g., by hitting the esc key or pressing a UA provided button). +

+
    +
  1. + +
  2. +
+
+ +
+

Shipping address changed algorithm

+ +

+ When prompted, please change or enter a new shipping address and then select Pay. +

+
    +
  1. + +
  2. +
+
+ +
+

Shipping option changed algorithm

+ +

+ Finally, when prompted, please select "shipping option 2" and then select Pay. +

+
    +
  1. + +
  2. +
+
+ + + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/billing-address-changed-manual.https.html b/testing/web-platform/tests/payment-request/billing-address-changed-manual.https.html new file mode 100644 index 0000000000..d03f761518 --- /dev/null +++ b/testing/web-platform/tests/payment-request/billing-address-changed-manual.https.html @@ -0,0 +1,115 @@ + +Test for requesting billing address + + + + +

Request billing address

+

+ Click on each button in sequence from top to bottom without refreshing the + page. Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is presented, select a payment method (e.g., a credit + card). +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. +
+ + If you find a buggy test, please + file a bug and + tag one of the + suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/change-shipping-option-manual.https.html b/testing/web-platform/tests/payment-request/change-shipping-option-manual.https.html new file mode 100644 index 0000000000..438001804a --- /dev/null +++ b/testing/web-platform/tests/payment-request/change-shipping-option-manual.https.html @@ -0,0 +1,104 @@ + + + +Test for PaymentRequest shippingOption attribute + + + + + + +

PaymentRequest shippingOption attribute

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is presented, select "PICK ME!" as the shipping option. +

+
    +
  1. + +
  2. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/change-shipping-option-select-last-manual.https.html b/testing/web-platform/tests/payment-request/change-shipping-option-select-last-manual.https.html new file mode 100644 index 0000000000..4ad31d6531 --- /dev/null +++ b/testing/web-platform/tests/payment-request/change-shipping-option-select-last-manual.https.html @@ -0,0 +1,101 @@ + + +Test for PaymentDetailsBase's shippingOptions member + + + + + +

PaymentRequest shippingOption attribute

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is presented, hit pay. +

+
    +
  1. + +
  2. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/dynamically-change-shipping-options-manual.https.html b/testing/web-platform/tests/payment-request/dynamically-change-shipping-options-manual.https.html new file mode 100644 index 0000000000..0e6670a1b8 --- /dev/null +++ b/testing/web-platform/tests/payment-request/dynamically-change-shipping-options-manual.https.html @@ -0,0 +1,142 @@ + + +Test for PaymentRequest shippingOption dynamic updating + + + + + + +

PaymentRequest shippingOption attribute

+

+ Click on each button in sequence from top to bottom without refreshing the + page. Each button (except the 'Done' button) will bring up the Payment Request + UI window. +

+
    +
  1. + When the payment sheet is presented, view options for Shipping Method. There + should only be one: "Default shipping method" +
  2. +
  3. + Change your Shipping Address - either update your existing one by changing + something (name, address, etc), or select a different Shipping Address, or + add a new Shipping Address and select it. +
  4. +
  5. + Go back to Shipping Method, and there is now an option called "Dynamically + added shipping option". Select it +
  6. +
  7. + Click on the 'Done' button +
  8. +
+ + + If you find a buggy test, please + file a bug and + tag one of the + suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/historical.https.html b/testing/web-platform/tests/payment-request/historical.https.html index aa183a58cd..3e881d0122 100644 --- a/testing/web-platform/tests/payment-request/historical.https.html +++ b/testing/web-platform/tests/payment-request/historical.https.html @@ -10,7 +10,7 @@ ["paymentRequestID", "PaymentResponse"], // https://github.com/w3c/browser-payment-api/pull/258 - ["careOf", "PaymentAddress"], + ["careOf", "ContactAddress"], // https://github.com/w3c/browser-payment-api/pull/219 ["totalAmount", "PaymentResponse"], @@ -20,7 +20,7 @@ ["paymentRequestId", "PaymentResponse"], // https://github.com/w3c/payment-request/pull/765 - ["languageCode", "PaymentAddress"], + ["languageCode", "ContactAddress"], //https://github.com/whatwg/html/pull/5915 ["allowPaymentRequest", "HTMLIFrameElement"], diff --git a/testing/web-platform/tests/payment-request/payment-request-constructor-thcrash.https.html b/testing/web-platform/tests/payment-request/payment-request-constructor-thcrash.https.html new file mode 100644 index 0000000000..b600307085 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-request-constructor-thcrash.https.html @@ -0,0 +1,254 @@ + + + +Crash tests PaymentRequest Constructor + + + + diff --git a/testing/web-platform/tests/payment-request/payment-request-constructor.https.sub.html b/testing/web-platform/tests/payment-request/payment-request-constructor.https.sub.html index c1ecc22583..9b0ad06454 100644 --- a/testing/web-platform/tests/payment-request/payment-request-constructor.https.sub.html +++ b/testing/web-platform/tests/payment-request/payment-request-constructor.https.sub.html @@ -240,7 +240,7 @@ test(() => { test(() => { smokeTest(); - for (const prop in ["displayItems", "modifiers"]) { + for (const prop in ["displayItems", "shippingOptions", "modifiers"]) { try { const details = Object.assign({}, defaultDetails, { [prop]: [] }); new PaymentRequest(defaultMethods, details); @@ -361,6 +361,186 @@ test(() => { } }, "it handles high precision currency values without throwing"); +// Process shipping options: + +const defaultShippingOption = Object.freeze({ + id: "default", + label: "", + amount: defaultAmount, + selected: false, +}); +const defaultShippingOptions = Object.freeze([ + Object.assign({}, defaultShippingOption), +]); + +test(() => { + smokeTest(); + for (const amount of invalidAmounts) { + const invalidAmount = Object.assign({}, defaultAmount, { + value: amount, + }); + const invalidShippingOption = Object.assign({}, defaultShippingOption, { + amount: invalidAmount, + }); + const details = Object.assign({}, defaultDetails, { + shippingOptions: [invalidShippingOption], + }); + assert_throws_js( + TypeError, + () => { + new PaymentRequest(defaultMethods, details, { requestShipping: true }); + }, + `Expected TypeError for option.amount.value: "${amount}"` + ); + } +}, `For each option in details.shippingOptions: if option.amount.value is not a valid decimal monetary value, then throw a TypeError`); + +test(() => { + smokeTest(); + const shippingOptions = [defaultShippingOption]; + const details = Object.assign({}, defaultDetails, { shippingOptions }); + const request = new PaymentRequest(defaultMethods, details); + assert_equals( + request.shippingOption, + null, + "shippingOption must be null, as requestShipping is missing" + ); + // defaultDetails lacks shipping options + const request2 = new PaymentRequest(defaultMethods, defaultDetails, { + requestShipping: true, + }); + assert_equals( + request2.shippingOption, + null, + `request2.shippingOption must be null` + ); +}, "If there is no selected shipping option, then PaymentRequest.shippingOption remains null"); + +test(() => { + smokeTest(); + const selectedOption = Object.assign({}, defaultShippingOption, { + selected: true, + id: "the-id", + }); + const shippingOptions = [selectedOption]; + const details = Object.assign({}, defaultDetails, { shippingOptions }); + const requestNoShippingRequested1 = new PaymentRequest( + defaultMethods, + details + ); + assert_equals( + requestNoShippingRequested1.shippingOption, + null, + "Must be null when no shipping is requested (defaults to false)" + ); + const requestNoShippingRequested2 = new PaymentRequest( + defaultMethods, + details, + { requestShipping: false } + ); + assert_equals( + requestNoShippingRequested2.shippingOption, + null, + "Must be null when requestShipping is false" + ); + const requestWithShipping = new PaymentRequest(defaultMethods, details, { + requestShipping: "truthy value", + }); + assert_equals( + requestWithShipping.shippingOption, + "the-id", + "Selected option must be 'the-id'" + ); +}, "If there is a selected shipping option, and requestShipping is set, then that option becomes synchronously selected"); + +test(() => { + smokeTest(); + const failOption1 = Object.assign({}, defaultShippingOption, { + selected: true, + id: "FAIL1", + }); + const failOption2 = Object.assign({}, defaultShippingOption, { + selected: false, + id: "FAIL2", + }); + const passOption = Object.assign({}, defaultShippingOption, { + selected: true, + id: "the-id", + }); + const shippingOptions = [failOption1, failOption2, passOption]; + const details = Object.assign({}, defaultDetails, { shippingOptions }); + const requestNoShipping = new PaymentRequest(defaultMethods, details, { + requestShipping: false, + }); + assert_equals( + requestNoShipping.shippingOption, + null, + "shippingOption must be null, as requestShipping is false" + ); + const requestWithShipping = new PaymentRequest(defaultMethods, details, { + requestShipping: true, + }); + assert_equals( + requestWithShipping.shippingOption, + "the-id", + "selected option must 'the-id" + ); +}, "If requestShipping is set, and if there is a multiple selected shipping options, only the last is selected."); + +test(() => { + smokeTest(); + const selectedOption = Object.assign({}, defaultShippingOption, { + selected: true, + }); + const unselectedOption = Object.assign({}, defaultShippingOption, { + selected: false, + }); + const shippingOptions = [selectedOption, unselectedOption]; + const details = Object.assign({}, defaultDetails, { shippingOptions }); + const requestNoShipping = new PaymentRequest(defaultMethods, details); + assert_equals( + requestNoShipping.shippingOption, + null, + "shippingOption must be null, because requestShipping is false" + ); + assert_throws_js( + TypeError, + () => { + new PaymentRequest(defaultMethods, details, { requestShipping: true }); + }, + "Expected to throw a TypeError because duplicate IDs" + ); +}, "If there are any duplicate shipping option ids, and shipping is requested, then throw a TypeError"); + +test(() => { + smokeTest(); + const dupShipping1 = Object.assign({}, defaultShippingOption, { + selected: true, + id: "DUPLICATE", + label: "Fail 1", + }); + const dupShipping2 = Object.assign({}, defaultShippingOption, { + selected: false, + id: "DUPLICATE", + label: "Fail 2", + }); + const shippingOptions = [dupShipping1, defaultShippingOption, dupShipping2]; + const details = Object.assign({}, defaultDetails, { shippingOptions }); + const requestNoShipping = new PaymentRequest(defaultMethods, details); + assert_equals( + requestNoShipping.shippingOption, + null, + "shippingOption must be null, because requestShipping is false" + ); + assert_throws_js( + TypeError, + () => { + new PaymentRequest(defaultMethods, details, { requestShipping: true }); + }, + "Expected to throw a TypeError because duplicate IDs" + ); +}, "Throw when there are duplicate shippingOption ids, even if other values are different"); + // Process payment details modifiers: test(() => { smokeTest(); @@ -474,4 +654,44 @@ test(() => { }); }, "Rethrow any exceptions of JSON-serializing modifier.data"); +//Setting ShippingType attribute during construction +test(() => { + smokeTest(); + assert_throws_js(TypeError, () => { + new PaymentRequest(defaultMethods, defaultDetails, { + shippingType: "invalid", + }); + }); +}, "Shipping type should be valid"); + +test(() => { + smokeTest(); + const request = new PaymentRequest(defaultMethods, defaultDetails, {}); + assert_equals(request.shippingAddress, null, "must be null"); +}, "PaymentRequest.shippingAddress must initially be null"); + +test(() => { + smokeTest(); + const request1 = new PaymentRequest(defaultMethods, defaultDetails, {}); + assert_equals(request1.shippingType, null, "must be null"); + const request2 = new PaymentRequest(defaultMethods, defaultDetails, { + requestShipping: false, + }); + assert_equals(request2.shippingType, null, "must be null"); +}, "If options.requestShipping is not set, then request.shippingType attribute is null."); + +test(() => { + smokeTest(); + // option.shippingType defaults to 'shipping' + const request1 = new PaymentRequest(defaultMethods, defaultDetails, { + requestShipping: true, + }); + assert_equals(request1.shippingType, "shipping", "must be shipping"); + const request2 = new PaymentRequest(defaultMethods, defaultDetails, { + requestShipping: true, + shippingType: "delivery", + }); + assert_equals(request2.shippingType, "delivery", "must be delivery"); +}, "If options.requestShipping is true, request.shippingType will be options.shippingType."); + diff --git a/testing/web-platform/tests/payment-request/payment-request-ctor-currency-code-checks.https.sub.html b/testing/web-platform/tests/payment-request/payment-request-ctor-currency-code-checks.https.sub.html index c608608c7e..b4ca2a0c40 100644 --- a/testing/web-platform/tests/payment-request/payment-request-ctor-currency-code-checks.https.sub.html +++ b/testing/web-platform/tests/payment-request/payment-request-ctor-currency-code-checks.https.sub.html @@ -178,6 +178,63 @@ test(() => { } }, "Check and canonicalize invalid details.displayItems amount and rethrow RangeError."); +// Process shipping options: +test(() => { + assert_throws_js(RANGE_ERROR, smokeTest, "Expected smoke test to throw."); + const shippingOptions = []; + for (const validCurrency of wellFormedCurrencyCodes) { + const shippingOption = { + id: `test` + Math.random(), + label: "shipping option", + amount: { currency: validCurrency, value: "5.00" }, + selected: !shippingOptions.length, + }; + const details = { + total: defaultTotal, + shippingOptions: [shippingOption], + }; + try { + new PaymentRequest(defaultMethods, details, { requestShipping: true }); + } catch (err) { + assert_unreached( + `Unexpected exception with valid shippingOption currency code "${validCurrency}": ${err.message}.` + ); + } + shippingOptions.push(shippingOption); + } + try { + const details = Object.assign({}, defaultDetails, { shippingOptions }); + new PaymentRequest(defaultMethods, details, { requestShipping: true }); + } catch (err) { + assert_unreached( + `Unexpected error with multiple valid shppingOptions: ${err.message}.` + ); + } +}, "Check and canonicalize valid details.shippingOptions amount."); + +test(() => { + assert_throws_js(RANGE_ERROR, smokeTest, "Expected smoke test to throw."); + for (const invalidCurrency of invalidCurrencyCodes) { + const shippingOption = { + id: "test", + label: "shipping option", + amount: { currency: invalidCurrency, value: "5.00" }, + selected: true, + }; + const details = { + total: defaultTotal, + shippingOptions: [shippingOption], + }; + assert_throws_js( + RANGE_ERROR, + () => { + new PaymentRequest(defaultMethods, details, { requestShipping: true }); + }, + `Expected RangeError with invalid shippingOption currency code "${invalidCurrency}".` + ); + } +}, "Check and canonicalize invalid details.shippingOptions amount and rethrow RangeError."); + // Process payment details modifiers: test(() => { assert_throws_js(RANGE_ERROR, smokeTest, "Expected smoke test to throw."); diff --git a/testing/web-platform/tests/payment-request/payment-request-onshippingaddresschange-attribute.https.html b/testing/web-platform/tests/payment-request/payment-request-onshippingaddresschange-attribute.https.html new file mode 100644 index 0000000000..5b2538992f --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-request-onshippingaddresschange-attribute.https.html @@ -0,0 +1,78 @@ + + + +Test for onshippingaddresschange attribute + + + + diff --git a/testing/web-platform/tests/payment-request/payment-request-onshippingoptionchange-attribute.https.html b/testing/web-platform/tests/payment-request/payment-request-onshippingoptionchange-attribute.https.html new file mode 100644 index 0000000000..43ea5dcce8 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-request-onshippingoptionchange-attribute.https.html @@ -0,0 +1,79 @@ + + + +Test for onshippingoptionchange attribute + + + + diff --git a/testing/web-platform/tests/payment-request/payment-request-shippingAddress-attribute.https.html b/testing/web-platform/tests/payment-request/payment-request-shippingAddress-attribute.https.html new file mode 100644 index 0000000000..08918356b6 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-request-shippingAddress-attribute.https.html @@ -0,0 +1,28 @@ + + + +Test for PaymentRequest shippingAddress attribute + + + + diff --git a/testing/web-platform/tests/payment-request/payment-request-shippingOption-attribute.https.html b/testing/web-platform/tests/payment-request/payment-request-shippingOption-attribute.https.html new file mode 100644 index 0000000000..b5f9ea65c6 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-request-shippingOption-attribute.https.html @@ -0,0 +1,100 @@ + + + +Test for PaymentRequest shippingOption attribute + + + + diff --git a/testing/web-platform/tests/payment-request/payment-request-shippingType-attribute.https.html b/testing/web-platform/tests/payment-request/payment-request-shippingType-attribute.https.html new file mode 100644 index 0000000000..11f75b1c86 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-request-shippingType-attribute.https.html @@ -0,0 +1,72 @@ + + + +Test for PaymentRequest's shippingType attribute + + + + diff --git a/testing/web-platform/tests/payment-request/payment-response/helpers.js b/testing/web-platform/tests/payment-request/payment-response/helpers.js index 1242ecb743..3e4f5cfd36 100644 --- a/testing/web-platform/tests/payment-request/payment-response/helpers.js +++ b/testing/web-platform/tests/payment-request/payment-response/helpers.js @@ -65,8 +65,30 @@ async function getPaymentRequestResponse(options, id) { label: "Total due", amount: { currency: "USD", value: "1.0" }, }, + shippingOptions: [ + { + id: "fail1", + label: "Fail option 1", + amount: { currency: "USD", value: "5.00" }, + selected: false, + }, + { + id: "pass", + label: "Pass option", + amount: { currency: "USD", value: "5.00" }, + selected: true, + }, + { + id: "fail2", + label: "Fail option 2", + amount: { currency: "USD", value: "5.00" }, + selected: false, + }, + ], }; const request = new PaymentRequest(methods, details, options); + request.onshippingaddresschange = ev => ev.updateWith(details); + request.onshippingoptionchange = ev => ev.updateWith(details); const response = await request.show(); return { request, response }; } @@ -106,5 +128,23 @@ async function runManualTest(button, options, expected = {}, id = undefined) { assert_equals(typeof response.details, "object", "Expected an object"); // Testing that this does not throw: response.toJSON(); + if (options && options.requestShipping) { + assert_equals( + response.shippingOption, + "pass", + "request.shippingOption must be 'pass'" + ); + } else { + assert_equals( + request.shippingOption, + null, + "If requestShipping is falsy, request.shippingOption must be null" + ); + assert_equals( + response.shippingOption, + null, + "request.shippingOption must be null" + ); + } }, button.textContent.trim()); } diff --git a/testing/web-platform/tests/payment-request/payment-response/retry-method-manual.https.html b/testing/web-platform/tests/payment-request/payment-response/retry-method-manual.https.html new file mode 100644 index 0000000000..a5aab49e38 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-response/retry-method-manual.https.html @@ -0,0 +1,296 @@ + + + + + PaymentResponse.prototype.retry() method + + + + + +

+ Manual Tests for PaymentResponse.retry() - Please run in order! +

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When presented with the payment sheet, use any credit card select to "Pay" multiple times. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
  9. + +
  10. +
  11. +

    + When shown the payment sheet, hit pay once, then abort retrying the payment. +

    + +
  12. +
  13. +

    + When shown the payment sheet, hit pay once. Check payment sheet for error fields. + Then hit escape or otherwise abort the payment. +

    + +
  14. +
  15. +

    + When shown the payment sheet, hit pay once. + Then, change the shipping option. + Select to pay again. +

    + +
  16. +
  17. +

    + When shown the payment sheet, hit pay once. Then retry once. +

    + +
  18. +
  19. + +
  20. +
+ + If you find a buggy test, please file a bug + and tag one of the owners. + diff --git a/testing/web-platform/tests/payment-request/payment-response/retry-method-warnings-manual.https.html b/testing/web-platform/tests/payment-request/payment-response/retry-method-warnings-manual.https.html new file mode 100644 index 0000000000..b68bf18309 --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-response/retry-method-warnings-manual.https.html @@ -0,0 +1,158 @@ + +Warn when errorFields don't match request[[options]] + + + + + +

Manual Tests - Please run in order!

+

+ Please open the developer console. Each of the tests below should generate a + warning in the developer console. +

+

When presented with the payment sheet, hit pay twice.

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
  9. + +
  10. +
  11. + +
  12. +
  13. + +
  14. +
  15. + +
  16. +
  17. + +
  18. +
  19. + +
  20. +
  21. + +
  22. +
  23. + +
  24. +
  25. + +
  26. +
  27. + +
  28. +
  29. + +
  30. +
  31. +
diff --git a/testing/web-platform/tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html b/testing/web-platform/tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html new file mode 100644 index 0000000000..f9f0a6e4fa --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-response/shippingAddress-attribute-manual.https.html @@ -0,0 +1,101 @@ + + + + + PaymentResponse.prototype.shippingAddress + + + + + +

shippingAddress attribute

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When prompted, please enter "web platform test" as recipient, at address "1 wpt street" in "Kabul, Afghanistan", zip/postal code 1001. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/payment-response/shippingOption-attribute-manual.https.html b/testing/web-platform/tests/payment-request/payment-response/shippingOption-attribute-manual.https.html new file mode 100644 index 0000000000..687d3a52de --- /dev/null +++ b/testing/web-platform/tests/payment-request/payment-response/shippingOption-attribute-manual.https.html @@ -0,0 +1,43 @@ + + + + + PaymentResponse.prototype.complete() method + + + + +

shippingOption attribute

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ For the last test, please select the only available shipping option and select "Pay". +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/shipping-address-changed-manual.https.html b/testing/web-platform/tests/payment-request/shipping-address-changed-manual.https.html new file mode 100644 index 0000000000..aad57cd724 --- /dev/null +++ b/testing/web-platform/tests/payment-request/shipping-address-changed-manual.https.html @@ -0,0 +1,99 @@ + + + +Test for PaymentRequest shippingAddress attribute + + + + + + +

PaymentRequest shippingAddress attribute

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When the payment sheet is presented, enter or select a shipping address. +

+
    +
  1. + +
  2. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/show-method-optional-promise-rejects.https.html b/testing/web-platform/tests/payment-request/show-method-optional-promise-rejects.https.html index 4a41f28fc9..3b42965503 100644 --- a/testing/web-platform/tests/payment-request/show-method-optional-promise-rejects.https.html +++ b/testing/web-platform/tests/payment-request/show-method-optional-promise-rejects.https.html @@ -84,6 +84,10 @@ total: invalidNegativeTotal, }); + // PaymentOptions + const validOptions = Object.freeze({ + requestShipping: true, + }); // PaymentItem const validPaymentItem = Object.freeze({ @@ -100,6 +104,24 @@ 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, @@ -144,7 +166,8 @@ promise_test(async (t) => { const request = new PaymentRequest( validMethods, - validDetails + validDetails, + validOptions ); await test_driver.bless("Payment request"); const detailsPromise = Promise.resolve(badDetails); @@ -193,6 +216,21 @@ RangeError ); + testBadUpdate( + "Updating with duplicate shippingOptions (same IDs) results in a TypeError.", + { + ...validDetails, + shippingOptions: [validShippingOption, validShippingOption], + }, + TypeError + ); + + testBadUpdate( + "Updating with a shippingOption with an invalid currency value results in a RangError.", + { ...validDetails, shippingOptions: invalidShippingOptions }, + RangeError + ); + testBadUpdate( "Must throw a RangeError when a modifier's total item has an invalid currency.", { ...validDetails, modifiers: [modifierWithInvalidTotal, validModifier] }, diff --git a/testing/web-platform/tests/payment-request/show-method-optional-promise-resolves-manual.https.html b/testing/web-platform/tests/payment-request/show-method-optional-promise-resolves-manual.https.html new file mode 100644 index 0000000000..5360a9704a --- /dev/null +++ b/testing/web-platform/tests/payment-request/show-method-optional-promise-resolves-manual.https.html @@ -0,0 +1,339 @@ + + +Test for PaymentRequest.show(optional promise) method + + + + +

+ PaymentRequest .show(optional detailsPromise) tests +

+

+ These test cause detailsPromise 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. +

+

+ Instructions: 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. +

+
    +
  1. +
  2. +
  3. +
  4. +
  5. +
  6. +
  7. +
  8. +
  9. +
  10. +
  11. +
  12. +
  13. +
  14. + +
  15. +
  16. + +
  17. +
  18. + +
  19. +
  20. + +
  21. +
+ + + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/updateWith-method-pmi-handling-manual.https.html b/testing/web-platform/tests/payment-request/updateWith-method-pmi-handling-manual.https.html new file mode 100644 index 0000000000..1a52978ca3 --- /dev/null +++ b/testing/web-platform/tests/payment-request/updateWith-method-pmi-handling-manual.https.html @@ -0,0 +1,140 @@ + + +Test for validity of payment method identifiers when calling updateWith() method + + + + +

updateWith() method: test validity of payment method identifiers.

+

+ When shown a payment sheet, select a different address. +

+
    +
  1. + +
  2. +
  3. + +
  4. +
  5. + +
  6. +
  7. + +
  8. +
  9. + +
  10. +
  11. + +
  12. +
  13. + +
  14. +
  15. + +
  16. +
  17. + +
  18. +
  19. + +
  20. +
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + diff --git a/testing/web-platform/tests/payment-request/user-accepts-payment-request-algo-manual.https.html b/testing/web-platform/tests/payment-request/user-accepts-payment-request-algo-manual.https.html new file mode 100644 index 0000000000..300f04811f --- /dev/null +++ b/testing/web-platform/tests/payment-request/user-accepts-payment-request-algo-manual.https.html @@ -0,0 +1,230 @@ + + + + + User accepts the payment request algorithm + + + + + +
+

User accepts payment request

+

+ Click on each button in sequence from top to bottom without refreshing the page. + Each button will bring up the Payment Request UI window. +

+

+ When shown the payment sheet, please input a credit card and select Pay. +

+
    +
  1. + Use any credit card to pay. +
  2. +
  3. + Select any shipping option, and use any credit card to pay. +
  4. +
  5. + + When prompted, please use "wpt@w3.org" as the email. +
  6. +
  7. + + When prompted, please use "+12345678910" as the phone number. +
  8. +
  9. + + When prompted, please use "web platform test" as the payer name. +
  10. +
  11. + + When prompted, please use: "+12345678910" as the phone number, "web platform test" as the payer name, and "wpt@w3.org" as the email. Then press Pay. +
  12. +
  13. + +
  14. +
+
+ + If you find a buggy test, please file a bug + and tag one of the suggested reviewers. + -- cgit v1.2.3