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
|
/**
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
exported_symbols.testGetDirectoryDoesNotThrow = async function() {
await navigator.storage.getDirectory();
Assert.ok(true, "Should not have thrown");
};
exported_symbols.testGetDirectoryKindIsDirectory = async function() {
const root = await navigator.storage.getDirectory();
Assert.equal(root.kind, "directory");
};
exported_symbols.testDirectoryHandleStringConversion = async function() {
const root = await navigator.storage.getDirectory();
Assert.equal(
"" + root,
"[object FileSystemDirectoryHandle]",
"Is directoryHandle convertible to string?"
);
};
exported_symbols.testNewDirectoryHandleFromPrototype = async function() {
const root = await navigator.storage.getDirectory();
try {
Object.create(root.prototype);
Assert.ok(false, "Should have thrown");
} catch (ex) {
Assert.ok(true, "Should have thrown");
Assert.ok(ex instanceof TypeError, "Threw the right error type");
}
};
exported_symbols.testIsSameEntryRoot = async function() {
const root = await navigator.storage.getDirectory();
try {
await root.move(root);
Assert.ok(false, "root should not be movable");
} catch (ex) {
Assert.ok(true, "root isn't movable");
}
};
exported_symbols.testDirectoryHandleSupportsKeysIterator = async function() {
const root = await navigator.storage.getDirectory();
const it = await root.keys();
Assert.ok(!!it, "Does root support keys iterator?");
};
exported_symbols.testKeysIteratorNextIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const it = await root.keys();
Assert.ok(!!it, "Does root support keys iterator?");
const item = await it.next();
Assert.ok(!!item, "Should return an item");
};
exported_symbols.testDirectoryHandleSupportsValuesIterator = async function() {
const root = await navigator.storage.getDirectory();
const it = await root.values();
Assert.ok(!!it, "Does root support values iterator?");
};
exported_symbols.testValuesIteratorNextIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const it = await root.values();
Assert.ok(!!it, "Does root support values iterator?");
const item = await it.next();
Assert.ok(!!item, "Should return an item");
};
exported_symbols.testDirectoryHandleSupportsEntriesIterator = async function() {
const root = await navigator.storage.getDirectory();
const it = await root.entries();
Assert.ok(!!it, "Does root support entries iterator?");
};
exported_symbols.testEntriesIteratorNextIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const it = await root.entries();
Assert.ok(!!it, "Does root support entries iterator?");
const item = await it.next();
Assert.ok(!!item, "Should return an item");
};
exported_symbols.testGetFileHandleIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const allowCreate = { create: true };
const item = await root.getFileHandle("fileName", allowCreate);
Assert.ok(!!item, "Should return an item");
};
exported_symbols.testGetDirectoryHandleIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const allowCreate = { create: true };
const item = await root.getDirectoryHandle("dirName", allowCreate);
Assert.ok(!!item, "Should return an item");
};
exported_symbols.testRemoveEntryIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const removeOptions = { recursive: true };
await root.removeEntry("fileName", removeOptions);
await root.removeEntry("dirName", removeOptions);
try {
await root.removeEntry("doesNotExist", removeOptions);
Assert.ok(false, "Should have thrown");
} catch (ex) {
Assert.ok(true, "Should have thrown");
Assert.equal(
ex.message,
"Entry not found",
"Threw the right error message"
);
}
};
exported_symbols.testResolveIsCallable = async function() {
const root = await navigator.storage.getDirectory();
const allowCreate = { create: true };
const item = await root.getFileHandle("fileName", allowCreate);
let path = await root.resolve(item);
Assert.equal(path.length, 1);
Assert.equal(path[0], "fileName", "Resolve got the right path");
};
for (const [key, value] of Object.entries(exported_symbols)) {
Object.defineProperty(value, "name", {
value: key,
writable: false,
});
}
|