summaryrefslogtreecommitdiffstats
path: root/netwerk/test/unit/test_cache2-14-concurent-readers.js
blob: d2e80582dc6e5f6a3205ca94f94886e9e0acbbef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"use strict";

function run_test() {
  do_get_profile();

  asyncOpenCacheEntry(
    "http://x/",
    "disk",
    Ci.nsICacheStorage.OPEN_NORMALLY,
    null,
    new OpenCallback(NEW, "x1m", "x1d", function (entry) {
      // nothing to do here, we expect concurent callbacks to get
      // all notified, then the test finishes
    })
  );

  var mc = new MultipleCallbacks(3, finish_cache2_test);

  asyncOpenCacheEntry(
    "http://x/",
    "disk",
    Ci.nsICacheStorage.OPEN_NORMALLY,
    null,
    new OpenCallback(NORMAL, "x1m", "x1d", function (entry) {
      mc.fired();
    })
  );
  asyncOpenCacheEntry(
    "http://x/",
    "disk",
    Ci.nsICacheStorage.OPEN_NORMALLY,
    null,
    new OpenCallback(NORMAL, "x1m", "x1d", function (entry) {
      mc.fired();
    })
  );
  asyncOpenCacheEntry(
    "http://x/",
    "disk",
    Ci.nsICacheStorage.OPEN_NORMALLY,
    null,
    new OpenCallback(NORMAL, "x1m", "x1d", function (entry) {
      mc.fired();
    })
  );

  do_test_pending();
}