Bug 1643471 - Remove the browser.search.cohort preference from user profiles. r=Gijs
authorMark Banner <standard8@mozilla.com>
Tue, 22 Sep 2020 14:02:20 +0000
changeset 549635 3dee6f5ea847561c56b2038bd775af74c80fb585
parent 549634 7e73d7a3ddd291276ddb9c5f05d5b9c244aa3e5f
child 549636 01746b5061a4f2fb54997b294a105a070dff424d
push id126907
push usermbanner@mozilla.com
push dateTue, 22 Sep 2020 14:16:45 +0000
treeherderautoland@3dee6f5ea847 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1643471
milestone83.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1643471 - Remove the browser.search.cohort preference from user profiles. r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D91000
browser/components/BrowserGlue.jsm
browser/components/tests/unit/test_browserGlue_migration_no_errors.js
browser/components/tests/unit/xpcshell.ini
--- a/browser/components/BrowserGlue.jsm
+++ b/browser/components/BrowserGlue.jsm
@@ -3239,17 +3239,17 @@ BrowserGlue.prototype = {
       );
     });
   },
 
   // eslint-disable-next-line complexity
   _migrateUI: function BG__migrateUI() {
     // Use an increasing number to keep track of the current migration state.
     // Completely unrelated to the current Firefox release number.
-    const UI_VERSION = 97;
+    const UI_VERSION = 98;
     const BROWSER_DOCURL = AppConstants.BROWSER_CHROME_URL;
 
     if (!Services.prefs.prefHasUserValue("browser.migration.version")) {
       // This is a new profile, nothing to migrate.
       Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
       this._isNewProfile = true;
       return;
     }
@@ -3867,16 +3867,20 @@ BrowserGlue.prototype = {
         );
       } else {
         // The last remaining case is if they customized both values, in which
         // case also we leave the "migration complete" percentage at 100, as no
         // further migration is needed.
       }
     }
 
+    if (currentUIVersion < 98) {
+      Services.prefs.clearUserPref("browser.search.cohort");
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _maybeShowDefaultBrowserPrompt() {
     DefaultBrowserCheck.willCheckDefaultBrowser(/* isStartupCheck */ true).then(
       async willPrompt => {
         let { DefaultBrowserNotification } = ChromeUtils.import(
new file mode 100644
--- /dev/null
+++ b/browser/components/tests/unit/test_browserGlue_migration_no_errors.js
@@ -0,0 +1,34 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Since various migrations in BrowserGlue are sometimes trivial, e.g. just
+ * clearing a pref, it does not feel necessary to write tests for each of those.
+ *
+ * However, ensuring we have at least some coverage to check for errors, e.g.
+ * typos, is a good idea, hence this test.
+ *
+ * If your migration is more complex that clearing a couple of prefs, you
+ * should consider adding your own BrowserGlue migration test.
+ */
+const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
+const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";
+
+const gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"].getService(
+  Ci.nsIObserver
+);
+
+// Set the migration value to 1, to ensure that the migration code is called,
+// and so that this doesn't need updating every time we obsolete old tests.
+Services.prefs.setIntPref("browser.migration.version", 1);
+
+add_task(async function test_no_errors() {
+  // Simulate a migration.
+  gBrowserGlue.observe(
+    null,
+    TOPIC_BROWSERGLUE_TEST,
+    TOPICDATA_BROWSERGLUE_TEST
+  );
+
+  Assert.ok(true, "should have run the migration with no errors");
+});
--- a/browser/components/tests/unit/xpcshell.ini
+++ b/browser/components/tests/unit/xpcshell.ini
@@ -2,9 +2,10 @@
 head = head.js
 firefox-appdir = browser
 skip-if = toolkit == 'android'
 support-files =
   distribution.ini
 
 [test_distribution.js]
 [test_distribution_cachedexistence.js]
+[test_browserGlue_migration_no_errors.js]
 [test_browserGlue_migration_social_cleanup.js]