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: // Add entry to the memory storage michael@0: var mc = new MultipleCallbacks(5, function() { michael@0: // Check it's there by visiting the storage michael@0: syncWithCacheIOThread(function() { michael@0: var storage = getCacheStorage("memory"); michael@0: storage.asyncVisitStorage( michael@0: new VisitCallback(1, 12, ["http://mem1/"], function() { michael@0: storage = getCacheStorage("disk"); michael@0: storage.asyncVisitStorage( michael@0: // Previous tests should store 4 disk entries + 1 memory entry michael@0: new VisitCallback(5, 60, ["http://a/", "http://b/", "http://c/", "http://d/", "http://mem1/"], function() { michael@0: finish_cache2_test(); michael@0: }), michael@0: true michael@0: ); michael@0: }), michael@0: true michael@0: ); michael@0: }); michael@0: }); michael@0: michael@0: asyncOpenCacheEntry("http://mem1/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "m1m", "m1d", function(entry) { michael@0: asyncOpenCacheEntry("http://mem1/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "m1m", "m1d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "a1m", "a1d", function(entry) { michael@0: asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "a1m", "a1d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "a1m", "a1d", function(entry) { michael@0: asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "a1m", "a1d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: asyncOpenCacheEntry("http://c/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "a1m", "a1d", function(entry) { michael@0: asyncOpenCacheEntry("http://c/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "a1m", "a1d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: asyncOpenCacheEntry("http://d/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NEW, "a1m", "a1d", function(entry) { michael@0: asyncOpenCacheEntry("http://d/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, michael@0: new OpenCallback(NORMAL, "a1m", "a1d", function(entry) { michael@0: mc.fired(); michael@0: }) michael@0: ); michael@0: }) michael@0: ); michael@0: michael@0: do_test_pending(); michael@0: }