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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_signed_multiple.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +// ----------------------------------------------------------------------------
     1.5 +// Tests installing two signed add-ons in the same trigger works.
     1.6 +// This verifies bug 453545
     1.7 +function test() {
     1.8 +  Harness.installConfirmCallback = confirm_install;
     1.9 +  Harness.installEndedCallback = install_ended;
    1.10 +  Harness.installsCompletedCallback = finish_test;
    1.11 +  Harness.setup();
    1.12 +
    1.13 +  var pm = Services.perms;
    1.14 +  pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
    1.15 +
    1.16 +  var triggers = encodeURIComponent(JSON.stringify({
    1.17 +    "Signed XPI": TESTROOT + "signed.xpi",
    1.18 +    "Signed XPI 2": TESTROOT + "signed2.xpi",
    1.19 +    "Signed XPI 3": TESTROOT + "signed-no-o.xpi",
    1.20 +    "Signed XPI 4": TESTROOT + "signed-no-cn.xpi",
    1.21 +    "Signed XPI 5": TESTROOT + "unsigned.xpi"
    1.22 +  }));
    1.23 +  gBrowser.selectedTab = gBrowser.addTab();
    1.24 +  gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    1.25 +}
    1.26 +
    1.27 +function get_item(items, url) {
    1.28 +  for (let item of items) {
    1.29 +    if (item.url == url)
    1.30 +      return item;
    1.31 +  }
    1.32 +  ok(false, "Item for " + url + " was not listed");
    1.33 +  return null;
    1.34 +}
    1.35 +
    1.36 +function confirm_install(window) {
    1.37 +
    1.38 +  var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"].
    1.39 +                       getService(Components.interfaces.nsIStringBundleService);
    1.40 +  var bundle = sbs.createBundle("chrome://mozapps/locale/xpinstall/xpinstallConfirm.properties");
    1.41 +
    1.42 +  var expectedIntroString = bundle.formatStringFromName("itemWarnIntroMultiple", ["5"], 1);
    1.43 +  
    1.44 +  var introStringNode = window.document.getElementById("itemWarningIntro");
    1.45 +  is(introStringNode.textContent, expectedIntroString, "Should have the correct intro string");
    1.46 +
    1.47 +  var items = window.document.getElementById("itemList").childNodes;
    1.48 +  is(items.length, 5, "Should be 5 items listed in the confirmation dialog");
    1.49 +  let item = get_item(items, TESTROOT + "signed.xpi");
    1.50 +  if (item) {
    1.51 +    is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list");
    1.52 +    is(item.cert, "(Object Signer)", "Should have seen the signer");
    1.53 +    is(item.signed, "true", "Should have listed the item as signed");
    1.54 +  }
    1.55 +  item = get_item(items, TESTROOT + "signed2.xpi");
    1.56 +  if (item) {
    1.57 +    is(item.name, "Signed XPI Test", "Should have seen the name from the trigger list");
    1.58 +    is(item.cert, "(Object Signer)", "Should have seen the signer");
    1.59 +    is(item.signed, "true", "Should have listed the item as signed");
    1.60 +  }
    1.61 +  return true;
    1.62 +}
    1.63 +
    1.64 +function install_ended(install, addon) {
    1.65 +  install.cancel();
    1.66 +}
    1.67 +
    1.68 +function finish_test(count) {
    1.69 +  is(count, 5, "5 Add-ons should have been successfully installed");
    1.70 +
    1.71 +  Services.perms.remove("example.com", "install");
    1.72 +
    1.73 +  gBrowser.removeCurrentTab();
    1.74 +  Harness.finish();
    1.75 +}

mercurial