1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +// ---------------------------------------------------------------------------- 1.5 +// Tests installing an unsigned add-on through a navigation. Should be 1.6 +// blocked since the referer is not whitelisted even though the target is. 1.7 +function test() { 1.8 + Harness.installBlockedCallback = allow_blocked; 1.9 + Harness.installsCompletedCallback = finish_test; 1.10 + Harness.setup(); 1.11 + 1.12 + var pm = Services.perms; 1.13 + pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); 1.14 + 1.15 + var triggers = encodeURIComponent(JSON.stringify({ 1.16 + "Unsigned XPI": TESTROOT2 + "unsigned.xpi" 1.17 + })); 1.18 + gBrowser.selectedTab = gBrowser.addTab(); 1.19 + gBrowser.loadURI(TESTROOT + "unsigned.xpi", makeURI(TESTROOT2 + "test.html")); 1.20 +} 1.21 + 1.22 +function allow_blocked(installInfo) { 1.23 + is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window"); 1.24 + is(installInfo.originatingURI.spec, TESTROOT2 + "test.html", "Install should have been triggered by the right uri"); 1.25 + return false; 1.26 +} 1.27 + 1.28 +function finish_test(count) { 1.29 + is(count, 0, "No add-ons should have been installed"); 1.30 + Services.perms.remove("example.com", "install"); 1.31 + 1.32 + gBrowser.removeCurrentTab(); 1.33 + Harness.finish(); 1.34 +}