commit 5530250cfc2f8d817ae47b4735d807ddb56d727f
parent 2d40e63c43e81b4cc9d53b3f43c7bc0336e6a695
Author: Drew Willcoxon <adw@mozilla.com>
Date: Mon, 27 Oct 2025 22:28:21 +0000
Bug 1995574 - Part 4: Add a Suggest migration: Replace the `browser.urlbar.suggest.quicksuggest.nonsponsored` pref with `browser.urlbar.suggest.quicksuggest.all`. r=daisuke,Standard8,urlbar-reviewers
This adds a migration that copies the `nonsponsored` pref to the new `all` pref.
Depends on D269895
Differential Revision: https://phabricator.services.mozilla.com/D269896
Diffstat:
3 files changed, 128 insertions(+), 1 deletion(-)
diff --git a/browser/components/urlbar/QuickSuggest.sys.mjs b/browser/components/urlbar/QuickSuggest.sys.mjs
@@ -888,7 +888,7 @@ class _QuickSuggest {
* @returns {number}
*/
get MIGRATION_VERSION() {
- return 5;
+ return 6;
}
/**
@@ -1037,6 +1037,25 @@ class _QuickSuggest {
}
}
+ _migrateUserPrefsTo_6(userBranch) {
+ // Firefox 146 no longer uses `suggest.quicksuggest.nonsponsored` and stops
+ // setting it on the default branch. It introduces
+ // `suggest.quicksuggest.all`, which now controls all suggestions that are
+ // part of the Suggest brand, both sponsored and nonsponsored. To show
+ // nonsponsored suggestions, `all` must be true. To show sponsored
+ // suggestions, both `all` and `suggest.quicksuggest.sponsored` must be
+ // true.
+ //
+ // This migration copies the user-branch value of `nonsponsored` to the new
+ // `all` pref. We keep the user-branch value in case we need it later.
+ if (userBranch.prefHasUserValue("suggest.quicksuggest.nonsponsored")) {
+ userBranch.setBoolPref(
+ "suggest.quicksuggest.all",
+ userBranch.getBoolPref("suggest.quicksuggest.nonsponsored")
+ );
+ }
+ }
+
async _test_reset(testOverrides = null) {
if (this.#initStarted) {
await this.initPromise;
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v6.js b/browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v6.js
@@ -0,0 +1,106 @@
+/* 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 Suggest prefs migration from version 5 to 6.
+
+"use strict";
+
+const TO_VERSION = 6;
+
+add_setup(async () => {
+ await setUpMigrateTest();
+});
+
+// No user-branch values set before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ });
+});
+
+// Nonsponsored false on the user branch before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ preMigrationUserPrefs: {
+ "suggest.quicksuggest.nonsponsored": false,
+ },
+ expectedPostMigrationUserPrefs: {
+ "suggest.quicksuggest.all": false,
+ "suggest.quicksuggest.nonsponsored": false,
+ },
+ });
+});
+
+// Nonsponsored true on the user branch before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ preMigrationUserPrefs: {
+ "suggest.quicksuggest.nonsponsored": true,
+ },
+ expectedPostMigrationUserPrefs: {
+ "suggest.quicksuggest.all": true,
+ "suggest.quicksuggest.nonsponsored": true,
+ },
+ });
+});
+
+// Nonsponsored and sponsored both false on the user branch before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ preMigrationUserPrefs: {
+ "suggest.quicksuggest.nonsponsored": false,
+ "suggest.quicksuggest.sponsored": false,
+ },
+ expectedPostMigrationUserPrefs: {
+ "suggest.quicksuggest.all": false,
+ "suggest.quicksuggest.nonsponsored": false,
+ "suggest.quicksuggest.sponsored": false,
+ },
+ });
+});
+
+// Nonsponsored false sponsored true on the user branch before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ preMigrationUserPrefs: {
+ "suggest.quicksuggest.nonsponsored": false,
+ "suggest.quicksuggest.sponsored": true,
+ },
+ expectedPostMigrationUserPrefs: {
+ "suggest.quicksuggest.all": false,
+ "suggest.quicksuggest.nonsponsored": false,
+ "suggest.quicksuggest.sponsored": true,
+ },
+ });
+});
+
+// Sponsored false on the user branch before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ preMigrationUserPrefs: {
+ "suggest.quicksuggest.sponsored": false,
+ },
+ expectedPostMigrationUserPrefs: {
+ "suggest.quicksuggest.sponsored": false,
+ },
+ });
+});
+
+// Sponsored true on the user branch before migration
+add_task(async function () {
+ await doMigrateTest({
+ toVersion: TO_VERSION,
+ preMigrationUserPrefs: {
+ "suggest.quicksuggest.sponsored": true,
+ },
+ expectedPostMigrationUserPrefs: {
+ "suggest.quicksuggest.sponsored": true,
+ },
+ });
+});
diff --git a/browser/components/urlbar/tests/quicksuggest/unit/xpcshell.toml b/browser/components/urlbar/tests/quicksuggest/unit/xpcshell.toml
@@ -53,6 +53,8 @@ skip-if = ["true"] # Bug 1880214
["test_quicksuggest_migrate_v5.js"]
+["test_quicksuggest_migrate_v6.js"]
+
["test_quicksuggest_relevanceRanking.js"]
["test_quicksuggest_remoteSettingsFilter.js"]