Bug 567365 - allow bfcache for no-cache/https r=jduell r=bz

This commit is contained in:
Patrick McManus 2016-01-26 13:27:46 -05:00
parent 181807a4de
commit 519de62f7c
4 changed files with 17 additions and 23 deletions

View File

@ -12541,13 +12541,9 @@ nsDocShell::ShouldDiscardLayoutState(nsIHttpChannel* aChannel)
}
// figure out if SH should be saving layout state
nsCOMPtr<nsISupports> securityInfo;
bool noStore = false, noCache = false;
aChannel->GetSecurityInfo(getter_AddRefs(securityInfo));
bool noStore = false;
aChannel->IsNoStoreResponse(&noStore);
aChannel->IsNoCacheResponse(&noCache);
return (noStore || (noCache && securityInfo));
return noStore;
}
NS_IMETHODIMP

View File

@ -84,8 +84,9 @@
}
function testsIterator() {
// Load a secure page with a no-store header, followed by a simple page
// On pagehide, first page should report it is not being persisted
// Load a secure page with a no-cache header, followed by a simple page.
// no-cache should not interfere with the bfcache in the way no-store
// does.
var test1DocURI = "https://example.com:443/tests/docshell/test/chrome/112564_nocache.html";
gExpected = [{type: "pagehide", persisted: true},
@ -97,18 +98,16 @@
var test2Doc = "data:text/html,<html><head><title>test2</title></head>" +
"<body>test2</body></html>";
gExpected = [{type: "pagehide", title: "test1", persisted: false},
{type: "unload", title: "test1"},
gExpected = [{type: "pagehide", title: "test1", persisted: true},
{type: "load", title: "test2"},
{type: "pageshow", title: "test2", persisted: false}];
gBrowser.loadURI(test2Doc);
yield undefined;
// Now go back in history. First page should not have been cached.
// Now go back in history. First page has been cached.
// Check persisted property to confirm
gExpected = [{type: "pagehide", title: "test2", persisted: true},
{type: "load", title: "test1"},
{type: "pageshow", title: "test1", persisted: false}];
{type: "pageshow", title: "test1", persisted: true}];
gBrowser.goBack();
yield undefined;
}

View File

@ -113,7 +113,8 @@
// https no-cache
testName = "[nocache]";
// Load a page with a no-cache header
// Load a page with a no-cache header. This should not be
// restricted like no-store (bug 567365)
gBrowser.loadURI(nocacheURI);
yield undefined;
@ -141,19 +142,19 @@
yield undefined;
// Now go back in history. First page should not have been cached.
// Now go back in history to the cached page.
gBrowser.goBack();
yield undefined;
// First uncacheable page will now be reloaded. Check scroll position
// restored, and form contents not
// First page will now be reloaded. Check scroll position
// and form contents are restored
is(gBrowser.contentWindow.scrollX, scrollX, testName +
" horizontal axis scroll position not correctly restored");
is(gBrowser.contentWindow.scrollY, scrollY, testName +
" vertical axis scroll position not correctly restored");
var formValue = gBrowser.contentDocument.getElementById("inp").value;
isnot(formValue, text, testName + " form value incorrectly restored");
is(formValue, text, testName + " form value not correctly restored");
// nextTest has to be called from here, as no events are fired in this
// step

View File

@ -3206,11 +3206,9 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
// which we must validate the cached response with the server.
else if (mLoadFlags & nsIRequest::VALIDATE_NEVER) {
LOG(("VALIDATE_NEVER set\n"));
// if no-store or if no-cache and ssl, validate cached response (see
// bug 112564 for an explanation of this logic)
if (mCachedResponseHead->NoStore() ||
(mCachedResponseHead->NoCache() && isHttps)) {
LOG(("Validating based on (no-store || (no-cache && ssl)) logic\n"));
// if no-store validate cached response (see bug 112564)
if (mCachedResponseHead->NoStore()) {
LOG(("Validating based on no-store logic\n"));
doValidation = true;
}
else {