mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Bug 1583110, freeze/thaw in a separate step, r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D129701
This commit is contained in:
parent
ee4097ed0e
commit
d0c5eae6ca
@ -2869,8 +2869,13 @@ void BrowsingContext::DidSet(FieldIndex<IDX_IsInBFCache>) {
|
||||
|
||||
const bool isInBFCache = GetIsInBFCache();
|
||||
if (!isInBFCache) {
|
||||
PreOrderWalk(
|
||||
[&](BrowsingContext* aContext) { aContext->mIsInBFCache = false; });
|
||||
PreOrderWalk([&](BrowsingContext* aContext) {
|
||||
aContext->mIsInBFCache = false;
|
||||
nsCOMPtr<nsIDocShell> shell = aContext->GetDocShell();
|
||||
if (shell) {
|
||||
nsDocShell::Cast(shell)->ThawFreezeNonRecursive(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isInBFCache && XRE_IsContentProcess() && mDocShell) {
|
||||
@ -2880,13 +2885,16 @@ void BrowsingContext::DidSet(FieldIndex<IDX_IsInBFCache>) {
|
||||
PreOrderWalk([&](BrowsingContext* aContext) {
|
||||
nsCOMPtr<nsIDocShell> shell = aContext->GetDocShell();
|
||||
if (shell) {
|
||||
static_cast<nsDocShell*>(shell.get())
|
||||
->FirePageHideShowNonRecursive(!isInBFCache);
|
||||
nsDocShell::Cast(shell)->FirePageHideShowNonRecursive(!isInBFCache);
|
||||
}
|
||||
});
|
||||
|
||||
if (isInBFCache) {
|
||||
PreOrderWalk([&](BrowsingContext* aContext) {
|
||||
nsCOMPtr<nsIDocShell> shell = aContext->GetDocShell();
|
||||
if (shell) {
|
||||
nsDocShell::Cast(shell)->ThawFreezeNonRecursive(false);
|
||||
}
|
||||
aContext->mIsInBFCache = true;
|
||||
Document* doc = aContext->GetDocument();
|
||||
if (doc) {
|
||||
|
@ -1164,6 +1164,24 @@ void nsDocShell::FirePageHideNotificationInternal(
|
||||
}
|
||||
}
|
||||
|
||||
void nsDocShell::ThawFreezeNonRecursive(bool aThaw) {
|
||||
MOZ_ASSERT(mozilla::BFCacheInParent());
|
||||
|
||||
if (!mScriptGlobal) {
|
||||
return;
|
||||
}
|
||||
|
||||
RefPtr<nsGlobalWindowInner> inner =
|
||||
mScriptGlobal->GetCurrentInnerWindowInternal();
|
||||
if (inner) {
|
||||
if (aThaw) {
|
||||
inner->Thaw(false);
|
||||
} else {
|
||||
inner->Freeze(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
|
||||
MOZ_ASSERT(mozilla::BFCacheInParent());
|
||||
|
||||
@ -1199,10 +1217,6 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
|
||||
}
|
||||
}
|
||||
|
||||
if (inner) {
|
||||
inner->Thaw(false);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel = doc->GetChannel();
|
||||
if (channel) {
|
||||
SetLoadType(LOAD_HISTORY);
|
||||
@ -1240,9 +1254,6 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
|
||||
mFiredUnloadEvent = true;
|
||||
contentViewer->PageHide(false);
|
||||
|
||||
if (mScriptGlobal && mScriptGlobal->GetCurrentInnerWindowInternal()) {
|
||||
mScriptGlobal->GetCurrentInnerWindowInternal()->Freeze(false);
|
||||
}
|
||||
RefPtr<PresShell> presShell = GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->Freeze(false);
|
||||
|
@ -946,6 +946,7 @@ class nsDocShell final : public nsDocLoader,
|
||||
void FirePageHideNotificationInternal(bool aIsUnload,
|
||||
bool aSkipCheckingDynEntries);
|
||||
|
||||
void ThawFreezeNonRecursive(bool aThaw);
|
||||
void FirePageHideShowNonRecursive(bool aShow);
|
||||
|
||||
nsresult Dispatch(mozilla::TaskCategory aCategory,
|
||||
|
26
docshell/test/navigation/file_bug1583110.html
Normal file
26
docshell/test/navigation/file_bug1583110.html
Normal file
@ -0,0 +1,26 @@
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
var bc;
|
||||
window.onpageshow = function(pageshow) {
|
||||
bc = new BroadcastChannel("bug1583110");
|
||||
bc.onmessage = function(event) {
|
||||
bc.close();
|
||||
if (event.data == "loadnext") {
|
||||
location.search = "?nextpage";
|
||||
} else if (event.data == "back") {
|
||||
history.back();
|
||||
}
|
||||
}
|
||||
bc.postMessage({type: "pageshow", persisted: pageshow.persisted });
|
||||
if (pageshow.persisted) {
|
||||
document.body.appendChild(document.createElement("iframe"));
|
||||
bc.close();
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -93,6 +93,8 @@ support-files =
|
||||
[test_beforeunload_and_bfcache.html]
|
||||
support-files = file_beforeunload_and_bfcache.html
|
||||
[test_bug13871.html]
|
||||
[test_bug1583110.html]
|
||||
support-files = file_bug1583110.html
|
||||
[test_bug1706090.html]
|
||||
support-files = file_bug1706090.html
|
||||
skip-if = fission # The test is currently for the old bfcache implementation
|
||||
|
36
docshell/test/navigation/test_bug1583110.html
Normal file
36
docshell/test/navigation/test_bug1583110.html
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>test bug 1583110</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var bc = new BroadcastChannel("bug1583110");
|
||||
var pageshowCount = 0;
|
||||
bc.onmessage = function(event) {
|
||||
ok(event.data.type == "pageshow");
|
||||
++pageshowCount;
|
||||
if (pageshowCount == 1) {
|
||||
bc.postMessage("loadnext");
|
||||
} else if (pageshowCount == 2) {
|
||||
bc.postMessage("back");
|
||||
} else {
|
||||
ok(event.data.persisted, "Should have persisted the first page");
|
||||
bc.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
window.open("file_bug1583110.html", "", "noopener");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="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