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
|
// META: global=window,dedicatedworker,sharedworker,serviceworker
// META: script=resources/support-promises.js
// META: script=resources/reading-autoincrement-common.js
promise_test(async testCase => {
const database = await setupAutoincrementDatabase(testCase);
const transaction = database.transaction(['store'], 'readonly');
const store = transaction.objectStore('store');
const index = store.index('by_id');
const request = index.getAll();
const result = await promiseForRequest(testCase, request);
assert_equals(result.length, 32);
for (let i = 1; i <= 32; ++i) {
assert_equals(result[i - 1].id, i, 'Autoincrement key');
assert_equals(result[i - 1].name, nameForId(i), 'String property');
}
database.close();
}, 'IDBIndex.getAll() for an index on the autoincrement key');
promise_test(async testCase => {
const database = await setupAutoincrementDatabase(testCase);
const transaction = database.transaction(['store'], 'readonly');
const store = transaction.objectStore('store');
const index = store.index('by_id');
const request = index.getAllKeys();
const result = await promiseForRequest(testCase, request);
assert_equals(result.length, 32);
for (let i = 1; i <= 32; ++i)
assert_equals(result[i - 1], i, 'Autoincrement key');
database.close();
}, 'IDBIndex.getAllKeys() for an index on the autoincrement key');
promise_test(async testCase => {
const database = await setupAutoincrementDatabase(testCase);
const transaction = database.transaction(['store'], 'readonly');
const store = transaction.objectStore('store');
const index = store.index('by_id');
for (let i = 1; i <= 32; ++i) {
const request = index.get(i);
const result = await promiseForRequest(testCase, request);
assert_equals(result.id, i, 'autoincrement key');
assert_equals(result.name, nameForId(i), 'string property');
}
database.close();
}, 'IDBIndex.get() for an index on the autoincrement key');
promise_test(async testCase => {
const database = await setupAutoincrementDatabase(testCase);
const stringSortedIds = idsSortedByStringCompare();
const transaction = database.transaction(['store'], 'readonly');
const store = transaction.objectStore('store');
const index = store.index('by_name');
const request = index.getAll();
const result = await promiseForRequest(testCase, request);
assert_equals(result.length, 32);
for (let i = 1; i <= 32; ++i) {
assert_equals(result[i - 1].id, stringSortedIds[i - 1],
'autoincrement key');
assert_equals(result[i - 1].name, nameForId(stringSortedIds[i - 1]),
'string property');
}
database.close();
}, 'IDBIndex.getAll() for an index not covering the autoincrement key');
promise_test(async testCase => {
const database = await setupAutoincrementDatabase(testCase);
const stringSortedIds = idsSortedByStringCompare();
const transaction = database.transaction(['store'], 'readonly');
const store = transaction.objectStore('store');
const index = store.index('by_name');
const request = index.getAllKeys();
const result = await promiseForRequest(testCase, request);
assert_equals(result.length, 32);
for (let i = 1; i <= 32; ++i)
assert_equals(result[i - 1], stringSortedIds[i - 1], 'String property');
database.close();
}, 'IDBIndex.getAllKeys() returns correct result for an index not covering ' +
'the autoincrement key');
promise_test(async testCase => {
const database = await setupAutoincrementDatabase(testCase);
const transaction = database.transaction(['store'], 'readonly');
const store = transaction.objectStore('store');
const index = store.index('by_name');
for (let i = 1; i <= 32; ++i) {
const request = index.get(nameForId(i));
const result = await promiseForRequest(testCase, request);
assert_equals(result.id, i, 'Autoincrement key');
assert_equals(result.name, nameForId(i), 'String property');
}
database.close();
}, 'IDBIndex.get() for an index not covering the autoincrement key');
|