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://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "21m", "21d", function(entry) { michael@0: asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "21m", "21d", function(entry) { michael@0: // Open normally but wait for validation from the server michael@0: asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(REVAL, "21m", "21d", function(entry) { michael@0: // emulate 200 from server (new content) michael@0: do_execute_soon(function() { michael@0: var entry2 = entry.recreate(); michael@0: michael@0: // now fill the new entry, use OpenCallback directly for it michael@0: (new OpenCallback(NEW, "22m", "22d", function() {})) michael@0: .onCacheEntryAvailable(entry2, true, null, Cr.NS_OK); michael@0: }); michael@0: }) michael@0: ); michael@0: michael@0: var mc = new MultipleCallbacks(3, finish_cache2_test); michael@0: michael@0: asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "22m", "22d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "22m", "22d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "22m", "22d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: do_test_pending(); michael@0: }