|
1 // ---------------------------------------------------------------------------- |
|
2 // Tests installing an unsigned add-on through a navigation. Should be |
|
3 // blocked since the referer is not whitelisted even though the target is. |
|
4 function test() { |
|
5 Harness.installBlockedCallback = allow_blocked; |
|
6 Harness.installsCompletedCallback = finish_test; |
|
7 Harness.setup(); |
|
8 |
|
9 var pm = Services.perms; |
|
10 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
11 |
|
12 var triggers = encodeURIComponent(JSON.stringify({ |
|
13 "Unsigned XPI": TESTROOT2 + "unsigned.xpi" |
|
14 })); |
|
15 gBrowser.selectedTab = gBrowser.addTab(); |
|
16 gBrowser.loadURI(TESTROOT + "unsigned.xpi", makeURI(TESTROOT2 + "test.html")); |
|
17 } |
|
18 |
|
19 function allow_blocked(installInfo) { |
|
20 is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window"); |
|
21 is(installInfo.originatingURI.spec, TESTROOT2 + "test.html", "Install should have been triggered by the right uri"); |
|
22 return false; |
|
23 } |
|
24 |
|
25 function finish_test(count) { |
|
26 is(count, 0, "No add-ons should have been installed"); |
|
27 Services.perms.remove("example.com", "install"); |
|
28 |
|
29 gBrowser.removeCurrentTab(); |
|
30 Harness.finish(); |
|
31 } |