netwerk/test/unit/test_cache2-20-range-200.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 function run_test()
     2 {
     3   do_get_profile();
     5   if (!newCacheBackEndUsed()) {
     6     do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different");
     7     return;
     8   }
    10   // Open for write, write
    11   asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
    12     new OpenCallback(NEW, "200m1", "200part1a-", function(entry) {
    13       // Open normally but wait for validation from the server
    14       asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
    15         new OpenCallback(PARTIAL, "200m1", "200part1a-", function(entry) {
    16           // emulate 200 from the server, i.e. recreate the entry, resume transaction and
    17           // write new content to the output stream
    18           (new OpenCallback(NEW|WAITFORWRITE|RECREATE, "200m2", "200part1b--part2b", function(entry) {
    19             entry.setValid();
    20           })).onCacheEntryAvailable(entry, true, null, Cr.NS_OK);
    21         })
    22       );
    24       var mc = new MultipleCallbacks(3, finish_cache2_test);
    26       asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
    27         new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) {
    28           mc.fired();
    29         })
    30       );
    31       asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
    32         new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) {
    33           mc.fired();
    34         })
    35       );
    36       asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
    37         new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) {
    38           mc.fired();
    39         })
    40       );
    41     })
    42   );
    44   do_test_pending();
    45 }

mercurial