Bug 1704068 - Enable test_multi_sharedWorker_lifetimes_bfcache.html on Fission, r=peterv,emilio

Differential Revision: https://phabricator.services.mozilla.com/D111403
This commit is contained in:
Olli Pettay 2021-04-26 22:25:58 +00:00
Родитель 508fc53c33
Коммит 83625b981f
6 изменённых файлов: 32 добавлений и 5 удалений

Просмотреть файл

@ -535,6 +535,7 @@ BrowsingContext::BrowsingContext(WindowContext* aParentWindow,
mUseRemoteTabs(false),
mUseRemoteSubframes(false),
mCreatedDynamically(false),
mIsInBFCache(false),
mChildOffset(0) {
MOZ_RELEASE_ASSERT(!mParentWindow || mParentWindow->Group() == mGroup);
MOZ_RELEASE_ASSERT(mBrowsingContextId != 0);
@ -2745,6 +2746,11 @@ void BrowsingContext::DidSet(FieldIndex<IDX_IsInBFCache>) {
MOZ_DIAGNOSTIC_ASSERT(IsTop());
const bool isInBFCache = GetIsInBFCache();
if (!isInBFCache) {
PreOrderWalk(
[&](BrowsingContext* aContext) { aContext->mIsInBFCache = false; });
}
PreOrderWalk([&](BrowsingContext* aContext) {
nsCOMPtr<nsIDocShell> shell = aContext->GetDocShell();
if (shell) {
@ -2752,6 +2758,11 @@ void BrowsingContext::DidSet(FieldIndex<IDX_IsInBFCache>) {
->FirePageHideShowNonRecursive(!isInBFCache);
}
});
if (isInBFCache) {
PreOrderWalk(
[&](BrowsingContext* aContext) { aContext->mIsInBFCache = true; });
}
}
void BrowsingContext::SetCustomPlatform(const nsAString& aPlatform,

Просмотреть файл

@ -197,6 +197,7 @@ enum class ExplicitActiveStatus : uint8_t {
/* The number of entries added to the session history because of this \
* browsing context. */ \
FIELD(HistoryEntryCount, uint32_t) \
/* Don't use the getter of the field, but IsInBFCache() method */ \
FIELD(IsInBFCache, bool) \
FIELD(HasRestoreData, bool) \
FIELD(SessionStoreEpoch, uint32_t)
@ -849,6 +850,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
void FlushSessionStore();
bool IsInBFCache() const { return mIsInBFCache; }
protected:
virtual ~BrowsingContext();
BrowsingContext(WindowContext* aParentWindow, BrowsingContextGroup* aGroup,
@ -1178,6 +1181,11 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
// True if this BrowsingContext is for a frame that was added dynamically.
bool mCreatedDynamically : 1;
// Set to true if the browsing context is in the bfcache and pagehide has been
// dispatched. When coming out from the bfcache, the value is set to false
// before dispatching pageshow.
bool mIsInBFCache : 1;
// The original offset of this context in its container. This property is -1
// if this BrowsingContext is for a frame that was added dynamically.
int32_t mChildOffset;

Просмотреть файл

@ -6824,15 +6824,14 @@ bool Document::RemoveFromBFCacheSync() {
if (XRE_IsContentProcess()) {
if (BrowsingContext* bc = GetBrowsingContext()) {
BrowsingContext* top = bc->Top();
if (top->GetIsInBFCache()) {
if (bc->IsInBFCache()) {
ContentChild* cc = ContentChild::GetSingleton();
// IPC is asynchronous but the caller is supposed to check the return
// value. The reason for 'Sync' in the method name is that the old
// implementation may run scripts. There is Async variant in
// the old session history implementation for the cases where
// synchronous operation isn't safe.
cc->SendRemoveFromBFCache(top);
cc->SendRemoveFromBFCache(bc->Top());
removed = true;
}
}

Просмотреть файл

@ -2758,6 +2758,10 @@ bool nsPIDOMWindowInner::HasOpenWebSockets() const {
}
bool nsPIDOMWindowInner::IsCurrentInnerWindow() const {
if (mBrowsingContext && mBrowsingContext->IsInBFCache()) {
return false;
}
if (!mBrowsingContext || mBrowsingContext->IsDiscarded()) {
// If our BrowsingContext has been discarded, we consider ourselves
// still-current if we were current at the time it was discarded.

Просмотреть файл

@ -155,7 +155,6 @@ tags = mcb
[test_multi_sharedWorker.html]
[test_multi_sharedWorker_lifetimes_nobfcache.html]
[test_multi_sharedWorker_lifetimes_bfcache.html]
skip-if = fission # bug 1667955
[test_navigator.html]
support-files =
test_navigator.js

Просмотреть файл

@ -115,8 +115,14 @@
let sendToGenerator = testGenerator.next.bind(testGenerator);
function runTest() {
// If Fission is disabled, the pref is no-op.
SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]}, () => {
testGenerator.next();
});
}
</script>
</head>
<body onload="testGenerator.next();">
<body onload="runTest()">
</body>
</html>