tor-browser

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

payment-request-disallowed-when-hidden.https.html (1548B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test for PaymentRequest.show() method - should fail when tab is not visible</title>
      4 <link rel="help" href="https://w3c.github.io/payment-request/#show-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 <!-- For minimize() -->
     10 <script src="/page-visibility/resources/window_state_context.js"></script>
     11 <script>
     12 'use strict';
     13 
     14 promise_test(async t => {
     15  const {minimize, restore} = window_state_context(t);
     16 
     17  const request = new PaymentRequest([
     18      {
     19        supportedMethods: "https://apple.com/apple-pay",
     20        data: {
     21          version: 3,
     22          merchantIdentifier: "merchant.com.example",
     23          countryCode: "US",
     24          merchantCapabilities: ["supports3DS"],
     25          supportedNetworks: ["visa"],
     26        },
     27      },
     28  ], {
     29      total: {
     30        label: "Total",
     31        amount: {
     32          currency: "USD",
     33          value: "1.00",
     34        },
     35      }
     36  });
     37 
     38  // `bless` simulates a click so it must happen before minimizing the window.
     39  await test_driver.bless('user activation');
     40 
     41  // Before we trigger the Payment Request, minimize the window. This should
     42  // cause the show() call to be rejected.
     43  await minimize();
     44  assert_equals(document.hidden, true);
     45 
     46  return promise_rejects_dom(t, "AbortError", request.show());
     47 }, 'PaymentRequest.show() cannot be triggered from a hidden context');
     48 </script>