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
|
<!DOCTYPE html>
<title>IndexedDB: Exception Order of IDBObjectStore.createIndex()</title>
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
<link rel="help" href="http://w3c.github.io/IndexedDB/#dom-idbobjectstore-createindex">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/support.js"></script>
<script>
indexeddb_test(
function(t, db, txn) {
var store = db.createObjectStore("s");
},
function(t, db) {
var txn = db.transaction("s", "readonly", {durability: 'relaxed'});
var store = txn.objectStore("s");
txn.oncomplete = function() {
assert_throws_dom("InvalidStateError", function() {
store.createIndex("index", "foo");
}, "Mode check should precede state check of the transaction");
t.done();
};
},
"InvalidStateError(Incorrect mode) vs. TransactionInactiveError"
);
var gDeletedObjectStore;
indexeddb_test(
function(t, db, txn) {
gDeletedObjectStore = db.createObjectStore("s");
db.deleteObjectStore("s");
txn.oncomplete = function() {
assert_throws_dom("InvalidStateError", function() {
gDeletedObjectStore.createIndex("index", "foo");
}, "Deletion check should precede transaction-state check");
t.done();
};
},
null,
"InvalidStateError(Deleted ObjectStore) vs. TransactionInactiveError"
);
indexeddb_test(
function(t, db, txn) {
var store = db.createObjectStore("s");
store.createIndex("index", "foo");
txn.oncomplete = function() {
assert_throws_dom("TransactionInactiveError", function() {
store.createIndex("index", "foo");
}, "Transaction-state check should precede index name check");
t.done();
};
},
null,
"TransactionInactiveError vs. ConstraintError"
);
indexeddb_test(
function(t, db) {
var store = db.createObjectStore("s");
store.createIndex("index", "foo");
assert_throws_dom("ConstraintError", function() {
store.createIndex("index", "invalid key path");
}, "Index name check should precede syntax check of the key path");
assert_throws_dom("ConstraintError", function() {
store.createIndex("index",
["invalid key path 1", "invalid key path 2"]);
}, "Index name check should precede syntax check of the key path");
t.done();
},
null,
"ConstraintError vs. SyntaxError"
);
indexeddb_test(
function(t, db) {
var store = db.createObjectStore("s");
assert_throws_dom("SyntaxError", function() {
store.createIndex("index",
["invalid key path 1", "invalid key path 2"],
{ multiEntry: true });
}, "Syntax check should precede multiEntry check of the key path");
t.done();
},
null,
"SyntaxError vs. InvalidAccessError"
);
</script>
|