payerdetailschange-updateWith-manual.https.html (1776B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>Dispatching PaymentRequestUpdateEvent for "payerdetailschange"</title> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <script src="helpers.js"></script> 7 <script> 8 function runTest(button) { 9 button.disabled = true; 10 promise_test(async t => { 11 const response = await getPaymentResponse({ requestPayerName: true }); 12 const eventPromise = new Promise((_, reject) => { 13 response.addEventListener("payerdetailchange", ev => { 14 // [[waitForUpdate]] becomes true... 15 ev.updateWith({}); 16 // So calling it again throws "InvalidStateError". 17 try { 18 ev.updateWith({}); 19 } catch (err) { 20 reject(err); 21 } 22 }); 23 }); 24 await response.retry({ 25 payer: { name: "Change me!" }, 26 }); 27 await promise_rejects_dom(t, "InvalidStateError", eventPromise); 28 await response.complete("success"); 29 }, button.textContent.trim()); 30 } 31 </script> 32 <h2>Handling PaymentResponse.prototype.onpayerdetailchange events</h2> 33 <p> 34 The test brings up the Payment Request UI window. 35 When shown the payment sheet, use any details and hit pay. 36 </p> 37 <p> 38 When asked to retry the payment: 39 </p> 40 <ol> 41 <li> 42 <p> 43 Change payer's name to anything. 44 </p> 45 <button onclick="runTest(this);"> 46 Calling PaymentRequestUpdateEvent updateWith() twice throws an "InvalidStateError". 47 </button> 48 </li> 49 <li> 50 <button onclick="done();">DONE!</button> 51 </li> 52 </ol> 53 <small> 54 If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a> 55 and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">owners</a>. 56 </small>