Backed out changeset e55eb174b342 (bug 1742865) for causin failures at attr-meta-http-equiv-refresh/parsing.html?131

This commit is contained in:
Butkovits Atila 2021-12-16 12:15:59 +02:00
parent 96e9bde4a3
commit 196050d57d
10 changed files with 109 additions and 268 deletions

View File

@ -3482,24 +3482,10 @@ bool BrowsingContext::IsPopupAllowed() {
return false;
}
/* static */
bool BrowsingContext::ShouldAddEntryForRefresh(
nsIURI* aCurrentURI, const SessionHistoryInfo& aInfo) {
if (aInfo.GetPostData()) {
return true;
}
bool equalsURI = false;
if (aCurrentURI) {
aCurrentURI->Equals(aInfo.GetURI(), &equalsURI);
}
return !equalsURI;
}
void BrowsingContext::SessionHistoryCommit(
const LoadingSessionHistoryInfo& aInfo, uint32_t aLoadType,
nsIURI* aCurrentURI, bool aHadActiveEntry, bool aPersist,
bool aCloneEntryChildren, bool aChannelExpired) {
bool aHadActiveEntry, bool aPersist, bool aCloneEntryChildren,
bool aChannelExpired) {
nsID changeID = {};
if (XRE_IsContentProcess()) {
RefPtr<ChildSHistory> rootSH = Top()->GetChildSessionHistory();
@ -3509,17 +3495,13 @@ void BrowsingContext::SessionHistoryCommit(
// CanonicalBrowsingContext::SessionHistoryCommit. We'll be
// incrementing the session history length if we're not replacing,
// this is a top-level load or it's not the initial load in an iframe,
// ShouldUpdateSessionHistory(loadType) returns true and it's not a
// refresh for which ShouldAddEntryForRefresh returns false.
// and ShouldUpdateSessionHistory(loadType) returns true.
// It is possible that this leads to wrong length temporarily, but
// so would not having the check for replace.
if (!LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY) &&
(IsTop() || aHadActiveEntry) &&
ShouldUpdateSessionHistory(aLoadType) &&
(!LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) ||
ShouldAddEntryForRefresh(aCurrentURI, aInfo.mInfo))) {
ShouldUpdateSessionHistory(aLoadType)) {
changeID = rootSH->AddPendingHistoryChange();
}
} else {

View File

@ -791,13 +791,10 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
// context or any of its ancestors.
bool IsPopupAllowed();
// aCurrentURI is only required to be non-null if the load type contains the
// nsIWebNavigation::LOAD_FLAGS_IS_REFRESH flag and aInfo is for a refresh to
// the current URI.
void SessionHistoryCommit(const LoadingSessionHistoryInfo& aInfo,
uint32_t aLoadType, nsIURI* aCurrentURI,
bool aHadActiveEntry, bool aPersist,
bool aCloneEntryChildren, bool aChannelExpired);
uint32_t aLoadType, bool aHadActiveEntry,
bool aPersist, bool aCloneEntryChildren,
bool aChannelExpired);
// Set a new active entry on this browsing context. This is used for
// implementing history.pushState/replaceState and same document navigations.
@ -901,9 +898,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
return mChildSessionHistory.forget();
}
static bool ShouldAddEntryForRefresh(nsIURI* aCurrentURI,
const SessionHistoryInfo& aInfo);
private:
void Attach(bool aFromIPC, ContentParent* aOriginProcess);

View File

