diff --git a/toolkit/actors/NetErrorChild.jsm b/toolkit/actors/NetErrorChild.jsm index 14a7a5bd4da0..d91c84b79bf9 100644 --- a/toolkit/actors/NetErrorChild.jsm +++ b/toolkit/actors/NetErrorChild.jsm @@ -29,7 +29,8 @@ class NetErrorChild extends RemotePageChild { "RPMCheckAlternateHostAvailable", "RPMGetHttpResponseHeader", "RPMIsTRROnlyFailure", - "RPMShowTRROnlyFailureError", + "RPMIsFirefox", + "RPMIsNativeFallbackFailure", "RPMOpenPreferences", "RPMGetTRRSkipReason", "RPMGetTRRDomain", @@ -162,7 +163,7 @@ class NetErrorChild extends RemotePageChild { } RPMIsTRROnlyFailure() { - // As per RPMShowTRROnlyFailureError, we will only show this in Firefox + // We will only show this in Firefox because the options may direct users to settings only available on Firefox Desktop let channel = this.contentWindow?.docShell?.failedChannel?.QueryInterface( Ci.nsIHttpChannelInternal ); @@ -172,10 +173,37 @@ class NetErrorChild extends RemotePageChild { return channel.effectiveTRRMode == Ci.nsIRequest.TRR_ONLY_MODE; } - RPMShowTRROnlyFailureError() { + RPMIsFirefox() { return lazy.AppInfo.isFirefox; } + RPMIsNativeFallbackFailure() { + let channel = this.contentWindow?.docShell?.failedChannel?.QueryInterface( + Ci.nsIHttpChannelInternal + ); + let value = channel?.trrSkipReason ?? Ci.nsITRRSkipReason.TRR_UNSET; + + const warningReasons = new Set([ + Ci.nsITRRSkipReason.TRR_NOT_CONFIRMED, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_GOOGLE_SAFESEARCH, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_YOUTUBE_SAFESEARCH, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_ZSCALER_CANARY, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_CANARY, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_MODIFIED_ROOTS, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_PARENTAL_CONTROLS, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_THIRD_PARTY_ROOTS, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_ENTERPRISE_POLICY, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_VPN, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_PROXY, + Ci.nsITRRSkipReason.TRR_HEURISTIC_TRIPPED_NRPT, + ]); + + return ( + Services.dns.currentTrrMode == Ci.nsIRequest.TRR_FIRST_MODE && + warningReasons.has(value) + ); + } + RPMGetTRRSkipReason() { let channel = this.contentWindow?.docShell?.failedChannel?.QueryInterface( Ci.nsIHttpChannelInternal diff --git a/toolkit/content/aboutNetError.mjs b/toolkit/content/aboutNetError.mjs index 62cdc8a86c49..b2aa548cdcc2 100644 --- a/toolkit/content/aboutNetError.mjs +++ b/toolkit/content/aboutNetError.mjs @@ -239,6 +239,12 @@ function initPage() { const isTRROnlyFailure = gErrorCode == "dnsNotFound" && RPMIsTRROnlyFailure(); + let isNativeFallbackWarning = false; + if (RPMGetBoolPref("network.trr.display_fallback_warning")) { + isNativeFallbackWarning = + gErrorCode == "dnsNotFound" && RPMIsNativeFallbackFailure(); + } + const docTitle = document.querySelector("title"); const bodyTitle = document.querySelector(".title-text"); const shortDesc = document.getElementById("errorShortDesc"); @@ -390,90 +396,99 @@ function initPage() { bodyTitleId = "generic-title"; } - if (isTRROnlyFailure && RPMShowTRROnlyFailureError()) { - document.body.className = "certerror"; // Shows warning icon - pageTitleId = "dns-not-found-trr-only-title"; - document.l10n.setAttributes(docTitle, pageTitleId, { - hostname: HOST_NAME, - }); - bodyTitleId = "dns-not-found-trr-only-title"; - document.l10n.setAttributes(bodyTitle, bodyTitleId, { - hostname: HOST_NAME, - }); - - shortDesc.textContent = ""; - - // enable buttons - let trrExceptionButton = document.getElementById("trrExceptionButton"); - trrExceptionButton.addEventListener("click", () => { - RPMSendQuery("Browser:AddTRRExcludedDomain", { + // The TRR errors may present options that direct users to settings only available on Firefox Desktop + if (RPMIsFirefox()) { + if (isTRROnlyFailure) { + document.body.className = "certerror"; // Shows warning icon + pageTitleId = "dns-not-found-trr-only-title"; + document.l10n.setAttributes(docTitle, pageTitleId, { hostname: HOST_NAME, - }).then(msg => { - retryThis(this); }); - }); - trrExceptionButton.hidden = false; - let trrSettingsButton = document.getElementById("trrSettingsButton"); - trrSettingsButton.addEventListener("click", () => { - RPMSendAsyncMessage("OpenTRRPreferences"); - }); - trrSettingsButton.hidden = false; - let message = document.getElementById("trrOnlyMessage"); - document.l10n.setAttributes( - message, - "neterror-dns-not-found-trr-only-reason", - { + bodyTitleId = "dns-not-found-trr-only-title"; + document.l10n.setAttributes(bodyTitle, bodyTitleId, { hostname: HOST_NAME, + }); + + shortDesc.textContent = ""; + + // enable buttons + let trrExceptionButton = document.getElementById("trrExceptionButton"); + trrExceptionButton.addEventListener("click", () => { + RPMSendQuery("Browser:AddTRRExcludedDomain", { + hostname: HOST_NAME, + }).then(msg => { + retryThis(this); + }); + }); + trrExceptionButton.hidden = false; + let trrSettingsButton = document.getElementById("trrSettingsButton"); + trrSettingsButton.addEventListener("click", () => { + RPMSendAsyncMessage("OpenTRRPreferences"); + }); + trrSettingsButton.hidden = false; + let message = document.getElementById("trrOnlyMessage"); + document.l10n.setAttributes( + message, + "neterror-dns-not-found-trr-only-reason", + { + hostname: HOST_NAME, + } + ); + + let skipReason = RPMGetTRRSkipReason(); + + let descriptionTag = "neterror-dns-not-found-trr-unknown-problem"; + let args = { trrDomain: RPMGetTRRDomain() }; + if ( + skipReason == "TRR_FAILED" || + skipReason == "TRR_CHANNEL_DNS_FAIL" || + skipReason == "TRR_UNKNOWN_CHANNEL_FAILURE" || + skipReason == "TRR_NET_REFUSED" || + skipReason == "TRR_NET_INTERRUPT" || + skipReason == "TRR_NET_INADEQ_SEQURITY" + ) { + descriptionTag = "neterror-dns-not-found-trr-only-could-not-connect"; + } else if (skipReason == "TRR_TIMEOUT") { + descriptionTag = "neterror-dns-not-found-trr-only-timeout"; + } else if ( + skipReason == "TRR_IS_OFFLINE" || + skipReason == "TRR_NO_CONNECTIVITY" + ) { + descriptionTag = "neterror-dns-not-found-trr-offline"; + } else if ( + skipReason == "TRR_NO_ANSWERS" || + skipReason == "TRR_NXDOMAIN" + ) { + descriptionTag = "neterror-dns-not-found-trr-unknown-host"; + } else if ( + skipReason == "TRR_DECODE_FAILED" || + skipReason == "TRR_SERVER_RESPONSE_ERR" + ) { + descriptionTag = "neterror-dns-not-found-trr-server-problem"; } - ); - let skipReason = RPMGetTRRSkipReason(); + let description = document.getElementById("trrOnlyDescription"); + document.l10n.setAttributes(description, descriptionTag, args); - let descriptionTag = "neterror-dns-not-found-trr-unknown-problem"; - let args = { trrDomain: RPMGetTRRDomain() }; - if ( - skipReason == "TRR_FAILED" || - skipReason == "TRR_CHANNEL_DNS_FAIL" || - skipReason == "TRR_UNKNOWN_CHANNEL_FAILURE" || - skipReason == "TRR_NET_REFUSED" || - skipReason == "TRR_NET_INTERRUPT" || - skipReason == "TRR_NET_INADEQ_SEQURITY" - ) { - descriptionTag = "neterror-dns-not-found-trr-only-could-not-connect"; - } else if (skipReason == "TRR_TIMEOUT") { - descriptionTag = "neterror-dns-not-found-trr-only-timeout"; - } else if ( - skipReason == "TRR_IS_OFFLINE" || - skipReason == "TRR_NO_CONNECTIVITY" - ) { - descriptionTag = "neterror-dns-not-found-trr-offline"; - } else if (skipReason == "TRR_NO_ANSWERS" || skipReason == "TRR_NXDOMAIN") { - descriptionTag = "neterror-dns-not-found-trr-unknown-host"; - } else if ( - skipReason == "TRR_DECODE_FAILED" || - skipReason == "TRR_SERVER_RESPONSE_ERR" - ) { - descriptionTag = "neterror-dns-not-found-trr-server-problem"; + const trrLearnMoreContainer = document.getElementById( + "trrLearnMoreContainer" + ); + trrLearnMoreContainer.hidden = false; + let learnMoreLink = document.getElementById("trrOnlylearnMoreLink"); + // This will be replaced at a later point with a link to an offline support page + // https://bugzilla.mozilla.org/show_bug.cgi?id=1806257 + learnMoreLink.href = + RPMGetFormatURLPref("network.trr_ui.skip_reason_learn_more_url") + + skipReason.toLowerCase().replaceAll("_", "-"); + + let div = document.getElementById("trrOnlyContainer"); + div.hidden = false; + + return; + } else if (isNativeFallbackWarning) { + showNativeFallbackWarning(); + return; } - - let description = document.getElementById("trrOnlyDescription"); - document.l10n.setAttributes(description, descriptionTag, args); - - const trrLearnMoreContainer = document.getElementById( - "trrLearnMoreContainer" - ); - trrLearnMoreContainer.hidden = false; - let learnMoreLink = document.getElementById("trrOnlylearnMoreLink"); - // This will be replaced at a later point with a link to an offline support page - // https://bugzilla.mozilla.org/show_bug.cgi?id=1806257 - learnMoreLink.href = - RPMGetFormatURLPref("network.trr_ui.skip_reason_learn_more_url") + - skipReason.toLowerCase().replaceAll("_", "-"); - - let div = document.getElementById("trrOnlyContainer"); - div.hidden = false; - - return; } document.l10n.setAttributes(docTitle, pageTitleId); @@ -490,6 +505,69 @@ function initPage() { setNetErrorMessageFromCode(); } +function showNativeFallbackWarning() { + const docTitle = document.querySelector("title"); + const bodyTitle = document.querySelector(".title-text"); + const shortDesc = document.getElementById("errorShortDesc"); + + let pageTitleId = "neterror-page-title"; + let bodyTitleId = gErrorCode + "-title"; + + document.body.className = "certerror"; // Shows warning icon + pageTitleId = "dns-not-found-native-fallback-title"; + document.l10n.setAttributes(docTitle, pageTitleId, { + hostname: HOST_NAME, + }); + + bodyTitleId = "dns-not-found-native-fallback-title"; + document.l10n.setAttributes(bodyTitle, bodyTitleId, { + hostname: HOST_NAME, + }); + + shortDesc.textContent = ""; + let nativeFallbackIgnoreButton = document.getElementById( + "nativeFallbackIgnoreButton" + ); + nativeFallbackIgnoreButton.addEventListener("click", () => { + RPMSetBoolPref("network.trr.display_fallback_warning", false); + retryThis(nativeFallbackIgnoreButton); + }); + + nativeFallbackIgnoreButton.hidden = false; + let message = document.getElementById("nativeFallbackMessage"); + document.l10n.setAttributes( + message, + "neterror-dns-not-found-native-fallback-reason", + { + hostname: HOST_NAME, + } + ); + let skipReason = RPMGetTRRSkipReason(); + let descriptionTag = "neterror-dns-not-found-trr-unknown-problem"; + let args = { trrDomain: RPMGetTRRDomain() }; + + if (skipReason.includes("HEURISTIC_TRIPPED")) { + descriptionTag = "neterror-dns-not-found-native-fallback-heuristic"; + } else if (skipReason == "TRR_NOT_CONFIRMED") { + descriptionTag = "neterror-dns-not-found-native-fallback-not-confirmed"; + } + + let description = document.getElementById("nativeFallbackDescription"); + document.l10n.setAttributes(description, descriptionTag, args); + + let learnMoreContainer = document.getElementById( + "nativeFallbackLearnMoreContainer" + ); + learnMoreContainer.hidden = false; + + let learnMoreLink = document.getElementById("nativeFallbackLearnMoreLink"); + learnMoreLink.href = + RPMGetFormatURLPref("network.trr_ui.skip_reason_learn_more_url") + + skipReason.toLowerCase().replaceAll("_", "-"); + + let div = document.getElementById("nativeFallbackContainer"); + div.hidden = false; +} /** * Builds HTML elements from `parts` and appends them to `parent`. * diff --git a/toolkit/content/aboutNetError.xhtml b/toolkit/content/aboutNetError.xhtml index 4b5172efea72..8ca1be38da7f 100644 --- a/toolkit/content/aboutNetError.xhtml +++ b/toolkit/content/aboutNetError.xhtml @@ -51,6 +51,17 @@
+
+
+ ++ +
@@ -81,6 +92,7 @@ +