toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.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.

     1 // ----------------------------------------------------------------------------
     2 // Tests installing an unsigned add-on through an InstallTrigger call in web
     3 // content.
     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     "Unsigned XPI": {
    15       URL: TESTROOT + "unsigned.xpi",
    16       IconURL: TESTROOT + "icon.png",
    17       toString: function() { return this.URL; }
    18     }
    19   }));
    20   gBrowser.selectedTab = gBrowser.addTab();
    21   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    22 }
    24 function confirm_install(window) {
    25   var items = window.document.getElementById("itemList").childNodes;
    26   is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
    27   is(items[0].name, "XPI Test", "Should have seen the name");
    28   is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url for the item");
    29   is(items[0].icon, TESTROOT + "icon.png", "Should have listed the correct icon for the item");
    30   is(items[0].signed, "false", "Should have listed the item as unsigned");
    31   return true;
    32 }
    34 function install_ended(install, addon) {
    35   install.cancel();
    36 }
    38 function finish_test(count) {
    39   is(count, 1, "1 Add-on should have been successfully installed");
    41   Services.perms.remove("example.com", "install");
    43   var doc = gBrowser.contentDocument;
    44   is(doc.getElementById("return").textContent, "true", "installTrigger should have claimed success");
    45   is(doc.getElementById("status").textContent, "0", "Callback should have seen a success");
    47   gBrowser.removeCurrentTab();
    48   Harness.finish();
    49 }

mercurial