tor-browser

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

test_cache_requestCache.js (1065B)


      1 /* global context testDone:true */
      2 
      3 var name = "requestCache" + context;
      4 var c;
      5 
      6 var reqWithoutCache = new Request("//mochi.test:8888/?noCache" + context);
      7 var reqWithCache = new Request("//mochi.test:8888/?withCache" + context, {
      8  cache: "force-cache",
      9 });
     10 
     11 // Sanity check
     12 is(reqWithoutCache.cache, "default", "Correct default value");
     13 is(reqWithCache.cache, "force-cache", "Correct value set by the ctor");
     14 
     15 caches
     16  .open(name)
     17  .then(function (cache) {
     18    c = cache;
     19    return c.addAll([reqWithoutCache, reqWithCache]);
     20  })
     21  .then(function () {
     22    return c.keys();
     23  })
     24  .then(function (keys) {
     25    is(keys.length, 2, "Correct number of requests");
     26    is(keys[0].url, reqWithoutCache.url, "Correct URL");
     27    is(keys[0].cache, reqWithoutCache.cache, "Correct cache attribute");
     28    is(keys[1].url, reqWithCache.url, "Correct URL");
     29    is(keys[1].cache, reqWithCache.cache, "Correct cache attribute");
     30    return caches.delete(name);
     31  })
     32  .then(function (deleted) {
     33    ok(deleted, "The cache should be successfully deleted");
     34    testDone();
     35  });