Bug 1931425 - Limit how often moz-label's #setStyles runs r=reusable-components-revie...
[gecko.git] / netwerk / test / unit / test_cache2-07a-open-memory.js
blob3392ee33fc26a4122a13aaff09de434904370501
1 "use strict";
3 function run_test() {
4 do_get_profile();
6 // First check how behaves the memory storage.
8 asyncOpenCacheEntry(
9 "http://mem-first/",
10 "memory",
11 Ci.nsICacheStorage.OPEN_NORMALLY,
12 null,
13 new OpenCallback(NEW, "mem1-meta", "mem1-data", function (entryM1) {
14 Assert.ok(!entryM1.persistent);
15 asyncOpenCacheEntry(
16 "http://mem-first/",
17 "disk",
18 Ci.nsICacheStorage.OPEN_NORMALLY,
19 null,
20 new OpenCallback(NORMAL, "mem1-meta", "mem1-data", function (entryM2) {
21 Assert.ok(!entryM1.persistent);
22 Assert.ok(!entryM2.persistent);
24 // Now check the disk storage behavior.
26 asyncOpenCacheEntry(
27 "http://disk-first/",
28 "disk",
29 Ci.nsICacheStorage.OPEN_NORMALLY,
30 null,
31 // Must wait for write, since opening the entry as memory-only before the disk one
32 // is written would cause NS_ERROR_NOT_AVAILABLE from openOutputStream when writing
33 // this disk entry since it's doomed during opening of the memory-only entry for the same URL.
34 new OpenCallback(
35 NEW | WAITFORWRITE,
36 "disk1-meta",
37 "disk1-data",
38 function (entryD1) {
39 Assert.ok(entryD1.persistent);
40 // Now open the same URL as a memory-only entry, the disk entry must be doomed.
41 asyncOpenCacheEntry(
42 "http://disk-first/",
43 "memory",
44 Ci.nsICacheStorage.OPEN_NORMALLY,
45 null,
46 // This must be recreated
47 new OpenCallback(NEW, "mem2-meta", "mem2-data", function (
48 entryD2
49 ) {
50 Assert.ok(entryD1.persistent);
51 Assert.ok(!entryD2.persistent);
52 // Check we get it back, even when opening via the disk storage
53 asyncOpenCacheEntry(
54 "http://disk-first/",
55 "disk",
56 Ci.nsICacheStorage.OPEN_NORMALLY,
57 null,
58 new OpenCallback(
59 NORMAL,
60 "mem2-meta",
61 "mem2-data",
62 function (entryD3) {
63 Assert.ok(entryD1.persistent);
64 Assert.ok(!entryD2.persistent);
65 Assert.ok(!entryD3.persistent);
66 finish_cache2_test();
80 do_test_pending();