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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
"use strict";
const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs"
);
function run_test() {
do_get_profile();
run_next_test();
}
add_task(
{
skip_if: () => !AppConstants.MOZ_NEW_XULSTORE,
},
async function test_create_old_datastore() {
const path = PathUtils.join(PathUtils.profileDir, "xulstore.json");
const xulstoreJSON = {
doc1: {
id1: {
attr1: "value1",
},
},
doc2: {
id1: {
attr2: "value2",
},
id2: {
attr1: "value1",
attr2: "value2",
attr3: "value3",
},
id3: {},
},
doc3: {},
};
await IOUtils.writeJSON(path, xulstoreJSON);
}
);
add_task(
{
skip_if: () => !AppConstants.MOZ_NEW_XULSTORE,
},
async function test_get_values() {
// We wait until now to import XULStore to ensure we've created
// the old datastore, as importing that module will initiate the attempt
// to migrate the old datastore to the new one.
const { XULStore } = ChromeUtils.import(
"resource://gre/modules/XULStore.jsm"
);
Assert.equal(await XULStore.getValue("doc1", "id1", "attr1"), "value1");
Assert.equal(await XULStore.getValue("doc1", "id1", "attr2"), "");
Assert.equal(await XULStore.getValue("doc1", "id1", "attr3"), "");
Assert.equal(await XULStore.getValue("doc1", "id2", "attr1"), "");
Assert.equal(await XULStore.getValue("doc1", "id2", "attr2"), "");
Assert.equal(await XULStore.getValue("doc1", "id2", "attr3"), "");
Assert.equal(await XULStore.getValue("doc1", "id3", "attr1"), "");
Assert.equal(await XULStore.getValue("doc1", "id3", "attr2"), "");
Assert.equal(await XULStore.getValue("doc1", "id3", "attr3"), "");
Assert.equal(await XULStore.getValue("doc2", "id1", "attr1"), "");
Assert.equal(await XULStore.getValue("doc2", "id1", "attr2"), "value2");
Assert.equal(await XULStore.getValue("doc2", "id1", "attr3"), "");
Assert.equal(await XULStore.getValue("doc2", "id2", "attr1"), "value1");
Assert.equal(await XULStore.getValue("doc2", "id2", "attr2"), "value2");
Assert.equal(await XULStore.getValue("doc2", "id2", "attr3"), "value3");
Assert.equal(await XULStore.getValue("doc2", "id3", "attr1"), "");
Assert.equal(await XULStore.getValue("doc2", "id3", "attr2"), "");
Assert.equal(await XULStore.getValue("doc2", "id3", "attr3"), "");
Assert.equal(await XULStore.getValue("doc3", "id1", "attr1"), "");
Assert.equal(await XULStore.getValue("doc3", "id1", "attr2"), "");
Assert.equal(await XULStore.getValue("doc3", "id1", "attr3"), "");
Assert.equal(await XULStore.getValue("doc3", "id2", "attr1"), "");
Assert.equal(await XULStore.getValue("doc3", "id2", "attr2"), "");
Assert.equal(await XULStore.getValue("doc3", "id2", "attr3"), "");
Assert.equal(await XULStore.getValue("doc3", "id3", "attr1"), "");
Assert.equal(await XULStore.getValue("doc3", "id3", "attr2"), "");
Assert.equal(await XULStore.getValue("doc3", "id3", "attr3"), "");
}
);
|