commit 381d870c63af5fa426f873eff1192c9e4efb1f76
parent 53e6a02102397e67564b9323483caae68c0d7754
Author: Mark Banner <standard8@mozilla.com>
Date: Tue, 21 Oct 2025 20:22:10 +0000
Bug 1995338 - Hide the improve preference for all users. r=adw,urlbar-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D269266
Diffstat:
4 files changed, 85 insertions(+), 8 deletions(-)
diff --git a/browser/components/urlbar/QuickSuggest.sys.mjs b/browser/components/urlbar/QuickSuggest.sys.mjs
@@ -892,7 +892,7 @@ class _QuickSuggest {
* @returns {number}
*/
get MIGRATION_VERSION() {
- return 3;
+ return 4;
}
/**
@@ -995,9 +995,17 @@ class _QuickSuggest {
}
_migrateFirefoxSuggestPrefsTo_3() {
- if (lazy.UrlbarPrefs.get("quicksuggest.dataCollection.enabled")) {
- lazy.UrlbarPrefs.set("quicksuggest.settingsUi", SETTINGS_UI.FULL);
- }
+ // This used to check the `quicksuggest.dataCollection.enabled` preference
+ // and set `quicksuggest.settingsUi` to `SETTINGS_UI.FULL` if data collection
+ // was enabled. However, this is now cleared for everyone in the v4 migration,
+ // hence there is nothing to do here.
+ }
+
+ _migrateFirefoxSuggestPrefsTo_4() {
+ // This will reset the pref to the default value, i.e. SETTINGS_UI.OFFLINE_ONLY
+ // for users where suggest is enabled, or SETTINGS_UI.NONE where it is not
+ // enabled.
+ lazy.UrlbarPrefs.clear("quicksuggest.settingsUi");
}
async _test_reset(testOverrides = null) {
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v3.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v3.js
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-// Tests quick suggest prefs migration from version 2 to 3.
+// Tests quick suggest prefs migration from version 2 to 4.
"use strict";
@@ -25,7 +25,7 @@ add_setup(async () => {
await UrlbarTestUtils.initNimbusFeature();
});
-// The following tasks test OFFLINE version 2 to version 3 when SUGGEST IS ENABLED.
+// The following tasks test OFFLINE version 2 to version 4 when SUGGEST IS ENABLED.
// Migrating from:
// * User enabled `quicksuggest.dataCollection.enabled`
@@ -34,7 +34,7 @@ add_setup(async () => {
// * Yes
//
// Expected:
-// * quicksuggest.settingsUi set to FULL on the User Branch
+// * quicksuggest.settingsUi is not set on the user branch.
add_task(async function test_migrate_with_datacollection_enabled() {
await doMigrateTest({
testOverrides: TEST_OVERRIDES,
@@ -45,7 +45,6 @@ add_task(async function test_migrate_with_datacollection_enabled() {
defaultBranch: DEFAULT_PREFS,
userBranch: {
"quicksuggest.dataCollection.enabled": true,
- "quicksuggest.settingsUi": QuickSuggest.SETTINGS_UI.FULL,
},
},
});
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v4.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v4.js
@@ -0,0 +1,68 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Tests quick suggest prefs migration from version 3 to 4.
+
+"use strict";
+
+// Expected version 3 default-branch prefs (important core prefs only, assuming
+// US region and en-US locale).
+const DEFAULT_PREFS = {
+ "quicksuggest.enabled": true,
+ "quicksuggest.dataCollection.enabled": false,
+ "quicksuggest.settingsUi": QuickSuggest.SETTINGS_UI.FULL,
+ "suggest.quicksuggest.nonsponsored": true,
+ "suggest.quicksuggest.sponsored": true,
+};
+
+const TEST_OVERRIDES = {
+ migrationVersion: 4,
+ defaultPrefs: DEFAULT_PREFS,
+};
+
+add_setup(async () => {
+ await UrlbarTestUtils.initNimbusFeature();
+});
+
+// The following tasks test OFFLINE version 3 to version 4 when SUGGEST IS ENABLED.
+
+// Migrating from:
+// * User enabled `quicksuggest.dataCollection.enabled`
+//
+// Suggest enabled when migration occurs:
+// * Yes
+//
+// Expected:
+// * quicksuggest.settingsUi not set on the User Branch
+add_task(async function test_migrate_with_datacollection_enabled() {
+ await doMigrateTest({
+ testOverrides: TEST_OVERRIDES,
+ initialUserBranch: {
+ "quicksuggest.dataCollection.enabled": true,
+ },
+ expectedPrefs: {
+ defaultBranch: DEFAULT_PREFS,
+ userBranch: {
+ "quicksuggest.dataCollection.enabled": true,
+ },
+ },
+ });
+});
+
+// Migrating from:
+// * User has not enabled `quicksuggest.dataCollection.enabled`
+//
+// Suggest enabled when migration occurs:
+// * Yes
+//
+// Expected:
+// * quicksuggest.settingsUi not set on the User Branch
+add_task(async function test_migrate_with_datacollection_disabled() {
+ await doMigrateTest({
+ testOverrides: TEST_OVERRIDES,
+ expectedPrefs: {
+ defaultBranch: DEFAULT_PREFS,
+ },
+ });
+});
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/xpcshell.toml b/browser/components/urlbar/tests/quicksuggest/unit/xpcshell.toml
@@ -46,6 +46,8 @@ skip-if = ["true"] # Bug 1880214
["test_quicksuggest_migrate_v3.js"]
+["test_quicksuggest_migrate_v4.js"]
+
["test_quicksuggest_offlineDefault.js"]
requesttimeoutfactor = 2 # Slow on Linux and Windows