OLD | NEW |
1 Test IndexedDB's transaction and objectStore calls | 1 Test IndexedDB's transaction and objectStore calls |
2 | 2 |
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". | 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
". |
4 | 4 |
5 | 5 |
6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; | 6 indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.
msIndexedDB || self.OIndexedDB; |
7 | 7 |
8 dbname = "transaction-and-objectstore-calls.html" | 8 dbname = "transaction-and-objectstore-calls.html" |
9 indexedDB.deleteDatabase(dbname) | 9 indexedDB.deleteDatabase(dbname) |
10 indexedDB.open(dbname) | 10 indexedDB.open(dbname) |
11 db.createObjectStore('a') | 11 db.createObjectStore('a') |
12 db.createObjectStore('b') | 12 db.createObjectStore('b') |
13 db.createObjectStore('store').createIndex('index', 'some_path') | 13 db.createObjectStore('store').createIndex('index', 'some_path') |
14 | 14 |
15 trans = db.transaction(['a']) | 15 trans = db.transaction(['a']) |
16 trans.objectStore('a') | 16 trans.objectStore('a') |
17 Expecting exception from trans.objectStore('b') | 17 Expecting exception from trans.objectStore('b') |
18 PASS Exception was thrown. | 18 PASS Exception was thrown. |
19 PASS code is DOMException.NOT_FOUND_ERR | 19 PASS code is DOMException.NOT_FOUND_ERR |
20 PASS ename is 'NotFoundError' | 20 PASS ename is 'NotFoundError' |
21 Exception message: The specified object store was not found. | 21 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
22 Expecting exception from trans.objectStore('x') | 22 Expecting exception from trans.objectStore('x') |
23 PASS Exception was thrown. | 23 PASS Exception was thrown. |
24 PASS code is DOMException.NOT_FOUND_ERR | 24 PASS code is DOMException.NOT_FOUND_ERR |
25 PASS ename is 'NotFoundError' | 25 PASS ename is 'NotFoundError' |
26 Exception message: The specified object store was not found. | 26 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
27 | 27 |
28 trans = db.transaction(['a']) | 28 trans = db.transaction(['a']) |
29 trans.objectStore('a') | 29 trans.objectStore('a') |
30 Expecting exception from trans.objectStore('b') | 30 Expecting exception from trans.objectStore('b') |
31 PASS Exception was thrown. | 31 PASS Exception was thrown. |
32 PASS code is DOMException.NOT_FOUND_ERR | 32 PASS code is DOMException.NOT_FOUND_ERR |
33 PASS ename is 'NotFoundError' | 33 PASS ename is 'NotFoundError' |
34 Exception message: The specified object store was not found. | 34 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
35 Expecting exception from trans.objectStore('x') | 35 Expecting exception from trans.objectStore('x') |
36 PASS Exception was thrown. | 36 PASS Exception was thrown. |
37 PASS code is DOMException.NOT_FOUND_ERR | 37 PASS code is DOMException.NOT_FOUND_ERR |
38 PASS ename is 'NotFoundError' | 38 PASS ename is 'NotFoundError' |
39 Exception message: The specified object store was not found. | 39 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
40 | 40 |
41 trans = db.transaction(['b']) | 41 trans = db.transaction(['b']) |
42 trans.objectStore('b') | 42 trans.objectStore('b') |
43 Expecting exception from trans.objectStore('a') | 43 Expecting exception from trans.objectStore('a') |
44 PASS Exception was thrown. | 44 PASS Exception was thrown. |
45 PASS code is DOMException.NOT_FOUND_ERR | 45 PASS code is DOMException.NOT_FOUND_ERR |
46 PASS ename is 'NotFoundError' | 46 PASS ename is 'NotFoundError' |
47 Exception message: The specified object store was not found. | 47 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
48 Expecting exception from trans.objectStore('x') | 48 Expecting exception from trans.objectStore('x') |
49 PASS Exception was thrown. | 49 PASS Exception was thrown. |
50 PASS code is DOMException.NOT_FOUND_ERR | 50 PASS code is DOMException.NOT_FOUND_ERR |
51 PASS ename is 'NotFoundError' | 51 PASS ename is 'NotFoundError' |
52 Exception message: The specified object store was not found. | 52 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
53 | 53 |
54 trans = db.transaction(['a', 'b']) | 54 trans = db.transaction(['a', 'b']) |
55 trans.objectStore('a') | 55 trans.objectStore('a') |
56 trans.objectStore('b') | 56 trans.objectStore('b') |
57 Expecting exception from trans.objectStore('x') | 57 Expecting exception from trans.objectStore('x') |
58 PASS Exception was thrown. | 58 PASS Exception was thrown. |
59 PASS code is DOMException.NOT_FOUND_ERR | 59 PASS code is DOMException.NOT_FOUND_ERR |
60 PASS ename is 'NotFoundError' | 60 PASS ename is 'NotFoundError' |
61 Exception message: The specified object store was not found. | 61 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
62 | 62 |
63 trans = db.transaction(['b', 'a']) | 63 trans = db.transaction(['b', 'a']) |
64 trans.objectStore('a') | 64 trans.objectStore('a') |
65 trans.objectStore('b') | 65 trans.objectStore('b') |
66 Expecting exception from trans.objectStore('x') | 66 Expecting exception from trans.objectStore('x') |
67 PASS Exception was thrown. | 67 PASS Exception was thrown. |
68 PASS code is DOMException.NOT_FOUND_ERR | 68 PASS code is DOMException.NOT_FOUND_ERR |
69 PASS ename is 'NotFoundError' | 69 PASS ename is 'NotFoundError' |
70 Exception message: The specified object store was not found. | 70 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
71 | 71 |
72 Passing a string as the first argument is a shortcut for just one object store: | 72 Passing a string as the first argument is a shortcut for just one object store: |
73 trans = db.transaction('a') | 73 trans = db.transaction('a') |
74 trans.objectStore('a') | 74 trans.objectStore('a') |
75 Expecting exception from trans.objectStore('b') | 75 Expecting exception from trans.objectStore('b') |
76 PASS Exception was thrown. | 76 PASS Exception was thrown. |
77 PASS code is DOMException.NOT_FOUND_ERR | 77 PASS code is DOMException.NOT_FOUND_ERR |
78 PASS ename is 'NotFoundError' | 78 PASS ename is 'NotFoundError' |
79 Exception message: The specified object store was not found. | 79 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
80 Expecting exception from trans.objectStore('x') | 80 Expecting exception from trans.objectStore('x') |
81 PASS Exception was thrown. | 81 PASS Exception was thrown. |
82 PASS code is DOMException.NOT_FOUND_ERR | 82 PASS code is DOMException.NOT_FOUND_ERR |
83 PASS ename is 'NotFoundError' | 83 PASS ename is 'NotFoundError' |
84 Exception message: The specified object store was not found. | 84 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The spec
ified object store was not found. |
85 | 85 |
86 PASS trans = db.transaction() threw exception TypeError: Failed to execute 'tran
saction' on 'IDBDatabase': 1 argument required, but only 0 present.. | 86 PASS trans = db.transaction() threw exception TypeError: Failed to execute 'tran
saction' on 'IDBDatabase': 1 argument required, but only 0 present.. |
87 | 87 |
88 Expecting exception from db.transaction(['x']) | 88 Expecting exception from db.transaction(['x']) |
89 PASS Exception was thrown. | 89 PASS Exception was thrown. |
90 PASS code is DOMException.NOT_FOUND_ERR | 90 PASS code is DOMException.NOT_FOUND_ERR |
91 PASS ename is 'NotFoundError' | 91 PASS ename is 'NotFoundError' |
92 Exception message: One of the specified object stores was not found. | 92 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
93 Expecting exception from db.transaction(['x']) | 93 Expecting exception from db.transaction(['x']) |
94 PASS Exception was thrown. | 94 PASS Exception was thrown. |
95 PASS code is DOMException.NOT_FOUND_ERR | 95 PASS code is DOMException.NOT_FOUND_ERR |
96 PASS ename is 'NotFoundError' | 96 PASS ename is 'NotFoundError' |
97 Exception message: One of the specified object stores was not found. | 97 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
98 Expecting exception from db.transaction(['a', 'x']) | 98 Expecting exception from db.transaction(['a', 'x']) |
99 PASS Exception was thrown. | 99 PASS Exception was thrown. |
100 PASS code is DOMException.NOT_FOUND_ERR | 100 PASS code is DOMException.NOT_FOUND_ERR |
101 PASS ename is 'NotFoundError' | 101 PASS ename is 'NotFoundError' |
102 Exception message: One of the specified object stores was not found. | 102 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
103 Expecting exception from db.transaction(['x', 'x']) | 103 Expecting exception from db.transaction(['x', 'x']) |
104 PASS Exception was thrown. | 104 PASS Exception was thrown. |
105 PASS code is DOMException.NOT_FOUND_ERR | 105 PASS code is DOMException.NOT_FOUND_ERR |
106 PASS ename is 'NotFoundError' | 106 PASS ename is 'NotFoundError' |
107 Exception message: One of the specified object stores was not found. | 107 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
108 Expecting exception from db.transaction(['a', 'x', 'b']) | 108 Expecting exception from db.transaction(['a', 'x', 'b']) |
109 PASS Exception was thrown. | 109 PASS Exception was thrown. |
110 PASS code is DOMException.NOT_FOUND_ERR | 110 PASS code is DOMException.NOT_FOUND_ERR |
111 PASS ename is 'NotFoundError' | 111 PASS ename is 'NotFoundError' |
112 Exception message: One of the specified object stores was not found. | 112 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
113 | 113 |
114 Exception thrown when no stores specified: | 114 Exception thrown when no stores specified: |
115 Expecting exception from db.transaction([]) | 115 Expecting exception from db.transaction([]) |
116 PASS Exception was thrown. | 116 PASS Exception was thrown. |
117 PASS code is DOMException.INVALID_ACCESS_ERR | 117 PASS code is DOMException.INVALID_ACCESS_ERR |
118 Exception message: The storeNames parameter was empty. | 118 Exception message: Failed to execute 'transaction' on 'IDBDatabase': The storeNa
mes parameter was empty. |
119 | 119 |
120 {} coerces to a string - so no match, but not a type error: | 120 {} coerces to a string - so no match, but not a type error: |
121 Expecting exception from db.transaction({}) | 121 Expecting exception from db.transaction({}) |
122 PASS Exception was thrown. | 122 PASS Exception was thrown. |
123 PASS code is DOMException.NOT_FOUND_ERR | 123 PASS code is DOMException.NOT_FOUND_ERR |
124 PASS ename is 'NotFoundError' | 124 PASS ename is 'NotFoundError' |
125 Exception message: One of the specified object stores was not found. | 125 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
126 Expecting exception from db.transaction({mode:0}) | 126 Expecting exception from db.transaction({mode:0}) |
127 PASS Exception was thrown. | 127 PASS Exception was thrown. |
128 PASS code is DOMException.NOT_FOUND_ERR | 128 PASS code is DOMException.NOT_FOUND_ERR |
129 PASS ename is 'NotFoundError' | 129 PASS ename is 'NotFoundError' |
130 Exception message: One of the specified object stores was not found. | 130 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
131 | 131 |
132 Overriding the default string coercion makes these work: | 132 Overriding the default string coercion makes these work: |
133 db.transaction({toString:function(){return 'a';}}) | 133 db.transaction({toString:function(){return 'a';}}) |
134 db.transaction([{toString:function(){return 'a';}}]) | 134 db.transaction([{toString:function(){return 'a';}}]) |
135 ... but you still need to specify a real store: | 135 ... but you still need to specify a real store: |
136 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) | 136 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) |
137 PASS Exception was thrown. | 137 PASS Exception was thrown. |
138 PASS code is DOMException.NOT_FOUND_ERR | 138 PASS code is DOMException.NOT_FOUND_ERR |
139 PASS ename is 'NotFoundError' | 139 PASS ename is 'NotFoundError' |
140 Exception message: One of the specified object stores was not found. | 140 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
141 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) | 141 Expecting exception from db.transaction([{toString:function(){return 'x';}}]) |
142 PASS Exception was thrown. | 142 PASS Exception was thrown. |
143 PASS code is DOMException.NOT_FOUND_ERR | 143 PASS code is DOMException.NOT_FOUND_ERR |
144 PASS ename is 'NotFoundError' | 144 PASS ename is 'NotFoundError' |
145 Exception message: One of the specified object stores was not found. | 145 Exception message: Failed to execute 'transaction' on 'IDBDatabase': One of the
specified object stores was not found. |
146 | 146 |
147 trans = db.transaction(['store']) | 147 trans = db.transaction(['store']) |
148 PASS trans is non-null. | 148 PASS trans is non-null. |
149 store = trans.objectStore('store') | 149 store = trans.objectStore('store') |
150 PASS store is non-null. | 150 PASS store is non-null. |
151 store.get('some_key') | 151 store.get('some_key') |
152 transaction complete, ensuring methods fail | 152 transaction complete, ensuring methods fail |
153 PASS trans is non-null. | 153 PASS trans is non-null. |
154 PASS store is non-null. | 154 PASS store is non-null. |
155 Expecting exception from trans.objectStore('store') | 155 Expecting exception from trans.objectStore('store') |
156 PASS Exception was thrown. | 156 PASS Exception was thrown. |
157 PASS code is DOMException.INVALID_STATE_ERR | 157 PASS code is DOMException.INVALID_STATE_ERR |
158 PASS ename is 'InvalidStateError' | 158 PASS ename is 'InvalidStateError' |
159 Exception message: The transaction has finished. | 159 Exception message: Failed to execute 'objectStore' on 'IDBTransaction': The tran
saction has finished. |
160 Expecting exception from store.index('index') | 160 Expecting exception from store.index('index') |
161 PASS Exception was thrown. | 161 PASS Exception was thrown. |
162 PASS code is DOMException.INVALID_STATE_ERR | 162 PASS code is DOMException.INVALID_STATE_ERR |
163 PASS ename is 'InvalidStateError' | 163 PASS ename is 'InvalidStateError' |
164 Exception message: The transaction has finished. | 164 Exception message: Failed to execute 'index' on 'IDBObjectStore': The transactio
n has finished. |
165 PASS successfullyParsed is true | 165 PASS successfullyParsed is true |
166 | 166 |
167 TEST COMPLETE | 167 TEST COMPLETE |
168 | 168 |
OLD | NEW |