netwerk/test/unit/test_cache2-07-visit-memory.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 function run_test()
michael@0 2 {
michael@0 3 do_get_profile();
michael@0 4
michael@0 5 if (!newCacheBackEndUsed()) {
michael@0 6 do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different");
michael@0 7 return;
michael@0 8 }
michael@0 9
michael@0 10 // Add entry to the memory storage
michael@0 11 var mc = new MultipleCallbacks(5, function() {
michael@0 12 // Check it's there by visiting the storage
michael@0 13 syncWithCacheIOThread(function() {
michael@0 14 var storage = getCacheStorage("memory");
michael@0 15 storage.asyncVisitStorage(
michael@0 16 new VisitCallback(1, 12, ["http://mem1/"], function() {
michael@0 17 storage = getCacheStorage("disk");
michael@0 18 storage.asyncVisitStorage(
michael@0 19 // Previous tests should store 4 disk entries + 1 memory entry
michael@0 20 new VisitCallback(5, 60, ["http://a/", "http://b/", "http://c/", "http://d/", "http://mem1/"], function() {
michael@0 21 finish_cache2_test();
michael@0 22 }),
michael@0 23 true
michael@0 24 );
michael@0 25 }),
michael@0 26 true
michael@0 27 );
michael@0 28 });
michael@0 29 });
michael@0 30
michael@0 31 asyncOpenCacheEntry("http://mem1/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 32 new OpenCallback(NEW, "m1m", "m1d", function(entry) {
michael@0 33 asyncOpenCacheEntry("http://mem1/", "memory", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 34 new OpenCallback(NORMAL, "m1m", "m1d", function(entry) {
michael@0 35 mc.fired();
michael@0 36 })
michael@0 37 );
michael@0 38 })
michael@0 39 );
michael@0 40
michael@0 41 asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 42 new OpenCallback(NEW, "a1m", "a1d", function(entry) {
michael@0 43 asyncOpenCacheEntry("http://a/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 44 new OpenCallback(NORMAL, "a1m", "a1d", function(entry) {
michael@0 45 mc.fired();
michael@0 46 })
michael@0 47 );
michael@0 48 })
michael@0 49 );
michael@0 50
michael@0 51 asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 52 new OpenCallback(NEW, "a1m", "a1d", function(entry) {
michael@0 53 asyncOpenCacheEntry("http://b/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 54 new OpenCallback(NORMAL, "a1m", "a1d", function(entry) {
michael@0 55 mc.fired();
michael@0 56 })
michael@0 57 );
michael@0 58 })
michael@0 59 );
michael@0 60
michael@0 61 asyncOpenCacheEntry("http://c/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 62 new OpenCallback(NEW, "a1m", "a1d", function(entry) {
michael@0 63 asyncOpenCacheEntry("http://c/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 64 new OpenCallback(NORMAL, "a1m", "a1d", function(entry) {
michael@0 65 mc.fired();
michael@0 66 })
michael@0 67 );
michael@0 68 })
michael@0 69 );
michael@0 70
michael@0 71 asyncOpenCacheEntry("http://d/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 72 new OpenCallback(NEW, "a1m", "a1d", function(entry) {
michael@0 73 asyncOpenCacheEntry("http://d/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
michael@0 74 new OpenCallback(NORMAL, "a1m", "a1d", function(entry) {
michael@0 75 mc.fired();
michael@0 76 })
michael@0 77 );
michael@0 78 })
michael@0 79 );
michael@0 80
michael@0 81 do_test_pending();
michael@0 82 }

mercurial