tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_cache2-30b-pinning-storage-clear.js (1228B)


      1 "use strict";
      2 
      3 function run_test() {
      4  do_get_profile();
      5 
      6  var lci = Services.loadContextInfo.default;
      7 
      8  // Open a pinned entry for write, write
      9  asyncOpenCacheEntry(
     10    "http://a/",
     11    "pin",
     12    Ci.nsICacheStorage.OPEN_TRUNCATE,
     13    lci,
     14    new OpenCallback(NEW | WAITFORWRITE, "a1m", "a1d", function () {
     15      // Now clear the disk storage, that should leave the pinned  entry in the cache
     16      var diskStorage = getCacheStorage("disk", lci);
     17      diskStorage.asyncEvictStorage(null);
     18 
     19      // Open for read and check, it should still be there
     20      asyncOpenCacheEntry(
     21        "http://a/",
     22        "disk",
     23        Ci.nsICacheStorage.OPEN_NORMALLY,
     24        lci,
     25        new OpenCallback(NORMAL, "a1m", "a1d", function () {
     26          // Now clear the pinning storage, entry should be gone
     27          var pinningStorage = getCacheStorage("pin", lci);
     28          pinningStorage.asyncEvictStorage(null);
     29 
     30          asyncOpenCacheEntry(
     31            "http://a/",
     32            "disk",
     33            Ci.nsICacheStorage.OPEN_NORMALLY,
     34            lci,
     35            new OpenCallback(NEW, "", "", function () {
     36              finish_cache2_test();
     37            })
     38          );
     39        })
     40      );
     41    })
     42  );
     43 
     44  do_test_pending();
     45 }