Skip to content

Commit 9c8557b

Browse files
Garima Chadhachromium-wpt-export-bot
authored andcommitted
IDB WPTs: Extend idbobjectstore-exception related tests to workers
The update modifies idbobjectstore-exception related WPTs to run not only in window environments but also on dedicated, service, and shared workers. Change-Id: I05fbe6505699b7132501a934dfac9cfb814404c2 Bug: 41455766 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6200286 Auto-Submit: Garima Chadha <[email protected]> Reviewed-by: Steve Becker <[email protected]> Commit-Queue: Steve Becker <[email protected]> Reviewed-by: Rahul Singh <[email protected]> Cr-Commit-Position: refs/heads/main@{#1413300}
1 parent e6846ed commit 9c8557b

10 files changed

+354
-327
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// META: global=window,worker
2+
// META: title=IndexedDB: IDBObjectStore add()/put() Exception Ordering
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-put
6+
// Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-add
7+
8+
'use strict';
9+
10+
['put', 'add'].forEach(method => {
11+
indexeddb_test(
12+
(t, db) => {
13+
const store = db.createObjectStore('s');
14+
const store2 = db.createObjectStore('s2');
15+
16+
db.deleteObjectStore('s2');
17+
18+
setTimeout(
19+
t.step_func(() => {
20+
assert_throws_dom(
21+
'InvalidStateError',
22+
() => {
23+
store2[method]('key', 'value');
24+
},
25+
'"has been deleted" check (InvalidStateError) should precede ' +
26+
'"not active" check (TransactionInactiveError)');
27+
t.done();
28+
}),
29+
0);
30+
},
31+
(t, db) => {},
32+
`IDBObjectStore.${method} exception order: ` +
33+
'InvalidStateError vs. TransactionInactiveError');
34+
35+
indexeddb_test(
36+
(t, db) => {
37+
const store = db.createObjectStore('s');
38+
},
39+
(t, db) => {
40+
const tx = db.transaction('s', 'readonly');
41+
const store = tx.objectStore('s');
42+
43+
setTimeout(
44+
t.step_func(() => {
45+
assert_throws_dom(
46+
'TransactionInactiveError',
47+
() => {
48+
store[method]('key', 'value');
49+
},
50+
'"not active" check (TransactionInactiveError) should precede ' +
51+
'"read only" check (ReadOnlyError)');
52+
t.done();
53+
}),
54+
0);
55+
},
56+
57+
`IDBObjectStore.${method} exception order: ` +
58+
'TransactionInactiveError vs. ReadOnlyError');
59+
60+
indexeddb_test(
61+
(t, db) => {
62+
const store = db.createObjectStore('s');
63+
},
64+
(t, db) => {
65+
const tx = db.transaction('s', 'readonly');
66+
const store = tx.objectStore('s');
67+
68+
assert_throws_dom(
69+
'ReadOnlyError',
70+
() => {
71+
store[method]({}, 'value');
72+
},
73+
'"read only" check (ReadOnlyError) should precede ' +
74+
'key/data check (DataError)');
75+
76+
t.done();
77+
},
78+
79+
`IDBObjectStore.${method} exception order: ` +
80+
'ReadOnlyError vs. DataError');
81+
});

IndexedDB/idbobjectstore-add-put-exception-order.html

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// META: global=window,worker
2+
// META: title=IndexedDB: IDBObjectStore clear() Exception Ordering
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-clear
6+
7+
'use strict';
8+
9+
indexeddb_test(
10+
(t, db) => {
11+
const store = db.createObjectStore('s');
12+
const store2 = db.createObjectStore('s2');
13+
14+
db.deleteObjectStore('s2');
15+
16+
setTimeout(
17+
t.step_func(() => {
18+
assert_throws_dom(
19+
'InvalidStateError',
20+
() => {
21+
store2.clear();
22+
},
23+
'"has been deleted" check (InvalidStateError) should precede ' +
24+
'"not active" check (TransactionInactiveError)');
25+
t.done();
26+
}),
27+
0);
28+
},
29+
(t, db) => {},
30+
'IDBObjectStore.clear exception order: ' +
31+
'InvalidStateError vs. TransactionInactiveError');
32+
33+
indexeddb_test(
34+
(t, db) => {
35+
const store = db.createObjectStore('s');
36+
},
37+
(t, db) => {
38+
const tx = db.transaction('s', 'readonly');
39+
const store = tx.objectStore('s');
40+
41+
setTimeout(
42+
t.step_func(() => {
43+
assert_throws_dom(
44+
'TransactionInactiveError',
45+
() => {
46+
store.clear();
47+
},
48+
'"not active" check (TransactionInactiveError) should precede ' +
49+
'"read only" check (ReadOnlyError)');
50+
t.done();
51+
}),
52+
0);
53+
},
54+
55+
'IDBObjectStore.clear exception order: ' +
56+
'TransactionInactiveError vs. ReadOnlyError');

IndexedDB/idbobjectstore-clear-exception-order.html

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// META: global=window,worker
2+
// META: title=IndexedDB: IDBObjectStore delete() Exception Ordering
3+
// META: script=resources/support.js
4+
5+
// Spec: https://w3c.github.io/IndexedDB/#dom-idbobjectstore-delete
6+
7+
'use strict';
8+
9+
indexeddb_test(
10+
(t, db) => {
11+
const store = db.createObjectStore('s');
12+
const store2 = db.createObjectStore('s2');
13+
14+
db.deleteObjectStore('s2');
15+
16+
setTimeout(
17+
t.step_func(() => {
18+
assert_throws_dom(
19+
'InvalidStateError',
20+
() => {
21+
store2.delete('key');
22+
},
23+
'"has been deleted" check (InvalidStateError) should precede ' +
24+
'"not active" check (TransactionInactiveError)');
25+
t.done();
26+
}),
27+
0);
28+
},
29+
(t, db) => {},
30+
'IDBObjectStore.delete exception order: ' +
31+
'InvalidStateError vs. TransactionInactiveError');
32+
33+
indexeddb_test(
34+
(t, db) => {
35+
const store = db.createObjectStore('s');
36+
},
37+
(t, db) => {
38+
const tx = db.transaction('s', 'readonly');
39+
const store = tx.objectStore('s');
40+
41+
setTimeout(
42+
t.step_func(() => {
43+
assert_throws_dom(
44+
'TransactionInactiveError',
45+
() => {
46+
store.delete('key');
47+
},
48+
'"not active" check (TransactionInactiveError) should precede ' +
49+
'"read only" check (ReadOnlyError)');
50+
t.done();
51+
}),
52+
0);
53+
},
54+
'IDBObjectStore.delete exception order: ' +
55+
'TransactionInactiveError vs. ReadOnlyError');
56+
57+
indexeddb_test(
58+
(t, db) => {
59+
const store = db.createObjectStore('s');
60+
},
61+
(t, db) => {
62+
const tx = db.transaction('s', 'readonly');
63+
const store = tx.objectStore('s');
64+
65+
assert_throws_dom(
66+
'ReadOnlyError',
67+
() => {
68+
store.delete({});
69+
},
70+
'"read only" check (ReadOnlyError) should precede ' +
71+
'key/data check (DataError)');
72+
73+
t.done();
74+
},
75+
'IDBObjectStore.delete exception order: ' +
76+
'ReadOnlyError vs. DataError');

0 commit comments

Comments
 (0)