From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../https-only/browser_continue_button_delay.js | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 dom/security/test/https-only/browser_continue_button_delay.js (limited to 'dom/security/test/https-only/browser_continue_button_delay.js') 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(); +}); -- cgit v1.2.3