Bug 1555753 - Always enable Browsing Context preservation in fission windows, r=farre

Differential Revision: https://phabricator.services.mozilla.com/D33544

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-06-10 13:06:46 +00:00
Родитель 1a96a7dc26
Коммит f02c5f7c87
4 изменённых файлов: 52 добавлений и 15 удалений

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

@ -827,9 +827,7 @@ void BrowsingContext::Transaction::Apply(BrowsingContext* aBrowsingContext,
}
BrowsingContext::IPCInitializer BrowsingContext::GetIPCInitializer() {
MOZ_ASSERT(!mozilla::Preferences::GetBool(
"fission.preserve_browsing_contexts", false) ||
IsContent());
// FIXME: We should assert that we're loaded in-content here. (bug 1553804)
IPCInitializer init;
init.mId = Id();

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

@ -14,6 +14,9 @@
#include "mozilla/dom/FrameLoaderBinding.h"
#include "mozilla/dom/MozFrameLoaderOwnerBinding.h"
using namespace mozilla;
using namespace mozilla::dom;
already_AddRefed<nsFrameLoader> nsFrameLoaderOwner::GetFrameLoader() {
return do_AddRef(mFrameLoader);
}
@ -30,6 +33,35 @@ nsFrameLoaderOwner::GetBrowsingContext() {
return nullptr;
}
bool nsFrameLoaderOwner::UseRemoteSubframes() {
RefPtr<Element> owner = do_QueryObject(this);
MOZ_ASSERT(this);
nsILoadContext* loadContext = owner->OwnerDoc()->GetLoadContext();
MOZ_DIAGNOSTIC_ASSERT(loadContext);
return loadContext->UseRemoteSubframes();
}
bool nsFrameLoaderOwner::ShouldPreserveBrowsingContext(
const mozilla::dom::RemotenessOptions& aOptions) {
if (aOptions.mReplaceBrowsingContext) {
return false;
}
// Don't preserve contexts if this is a chrome (parent process) window
// that is changing from remote to local.
if (XRE_IsParentProcess() && (!aOptions.mRemoteType.WasPassed() ||
aOptions.mRemoteType.Value().IsVoid())) {
return false;
}
// We will preserve our browsing context if either fission is enabled, or the
// `preserve_browsing_contexts` pref is active.
return UseRemoteSubframes() ||
StaticPrefs::fission_preserve_browsing_contexts();
}
void nsFrameLoaderOwner::ChangeRemoteness(
const mozilla::dom::RemotenessOptions& aOptions, mozilla::ErrorResult& rv) {
RefPtr<mozilla::dom::BrowsingContext> bc;
@ -37,18 +69,7 @@ void nsFrameLoaderOwner::ChangeRemoteness(
// If we already have a Frameloader, destroy it, possibly preserving its
// browsing context.
if (mFrameLoader) {
// Don't preserve contexts if this is a chrome (parent process) window that
// is changing from remote to local.
bool isChromeRemoteToLocal =
XRE_IsParentProcess() && (!aOptions.mRemoteType.WasPassed() ||
aOptions.mRemoteType.Value().IsVoid());
// If this is a process switch due to a difference in Cross Origin Opener
// Policy, do not preserve the browsing context. Otherwise, save off the
// browsing context and use it when creating our new FrameLoader.
if (!aOptions.mReplaceBrowsingContext && !isChromeRemoteToLocal &&
mozilla::Preferences::GetBool("fission.preserve_browsing_contexts",
false)) {
if (ShouldPreserveBrowsingContext(aOptions)) {
bc = mFrameLoader->GetBrowsingContext();
mFrameLoader->SkipBrowsingContextDetach();
}

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

@ -52,6 +52,11 @@ class nsFrameLoaderOwner : public nsISupports {
void ChangeRemoteness(const mozilla::dom::RemotenessOptions& aOptions,
mozilla::ErrorResult& rv);
private:
bool UseRemoteSubframes();
bool ShouldPreserveBrowsingContext(
const mozilla::dom::RemotenessOptions& aOptions);
protected:
virtual ~nsFrameLoaderOwner() = default;
RefPtr<nsFrameLoader> mFrameLoader;

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

@ -2262,6 +2262,19 @@ VARCACHE_PREF(
bool, false
)
//---------------------------------------------------------------------------
// Prefs starting with "fission."
//---------------------------------------------------------------------------
// This pref has no effect within fission windows, it only controls the
// behaviour within non-fission windows.
VARCACHE_PREF(
Live,
"fission.preserve_browsing_contexts",
fission_preserve_browsing_contexts,
bool, false
)
//---------------------------------------------------------------------------
// Prefs starting with "full-screen-api."
//---------------------------------------------------------------------------