Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: http3 OR http2
- Manifest: dom/security/test/https-first/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script class="testbody" type="text/javascript">
"use strict";
/*
* Description of the test:
* Open a site with non standard port that answers after 1 sec.
* Expected result: https-first is not timeouting the page and
* doesn't upgrade the request.
*/
SimpleTest.waitForExplicitFinish();
const REQUEST_URL =
let testWin;
window.addEventListener("message", receiveMessage);
// Receive message and verify that it is from an http site.
// When the message is 'downgraded' then it was send by an http site
// and the test worked.
async function receiveMessage(event) {
let data = event.data;
ok(data.result === "downgraded", "Downgraded successful to 'http' for non standard port localhost request");
is(data.scheme,"http:", "scheme is 'http' " );
testWin.close();
window.removeEventListener("message", receiveMessage);
SimpleTest.finish();
}
async function runTest() {
testWin = window.open(REQUEST_URL, "_blank");
}
SpecialPowers.pushPrefEnv({ set: [
["dom.security.https_first", true],
// To speed up the test, tell HTTPS-First to potentially downgrade after 0.1s
["dom.security.https_only_fire_http_request_background_timer_ms", 100]
]}, runTest);
</script>
</body>
</html>