mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d
This commit is contained in:
parent
65dd6d4340
commit
ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions
104
tests/wpt/web-platform-tests/webauthn/interfaces.https.html
Normal file
104
tests/wpt/web-platform-tests/webauthn/interfaces.https.html
Normal file
|
@ -0,0 +1,104 @@
|
|||
<!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>
|
||||
<!-- for testing WebIDL -->
|
||||
<script src=/resources/WebIDLParser.js></script>
|
||||
<script src=/resources/idlharness.js></script>
|
||||
<body></body>
|
||||
<script>
|
||||
// IIFE for namespace cleanliness
|
||||
(function() {
|
||||
"use strict";
|
||||
|
||||
|
||||
//************* BEGIN DELETE AFTER 1/1/2017 *************** //
|
||||
// XXX for development mode only!!
|
||||
// debug() for debugging purposes... we can drop this later if it is considered ugly
|
||||
// note that debug is currently an empty function (i.e. - prints no output)
|
||||
// and debug only prints output if the polyfill is loaded
|
||||
var debug = function() {};
|
||||
// if the WebAuthn API doesn't exist load a polyfill for testing
|
||||
// note that the polyfill only gets loaded if navigator.authentication doesn't exist
|
||||
// AND if the polyfill script is found at the right path (i.e. - the polyfill is opt-in)
|
||||
function ensureInterface() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (typeof navigator.authentication !== "object") {
|
||||
debug = console.log;
|
||||
|
||||
// dynamic loading of polyfill script by creating new <script> tag and seeing the src=
|
||||
var scriptElem = document.createElement("script");
|
||||
if (typeof scriptElem !== "object") {
|
||||
debug("ensureInterface: Error creating script element while attempting loading polyfill");
|
||||
return reject(new Error("ensureInterface: Error creating script element while loading polyfill"));
|
||||
}
|
||||
scriptElem.type = "application/javascript";
|
||||
scriptElem.onload = function() {
|
||||
debug("!!! XXX - LOADING POLYFILL FOR WEBAUTHN TESTING - XXX !!!");
|
||||
return resolve();
|
||||
};
|
||||
scriptElem.onerror = function() {
|
||||
return reject(new Error("navigator.authentication does not exist"));
|
||||
};
|
||||
scriptElem.src = "/webauthn/webauthn-polyfill/webauthn-polyfill.js";
|
||||
if (document.body) {
|
||||
document.body.appendChild(scriptElem);
|
||||
} else {
|
||||
debug("ensureInterface: DOM has no body");
|
||||
return reject(new Error("ensureInterface: DOM has no body"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//************* END DELETE AFTER 1/1/2017 *************** //
|
||||
|
||||
// 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 ensureInterface() // ensure we have navigator.authentication ...
|
||||
.then(function() { // ... then load the IDL file ...
|
||||
return fetchIdl("interfaces.idl");
|
||||
})
|
||||
.then(function(idls) { // ... then run the tests.
|
||||
return runIdlTests(idls);
|
||||
});
|
||||
}, "Validate WebAuthn IDL");
|
||||
}());
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue