1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/unit/test_cache2-20-range-200.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,45 @@ 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://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.15 + new OpenCallback(NEW, "200m1", "200part1a-", function(entry) { 1.16 + // Open normally but wait for validation from the server 1.17 + asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.18 + new OpenCallback(PARTIAL, "200m1", "200part1a-", function(entry) { 1.19 + // emulate 200 from the server, i.e. recreate the entry, resume transaction and 1.20 + // write new content to the output stream 1.21 + (new OpenCallback(NEW|WAITFORWRITE|RECREATE, "200m2", "200part1b--part2b", function(entry) { 1.22 + entry.setValid(); 1.23 + })).onCacheEntryAvailable(entry, true, null, Cr.NS_OK); 1.24 + }) 1.25 + ); 1.26 + 1.27 + var mc = new MultipleCallbacks(3, finish_cache2_test); 1.28 + 1.29 + asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.30 + new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) { 1.31 + mc.fired(); 1.32 + }) 1.33 + ); 1.34 + asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.35 + new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) { 1.36 + mc.fired(); 1.37 + }) 1.38 + ); 1.39 + asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, 1.40 + new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) { 1.41 + mc.fired(); 1.42 + }) 1.43 + ); 1.44 + }) 1.45 + ); 1.46 + 1.47 + do_test_pending(); 1.48 +}