toolkit/mozapps/extensions/test/xpinstall/browser_whitelist4.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 a navigation. Should be
     3 // blocked since the referer is not whitelisted even though the target is.
     4 function test() {
     5   Harness.installBlockedCallback = allow_blocked;
     6   Harness.installsCompletedCallback = finish_test;
     7   Harness.setup();
     9   var pm = Services.perms;
    10   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
    12   var triggers = encodeURIComponent(JSON.stringify({
    13     "Unsigned XPI": TESTROOT2 + "unsigned.xpi"
    14   }));
    15   gBrowser.selectedTab = gBrowser.addTab();
    16   gBrowser.loadURI(TESTROOT + "unsigned.xpi", makeURI(TESTROOT2 + "test.html"));
    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, TESTROOT2 + "test.html", "Install should have been triggered by the right uri");
    22   return false;
    23 }
    25 function finish_test(count) {
    26   is(count, 0, "No add-ons should have been installed");
    27   Services.perms.remove("example.com", "install");
    29   gBrowser.removeCurrentTab();
    30   Harness.finish();
    31 }

mercurial