tor-browser

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

test_cache2-20-range-200.js (1762B)


      1 "use strict";
      2 
      3 function run_test() {
      4  do_get_profile();
      5 
      6  // Open for write, write
      7  asyncOpenCacheEntry(
      8    "http://r200/",
      9    "disk",
     10    Ci.nsICacheStorage.OPEN_NORMALLY,
     11    null,
     12    new OpenCallback(NEW, "200m1", "200part1a-", function () {
     13      // Open normally but wait for validation from the server
     14      asyncOpenCacheEntry(
     15        "http://r200/",
     16        "disk",
     17        Ci.nsICacheStorage.OPEN_NORMALLY,
     18        null,
     19        new OpenCallback(PARTIAL, "200m1", "200part1a-", function (entry) {
     20          // emulate 200 from the server, i.e. recreate the entry, resume transaction and
     21          // write new content to the output stream
     22          new OpenCallback(
     23            NEW | WAITFORWRITE | RECREATE,
     24            "200m2",
     25            "200part1b--part2b",
     26            function (entry1) {
     27              entry1.setValid();
     28            }
     29          ).onCacheEntryAvailable(entry, true, Cr.NS_OK);
     30        })
     31      );
     32 
     33      var mc = new MultipleCallbacks(3, finish_cache2_test);
     34 
     35      asyncOpenCacheEntry(
     36        "http://r200/",
     37        "disk",
     38        Ci.nsICacheStorage.OPEN_NORMALLY,
     39        null,
     40        new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function () {
     41          mc.fired();
     42        })
     43      );
     44      asyncOpenCacheEntry(
     45        "http://r200/",
     46        "disk",
     47        Ci.nsICacheStorage.OPEN_NORMALLY,
     48        null,
     49        new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function () {
     50          mc.fired();
     51        })
     52      );
     53      asyncOpenCacheEntry(
     54        "http://r200/",
     55        "disk",
     56        Ci.nsICacheStorage.OPEN_NORMALLY,
     57        null,
     58        new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function () {
     59          mc.fired();
     60        })
     61      );
     62    })
     63  );
     64 
     65  do_test_pending();
     66 }