diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/security/test/https-only/test_fragment.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/security/test/https-only/test_fragment.html')
-rw-r--r-- | dom/security/test/https-only/test_fragment.html | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/dom/security/test/https-only/test_fragment.html b/dom/security/test/https-only/test_fragment.html new file mode 100644 index 0000000000..52a63764fb --- /dev/null +++ b/dom/security/test/https-only/test_fragment.html @@ -0,0 +1,72 @@ +<!DOCTYPE HTML> +<html> +<head> +<title>Bug 1694932: Https-only mode reloads the page in certain cases when there should be just a fragment navigation </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: + * Perform a test where a button click leads to scroll the page. Test if https-only detects + * that the redirection address of the button is on the same page. Instead of a reload https-only + * should only scroll. + * + * Test: + * Enable https-only and load the url + * Load: http://mozilla.pettay.fi/moztests/fragment.html + * Click "Click me" + * The page should be scrolled down to 'foo' without a reload + * It shouldn't receive a message 'before unload' because the on before unload + * function in file_fragment.html should not be called + */ + +SimpleTest.waitForExplicitFinish(); + +const REQUEST_URL = "http://example.com/tests/dom/security/test/https-only/file_fragment.html"; +const EXPECT_URL = REQUEST_URL.replace("http://", "https://"); +let winTest = null; +let checkButtonClicked = false; + +async function receiveMessage(event) { + let data = event.data; + // checks if click was successful + if (!checkButtonClicked){ + // expected window location ( expected URL) + ok(data.result == EXPECT_URL, "location is correct"); + ok(data.button, "button is clicked"); + // checks if loading was successful + ok(data.info == "onload", "Onloading worked"); + // button was clicked + checkButtonClicked = true; + return; + } + // if Button was clicked once -> test finished + // check if hash exist and if hash of location is correct + ok(data.button, "button is clicked"); + ok(data.result == EXPECT_URL + "#foo", "location (hash) is correct"); + // check that page is scrolled not reloaded + ok(data.info == "scrolled-to-foo","Scrolled successfully without reloading!"); + is(data.documentURI, EXPECT_URL + "#foo", "Document URI is correct"); + // complete test and close window + window.removeEventListener("message",receiveMessage); + winTest.close(); + SimpleTest.finish(); +} + +async function runTest() { + //Test: With https-only mode activated + await SpecialPowers.pushPrefEnv({ set: [ + ["dom.security.https_only_mode", true], + ]}); + winTest = window.open(REQUEST_URL); +} +window.addEventListener("message", receiveMessage); +runTest(); + +</script> +</body> +</html> |