toolkit/mozapps/extensions/test/xpcshell/test_bug596343.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4 */
michael@0 5
michael@0 6 const URI_EXTENSION_SELECT_DIALOG = "chrome://mozapps/content/extensions/selectAddons.xul";
michael@0 7 const URI_EXTENSION_UPDATE_DIALOG = "chrome://mozapps/content/extensions/update.xul";
michael@0 8 const PREF_EM_SHOW_MISMATCH_UI = "extensions.showMismatchUI";
michael@0 9 const PREF_SHOWN_SELECTION_UI = "extensions.shownSelectionUI";
michael@0 10
michael@0 11 const profileDir = gProfD.clone();
michael@0 12 profileDir.append("extensions");
michael@0 13
michael@0 14 var gExpectedURL = null;
michael@0 15
michael@0 16 // This will be called to show the any update dialog.
michael@0 17 var WindowWatcher = {
michael@0 18 openWindow: function(parent, url, name, features, arguments) {
michael@0 19 do_check_eq(url, gExpectedURL);
michael@0 20 gExpectedURL = null;
michael@0 21 },
michael@0 22
michael@0 23 QueryInterface: function(iid) {
michael@0 24 if (iid.equals(AM_Ci.nsIWindowWatcher)
michael@0 25 || iid.equals(AM_Ci.nsISupports))
michael@0 26 return this;
michael@0 27
michael@0 28 throw Components.results.NS_ERROR_NO_INTERFACE;
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 var WindowWatcherFactory = {
michael@0 33 createInstance: function createInstance(outer, iid) {
michael@0 34 if (outer != null)
michael@0 35 throw Components.results.NS_ERROR_NO_AGGREGATION;
michael@0 36 return WindowWatcher.QueryInterface(iid);
michael@0 37 }
michael@0 38 };
michael@0 39
michael@0 40 var registrar = Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar);
michael@0 41 registrar.registerFactory(Components.ID("{1dfeb90a-2193-45d5-9cb8-864928b2af55}"),
michael@0 42 "Fake Window Watcher",
michael@0 43 "@mozilla.org/embedcomp/window-watcher;1", WindowWatcherFactory);
michael@0 44
michael@0 45 // Tests that the selection UI is displayed when upgrading an existing profile
michael@0 46 function run_test() {
michael@0 47 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
michael@0 48
michael@0 49 Services.prefs.setBoolPref(PREF_EM_SHOW_MISMATCH_UI, true);
michael@0 50
michael@0 51 var dest = writeInstallRDFForExtension({
michael@0 52 id: "addon1@tests.mozilla.org",
michael@0 53 version: "1.0",
michael@0 54 targetApplications: [{
michael@0 55 id: "xpcshell@tests.mozilla.org",
michael@0 56 minVersion: "1",
michael@0 57 maxVersion: "1"
michael@0 58 }],
michael@0 59 name: "Test Addon 1",
michael@0 60 }, profileDir);
michael@0 61
michael@0 62 startupManager();
michael@0 63
michael@0 64 // For a new profile it should disable showing the selection UI in the future
michael@0 65 do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI));
michael@0 66 Services.prefs.clearUserPref(PREF_SHOWN_SELECTION_UI);
michael@0 67
michael@0 68 gExpectedURL = URI_EXTENSION_SELECT_DIALOG;
michael@0 69 restartManager("2");
michael@0 70
michael@0 71 do_check_true(Services.prefs.getBoolPref(PREF_SHOWN_SELECTION_UI));
michael@0 72 do_check_eq(gExpectedURL, null);
michael@0 73
michael@0 74 gExpectedURL = URI_EXTENSION_UPDATE_DIALOG;
michael@0 75
michael@0 76 restartManager("3");
michael@0 77
michael@0 78 do_check_eq(gExpectedURL, null);
michael@0 79 }

mercurial