OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 window.indexedDB = window.indexedDB || window.webkitIndexedDB; | 5 window.indexedDB = window.indexedDB || window.webkitIndexedDB; |
6 window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction; | 6 window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction; |
7 window.IDBDatabaseException = window.IDBDatabaseException || | |
8 window.webkitIDBDatabaseException; | |
9 | 7 |
10 function test() { | 8 function test() { |
11 indexedDBTest(prepareDatabase, testValidKeys); | 9 indexedDBTest(prepareDatabase, testValidKeys); |
12 } | 10 } |
13 | 11 |
14 function prepareDatabase() | 12 function prepareDatabase() |
15 { | 13 { |
16 db = event.target.result; | 14 db = event.target.result; |
17 db.createObjectStore('store'); | 15 db.createObjectStore('store'); |
18 } | 16 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 invalid_keys.forEach( | 134 invalid_keys.forEach( |
137 function(key) { | 135 function(key) { |
138 try { | 136 try { |
139 key = eval("(" + key + ")"); | 137 key = eval("(" + key + ")"); |
140 var putreq = store.put('value', key); | 138 var putreq = store.put('value', key); |
141 putreq.onerror = unexpectedErrorCallback; | 139 putreq.onerror = unexpectedErrorCallback; |
142 putreq.onsuccess = unexpectedSuccessCallback; | 140 putreq.onsuccess = unexpectedSuccessCallback; |
143 return; | 141 return; |
144 } catch (e) { | 142 } catch (e) { |
145 window.ex = e; | 143 window.ex = e; |
146 shouldBe("ex.code", "IDBDatabaseException.DATA_ERR"); | 144 // TODO(jsbell): Uncomment when wkbug.com/102514 has landed/rolled. |
| 145 //shouldBe("ex.code", "0"); |
147 shouldBe("ex.name", "'DataError'"); | 146 shouldBe("ex.name", "'DataError'"); |
148 } | 147 } |
149 }); | 148 }); |
150 testKeyOrdering(); | 149 testKeyOrdering(); |
151 } | 150 } |
152 | 151 |
153 function testKeyOrdering() { | 152 function testKeyOrdering() { |
154 | 153 |
155 for (var i = 0; i < valid_keys.length - 1; ++i) { | 154 for (var i = 0; i < valid_keys.length - 1; ++i) { |
156 var key1 = valid_keys[i]; | 155 var key1 = valid_keys[i]; |
157 var key2 = valid_keys[i + 1]; | 156 var key2 = valid_keys[i + 1]; |
158 | 157 |
159 shouldBe("indexedDB.cmp(" + key1 + "," + key2 + ")", "-1"); | 158 shouldBe("indexedDB.cmp(" + key1 + "," + key2 + ")", "-1"); |
160 shouldBe("indexedDB.cmp(" + key2 + "," + key1 + ")", "1"); | 159 shouldBe("indexedDB.cmp(" + key2 + "," + key1 + ")", "1"); |
161 shouldBe("indexedDB.cmp(" + key1 + "," + key1 + ")", "0"); | 160 shouldBe("indexedDB.cmp(" + key1 + "," + key1 + ")", "0"); |
162 shouldBe("indexedDB.cmp(" + key2 + "," + key2 + ")", "0"); | 161 shouldBe("indexedDB.cmp(" + key2 + "," + key2 + ")", "0"); |
163 } | 162 } |
164 | 163 |
165 done(); | 164 done(); |
166 } | 165 } |
OLD | NEW |