summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/payment-request/payment-response/helpers.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/payment-request/payment-response/helpers.js')
-rw-r--r--testing/web-platform/tests/payment-request/payment-response/helpers.js40
1 files changed, 40 insertions, 0 deletions
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());
}