user-abort-algorithm-manual.https.html (2404B)
1 <!doctype html> 2 <meta charset="utf8"> 3 <link rel="help" href="https://w3c.github.io/payment-request/#user-aborts-the-payment-request-algorithm"> 4 <title> 5 User aborts the payment request algorithm. 6 </title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script> 10 setup({ explicit_done: true, explicit_timeout: true }); 11 12 const validAmount = Object.freeze({ 13 currency: "USD", 14 value: "1.0", 15 }); 16 const validTotal = Object.freeze({ 17 label: "Total due", 18 amount: validAmount, 19 }); 20 const applePay = Object.freeze({ 21 supportedMethods: "https://apple.com/apple-pay", 22 data: { 23 version: 3, 24 merchantIdentifier: "merchant.com.example", 25 countryCode: "US", 26 merchantCapabilities: ["supports3DS"], 27 supportedNetworks: ["visa"], 28 } 29 }); 30 const validMethod = Object.freeze({ 31 supportedMethods: "basic-card", 32 }); 33 const validMethods = Object.freeze([validMethod, applePay]); 34 const validDetails = Object.freeze({ 35 total: validTotal, 36 }); 37 38 test(() => { 39 try { 40 new PaymentRequest(validMethods, validDetails); 41 } catch (err) { 42 done(); 43 throw err; 44 } 45 }, "Can construct a payment request (smoke test)."); 46 47 async function runAbortTest(button) { 48 button.disabled = true; 49 const { textContent: testName } = button; 50 promise_test(async t => { 51 const request = new PaymentRequest(validMethods, validDetails); 52 // Await the user to abort 53 await promise_rejects_dom(t, "AbortError", request.show()); 54 // [[state]] is now closed 55 await promise_rejects_dom(t, "InvalidStateError", request.show()); 56 }, testName.trim()); 57 } 58 </script> 59 <h2> 60 User aborts the payment request algorithm. 61 </h2> 62 <p> 63 Click on each button in sequence from top to bottom without refreshing the page. 64 Each button will bring up the Payment Request UI window. 65 </p> 66 <p> 67 When presented with the payment sheet, abort the payment request 68 (e.g., by hitting the esc key or pressing a UA provided button). 69 </p> 70 <ol> 71 <li> 72 <button onclick="runAbortTest(this); done();"> 73 If the user aborts, the UA must run the user aborts the payment request algorithm. 74 </button> 75 </li> 76 </ol> 77 <small> 78 If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a> 79 and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>. 80 </small>