commit 39d07234cfea49c813053b01908d35626d75f1c5 parent b93e40e1e23baa885fd419a45d574efe80c87547 Author: Luca Greco <lgreco@mozilla.com> Date: Thu, 16 Oct 2025 18:52:47 +0000 Bug 1994389 - Fix about:telemetry tab fails to load correctly after first startup on a new profile. r=TravisLong,willdurand,toolkit-telemetry-reviewers Differential Revision: https://phabricator.services.mozilla.com/D268749 Diffstat:
4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs b/toolkit/components/telemetry/tests/unit/TelemetryEnvironmentTesting.sys.mjs @@ -1124,7 +1124,11 @@ export var TelemetryEnvironmentTesting = { } // Check "theme" structure. - if (data.addons.theme) { + // NOTE: theme is expected to be set to an empty object while the theme is + // not installed or enabled yet by the time the telemetry environment is + // capturing the active addons and themes early during the first at startup, + // see Bug 1994389. + if (Object.keys(data.addons.theme).length !== 0) { this.checkTheme(data.addons.theme); } diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js @@ -196,6 +196,18 @@ add_task(async function test_checkEnvironment() { ); let data = TelemetryEnvironment.currentEnvironment; + + // NOTE: about:telemetry expects the active theme to always be set, if no theme + // was enabled and active (eg. because the theme has not been installed yet and + // enabled yet) then it should be set to an empty object. This assertion is + // meant to prevent issues like Bug 1994389 to regress without being caught by + // the TelemetryEnvironment unit tests. + Assert.deepEqual( + data.addons.theme, + {}, + "Expect active theme property to be set to an empty object" + ); + TelemetryEnvironmentTesting.checkAddonsSection(data, false, true); // Check that settings.intl is lazily loaded. diff --git a/toolkit/mozapps/extensions/AddonManager.sys.mjs b/toolkit/mozapps/extensions/AddonManager.sys.mjs @@ -5071,7 +5071,9 @@ export class EnvironmentAddonBuilder { let addons = { activeAddons: await this._getActiveAddons(), - theme: await this._getActiveTheme(), + // NOTE: about:telemetry expects `theme` to always be set to an object (potentially empty + // if no theme was yet found installed and active), see Bug 1994389. + theme: (await this._getActiveTheme()) ?? {}, activeGMPlugins: await this._getActiveGMPlugins(), }; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_EnvironmentAddonBuilder_telemetry.js b/toolkit/mozapps/extensions/test/xpcshell/test_EnvironmentAddonBuilder_telemetry.js @@ -206,7 +206,12 @@ function checkEnvironmentAddonBuilderData( } // Check "theme" structure. - if (data.addons.theme) { + // + // NOTE: theme is expected to be set to an empty object while the theme is + // not installed or enabled yet by the time the telemetry environment is + // capturing the active addons and themes early during the first at startup, + // see Bug 1994389. + if (data.addons.theme?.id) { checkTheme(data.addons.theme); }