| <!DOCTYPE html> |
| <meta charset="utf-8"> |
| <title>Test for PaymentRequest.abort() method</title> |
| <link rel="help" href="https://w3c.github.io/payment-request/#abort-method"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/resources/testdriver.js"></script> |
| <script src='/resources/testdriver-vendor.js'></script> |
| <script> |
| "use strict"; |
| setup({ |
| // Ignore unhandled rejections resulting from .show()'s acceptPromise |
| // not being explicitly handled. |
| allow_uncaught_exception: true, |
| explicit_timeout: true, |
| }); |
| const basicCard = Object.freeze({ supportedMethods: "basic-card" }); |
| const applePay = Object.freeze({ |
| supportedMethods: "https://apple.com/apple-pay", |
| data: { |
| version: 3, |
| merchantIdentifier: "merchant.com.example", |
| countryCode: "US", |
| merchantCapabilities: ["supports3DS"], |
| supportedNetworks: ["visa"], |
| } |
| }); |
| const defaultMethods = Object.freeze([basicCard, applePay]); |
| const defaultDetails = Object.freeze({ |
| total: { |
| label: "Total", |
| amount: { |
| currency: "USD", |
| value: "1.00", |
| }, |
| }, |
| }); |
| |
| promise_test(async t => { |
| // request is in "created" state |
| const request = new PaymentRequest(defaultMethods, defaultDetails); |
| await promise_rejects(t, "InvalidStateError", request.abort()); |
| }, `Throws if the promise [[state]] is not "interactive"`); |
| |
| promise_test(async t => { |
| const request = new PaymentRequest(defaultMethods, defaultDetails); |
| const promises = new Set([request.abort(), request.abort(), request.abort()]); |
| assert_equals(promises.size, 3, "Must have three unique objects"); |
| }, "Calling abort() multiple times is always a new object."); |
| </script> |
| <small> |
| If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a> |
| and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>. |
| </small> |