blob: 0da4e8584d8062067a672ae1a2e8852529077990 (
plain)
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
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* This test verifies that group and origin strings for URIs with special
* characters are consistent between calling
* EnsureQuotaForOringin/EnsureOriginIsInitailized and GetQuotaObject in
* PrepareDatastoreOp, so writing to local storage won't cause a crash because
* of a null quota object. See bug 1516333.
*/
add_task(async function testSteps() {
/**
* The edge cases are specified in this array of origins. Each edge case must
* contain two properties uri and path (origin directory path relative to the
* profile directory).
*/
const origins = [
{
uri: "file:///test'.html",
path: "storage/default/file++++test'.html",
},
{
uri: "file:///test>.html",
path: "storage/default/file++++test%3E.html",
},
];
info("Setting prefs");
Services.prefs.setBoolPref(
"dom.storage.enable_unsupported_legacy_implementation",
false
);
for (let origin of origins) {
const principal = getPrincipal(origin.uri);
let originDir = getRelativeFile(origin.path);
info("Checking the origin directory existence");
ok(
!originDir.exists(),
`The origin directory ${origin.path} should not exists`
);
info("Getting storage");
let storage = getLocalStorage(principal);
info("Adding item");
storage.setItem("foo", "bar");
info("Resetting origin");
// This forces any pending changes to be flushed to disk (including origin
// directory creation).
let request = resetOrigin(principal);
await requestFinished(request);
info("Checking the origin directory existence");
ok(originDir.exists(), `The origin directory ${origin.path} should exist`);
}
});
|