diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /dom/security/test/https-first/test_downgrade_request_upgrade_request.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/security/test/https-first/test_downgrade_request_upgrade_request.html')
-rw-r--r-- | dom/security/test/https-first/test_downgrade_request_upgrade_request.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/dom/security/test/https-first/test_downgrade_request_upgrade_request.html b/dom/security/test/https-first/test_downgrade_request_upgrade_request.html new file mode 100644 index 0000000000..b659636ace --- /dev/null +++ b/dom/security/test/https-first/test_downgrade_request_upgrade_request.html @@ -0,0 +1,52 @@ +<!DOCTYPE HTML> +<html> +<head> +<title> Bug 1706126: Test https-first, downgrade first request and then upgrade redirection to subdomain</title> +<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: + * First we request http://redirect-example.com which HTTPS-First upgrades to https://redirect-example.com. + * The request https://redirect-example.com doesn't receive an answer (timeout), so we send a background + * request. + * The background request receives an answer. So the request https://redirect-example.com gets downgraded + * to http://redirect-example.com by the exempt flag. + * The request http://redirect-example.com gets redirected to http://wwww.redirect-example.com. At that stage + * HTTPS-First should clear the exempt flag and upgrade the redirection to https://wwww.redirect-example.com. + * + */ + +SimpleTest.waitForExplicitFinish(); + +const REQUEST_URL = + "http://redirect-example.com/tests/dom/security/test/https-first/file_downgrade_request_upgrade_request.sjs"; + +let testWin; +window.addEventListener("message", receiveMessage); + +// Receive message and verify that it is from an https site. +async function receiveMessage(event) { + let data = event.data; + ok(data.result === "upgraded", "Redirected successful to 'https' for subdomain "); + is(data.scheme,"https:", "scheme is 'https' for subdomain"); + 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] + ]}, runTest); + +</script> +</body> +</html> |