toolkit/mozapps/extensions/test/xpinstall/browser_signed_multiple.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b6dbb9eda8e2
1 // ----------------------------------------------------------------------------
2 // Tests installing two signed add-ons in the same trigger works.
3 // This verifies bug 453545
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 "Signed XPI": TESTROOT + "signed.xpi",
15 "Signed XPI 2": TESTROOT + "signed2.xpi",
16 "Signed XPI 3": TESTROOT + "signed-no-o.xpi",
17 "Signed XPI 4": TESTROOT + "signed-no-cn.xpi",
18 "Signed XPI 5": TESTROOT + "unsigned.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
35 var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"].
36 getService(Components.interfaces.nsIStringBundleService);
37 var bundle = sbs.createBundle("chrome://mozapps/locale/xpinstall/xpinstallConfirm.properties");
38
39 var expectedIntroString = bundle.formatStringFromName("itemWarnIntroMultiple", ["5"], 1);
40
41 var introStringNode = window.document.getElementById("itemWarningIntro");
42 is(introStringNode.textContent, expectedIntroString, "Should have the correct intro string");
43
44 var items = window.document.getElementById("itemList").childNodes;
45 is(items.length, 5, "Should be 5 items listed in the confirmation dialog");
46 let item = get_item(items, TESTROOT + "signed.xpi");
47 if (item) {
48 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list");
49 is(item.cert, "(Object Signer)", "Should have seen the signer");
50 is(item.signed, "true", "Should have listed the item as signed");
51 }
52 item = get_item(items, TESTROOT + "signed2.xpi");
53 if (item) {
54 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list");
55 is(item.cert, "(Object Signer)", "Should have seen the signer");
56 is(item.signed, "true", "Should have listed the item as signed");
57 }
58 return true;
59 }
60
61 function install_ended(install, addon) {
62 install.cancel();
63 }
64
65 function finish_test(count) {
66 is(count, 5, "5 Add-ons should have been successfully installed");
67
68 Services.perms.remove("example.com", "install");
69
70 gBrowser.removeCurrentTab();
71 Harness.finish();
72 }

mercurial