Changeset 106830 in webkit
- Timestamp:
- Feb 6, 2012 12:00:24 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r106829 r106830 1 2012-02-06 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Raise exception during add/put call if autoIncrement key insertion will fail 4 https://bugs.webkit.org/show_bug.cgi?id=77374 5 6 Reviewed by Tony Chang. 7 8 * storage/indexeddb/keypath-edges-expected.txt: 9 * storage/indexeddb/keypath-edges.html: 10 1 11 2012-02-06 Julien Chaffraix <jchaffraix@webkit.org> 2 12 -
trunk/LayoutTests/storage/indexeddb/keypath-edges-expected.txt
r105891 r106830 46 46 store = transaction.objectStore('store-with-path-and-generator') 47 47 48 Key path doesn't resolve to a value; should yield null, put request should raise error event 49 store.put(null) 50 PASS Error event raised: The generated key could not be inserted into the object using the keyPath. 51 PASS event.target.errorCode is IDBDatabaseException.DATA_ERR 52 PASS event.cancelable is true 53 event.preventDefault() 48 Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception 49 Expecting exception from store.put(null) 50 PASS Exception was thrown. 51 PASS code is IDBDatabaseException.DATA_ERR 52 53 Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception 54 Expecting exception from store.put('string') 55 PASS Exception was thrown. 56 PASS code is IDBDatabaseException.DATA_ERR 54 57 55 58 Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed -
trunk/LayoutTests/storage/indexeddb/keypath-edges.html
r105891 r106830 89 89 90 90 debug(""); 91 debug("Key path doesn't resolve to a value; should yield null, put request should raise error event"); 92 request = evalAndLog("store.put(null)"); 93 request.onerror = function (e) { 94 testPassed("Error event raised: " + e.target.webkitErrorMessage); 95 shouldBe("event.target.errorCode", "IDBDatabaseException.DATA_ERR"); 96 shouldBeTrue("event.cancelable"); 97 evalAndLog("event.preventDefault()"); 91 debug("Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception"); 92 evalAndExpectException("store.put(null)", "IDBDatabaseException.DATA_ERR"); 93 94 debug(""); 95 debug("Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception"); 96 evalAndExpectException("store.put('string')", "IDBDatabaseException.DATA_ERR"); 97 98 debug(""); 99 debug("Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed"); 100 request = evalAndLog("store.put({})"); 101 request.onerror = unexpectedErrorCallback; 102 request.onsuccess = function () { 103 testPassed("store.put succeeded"); 98 104 99 105 debug(""); 100 debug("Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed"); 101 request = evalAndLog("store.put({})"); 106 debug("Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR"); 107 evalAndExpectException("store.put({foo: null})", "IDBDatabaseException.DATA_ERR"); 108 109 debug(""); 110 debug("Key path resolves to a value that is valid key; should yield 'string' key, should succeed"); 111 request = evalAndLog("store.put({foo: 'zoo'})"); 102 112 request.onerror = unexpectedErrorCallback; 103 113 request.onsuccess = function () { 104 114 testPassed("store.put succeeded"); 105 115 106 debug("");107 debug("Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR");108 evalAndExpectException("store.put({foo: null})", "IDBDatabaseException.DATA_ERR");109 110 debug("");111 debug("Key path resolves to a value that is valid key; should yield 'string' key, should succeed");112 request = evalAndLog("store.put({foo: 'zoo'})");113 request.onerror = unexpectedErrorCallback;114 request.onsuccess = function () {115 testPassed("store.put succeeded");116 };117 116 }; 118 117 }; -
trunk/Source/WebCore/ChangeLog
r106828 r106830 1 2012-02-06 Joshua Bell <jsbell@chromium.org> 2 3 IndexedDB: Raise exception during add/put call if autoIncrement key insertion will fail 4 https://bugs.webkit.org/show_bug.cgi?id=77374 5 6 If a put request will use a key generator, try inserting a dummy key during the sync 7 put() call to check if the key insertion will succeed so an exception can be raised 8 early, rather than deferring to the asynchronous task. 9 10 Reviewed by Tony Chang. 11 12 Test: storage/indexeddb/keypath-edges.html 13 14 * storage/IDBObjectStoreBackendImpl.cpp: 15 (WebCore::IDBObjectStoreBackendImpl::put): 16 1 17 2012-02-06 Gustavo Noronha Silva <gns@gnome.org> 2 18 -
trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp
r106705 r106830 154 154 return; 155 155 } 156 if (autoIncrement && !keyPathKey) { 157 RefPtr<IDBKey> dummyKey = IDBKey::createNumber(-1); 158 RefPtr<SerializedScriptValue> valueAfterInjection = injectKeyIntoKeyPath(dummyKey, value, objectStore->m_keyPath); 159 if (!valueAfterInjection) { 160 ec = IDBDatabaseException::DATA_ERR; 161 return; 162 } 163 } 156 164 } 157 165 if (key && !key->valid()) { … … 209 217 RefPtr<IDBKey> autoIncKey = objectStore->genAutoIncrementKey(); 210 218 if (hasKeyPath) { 211 // FIXME: Add checks in put() to ensure this will always succeed (apart from I/O errors).212 // https://bugs.webkit.org/show_bug.cgi?id=77374213 219 RefPtr<SerializedScriptValue> valueAfterInjection = injectKeyIntoKeyPath(autoIncKey, value, objectStore->m_keyPath); 220 ASSERT(valueAfterInjection); 214 221 if (!valueAfterInjection) { 215 222 objectStore->resetAutoIncrementKeyCache(); 216 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "The generated key could not be inserted into the object using the keyPath.")); 223 // Checks in put() ensure this should only happen if I/O error occurs. 224 // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. 225 callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error inserting generated key into the object.")); 217 226 return; 218 227 }
Note: See TracChangeset
for help on using the changeset viewer.