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-only/browser_continue_button_delay.js | |
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 '')
-rw-r--r-- | dom/security/test/https-only/browser_continue_button_delay.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/dom/security/test/https-only/browser_continue_button_delay.js b/dom/security/test/https-only/browser_continue_button_delay.js new file mode 100644 index 0000000000..6bdee1610e --- /dev/null +++ b/dom/security/test/https-only/browser_continue_button_delay.js @@ -0,0 +1,59 @@ +"use strict"; + +function waitForEnabledButton() { + return new Promise(resolve => { + const button = content.document.getElementById("openInsecure"); + const observer = new content.MutationObserver(mutations => { + for (const mutation of mutations) { + if ( + mutation.type === "attributes" && + mutation.attributeName === "inert" && + !mutation.target.inert + ) { + resolve(); + } + } + }); + observer.observe(button, { attributeFilter: ["inert"] }); + ok( + button.inert, + "The 'Continue to HTTP Site' button should be inert right after the error page is loaded." + ); + }); +} + +add_task(async function () { + waitForExplicitFinish(); + + await SpecialPowers.pushPrefEnv({ + set: [["dom.security.https_only_mode", true]], + }); + + const specifiedDelay = Services.prefs.getIntPref( + "security.dialog_enable_delay", + 1000 + ); + + let loaded = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser); + info("Loading insecure page"); + const startTime = Date.now(); + BrowserTestUtils.startLoadingURIString( + gBrowser, + // We specifically want a insecure url here that will fail to upgrade + // eslint-disable-next-line @microsoft/sdl/no-insecure-url + "http://untrusted.example.com:80" + ); + await loaded; + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], waitForEnabledButton); + const endTime = Date.now(); + + const observedDelay = endTime - startTime; + + Assert.greater( + observedDelay, + specifiedDelay - 100, + `The observed delay (${observedDelay}ms) should be roughly the same or greater than the delay specified in "security.dialog_enable_delay" (${specifiedDelay}ms)` + ); + + finish(); +}); |