1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/unit/test_cache2-19-range-206.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +function run_test() 1.5 +{ 1.6 + do_get_profile(); 1.7 + 1.8 + if (!newCacheBackEndUsed()) { 1.9 + do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); 1.10 + return; 1.11 + } 1.12 + 1.13 + // Open for write, write 1.14 + asyncOpenCacheEntry("http://r206/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.15 + new OpenCallback(NEW, "206m", "206part1-", function(entry) { 1.16 + // Open normally but wait for validation from the server 1.17 + asyncOpenCacheEntry("http://r206/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.18 + new OpenCallback(PARTIAL, "206m", "206part1-", function(entry) { 1.19 + // emulate 206 from the server, i.e. resume transaction and write content to the output stream 1.20 + (new OpenCallback(NEW|WAITFORWRITE|PARTIAL, "206m", "-part2", function(entry) { 1.21 + entry.setValid(); 1.22 + })).onCacheEntryAvailable(entry, true, null, Cr.NS_OK); 1.23 + }) 1.24 + ); 1.25 + 1.26 + var mc = new MultipleCallbacks(3, finish_cache2_test); 1.27 + 1.28 + asyncOpenCacheEntry("http://r206/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.29 + new OpenCallback(NORMAL, "206m", "206part1--part2", function(entry) { 1.30 + mc.fired(); 1.31 + }) 1.32 + ); 1.33 + asyncOpenCacheEntry("http://r206/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.34 + new OpenCallback(NORMAL, "206m", "206part1--part2", function(entry) { 1.35 + mc.fired(); 1.36 + }) 1.37 + ); 1.38 + asyncOpenCacheEntry("http://r206/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.39 + new OpenCallback(NORMAL, "206m", "206part1--part2", function(entry) { 1.40 + mc.fired(); 1.41 + }) 1.42 + ); 1.43 + }) 1.44 + ); 1.45 + 1.46 + do_test_pending(); 1.47 +}