|
1 // ---------------------------------------------------------------------------- |
|
2 // Tests that the correct signer is presented for combinations of O and CN present. |
|
3 // The signed files have (when present) O=Mozilla Testing, CN=Object Signer |
|
4 // This verifies bug 372980 |
|
5 function test() { |
|
6 Harness.installConfirmCallback = confirm_install; |
|
7 Harness.installEndedCallback = install_ended; |
|
8 Harness.installsCompletedCallback = finish_test; |
|
9 Harness.setup(); |
|
10 |
|
11 var pm = Services.perms; |
|
12 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION); |
|
13 |
|
14 var triggers = encodeURIComponent(JSON.stringify({ |
|
15 "Signed XPI (O and CN)": TESTROOT + "signed.xpi", |
|
16 "Signed XPI (CN)": TESTROOT + "signed-no-o.xpi", |
|
17 "Signed XPI (O)": TESTROOT + "signed-no-cn.xpi", |
|
18 })); |
|
19 gBrowser.selectedTab = gBrowser.addTab(); |
|
20 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers); |
|
21 } |
|
22 |
|
23 function get_item(items, url) { |
|
24 for (let item of items) { |
|
25 if (item.url == url) |
|
26 return item; |
|
27 } |
|
28 ok(false, "Item for " + url + " was not listed"); |
|
29 return null; |
|
30 } |
|
31 |
|
32 function confirm_install(window) { |
|
33 let items = window.document.getElementById("itemList").childNodes; |
|
34 is(items.length, 3, "Should be 3 items listed in the confirmation dialog"); |
|
35 let item = get_item(items, TESTROOT + "signed.xpi"); |
|
36 if (item) { |
|
37 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list"); |
|
38 is(item.cert, "(Object Signer)", "Should have seen the signer"); |
|
39 is(item.signed, "true", "Should have listed the item as signed"); |
|
40 } |
|
41 item = get_item(items, TESTROOT + "signed-no-o.xpi"); |
|
42 if (item) { |
|
43 is(item.name, "Signed XPI Test (No Org)", "Should have seen the name from the trigger list"); |
|
44 is(item.cert, "(Object Signer)", "Should have seen the signer"); |
|
45 is(item.signed, "true", "Should have listed the item as signed"); |
|
46 } |
|
47 item = get_item(items, TESTROOT + "signed-no-cn.xpi"); |
|
48 if (item) { |
|
49 is(item.name, "Signed XPI Test (No Common Name)", "Should have seen the name from the trigger list"); |
|
50 is(item.cert, "(Mozilla Testing)", "Should have seen the signer"); |
|
51 is(item.signed, "true", "Should have listed the item as signed"); |
|
52 } |
|
53 return true; |
|
54 } |
|
55 |
|
56 function install_ended(install, addon) { |
|
57 install.cancel(); |
|
58 } |
|
59 |
|
60 function finish_test(count) { |
|
61 is(count, 3, "3 Add-ons should have been successfully installed"); |
|
62 |
|
63 Services.perms.remove("example.com", "install"); |
|
64 |
|
65 gBrowser.removeCurrentTab(); |
|
66 Harness.finish(); |
|
67 } |