toolkit/mozapps/extensions/test/xpinstall/browser_cookies4.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 // Test that an install that requires cookies to be sent fails when cookies
     3 // are set and third party cookies are disabled and the request is to a third
     4 // party.
     5 // This verifies bug 462739
     6 function test() {
     7   Harness.downloadFailedCallback = download_failed;
     8   Harness.installsCompletedCallback = finish_test;
     9   Harness.setup();
    11   var cm = Components.classes["@mozilla.org/cookiemanager;1"]
    12                      .getService(Components.interfaces.nsICookieManager2);
    13   cm.add("example.com", "/browser/" + RELATIVE_DIR, "xpinstall", "true", false,
    14          false, true, (Date.now() / 1000) + 60);
    16   var pm = Services.perms;
    17   pm.add(makeURI("http://example.com/"), "install", pm.ALLOW_ACTION);
    19   Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);
    21   var triggers = encodeURIComponent(JSON.stringify({
    22     "Cookie check": TESTROOT2 + "cookieRedirect.sjs?" + TESTROOT + "unsigned.xpi"
    23   }));
    24   gBrowser.selectedTab = gBrowser.addTab();
    25   gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
    26 }
    28 function download_failed(install) {
    29   is(install.error, AddonManager.ERROR_NETWORK_FAILURE, "Install should fail");
    30 }
    32 function finish_test(count) {
    33   is(count, 0, "No add-ons should have been installed");
    34   var cm = Components.classes["@mozilla.org/cookiemanager;1"]
    35                      .getService(Components.interfaces.nsICookieManager2);
    36   cm.remove("example.com", "xpinstall", "/browser/" + RELATIVE_DIR, false);
    38   Services.prefs.clearUserPref("network.cookie.cookieBehavior");
    39   Services.perms.remove("example.com", "install");
    41   gBrowser.removeCurrentTab();
    42   Harness.finish();
    43 }

mercurial