mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1750973, don't replace the nsILayoutHistoryState object when doing same document history navigations, r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D137703
This commit is contained in:
parent
bc552e977b
commit
90b2d9e86c
@ -9005,7 +9005,20 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
|
||||
"%s",
|
||||
this, mLoadingEntry->mInfo.GetURI()->GetSpecOrDefault().get()));
|
||||
bool hadActiveEntry = !!mActiveEntry;
|
||||
|
||||
nsCOMPtr<nsILayoutHistoryState> currentLayoutHistoryState;
|
||||
if (mActiveEntry) {
|
||||
currentLayoutHistoryState = mActiveEntry->GetLayoutHistoryState();
|
||||
}
|
||||
mActiveEntry = MakeUnique<SessionHistoryInfo>(mLoadingEntry->mInfo);
|
||||
if (currentLayoutHistoryState) {
|
||||
// Restore the existing nsILayoutHistoryState object, since it is
|
||||
// possibly being used by the layout. When doing a new load, the
|
||||
// shared state is copied from the existing active entry, so this
|
||||
// special case is needed only with the history loads.
|
||||
mActiveEntry->SetLayoutHistoryState(currentLayoutHistoryState);
|
||||
}
|
||||
|
||||
if (cacheKey != 0) {
|
||||
mActiveEntry->SetCacheKey(cacheKey);
|
||||
}
|
||||
|
45
docshell/test/navigation/file_bug1750973.html
Normal file
45
docshell/test/navigation/file_bug1750973.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
function test() {
|
||||
history.scrollRestoration = "manual";
|
||||
document.getElementById("initialfocus").focus();
|
||||
history.pushState('data', '', '');
|
||||
history.back();
|
||||
}
|
||||
|
||||
window.onpopstate = function() {
|
||||
window.onscroll = function() {
|
||||
window.onscroll = null;
|
||||
document.documentElement.style.display = "none";
|
||||
// focus() triggers recreation of the nsIFrames without a reflow.
|
||||
document.getElementById("focustarget").focus();
|
||||
document.documentElement.style.display = "";
|
||||
// Flush the layout.
|
||||
document.documentElement.getBoundingClientRect();
|
||||
opener.isnot(window.scrollY, 0, "The page should have been scrolled down(1)");
|
||||
requestAnimationFrame(
|
||||
function() {
|
||||
// Extra timeout to ensure we're called after rAF has triggered a
|
||||
// reflow.
|
||||
setTimeout(function() {
|
||||
opener.isnot(window.scrollY, 0, "The page should have been scrolled down(2)");
|
||||
window.close();
|
||||
opener.SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
window.scrollTo(0, 1000);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="setTimeout(test)">
|
||||
<div style="position: fixed;">
|
||||
<input type="button" value="" id="initialfocus">
|
||||
<input type="button" value="" id="focustarget">
|
||||
</div>
|
||||
<div style="border: 1px solid black; width: 100px; height: 9000px;"></div>
|
||||
</body>
|
||||
</html>
|
@ -104,6 +104,8 @@ support-files = file_bug1745638.html
|
||||
support-files =
|
||||
goback.html
|
||||
cache_control_max_age_3600.sjs
|
||||
[test_bug1750973.html]
|
||||
support-files = file_bug1750973.html
|
||||
[test_bug270414.html]
|
||||
[test_bug278916.html]
|
||||
[test_bug279495.html]
|
||||
|
20
docshell/test/navigation/test_bug1750973.html
Normal file
20
docshell/test/navigation/test_bug1750973.html
Normal file
@ -0,0 +1,20 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>The layout state restoration when reframing the root element</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function test() {
|
||||
window.open("file_bug1750973.html");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="setTimeout(test)">
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test"></pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user