toolkit/mozapps/extensions/test/xpinstall/browser_multipackage.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_multipackage.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +// ----------------------------------------------------------------------------
     1.5 +// Tests installing an signed add-on by navigating directly to the url
     1.6 +function test() {
     1.7 +  Harness.installConfirmCallback = confirm_install;
     1.8 +  Harness.installEndedCallback = install_ended;
     1.9 +  Harness.installsCompletedCallback = finish_test;
    1.10 +  Harness.setup();
    1.11 +
    1.12 +  gBrowser.selectedTab = gBrowser.addTab();
    1.13 +  gBrowser.loadURI(TESTROOT + "multipackage.xpi");
    1.14 +}
    1.15 +
    1.16 +function get_item(items, name) {
    1.17 +  for (let item of items) {
    1.18 +    if (item.name == name)
    1.19 +      return item;
    1.20 +  }
    1.21 +  ok(false, "Item for " + name + " was not listed");
    1.22 +  return null;
    1.23 +}
    1.24 +
    1.25 +function confirm_install(window) {
    1.26 +  let items = window.document.getElementById("itemList").childNodes;
    1.27 +  is(items.length, 2, "Should be 2 items listed in the confirmation dialog");
    1.28 +
    1.29 +  let item = get_item(items, "XPI Test");
    1.30 +  if (item) {
    1.31 +    is(item.signed, "false", "Should not have listed the item as signed");
    1.32 +    is(item.icon, "", "Should have listed no icon for the item");
    1.33 +  }
    1.34 +
    1.35 +  item = get_item(items, "Signed XPI Test");
    1.36 +  if (item) {
    1.37 +    is(item.cert, "(Object Signer)", "Should have seen the signer");
    1.38 +    is(item.signed, "true", "Should have listed the item as signed");
    1.39 +    is(item.icon, "", "Should have listed no icon for the item");
    1.40 +  }
    1.41 +
    1.42 +  return true;
    1.43 +}
    1.44 +
    1.45 +function install_ended(install, addon) {
    1.46 +  install.cancel();
    1.47 +}
    1.48 +
    1.49 +function finish_test(count) {
    1.50 +  is(count, 2, "2 Add-ons should have been successfully installed");
    1.51 +  gBrowser.removeCurrentTab();
    1.52 +  Harness.finish();
    1.53 +}
    1.54 +// ----------------------------------------------------------------------------

mercurial