| <input type="text" id="input"> |
| <script> |
| if (window.internals) |
| internals.withUserGesture(() => { input.focus(); }); |
| |
| const options = { |
| publicKey: { |
| rp: { |
| name: "localhost", |
| }, |
| user: { |
| name: "John Appleseed", |
| id: new Uint8Array(16), |
| displayName: "Appleseed", |
| }, |
| challenge: new Uint8Array(16), |
| pubKeyCredParams: [{ type: "public-key", alg: -7 }], |
| timeout: 100, |
| } |
| }; |
| |
| navigator.credentials.create(options).then(credential => { |
| window.webkit.messageHandlers.testHandler.postMessage("Succeeded!"); |
| }, error => { |
| // The first call will consume the freebie, the second will give the no user gesture error. |
| navigator.credentials.create(options).then(credential => { |
| window.webkit.messageHandlers.testHandler.postMessage("Succeeded!"); |
| }, error => { |
| window.webkit.messageHandlers.testHandler.postMessage(error.message); |
| }); |
| window.webkit.messageHandlers.testHandler.postMessage(error.message); |
| }); |
| </script> |