diff --git a/browser/actors/NetErrorChild.jsm b/browser/actors/NetErrorChild.jsm index 82978412fe24..eea7ddd0cf97 100644 --- a/browser/actors/NetErrorChild.jsm +++ b/browser/actors/NetErrorChild.jsm @@ -24,11 +24,8 @@ class NetErrorChild extends RemotePageChild { actorCreated() { super.actorCreated(); - // If you add a new function, remember to add it to RemotePageAccessManager.jsm - // to allow content-privileged about:neterror or about:certerror to use it. const exportableFunctions = [ "RPMGetAppBuildID", - "RPMGetInnerMostURI", "RPMPrefIsLocked", "RPMAddToHistogram", "RPMRecordTelemetryEvent", @@ -71,15 +68,6 @@ class NetErrorChild extends RemotePageChild { } } - RPMGetInnerMostURI(uriString) { - let uri = Services.io.newURI(uriString); - if (uri instanceof Ci.nsINestedURI) { - uri = uri.QueryInterface(Ci.nsINestedURI).innermostURI; - } - - return uri.spec; - } - RPMGetAppBuildID() { return Services.appinfo.appBuildID; } diff --git a/browser/base/content/aboutNetError.js b/browser/base/content/aboutNetError.js index 75d040e95e5d..b54038018680 100644 --- a/browser/base/content/aboutNetError.js +++ b/browser/base/content/aboutNetError.js @@ -11,8 +11,6 @@ const TLS_ERROR_REPORT_TELEMETRY_AUTO_CHECKED = 2; const TLS_ERROR_REPORT_TELEMETRY_AUTO_UNCHECKED = 3; const TLS_ERROR_REPORT_TELEMETRY_UI_SHOWN = 0; -const HOST_NAME = new URL(RPMGetInnerMostURI(document.location.href)).hostname; - // Used to check if we have a specific localized message for an error. const KNOWN_ERROR_TITLE_IDS = new Set([ // Error titles: @@ -140,7 +138,7 @@ function setupAdvancedButton() { // Get the hostname and add it to the panel var panel = document.getElementById("badCertAdvancedPanel"); for (var span of panel.querySelectorAll("span.hostname")) { - span.textContent = HOST_NAME; + span.textContent = document.location.hostname; } // Register click handler for the weakCryptoAdvancedPanel @@ -432,7 +430,7 @@ function initPage() { var container = document.getElementById("errorLongDesc"); for (var span of container.querySelectorAll("span.hostname")) { - span.textContent = HOST_NAME; + span.textContent = document.location.hostname; } } } @@ -557,8 +555,7 @@ function onSetBlockingReportAutomatic(checked) { } async function setNetErrorMessageFromCode() { - let hostString = HOST_NAME; - + let hostString = document.location.hostname; let port = document.location.port; if (port && port != 443) { hostString += ":" + port; @@ -647,7 +644,7 @@ function initPageCaptivePortal() { function initPageCertError() { document.body.classList.add("certerror"); for (let host of document.querySelectorAll(".hostname")) { - host.textContent = HOST_NAME; + host.textContent = document.location.hostname; } addAutofocus("#returnButton"); @@ -856,11 +853,12 @@ function setCertErrorDetails(event) { // without replicating the complex logic from certverifier code. case "MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED": desc = document.getElementById("errorShortDescText2"); + let hostname = document.location.hostname; document.l10n.setAttributes( desc, "cert-error-symantec-distrust-description", { - HOST_NAME, + hostname, } ); @@ -1000,7 +998,7 @@ function setCertErrorDetails(event) { sd.innerHTML = errDesc.innerHTML; let span = sd.querySelector(".hostname"); - span.textContent = HOST_NAME; + span.textContent = document.location.hostname; // The secondary description mentions expired certificates explicitly // and should only be shown if the certificate has actually expired @@ -1090,7 +1088,7 @@ async function setTechnicalDetailsOnCertError( let cssClass = getCSSClass(); let error = getErrorCode(); - let hostString = HOST_NAME; + let hostString = document.location.hostname; let port = document.location.port; if (port && port != 443) { hostString += ":" + port; @@ -1156,7 +1154,7 @@ async function setTechnicalDetailsOnCertError( // Let's check if we want to make this a link. let okHost = failedCertInfo.subjectAltNames; let href = ""; - let thisHost = HOST_NAME; + let thisHost = document.location.hostname; let proto = document.location.protocol + "//"; // If okHost is a wildcard domain ("*.example.com") let's // use "www" instead. "*.example.com" isn't going to diff --git a/browser/base/content/test/about/browser_aboutCertError.js b/browser/base/content/test/about/browser_aboutCertError.js index d0ab759831bc..a7d92d082e06 100644 --- a/browser/base/content/test/about/browser_aboutCertError.js +++ b/browser/base/content/test/about/browser_aboutCertError.js @@ -528,77 +528,3 @@ add_task(async function checkSandboxedIframe() { }); BrowserTestUtils.removeTab(gBrowser.selectedTab); }); - -add_task(async function checkViewSource() { - info( - "Loading a bad sts cert error in a sandboxed iframe and check that the correct headline is shown" - ); - let uri = "view-source:" + BAD_CERT; - let tab = await openErrorPage(uri); - let browser = tab.linkedBrowser; - - await SpecialPowers.spawn(browser, [], async function() { - let doc = content.document; - - // Wait until fluent sets the errorCode inner text. - let el; - await ContentTaskUtils.waitForCondition(() => { - el = doc.getElementById("errorCode"); - return el.textContent != ""; - }, "error code has been set inside the advanced button panel"); - Assert.equal( - el.textContent, - "SEC_ERROR_EXPIRED_CERTIFICATE", - "Correct error message found" - ); - Assert.equal(el.tagName, "a", "Error message is a link"); - - let titleText = doc.querySelector(".title-text"); - Assert.equal( - titleText.textContent, - "Warning: Potential Security Risk Ahead" - ); - - let shortDescText = doc.getElementById("errorShortDescText"); - Assert.ok( - shortDescText.textContent.includes("expired.example.com"), - "Should list hostname in error message." - ); - - let whatToDoText = doc.getElementById("errorWhatToDoText"); - Assert.ok( - whatToDoText.textContent.includes("expired.example.com"), - "Should list hostname in what to do text." - ); - }); - - let loaded = BrowserTestUtils.browserLoaded(browser, false, uri); - info("Clicking the exceptionDialogButton in advanced panel"); - await SpecialPowers.spawn(browser, [], async function() { - let doc = content.document; - let exceptionButton = doc.getElementById("exceptionDialogButton"); - exceptionButton.click(); - }); - - info("Loading the url after adding exception"); - await loaded; - - await SpecialPowers.spawn(browser, [], async function() { - let doc = content.document; - ok( - !doc.documentURI.startsWith("about:certerror"), - "Exception has been added" - ); - }); - - let certOverrideService = Cc[ - "@mozilla.org/security/certoverride;1" - ].getService(Ci.nsICertOverrideService); - certOverrideService.clearValidityOverride("expired.example.com", -1); - - loaded = BrowserTestUtils.waitForErrorPage(browser); - BrowserReloadSkipCache(); - await loaded; - - BrowserTestUtils.removeTab(gBrowser.selectedTab); -}); diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 38feff6b2275..a84f81fef2e9 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -1480,17 +1480,10 @@ already_AddRefed Document::AddCertException( promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR); return promise.forget(); } - - nsCOMPtr innerURI = NS_GetInnermostURI(failedChannelURI); - if (!innerURI) { - promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR); - return promise.forget(); - } - nsAutoCString host; - innerURI->GetAsciiHost(host); + failedChannelURI->GetAsciiHost(host); int32_t port; - innerURI->GetPort(&port); + failedChannelURI->GetPort(&port); tsi = do_QueryInterface(info); if (NS_WARN_IF(!tsi)) { diff --git a/toolkit/modules/RemotePageAccessManager.jsm b/toolkit/modules/RemotePageAccessManager.jsm index aa6601cf7db6..c9983151407a 100644 --- a/toolkit/modules/RemotePageAccessManager.jsm +++ b/toolkit/modules/RemotePageAccessManager.jsm @@ -62,7 +62,6 @@ let RemotePageAccessManager = { "services.settings.last_update_seconds", ], RPMGetAppBuildID: ["*"], - RPMGetInnerMostURI: ["*"], RPMIsWindowPrivate: ["*"], RPMAddToHistogram: ["*"], }, diff --git a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js index 5f3cb199af4a..dd5c5fdbe1b0 100644 --- a/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js +++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/environments/frame-script.js @@ -24,7 +24,6 @@ module.exports = { sendSyncMessage: false, tabEventTarget: false, RPMGetAppBuildID: false, - RPMGetInnerMostURI: false, RPMGetIntPref: false, RPMGetStringPref: false, RPMGetBoolPref: false,