[WebAuthN] Implement PublicKeyCredential’s [[DiscoverFromExternalSource]] with a...
[WebKit-https.git] / LayoutTests / http / tests / webauthn / resources / last-layer-frame.https.html
1 <html>
2 <head>
3     <script src="/js-test-resources/js-test.js"></script>
4     <script src="util.js"></script>
5     <script>
6     function messageToTop(messagePrefix) {
7         top.postMessage(messagePrefix, "https://127.0.0.1:8443");
8     }
9
10     const makeOptions = {
11         publicKey: {
12             rp: {
13                 name: "example.com"
14             },
15             user: {
16                 name: "John Appleseed",
17                 id: asciiToUint8Array("123456"),
18                 displayName: "Appleseed",
19             },
20             challenge: asciiToUint8Array("123456"),
21             pubKeyCredParams: [{ type: "public-key", alg: -7 }]
22         }
23     };
24     const requestOptions = {
25         publicKey: {
26             challenge: asciiToUint8Array("123456"),
27         }
28     };
29
30     navigator.credentials.create(makeOptions).then(
31         function(value) {
32             messageToTop("Access granted. " + value);
33         },
34         function(exception) {
35             if (exception.name == "NotAllowedError")
36                 return navigator.credentials.get(requestOptions)
37             else
38                 messageToTop("Throw " + exception.name  + ".");
39         }
40     ).then(function(value) {
41             messageToTop("Access granted. " + value);
42         },
43         function(exception) {
44             if (exception.name == "NotAllowedError")
45                 messageToTop("PASS Throw NotAllowedError for both PublicKeyCredential's [[create]] and [[get]].");
46             else
47                 messageToTop("Throw " + exception.name  + ".");
48     });
49     </script>
50 </head>
51 </html>