summaryrefslogtreecommitdiffstats
path: root/dom/webauthn/tests/test_webauthn_store_credential.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/webauthn/tests/test_webauthn_store_credential.html
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/webauthn/tests/test_webauthn_store_credential.html')
-rw-r--r--dom/webauthn/tests/test_webauthn_store_credential.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/dom/webauthn/tests/test_webauthn_store_credential.html b/dom/webauthn/tests/test_webauthn_store_credential.html
new file mode 100644
index 0000000000..f19d1d7fa0
--- /dev/null
+++ b/dom/webauthn/tests/test_webauthn_store_credential.html
@@ -0,0 +1,53 @@
+<!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";
+
+ 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");
+
+ 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 test_store_credential() {
+ 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, 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>