| <html> |
| <head> |
| <script src="/js-test-resources/js-test.js"></script> |
| <script src="util.js"></script> |
| <script> |
| function messageToTop(messagePrefix) { |
| top.postMessage(messagePrefix, "https://127.0.0.1:8443"); |
| } |
| |
| const makeOptions = { |
| publicKey: { |
| rp: { |
| name: "example.com" |
| }, |
| user: { |
| name: "John Appleseed", |
| id: asciiToUint8Array("123456"), |
| displayName: "Appleseed", |
| }, |
| challenge: asciiToUint8Array("123456"), |
| pubKeyCredParams: [{ type: "public-key", alg: -7 }] |
| } |
| }; |
| const requestOptions = { |
| publicKey: { |
| challenge: asciiToUint8Array("123456"), |
| } |
| }; |
| |
| navigator.credentials.create(makeOptions).then( |
| function(value) { |
| messageToTop("Access granted. " + value); |
| }, |
| function(exception) { |
| if (exception.name == "NotAllowedError") |
| return navigator.credentials.get(requestOptions) |
| else |
| messageToTop("Throw " + exception.name + "."); |
| } |
| ).then(function(value) { |
| messageToTop("Access granted. " + value); |
| }, |
| function(exception) { |
| if (exception.name == "NotAllowedError") |
| messageToTop("PASS Throw NotAllowedError for both PublicKeyCredential's [[create]] and [[get]]."); |
| else |
| messageToTop("Throw " + exception.name + "."); |
| }); |
| </script> |
| </head> |
| </html> |