diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/test/unit/test_cache2-05-visit.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/test/unit/test_cache2-05-visit.js')
-rw-r--r-- | netwerk/test/unit/test_cache2-05-visit.js | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/netwerk/test/unit/test_cache2-05-visit.js b/netwerk/test/unit/test_cache2-05-visit.js new file mode 100644 index 000000000..550162271 --- /dev/null +++ b/netwerk/test/unit/test_cache2-05-visit.js @@ -0,0 +1,78 @@ +function run_test() +{ + do_get_profile(); + + var storage = getCacheStorage("disk"); + var mc = new MultipleCallbacks(4, function() { + // Method asyncVisitStorage() gets the data from index on Cache I/O thread + // with INDEX priority, so it is ensured that index contains information + // about all pending writes. However, OpenCallback emulates network latency + // by postponing the writes using do_execute_soon. We must do the same here + // to make sure that all writes are posted to Cache I/O thread before we + // visit the storage. + do_execute_soon(function() { + syncWithCacheIOThread(function() { + + var expectedConsumption = newCacheBackEndUsed() + ? 4096 + : 48; + + storage.asyncVisitStorage( + // Test should store 4 entries + new VisitCallback(4, expectedConsumption, ["http://a/", "http://b/", "http://c/", "http://d/"], function() { + storage.asyncVisitStorage( + // Still 4 entries expected, now don't walk them + new VisitCallback(4, expectedConsumption, null, function() { + finish_cache2_test(); + }), + false + ); + }), + true + ); + }); + }); + }, !newCacheBackEndUsed()); + + asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NEW, "a1m", "a1d", function(entry) { + asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NORMAL, "a1m", "a1d", function(entry) { + mc.fired(); + }) + ); + }) + ); + + asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NEW, "b1m", "b1d", function(entry) { + asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NORMAL, "b1m", "b1d", function(entry) { + mc.fired(); + }) + ); + }) + ); + + asyncOpenCacheEntry("http://c/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NEW, "c1m", "c1d", function(entry) { + asyncOpenCacheEntry("http://c/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NORMAL, "c1m", "c1d", function(entry) { + mc.fired(); + }) + ); + }) + ); + + asyncOpenCacheEntry("http://d/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NEW, "d1m", "d1d", function(entry) { + asyncOpenCacheEntry("http://d/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null, + new OpenCallback(NORMAL, "d1m", "d1d", function(entry) { + mc.fired(); + }) + ); + }) + ); + + do_test_pending(); +} |