netwerk/test/unit/test_cache2-22-anon-visit.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/test/unit/test_cache2-22-anon-visit.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +Components.utils.import('resource://gre/modules/LoadContextInfo.jsm');
     1.5 +
     1.6 +function run_test()
     1.7 +{
     1.8 +  do_get_profile();
     1.9 +
    1.10 +  function checkNewBackEnd()
    1.11 +  {
    1.12 +    var storage = getCacheStorage("disk", LoadContextInfo.default);
    1.13 +    storage.asyncVisitStorage(
    1.14 +      new VisitCallback(1, 12, ["http://an2/"], function() {
    1.15 +        storage = getCacheStorage("disk", LoadContextInfo.anonymous);
    1.16 +        storage.asyncVisitStorage(
    1.17 +          new VisitCallback(1, 12, ["http://an2/"], function() {
    1.18 +            finish_cache2_test();
    1.19 +          }),
    1.20 +          true
    1.21 +        );
    1.22 +      }),
    1.23 +      true
    1.24 +    );
    1.25 +  }
    1.26 +
    1.27 +  function checkOldBackEnd()
    1.28 +  {
    1.29 +    syncWithCacheIOThread(function() {
    1.30 +      var storage = getCacheStorage("disk", LoadContextInfo.default);
    1.31 +      storage.asyncVisitStorage(
    1.32 +        new VisitCallback(2, 24, ["http://an2/", "anon&uri=http://an2/"], function() {
    1.33 +          storage = getCacheStorage("disk", LoadContextInfo.anonymous);
    1.34 +          storage.asyncVisitStorage(
    1.35 +            new VisitCallback(0, 0, [], function() {
    1.36 +              finish_cache2_test();
    1.37 +            }),
    1.38 +            true
    1.39 +          );
    1.40 +        }),
    1.41 +        true
    1.42 +      );
    1.43 +    });
    1.44 +  }
    1.45 +
    1.46 +  var mc = new MultipleCallbacks(2, newCacheBackEndUsed() ? checkNewBackEnd : checkOldBackEnd, !newCacheBackEndUsed());
    1.47 +
    1.48 +  asyncOpenCacheEntry("http://an2/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.default,
    1.49 +    new OpenCallback(NEW|WAITFORWRITE, "an2", "an2", function(entry) {
    1.50 +      mc.fired();
    1.51 +    })
    1.52 +  );
    1.53 +
    1.54 +  asyncOpenCacheEntry("http://an2/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.anonymous,
    1.55 +    new OpenCallback(NEW|WAITFORWRITE, "an2", "an2", function(entry) {
    1.56 +      mc.fired();
    1.57 +    })
    1.58 +  );
    1.59 +
    1.60 +  do_test_pending();
    1.61 +}

mercurial