DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b6d82b1a6b02)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<!DOCTYPE html>
<meta charset=utf-8>
<head>
  <title>Tests for Store for W3C Web Authentication</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>

  <h1>Tests for Store for W3C Web Authentication</h1>
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1309284">Mozilla Bug 1309284</a>

  <script class="testbody" type="text/javascript">
    "use strict";

    function arrivingHereIsBad(aResult) {
      ok(false, "Bad result! Received a: " + aResult);
      return Promise.resolve();
    }

    function expectNotSupportedError(aResult) {
      ok(aResult.toString().startsWith("NotSupportedError"), "Expecting a NotSupportedError, received: " + aResult);
      return Promise.resolve();
    }

    add_task(async function(){
      await SpecialPowers.pushPrefEnv({"set": [["security.webauth.webauthn", true],
                                   ["security.webauth.webauthn_enable_softtoken", true],
                                   ["security.webauth.webauthn_enable_android_fido2", false],
                                   ["security.webauth.webauthn_enable_usbtoken", false]]});

      isnot(navigator.credentials, undefined, "Credential Management API endpoint must exist");
      isnot(navigator.credentials.create, undefined, "CredentialManagement create API endpoint must exist");
      isnot(navigator.credentials.get, undefined, "CredentialManagement get API endpoint must exist");
      isnot(navigator.credentials.store, undefined, "CredentialManagement store API endpoint must exist");

      let credentialChallenge = new Uint8Array(16);
      window.crypto.getRandomValues(credentialChallenge);

      let rp = {id: document.domain, name: "none", icon: "none"};
      let user = {id: new Uint8Array(64), name: "none", icon: "none", displayName: "none"};
      let params = [ {type: "public-key", alg: "es256"}, {type: "public-key", alg: -7} ]

      let makeCredentialOptions = {
        rp: rp, user: user, challenge: credentialChallenge, pubKeyCredParams: params
      };

      let credential = await navigator.credentials.create({publicKey: makeCredentialOptions})
        .catch(arrivingHereIsBad);

      await navigator.credentials.store(credential)
        .then(arrivingHereIsBad)
        .catch(expectNotSupportedError);
    });
  </script>

</body>
</html>