netwerk/test/unit/test_bug667818.js

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 Cu.import("resource://gre/modules/Services.jsm");
     3 function makeURI(str) {
     4     return Components.classes["@mozilla.org/network/io-service;1"]
     5                      .getService(Components.interfaces.nsIIOService)
     6                      .newURI(str, null, null);
     7 }
     9 function run_test() {
    10     // Allow all cookies.
    11     Services.prefs.setIntPref("network.cookie.cookieBehavior", 0);
    12     var serv =   Components.classes["@mozilla.org/cookieService;1"]
    13                            .getService(Components.interfaces.nsICookieService);
    14     var uri = makeURI("http://example.com/");
    15     // Try an expiration time before the epoch
    16     serv.setCookieString(uri, null, "test=test; path=/; domain=example.com; expires=Sun, 31-Dec-1899 16:00:00 GMT;", null);
    17     do_check_eq(serv.getCookieString(uri, null), null);
    18     // Now sanity check
    19     serv.setCookieString(uri, null, "test2=test2; path=/; domain=example.com;", null);
    20     do_check_eq(serv.getCookieString(uri, null), "test2=test2");
    21 }

mercurial