Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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();
10 var pm = Services.perms;
11 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
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 }
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 }
33 function confirm_install(window) {
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");
39 var expectedIntroString = bundle.formatStringFromName("itemWarnIntroMultiple", ["5"], 1);
41 var introStringNode = window.document.getElementById("itemWarningIntro");
42 is(introStringNode.textContent, expectedIntroString, "Should have the correct intro string");
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 }
61 function install_ended(install, addon) {
62 install.cancel();
63 }
65 function finish_test(count) {
66 is(count, 5, "5 Add-ons should have been successfully installed");
68 Services.perms.remove("example.com", "install");
70 gBrowser.removeCurrentTab();
71 Harness.finish();
72 }