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