Source code

Revision control

Copy as Markdown

Other Tools

<!doctype html>
<meta charset="utf8">
User aborts the payment request algorithm.
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
setup({ explicit_done: true, explicit_timeout: true });
const validAmount = Object.freeze({
currency: "USD",
value: "1.0",
const validTotal = Object.freeze({
label: "Total due",
amount: validAmount,
const applePay = Object.freeze({
supportedMethods: "",
data: {
version: 3,
merchantIdentifier: "",
countryCode: "US",
merchantCapabilities: ["supports3DS"],
supportedNetworks: ["visa"],
const validMethod = Object.freeze({
supportedMethods: "basic-card",
const validMethods = Object.freeze([validMethod, applePay]);
const validDetails = Object.freeze({
total: validTotal,
test(() => {
try {
new PaymentRequest(validMethods, validDetails);
} catch (err) {
throw err;
}, "Can construct a payment request (smoke test).");
async function runAbortTest(button) {
button.disabled = true;
const { textContent: testName } = button;
promise_test(async t => {
const request = new PaymentRequest(validMethods, validDetails);
// Await the user to abort
await promise_rejects_dom(t, "AbortError",;
// [[state]] is now closed
await promise_rejects_dom(t, "InvalidStateError",;
}, testName.trim());
User aborts the payment request algorithm.
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, abort the payment request
(e.g., by hitting the esc key or pressing a UA provided button).
<button onclick="runAbortTest(this); done();">
If the user aborts, the UA must run the user aborts the payment request algorithm.
If you find a buggy test, please <a href="">file a bug</a>
and tag one of the <a href="">suggested reviewers</a>.