|
1 // ---------------------------------------------------------------------------- |
|
2 // Tests installing an add-on from a local file with whitelisting disabled. |
|
3 // This should be blocked by the whitelist check. |
|
4 function test() { |
|
5 Harness.installBlockedCallback = allow_blocked; |
|
6 Harness.installsCompletedCallback = finish_test; |
|
7 Harness.setup(); |
|
8 |
|
9 // Disable direct request whitelisting, installing from file should be blocked. |
|
10 Services.prefs.setBoolPref("xpinstall.whitelist.directRequest", false); |
|
11 |
|
12 var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] |
|
13 .getService(Components.interfaces.nsIChromeRegistry); |
|
14 |
|
15 var chromeroot = extractChromeRoot(gTestPath); |
|
16 try { |
|
17 var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec; |
|
18 } catch (ex) { |
|
19 var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted |
|
20 } |
|
21 gBrowser.selectedTab = gBrowser.addTab(); |
|
22 gBrowser.loadURI(xpipath); |
|
23 } |
|
24 |
|
25 function allow_blocked(installInfo) { |
|
26 ok(true, "Seen blocked"); |
|
27 return false; |
|
28 } |
|
29 |
|
30 function finish_test(count) { |
|
31 is(count, 0, "No add-ons should have been installed"); |
|
32 |
|
33 Services.prefs.clearUserPref("xpinstall.whitelist.directRequest"); |
|
34 |
|
35 gBrowser.removeCurrentTab(); |
|
36 Harness.finish(); |
|
37 } |