|
1 // ---------------------------------------------------------------------------- |
|
2 // Tests that InstallTrigger deals with relative urls correctly. |
|
3 function test() { |
|
4 Harness.installConfirmCallback = confirm_install; |
|
5 Harness.installEndedCallback = install_ended; |
|
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": { |
|
14 URL: "unsigned.xpi", |
|
15 IconURL: "icon.png", |
|
16 toString: function() { return this.URL; } |
|
17 } |
|
18 })); |
|
19 gBrowser.selectedTab = gBrowser.addTab(); |
|
20 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
21 } |
|
22 |
|
23 function confirm_install(window) { |
|
24 var items = window.document.getElementById("itemList").childNodes; |
|
25 is(items.length, 1, "Should only be 1 item listed in the confirmation dialog"); |
|
26 is(items[0].name, "XPI Test", "Should have seen the name"); |
|
27 is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item"); |
|
28 is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item"); |
|
29 is(items[0].signed, "false", "Should have listed the item as unsigned"); |
|
30 return true; |
|
31 } |
|
32 |
|
33 function install_ended(install, addon) { |
|
34 install.cancel(); |
|
35 } |
|
36 |
|
37 function finish_test(count) { |
|
38 is(count, 1, "1 Add-on should have been successfully installed"); |
|
39 |
|
40 Services.perms.remove("example.com", "install"); |
|
41 |
|
42 var doc = gBrowser.contentDocument; |
|
43 is(doc.getElementById("return").textContent, "true", "installTrigger should have claimed success"); |
|
44 is(doc.getElementById("status").textContent, "0", "Callback should have seen a success"); |
|
45 |
|
46 gBrowser.removeCurrentTab(); |
|
47 Harness.finish(); |
|
48 } |