Bug 1532639 [wpt PR 15630] - Add <meta name=timeout content=long> to WPT in SlowTests...
[gecko.git] / testing / web-platform / tests / webauthn / idlharness.https.window.js
bloba228644b8cab9c348a7345a6eb481ced75ded2e5
1 // META: timeout=long
2 // META: script=/resources/WebIDLParser.js
3 // META: script=/resources/idlharness.js
4 // META: script=helpers.js
6 // https://w3c.github.io/webauthn/
8 'use strict';
10 promise_test(() => {
11   const execute_test = () => idl_test(
12     ['webauthn'],
13     ['credential-management'],
14     idlArray => {
15       idlArray.add_untested_idls("[Exposed=(Window,Worker)] interface ArrayBuffer {};");
16       idlArray.add_objects({
17         WebAuthentication: ['navigator.authentication'],
18         PublicKeyCredential: ['cred'],
19         AuthenticatorAssertionResponse: ['assertionResponse']
20       });
21     }
22   );
24   let challengeBytes = new Uint8Array(16);
25   window.crypto.getRandomValues(challengeBytes);
27   return createCredential({
28       options: {
29         publicKey: {
30           timeout: 3000,
31           user: {
32             id: new Uint8Array(16),
33           },
34         }
35       }
36     })
37     .then(cred => {
38       self.cred = cred;
39       return navigator.credentials.get({
40         publicKey: {
41           timeout: 3000,
42           allowCredentials: [{
43             id: cred.rawId,
44             transports: ["usb", "nfc", "ble"],
45             type: "public-key"
46           }],
47           challenge: challengeBytes,
48         }
49       });
50     })
51     .then(assertion => {
52       self.assertionResponse = assertion.response;
53     })
54     .then(execute_test)
55     .catch(reason => {
56       execute_test();
57       return Promise.reject(reason);
58     });
59 });