commit 975e34dfef24a34168881b962a521c2388e066ae
parent b944a731f26eaccacbb4f93c6d36de569f37f31d
Author: Thomas Wisniewski <twisniewski@mozilla.com>
Date: Mon, 27 Oct 2025 21:03:14 +0000
Bug 1996081 - add a pref to silence debug logging from the webcompat addon, and enable it on an intermittent failing devtools test; r=ksenia,webcompat-reviewers,devtools-reviewers,ochameau
Differential Revision: https://phabricator.services.mozilla.com/D270259
Diffstat:
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/browser/extensions/webcompat/lib/interventions.js b/browser/extensions/webcompat/lib/interventions.js
@@ -6,6 +6,15 @@
/* globals browser, InterventionHelpers */
+const debugLoggingPrefPromise = browser.aboutConfigPrefs.getPref(
+ "disable_debug_logging"
+);
+let debugLog = async function () {
+ if ((await debugLoggingPrefPromise) !== true) {
+ console.debug.apply(this, arguments);
+ }
+};
+
class Interventions {
constructor(availableInterventions, customFunctions) {
this._originalInterventions = availableInterventions;
@@ -210,12 +219,12 @@ class Interventions {
);
if (value === true) {
await this.disableIntervention(config);
- console.debug(
+ debugLog(
`Webcompat intervention for ${config.label} disabled by pref`
);
} else {
await this.enableIntervention(config);
- console.debug(
+ debugLog(
`Webcompat intervention for ${config.label} enabled by pref`
);
}
@@ -289,7 +298,7 @@ class Interventions {
}
if (skipped.length) {
- console.debug(
+ debugLog(
"Skipping",
skipped.length,
"un-needed interventions",
@@ -356,15 +365,11 @@ class Interventions {
if (!this._getActiveInterventionById(config.id)) {
this._availableInterventions.push(config);
- console.debug("Added webcompat intervention", config.id, config);
+ debugLog("Added webcompat intervention", config.id, config);
} else {
for (const [index, oldConfig] of this._availableInterventions.entries()) {
if (oldConfig.id === config.id && oldConfig !== config) {
- console.debug(
- "Replaced webcompat intervention",
- oldConfig.id,
- config
- );
+ debugLog("Replaced webcompat intervention", oldConfig.id, config);
this._availableInterventions[index] = config;
}
}
@@ -480,7 +485,7 @@ class Interventions {
listeners.onBeforeSendHeaders = listener;
- console.debug(`Enabled UA override for ${label}`);
+ debugLog(`Enabled UA override for ${label}`);
}
async _enableRequestBlocks(label, intervention, blocks) {
@@ -503,7 +508,7 @@ class Interventions {
]);
listeners.onBeforeRequest = listener;
- console.debug(`Blocking requests as specified for ${label}`);
+ debugLog(`Blocking requests as specified for ${label}`);
}
async _enableContentScripts(bug, label, intervention, matches) {
@@ -531,14 +536,14 @@ class Interventions {
({ id }) => !alreadyReggedIds.includes(id)
);
await browser.scripting.registerContentScripts(stillNeeded);
- console.debug(
+ debugLog(
`Registered still-not-active content scripts for ${label}`,
stillNeeded
);
} catch (e) {
try {
await browser.scripting.registerContentScripts(scriptsToReg);
- console.debug(
+ debugLog(
`Registered all content scripts for ${label} after error registering just non-active ones`,
scriptsToReg,
e
diff --git a/browser/extensions/webcompat/lib/shims.js b/browser/extensions/webcompat/lib/shims.js
@@ -12,6 +12,10 @@
// on tabs where a shim using a given logo happens to be active).
const LogosBaseURL = "https://smartblock.firefox.etp/";
+const loggingPrefPromise = browser.aboutConfigPrefs.getPref(
+ "disable_debug_logging"
+);
+
const releaseBranchPromise = browser.appConstants.getReleaseBranch();
const platformPromise = browser.runtime.getPlatformInfo().then(info => {
@@ -19,7 +23,10 @@ const platformPromise = browser.runtime.getPlatformInfo().then(info => {
});
let debug = async function () {
- if ((await releaseBranchPromise) !== "release_or_beta") {
+ if (
+ (await loggingPrefPromise) !== true &&
+ (await releaseBranchPromise) !== "release_or_beta"
+ ) {
console.debug.apply(this, arguments);
}
};
diff --git a/devtools/client/framework/test/allocations/browser_allocations_browser_console.toml b/devtools/client/framework/test/allocations/browser_allocations_browser_console.toml
@@ -5,6 +5,7 @@ support-files = [
"!/devtools/shared/test-helpers/allocation-tracker.js",
"head.js",
]
+prefs = "extensions.webcompat.disable_debug_logging=true"
# Each metrics tests is loaded in a separate .ini file. This way the test is executed
# individually, without any other test being executed before or after.