tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

payment-request-hasenrolledinstrument-method-protection.tentative.https.html (2005B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Tests for PaymentRequest.hasEnrolledInstrument() method</title>
      4 <link rel="help" href="https://w3c.github.io/payment-request/#hasenrolledinstrument-method">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/resources/testdriver.js"></script>
      8 <script src='/resources/testdriver-vendor.js'></script>
      9 <script>
     10 const visaMethod = Object.freeze({
     11    supportedMethods: "basic-card",
     12    data: {
     13      supportedNetworks: ['visa']
     14    }
     15 });
     16 const mastercardMethod = Object.freeze({
     17    supportedMethods: "basic-card",
     18    data: {
     19      supportedNetworks: ['mastercard']
     20    }
     21 });
     22 const defaultDetails = Object.freeze({
     23  total: {
     24    label: "Total",
     25    amount: {
     26      currency: "USD",
     27      value: "1.00",
     28    },
     29  },
     30 });
     31 
     32 promise_test(async t => {
     33  // This test may never actually hit its assertion, but that's allowed.
     34  const request = new PaymentRequest([visaMethod], defaultDetails);
     35  for (let i = 0; i < 1000; i++) {
     36    try {
     37      await request.hasEnrolledInstrument();
     38    } catch (err) {
     39      assert_equals(
     40        err.name,
     41        "NotAllowedError",
     42        "If it throws, then it must be a NotAllowedError."
     43      );
     44      break;
     45    }
     46  }
     47 
     48  for (let i = 0; i < 1000; i++) {
     49    try {
     50      const request2 = new PaymentRequest([mastercardMethod], defaultDetails);
     51      await request2.hasEnrolledInstrument();
     52    } catch (err) {
     53      assert_equals(
     54        err.name,
     55        "NotAllowedError",
     56        "If it throws, then it must be a NotAllowedError."
     57      );
     58      break;
     59    }
     60  }
     61 }, `Optionally, at the user agent's discretion, return a promise rejected with a "NotAllowedError" DOMException.`);
     62 
     63 </script>
     64 
     65 <small>
     66  If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a>
     67  and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>.
     68 </small>