1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_localfile3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Tests installing an add-on from a local file with whitelisting disabled. 1.6 +// This should be blocked by the whitelist check. 1.7 +function test() { 1.8 + Harness.installBlockedCallback = allow_blocked; 1.9 + Harness.installsCompletedCallback = finish_test; 1.10 + Harness.setup(); 1.11 + 1.12 + // Disable direct request whitelisting, installing from file should be blocked. 1.13 + Services.prefs.setBoolPref("xpinstall.whitelist.directRequest", false); 1.14 + 1.15 + var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"] 1.16 + .getService(Components.interfaces.nsIChromeRegistry); 1.17 + 1.18 + var chromeroot = extractChromeRoot(gTestPath); 1.19 + try { 1.20 + var xpipath = cr.convertChromeURL(makeURI(chromeroot + "unsigned.xpi")).spec; 1.21 + } catch (ex) { 1.22 + var xpipath = chromeroot + "unsigned.xpi"; //scenario where we are running from a .jar and already extracted 1.23 + } 1.24 + gBrowser.selectedTab = gBrowser.addTab(); 1.25 + gBrowser.loadURI(xpipath); 1.26 +} 1.27 + 1.28 +function allow_blocked(installInfo) { 1.29 + ok(true, "Seen blocked"); 1.30 + return false; 1.31 +} 1.32 + 1.33 +function finish_test(count) { 1.34 + is(count, 0, "No add-ons should have been installed"); 1.35 + 1.36 + Services.prefs.clearUserPref("xpinstall.whitelist.directRequest"); 1.37 + 1.38 + gBrowser.removeCurrentTab(); 1.39 + Harness.finish(); 1.40 +}