|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // Tests that compatibility overrides are refreshed when showing the addon |
|
6 // selection UI. |
|
7 |
|
8 const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url"; |
|
9 const PREF_MIN_PLATFORM_COMPAT = "extensions.minCompatiblePlatformVersion"; |
|
10 |
|
11 var gTestAddon = null; |
|
12 var gWin; |
|
13 |
|
14 function waitForView(aView, aCallback) { |
|
15 var view = gWin.document.getElementById(aView); |
|
16 if (view.parentNode.selectedPanel == view) { |
|
17 aCallback(); |
|
18 return; |
|
19 } |
|
20 |
|
21 view.addEventListener("ViewChanged", function() { |
|
22 view.removeEventListener("ViewChanged", arguments.callee, false); |
|
23 aCallback(); |
|
24 }, false); |
|
25 } |
|
26 |
|
27 function install_test_addon(aCallback) { |
|
28 AddonManager.getInstallForURL(TESTROOT + "addons/browser_select_compatoverrides_1.xpi", function(aInstall) { |
|
29 var listener = { |
|
30 onInstallEnded: function() { |
|
31 AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) { |
|
32 gTestAddon = addon; |
|
33 aCallback(); |
|
34 }); |
|
35 } |
|
36 }; |
|
37 aInstall.addListener(listener); |
|
38 aInstall.install(); |
|
39 }, "application/x-xpinstall"); |
|
40 } |
|
41 |
|
42 registerCleanupFunction(function() { |
|
43 if (gWin) |
|
44 gWin.close(); |
|
45 if (gTestAddon) |
|
46 gTestAddon.uninstall(); |
|
47 |
|
48 Services.prefs.clearUserPref(PREF_MIN_PLATFORM_COMPAT); |
|
49 }); |
|
50 |
|
51 function end_test() { |
|
52 finish(); |
|
53 } |
|
54 |
|
55 |
|
56 function test() { |
|
57 waitForExplicitFinish(); |
|
58 Services.prefs.setCharPref(PREF_UPDATEURL, TESTROOT + "missing.rdf"); |
|
59 Services.prefs.setBoolPref(PREF_STRICT_COMPAT, false); |
|
60 Services.prefs.setCharPref(PREF_MIN_PLATFORM_COMPAT, "0"); |
|
61 |
|
62 install_test_addon(run_next_test); |
|
63 } |
|
64 |
|
65 add_test(function() { |
|
66 gWin = Services.ww.openWindow(null, |
|
67 "chrome://mozapps/content/extensions/selectAddons.xul", |
|
68 "", |
|
69 "chrome,centerscreen,dialog,titlebar", |
|
70 null); |
|
71 waitForFocus(function() { |
|
72 waitForView("select", run_next_test); |
|
73 }, gWin); |
|
74 }); |
|
75 |
|
76 add_test(function() { |
|
77 for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) { |
|
78 if (row.localName == "separator") |
|
79 continue; |
|
80 if (row.id.substr(-18) != "@tests.mozilla.org") |
|
81 continue; |
|
82 |
|
83 is(row.id, "addon1@tests.mozilla.org", "Should get expected addon"); |
|
84 isnot(row.action, "incompatible", "Addon should not be incompatible"); |
|
85 |
|
86 gWin.close(); |
|
87 gWin = null; |
|
88 run_next_test(); |
|
89 } |
|
90 }); |
|
91 |
|
92 add_test(function() { |
|
93 Services.prefs.setCharPref(PREF_GETADDONS_BYIDS, TESTROOT + "browser_select_compatoverrides.xml"); |
|
94 Services.prefs.setBoolPref(PREF_GETADDONS_CACHE_ENABLED, true); |
|
95 |
|
96 gWin = Services.ww.openWindow(null, |
|
97 "chrome://mozapps/content/extensions/selectAddons.xul", |
|
98 "", |
|
99 "chrome,centerscreen,dialog,titlebar", |
|
100 null); |
|
101 waitForFocus(function() { |
|
102 waitForView("select", run_next_test); |
|
103 }, gWin); |
|
104 }); |
|
105 |
|
106 add_test(function() { |
|
107 for (var row = gWin.document.getElementById("select-rows").firstChild; row; row = row.nextSibling) { |
|
108 if (row.localName == "separator") |
|
109 continue; |
|
110 if (row.id.substr(-18) != "@tests.mozilla.org") |
|
111 continue; |
|
112 is(row.id, "addon1@tests.mozilla.org", "Should get expected addon"); |
|
113 is(row.action, "incompatible", "Addon should be incompatible"); |
|
114 run_next_test(); |
|
115 } |
|
116 }); |