commit 6e74e112384ab402b1a5fa6d3a3c6dea972d05a6 parent 5c2e8dbbc1593dbc5682f035812cf51862daefcf Author: Harshit <hsohaney@mozilla.com> Date: Mon, 29 Dec 2025 14:00:53 +0000 Bug 2005845 - Add a check to ensure that the spotlight is loaded from the about page. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D276562 Diffstat:
6 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/browser/base/content/test/sanitize/browser_sanitizeOnShutdown_migration.js b/browser/base/content/test/sanitize/browser_sanitizeOnShutdown_migration.js @@ -48,7 +48,6 @@ add_task(async function testMigrationForDeleteOnClose() { ); // We are done changing settings in about:preferences, remove the tab BrowserTestUtils.removeTab(gBrowser.selectedTab); - // Open the clear on shutdown preferences dialog let dh = new ClearHistoryDialogHelper({ mode: "clearOnShutdown" }); dh.onload = function () { diff --git a/browser/components/backup/actors/BackupUIParent.sys.mjs b/browser/components/backup/actors/BackupUIParent.sys.mjs @@ -7,6 +7,7 @@ const lazy = {}; ChromeUtils.defineESModuleGetters(lazy, { BackupService: "resource:///modules/backup/BackupService.sys.mjs", ERRORS: "chrome://browser/content/backup/backup-constants.mjs", + E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs", }); ChromeUtils.defineLazyGetter(lazy, "logConsole", function () { @@ -121,6 +122,22 @@ export class BackupUIParent extends JSWindowActorParent { * Returns either a success object, a file details object, or null. */ async receiveMessage(message) { + let currentWindowGlobal = this.browsingContext.currentWindowGlobal; + // The backup spotlights can be embedded in less privileged content pages, so let's + // make sure that any messages from content are coming from the privileged + // about content process type + if ( + !currentWindowGlobal || + (!currentWindowGlobal.isInProcess && + this.browsingContext.currentRemoteType != + lazy.E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE) + ) { + lazy.logConsole.debug( + "BackupUIParent: received message from the wrong content process type." + ); + return null; + } + if (message.name == "RequestState") { this.sendState(); } else if (message.name == "TriggerCreateBackup") { diff --git a/browser/components/backup/tests/browser/browser_password_validation_inputs.js b/browser/components/backup/tests/browser/browser_password_validation_inputs.js @@ -10,11 +10,10 @@ const SCHEDULED_BACKUPS_ENABLED_PREF = "browser.backup.scheduled.enabled"; * as expected. */ add_task(async function password_validation() { - await SpecialPowers.pushPrefEnv({ - set: [[SCHEDULED_BACKUPS_ENABLED_PREF, true]], - }); - await BrowserTestUtils.withNewTab("about:preferences#sync", async browser => { + await SpecialPowers.pushPrefEnv({ + set: [[SCHEDULED_BACKUPS_ENABLED_PREF, true]], + }); let sandbox = sinon.createSandbox(); let settings = browser.contentDocument.querySelector("backup-settings"); diff --git a/browser/components/preferences/tests/browser_backup_visibility.js b/browser/components/preferences/tests/browser_backup_visibility.js @@ -7,14 +7,14 @@ * Test that we don't show the backup section if backup is disabled */ add_task(async function () { - await SpecialPowers.pushPrefEnv({ - set: [["browser.backup.archive.enabled", false]], - }); - await openPreferencesViaOpenPreferencesAPI("paneSync", { leaveOpen: true, }); + await SpecialPowers.pushPrefEnv({ + set: [["browser.backup.archive.enabled", false]], + }); + ok( gBrowser.contentDocument.getElementById("backupCategory").hidden, "backup category hidden" diff --git a/browser/components/preferences/tests/browser_browser_languages_subdialog.js b/browser/components/preferences/tests/browser_browser_languages_subdialog.js @@ -1036,9 +1036,10 @@ add_task(async function testLiveLanguageReloadingBidiOff() { ); await Promise.all(addons.map(addon => addon.uninstall())); - BrowserTestUtils.removeTab(gBrowser.selectedTab); assertTelemetryRecorded([["reorder", "main"]]); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); }); add_task(async function testLiveLanguageReloadingBidiOn() { @@ -1109,7 +1110,8 @@ add_task(async function testLiveLanguageReloadingBidiOn() { ); await Promise.all(addons.map(addon => addon.uninstall())); - BrowserTestUtils.removeTab(gBrowser.selectedTab); assertTelemetryRecorded([["reorder", "main"]]); + + BrowserTestUtils.removeTab(gBrowser.selectedTab); }); diff --git a/browser/components/profiles/tests/browser/browser_preferences.js b/browser/components/profiles/tests/browser/browser_preferences.js @@ -118,9 +118,8 @@ add_task(async function testHiddenWhenDisabled() { ok(profilesCategory, "The category exists"); ok(!BrowserTestUtils.isVisible(profilesCategory), "The category is hidden"); - BrowserTestUtils.removeTab(gBrowser.selectedTab); - await SpecialPowers.popPrefEnv(); + BrowserTestUtils.removeTab(gBrowser.selectedTab); }); add_task(async function testEnabled() { @@ -343,8 +342,8 @@ add_task(async function testPrivacyInfoHiddenWhenDisabled() { ok(!BrowserTestUtils.isVisible(profilesNote), "The profiles note is hidden"); - BrowserTestUtils.removeTab(gBrowser.selectedTab); await SpecialPowers.popPrefEnv(); + BrowserTestUtils.removeTab(gBrowser.selectedTab); }); // If the user disables data collection, then re-enables data collection in