Bug 1890076 - Make browser.startup.record and browser.startup.recordImage static prefs. r=florian

Differential Revision: https://phabricator.services.mozilla.com/D206830
This commit is contained in:
Mike Conley 2024-04-18 21:24:41 +00:00
Родитель 62f13f310c
Коммит fcf4e263b0
4 изменённых файлов: 29 добавлений и 27 удалений

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

@ -70,13 +70,6 @@ function checkPrefGetters(stats, max, knownProblematicPrefs = {}) {
} }
} }
// This pref will be accessed by mozJSComponentLoader when loading modules,
// which fails TV runs since they run the test multiple times without restarting.
// We just ignore this pref, since it's for testing only anyway.
if (knownProblematicPrefs["browser.startup.record"]) {
delete knownProblematicPrefs["browser.startup.record"];
}
let unusedPrefs = Object.keys(knownProblematicPrefs); let unusedPrefs = Object.keys(knownProblematicPrefs);
is( is(
unusedPrefs.length, unusedPrefs.length,
@ -104,18 +97,9 @@ add_task(async function startup() {
let max = 40; let max = 40;
let knownProblematicPrefs = { let knownProblematicPrefs = {
"browser.startup.record": {
// This pref is accessed in Nighly and debug builds only.
min: 200,
max: 450,
},
"network.loadinfo.skip_type_assertion": { "network.loadinfo.skip_type_assertion": {
// This is accessed in debug only. // This is accessed in debug only.
}, },
"chrome.override_package.global": {
min: 0,
max: 50,
},
}; };
let startupRecorder = let startupRecorder =
@ -135,9 +119,6 @@ add_task(async function open_10_tabs() {
const max = 4 * DEFAULT_PROCESS_COUNT; const max = 4 * DEFAULT_PROCESS_COUNT;
let knownProblematicPrefs = { let knownProblematicPrefs = {
"browser.startup.record": {
max: 20,
},
"browser.tabs.remote.logSwitchTiming": { "browser.tabs.remote.logSwitchTiming": {
max: 35, max: 35,
}, },

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

@ -6,6 +6,23 @@ const Cm = Components.manager;
Cm.QueryInterface(Ci.nsIServiceManager); Cm.QueryInterface(Ci.nsIServiceManager);
import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs"; import { AppConstants } from "resource://gre/modules/AppConstants.sys.mjs";
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"BROWSER_STARTUP_RECORD",
"browser.startup.record",
false
);
XPCOMUtils.defineLazyPreferenceGetter(
lazy,
"BROWSER_STARTUP_RECORD_IMAGES",
"browser.startup.recordImages",
false
);
let firstPaintNotification = "widget-first-paint"; let firstPaintNotification = "widget-first-paint";
// widget-first-paint fires much later than expected on Linux. // widget-first-paint fires much later than expected on Linux.
@ -98,10 +115,7 @@ StartupRecorder.prototype = {
return; return;
} }
if ( if (!lazy.BROWSER_STARTUP_RECORD && !lazy.BROWSER_STARTUP_RECORD_IMAGES) {
!Services.prefs.getBoolPref("browser.startup.record", false) &&
!Services.prefs.getBoolPref("browser.startup.recordImages", false)
) {
this._resolve(); this._resolve();
this._resolve = null; this._resolve = null;
return; return;
@ -118,7 +132,7 @@ StartupRecorder.prototype = {
"browser-startup-idle-tasks-finished", "browser-startup-idle-tasks-finished",
]; ];
if (Services.prefs.getBoolPref("browser.startup.recordImages", false)) { if (lazy.BROWSER_STARTUP_RECORD_IMAGES) {
// For code simplicify, recording images excludes the other startup // For code simplicify, recording images excludes the other startup
// recorder behaviors, so we can observe only the image topics. // recorder behaviors, so we can observe only the image topics.
topics = [ topics = [
@ -180,7 +194,7 @@ StartupRecorder.prototype = {
this.record.bind(this, "before handling user events") this.record.bind(this, "before handling user events")
); );
} else if (topic == "browser-startup-idle-tasks-finished") { } else if (topic == "browser-startup-idle-tasks-finished") {
if (Services.prefs.getBoolPref("browser.startup.recordImages", false)) { if (lazy.BROWSER_STARTUP_RECORD_IMAGES) {
Services.obs.removeObserver(this, "image-drawing"); Services.obs.removeObserver(this, "image-drawing");
Services.obs.removeObserver(this, "image-loading"); Services.obs.removeObserver(this, "image-loading");
this._resolve(); this._resolve();

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

@ -1505,7 +1505,7 @@ nsresult mozJSModuleLoader::GetLoadedJSAndESModules(
#ifdef STARTUP_RECORDER_ENABLED #ifdef STARTUP_RECORDER_ENABLED
void mozJSModuleLoader::RecordImportStack(JSContext* aCx, void mozJSModuleLoader::RecordImportStack(JSContext* aCx,
const nsACString& aLocation) { const nsACString& aLocation) {
if (!Preferences::GetBool("browser.startup.record", false)) { if (!StaticPrefs::browser_startup_record()) {
return; return;
} }
@ -1515,7 +1515,7 @@ void mozJSModuleLoader::RecordImportStack(JSContext* aCx,
void mozJSModuleLoader::RecordImportStack( void mozJSModuleLoader::RecordImportStack(
JSContext* aCx, JS::loader::ModuleLoadRequest* aRequest) { JSContext* aCx, JS::loader::ModuleLoadRequest* aRequest) {
if (!Preferences::GetBool("browser.startup.record", false)) { if (!StaticPrefs::browser_startup_record()) {
return; return;
} }

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

@ -1659,6 +1659,13 @@
mirror: once mirror: once
do_not_use_directly: true do_not_use_directly: true
#if defined(NIGHTLY_BUILD) || defined(MOZ_DEV_EDITION) || defined(DEBUG)
- name: browser.startup.record
type: bool
value: false
mirror: always
#endif
# Causes SessionStore to ignore non-final update messages from # Causes SessionStore to ignore non-final update messages from
# browser tabs that were not caused by a flush from the parent. # browser tabs that were not caused by a flush from the parent.
# This is a testing flag and should not be used by end-users. # This is a testing flag and should not be used by end-users.