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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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