summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webauthn/getcredential-timeout.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/webauthn/getcredential-timeout.https.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webauthn/getcredential-timeout.https.html')
-rw-r--r--testing/web-platform/tests/webauthn/getcredential-timeout.https.html72
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webauthn/getcredential-timeout.https.html b/testing/web-platform/tests/webauthn/getcredential-timeout.https.html
new file mode 100644
index 0000000000..c4d8aed38c
--- /dev/null
+++ b/testing/web-platform/tests/webauthn/getcredential-timeout.https.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>WebAuthn navigator.credentials.get() timeout Tests</title>
+<meta name="timeout" content="long">
+<link rel="author" title="Adam Powers" href="mailto:adam@fidoalliance.org">
+<link rel="help" href="https://w3c.github.io/webauthn/#iface-credential">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src=helpers.js></script>
+<body></body>
+<script>
+promise_test(async t => {
+ "use strict";
+
+ let credentialId;
+ try {
+ // if available, set up a mock authenticator that does not respond to user input with a credential
+ let authenticator = await window.test_driver.add_virtual_authenticator({
+ protocol: "ctap1/u2f",
+ transport: "usb",
+ isUserConsenting: false,
+ });
+ t.add_cleanup(() => window.test_driver.remove_virtual_authenticator(authenticator));
+ const private_key =
+ "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Q"
+ + "hk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwU"
+ + "RmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB";
+ credentialId = new Uint8Array([..."cred-1"].map(c => c.charCodeAt(0)));
+ await window.test_driver.add_credential(authenticator, {
+ credentialId: btoa("cred-1"),
+ rpId: window.location.hostname,
+ privateKey: private_key,
+ signCount: 0,
+ isResidentCredential: false,
+ });
+ } catch (error) {
+ if (error !== "error: Action add_virtual_authenticator not implemented") {
+ throw error;
+ }
+ // configure a manual authenticator by creating a credential.
+ credentialId = (await createCredential()).rawId;
+ }
+
+ // bad timeout values
+ // TODO: there is some debate as to whether MAX_UNSIGNED_LONG + 1 and / or -1 should be disallowed since they get converted to valid values internally
+ // new GetCredentialsTest({path: "options.publicKey.timeout", value: -1})
+ // .addCredential(credPromise)
+ // .runTest("Bad timeout: negative", TypeError);
+ // new GetCredentialsTest({path: "options.publicKey.timeout", value: 4294967295 + 1})
+ // .addCredential(credPromise)
+ // .runTest("Bad timeout: too big", TypeError);
+
+ // timeout test
+ return promise_rejects_dom(t, "NotAllowedError", navigator.credentials.get({
+ publicKey: {
+ challenge: new Uint8Array([1, 2, 3]),
+ allowCredentials: [{
+ id: credentialId,
+ type: "public-key",
+ }],
+ timeout: 1,
+ },
+ }));
+ // TODO: createCredential.timeout > 1s && setTimeout < 1s
+ // TODO: createCredential.timeout < 5s && setTimeout > 5s
+});
+
+/* JSHINT */
+/* globals standardSetup, GetCredentialsTest, createCredential, promise_rejects_dom */
+</script>