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
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* This test is mainly to verify
* MaybeUpgradeFromIndexedDBDirectoryToPersistentStorageDirectory method.
*/
function* testSteps() {
const origins = [
{
oldPath: "indexedDB/http+++www.mozilla.org",
newPath: "storage/default/http+++www.mozilla.org",
url: "http://www.mozilla.org",
persistence: "default",
},
{
oldPath: "indexedDB/1007+f+app+++system.gaiamobile.org",
},
{
oldPath: "indexedDB/1007+t+https+++developer.cdn.mozilla.net",
},
];
const packages = [
// Storage used prior FF 26 (indexedDB/ directory).
"indexedDBDirectory_profile",
"../indexedDBDirectory_shared",
];
info("Clearing");
clear(continueToNextStepSync);
yield undefined;
info("Verifying storage");
verifyStorage(packages, "beforeInstall");
info("Installing package");
installPackages(packages);
info("Verifying storage");
verifyStorage(packages, "afterInstall");
for (let origin of origins) {
let originDir = getRelativeFile(origin.oldPath);
let exists = originDir.exists();
ok(exists, "Origin directory does 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(packages, "afterInit");
// TODO: Remove this block once temporary storage initialization is able to
// ignore unknown directories.
getRelativeFile("storage/default/invalid+++example.com").remove(false);
info("Checking origin directories");
for (let origin of 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");
}
}
info("Initializing temporary storage");
request = initTemporaryStorage(continueToNextStepSync);
yield undefined;
ok(request.resultCode == NS_OK, "Initialization succeeded");
info("Initializing origins");
for (const origin of 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();
}
|