tor-browser

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

authentication-auth-another-way.https.html (2661B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Test for the 'secure-payment-confirmation' payment method authentication - user wants to auth another way case</title>
      4 <link rel="help" href="https://w3c.github.io/secure-payment-confirmation/#sctn-transaction-confirmation-outcome">
      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  await window.test_driver.set_spc_transaction_mode("autoChooseToAuthAnotherWay");
     15  t.add_cleanup(() => {
     16    return window.test_driver.set_spc_transaction_mode("none");
     17  });
     18 
     19  const challenge = 'server challenge';
     20  const payeeOrigin = 'https://merchant.com';
     21  const displayName = 'Troycard ***1234';
     22  const request = new PaymentRequest([{
     23    supportedMethods: 'secure-payment-confirmation',
     24    data: {
     25      credentialIds: [Uint8Array.from('nonexistent', c => c.charCodeAt(0))],
     26      challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
     27      rpId: window.location.hostname,
     28      payeeOrigin,
     29      timeout: 60000,
     30      instrument: {
     31        displayName,
     32        icon: ICON_URL,
     33      },
     34    }
     35  }], PAYMENT_DETAILS);
     36 
     37  await test_driver.bless('user activation');
     38  return promise_rejects_dom(t, "NotAllowedError", request.show());
     39 }, 'Choose to auth another way without matching credential');
     40 
     41 promise_test(async t => {
     42  const authenticator = await window.test_driver.add_virtual_authenticator(
     43      AUTHENTICATOR_OPTS);
     44  t.add_cleanup(() => {
     45    return window.test_driver.remove_virtual_authenticator(authenticator);
     46  });
     47 
     48  await window.test_driver.set_spc_transaction_mode("autoChooseToAuthAnotherWay");
     49  t.add_cleanup(() => {
     50    return window.test_driver.set_spc_transaction_mode("none");
     51  });
     52 
     53  const credential = await createCredential();
     54 
     55  const challenge = 'server challenge';
     56  const payeeOrigin = 'https://merchant.com';
     57  const displayName = 'Troycard ***1234';
     58  const request = new PaymentRequest([{
     59    supportedMethods: 'secure-payment-confirmation',
     60    data: {
     61      credentialIds: [credential.rawId],
     62      challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)),
     63      rpId: window.location.hostname,
     64      payeeOrigin,
     65      timeout: 60000,
     66      instrument: {
     67        displayName,
     68        icon: ICON_URL,
     69      },
     70    }
     71  }], PAYMENT_DETAILS);
     72 
     73  await test_driver.bless('user activation');
     74  return promise_rejects_dom(t, "NotAllowedError", request.show());
     75 }, 'Choose to auth another way when credential matched');
     76 </script>