Bug 1273255 - Don't try alternate URIs at the end of pageload if the channel was redirected: we don't want to be applying that sort of fixup to the redirect target URI. r=smaug

This commit is contained in:
Gijs Kruitbosch 2016-05-19 22:29:04 +01:00
parent ee97bc5aed
commit 23ed0206bf
4 changed files with 41 additions and 0 deletions

View File

@ -7761,6 +7761,16 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
doCreateAlternate = false;
}
}
if (doCreateAlternate) {
// Skip doing this if our channel was redirected, because we
// shouldn't be guessing things about the post-redirect URI.
nsLoadFlags loadFlags = 0;
if (NS_FAILED(aChannel->GetLoadFlags(&loadFlags)) ||
(loadFlags & nsIChannel::LOAD_REPLACE)) {
doCreateAlternate = false;
}
}
}
if (doCreateAlternate) {
newURI = nullptr;

View File

@ -76,6 +76,9 @@ skip-if = buildapp == 'mulet'
[browser_bug852909.js]
[browser_bug92473.js]
[browser_uriFixupIntegration.js]
[browser_uriFixupAlternateRedirects.js]
support-files =
redirect_to_example.sjs
[browser_loadDisallowInherit.js]
[browser_loadURI.js]
[browser_multiple_pushState.js]

View File

@ -0,0 +1,24 @@
"use strict";
const REDIRECTURL = "http://www.example.com/browser/docshell/test/browser/redirect_to_example.sjs"
add_task(function* () {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
gURLBar.value = REDIRECTURL;
gURLBar.select();
let errorPageLoaded = BrowserTestUtils.waitForErrorPage(tab.linkedBrowser);
EventUtils.sendKey("return");
yield errorPageLoaded;
let [contentURL, originalURL] = yield ContentTask.spawn(tab.linkedBrowser, null, () => {
return [
content.document.documentURI,
content.document.mozDocumentURIIfNotForErrorPages.spec,
];
});
info("Page that loaded: " + contentURL);
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/");
yield BrowserTestUtils.removeTab(tab);
});

View File

@ -0,0 +1,4 @@
function handleRequest(request, response) {
response.setStatusLine(request.httpVersion, 302, "Moved Permanently");
response.setHeader("Location", "http://example");
}