Bug 1845311 - [Part 2] Use ChromeUtils.defineLazyGetter in more places r=arai,webcomp...
[gecko.git] / netwerk / test / unit / test_cache2-01b-basic-datasize.js
blobf7b090958fb7665c991ead2c684b5452d9c67f4c
1 "use strict";
3 function run_test() {
4   do_get_profile();
6   // Open for write, write
7   asyncOpenCacheEntry(
8     "http://a/",
9     "disk",
10     Ci.nsICacheStorage.OPEN_NORMALLY,
11     null,
12     new OpenCallback(NEW | WAITFORWRITE, "a1m", "a1d", function (entry) {
13       // Open for read and check
14       Assert.equal(entry.dataSize, 3);
15       asyncOpenCacheEntry(
16         "http://a/",
17         "disk",
18         Ci.nsICacheStorage.OPEN_NORMALLY,
19         null,
20         new OpenCallback(NORMAL, "a1m", "a1d", function (entry) {
21           // Open for rewrite (truncate), write different meta and data
22           Assert.equal(entry.dataSize, 3);
23           asyncOpenCacheEntry(
24             "http://a/",
25             "disk",
26             Ci.nsICacheStorage.OPEN_TRUNCATE,
27             null,
28             new OpenCallback(NEW | WAITFORWRITE, "a2m", "a2d", function (
29               entry
30             ) {
31               // Open for read and check
32               Assert.equal(entry.dataSize, 3);
33               asyncOpenCacheEntry(
34                 "http://a/",
35                 "disk",
36                 Ci.nsICacheStorage.OPEN_NORMALLY,
37                 null,
38                 new OpenCallback(NORMAL, "a2m", "a2d", function (entry) {
39                   Assert.equal(entry.dataSize, 3);
40                   finish_cache2_test();
41                 })
42               );
43             })
44           );
45         })
46       );
47     })
48   );
50   do_test_pending();