tor-browser

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

authentication-icon-data-url.https.html (2044B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test for the 'secure-payment-confirmation' payment method authentication - data URL icon</title>
      4 <link rel="help" href="https://w3c.github.io/secure-payment-confirmation#sctn-steps-to-check-if-a-payment-can-be-made">
      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 src="utils.sub.js"></script>
     10 <script>
     11 'use strict';
     12 
     13 promise_test(async t => {
     14  const authenticator = await window.test_driver.add_virtual_authenticator(
     15      AUTHENTICATOR_OPTS);
     16  t.add_cleanup(() => {
     17    return window.test_driver.remove_virtual_authenticator(authenticator);
     18  });
     19 
     20  await window.test_driver.set_spc_transaction_mode("autoAccept");
     21  t.add_cleanup(() => {
     22    return window.test_driver.set_spc_transaction_mode("none");
     23  });
     24 
     25  const credential = await createCredential();
     26 
     27  const challenge = 'server challenge';
     28  const payeeOrigin = 'https://merchant.com';
     29  const displayName = 'Troycard ***1234';
     30  // Use a Data URL for the request, which should be accepted.
     31  const request = new PaymentRequest([{
     32    supportedMethods: 'secure-payment-confirmation',
     33    data: {
     34      credentialIds: [credential.rawId],
     35      challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
     36      payeeOrigin,
     37      rpId: window.location.hostname,
     38      timeout: 60000,
     39      instrument: {
     40        displayName,
     41        icon: ICON_DATA_URL,
     42      },
     43    }
     44  }], PAYMENT_DETAILS);
     45 
     46  await test_driver.bless('user activation');
     47  const responsePromise = request.show();
     48 
     49  const response = await responsePromise;
     50  await response.complete('success');
     51 
     52  const cred = response.details;
     53  assert_equals(cred.id, credential.id);
     54 
     55  const clientDataJSON = JSON.parse(arrayBufferToString(cred.response.clientDataJSON));
     56  assert_equals(clientDataJSON.payment.instrument.icon, ICON_DATA_URL);
     57 }, 'SPC authentication with data URL instrument icon');
     58 </script>