|
1 Components.utils.import('resource://gre/modules/LoadContextInfo.jsm'); |
|
2 |
|
3 function run_test() |
|
4 { |
|
5 do_get_profile(); |
|
6 |
|
7 function checkNewBackEnd() |
|
8 { |
|
9 var storage = getCacheStorage("disk", LoadContextInfo.default); |
|
10 storage.asyncVisitStorage( |
|
11 new VisitCallback(1, 12, ["http://an2/"], function() { |
|
12 storage = getCacheStorage("disk", LoadContextInfo.anonymous); |
|
13 storage.asyncVisitStorage( |
|
14 new VisitCallback(1, 12, ["http://an2/"], function() { |
|
15 finish_cache2_test(); |
|
16 }), |
|
17 true |
|
18 ); |
|
19 }), |
|
20 true |
|
21 ); |
|
22 } |
|
23 |
|
24 function checkOldBackEnd() |
|
25 { |
|
26 syncWithCacheIOThread(function() { |
|
27 var storage = getCacheStorage("disk", LoadContextInfo.default); |
|
28 storage.asyncVisitStorage( |
|
29 new VisitCallback(2, 24, ["http://an2/", "anon&uri=http://an2/"], function() { |
|
30 storage = getCacheStorage("disk", LoadContextInfo.anonymous); |
|
31 storage.asyncVisitStorage( |
|
32 new VisitCallback(0, 0, [], function() { |
|
33 finish_cache2_test(); |
|
34 }), |
|
35 true |
|
36 ); |
|
37 }), |
|
38 true |
|
39 ); |
|
40 }); |
|
41 } |
|
42 |
|
43 var mc = new MultipleCallbacks(2, newCacheBackEndUsed() ? checkNewBackEnd : checkOldBackEnd, !newCacheBackEndUsed()); |
|
44 |
|
45 asyncOpenCacheEntry("http://an2/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.default, |
|
46 new OpenCallback(NEW|WAITFORWRITE, "an2", "an2", function(entry) { |
|
47 mc.fired(); |
|
48 }) |
|
49 ); |
|
50 |
|
51 asyncOpenCacheEntry("http://an2/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, LoadContextInfo.anonymous, |
|
52 new OpenCallback(NEW|WAITFORWRITE, "an2", "an2", function(entry) { |
|
53 mc.fired(); |
|
54 }) |
|
55 ); |
|
56 |
|
57 do_test_pending(); |
|
58 } |