tor-browser

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

empty-data-manual.https.html (3712B)


      1 <!doctype html>
      2 <meta charset="utf8">
      3 <title>Payment Method Basic Card - test passing empty BasicCardRequest members</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script>
      7 setup({ explicit_done: true, explicit_timeout: true });
      8 
      9 const amount = { value: "1.0", currency: "USD" };
     10 const details = {
     11  total: {
     12    label: "Total",
     13    amount,
     14  },
     15 };
     16 const method = {
     17  supportedMethods: "basic-card",
     18 };
     19 
     20 const defaultBillingAddress = {
     21  country: 'AF',
     22  addressLine: '1 wpt street',
     23  region: '',
     24  city: 'Kabul',
     25  dependentLocality: '',
     26  postalCode: '1001',
     27  sortingCode: '',
     28  organization: 'w3c',
     29  recipient: 'web platform test',
     30  phone: '+93555555555',
     31 };
     32 
     33 const visaCredit = {
     34  cardNumber: "4111111111111111",
     35  cardSecurityCode: "123",
     36  cardholderName: "web platform test",
     37  expiryMonth: "01",
     38  expiryYear: "2026",
     39 };
     40 
     41 async function getCardResponse(data) {
     42  const payMethod = Object.assign({ data }, method);
     43  const response = await new PaymentRequest([payMethod], details).show();
     44  await response.complete("success");
     45  return response.details;
     46 }
     47 
     48 /**
     49 * All tests expect the same return data, so we can just check the
     50 * same result over and over again.
     51 */
     52 function runPromiseTest(button, data, expectedCard = visaCredit, expectedAddress = defaultBillingAddress ) {
     53  button.disabled = true;
     54  promise_test(async () => {
     55    const card = await getCardResponse(data);
     56    for (const [member, expectedValue] of Object.entries(expectedCard)) {
     57      const msg = `Expected "card.${member}" to equal "${expectedValue}".`;
     58      assert_equals(card[member], expectedValue, msg);
     59    }
     60    const { billingAddress } = card;
     61    for (const [member, expectedValue] of Object.entries(expectedAddress)) {
     62      const msg = `billingAddress.${member} to equal ${expectedValue}.`;
     63      assert_equals(billingAddress[member], expectedValue);
     64    }
     65  }, button.textContent.trim());
     66 }
     67 </script>
     68 <h2>
     69  Payment Method Basic Card - test passing empty BasicCardRequest values
     70 </h2>
     71 <p>
     72  This test checks that the Basic Card payment handler can accept any card.
     73 </p>
     74 <p>
     75  Click on each button in sequence from top to bottom without refreshing the page.
     76  Each button will bring up the Payment Request UI window.
     77  The test expects the following credit card.
     78 </p>
     79 <ol>
     80  <li>Add card:
     81    <dl>
     82      <dt>Cardholder name:</dt>
     83      <dd>web platform test</dd>
     84      <dt>Card number:</dt>
     85      <dd>4111111111111111</dd>
     86      <dt>Security code (CVV):</dt>
     87      <dd>123</dd>
     88      <dt>Expiry month:</dt>
     89      <dd>01</dd>
     90      <dt>Expiry year:</dt>
     91      <dd>2026</dd>
     92    </dl>
     93  </li>
     94  <li>Add billing address:
     95    <dl>
     96      <dt>Recipient:</dt>
     97      <dd>web platform test</dd>
     98      <dt>Address:</dt>
     99      <dd>1 web st</dd>
    100      <dt>Post code:</dt>
    101      <dd>1234</dd>
    102      <dt>Country:</dt>
    103      <dd>Afghanistan</dd>
    104      <dt>City:</dt>
    105      <dd>w3c</dd>
    106      <dt>Phone</dt>
    107      <dd>+12345678910</dd>
    108    </dl>
    109  </li>
    110 </ol>
    111 <hr>
    112 <ol>
    113  <li>
    114    <button onclick="runPromiseTest(this, {});">
    115      When passed BasicCardRequest without members, allow the user to input a card on any network.
    116    </button>
    117  </li>
    118  <li>
    119    <button onclick="runPromiseTest(this, { supportedNetworks: [] });">
    120      Returns a card on any network, because zero length supportedNetworks.
    121    </button>
    122  </li>
    123  <li>
    124    <button onclick="done();">
    125      Done!
    126    </button>
    127  </li>
    128 </ol>
    129 
    130 <small>
    131  If you find a buggy test, please <a href="https://github.com/web-platform-tests/wpt/issues">file a bug</a>
    132  and tag one of the <a href="https://github.com/web-platform-tests/wpt/blob/master/payment-request/META.yml">suggested reviewers</a>.
    133 </small>