diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /netwerk/test/unit/test_cache2-05-visit.js | |
parent | Initial commit. (diff) | |
download | firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.tar.xz firefox-e51783d008170d9ab27d25da98ca3a38b0a41b67.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'netwerk/test/unit/test_cache2-05-visit.js')
-rw-r--r-- | netwerk/test/unit/test_cache2-05-visit.js | 113 |
1 files changed, 113 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 0000000000..b4ed3ea26e --- /dev/null +++ b/netwerk/test/unit/test_cache2-05-visit.js @@ -0,0 +1,113 @@ +"use strict"; + +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. + executeSoon(function () { + syncWithCacheIOThread(function () { + var expectedConsumption = 4096; + + 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 + ); + }); + }); + }); + + asyncOpenCacheEntry( + "http://a/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NEW, "a1m", "a1d", function () { + asyncOpenCacheEntry( + "http://a/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NORMAL, "a1m", "a1d", function () { + mc.fired(); + }) + ); + }) + ); + + asyncOpenCacheEntry( + "http://b/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NEW, "b1m", "b1d", function () { + asyncOpenCacheEntry( + "http://b/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NORMAL, "b1m", "b1d", function () { + mc.fired(); + }) + ); + }) + ); + + asyncOpenCacheEntry( + "http://c/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NEW, "c1m", "c1d", function () { + asyncOpenCacheEntry( + "http://c/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NORMAL, "c1m", "c1d", function () { + mc.fired(); + }) + ); + }) + ); + + asyncOpenCacheEntry( + "http://d/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NEW, "d1m", "d1d", function () { + asyncOpenCacheEntry( + "http://d/", + "disk", + Ci.nsICacheStorage.OPEN_NORMALLY, + null, + new OpenCallback(NORMAL, "d1m", "d1d", function () { + mc.fired(); + }) + ); + }) + ); + + do_test_pending(); +} |