Bug 1460675 - Clear old social prefs from profiles
authorbobslept <bobslept@protonmail.com>
Tue, 15 May 2018 17:03:39 +0200
changeset 418413 84ec88aaa796b4b86bede156bf7f43fe82870955
parent 418412 62451c9687b29739b90830ce876c21f158298247
child 418414 ff1839757f0cad9d24058efad9a0d874acf451da
push id103302
push userfelipc@gmail.com
push dateTue, 15 May 2018 22:51:00 +0000
treeherdermozilla-inbound@84ec88aaa796 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1460675
milestone62.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 1460675 - Clear old social prefs from profiles
browser/components/nsBrowserGlue.js
browser/components/tests/unit/test_browserGlue_migration_social_cleanup.js
browser/components/tests/unit/xpcshell.ini
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1838,17 +1838,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 = 68;
+    const UI_VERSION = 69;
     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);
@@ -2200,16 +2200,27 @@ BrowserGlue.prototype = {
     }
 
     if (currentUIVersion < 68) {
       // Remove blocklists legacy storage, now relying on IndexedDB.
       OS.File.remove(OS.Path.join(OS.Constants.Path.profileDir,
                                   "kinto.sqlite"), {ignoreAbsent: true});
     }
 
+    if (currentUIVersion < 69) {
+      // Clear old social prefs from profile (bug 1460675)
+      let socialPrefs = Services.prefs.getBranch("social.");
+      if (socialPrefs) {
+        let socialPrefsArray = socialPrefs.getChildList("");
+        for (let item of socialPrefsArray) {
+          Services.prefs.clearUserPref("social." + item);
+        }
+      }
+    }
+
     // Update the migration version.
     Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
   },
 
   _checkForDefaultBrowser() {
     // Perform default browser checking.
     if (!ShellService) {
       return;
new file mode 100644
--- /dev/null
+++ b/browser/components/tests/unit/test_browserGlue_migration_social_cleanup.js
@@ -0,0 +1,23 @@
+const UI_VERSION = 69;
+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(async function test_check_cleanup_social_prefs() {
+  Services.prefs.setStringPref("social.manifest.example-com", "example.com");
+
+  // Simulate a migration.
+  gBrowserGlue.observe(null, TOPIC_BROWSERGLUE_TEST, TOPICDATA_BROWSERGLUE_TEST);
+
+  Assert.ok(!Services.prefs.prefHasUserValue("social.manifest.example-com"),
+            "should have cleared old social preference 'social.manifest.example-com'");
+});
+
+registerCleanupFunction(() => {
+  Services.prefs.clearUserPref("browser.migration.version");
+  Services.prefs.clearUserPref("social.manifest.example-com");
+});
--- a/browser/components/tests/unit/xpcshell.ini
+++ b/browser/components/tests/unit/xpcshell.ini
@@ -4,9 +4,10 @@ firefox-appdir = browser
 skip-if = toolkit == 'android'
 support-files =
   distribution.ini
   data/engine-de-DE.xml
 
 [test_browserGlue_migration_loop_cleanup.js]
 [test_distribution.js]
 [test_distribution_cachedexistence.js]
+[test_browserGlue_migration_social_cleanup.js]
 [test_browserGlue_pingcentre.js]