tor-browser

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

complete-method-manual.https.html (3554B)


      1 <!doctype html>
      2 <meta charset="utf8">
      3 <link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentresponse-complete()">
      4 <title>
      5  PaymentResponse.prototype.complete() method
      6 </title>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="helpers.js"></script>
     10 <script>
     11 async function runManualTest({ completeWith: result }, button) {
     12  button.disabled = true;
     13  const { response, request } = await getPaymentRequestResponse();
     14  promise_test(async t => {
     15    let completePromise;
     16    let invalidComplete;
     17    let afterComplete;
     18    try {
     19      // We .complete() as normal, using the passed test value
     20      completePromise = response.complete(result);
     21      assert_true(completePromise instanceof Promise, "returns a promise");
     22      // Immediately calling complete() again yields a rejected promise.
     23      invalidComplete = response.complete(result);
     24      await promise_rejects_dom(t, "InvalidStateError", invalidComplete);
     25      // but the original promise is unaffected
     26      const returnedValue = await completePromise;
     27      assert_equals(
     28        returnedValue,
     29        undefined,
     30        "Returned value must always be undefined"
     31      );
     32      // We now call .complete() again, to force an exception
     33      // because [[complete]] is true.
     34      afterComplete = response.complete(result);
     35      await promise_rejects_dom(t, "InvalidStateError", afterComplete);
     36      button.innerHTML = `✅  ${button.textContent}`;
     37    } catch (err) {
     38      button.innerHTML = `❌  ${button.textContent}`;
     39      assert_unreached("Unexpected exception: " + err.message);
     40    }
     41    const allPromises = new Set([
     42      completePromise,
     43      invalidComplete,
     44      afterComplete,
     45    ]);
     46    assert_equals(
     47      allPromises.size,
     48      3,
     49      "Calling complete() multiple times is always a new object."
     50    );
     51  }, button.textContent.trim());
     52 }
     53 </script>
     54 
     55 <h2>
     56    Manual Tests for PaymentResponse.complete() - Please run in order!
     57 </h2>
     58 <p>
     59  Click on each button in sequence from top to bottom without refreshing the page.
     60  Each button will bring up the Payment Request UI window.
     61 </p>
     62 <p>
     63  When presented with the payment sheet, use any credit card select to "Pay".
     64  Also confirm any prompts that come up.
     65 </p>
     66 <ol>
     67  <li>
     68    <button onclick="runManualTest({completeWith: 'success'}, this)">
     69      If the value of the internal slot [[completeCalled]] is true,
     70      reject promise with an "InvalidStateError" DOMException.
     71    </button>
     72  </li>
     73  <li>
     74    <button onclick="runManualTest({completeWith: undefined}, this)">
     75      Passing no argument defaults to "unknown",
     76      eventually closing the sheet and doesn't throw.
     77    </button>
     78  </li>
     79  <li>
     80    <button onclick="runManualTest({completeWith: 'success'}, this)">
     81      Passing "success" eventually closes the sheet and doesn't throw.
     82    </button>
     83  </li>
     84  <li>
     85    <button onclick="runManualTest({completeWith: 'fail'}, this)">
     86      Passing "fail" eventually closes the sheet and doesn't throw.
     87    </button>
     88  </li>
     89  <li>
     90    <button onclick="runManualTest({completeWith: 'unknown'}, this)">
     91      Passing "unknown" eventually closes the sheet and doesn't throw.
     92    </button>
     93  </li>
     94  <li>
     95    <button onclick="done()">Done!</button>
     96  </li>
     97 </ol>
     98 <small>
     99  If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a>
    100  and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>.
    101 </small>