Changeset 105329 in webkit
- Timestamp:
- Jan 18, 2012 2:58:56 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r105327 r105329 1 2012-01-18 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Invalid keys yielded by key paths should raise exceptions, not error callbacks 4 https://bugs.webkit.org/show_bug.cgi?id=76075 5 6 Reviewed by Tony Chang. 7 8 * storage/indexeddb/mozilla/bad-keypath-expected.txt: 9 * storage/indexeddb/mozilla/bad-keypath.html: 10 * storage/indexeddb/objectstore-basics-expected.txt: 11 * storage/indexeddb/objectstore-basics.html: 12 1 13 2012-01-18 James Robinson <jamesr@chromium.org> 2 14 -
trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath-expected.txt
r85121 r105329 14 14 objectStore = db.createObjectStore('foo', { keyPath: 'keyPath' }); 15 15 request = objectStore.add({ keyPath: 'foo' }); 16 request = objectStore.add({}); 17 PASS event.target.errorCode is IDBDatabaseException.DATA_ERR 16 Expecting exception from request = objectStore.add({}); 17 PASS Exception was thrown. 18 PASS code is IDBDatabaseException.DATA_ERR 18 19 PASS successfullyParsed is true 19 20 -
trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath.html
r99258 r105329 55 55 function addFirstSuccess() 56 56 { 57 request = evalAndLog("request = objectStore.add({});"); 58 request.onsuccess = unexpectedSuccessCallback; 59 request.onerror = addSecondExpectedError; 60 } 61 62 function addSecondExpectedError() 63 { 64 shouldBe("event.target.errorCode", "IDBDatabaseException.DATA_ERR"); 57 evalAndExpectException("request = objectStore.add({});", "IDBDatabaseException.DATA_ERR"); 65 58 done(); 66 59 } -
trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt
r103100 r105329 136 136 PASS Exception was thrown. 137 137 PASS code is webkitIDBDatabaseException.DATA_ERR 138 139 testPreConditions(): 140 db.setVersion('precondition version') 141 storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key'}) 142 storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys') 143 storeWithIndex = db.createObjectStore('storeWithIndex') 144 index = storeWithIndex.createIndex('indexName', 'indexKey') 145 146 IDBObjectStore.put() 147 The object store uses in-line keys and the key parameter was provided. 148 Expecting exception from storeWithInLineKeys.put({key: 1}, 'key') 149 PASS Exception was thrown. 150 PASS code is webkitIDBDatabaseException.DATA_ERR 151 The object store uses out-of-line keys and has no key generator and the key parameter was not provided. 152 Expecting exception from storeWithOutOfLineKeys.put({}) 153 PASS Exception was thrown. 154 PASS code is webkitIDBDatabaseException.DATA_ERR 155 The object store uses in-line keys and the result of evaluating the object store's key path yields a value and that value is not a valid key. 156 Expecting exception from storeWithInLineKeys.put({key: null}) 157 PASS Exception was thrown. 158 PASS code is webkitIDBDatabaseException.DATA_ERR 159 The object store uses in-line keys but no key generator and the result of evaluating the object store's key path does not yield a value. 160 Expecting exception from storeWithInLineKeys.put({}) 161 PASS Exception was thrown. 162 PASS code is webkitIDBDatabaseException.DATA_ERR 163 The key parameter was provided but does not contain a valid key. 164 Expecting exception from storeWithOutOfLineKeys.put({}, null) 165 PASS Exception was thrown. 166 PASS code is webkitIDBDatabaseException.DATA_ERR 167 168 IDBObjectStore.add() 169 The object store uses in-line keys and the key parameter was provided. 170 Expecting exception from storeWithInLineKeys.add({key: 1}, 'key') 171 PASS Exception was thrown. 172 PASS code is webkitIDBDatabaseException.DATA_ERR 173 The object store uses out-of-line keys and has no key generator and the key parameter was not provided. 174 Expecting exception from storeWithOutOfLineKeys.add({}) 175 PASS Exception was thrown. 176 PASS code is webkitIDBDatabaseException.DATA_ERR 177 The object store uses in-line keys and the result of evaluating the object store's key path yields a value and that value is not a valid key. 178 Expecting exception from storeWithInLineKeys.add({key: null}) 179 PASS Exception was thrown. 180 PASS code is webkitIDBDatabaseException.DATA_ERR 181 The object store uses in-line keys but no key generator and the result of evaluating the object store's key path does not yield a value. 182 Expecting exception from storeWithInLineKeys.add({}) 183 PASS Exception was thrown. 184 PASS code is webkitIDBDatabaseException.DATA_ERR 185 The key parameter was provided but does not contain a valid key. 186 Expecting exception from storeWithOutOfLineKeys.add({}, null) 187 PASS Exception was thrown. 188 PASS code is webkitIDBDatabaseException.DATA_ERR 138 189 PASS successfullyParsed is true 139 190 -
trunk/LayoutTests/storage/indexeddb/objectstore-basics.html
r103100 r105329 287 287 evalAndExpectException("store.put(null, {})", "webkitIDBDatabaseException.DATA_ERR"); 288 288 289 done(); 290 } 289 testPreConditions(); 290 } 291 292 function testPreConditions() 293 { 294 debug(""); 295 debug("testPreConditions():"); 296 request = evalAndLog("db.setVersion('precondition version')"); 297 request.onerror = unexpectedErrorCallback; 298 request.onsuccess = function() { 299 storeWithInLineKeys = evalAndLog("storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key'})"); 300 storeWithOutOfLineKeys = evalAndLog("storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys')"); 301 storeWithIndex = evalAndLog("storeWithIndex = db.createObjectStore('storeWithIndex')"); 302 index = evalAndLog("index = storeWithIndex.createIndex('indexName', 'indexKey')"); 303 304 debug(""); 305 debug("IDBObjectStore.put()"); 306 debug("The object store uses in-line keys and the key parameter was provided."); 307 evalAndExpectException("storeWithInLineKeys.put({key: 1}, 'key')", "webkitIDBDatabaseException.DATA_ERR"); 308 309 debug("The object store uses out-of-line keys and has no key generator and the key parameter was not provided."); 310 evalAndExpectException("storeWithOutOfLineKeys.put({})", "webkitIDBDatabaseException.DATA_ERR"); 311 312 debug("The object store uses in-line keys and the result of evaluating the object store's key path yields a value and that value is not a valid key."); 313 evalAndExpectException("storeWithInLineKeys.put({key: null})", "webkitIDBDatabaseException.DATA_ERR"); 314 315 debug("The object store uses in-line keys but no key generator and the result of evaluating the object store's key path does not yield a value."); 316 evalAndExpectException("storeWithInLineKeys.put({})", "webkitIDBDatabaseException.DATA_ERR"); 317 318 debug("The key parameter was provided but does not contain a valid key."); 319 evalAndExpectException("storeWithOutOfLineKeys.put({}, null)", "webkitIDBDatabaseException.DATA_ERR"); 320 321 // FIXME: Add precondition checks for put() with index key paths that yield invalid keys. 322 // https://bugs.webkit.org/show_bug.cgi?id=76487 323 324 debug(""); 325 debug("IDBObjectStore.add()"); 326 debug("The object store uses in-line keys and the key parameter was provided."); 327 evalAndExpectException("storeWithInLineKeys.add({key: 1}, 'key')", "webkitIDBDatabaseException.DATA_ERR"); 328 329 debug("The object store uses out-of-line keys and has no key generator and the key parameter was not provided."); 330 evalAndExpectException("storeWithOutOfLineKeys.add({})", "webkitIDBDatabaseException.DATA_ERR"); 331 332 debug("The object store uses in-line keys and the result of evaluating the object store's key path yields a value and that value is not a valid key."); 333 evalAndExpectException("storeWithInLineKeys.add({key: null})", "webkitIDBDatabaseException.DATA_ERR"); 334 335 debug("The object store uses in-line keys but no key generator and the result of evaluating the object store's key path does not yield a value."); 336 evalAndExpectException("storeWithInLineKeys.add({})", "webkitIDBDatabaseException.DATA_ERR"); 337 338 debug("The key parameter was provided but does not contain a valid key."); 339 evalAndExpectException("storeWithOutOfLineKeys.add({}, null)", "webkitIDBDatabaseException.DATA_ERR"); 340 341 // FIXME: Add precondition checks for add() with index key paths that yield invalid keys. 342 // https://bugs.webkit.org/show_bug.cgi?id=76487 343 344 done(); 345 }; 346 } 347 348 291 349 292 350 test(); -
trunk/Source/WebCore/ChangeLog
r105328 r105329 1 2012-01-18 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Invalid keys yielded by key paths should raise exceptions, not error callbacks 4 https://bugs.webkit.org/show_bug.cgi?id=76075 5 6 Reviewed by Tony Chang. 7 8 Tests: storage/indexeddb/objectstore-basics.html 9 10 * storage/IDBObjectStoreBackendImpl.cpp: 11 (WebCore::IDBObjectStoreBackendImpl::put): 12 1 13 2012-01-18 Dana Jansens <danakj@chromium.org> 2 14 -
trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
r104771 r105329 139 139 const bool autoIncrement = objectStore->autoIncrement(); 140 140 const bool hasKeyPath = !objectStore->m_keyPath.isNull(); 141 if (!key && !autoIncrement && !hasKeyPath) { 142 ec = IDBDatabaseException::DATA_ERR; 143 return; 144 } 145 146 if (key && hasKeyPath && (putMode == AddOnly || putMode == AddOrUpdate)) { 147 ec = IDBDatabaseException::DATA_ERR; 148 return; 149 } 150 151 // FIXME: This should throw a SERIAL_ERR on structured clone problems. 152 // FIXME: This should throw a DATA_ERR when the wrong key/keyPath data is supplied. 141 142 if (putMode != CursorUpdate) { 143 if (!key && !autoIncrement && !hasKeyPath) { 144 ec = IDBDatabaseException::DATA_ERR; 145 return; 146 } 147 if (hasKeyPath) { 148 if (key && key->valid()) { 149 ec = IDBDatabaseException::DATA_ERR; 150 return; 151 } 152 if (!autoIncrement) { 153 RefPtr<IDBKey> keyPathKey = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath); 154 if (!keyPathKey || !keyPathKey->valid()) { 155 ec = IDBDatabaseException::DATA_ERR; 156 return; 157 } 158 } 159 } 160 // FIXME: Add precondition checks for index key paths that yield invalid keys. 161 // https://bugs.webkit.org/show_bug.cgi?id=76487 162 } 163 153 164 if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::putInternal, objectStore, value, key, putMode, callbacks, transaction))) 154 165 ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
Note: See TracChangeset
for help on using the changeset viewer.