@ -797,6 +797,7 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
RemoveDynEntriesFromActiveSessionHistoryEntry();
}
}
mActiveEntry = newActiveEntry;
if (LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY)) {
@ -807,16 +808,8 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
// should append instead.
addEntry = index < 0;
if (!addEntry) {
shistory->ReplaceEntry(index, newActiveEntry);
shistory->ReplaceEntry(index, mActiveEntry);
}
mActiveEntry = newActiveEntry;
} else if (LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) &&
!ShouldAddEntryForRefresh(newActiveEntry)) {
addEntry = false;
mActiveEntry->ReplaceWith(*newActiveEntry);
} else {
mActiveEntry = newActiveEntry;
}
if (loadFromSessionHistory) {
@ -848,10 +841,7 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
} else if (addEntry) {
if (mActiveEntry) {
if (LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY) ||
(LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) &&
!ShouldAddEntryForRefresh(newActiveEntry))) {
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY)) {
// FIXME We need to make sure that when we create the info we
// make a copy of the shared state.
mActiveEntry->ReplaceWith(*newActiveEntry);

View File

@ -459,12 +459,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
void RemovePendingDiscard();
bool ShouldAddEntryForRefresh(const SessionHistoryEntry* aEntry) {
nsCOMPtr<nsIURI> currentURI = GetCurrentURI();
return BrowsingContext::ShouldAddEntryForRefresh(currentURI,
aEntry->Info());
}
// XXX(farre): Store a ContentParent pointer here rather than mProcessId?
// Indicates which process owns the docshell.
uint64_t mProcessId;

View File

@ -8940,11 +8940,8 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
this, mLoadingEntry->mInfo.GetURI()->GetSpecOrDefault().get()));
bool hadActiveEntry = !!mActiveEntry;
mActiveEntry = MakeUnique<SessionHistoryInfo>(mLoadingEntry->mInfo);
// We're passing in mCurrentURI, which could be null. SessionHistoryCommit
// does require a non-null uri if this is for a refresh load of the same
// URI, but in that case mCurrentURI won't be null here.
mBrowsingContext->SessionHistoryCommit(
*mLoadingEntry, mLoadType, mCurrentURI, hadActiveEntry, true, true,
*mLoadingEntry, mLoadType, hadActiveEntry, true, true,
/* No expiration update on the same document loads*/
false);
// FIXME Need to set postdata.
@ -13475,13 +13472,8 @@ void nsDocShell::MoveLoadingToActiveEntry(bool aPersist, bool aExpired) {
MOZ_ASSERT(loadingEntry);
uint32_t loadType =
mLoadType == LOAD_ERROR_PAGE ? mFailedLoadType : mLoadType;
// We're passing in mCurrentURI, which could be null. SessionHistoryCommit
// does require a non-null uri if this is for a refresh load of the same
// URI, but in that case mCurrentURI won't be null here.
mBrowsingContext->SessionHistoryCommit(*loadingEntry, loadType, mCurrentURI,
hadActiveEntry, aPersist, false,
aExpired);
mBrowsingContext->SessionHistoryCommit(
*loadingEntry, loadType, hadActiveEntry, aPersist, false, aExpired);
}
}

View File

@ -1,68 +0,0 @@
Cu.importGlobalProperties(["URLSearchParams"]);
function handleRequest(request, response) {
if (request.queryString == "reset") {
setState("index", "0");
response.setStatusLine(request.httpVersion, 200, "Ok");
response.write("Reset");
return;
}
let refresh = "";
let index = Number(getState("index"));
// index == 0 First load, returns first meta refresh
// index == 1 Second load, caused by first meta refresh, returns second meta refresh
// index == 2 Third load, caused by second meta refresh, doesn't return a meta refresh
if (index < 2) {
let query = new URLSearchParams(request.queryString);
refresh = query.get("seconds");
if (query.get("crossorigin") == "true") {
const hosts = ["example.org", "example.com"];
let url = `${request.scheme}://${hosts[index]}${request.path}?${request.queryString}`;
refresh += `; url=${url}`;
}
refresh = `<meta http-equiv="Refresh" content="${refresh}">`;
}
setState("index", String(index + 1));
response.write(
`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="no-cache">
${refresh}
<script>
window.addEventListener("pageshow", () => {
window.top.opener.postMessage({
commandType: "pageShow",
commandData: {
inputValue: document.getElementById("input").value,
},
}, "*");
});
window.addEventListener("message", ({ data }) => {
if (data == "changeInputValue") {
document.getElementById("input").value = "1234";
window.top.opener.postMessage({
commandType: "onChangedInputValue",
commandData: {
historyLength: history.length,
inputValue: document.getElementById("input").value,
},
}, "*");
} else if (data == "loadNext") {
location.href += "&loadnext=1";
} else if (data == "back") {
history.back();
}
});
</script>
</head>
<body>
<input type="text" id="input" value="initial"></input>
</body>
</html>`
);
}

