Bug 1940688 - Add a pref to make top level pages always active for the purpose of refresh driver throttling and such. r=layout-reviewers,tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D233937
This commit is contained in:
Emilio Cobos Álvarez
2025-01-15 20:43:02 +00:00
parent 3c1b64acfe
commit e2b1d953d0
3 changed files with 16 additions and 1 deletions

View File

@@ -7364,7 +7364,7 @@ bool Document::ShouldThrottleFrameRequests() const {
return false;
}
if (Hidden()) {
if (Hidden() && !StaticPrefs::layout_testing_top_level_always_active()) {
// We're not visible (probably in a background tab or the bf cache).
return true;
}

View File

@@ -11246,6 +11246,12 @@ bool PresShell::ComputeActiveness() const {
MOZ_LOG(gLog, LogLevel::Debug,
(" > BrowsingContext %p active: %d", bc, inActiveTab));
if (StaticPrefs::layout_testing_top_level_always_active() && bc &&
bc->IsTop()) {
MOZ_LOG(gLog, LogLevel::Debug, (" > Activeness overridden by pref"));
return true;
}
Document* root = nsContentUtils::GetInProcessSubtreeRootDocument(doc);
if (auto* browserChild = BrowserChild::GetFrom(root->GetDocShell())) {
// We might want to activate a tab even though the browsing-context is not

View File

@@ -10040,6 +10040,15 @@
value: true
mirror: always
# Treat top level pages as always-active for the purpose of refresh driver
# throttling and such.
#
# Intended for testing automation and so forth.
- name: layout.testing.top-level-always-active
type: bool
value: false
mirror: always
# Pref to stop overlay scrollbars from fading out, for testing purposes.
- name: layout.testing.overlay-scrollbars.always-visible
type: bool