|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 // ---------------------------------------------------------------------------- |
|
6 // Tests that cancelling multiple installs doesn't fail |
|
7 function test() { |
|
8 Harness.installConfirmCallback = confirm_install; |
|
9 Harness.installEndedCallback = install_ended; |
|
10 Harness.installsCompletedCallback = finish_test; |
|
11 Harness.setup(); |
|
12 |
|
13 var pm = Services.perms; |
|
14 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
15 |
|
16 var triggers = encodeURIComponent(JSON.stringify({ |
|
17 "Signed XPI": TESTROOT + "signed.xpi", |
|
18 "Signed XPI 2": TESTROOT + "signed2.xpi", |
|
19 })); |
|
20 gBrowser.selectedTab = gBrowser.addTab(); |
|
21 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
22 } |
|
23 |
|
24 function get_item(items, url) { |
|
25 for (let item of items) { |
|
26 if (item.url == url) |
|
27 return item; |
|
28 } |
|
29 ok(false, "Item for " + url + " was not listed"); |
|
30 return null; |
|
31 } |
|
32 |
|
33 function confirm_install(window) { |
|
34 let items = window.document.getElementById("itemList").childNodes; |
|
35 is(items.length, 2, "Should be 2 items listed in the confirmation dialog"); |
|
36 let item = get_item(items, TESTROOT + "signed.xpi"); |
|
37 if (item) { |
|
38 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); |
|
39 is(item.cert, "(Object Signer)", "Should have seen the signer"); |
|
40 is(item.signed, "true", "Should have listed the item as signed"); |
|
41 } |
|
42 item = get_item(items, TESTROOT + "signed2.xpi"); |
|
43 if (item) { |
|
44 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); |
|
45 is(item.cert, "(Object Signer)", "Should have seen the signer"); |
|
46 is(item.signed, "true", "Should have listed the item as signed"); |
|
47 } |
|
48 return false; |
|
49 } |
|
50 |
|
51 function install_ended(install, addon) { |
|
52 ok(false, "Should not have seen installs complete"); |
|
53 } |
|
54 |
|
55 function finish_test(count) { |
|
56 is(count, 0, "No add-ons should have been successfully installed"); |
|
57 |
|
58 Services.perms.remove("example.com", "install"); |
|
59 |
|
60 gBrowser.removeCurrentTab(); |
|
61 Harness.finish(); |
|
62 } |