michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: const URI_EXTENSION_SELECT_DIALOG = "chrome://mozapps/content/extensions/selectAddons.xul"; michael@0: const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul"; michael@0: const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI"; michael@0: const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI"; michael@0: michael@0: const profileDir = gProfD.clone(); michael@0: profileDir.append("extensions"); michael@0: michael@0: var gExpectedURL = null; michael@0: michael@0: // This will be called to show the any update dialog. michael@0: var WindowWatcher = { michael@0: openWindow: function(parent, url, name, features, arguments) { michael@0: do_check_eq(url, gExpectedURL); michael@0: gExpectedURL = null; michael@0: }, michael@0: michael@0: QueryInterface: function(iid) { michael@0: if (iid.equals(AM_Ci.nsIWindowWatcher) michael@0: || iid.equals(AM_Ci.nsISupports)) michael@0: return this; michael@0: michael@0: throw Components.results.NS_ERROR_NO_INTERFACE; michael@0: } michael@0: } michael@0: michael@0: var WindowWatcherFactory = { michael@0: createInstance: function createInstance(outer, iid) { michael@0: if (outer != null) michael@0: throw Components.results.NS_ERROR_NO_AGGREGATION; michael@0: return WindowWatcher.QueryInterface(iid); michael@0: } michael@0: }; michael@0: michael@0: var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar); michael@0: registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"), michael@0: "Fake Window Watcher", michael@0: "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory); michael@0: michael@0: // Tests that the selection UI is displayed when upgrading an existing profile michael@0: function run_test() { michael@0: createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); michael@0: michael@0: Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true); michael@0: michael@0: var dest = writeInstallRDFForExtension({ michael@0: id: "addon1@tests.mozilla.org", michael@0: version: "1.0", michael@0: targetApplications: [{ michael@0: id: "xpcshell@tests.mozilla.org", michael@0: minVersion: "1", michael@0: maxVersion: "1" michael@0: }], michael@0: name: "Test Addon 1", michael@0: }, profileDir); michael@0: michael@0: startupManager(); michael@0: michael@0: // For a new profile it should disable showing the selection UI in the future michael@0: do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI)); michael@0: Services.prefs.clearUserPref(PREF_SHOWN_SELECTION_UI); michael@0: michael@0: gExpectedURL = URI_EXTENSION_SELECT_DIALOG; michael@0: restartManager("2"); michael@0: michael@0: do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI)); michael@0: do_check_eq(gExpectedURL, null); michael@0: michael@0: gExpectedURL = URI_EXTENSION_UPDATE_DIALOG; michael@0: michael@0: restartManager("3"); michael@0: michael@0: do_check_eq(gExpectedURL, null); michael@0: }