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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// A flat origin directory is an origin directory with no sub directories for
// quota clients. The upgrade was initially done lazily and an empty .metadata
// file was used to indicate a successful upgrade.
function* testSteps() {
const setups = [
{
packages: [
// Storage used prior FF 22 (indexedDB/ directory with flat origin
// directories).
// FF 26 renamed indexedDB/ to storage/persistent and the lazy upgrade
// of flat origin directories remained. There's a test for that below.
"indexedDBDirectory_flatOriginDirectories_profile",
"../indexedDBDirectory_shared",
],
origins: [
{
oldPath: "indexedDB/1007+f+app+++system.gaiamobile.org",
},
{
oldPath: "indexedDB/1007+t+https+++developer.cdn.mozilla.net",
},
{
oldPath: "indexedDB/http+++www.mozilla.org",
newPath: "storage/default/http+++www.mozilla.org",
url: "http://www.mozilla.org",
persistence: "default",
},
],
},
{
packages: [
// Storage used by FF 26-35 (storage/persistent/ directory with not yet
// upgraded flat origin directories).
// FF 36 renamed storage/persistent/ to storage/default/ and all not
// yet upgraded flat origin directories were upgraded. There's a
// separate test for that:
// test_upgradeFromPersistentStorageDirectory_upgradeOriginDirectories.
"persistentStorageDirectory_flatOriginDirectories_profile",
"../persistentStorageDirectory_shared",
],
origins: [
{
oldPath: "storage/persistent/1007+f+app+++system.gaiamobile.org",
},
{
oldPath:
"storage/persistent/1007+t+https+++developer.cdn.mozilla.net",
},
{
oldPath: "storage/persistent/http+++www.mozilla.org",
newPath: "storage/default/http+++www.mozilla.org",
url: "http://www.mozilla.org",
persistence: "default",
},
],
},
];
const metadataFileName = ".metadata";
for (const setup of setups) {
clear(continueToNextStepSync);
yield undefined;
info("Verifying storage");
verifyStorage(setup.packages, "beforeInstall");
info("Installing packages");
installPackages(setup.packages);
info("Verifying storage");
verifyStorage(setup.packages, "afterInstall");
info("Checking origin directories");
for (const origin of setup.origins) {
let originDir = getRelativeFile(origin.oldPath);
let exists = originDir.exists();
ok(exists, "Origin directory does exist");
let idbDir = originDir.clone();
idbDir.append("idb");
exists = idbDir.exists();
ok(!exists, "idb directory doesn't exist");
let metadataFile = originDir.clone();
metadataFile.append(metadataFileName);
exists = metadataFile.exists();
ok(!exists, "Metadata file doesn't exist");
if (origin.newPath) {
originDir = getRelativeFile(origin.newPath);
exists = originDir.exists();
ok(!exists, "Origin directory doesn't exist");
}
}
info("Initializing");
let request = init(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_OK, "Initialization succeeded");
info("Verifying storage");
verifyStorage(setup.packages, "afterInit");
// TODO: Remove this block once temporary storage initialization is able to
// ignore unknown directories.
getRelativeFile("storage/default/invalid+++example.com").remove(false);
try {
getRelativeFile("storage/temporary/invalid+++example.com").remove(false);
} catch (ex) {}
info("Checking origin directories");
for (const origin of setup.origins) {
let originDir = getRelativeFile(origin.oldPath);
let exists = originDir.exists();
ok(!exists, "Origin directory doesn't exist");
if (origin.newPath) {
originDir = getRelativeFile(origin.newPath);
exists = originDir.exists();
ok(exists, "Origin directory does exist");
let idbDir = originDir.clone();
idbDir.append("idb");
exists = idbDir.exists();
ok(exists, "idb directory does exist");
let metadataFile = originDir.clone();
metadataFile.append(metadataFileName);
exists = metadataFile.exists();
ok(exists, "Metadata file does exist");
}
}
info("Initializing temporary storage");
request = initTemporaryStorage(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_OK, "Initialization succeeded");
info("Initializing origins");
for (const origin of setup.origins) {
if (origin.newPath) {
info("Initializing origin");
let principal = getPrincipal(origin.url);
request = initTemporaryOrigin(
origin.persistence,
principal,
continueToNextStepSync
);
yield undefined;
ok(request.resultCode == NS_OK, "Initialization succeeded");
ok(!request.result, "Origin directory wasn't created");
}
}
}
finishTest();
}
|