getcredential-timeout.https.html (3021B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>WebAuthn navigator.credentials.get() timeout Tests</title> 4 <meta name="timeout" content="long"> 5 <link rel="author" title="Adam Powers" href="mailto:adam@fidoalliance.org"> 6 <link rel="help" href="https://w3c.github.io/webauthn/#iface-credential"> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src=helpers.js></script> 12 <body></body> 13 <script> 14 promise_test(async t => { 15 "use strict"; 16 17 let credentialId; 18 try { 19 // if available, set up a mock authenticator that does not respond to user input with a credential 20 let authenticator = await window.test_driver.add_virtual_authenticator({ 21 protocol: "ctap1/u2f", 22 transport: "usb", 23 isUserConsenting: false, 24 }); 25 t.add_cleanup(() => window.test_driver.remove_virtual_authenticator(authenticator)); 26 const private_key = 27 "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Q" 28 + "hk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwU" 29 + "RmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB"; 30 credentialId = new Uint8Array([..."cred-1"].map(c => c.charCodeAt(0))); 31 await window.test_driver.add_credential(authenticator, { 32 credentialId: btoa("cred-1"), 33 rpId: window.location.hostname, 34 privateKey: private_key, 35 signCount: 0, 36 isResidentCredential: false, 37 }); 38 } catch (error) { 39 if (error !== "error: Action add_virtual_authenticator not implemented") { 40 throw error; 41 } 42 // configure a manual authenticator by creating a credential. 43 credentialId = (await createCredential()).rawId; 44 } 45 46 // bad timeout values 47 // 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 48 // new GetCredentialsTest({path: "options.publicKey.timeout", value: -1}) 49 // .addCredential(credPromise) 50 // .runTest("Bad timeout: negative", TypeError); 51 // new GetCredentialsTest({path: "options.publicKey.timeout", value: 4294967295 + 1}) 52 // .addCredential(credPromise) 53 // .runTest("Bad timeout: too big", TypeError); 54 55 // timeout test 56 return promise_rejects_dom(t, "NotAllowedError", navigator.credentials.get({ 57 publicKey: { 58 challenge: new Uint8Array([1, 2, 3]), 59 allowCredentials: [{ 60 id: credentialId, 61 type: "public-key", 62 }], 63 timeout: 1, 64 }, 65 })); 66 // TODO: createCredential.timeout > 1s && setTimeout < 1s 67 // TODO: createCredential.timeout < 5s && setTimeout > 5s 68 }); 69 70 /* JSHINT */ 71 /* globals standardSetup, GetCredentialsTest, createCredential, promise_rejects_dom */ 72 </script>