tor-browser

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

show-method-postmessage-manual.https.html (1810B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test for PaymentRequest.show() method</title>
      4 <link rel="help" href="https://w3c.github.io/browser-payment-api/#show-method">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script>
      8 "use strict";
      9 setup({
     10  explicit_done: true,
     11  explicit_timeout: true,
     12  allow_uncaught_exception: true,
     13 });
     14 
     15 async function runUserActivation(button) {
     16  button.disabled = true;
     17  const { contentWindow: iframeWindow } = document.getElementById("iframe");
     18  const expectedId = "pass123";
     19  await Promise.resolve(); // next tick
     20  const promiseForResponse = new Promise(resolve => {
     21    window.onmessage = ({ data: { requestId } }) => resolve(requestId);
     22  });
     23  const ops = { id: expectedId, request: "show-payment-request" };
     24  iframeWindow.postMessage(ops, window.location.origin);
     25  promise_test(async () => {
     26    const actualId = await promiseForResponse;
     27    assert_equals(actualId, expectedId, "ids must match");
     28  }, button.textContent.trim());
     29  done();
     30 }
     31 
     32 </script>
     33 <h2>Test PaymentRequest.show() triggered by user activation using postMessage()</h2>
     34 <p>
     35  Tests that user activation works over postMessage().
     36 </p>
     37 <p>
     38  Click on bottom below. Hit "Pay".
     39 </p>
     40 <ol>
     41  <li>
     42    <button onclick="runUserActivation(this)">
     43      show() is triggered by user activation passed through postMessage() and a promise
     44    </button>
     45  </li>
     46 </ol>
     47 <iframe width="100%" id="iframe" src="show-method-postmessage-iframe.html" allow="payment"></iframe>
     48 <p>
     49  <small>
     50    If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a>
     51    and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>.
     52  </small>
     53 </p>