| <!DOCTYPE html> |
| <meta charset="utf-8"> |
| <title>WebAuthn WebIDL Tests</title> |
| <link rel="author" title="Adam Powers" href="mailto:adam@fidoalliance.org"> |
| <link rel="help" href="https://w3c.github.io/webauthn/#iface-credential"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src=helpers.js></script> |
| <!-- for testing WebIDL --> |
| <script src=/resources/WebIDLParser.js></script> |
| <script src=/resources/idlharness.js></script> |
| <body></body> |
| <script> |
| standardSetup(function() { |
| "use strict"; |
| |
| // loads an IDL file from the webserver |
| function fetchIdl(idlUrl) { |
| return new Promise(function(resolve, reject) { |
| if (typeof idlUrl !== "string") { |
| return reject("fetchIdl: expected argument to be URL string"); |
| } |
| var request = new XMLHttpRequest(); |
| request.open("GET", idlUrl); |
| request.send(); |
| request.onload = function() { |
| var idls = request.responseText; |
| return resolve(idls); |
| }; |
| }); |
| } |
| |
| // this does the real work of running the IDL tests |
| function runIdlTests(idls) { |
| return new Promise(function(resolve, reject) { |
| var idlArray = new window.IdlArray(); |
| |
| // static IDL tests |
| idlArray.add_untested_idls("interface Navigator { };"); |
| // TODO: change to "tested" for real browsers? |
| idlArray.add_untested_idls("partial interface Navigator { readonly attribute WebAuthentication authentication; };"); |
| idlArray.add_objects({ |
| WebAuthentication: ["navigator.authentication"] |
| }); |
| |
| // run test WebIDL tests loaded from the idls file |
| idlArray.add_idls(idls); |
| return resolve(idlArray.test()); |
| }); |
| } |
| |
| // test harness function |
| window.promise_test(function() { |
| return fetchIdl("/interfaces/webauthn.idl") // load the IDL file ... |
| .then(function(idls) { |
| return runIdlTests(idls); // ... then run the tests. |
| }); |
| }, "Validate WebAuthn IDL"); |
| }); |
| </script> |