netwerk/test/unit/test_cache2-06-pb-mode.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 function exitPB()
     2 {
     3   var obsvc = Cc["@mozilla.org/observer-service;1"].
     4     getService(Ci.nsIObserverService);
     5   obsvc.notifyObservers(null, "last-pb-context-exited", null);
     6 }
     8 function run_test()
     9 {
    10   do_get_profile();
    12   // Store PB entry
    13   asyncOpenCacheEntry("http://p1/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.private,
    14     new OpenCallback(NEW, "p1m", "p1d", function(entry) {
    15       asyncOpenCacheEntry("http://p1/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.private,
    16         new OpenCallback(NORMAL, "p1m", "p1d", function(entry) {
    17           // Check it's there
    18           syncWithCacheIOThread(function() {
    19             var storage = getCacheStorage("disk", LoadContextInfo.private);
    20             storage.asyncVisitStorage(
    21               new VisitCallback(1, 12, ["http://p1/"], function() {
    22                 // Simulate PB exit
    23                 exitPB();
    24                 // Check the entry is gone
    25                 storage.asyncVisitStorage(
    26                   new VisitCallback(0, 0, [], function() {
    27                     finish_cache2_test();
    28                   }),
    29                   true
    30                 );
    31               }),
    32               true
    33             );
    34           });
    35         })
    36       );
    37     })
    38   );
    40   do_test_pending();
    41 }

mercurial