toolkit/mozapps/extensions/test/xpinstall/browser_whitelist4.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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