gecko-dev/dom/u2f/tests/frame_appid_facet_subdomain...

85 строки
2.6 KiB
HTML

<!DOCTYPE html>
<meta charset=utf-8>
<head>
<script type="text/javascript" src="frame_utils.js"></script>
<script type="text/javascript" src="u2futil.js"></script>
</head>
<body>
<p>AppID / FacetID behavior check for subdomain processing</p>
<script class="testbody" type="text/javascript">
"use strict";
async function doTests() {
var version = "U2F_V2";
var challenge = new Uint8Array(16);
local_is(window.location.origin, "https://test1.example.com", "Is loaded correctly");
// same domain check
await promiseU2FRegister("https://test1.example.com/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
local_is(res.errorCode, 0, "AppID should work from a different path of this domain");
});
// same domain check, but wrong scheme
await promiseU2FRegister("http://test1.example.com/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
local_isnot(res.errorCode, 0, "AppID should not work when using a different scheme");
});
// eTLD+1 subdomain check
await promiseU2FRegister("https://example.com/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
// Changed in Bug 1244959 to behave like W3C Web Authentication
local_is(res.errorCode, 0, "AppID should work from another subdomain in this registered domain");
});
// sub-subdomain check
await promiseU2FRegister("https://sub.test1.example.com/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
// Changed in Bug 1244959 to behave like W3C Web Authentication
local_is(res.errorCode, 0, "AppID should work from a sub-subdomain");
});
// sub-subdomain check
await promiseU2FRegister("https://test2.example.com/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
// Changed in Bug 1244959 to behave like W3C Web Authentication
local_is(res.errorCode, 0, "AppID should work from another subdomain of the eTLD+1");
});
// other domain check
await promiseU2FRegister("https://mochi.test:8888/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
local_isnot(res.errorCode, 0, "AppID should not work from other domains");
});
// TLD check
await promiseU2FRegister("https://com:8888/appId", [{
version: version,
challenge: bytesToBase64UrlSafe(challenge),
}], [], function(res){
local_isnot(res.errorCode, 0, "AppID should not work from the eTLD itself");
});
local_finished();
};
doTests();
</script>
</body>
</html>