From d36ce4559aefeaaaf1d148ec7bbf9623a5bda859 Mon Sep 17 00:00:00 2001 From: Kelsey Gilbert Date: Mon, 3 Apr 2023 23:50:26 +0000 Subject: [PATCH] Bug 1695986 - Delay enabling exceptionDialogButton by pref security.dialog_enable_delay. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D153793 --- toolkit/content/aboutNetError.mjs | 61 +++++++++++++++++++------ toolkit/modules/RemotePageAccessManager.sys.mjs | 1 + 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/toolkit/content/aboutNetError.mjs b/toolkit/content/aboutNetError.mjs index 72ca932e0819..ec9b3da31cb1 100644 --- a/toolkit/content/aboutNetError.mjs +++ b/toolkit/content/aboutNetError.mjs @@ -156,26 +156,62 @@ function setupAdvancedButton() { .addEventListener("click", togglePanelVisibility); function togglePanelVisibility() { - panel.hidden = !panel.hidden; + if (panel.hidden) { + // Reveal + revealAdvancedPanelSlowlyAsync(); - // Toggling the advanced panel must ensure that the debugging - // information panel is hidden as well, since it's opened by the - // error code link in the advanced panel. - toggleCertErrorDebugInfoVisibility(false); - - if (!panel.hidden) { // send event to trigger telemetry ping document.dispatchEvent( new CustomEvent("AboutNetErrorUIExpanded", { bubbles: true }) ); + } else { + // Hide + panel.hidden = true; } } if (getCSSClass() == "expertBadCert") { - panel.hidden = false; + revealAdvancedPanelSlowlyAsync(); } } +async function revealAdvancedPanelSlowlyAsync() { + const badCertAdvancedPanel = document.getElementById("badCertAdvancedPanel"); + const exceptionDialogButton = document.getElementById( + "exceptionDialogButton" + ); + + // Toggling the advanced panel must ensure that the debugging + // information panel is hidden as well, since it's opened by the + // error code link in the advanced panel. + toggleCertErrorDebugInfoVisibility(false); + + // Reveal, but disabled (and grayed-out) for 3.0s. + badCertAdvancedPanel.hidden = false; + exceptionDialogButton.disabled = true; + + // - + + if (exceptionDialogButton.resetReveal) { + exceptionDialogButton.resetReveal(); // Reset if previous is pending. + } + let wasReset = false; + exceptionDialogButton.resetReveal = () => { + wasReset = true; + }; + + // Wait another Nms (default: 1000) for the user to be very sure. (Sorry speed readers!) + const securityDelayMs = RPMGetIntPref("security.dialog_enable_delay", 1000); + await new Promise(go => setTimeout(go, securityDelayMs)); + + if (wasReset) { + return; + } + + // Enable and un-gray-out. + exceptionDialogButton.disabled = false; +} + function disallowCertOverridesIfNeeded() { // Disallow overrides if this is a Strict-Transport-Security // host and the cert is bad (STS Spec section 7.3) or if the @@ -1262,7 +1298,7 @@ function setTechnicalDetailsOnCertError( technicalInfo.addEventListener("click", event => { if (event.target.id === "errorCode") { event.preventDefault(); - toggleCertErrorDebugInfoVisibility(); + revealAdvancedPanelSlowlyAsync(); recordClickTelemetry(event); } }); @@ -1389,12 +1425,7 @@ function setTechnicalDetailsOnCertError( // If we set a link, meaning there's something helpful for // the user here, expand the section by default if (getCSSClass() != "expertBadCert") { - document.getElementById("badCertAdvancedPanel").hidden = false; - - // Toggling the advanced panel must ensure that the debugging - // information panel is hidden as well, since it's opened by the - // error code link in the advanced panel. - toggleCertErrorDebugInfoVisibility(false); + revealAdvancedPanelSlowlyAsync(); } } else { addLabel("cert-error-domain-mismatch-single-nolink", l10nArgs); diff --git a/toolkit/modules/RemotePageAccessManager.sys.mjs b/toolkit/modules/RemotePageAccessManager.sys.mjs index 06830c171c14..bc765da92f3b 100644 --- a/toolkit/modules/RemotePageAccessManager.sys.mjs +++ b/toolkit/modules/RemotePageAccessManager.sys.mjs @@ -51,6 +51,7 @@ export let RemotePageAccessManager = { "network.trr.display_fallback_warning", ], RPMGetIntPref: [ + "security.dialog_enable_delay", "services.settings.clock_skew_seconds", "services.settings.last_update_seconds", ], -- 2.11.4.GIT