Skip to content

Commit c522a0d

Browse files
authored
browser(firefox): force always active docshell (#4363)
This forces active docshell for all content processes. References #4208
1 parent 49e4d9a commit c522a0d

File tree

3 files changed

+43
-13
lines changed

3 files changed

+43
-13
lines changed

browser_patches/firefox/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1202
2-
Changed: yurys@chromium.org Thu Nov 5 20:30:30 GMTST 2020
1+
1203
2+
Changed: lushnikov@chromium.org Thu Nov 5 17:39:41 PST 2020

browser_patches/firefox/juggler/content/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function initialize() {
9292

9393
// Enforce focused state for all top level documents.
9494
docShell.overrideHasFocus = true;
95+
docShell.forceActiveState = true;
9596
frameTree = new FrameTree(docShell);
9697
for (const [name, value] of Object.entries(settings)) {
9798
if (value !== undefined)

browser_patches/firefox/patches/bootstrap.diff

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ index 040c7b124dec6bb254563bbe74fe50012cb077a3..b4e6b8132786af70e8ad0dce88b67c28
178178
const transportProvider = {
179179
setListener(upgradeListener) {
180180
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
181-
index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336a1baf2e4 100644
181+
index 665db419cb4909d34cdd3963d922aed12cf2c8ac..feadde48633ee78a5910c776d34d42864bf0e682 100644
182182
--- a/docshell/base/nsDocShell.cpp
183183
+++ b/docshell/base/nsDocShell.cpp
184184
@@ -15,6 +15,12 @@
@@ -226,27 +226,28 @@ index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336
226226
#include "nsNetCID.h"
227227
#include "nsNetUtil.h"
228228
#include "nsObjectLoadingContent.h"
229-
@@ -391,6 +401,11 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
229+
@@ -391,6 +401,12 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
230230
mAllowDNSPrefetch(true),
231231
mAllowWindowControl(true),
232232
mCSSErrorReportingEnabled(false),
233233
+ mFileInputInterceptionEnabled(false),
234234
+ mOverrideHasFocus(false),
235235
+ mBypassCSPEnabled(false),
236+
+ mForceActiveState(false),
236237
+ mOnlineOverride(nsIDocShell::ONLINE_OVERRIDE_NONE),
237238
+ mColorSchemeOverride(COLOR_SCHEME_OVERRIDE_NONE),
238239
mAllowAuth(mItemType == typeContent),
239240
mAllowKeywordFixup(false),
240241
mIsOffScreenBrowser(false),
241-
@@ -1418,6 +1433,7 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
242+
@@ -1418,6 +1434,7 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
242243
}
243244
}
244245

245246
+ FireOnFrameLocationChange(this, aRequest, aURI, aLocationFlags);
246247
if (!isSubFrame && !isRoot) {
247248
/*
248249
* We don't want to send OnLocationChange notifications when
249-
@@ -3214,6 +3230,189 @@ nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager) {
250+
@@ -3214,6 +3231,204 @@ nsDocShell::GetMessageManager(ContentFrameMessageManager** aMessageManager) {
250251
return NS_OK;
251252
}
252253

@@ -272,6 +273,21 @@ index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336
272273
+ return NS_OK;
273274
+}
274275
+
276+
+NS_IMETHODIMP
277+
+nsDocShell::GetForceActiveState(bool* aEnabled) {
278+
+ MOZ_ASSERT(aEnabled);
279+
+ *aEnabled = mForceActiveState;
280+
+ return NS_OK;
281+
+}
282+
+
283+
+NS_IMETHODIMP
284+
+nsDocShell::SetForceActiveState(bool aEnabled) {
285+
+ mForceActiveState = aEnabled;
286+
+ if (aEnabled)
287+
+ SetIsActive(true);
288+
+ return NS_OK;
289+
+}
290+
+
275291
+bool nsDocShell::IsBypassCSPEnabled() {
276292
+ return GetRootDocShell()->mBypassCSPEnabled;
277293
+}
@@ -436,7 +452,17 @@ index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336
436452
NS_IMETHODIMP
437453
nsDocShell::GetIsNavigating(bool* aOut) {
438454
*aOut = mIsNavigating;
439-
@@ -8526,6 +8725,12 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
455+
@@ -4821,6 +5036,9 @@ nsDocShell::GetSuspendMediaWhenInactive(bool* aSuspendMediaWhenInactive) {
456+
457+
NS_IMETHODIMP
458+
nsDocShell::SetIsActive(bool aIsActive) {
459+
+ if (mForceActiveState && !aIsActive)
460+
+ return NS_OK;
461+
+
462+
// Keep track ourselves.
463+
// Changing the activeness on a discarded browsing context has no effect.
464+
Unused << mBrowsingContext->SetIsActive(aIsActive);
465+
@@ -8526,6 +8744,12 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
440466
true, // aForceNoOpener
441467
getter_AddRefs(newBC));
442468
MOZ_ASSERT(!newBC);
@@ -449,7 +475,7 @@ index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336
449475
return rv;
450476
}
451477

452-
@@ -12413,6 +12618,9 @@ class OnLinkClickEvent : public Runnable {
478+
@@ -12413,6 +12637,9 @@ class OnLinkClickEvent : public Runnable {
453479
mHandler->OnLinkClickSync(mContent, mLoadState, mNoOpenerImplied,
454480
mTriggeringPrincipal);
455481
}
@@ -459,7 +485,7 @@ index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336
459485
return NS_OK;
460486
}
461487

462-
@@ -12498,6 +12706,8 @@ nsresult nsDocShell::OnLinkClick(
488+
@@ -12498,6 +12725,8 @@ nsresult nsDocShell::OnLinkClick(
463489
nsCOMPtr<nsIRunnable> ev =
464490
new OnLinkClickEvent(this, aContent, loadState, noOpenerImplied,
465491
aIsTrusted, aTriggeringPrincipal);
@@ -469,7 +495,7 @@ index 665db419cb4909d34cdd3963d922aed12cf2c8ac..9323dade18a7780802275fa6fcebe336
469495
}
470496

471497
diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h
472-
index 0d3594f977ac28595f830cbc5e310a8af284d777..7e3222a0cafc3f38e335c9dc8654019a067a7a39 100644
498+
index 0d3594f977ac28595f830cbc5e310a8af284d777..0149141757abef2787a09bba20d98714fd50d50d 100644
473499
--- a/docshell/base/nsDocShell.h
474500
+++ b/docshell/base/nsDocShell.h
475501
@@ -13,6 +13,7 @@
@@ -513,13 +539,14 @@ index 0d3594f977ac28595f830cbc5e310a8af284d777..7e3222a0cafc3f38e335c9dc8654019a
513539
// Handles retrieval of subframe session history for nsDocShell::LoadURI. If a
514540
// load is requested in a subframe of the current DocShell, the subframe
515541
// loadType may need to reflect the loadType of the parent document, or in
516-
@@ -1264,6 +1277,14 @@ class nsDocShell final : public nsDocLoader,
542+
@@ -1264,6 +1277,15 @@ class nsDocShell final : public nsDocLoader,
517543
bool mAllowDNSPrefetch : 1;
518544
bool mAllowWindowControl : 1;
519545
bool mCSSErrorReportingEnabled : 1;
520546
+ bool mFileInputInterceptionEnabled: 1;
521547
+ bool mOverrideHasFocus : 1;
522548
+ bool mBypassCSPEnabled : 1;
549+
+ bool mForceActiveState : 1;
523550
+ nsString mLanguageOverride;
524551
+ RefPtr<nsGeolocationService> mGeolocationServiceOverride;
525552
+ OnlineOverride mOnlineOverride;
@@ -529,7 +556,7 @@ index 0d3594f977ac28595f830cbc5e310a8af284d777..7e3222a0cafc3f38e335c9dc8654019a
529556
bool mAllowKeywordFixup : 1;
530557
bool mIsOffScreenBrowser : 1;
531558
diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl
532-
index 605de327047b338a0abde638e3b3a9fc5a617815..773511a4ae35b14262afeb3d005b437d30d96c0a 100644
559+
index 605de327047b338a0abde638e3b3a9fc5a617815..4e16debccf367a72c07660fb92015c5fb5de9b34 100644
533560
--- a/docshell/base/nsIDocShell.idl
534561
+++ b/docshell/base/nsIDocShell.idl
535562
@@ -44,6 +44,7 @@ interface nsIURI;
@@ -540,7 +567,7 @@ index 605de327047b338a0abde638e3b3a9fc5a617815..773511a4ae35b14262afeb3d005b437d
540567
interface nsIDocShellLoadInfo;
541568
interface nsIEditor;
542569
interface nsIEditingSession;
543-
@@ -923,6 +924,33 @@ interface nsIDocShell : nsIDocShellTreeItem
570+
@@ -923,6 +924,35 @@ interface nsIDocShell : nsIDocShellTreeItem
544571
*/
545572
void synchronizeLayoutHistoryState();
546573

@@ -550,6 +577,8 @@ index 605de327047b338a0abde638e3b3a9fc5a617815..773511a4ae35b14262afeb3d005b437d
550577
+
551578
+ attribute boolean bypassCSPEnabled;
552579
+
580+
+ attribute boolean forceActiveState;
581+
+
553582
+ attribute AString languageOverride;
554583
+
555584
+ boolean overrideTimezone(in AString timezoneId);

0 commit comments

Comments
 (0)