Bug 1309589 - Cleanup old loop.* preferences in profiles after Firefox Hello removal. r=mikedeboer

MozReview-Commit-ID: KNOJzUL7hRv

--HG--
extra : rebase_source : 2a36dd1ffe41e7b673ee4dc514a74c57c4b85390
This commit is contained in:
Mark Banner 2016-10-12 16:08:55 +01:00
Родитель 320a08b33e
Коммит 554ec1a33f
5 изменённых файлов: 49 добавлений и 9 удалений

Просмотреть файл

@ -1779,7 +1779,7 @@ BrowserGlue.prototype = {
}, },
_migrateUI: function BG__migrateUI() { _migrateUI: function BG__migrateUI() {
const UI_VERSION = 40; const UI_VERSION = 41;
const BROWSER_DOCURL = "chrome://browser/content/browser.xul"; const BROWSER_DOCURL = "chrome://browser/content/browser.xul";
let currentUIVersion; let currentUIVersion;
@ -2105,6 +2105,11 @@ BrowserGlue.prototype = {
} }
} }
if (currentUIVersion < 41) {
const Preferences = Cu.import("resource://gre/modules/Preferences.jsm", {}).Preferences;
Preferences.resetBranch("loop.");
}
// Update the migration version. // Update the migration version.
Services.prefs.setIntPref("browser.migration.version", UI_VERSION); Services.prefs.setIntPref("browser.migration.version", UI_VERSION);
}, },

Просмотреть файл

@ -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);

Просмотреть файл

@ -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");
});

Просмотреть файл

@ -5,12 +5,6 @@
* Tests that preferences are properly set by distribution.ini * 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"); Cu.import("resource://gre/modules/LoadContextInfo.jsm");
// Import common head. // Import common head.
@ -31,8 +25,6 @@ const TOPIC_BROWSERGLUE_TEST = "browser-glue-test";
function installDistributionEngine() { function installDistributionEngine() {
const XRE_APP_DISTRIBUTION_DIR = "XREAppDist"; const XRE_APP_DISTRIBUTION_DIR = "XREAppDist";
const gProfD = do_get_profile().QueryInterface(Ci.nsILocalFile);
let dir = gProfD.clone(); let dir = gProfD.clone();
dir.append("distribution"); dir.append("distribution");
let distDir = dir.clone(); let distDir = dir.clone();

Просмотреть файл

@ -1,4 +1,5 @@
[DEFAULT] [DEFAULT]
head = head.js
firefox-appdir = browser firefox-appdir = browser
skip-if = toolkit == 'android' || toolkit == 'gonk' skip-if = toolkit == 'android' || toolkit == 'gonk'
support-files = support-files =
@ -6,3 +7,4 @@ support-files =
data/engine-de-DE.xml data/engine-de-DE.xml
[test_distribution.js] [test_distribution.js]
[test_browserGlue_migration_loop_cleanup.js]