Bug 1639577 - Only suspend GeckoView tabs that are alone in their BrowsingContextGroup r=nika,geckoview-reviewers,agi
This avoids problems where a foreground tab tries to communicate with a background tab via `window.opener`, but is unable to because the background tab is suspended. Differential Revision: https://phabricator.services.mozilla.com/D83693
This commit is contained in:
@@ -43,7 +43,8 @@ already_AddRefed<BrowsingContextGroup> BrowsingContextGroup::Create() {
|
||||
return GetOrCreate(nsContentUtils::GenerateBrowsingContextId());
|
||||
}
|
||||
|
||||
BrowsingContextGroup::BrowsingContextGroup(uint64_t aId) : mId(aId) {
|
||||
BrowsingContextGroup::BrowsingContextGroup(uint64_t aId)
|
||||
: mId(aId), mToplevelsSuspended(false) {
|
||||
mTimerEventQueue = ThrottledEventQueue::Create(
|
||||
GetMainThreadSerialEventTarget(), "BrowsingContextGroup timer queue");
|
||||
|
||||
@@ -147,6 +148,26 @@ void BrowsingContextGroup::EnsureSubscribed(ContentParent* aProcess) {
|
||||
}
|
||||
}
|
||||
|
||||
void BrowsingContextGroup::SetToplevelsSuspended(bool aSuspended) {
|
||||
for (const auto& context : mToplevels) {
|
||||
nsPIDOMWindowOuter* outer = context->GetDOMWindow();
|
||||
if (outer) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> inner = outer->GetCurrentInnerWindow();
|
||||
if (inner) {
|
||||
if (aSuspended && !inner->GetWasSuspendedByGroup()) {
|
||||
inner->Suspend();
|
||||
inner->SetWasSuspendedByGroup(true);
|
||||
} else if (!aSuspended && inner->GetWasSuspendedByGroup()) {
|
||||
inner->Resume();
|
||||
inner->SetWasSuspendedByGroup(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mToplevelsSuspended = aSuspended;
|
||||
}
|
||||
|
||||
BrowsingContextGroup::~BrowsingContextGroup() {
|
||||
UnsubscribeAllContentParents();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user