View File

@ -1,25 +0,0 @@
Cu.importGlobalProperties(["URLSearchParams"]);
function handleRequest(request, response) {
response.write(
`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
window.addEventListener("message", ({ data }) => {
if (data == "loadNext") {
location.href += "&loadnext=1";
return;
}
// Forward other messages to the frame.
document.getElementById("frame").contentWindow.postMessage(data, "*");
});
</script>
</head>
<body>
<iframe src="file_bug1742865.sjs?${request.queryString}" id="frame"></iframe>
</body>
</html>`
);
}

View File

@ -125,11 +125,6 @@ support-files =
support-files =
file_bug1741132.html
skip-if = toolkit == "android" && !sessionHistoryInParent
[test_bug1742865.html]
support-files =
file_bug1742865.sjs
file_bug1742865_outer.sjs
skip-if = toolkit == "android" && debug && fission && verify # Bug 1745937
[test_bug1743353.html]
support-files =
file_bug1743353.html

View File

@ -1,109 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Auto refreshing pages shouldn't add an entry to session history</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
const REFRESH_REDIRECT_TIMER = 15;
// 2 tests (same and cross origin) consisting of 2 refreshes of maximum 1 seconds
// 2 tests (same and cross origin) consisting of 2 refreshes of REFRESH_REDIRECT_TIMER seconds
// => We need (2 * 1) + (2 * 15) seconds
SimpleTest.requestLongerTimeout(3);
SimpleTest.waitForExplicitFinish();
const SJS = new URL("file_bug1742865.sjs", location.href);
const SJS_OUTER = new URL("file_bug1742865_outer.sjs", location.href);
function openWindowAndCheckRefresh(url, shouldAddToHistory) {
let resetURL = new URL(SJS);
resetURL.search = "?reset";
return fetch(resetURL).then(() => {
return new Promise((resolve) => {
let count = 0;
window.addEventListener("message", function listener({ data: { commandType, commandData = {} } }) {
if (commandType == "onChangedInputValue") {
let { historyLength, inputValue } = commandData;
if (shouldAddToHistory) {
is(historyLength, count, "Auto-refresh should add entries to session history");
} else {
is(historyLength, 1, "Auto-refresh shouldn't add entries to session history");
}
is(inputValue, "1234", "Input's value should have been changed");
win.postMessage("loadNext", "*");
return;
}
is(commandType, "pageShow", "Unknown command type");
let { inputValue } = commandData;
switch (++count) {
// file_bug1742865.sjs causes 3 loads:
// * first load, returns first meta refresh
// * second load, caused by first meta refresh, returns second meta refresh
// * third load, caused by second meta refresh, doesn't return a meta refresh
case 3:
win.postMessage("changeInputValue", "*");
break;
case 4:
win.postMessage("back", "*");
break;
case 5:
is(inputValue, "1234", "Entries for auto-refresh should be attached to session history");
removeEventListener("message", listener);
win.close();
resolve();
break;
}
});
let win = window.open(url);
});
});
}
function doTest(seconds, crossOrigin, shouldAddToHistory) {
let url = new URL(SJS);
url.searchParams.append("seconds", seconds);
url.searchParams.append("crossorigin", crossOrigin);
let urlOuter = new URL(SJS_OUTER);
urlOuter.searchParams.append("seconds", seconds);
urlOuter.searchParams.append("crossorigin", crossOrigin);
return openWindowAndCheckRefresh(url, shouldAddToHistory).then(() =>
openWindowAndCheckRefresh(urlOuter, shouldAddToHistory)
);
}
function runTest() {
const FAST = Math.min(1, REFRESH_REDIRECT_TIMER);
const SLOW = REFRESH_REDIRECT_TIMER + 1;
let tests = [
// [ time, crossOrigin, shouldAddToHistory ]
[ FAST, false, false ],
[ FAST, true, false ],
[ SLOW, false, false ],
[ SLOW, true, true ],
];
let test = Promise.resolve();
for (let [ time, crossOrigin, shouldAddToHistory ] of tests) {
test = test.then(() => doTest(time, crossOrigin, shouldAddToHistory));
}
test.then(() => SimpleTest.finish());
}
</script>
</head>
<body onload="runTest();">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test"></pre>
</body>
</html>

View File

@ -43,6 +43,13 @@
if debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
["-0; url=foo"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
if not debug and (os == "mac") and (processor == "x86") and (bits == 32): FAIL
if debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
["+1; foo"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
@ -57,6 +64,13 @@
if debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
["-0; foo"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
if not debug and (os == "mac") and (processor == "x86") and (bits == 32): FAIL
if debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
["+1"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
@ -65,6 +79,14 @@
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
if (processor == "x86_64") and (bits == 64): FAIL
["-1"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
if not debug and (os == "mac") and (processor == "x86") and (bits == 32): FAIL
if debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
if (processor == "x86_64") and (bits == 64): FAIL
["+0"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
@ -73,6 +95,13 @@
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
if (processor == "x86_64") and (bits == 64): FAIL
["-0"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
if not debug and (os == "mac") and (processor == "x86") and (bits == 32): FAIL
if debug and (os == "mac"): FAIL
if not debug and (os == "win") and (version == "6.1.7601"): FAIL
[".9; url=foo"]
disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1230909
expected:
@ -86,6 +115,9 @@
[",foo"]
expected: FAIL
["-0.1; url=foo"]
expected: FAIL
[<meta>: "1\\f"]
expected: TIMEOUT
@ -140,6 +172,12 @@
[Refresh header: "+0; url=foo"]
expected: FAIL
[<meta>: "-0; url=foo"]
expected: FAIL
[Refresh header: "-0; url=foo"]
expected: FAIL
[<meta>: "+1; foo"]
expected: FAIL
@ -152,18 +190,42 @@
[Refresh header: "+0; foo"]
expected: FAIL
[<meta>: "-0; foo"]
expected: FAIL
[Refresh header: "-0; foo"]
expected: FAIL
[<meta>: "+1"]
expected: FAIL
[Refresh header: "+1"]
expected: FAIL
[<meta>: "-1"]
expected: FAIL
[Refresh header: "-1"]
expected: FAIL
[<meta>: "+0"]
expected: FAIL
[Refresh header: "+0"]
expected: FAIL
[<meta>: "-0"]
expected: FAIL
[Refresh header: "-0"]
expected: FAIL
[<meta>: "-0.1; url=foo"]
expected: FAIL
[Refresh header: "-0.1; url=foo"]
expected: FAIL
[parsing.html?11-20]
expected: TIMEOUT
@ -206,7 +268,15 @@
expected: TIMEOUT
[parsing.html?111-120]
[Refresh header: "-0"]
expected: FAIL
[parsing.html?91-100]
[Refresh header: "-0; url=foo"]
expected: FAIL
[<meta>: "+1; foo"]
expected: FAIL
@ -219,6 +289,9 @@
[Refresh header: "+0; foo"]
expected: FAIL
[<meta>: "-0; foo"]
expected: FAIL
[parsing.html?61-70]
[<meta>: "1; url=\\"foo'bar"]
@ -244,20 +317,43 @@
[Refresh header: "+0; url=foo"]
expected: FAIL
[<meta>: "-0; url=foo"]
expected: FAIL
[parsing.html?131-last]
[<meta>: "-0.1; url=foo"]
expected: FAIL
[Refresh header: "-0.1; url=foo"]
expected: FAIL
[parsing.html?101-110]
[Refresh header: "-0; foo"]
expected: FAIL
[<meta>: "+1"]
expected: FAIL
[Refresh header: "+1"]
expected: FAIL
[<meta>: "-1"]
expected: FAIL
[Refresh header: "-1"]
expected: FAIL
[<meta>: "+0"]
expected: FAIL
[Refresh header: "+0"]
expected: FAIL
[<meta>: "-0"]
expected: FAIL
[parsing.html?1-10]