Bug 1857386 [wpt PR 42383] - Update wpt metadata, a=testonly
[gecko.git] / netwerk / test / unit / test_cache2-14b-concurent-readers-complete.js
blob244dca9a3b0e820e0781e936f6bd3add66dac983
1 "use strict";
3 function run_test() {
4   do_get_profile();
6   asyncOpenCacheEntry(
7     "http://x/",
8     "disk",
9     Ci.nsICacheStorage.OPEN_NORMALLY,
10     null,
11     new OpenCallback(NEW, "x1m", "x1d", function (entry) {
12       // nothing to do here, we expect concurent callbacks to get
13       // all notified, then the test finishes
14     })
15   );
17   var mc = new MultipleCallbacks(3, finish_cache2_test);
19   var order = 0;
21   asyncOpenCacheEntry(
22     "http://x/",
23     "disk",
24     Ci.nsICacheStorage.OPEN_NORMALLY,
25     null,
26     new OpenCallback(
27       NORMAL | COMPLETE | NOTIFYBEFOREREAD,
28       "x1m",
29       "x1d",
30       function (entry, beforeReading) {
31         if (beforeReading) {
32           ++order;
33           Assert.equal(order, 3);
34         } else {
35           mc.fired();
36         }
37       }
38     )
39   );
40   asyncOpenCacheEntry(
41     "http://x/",
42     "disk",
43     Ci.nsICacheStorage.OPEN_NORMALLY,
44     null,
45     new OpenCallback(NORMAL | NOTIFYBEFOREREAD, "x1m", "x1d", function (
46       entry,
47       beforeReading
48     ) {
49       if (beforeReading) {
50         ++order;
51         Assert.equal(order, 1);
52       } else {
53         mc.fired();
54       }
55     })
56   );
57   asyncOpenCacheEntry(
58     "http://x/",
59     "disk",
60     Ci.nsICacheStorage.OPEN_NORMALLY,
61     null,
62     new OpenCallback(NORMAL | NOTIFYBEFOREREAD, "x1m", "x1d", function (
63       entry,
64       beforeReading
65     ) {
66       if (beforeReading) {
67         ++order;
68         Assert.equal(order, 2);
69       } else {
70         mc.fired();
71       }
72     })
73   );
75   do_test_pending();