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
|
'use strict';
directory_test(async (t, root_dir) => {
const handles = await create_file_system_handles(t, root_dir);
const db = await createDatabase(t, db => {
const store = db.createObjectStore('store');
});
const value = handles;
const tx = db.transaction('store', 'readwrite');
const store = tx.objectStore('store');
await promiseForRequest(t, store.put(value, 'key'));
const result = await promiseForRequest(t, store.get('key'));
await promiseForTransaction(t, tx);
assert_true(Array.isArray(result), 'Result should be an array');
assert_equals(result.length, value.length);
await assert_equals_cloned_handles(result, value);
}, 'Store handle in IndexedDB and read from pending transaction.');
directory_test(async (t, root_dir) => {
const handles = await create_file_system_handles(t, root_dir);
const db = await createDatabase(t, db => {
const store = db.createObjectStore('store');
});
const value = handles;
let tx = db.transaction('store', 'readwrite');
let store = tx.objectStore('store');
await promiseForRequest(t, store.put(value, 'key'));
await promiseForTransaction(t, tx);
tx = db.transaction('store', 'readonly');
store = tx.objectStore('store');
const result = await promiseForRequest(t, store.get('key'));
await promiseForTransaction(t, tx);
assert_true(Array.isArray(result), 'Result should be an array');
assert_equals(result.length, value.length);
await assert_equals_cloned_handles(result, value);
}, 'Store handle in IndexedDB and read from new transaction.');
directory_test(async (t, root_dir) => {
const handles = await create_file_system_handles(t, root_dir);
const db = await createDatabase(t, db => {
const store = db.createObjectStore('store');
});
const value = {handles, blob: new Blob(["foobar"])};
let tx = db.transaction('store', 'readwrite');
let store = tx.objectStore('store');
await promiseForRequest(t, store.put(value, 'key'));
await promiseForTransaction(t, tx);
tx = db.transaction('store', 'readonly');
store = tx.objectStore('store');
const result = await promiseForRequest(t, store.get('key'));
await promiseForTransaction(t, tx);
assert_true(Array.isArray(result.handles), 'Result should be an array');
assert_equals(result.handles.length, value.handles.length);
await assert_equals_cloned_handles(result.handles, value.handles);
assert_equals(await result.blob.text(), await value.blob.text());
}, 'Store handles and blobs in IndexedDB.');
directory_test(async (t, root_dir) => {
const handles = await create_file_system_handles(t, root_dir);
const db = await createDatabase(t, db => {
const store = db.createObjectStore('store');
});
const value = handles;
let tx = db.transaction('store', 'readwrite');
let store = tx.objectStore('store');
await promiseForRequest(t, store.put(value, 'key'));
await promiseForTransaction(t, tx);
tx = db.transaction('store', 'readonly');
store = tx.objectStore('store');
let cursor_request = store.openCursor();
await requestWatcher(t, cursor_request).wait_for('success');
const result = cursor_request.result.value;
await promiseForTransaction(t, tx);
assert_true(Array.isArray(result), 'Result should be an array');
assert_equals(result.length, value.length);
await assert_equals_cloned_handles(result, value);
}, 'Store handle in IndexedDB and read using a cursor.');
directory_test(async (t, root_dir) => {
const handles = await create_file_system_handles(t, root_dir);
const db = await createDatabase(t, db => {
const store = db.createObjectStore('store', {keyPath: 'key'});
});
const value = handles;
let tx = db.transaction('store', 'readwrite');
let store = tx.objectStore('store');
await promiseForRequest(t, store.put({key: 'key', value}));
await promiseForTransaction(t, tx);
tx = db.transaction('store', 'readonly');
store = tx.objectStore('store');
const result = await promiseForRequest(t, store.get('key'));
await promiseForTransaction(t, tx);
assert_true(Array.isArray(result.value), 'Result should be an array');
assert_equals(result.value.length, value.length);
await assert_equals_cloned_handles(result.value, value);
}, 'Store handle in IndexedDB using inline keys.');
|