toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.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. This should be blocked by the whitelist check.
     4 // This verifies bug 252830
     5 function test() {
     6   Harness.installConfirmCallback = confirm_install;
     7   Harness.installBlockedCallback = allow_blocked;
     8   Harness.installEndedCallback = install_ended;
     9   Harness.installsCompletedCallback = finish_test;
    10   Harness.setup();
    12   var triggers = encodeURIComponent(JSON.stringify({
    13     "Unsigned XPI": TESTROOT + "unsigned.xpi"
    14   }));
    15   gBrowser.selectedTab = gBrowser.addTab();
    16   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    17 }
    19 function allow_blocked(installInfo) {
    20   is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window");
    21   is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
    22   return true;
    23 }
    25 function confirm_install(window) {
    26   var items = window.document.getElementById("itemList").childNodes;
    27   is(items.length, 1, "Should only be 1 item listed in the confirmation dialog");
    28   is(items[0].name, "XPI Test", "Should have seen the name from the trigger list");
    29   is(items[0].url, TESTROOT + "unsigned.xpi", "Should have listed the correct url 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   var doc = gBrowser.contentDocument;
    42   is(doc.getElementById("return").textContent, "false", "installTrigger should seen a failure");
    43   gBrowser.removeCurrentTab();
    44   Harness.finish();
    45 }
    46 // ----------------------------------------------------------------------------

mercurial