tor-browser

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

test_cache2-19-range-206.js (1699B)


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