diff --git a/payment-method-basic-card/billing-address-is-null-manual.https.html b/payment-method-basic-card/billing-address-is-null-manual.https.html index 3250e0a2c550e8..5eac71963eb478 100644 --- a/payment-method-basic-card/billing-address-is-null-manual.https.html +++ b/payment-method-basic-card/billing-address-is-null-manual.https.html @@ -101,8 +101,8 @@ function checkRedaction(billingAddress) { assert_true( - billingAddress instanceof PaymentAddress, - "Expected instance of PaymentAddress" + billingAddress instanceof ContactAddress, + "Expected instance of ContactAddress" ); for (const item of ["organization", "phone", "recipient"]) { assert_equals( @@ -134,7 +134,7 @@

Request billing address

  • diff --git a/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html b/payment-request/PaymentAddress/attributes-and-toJSON-method-manual.https.html new file mode 100644 index 00000000000000..fc1ce3523e57a0 --- /dev/null +++ b/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/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html b/payment-request/PaymentRequestUpdateEvent/updateWith-call-immediate-manual.https.html new file mode 100644 index 00000000000000..1365ecefebeb27 --- /dev/null +++ b/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/payment-request/PaymentRequestUpdateEvent/updateWith-duplicate-shipping-options-manual.https.html b/payment-request/PaymentRequestUpdateEvent/updateWith-duplicate-shipping-options-manual.https.html new file mode 100644 index 00000000000000..a4a7afd7f6337c --- /dev/null +++ b/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/payment-request/PaymentRequestUpdateEvent/updateWith-incremental-update-manual.https.html b/payment-request/PaymentRequestUpdateEvent/updateWith-incremental-update-manual.https.html new file mode 100644 index 00000000000000..c1ed1b5f6850c7 --- /dev/null +++ b/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/payment-request/PaymentRequestUpdateEvent/updateWith-method-abort-update-manual.https.html b/payment-request/PaymentRequestUpdateEvent/updateWith-method-abort-update-manual.https.html new file mode 100644 index 00000000000000..e24452c2a99d30 --- /dev/null +++ b/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/payment-request/PaymentRequestUpdateEvent/updateWith-state-checks-manual.https.html b/payment-request/PaymentRequestUpdateEvent/updateWith-state-checks-manual.https.html new file mode 100644 index 00000000000000..fb16de5699aa74 --- /dev/null +++ b/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/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html b/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html index 9a60fe7a4c0a60..fffd3b3ec544c9 100644 --- a/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html +++ b/payment-request/PaymentRequestUpdateEvent/updatewith-method.https.html @@ -29,7 +29,9 @@ // 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(() => { 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/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html b/payment-request/PaymentValidationErrors/retry-shows-shippingAddress-member-manual.https.html new file mode 100644 index 00000000000000..94e6fa5105b20a --- /dev/null +++ b/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/payment-request/algorithms-manual.https.html b/payment-request/algorithms-manual.https.html new file mode 100644 index 00000000000000..b90c312aba3bf4 --- /dev/null +++ b/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/payment-request/billing-address-changed-manual.https.html b/payment-request/billing-address-changed-manual.https.html new file mode 100644 index 00000000000000..d03f7615187eb5 --- /dev/null +++ b/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/payment-request/change-shipping-option-manual.https.html b/payment-request/change-shipping-option-manual.https.html new file mode 100644 index 00000000000000..438001804acdac --- /dev/null +++ b/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/payment-request/change-shipping-option-select-last-manual.https.html b/payment-request/change-shipping-option-select-last-manual.https.html new file mode 100644 index 00000000000000..4ad31d65317338 --- /dev/null +++ b/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/payment-request/dynamically-change-shipping-options-manual.https.html b/payment-request/dynamically-change-shipping-options-manual.https.html new file mode 100644 index 00000000000000..0e6670a1b82452 --- /dev/null +++ b/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/payment-request/historical.https.html b/payment-request/historical.https.html index aa183a58cdb9fc..3e881d0122b413 100644 --- a/payment-request/historical.https.html +++ b/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/payment-request/payment-request-constructor-thcrash.https.html b/payment-request/payment-request-constructor-thcrash.https.html new file mode 100644 index 00000000000000..b6003070851459 --- /dev/null +++ b/payment-request/payment-request-constructor-thcrash.https.html @@ -0,0 +1,254 @@ + + + +Crash tests PaymentRequest Constructor + + + + diff --git a/payment-request/payment-request-constructor.https.sub.html b/payment-request/payment-request-constructor.https.sub.html index c1ecc225838b3b..9b0ad06454f933 100644 --- a/payment-request/payment-request-constructor.https.sub.html +++ b/payment-request/payment-request-constructor.https.sub.html @@ -240,7 +240,7 @@ 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 @@ } }, "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 @@ }); }, "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/payment-request/payment-request-ctor-currency-code-checks.https.sub.html b/payment-request/payment-request-ctor-currency-code-checks.https.sub.html index c608608c7ebdea..b4ca2a0c40b39b 100644 --- a/payment-request/payment-request-ctor-currency-code-checks.https.sub.html +++ b/payment-request/payment-request-ctor-currency-code-checks.https.sub.html @@ -178,6 +178,63 @@ } }, "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/payment-request/payment-request-onshippingaddresschange-attribute.https.html b/payment-request/payment-request-onshippingaddresschange-attribute.https.html new file mode 100644 index 00000000000000..5b2538992f76c7 --- /dev/null +++ b/payment-request/payment-request-onshippingaddresschange-attribute.https.html @@ -0,0 +1,78 @@ + + + +Test for onshippingaddresschange attribute + + + + diff --git a/payment-request/payment-request-onshippingoptionchange-attribute.https.html b/payment-request/payment-request-onshippingoptionchange-attribute.https.html new file mode 100644 index 00000000000000..43ea5dcce87afe --- /dev/null +++ b/payment-request/payment-request-onshippingoptionchange-attribute.https.html @@ -0,0 +1,79 @@ + + + +Test for onshippingoptionchange attribute + + + + diff --git a/payment-request/payment-request-shippingAddress-attribute.https.html b/payment-request/payment-request-shippingAddress-attribute.https.html new file mode 100644 index 00000000000000..08918356b6fea3 --- /dev/null +++ b/payment-request/payment-request-shippingAddress-attribute.https.html @@ -0,0 +1,28 @@ + + + +Test for PaymentRequest shippingAddress attribute + + + + diff --git a/payment-request/payment-request-shippingOption-attribute.https.html b/payment-request/payment-request-shippingOption-attribute.https.html new file mode 100644 index 00000000000000..b5f9ea65c6c8e0 --- /dev/null +++ b/payment-request/payment-request-shippingOption-attribute.https.html @@ -0,0 +1,100 @@ + + + +Test for PaymentRequest shippingOption attribute + + + + diff --git a/payment-request/payment-request-shippingType-attribute.https.html b/payment-request/payment-request-shippingType-attribute.https.html new file mode 100644 index 00000000000000..11f75b1c862224 --- /dev/null +++ b/payment-request/payment-request-shippingType-attribute.https.html @@ -0,0 +1,72 @@ + + + +Test for PaymentRequest's shippingType attribute + + + + diff --git a/payment-request/payment-response/helpers.js b/payment-request/payment-response/helpers.js index 1242ecb743c9a7..3e4f5cfd36f898 100644 --- a/payment-request/payment-response/helpers.js +++ b/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/payment-request/payment-response/retry-method-manual.https.html b/payment-request/payment-response/retry-method-manual.https.html new file mode 100644 index 00000000000000..a5aab49e387d32 --- /dev/null +++ b/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/payment-request/payment-response/retry-method-warnings-manual.https.html b/payment-request/payment-response/retry-method-warnings-manual.https.html new file mode 100644 index 00000000000000..b68bf18309702c --- /dev/null +++ b/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/payment-request/payment-response/shippingAddress-attribute-manual.https.html b/payment-request/payment-response/shippingAddress-attribute-manual.https.html new file mode 100644 index 00000000000000..f9f0a6e4faf2f0 --- /dev/null +++ b/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/payment-request/payment-response/shippingOption-attribute-manual.https.html b/payment-request/payment-response/shippingOption-attribute-manual.https.html new file mode 100644 index 00000000000000..687d3a52de9f6b --- /dev/null +++ b/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/payment-request/shipping-address-changed-manual.https.html b/payment-request/shipping-address-changed-manual.https.html new file mode 100644 index 00000000000000..aad57cd724c69b --- /dev/null +++ b/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/payment-request/show-method-optional-promise-rejects.https.html b/payment-request/show-method-optional-promise-rejects.https.html index 4a41f28fc9be16..3b42965503922d 100644 --- a/payment-request/show-method-optional-promise-rejects.https.html +++ b/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/payment-request/show-method-optional-promise-resolves-manual.https.html b/payment-request/show-method-optional-promise-resolves-manual.https.html new file mode 100644 index 00000000000000..5360a9704af459 --- /dev/null +++ b/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/payment-request/updateWith-method-pmi-handling-manual.https.html b/payment-request/updateWith-method-pmi-handling-manual.https.html new file mode 100644 index 00000000000000..1a52978ca3e312 --- /dev/null +++ b/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/payment-request/user-accepts-payment-request-algo-manual.https.html b/payment-request/user-accepts-payment-request-algo-manual.https.html new file mode 100644 index 00000000000000..300f04811fdf2d --- /dev/null +++ b/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. +