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