Skip to content

Commit 381d870

Browse files
committed
Bug 1995338 - Hide the improve preference for all users. r=adw,urlbar-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D269266
1 parent 53e6a02 commit 381d870

File tree

4 files changed

+85
-8
lines changed

4 files changed

+85
-8
lines changed

browser/components/urlbar/QuickSuggest.sys.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ class _QuickSuggest {
892892
* @returns {number}
893893
*/
894894
get MIGRATION_VERSION() {
895-
return 3;
895+
return 4;
896896
}
897897

898898
/**
@@ -995,9 +995,17 @@ class _QuickSuggest {
995995
}
996996

997997
_migrateFirefoxSuggestPrefsTo_3() {
998-
if (lazy.UrlbarPrefs.get("quicksuggest.dataCollection.enabled")) {
999-
lazy.UrlbarPrefs.set("quicksuggest.settingsUi", SETTINGS_UI.FULL);
1000-
}
998+
// This used to check the `quicksuggest.dataCollection.enabled` preference
999+
// and set `quicksuggest.settingsUi` to `SETTINGS_UI.FULL` if data collection
1000+
// was enabled. However, this is now cleared for everyone in the v4 migration,
1001+
// hence there is nothing to do here.
1002+
}
1003+
1004+
_migrateFirefoxSuggestPrefsTo_4() {
1005+
// This will reset the pref to the default value, i.e. SETTINGS_UI.OFFLINE_ONLY
1006+
// for users where suggest is enabled, or SETTINGS_UI.NONE where it is not
1007+
// enabled.
1008+
lazy.UrlbarPrefs.clear("quicksuggest.settingsUi");
10011009
}
10021010

10031011
async _test_reset(testOverrides = null) {

browser/components/urlbar/tests/quicksuggest/unit/test_quicksuggest_migrate_v3.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
// Tests quick suggest prefs migration from version 2 to 3.
5+
// Tests quick suggest prefs migration from version 2 to 4.
66

77
"use strict";
88

@@ -25,7 +25,7 @@ add_setup(async () => {
2525
await UrlbarTestUtils.initNimbusFeature();
2626
});
2727

28-
// The following tasks test OFFLINE version 2 to version 3 when SUGGEST IS ENABLED.
28+
// The following tasks test OFFLINE version 2 to version 4 when SUGGEST IS ENABLED.
2929

3030
// Migrating from:
3131
// * User enabled `quicksuggest.dataCollection.enabled`
@@ -34,7 +34,7 @@ add_setup(async () => {
3434
// * Yes
3535
//
3636
// Expected:
37-
// * quicksuggest.settingsUi set to FULL on the User Branch
37+
// * quicksuggest.settingsUi is not set on the user branch.
3838
add_task(async function test_migrate_with_datacollection_enabled() {
3939
await doMigrateTest({
4040
testOverrides: TEST_OVERRIDES,
@@ -45,7 +45,6 @@ add_task(async function test_migrate_with_datacollection_enabled() {
4545
defaultBranch: DEFAULT_PREFS,
4646
userBranch: {
4747
"quicksuggest.dataCollection.enabled": true,
48-
"quicksuggest.settingsUi": QuickSuggest.SETTINGS_UI.FULL,
4948
},
5049
},
5150
});
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
// Tests quick suggest prefs migration from version 3 to 4.
6+
7+
"use strict";
8+
9+
// Expected version 3 default-branch prefs (important core prefs only, assuming
10+
// US region and en-US locale).
11+
const DEFAULT_PREFS = {
12+
"quicksuggest.enabled": true,
13+
"quicksuggest.dataCollection.enabled": false,
14+
"quicksuggest.settingsUi": QuickSuggest.SETTINGS_UI.FULL,
15+
"suggest.quicksuggest.nonsponsored": true,
16+
"suggest.quicksuggest.sponsored": true,
17+
};
18+
19+
const TEST_OVERRIDES = {
20+
migrationVersion: 4,
21+
defaultPrefs: DEFAULT_PREFS,
22+
};
23+
24+
add_setup(async () => {
25+
await UrlbarTestUtils.initNimbusFeature();
26+
});
27+
28+
// The following tasks test OFFLINE version 3 to version 4 when SUGGEST IS ENABLED.
29+
30+
// Migrating from:
31+
// * User enabled `quicksuggest.dataCollection.enabled`
32+
//
33+
// Suggest enabled when migration occurs:
34+
// * Yes
35+
//
36+
// Expected:
37+
// * quicksuggest.settingsUi not set on the User Branch
38+
add_task(async function test_migrate_with_datacollection_enabled() {
39+
await doMigrateTest({
40+
testOverrides: TEST_OVERRIDES,
41+
initialUserBranch: {
42+
"quicksuggest.dataCollection.enabled": true,
43+
},
44+
expectedPrefs: {
45+
defaultBranch: DEFAULT_PREFS,
46+
userBranch: {
47+
"quicksuggest.dataCollection.enabled": true,
48+
},
49+
},
50+
});
51+
});
52+
53+
// Migrating from:
54+
// * User has not enabled `quicksuggest.dataCollection.enabled`
55+
//
56+
// Suggest enabled when migration occurs:
57+
// * Yes
58+
//
59+
// Expected:
60+
// * quicksuggest.settingsUi not set on the User Branch
61+
add_task(async function test_migrate_with_datacollection_disabled() {
62+
await doMigrateTest({
63+
testOverrides: TEST_OVERRIDES,
64+
expectedPrefs: {
65+
defaultBranch: DEFAULT_PREFS,
66+
},
67+
});
68+
});

browser/components/urlbar/tests/quicksuggest/unit/xpcshell.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ skip-if = ["true"] # Bug 1880214
4646

4747
["test_quicksuggest_migrate_v3.js"]
4848

49+
["test_quicksuggest_migrate_v4.js"]
50+
4951
["test_quicksuggest_offlineDefault.js"]
5052
requesttimeoutfactor = 2 # Slow on Linux and Windows
5153

0 commit comments

Comments
 (0)