toolkit/mozapps/extensions/test/xpinstall/browser_whitelist2.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 because the source
     4 // is not whitelisted, even though the target is.
     5 function test() {
     6   Harness.installBlockedCallback = allow_blocked;
     7   Harness.installsCompletedCallback = finish_test;
     8   Harness.setup();
    10   var pm = Services.perms;
    11   pm.add(makeURI("http://example.org/"), "install", pm.ALLOW_ACTION);
    13   var triggers = encodeURIComponent(JSON.stringify({
    14     "Unsigned XPI": TESTROOT2 + "unsigned.xpi"
    15   }));
    16   gBrowser.selectedTab = gBrowser.addTab();
    17   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    18 }
    20 function allow_blocked(installInfo) {
    21   is(installInfo.originatingWindow, gBrowser.contentWindow, "Install should have been triggered by the right window");
    22   is(installInfo.originatingURI.spec, gBrowser.currentURI.spec, "Install should have been triggered by the right uri");
    23   return false;
    24 }
    26 function finish_test() {
    27   Services.perms.remove("example.org", "install");
    29   gBrowser.removeCurrentTab();
    30   Harness.finish();
    31 }

mercurial