зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 5 changesets (bug 1599579) for twinopen failures. CLOSED TREE
Backed out changeset 053229a30ef1 (bug 1599579) Backed out changeset c2828aec4caf (bug 1599579) Backed out changeset 085558fe56dc (bug 1599579) Backed out changeset a4e7334f8ce6 (bug 1599579) Backed out changeset 9ebd2eb155da (bug 1599579)
This commit is contained in:
Родитель
7d97bd7510
Коммит
46e3b1ce2c
|
@ -12,8 +12,6 @@ function genericChecker() {
|
|||
}
|
||||
window.kind = kind;
|
||||
|
||||
let bcGroupId = SpecialPowers.wrap(window).browsingContext.group.id;
|
||||
|
||||
browser.test.onMessage.addListener((msg, ...args) => {
|
||||
if (msg == kind + "-check-views") {
|
||||
let counts = {
|
||||
|
@ -38,17 +36,6 @@ function genericChecker() {
|
|||
);
|
||||
background = view;
|
||||
}
|
||||
|
||||
// FIXME(bug 1646817): Extension documents loaded outside of tabs don't
|
||||
// perform process switches using DocumentLoadListener, meaning that
|
||||
// they may have the wrong BrowsingContextGroup.
|
||||
if (kind == "tab" && view.kind == "tab") {
|
||||
browser.test.assertEq(
|
||||
bcGroupId,
|
||||
SpecialPowers.wrap(view).browsingContext.group.id,
|
||||
"browsing context group is correct"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (background) {
|
||||
browser.runtime.getBackgroundPage().then(view => {
|
||||
|
|
|
@ -189,8 +189,7 @@ bool BrowsingContext::SameOriginWithTop() {
|
|||
/* static */
|
||||
already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
|
||||
nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
|
||||
BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
|
||||
uint64_t aBrowserId) {
|
||||
const nsAString& aName, Type aType, uint64_t aBrowserId) {
|
||||
if (aParent) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aParent->GetWindowContext());
|
||||
MOZ_DIAGNOSTIC_ASSERT(aParent->GetBrowsingContext()->mType == aType);
|
||||
|
@ -213,13 +212,10 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateDetached(
|
|||
aParent ? aParent->GetWindowContext() : nullptr;
|
||||
|
||||
// Determine which BrowsingContextGroup this context should be created in.
|
||||
RefPtr<BrowsingContextGroup> group = aSpecificGroup;
|
||||
if (aType == Type::Chrome) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(!group);
|
||||
group = BrowsingContextGroup::GetChromeGroup();
|
||||
} else if (!group) {
|
||||
group = BrowsingContextGroup::Select(parentWC, aOpener);
|
||||
}
|
||||
RefPtr<BrowsingContextGroup> group =
|
||||
(aType == Type::Chrome)
|
||||
? do_AddRef(BrowsingContextGroup::GetChromeGroup())
|
||||
: BrowsingContextGroup::Select(parentWC, aOpener);
|
||||
|
||||
RefPtr<BrowsingContext> context;
|
||||
if (XRE_IsParentProcess()) {
|
||||
|
@ -342,8 +338,8 @@ already_AddRefed<BrowsingContext> BrowsingContext::CreateIndependent(
|
|||
Type aType) {
|
||||
uint64_t browserId =
|
||||
aType == Type::Content ? nsContentUtils::GenerateBrowserId() : 0;
|
||||
RefPtr<BrowsingContext> bc(CreateDetached(nullptr, nullptr, nullptr,
|
||||
EmptyString(), aType, browserId));
|
||||
RefPtr<BrowsingContext> bc(
|
||||
CreateDetached(nullptr, nullptr, EmptyString(), aType, browserId));
|
||||
bc->mWindowless = bc->IsContent();
|
||||
bc->EnsureAttached();
|
||||
return bc.forget();
|
||||
|
|
|
@ -205,8 +205,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
|||
// DocShell, BrowserParent, or BrowserBridgeChild.
|
||||
static already_AddRefed<BrowsingContext> CreateDetached(
|
||||
nsGlobalWindowInner* aParent, BrowsingContext* aOpener,
|
||||
BrowsingContextGroup* aSpecificGroup, const nsAString& aName, Type aType,
|
||||
uint64_t aBrowserId);
|
||||
const nsAString& aName, Type aType, uint64_t aBrowserId);
|
||||
|
||||
void EnsureAttached();
|
||||
|
||||
|
|
|
@ -481,16 +481,11 @@ void CanonicalBrowsingContext::PendingRemotenessChange::Finish() {
|
|||
mContentParent ? NS_LITERAL_STRING("true") : NS_LITERAL_STRING("false"),
|
||||
/* notify */ true);
|
||||
|
||||
RefPtr<BrowsingContextGroup> specificGroup;
|
||||
if (mSpecificGroupId != 0) {
|
||||
specificGroup = BrowsingContextGroup::GetOrCreate(mSpecificGroupId);
|
||||
}
|
||||
|
||||
// The process has been created, hand off to nsFrameLoaderOwner to finish
|
||||
// the process switch.
|
||||
ErrorResult error;
|
||||
frameLoaderOwner->ChangeRemotenessToProcess(
|
||||
mContentParent, mReplaceBrowsingContext, specificGroup, error);
|
||||
frameLoaderOwner->ChangeRemotenessToProcess(mContentParent,
|
||||
mReplaceBrowsingContext, error);
|
||||
if (error.Failed()) {
|
||||
Cancel(error.StealNSResult());
|
||||
return;
|
||||
|
@ -676,12 +671,10 @@ void CanonicalBrowsingContext::PendingRemotenessChange::Clear() {
|
|||
|
||||
CanonicalBrowsingContext::PendingRemotenessChange::PendingRemotenessChange(
|
||||
CanonicalBrowsingContext* aTarget, RemotenessPromise::Private* aPromise,
|
||||
uint64_t aPendingSwitchId, bool aReplaceBrowsingContext,
|
||||
uint64_t aSpecificGroupId)
|
||||
uint64_t aPendingSwitchId, bool aReplaceBrowsingContext)
|
||||
: mTarget(aTarget),
|
||||
mPromise(aPromise),
|
||||
mPendingSwitchId(aPendingSwitchId),
|
||||
mSpecificGroupId(aSpecificGroupId),
|
||||
mReplaceBrowsingContext(aReplaceBrowsingContext) {}
|
||||
|
||||
CanonicalBrowsingContext::PendingRemotenessChange::~PendingRemotenessChange() {
|
||||
|
@ -692,8 +685,7 @@ CanonicalBrowsingContext::PendingRemotenessChange::~PendingRemotenessChange() {
|
|||
RefPtr<CanonicalBrowsingContext::RemotenessPromise>
|
||||
CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType,
|
||||
uint64_t aPendingSwitchId,
|
||||
bool aReplaceBrowsingContext,
|
||||
uint64_t aSpecificGroupId) {
|
||||
bool aReplaceBrowsingContext) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(IsContent(),
|
||||
"cannot change the process of chrome contexts");
|
||||
MOZ_DIAGNOSTIC_ASSERT(
|
||||
|
@ -701,8 +693,6 @@ CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType,
|
|||
"toplevel content must be embedded in the parent process");
|
||||
MOZ_DIAGNOSTIC_ASSERT(!aReplaceBrowsingContext || IsTop(),
|
||||
"Cannot replace BrowsingContext for subframes");
|
||||
MOZ_DIAGNOSTIC_ASSERT(aSpecificGroupId == 0 || aReplaceBrowsingContext,
|
||||
"Cannot specify group ID unless replacing BC");
|
||||
|
||||
// Ensure our embedder hasn't been destroyed already.
|
||||
RefPtr<WindowGlobalParent> embedderWindowGlobal = GetEmbedderWindowGlobal();
|
||||
|
@ -755,9 +745,8 @@ CanonicalBrowsingContext::ChangeRemoteness(const nsAString& aRemoteType,
|
|||
|
||||
// Switching to remote. Wait for new process to launch before switch.
|
||||
auto promise = MakeRefPtr<RemotenessPromise::Private>(__func__);
|
||||
RefPtr<PendingRemotenessChange> change =
|
||||
new PendingRemotenessChange(this, promise, aPendingSwitchId,
|
||||
aReplaceBrowsingContext, aSpecificGroupId);
|
||||
RefPtr<PendingRemotenessChange> change = new PendingRemotenessChange(
|
||||
this, promise, aPendingSwitchId, aReplaceBrowsingContext);
|
||||
mPendingRemotenessChange = change;
|
||||
|
||||
// Call `prepareToChangeRemoteness` in parallel with starting a new process
|
||||
|
|
|
@ -143,8 +143,7 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
|||
using RemotenessPromise = MozPromise<RefPtr<BrowserParent>, nsresult, false>;
|
||||
RefPtr<RemotenessPromise> ChangeRemoteness(const nsAString& aRemoteType,
|
||||
uint64_t aPendingSwitchId,
|
||||
bool aReplaceBrowsingContext,
|
||||
uint64_t aSpecificGroupId);
|
||||
bool aReplaceBrowsingContext);
|
||||
|
||||
// Return a media controller from the top-level browsing context that can
|
||||
// control all media belonging to this browsing context tree. Return nullptr
|
||||
|
@ -198,8 +197,7 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
|||
PendingRemotenessChange(CanonicalBrowsingContext* aTarget,
|
||||
RemotenessPromise::Private* aPromise,
|
||||
uint64_t aPendingSwitchId,
|
||||
bool aReplaceBrowsingContext,
|
||||
uint64_t aSpecificGroupId);
|
||||
bool aReplaceBrowsingContext);
|
||||
|
||||
void Cancel(nsresult aRv);
|
||||
|
||||
|
@ -217,7 +215,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
|
|||
RefPtr<ContentParent> mContentParent;
|
||||
|
||||
uint64_t mPendingSwitchId;
|
||||
uint64_t mSpecificGroupId;
|
||||
bool mReplaceBrowsingContext;
|
||||
};
|
||||
|
||||
|
|
|
@ -266,10 +266,7 @@ static bool IsTopContent(BrowsingContext* aParent, Element* aOwner) {
|
|||
}
|
||||
|
||||
static already_AddRefed<BrowsingContext> CreateBrowsingContext(
|
||||
Element* aOwner, nsIOpenWindowInfo* aOpenWindowInfo,
|
||||
BrowsingContextGroup* aSpecificGroup) {
|
||||
MOZ_ASSERT(!aOpenWindowInfo || !aSpecificGroup);
|
||||
|
||||
Element* aOwner, nsIOpenWindowInfo* aOpenWindowInfo) {
|
||||
// If we've got a pending BrowserParent from the content process, use the
|
||||
// BrowsingContext which was created for it.
|
||||
if (aOpenWindowInfo && aOpenWindowInfo->GetNextRemoteBrowser()) {
|
||||
|
@ -329,8 +326,7 @@ static already_AddRefed<BrowsingContext> CreateBrowsingContext(
|
|||
|
||||
// Create toplevel content without a parent & as Type::Content.
|
||||
return BrowsingContext::CreateDetached(
|
||||
nullptr, opener, aSpecificGroup, frameName,
|
||||
BrowsingContext::Type::Content, browserId);
|
||||
nullptr, opener, frameName, BrowsingContext::Type::Content, browserId);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!aOpenWindowInfo,
|
||||
|
@ -342,10 +338,8 @@ static already_AddRefed<BrowsingContext> CreateBrowsingContext(
|
|||
owner->SetBrowserId(browserId);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!aSpecificGroup,
|
||||
"Can't force BrowsingContextGroup for non-toplevel context");
|
||||
return BrowsingContext::CreateDetached(
|
||||
parentInner, nullptr, nullptr, frameName, parentBC->GetType(), browserId);
|
||||
return BrowsingContext::CreateDetached(parentInner, nullptr, frameName,
|
||||
parentBC->GetType(), browserId);
|
||||
}
|
||||
|
||||
static bool InitialLoadIsRemote(Element* aOwner) {
|
||||
|
@ -446,8 +440,8 @@ already_AddRefed<nsFrameLoader> nsFrameLoader::Create(
|
|||
doc->IsStaticDocument()),
|
||||
nullptr);
|
||||
|
||||
RefPtr<BrowsingContext> context = CreateBrowsingContext(
|
||||
aOwner, aOpenWindowInfo, /* specificGroup */ nullptr);
|
||||
RefPtr<BrowsingContext> context =
|
||||
CreateBrowsingContext(aOwner, aOpenWindowInfo);
|
||||
NS_ENSURE_TRUE(context, nullptr);
|
||||
|
||||
bool isRemoteFrame = InitialLoadIsRemote(aOwner);
|
||||
|
@ -462,9 +456,8 @@ already_AddRefed<nsFrameLoader> nsFrameLoader::Create(
|
|||
|
||||
/* static */
|
||||
already_AddRefed<nsFrameLoader> nsFrameLoader::Recreate(
|
||||
mozilla::dom::Element* aOwner, BrowsingContext* aContext,
|
||||
BrowsingContextGroup* aSpecificGroup, bool aIsRemote, bool aNetworkCreated,
|
||||
bool aPreserveContext) {
|
||||
mozilla::dom::Element* aOwner, BrowsingContext* aContext, bool aIsRemote,
|
||||
bool aNetworkCreated, bool aPreserveContext) {
|
||||
NS_ENSURE_TRUE(aOwner, nullptr);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -478,8 +471,7 @@ already_AddRefed<nsFrameLoader> nsFrameLoader::Recreate(
|
|||
|
||||
RefPtr<BrowsingContext> context = aContext;
|
||||
if (!context || !aPreserveContext) {
|
||||
context = CreateBrowsingContext(aOwner, /* openWindowInfo */ nullptr,
|
||||
aSpecificGroup);
|
||||
context = CreateBrowsingContext(aOwner, /* openWindowInfo */ nullptr);
|
||||
if (aContext) {
|
||||
MOZ_ASSERT(
|
||||
XRE_IsParentProcess(),
|
||||
|
|
|
@ -99,7 +99,6 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
|||
typedef mozilla::dom::BrowserParent BrowserParent;
|
||||
typedef mozilla::dom::BrowserBridgeChild BrowserBridgeChild;
|
||||
typedef mozilla::dom::BrowsingContext BrowsingContext;
|
||||
typedef mozilla::dom::BrowsingContextGroup BrowsingContextGroup;
|
||||
|
||||
public:
|
||||
// Called by Frame Elements to create a new FrameLoader.
|
||||
|
@ -109,9 +108,11 @@ class nsFrameLoader final : public nsStubMutationObserver,
|
|||
|
||||
// Called by nsFrameLoaderOwner::ChangeRemoteness when switching out
|
||||
// FrameLoaders.
|
||||
static already_AddRefed<nsFrameLoader> Recreate(
|
||||
Element* aOwner, BrowsingContext* aContext, BrowsingContextGroup* aGroup,
|
||||
bool aIsRemote, bool aNetworkCreated, bool aPreserveContext);
|
||||
static already_AddRefed<nsFrameLoader> Recreate(Element* aOwner,
|
||||
BrowsingContext* aContext,
|
||||
bool aIsRemote,
|
||||
bool aNetworkCreated,
|
||||
bool aPreserveContext);
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_FRAMELOADER_IID)
|
||||
|
||||
|
|
|
@ -86,10 +86,8 @@ nsFrameLoaderOwner::ShouldPreserveBrowsingContext(
|
|||
|
||||
void nsFrameLoaderOwner::ChangeRemotenessCommon(
|
||||
const ChangeRemotenessContextType& aContextType,
|
||||
bool aSwitchingInProgressLoad, bool aIsRemote, BrowsingContextGroup* aGroup,
|
||||
bool aSwitchingInProgressLoad, bool aIsRemote,
|
||||
std::function<void()>& aFrameLoaderInit, mozilla::ErrorResult& aRv) {
|
||||
MOZ_ASSERT_IF(aGroup, aContextType != ChangeRemotenessContextType::PRESERVE);
|
||||
|
||||
RefPtr<mozilla::dom::BrowsingContext> bc;
|
||||
bool networkCreated = false;
|
||||
|
||||
|
@ -131,7 +129,7 @@ void nsFrameLoaderOwner::ChangeRemotenessCommon(
|
|||
}
|
||||
|
||||
mFrameLoader = nsFrameLoader::Recreate(
|
||||
owner, bc, aGroup, aIsRemote, networkCreated,
|
||||
owner, bc, aIsRemote, networkCreated,
|
||||
aContextType == ChangeRemotenessContextType::PRESERVE);
|
||||
if (NS_WARN_IF(!mFrameLoader)) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -207,7 +205,7 @@ void nsFrameLoaderOwner::ChangeRemoteness(
|
|||
auto shouldPreserve = ShouldPreserveBrowsingContext(
|
||||
isRemote, /* replaceBrowsingContext */ false);
|
||||
ChangeRemotenessCommon(shouldPreserve, aOptions.mSwitchingInProgressLoad,
|
||||
isRemote, /* group */ nullptr, frameLoaderInit, rv);
|
||||
isRemote, frameLoaderInit, rv);
|
||||
}
|
||||
|
||||
void nsFrameLoaderOwner::ChangeRemotenessWithBridge(BrowserBridgeChild* aBridge,
|
||||
|
@ -227,15 +225,13 @@ void nsFrameLoaderOwner::ChangeRemotenessWithBridge(BrowserBridgeChild* aBridge,
|
|||
|
||||
ChangeRemotenessCommon(ChangeRemotenessContextType::PRESERVE,
|
||||
/* inProgress */ true,
|
||||
/* isRemote */ true, /* group */ nullptr,
|
||||
frameLoaderInit, rv);
|
||||
/* isRemote */ true, frameLoaderInit, rv);
|
||||
}
|
||||
|
||||
void nsFrameLoaderOwner::ChangeRemotenessToProcess(
|
||||
ContentParent* aContentParent, bool aReplaceBrowsingContext,
|
||||
BrowsingContextGroup* aGroup, mozilla::ErrorResult& rv) {
|
||||
mozilla::ErrorResult& rv) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT_IF(aGroup, aReplaceBrowsingContext);
|
||||
bool isRemote = aContentParent != nullptr;
|
||||
|
||||
std::function<void()> frameLoaderInit = [&] {
|
||||
|
@ -257,7 +253,7 @@ void nsFrameLoaderOwner::ChangeRemotenessToProcess(
|
|||
auto shouldPreserve =
|
||||
ShouldPreserveBrowsingContext(isRemote, aReplaceBrowsingContext);
|
||||
ChangeRemotenessCommon(shouldPreserve, /* inProgress */ true, isRemote,
|
||||
aGroup, frameLoaderInit, rv);
|
||||
frameLoaderInit, rv);
|
||||
}
|
||||
|
||||
void nsFrameLoaderOwner::SubframeCrashed() {
|
||||
|
@ -285,8 +281,8 @@ void nsFrameLoaderOwner::SubframeCrashed() {
|
|||
};
|
||||
|
||||
ChangeRemotenessCommon(ChangeRemotenessContextType::PRESERVE,
|
||||
/* inProgress */ false, /* isRemote */ false,
|
||||
/* group */ nullptr, frameLoaderInit, IgnoreErrors());
|
||||
/* inProgress */ false,
|
||||
/* isRemote */ false, frameLoaderInit, IgnoreErrors());
|
||||
}
|
||||
|
||||
void nsFrameLoaderOwner::UnbindFromTree() {
|
||||
|
|
|
@ -70,7 +70,6 @@ class nsFrameLoaderOwner : public nsISupports {
|
|||
// disabled for this process switch.
|
||||
void ChangeRemotenessToProcess(mozilla::dom::ContentParent* aContentParent,
|
||||
bool aReplaceBrowsingContext,
|
||||
mozilla::dom::BrowsingContextGroup* aGroup,
|
||||
mozilla::ErrorResult& rv);
|
||||
|
||||
void SubframeCrashed();
|
||||
|
@ -99,7 +98,6 @@ class nsFrameLoaderOwner : public nsISupports {
|
|||
|
||||
void ChangeRemotenessCommon(const ChangeRemotenessContextType& aContextType,
|
||||
bool aSwitchingInProgressLoad, bool aIsRemote,
|
||||
mozilla::dom::BrowsingContextGroup* aGroup,
|
||||
std::function<void()>& aFrameLoaderInit,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -177,6 +177,4 @@ interface CanonicalBrowsingContext : BrowsingContext {
|
|||
[Exposed=Window, ChromeOnly]
|
||||
interface BrowsingContextGroup {
|
||||
sequence<BrowsingContext> getToplevels();
|
||||
|
||||
readonly attribute unsigned long long id;
|
||||
};
|
||||
|
|
|
@ -951,8 +951,7 @@ nsresult ContentChild::ProvideWindowCommon(
|
|||
|
||||
uint64_t browserId(nsContentUtils::GenerateBrowserId());
|
||||
RefPtr<BrowsingContext> browsingContext = BrowsingContext::CreateDetached(
|
||||
nullptr, openerBC, nullptr, aName, BrowsingContext::Type::Content,
|
||||
browserId);
|
||||
nullptr, openerBC, aName, BrowsingContext::Type::Content, browserId);
|
||||
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteTabs(true));
|
||||
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetRemoteSubframes(useRemoteSubframes));
|
||||
MOZ_ALWAYS_SUCCEEDS(browsingContext->SetOriginAttributes(
|
||||
|
|
|
@ -196,9 +196,8 @@ class WindowGlobalParent final : public WindowContext,
|
|||
|
||||
nsITransportSecurityInfo* GetSecurityInfo() { return mSecurityInfo; }
|
||||
|
||||
const nsAString& GetRemoteType() override;
|
||||
|
||||
protected:
|
||||
const nsAString& GetRemoteType() override;
|
||||
JSActor::Type GetSide() override { return JSActor::Type::Parent; }
|
||||
|
||||
// IPC messages
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/RemoteWebProgress.h"
|
||||
#include "mozilla/dom/RemoteWebProgressRequest.h"
|
||||
#include "mozilla/ExtensionPolicyService.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
# include "mozilla/widget/nsWindow.h"
|
||||
|
@ -1115,31 +1114,42 @@ static bool IsLargeAllocationLoad(CanonicalBrowsingContext* aBrowsingContext,
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool ContextCanProcessSwitch(
|
||||
CanonicalBrowsingContext* aBrowsingContext) {
|
||||
if (NS_WARN_IF(!aBrowsingContext)) {
|
||||
bool DocumentLoadListener::MaybeTriggerProcessSwitch(
|
||||
bool* aWillSwitchToRemote) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mDoingProcessSwitch,
|
||||
"Already in the middle of switching?");
|
||||
MOZ_DIAGNOSTIC_ASSERT(mChannel);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mParentChannelListener);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aWillSwitchToRemote);
|
||||
|
||||
LOG(("DocumentLoadListener MaybeTriggerProcessSwitch [this=%p]", this));
|
||||
|
||||
// Get the BrowsingContext which will be switching processes.
|
||||
RefPtr<CanonicalBrowsingContext> browsingContext =
|
||||
mParentChannelListener->GetBrowsingContext();
|
||||
if (NS_WARN_IF(!browsingContext)) {
|
||||
LOG(("Process Switch Abort: no browsing context"));
|
||||
return false;
|
||||
}
|
||||
if (!aBrowsingContext->IsContent()) {
|
||||
if (!browsingContext->IsContent()) {
|
||||
LOG(("Process Switch Abort: non-content browsing context"));
|
||||
return false;
|
||||
}
|
||||
if (aBrowsingContext->GetParent() &&
|
||||
!aBrowsingContext->UseRemoteSubframes()) {
|
||||
if (browsingContext->GetParent() && !browsingContext->UseRemoteSubframes()) {
|
||||
LOG(("Process Switch Abort: remote subframes disabled"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aBrowsingContext->GetParentWindowContext() &&
|
||||
aBrowsingContext->GetParentWindowContext()->IsInProcess()) {
|
||||
if (browsingContext->GetParentWindowContext() &&
|
||||
browsingContext->GetParentWindowContext()->IsInProcess()) {
|
||||
LOG(("Process Switch Abort: Subframe with in-process parent"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine what process switching behaviour is being requested by the root
|
||||
// <browser> element.
|
||||
Element* browserElement = aBrowsingContext->Top()->GetEmbedderElement();
|
||||
Element* browserElement = browsingContext->Top()->GetEmbedderElement();
|
||||
if (!browserElement) {
|
||||
LOG(("Process Switch Abort: cannot get embedder element"));
|
||||
return false;
|
||||
|
@ -1166,148 +1176,101 @@ static bool ContextCanProcessSwitch(
|
|||
LOG(("Process Switch Abort: switch disabled by <browser>"));
|
||||
return false;
|
||||
}
|
||||
if (aBrowsingContext->IsTop() &&
|
||||
if (browsingContext->IsTop() &&
|
||||
processBehavior == nsIBrowser::PROCESS_BEHAVIOR_SUBFRAME_ONLY) {
|
||||
LOG(("Process Switch Abort: toplevel switch disabled by <browser>"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DocumentLoadListener::MaybeTriggerProcessSwitch(
|
||||
bool* aWillSwitchToRemote) {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_DIAGNOSTIC_ASSERT(!mDoingProcessSwitch,
|
||||
"Already in the middle of switching?");
|
||||
MOZ_DIAGNOSTIC_ASSERT(mChannel);
|
||||
MOZ_DIAGNOSTIC_ASSERT(mParentChannelListener);
|
||||
MOZ_DIAGNOSTIC_ASSERT(aWillSwitchToRemote);
|
||||
|
||||
LOG(("DocumentLoadListener MaybeTriggerProcessSwitch [this=%p]", this));
|
||||
|
||||
// Get the BrowsingContext which will be switching processes.
|
||||
RefPtr<CanonicalBrowsingContext> browsingContext =
|
||||
mParentChannelListener->GetBrowsingContext();
|
||||
if (!ContextCanProcessSwitch(browsingContext)) {
|
||||
return false;
|
||||
bool isPreloadSwitch = false;
|
||||
nsAutoString isPreloadBrowserStr;
|
||||
if (browserElement->GetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
|
||||
isPreloadBrowserStr) &&
|
||||
isPreloadBrowserStr.EqualsLiteral("consumed")) {
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
if (NS_SUCCEEDED(mChannel->GetOriginalURI(getter_AddRefs(originalURI))) &&
|
||||
!originalURI->GetSpecOrDefault().EqualsLiteral("about:newtab")) {
|
||||
LOG(("Process Switch: leaving preloaded browser"));
|
||||
isPreloadSwitch = true;
|
||||
browserElement->UnsetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
|
||||
true);
|
||||
}
|
||||
}
|
||||
|
||||
// Get information about the current document loaded in our BrowsingContext.
|
||||
nsCOMPtr<nsIPrincipal> currentPrincipal;
|
||||
if (RefPtr<WindowGlobalParent> wgp =
|
||||
browsingContext->GetCurrentWindowGlobal()) {
|
||||
currentPrincipal = wgp->DocumentPrincipal();
|
||||
}
|
||||
RefPtr<ContentParent> contentParent = browsingContext->GetContentParent();
|
||||
MOZ_ASSERT(!OtherPid() || contentParent,
|
||||
"Only PPDC is allowed to not have an existing ContentParent");
|
||||
|
||||
// Get the final principal, used to select which process to load into.
|
||||
nsCOMPtr<nsIPrincipal> resultPrincipal;
|
||||
nsresult rv = nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(
|
||||
rv = nsContentUtils::GetSecurityManager()->GetChannelResultPrincipal(
|
||||
mChannel, getter_AddRefs(resultPrincipal));
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG(("Process Switch Abort: failed to get channel result principal"));
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoString currentRemoteType(VoidString());
|
||||
if (RefPtr<ContentParent> contentParent =
|
||||
browsingContext->GetContentParent()) {
|
||||
// Determine our COOP status, which will be used to determine our preferred
|
||||
// remote type.
|
||||
bool isCOOPSwitch = HasCrossOriginOpenerPolicyMismatch();
|
||||
nsILoadInfo::CrossOriginOpenerPolicy coop =
|
||||
nsILoadInfo::OPENER_POLICY_UNSAFE_NONE;
|
||||
if (!browsingContext->IsTop()) {
|
||||
coop = browsingContext->Top()->GetOpenerPolicy();
|
||||
} else if (nsCOMPtr<nsIHttpChannelInternal> httpChannel =
|
||||
do_QueryInterface(mChannel)) {
|
||||
MOZ_ALWAYS_SUCCEEDS(httpChannel->GetCrossOriginOpenerPolicy(&coop));
|
||||
}
|
||||
|
||||
nsAutoString currentRemoteType;
|
||||
if (contentParent) {
|
||||
currentRemoteType = contentParent->GetRemoteType();
|
||||
} else {
|
||||
currentRemoteType = VoidString();
|
||||
}
|
||||
MOZ_ASSERT_IF(currentRemoteType.IsEmpty(), !OtherPid());
|
||||
|
||||
// Determine what type of content process this load should finish in.
|
||||
nsAutoString preferredRemoteType(currentRemoteType);
|
||||
bool replaceBrowsingContext = false;
|
||||
uint64_t specificGroupId = 0;
|
||||
|
||||
// If we're in a preloaded browser, force browsing context replacement to
|
||||
// ensure the current process is re-selected.
|
||||
{
|
||||
Element* browserElement = browsingContext->Top()->GetEmbedderElement();
|
||||
|
||||
nsAutoString isPreloadBrowserStr;
|
||||
if (browserElement->GetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
|
||||
isPreloadBrowserStr) &&
|
||||
isPreloadBrowserStr.EqualsLiteral("consumed")) {
|
||||
nsCOMPtr<nsIURI> originalURI;
|
||||
if (NS_SUCCEEDED(mChannel->GetOriginalURI(getter_AddRefs(originalURI))) &&
|
||||
!originalURI->GetSpecOrDefault().EqualsLiteral("about:newtab")) {
|
||||
LOG(("Process Switch: leaving preloaded browser"));
|
||||
replaceBrowsingContext = true;
|
||||
browserElement->UnsetAttr(kNameSpaceID_None, nsGkAtoms::preloadedState,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the preferred final process for our load based on the
|
||||
// Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers.
|
||||
{
|
||||
bool isCOOPSwitch = HasCrossOriginOpenerPolicyMismatch();
|
||||
replaceBrowsingContext |= isCOOPSwitch;
|
||||
|
||||
// Determine our COOP status, which will be used to determine our preferred
|
||||
// remote type.
|
||||
nsILoadInfo::CrossOriginOpenerPolicy coop =
|
||||
nsILoadInfo::OPENER_POLICY_UNSAFE_NONE;
|
||||
if (!browsingContext->IsTop()) {
|
||||
coop = browsingContext->Top()->GetOpenerPolicy();
|
||||
} else if (nsCOMPtr<nsIHttpChannelInternal> httpChannel =
|
||||
do_QueryInterface(mChannel)) {
|
||||
MOZ_ALWAYS_SUCCEEDS(httpChannel->GetCrossOriginOpenerPolicy(&coop));
|
||||
}
|
||||
|
||||
if (coop ==
|
||||
nsILoadInfo::OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP) {
|
||||
// We want documents with SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP COOP
|
||||
// policy to be loaded in a separate process in which we can enable
|
||||
// high-resolution timers.
|
||||
nsAutoCString siteOrigin;
|
||||
resultPrincipal->GetSiteOrigin(siteOrigin);
|
||||
preferredRemoteType =
|
||||
NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX);
|
||||
AppendUTF8toUTF16(siteOrigin, preferredRemoteType);
|
||||
} else if (isCOOPSwitch) {
|
||||
// If we're doing a COOP switch, we do not need any affinity to the
|
||||
// current remote type. Clear it back to the default value.
|
||||
preferredRemoteType = NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE);
|
||||
}
|
||||
}
|
||||
nsAutoString preferredRemoteType = currentRemoteType;
|
||||
|
||||
// If we're performing a large allocation load, override the remote type
|
||||
// with `LARGE_ALLOCATION_REMOTE_TYPE` to move it into an exclusive content
|
||||
// process. If we're already in one, and don't otherwise we force ourselves
|
||||
// out of that content process.
|
||||
bool isLargeAllocSwitch = false;
|
||||
if (browsingContext->IsTop() &&
|
||||
browsingContext->Group()->Toplevels().Length() == 1) {
|
||||
if (IsLargeAllocationLoad(browsingContext, mChannel)) {
|
||||
preferredRemoteType = NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE);
|
||||
replaceBrowsingContext = true;
|
||||
preferredRemoteType.Assign(
|
||||
NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE));
|
||||
isLargeAllocSwitch = true;
|
||||
} else if (preferredRemoteType.EqualsLiteral(
|
||||
LARGE_ALLOCATION_REMOTE_TYPE)) {
|
||||
preferredRemoteType = NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE);
|
||||
replaceBrowsingContext = true;
|
||||
preferredRemoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
|
||||
isLargeAllocSwitch = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Put toplevel BrowsingContexts which load within the extension process into
|
||||
// a specific BrowsingContextGroup.
|
||||
if (auto* addonPolicy = BasePrincipal::Cast(resultPrincipal)->AddonPolicy()) {
|
||||
if (browsingContext->IsTop()) {
|
||||
// Toplevel extension BrowsingContexts must be loaded in the extension
|
||||
// browsing context group, within the extension content process.
|
||||
if (ExtensionPolicyService::GetSingleton().UseRemoteExtensions()) {
|
||||
preferredRemoteType = NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE);
|
||||
} else {
|
||||
preferredRemoteType = VoidString();
|
||||
}
|
||||
|
||||
if (browsingContext->Group()->Id() !=
|
||||
addonPolicy->GetBrowsingContextGroupId()) {
|
||||
replaceBrowsingContext = true;
|
||||
specificGroupId = addonPolicy->GetBrowsingContextGroupId();
|
||||
}
|
||||
} else {
|
||||
// As a temporary measure, extension iframes must be loaded within the
|
||||
// same process as their parent document.
|
||||
preferredRemoteType =
|
||||
browsingContext->GetParentWindowContext()->GetRemoteType();
|
||||
}
|
||||
if (coop ==
|
||||
nsILoadInfo::OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP) {
|
||||
// We want documents with SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP COOP
|
||||
// policy to be loaded in a separate process in which we can enable
|
||||
// high-resolution timers.
|
||||
nsAutoCString siteOrigin;
|
||||
resultPrincipal->GetSiteOrigin(siteOrigin);
|
||||
preferredRemoteType.Assign(
|
||||
NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
|
||||
preferredRemoteType.Append(NS_ConvertUTF8toUTF16(siteOrigin));
|
||||
} else if (isCOOPSwitch) {
|
||||
// If we're doing a COOP switch, we do not need any affinity to the current
|
||||
// remote type. Clear it back to the default value.
|
||||
preferredRemoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
|
||||
}
|
||||
MOZ_DIAGNOSTIC_ASSERT(!contentParent || !preferredRemoteType.IsEmpty(),
|
||||
"Unexpected empty remote type!");
|
||||
|
||||
LOG(
|
||||
("DocumentLoadListener GetRemoteTypeForPrincipal "
|
||||
|
@ -1322,12 +1285,6 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
|
|||
return false;
|
||||
}
|
||||
|
||||
// Get information about the current document loaded in our BrowsingContext.
|
||||
nsCOMPtr<nsIPrincipal> currentPrincipal;
|
||||
if (auto* wgp = browsingContext->GetCurrentWindowGlobal()) {
|
||||
currentPrincipal = wgp->DocumentPrincipal();
|
||||
}
|
||||
|
||||
nsAutoString remoteType;
|
||||
rv = e10sUtils->GetRemoteTypeForPrincipal(
|
||||
resultPrincipal, mChannelCreationURI, browsingContext->UseRemoteTabs(),
|
||||
|
@ -1338,20 +1295,13 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
|
|||
return false;
|
||||
}
|
||||
|
||||
// If the final decision is to switch from an 'extension' remote type to any
|
||||
// other remote type, ensure the browsing context is replaced so that we leave
|
||||
// the extension-specific BrowsingContextGroup.
|
||||
if (browsingContext->IsTop() && currentRemoteType != remoteType &&
|
||||
currentRemoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE)) {
|
||||
replaceBrowsingContext = true;
|
||||
}
|
||||
|
||||
LOG(("GetRemoteTypeForPrincipal -> current:%s remoteType:%s",
|
||||
NS_ConvertUTF16toUTF8(currentRemoteType).get(),
|
||||
NS_ConvertUTF16toUTF8(remoteType).get()));
|
||||
|
||||
// Check if a process switch is needed.
|
||||
if (currentRemoteType == remoteType && !replaceBrowsingContext) {
|
||||
if (currentRemoteType == remoteType && !isCOOPSwitch && !isPreloadSwitch &&
|
||||
!isLargeAllocSwitch) {
|
||||
LOG(("Process Switch Abort: type (%s) is compatible",
|
||||
NS_ConvertUTF16toUTF8(remoteType).get()));
|
||||
return false;
|
||||
|
@ -1375,7 +1325,7 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
|
|||
LOG(("Process Switch: Calling ChangeRemoteness"));
|
||||
browsingContext
|
||||
->ChangeRemoteness(remoteType, mCrossProcessRedirectIdentifier,
|
||||
replaceBrowsingContext, specificGroupId)
|
||||
isCOOPSwitch || isLargeAllocSwitch)
|
||||
->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
[self = RefPtr{this}](BrowserParent* aBrowserParent) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "mozilla/AddonManagerWebAPI.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/StaticPrefs_extensions.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsISubstitutingProtocolHandler.h"
|
||||
|
@ -249,11 +248,6 @@ bool WebExtensionPolicy::Enable() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
// Reserve a BrowsingContextGroup ID for use by this WebExtensionPolicy.
|
||||
mBrowsingContextGroupId = nsContentUtils::GenerateBrowsingContextId();
|
||||
}
|
||||
|
||||
Unused << Proto()->SetSubstitution(MozExtensionHostname(), mBaseURI);
|
||||
|
||||
mActive = true;
|
||||
|
@ -491,11 +485,6 @@ void WebExtensionPolicy::GetReadyPromise(
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t WebExtensionPolicy::GetBrowsingContextGroupId() const {
|
||||
MOZ_ASSERT(XRE_IsParentProcess() && mActive);
|
||||
return mBrowsingContextGroupId;
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_WEAK_PTR(WebExtensionPolicy, mParent,
|
||||
mLocalizeCallback,
|
||||
mHostPermissions,
|
||||
|
|
|
@ -142,8 +142,6 @@ class WebExtensionPolicy final : public nsISupports,
|
|||
void GetReadyPromise(JSContext* aCx, JS::MutableHandleObject aResult) const;
|
||||
dom::Promise* ReadyPromise() const { return mReadyPromise; }
|
||||
|
||||
uint64_t GetBrowsingContextGroupId() const;
|
||||
|
||||
static void GetActiveExtensions(
|
||||
dom::GlobalObject& aGlobal,
|
||||
nsTArray<RefPtr<WebExtensionPolicy>>& aResults);
|
||||
|
@ -189,8 +187,6 @@ class WebExtensionPolicy final : public nsISupports,
|
|||
nsString mExtensionPageCSP;
|
||||
nsString mContentScriptCSP;
|
||||
|
||||
uint64_t mBrowsingContextGroupId = 0;
|
||||
|
||||
bool mActive = false;
|
||||
bool mAllowPrivateBrowsingByDefault = true;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче