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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // ----------------------------------------------------------------------------
michael@0 2 // Tests installing two signed add-ons in the same trigger works.
michael@0 3 // This verifies bug 453545
michael@0 4 function test() {
michael@0 5 Harness.installConfirmCallback = confirm_install;
michael@0 6 Harness.installEndedCallback = install_ended;
michael@0 7 Harness.installsCompletedCallback = finish_test;
michael@0 8 Harness.setup();
michael@0 9
michael@0 10 var pm = Services.perms;
michael@0 11 pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
michael@0 12
michael@0 13 var triggers = encodeURIComponent(JSON.stringify({
michael@0 14 "Signed XPI": TESTROOT + "signed.xpi",
michael@0 15 "Signed XPI 2": TESTROOT + "signed2.xpi",
michael@0 16 "Signed XPI 3": TESTROOT + "signed-no-o.xpi",
michael@0 17 "Signed XPI 4": TESTROOT + "signed-no-cn.xpi",
michael@0 18 "Signed XPI 5": TESTROOT + "unsigned.xpi"
michael@0 19 }));
michael@0 20 gBrowser.selectedTab = gBrowser.addTab();
michael@0 21 gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
michael@0 22 }
michael@0 23
michael@0 24 function get_item(items, url) {
michael@0 25 for (let item of items) {
michael@0 26 if (item.url == url)
michael@0 27 return item;
michael@0 28 }
michael@0 29 ok(false, "Item for " + url + " was not listed");
michael@0 30 return null;
michael@0 31 }
michael@0 32
michael@0 33 function confirm_install(window) {
michael@0 34
michael@0 35 var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"].
michael@0 36 getService(Components.interfaces.nsIStringBundleService);
michael@0 37 var bundle = sbs.createBundle("chrome://mozapps/locale/xpinstall/xpinstallConfirm.properties");
michael@0 38
michael@0 39 var expectedIntroString = bundle.formatStringFromName("itemWarnIntroMultiple", ["5"], 1);
michael@0 40
michael@0 41 var introStringNode = window.document.getElementById("itemWarningIntro");
michael@0 42 is(introStringNode.textContent, expectedIntroString, "Should have the correct intro string");
michael@0 43
michael@0 44 var items = window.document.getElementById("itemList").childNodes;
michael@0 45 is(items.length, 5, "Should be 5 items listed in the confirmation dialog");
michael@0 46 let item = get_item(items, TESTROOT + "signed.xpi");
michael@0 47 if (item) {
michael@0 48 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list");
michael@0 49 is(item.cert, "(Object Signer)", "Should have seen the signer");
michael@0 50 is(item.signed, "true", "Should have listed the item as signed");
michael@0 51 }
michael@0 52 item = get_item(items, TESTROOT + "signed2.xpi");
michael@0 53 if (item) {
michael@0 54 is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list");
michael@0 55 is(item.cert, "(Object Signer)", "Should have seen the signer");
michael@0 56 is(item.signed, "true", "Should have listed the item as signed");
michael@0 57 }
michael@0 58 return true;
michael@0 59 }
michael@0 60
michael@0 61 function install_ended(install, addon) {
michael@0 62 install.cancel();
michael@0 63 }
michael@0 64
michael@0 65 function finish_test(count) {
michael@0 66 is(count, 5, "5 Add-ons should have been successfully installed");
michael@0 67
michael@0 68 Services.perms.remove("example.com", "install");
michael@0 69
michael@0 70 gBrowser.removeCurrentTab();
michael@0 71 Harness.finish();
michael@0 72 }

mercurial