diff --git a/browser/base/content/test/siteIdentity/browser_check_identity_state.js b/browser/base/content/test/siteIdentity/browser_check_identity_state.js index d9e40083086c..5b61688b8606 100644 --- a/browser/base/content/test/siteIdentity/browser_check_identity_state.js +++ b/browser/base/content/test/siteIdentity/browser_check_identity_state.js @@ -4,7 +4,7 @@ "use strict"; -const DUMMY = "browser/browser/base/content/test/siteIdentity/dummy_page.html" +const DUMMY = "browser/browser/base/content/test/general/dummy_page.html"; const INSECURE_ICON_PREF = "security.insecure_connection_icon.enabled"; const INSECURE_PBMODE_ICON_PREF = "security.insecure_connection_icon.pbmode.enabled"; @@ -233,35 +233,6 @@ add_task(async function test_about_net_error_uri() { await noCertErrorTest(false); }); -async function noCertErrorFromNavigationTest(secureCheck) { - let oldTab = gBrowser.selectedTab; - await SpecialPowers.pushPrefEnv({set: [[INSECURE_ICON_PREF, secureCheck]]}); - let newTab = await loadNewTab("http://example.com/" + DUMMY); - - let promise = BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser); - await ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { - content.document.getElementById("no-cert").click(); - }); - await promise; - await ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { - is(content.window.location.href, "https://nocert.example.com/", "Should be the cert error URL"); - }); - - - is(newTab.linkedBrowser.documentURI.spec.startsWith("about:certerror?"), true, "Should be an about:certerror"); - is(getIdentityMode(), "unknownIdentity", "Identity should be unknown"); - is(getConnectionState(), "not-secure", "Connection should be file"); - - gBrowser.removeTab(newTab); - - await SpecialPowers.popPrefEnv(); -} - -add_task(async function test_about_net_error_uri_from_navigation_tab() { - await noCertErrorFromNavigationTest(true); - await noCertErrorFromNavigationTest(false); -}); - async function aboutUriTest(secureCheck) { let oldTab = gBrowser.selectedTab; await SpecialPowers.pushPrefEnv({set: [[INSECURE_ICON_PREF, secureCheck]]}); diff --git a/browser/base/content/test/siteIdentity/dummy_page.html b/browser/base/content/test/siteIdentity/dummy_page.html index a7747a0bca47..1a87e28408d0 100644 --- a/browser/base/content/test/siteIdentity/dummy_page.html +++ b/browser/base/content/test/siteIdentity/dummy_page.html @@ -4,7 +4,6 @@ - No Cert page

Dummy test page

diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index d4b645d0fb6e..b852c914bcc0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9365,9 +9365,6 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType, // OnLoadingSite(), but don't fire OnLocationChange() // notifications before we've called Embed(). See bug 284993. mURIResultedInDocument = true; - bool errorOnLocationChangeNeeded = false; - nsCOMPtr failedChannel = mFailedChannel; - nsCOMPtr failedURI; if (mLoadType == LOAD_ERROR_PAGE) { // We need to set the SH entry and our current URI here and not @@ -9378,15 +9375,17 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType, // following function calls need it. mLoadType = mFailedLoadType; + nsCOMPtr failedChannel = mFailedChannel; nsIDocument* doc = viewer->GetDocument(); if (doc) { doc->SetFailedChannel(failedChannel); } + // Make sure we have a URI to set currentURI. + nsCOMPtr failedURI; nsCOMPtr triggeringPrincipal; if (failedChannel) { - // Make sure we have a URI to set currentURI. NS_GetFinalChannelURI(failedChannel, getter_AddRefs(failedURI)); } else { @@ -9412,9 +9411,14 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType, // Create an shistory entry for the old load. if (failedURI) { - errorOnLocationChangeNeeded = OnNewURI( + bool errorOnLocationChangeNeeded = OnNewURI( failedURI, failedChannel, triggeringPrincipal, nullptr, mLoadType, false, false, false); + + if (errorOnLocationChangeNeeded) { + FireOnLocationChange(this, failedChannel, failedURI, + LOCATION_CHANGE_ERROR_PAGE); + } } // Be sure to have a correct mLSHE, it may have been cleared by @@ -9505,10 +9509,7 @@ nsDocShell::CreateContentViewer(const nsACString& aContentType, FavorPerformanceHint(true); } - if (errorOnLocationChangeNeeded) { - FireOnLocationChange(this, failedChannel, failedURI, - LOCATION_CHANGE_ERROR_PAGE); - } else if (onLocationChangeNeeded) { + if (onLocationChangeNeeded) { FireOnLocationChange(this, aRequest, mCurrentURI, 0); } diff --git a/docshell/test/browser/browser_uriFixupAlternateRedirects.js b/docshell/test/browser/browser_uriFixupAlternateRedirects.js index 8931109416c6..de46466f8af2 100644 --- a/docshell/test/browser/browser_uriFixupAlternateRedirects.js +++ b/docshell/test/browser/browser_uriFixupAlternateRedirects.js @@ -16,12 +16,7 @@ add_task(async function() { ]; }); info("Page that loaded: " + contentURL); - const errorURI = "about:neterror?"; - ok(contentURL.startsWith(errorURI), "Should be on an error page"); - - const contentPrincipal = tab.linkedBrowser.contentPrincipal; - ok(contentPrincipal.URI.spec.startsWith(errorURI), "Principal should be for the error page"); - + ok(contentURL.startsWith("about:neterror?"), "Should be on an error page"); originalURL = new URL(originalURL); is(originalURL.host, "example", "Should be an error for http://example, not http://www.example.com/");