netwerk/test/unit/test_cache2-16-conditional-200.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:ea875c16a592
1 function run_test()
2 {
3 do_get_profile();
4
5 if (!newCacheBackEndUsed()) {
6 do_check_true(true, "This test doesn't run when the old cache back end is used since the behavior is different");
7 return;
8 }
9
10 // Open for write, write
11 asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
12 new OpenCallback(NEW, "21m", "21d", function(entry) {
13 asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
14 new OpenCallback(NORMAL, "21m", "21d", function(entry) {
15 // Open normally but wait for validation from the server
16 asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
17 new OpenCallback(REVAL, "21m", "21d", function(entry) {
18 // emulate 200 from server (new content)
19 do_execute_soon(function() {
20 var entry2 = entry.recreate();
21
22 // now fill the new entry, use OpenCallback directly for it
23 (new OpenCallback(NEW, "22m", "22d", function() {}))
24 .onCacheEntryAvailable(entry2, true, null, Cr.NS_OK);
25 });
26 })
27 );
28
29 var mc = new MultipleCallbacks(3, finish_cache2_test);
30
31 asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
32 new OpenCallback(NORMAL, "22m", "22d", function(entry) {
33 mc.fired();
34 })
35 );
36 asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
37 new OpenCallback(NORMAL, "22m", "22d", function(entry) {
38 mc.fired();
39 })
40 );
41 asyncOpenCacheEntry("http://200/", "disk", Ci.nsICacheStorage.OPEN_NORMALLY, null,
42 new OpenCallback(NORMAL, "22m", "22d", function(entry) {
43 mc.fired();
44 })
45 );
46 })
47 );
48 })
49 );
50
51 do_test_pending();
52 }

mercurial