https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 6668ff3716086d3f8efead0f5db2d8d2864c3563 authored by Robert Ma on 21 March 2018, 17:35:46 UTC
Fix resources/test (when running locally)
Tip revision: 6668ff3
interfaces.https.html
<!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>
back to top