|
1 // ---------------------------------------------------------------------------- |
|
2 // Tests installing an add-on signed by an untrusted certificate through an |
|
3 // InstallTrigger call in web content. |
|
4 function test() { |
|
5 Harness.installConfirmCallback = confirm_install; |
|
6 Harness.installEndedCallback = install_ended; |
|
7 Harness.installsCompletedCallback = finish_test; |
|
8 Harness.setup(); |
|
9 |
|
10 var pm = Services.perms; |
|
11 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
12 |
|
13 var triggers = encodeURIComponent(JSON.stringify({ |
|
14 "Untrusted Signed XPI": TESTROOT + "signed-untrusted.xpi" |
|
15 })); |
|
16 gBrowser.selectedTab = gBrowser.addTab(); |
|
17 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
18 } |
|
19 |
|
20 function confirm_install(window) { |
|
21 var items = window.document.getElementById("itemList").childNodes; |
|
22 is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); |
|
23 is(items[0].name, "Signed XPI Test", "Should have had the filename for the item name"); |
|
24 is(items[0].url, TESTROOT + "signed-untrusted.xpi", "Should have listed the correct url for the item"); |
|
25 is(items[0].icon, "", "Should have listed no icon for the item"); |
|
26 is(items[0].signed, "false", "Should have listed the item as unsigned"); |
|
27 return true; |
|
28 } |
|
29 |
|
30 function install_ended(install, addon) { |
|
31 install.cancel(); |
|
32 } |
|
33 |
|
34 function finish_test(count) { |
|
35 is(count, 1, "1 Add-on should have been successfully installed"); |
|
36 Services.perms.remove("example.com", "install"); |
|
37 |
|
38 gBrowser.removeCurrentTab(); |
|
39 Harness.finish(); |
|
40 } |
|
41 // ---------------------------------------------------------------------------- |