michael@0: function run_test() michael@0: { michael@0: do_get_profile(); michael@0: michael@0: if (!newCacheBackEndUsed()) { michael@0: do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different"); michael@0: return; michael@0: } michael@0: michael@0: // Open for write, write michael@0: asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "200m1", "200part1a-", function(entry) { michael@0: // Open normally but wait for validation from the server michael@0: asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(PARTIAL, "200m1", "200part1a-", function(entry) { michael@0: // emulate 200 from the server, i.e. recreate the entry, resume transaction and michael@0: // write new content to the output stream michael@0: (new OpenCallback(NEW|WAITFORWRITE|RECREATE, "200m2", "200part1b--part2b", function(entry) { michael@0: entry.setValid(); michael@0: })).onCacheEntryAvailable(entry, true, null, Cr.NS_OK); michael@0: }) michael@0: ); michael@0: michael@0: var mc = new MultipleCallbacks(3, finish_cache2_test); michael@0: michael@0: asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: asyncOpenCacheEntry("http://r200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "200m2", "200part1b--part2b", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: do_test_pending(); michael@0: }