Bug 1309589 - Cleanup old loop.* preferences in profiles after Firefox Hello removal. r=mikedeboer
authorMark Banner <standard8@mozilla.com>
Wed, 12 Oct 2016 16:08:55 +0100
changeset 317789 c07923f57466df5e436ec55c0112d89d59ac3e39
parent 317788 971b4fc7d1f4a23a10f083b6d35a947ab6a8b929
child 317790 752382b58cc46c9158af0f5325b388b32fd8d35d
push id30817
push usercbook@mozilla.com
push dateFri, 14 Oct 2016 09:56:08 +0000
treeherdermozilla-central@a71215ad8ab8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1309589
milestone52.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 1309589 - Cleanup old loop.* preferences in profiles after Firefox Hello removal. r=mikedeboer MozReview-Commit-ID: KNOJzUL7hRv
browser/components/nsBrowserGlue.js
browser/components/tests/unit/head.js
browser/components/tests/unit/test_browserGlue_migration_loop_cleanup.js
browser/components/tests/unit/test_distribution.js
browser/components/tests/unit/xpcshell.ini
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1774,17 +1774,17 @@ BrowserGlue.prototype = {
       if (topic != "alertclickcallback")
         return;
       this._openPreferences("sync");
     }
     AlertsService.showAlertNotification(null, title, body, true, null, clickCallback);
   },
 
   _migrateUI: function BG__migrateUI() {
-    const UI_VERSION = 40;
+    const UI_VERSION = 41;
     const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
 
     let currentUIVersion;
     if (Services.prefs.prefHasUserValue("browser.migration.version")) {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } else {
       // This is a new profile, nothing to migrate.
       Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
@@ -2100,16 +2100,21 @@ BrowserGlue.prototype = {
         Services.prefs.setBoolPref("browser.safebrowsing.phishing.enabled",
                                    false);
         // Should just remove support for the pref entirely, even if it's
         // only in about:config
         Services.prefs.clearUserPref(kOldSafeBrowsingPref);
       }
     }
 
+    if (currentUIVersion < 41) {
+      const Preferences = Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences;
+      Preferences.resetBranch("loop.");
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _hasExistingNotificationPermission: function BG__hasExistingNotificationPermission() {
     let enumerator = Services.perms.enumerator;
     while (enumerator.hasMoreElements()) {
       let permission = enumerator.getNext().QueryInterface(Ci.nsIPermission);
new file mode 100644
--- /dev/null
+++ b/browser/components/tests/unit/head.js
@@ -0,0 +1,9 @@
+/* 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/. */
+
+const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+var gProfD = do_get_profile().QueryInterface(Ci.nsILocalFile);
new file mode 100644
--- /dev/null
+++ b/browser/components/tests/unit/test_browserGlue_migration_loop_cleanup.js
@@ -0,0 +1,32 @@
+const UI_VERSION = 41;
+const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
+const TOPICDATA_BROWSERGLUE_TEST = "force-ui-migration";
+
+var gBrowserGlue = Cc["@mozilla.org/browser/browserglue;1"]
+                     .getService(Ci.nsIObserver);
+
+Services.prefs.setIntPref("browser.migration.version", UI_VERSION - 1);
+
+add_task(function* test_check_cleanup_loop_prefs() {
+  Services.prefs.setBoolPref("loop.createdRoom", true);
+  Services.prefs.setBoolPref("loop1.createdRoom", true);
+  Services.prefs.setBoolPref("loo.createdRoom", true);
+
+  // Simulate a migration.
+  gBrowserGlue.observe(null, TOPIC_BROWSERGLUE_TEST, TOPICDATA_BROWSERGLUE_TEST);
+
+  Assert.throws(() => Services.prefs.getBoolPref("loop.createdRoom"),
+                /NS_ERROR_UNEXPECTED/,
+                "should have cleared old loop preference 'loop.createdRoom'");
+  Assert.ok(Services.prefs.getBoolPref("loop1.createdRoom"),
+            "should have left non-loop pref 'loop1.createdRoom' untouched");
+  Assert.ok(Services.prefs.getBoolPref("loo.createdRoom"),
+            "should have left non-loop pref 'loo.createdRoom' untouched");
+});
+
+do_register_cleanup(() => {
+  Services.prefs.clearUserPref("browser.migration.version");
+  Services.prefs.clearUserPref("loop.createdRoom");
+  Services.prefs.clearUserPref("loop1.createdRoom");
+  Services.prefs.clearUserPref("loo.createdRoom");
+});
--- a/browser/components/tests/unit/test_distribution.js
+++ b/browser/components/tests/unit/test_distribution.js
@@ -1,21 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
  * Tests that preferences are properly set by distribution.ini
  */
 
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cr = Components.results;
-var Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/LoadContextInfo.jsm");
 
 // Import common head.
 var commonFile = do_get_file("../../../../toolkit/components/places/tests/head_common.js", false);
 if (commonFile) {
   let uri = Services.io.newFileURI(commonFile);
   Services.scriptloader.loadSubScript(uri.spec, this);
 }
@@ -26,18 +20,16 @@ const TOPIC_BROWSERGLUE_TEST = "browser-
 /**
  * Copy the engine-distribution.xml engine to a fake distribution
  * created in the profile, and registered with the directory service.
  * Create an empty en-US directory to make sure it isn't used.
  */
 function installDistributionEngine() {
   const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
 
-  const gProfD = do_get_profile().QueryInterface(Ci.nsILocalFile);
-
   let dir = gProfD.clone();
   dir.append("distribution");
   let distDir = dir.clone();
 
   dir.append("searchplugins");
   dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
 
   dir.append("locale");
--- a/browser/components/tests/unit/xpcshell.ini
+++ b/browser/components/tests/unit/xpcshell.ini
@@ -1,8 +1,10 @@
 [DEFAULT]
+head = head.js
 firefox-appdir = browser
 skip-if = toolkit == 'android' || toolkit == 'gonk'
 support-files =
   distribution.ini
   data/engine-de-DE.xml
 
 [test_distribution.js]
+[test_browserGlue_migration_loop_cleanup.js]