WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-77374-20120203165544.patch (text/plain), 8.62 KB, created by
Joshua Bell
on 2012-02-03 16:55:45 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Joshua Bell
Created:
2012-02-03 16:55:45 PST
Size:
8.62 KB
patch
obsolete
>Subversion Revision: 106709 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 94f72afa84aa9957eea41f83f8a0960ed8c42f75..d032f40c1aaf918d4f6e135bd2ce8b1e858ddb65 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2012-02-03 Joshua Bell <jsbell@chromium.org> >+ >+ IndexedDB: Raise exception during add/put call if autoIncrement key insertion will fail >+ https://bugs.webkit.org/show_bug.cgi?id=77374 >+ >+ If a put request will use a key generator, try inserting a dummy key during the sync >+ put() call to check if the key insertion will succeed so an exception can be raised >+ early, rather than deferring to the asynchronous task. >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Test: storage/indexeddb/keypath-edges.html >+ >+ * storage/IDBObjectStoreBackendImpl.cpp: >+ (WebCore::IDBObjectStoreBackendImpl::put): >+ > 2012-02-03 Brady Eidson <beidson@apple.com> > > <rdar://problem/10742441> and https://bugs.webkit.org/show_bug.cgi?id=77766 >diff --git a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp >index f9bd78023341cd53faaade548382959736d40680..f07ea3eeba6ee7a305e7e95f233ca70e9907e668 100644 >--- a/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp >+++ b/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp >@@ -153,6 +153,14 @@ void IDBObjectStoreBackendImpl::put(PassRefPtr<SerializedScriptValue> prpValue, > ec = IDBDatabaseException::DATA_ERR; > return; > } >+ if (autoIncrement && !keyPathKey) { >+ RefPtr<IDBKey> dummyKey = IDBKey::createNumber(-1); >+ RefPtr<SerializedScriptValue> valueAfterInjection = injectKeyIntoKeyPath(dummyKey, value, objectStore->m_keyPath); >+ if (!valueAfterInjection) { >+ ec = IDBDatabaseException::DATA_ERR; >+ return; >+ } >+ } > } > if (key && !key->valid()) { > ec = IDBDatabaseException::DATA_ERR; >@@ -208,12 +216,13 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr< > if (!key) { > RefPtr<IDBKey> autoIncKey = objectStore->genAutoIncrementKey(); > if (hasKeyPath) { >- // FIXME: Add checks in put() to ensure this will always succeed (apart from I/O errors). >- // https://bugs.webkit.org/show_bug.cgi?id=77374 > RefPtr<SerializedScriptValue> valueAfterInjection = injectKeyIntoKeyPath(autoIncKey, value, objectStore->m_keyPath); >+ ASSERT(valueAfterInjection); > if (!valueAfterInjection) { > objectStore->resetAutoIncrementKeyCache(); >- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::DATA_ERR, "The generated key could not be inserted into the object using the keyPath.")); >+ // Checks in put() ensure this should only happen if I/O error occurs. >+ // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors. >+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error inserting generated key into the object.")); > return; > } > value = valueAfterInjection; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index efdafd77ee6074ede85640e0444a340becec836a..ecfb2119c3f4c0b08095522dd38fc3ce13117b1c 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,5 +1,15 @@ > 2012-02-03 Joshua Bell <jsbell@chromium.org> > >+ IndexedDB: Raise exception during add/put call if autoIncrement key insertion will fail >+ https://bugs.webkit.org/show_bug.cgi?id=77374 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * storage/indexeddb/keypath-edges-expected.txt: >+ * storage/indexeddb/keypath-edges.html: >+ >+2012-02-03 Joshua Bell <jsbell@chromium.org> >+ > IndexedDB: Key generators not rolled back if insertion fails or is aborted > https://bugs.webkit.org/show_bug.cgi?id=77060 > >diff --git a/LayoutTests/storage/indexeddb/keypath-edges-expected.txt b/LayoutTests/storage/indexeddb/keypath-edges-expected.txt >index e5fca32ac79b7520261298ddd6ef29addf5d95d8..92d2ae9b9bf880c682ca84b49871cc7af2e4e40b 100644 >--- a/LayoutTests/storage/indexeddb/keypath-edges-expected.txt >+++ b/LayoutTests/storage/indexeddb/keypath-edges-expected.txt >@@ -45,12 +45,15 @@ testKeyPathsAndGenerator(): > transaction = db.transaction(['store-with-path-and-generator'], IDBTransaction.READ_WRITE) > store = transaction.objectStore('store-with-path-and-generator') > >-Key path doesn't resolve to a value; should yield null, put request should raise error event >-store.put(null) >-PASS Error event raised: The generated key could not be inserted into the object using the keyPath. >-PASS event.target.errorCode is IDBDatabaseException.DATA_ERR >-PASS event.cancelable is true >-event.preventDefault() >+Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception >+Expecting exception from store.put(null) >+PASS Exception was thrown. >+PASS code is IDBDatabaseException.DATA_ERR >+ >+Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception >+Expecting exception from store.put('string') >+PASS Exception was thrown. >+PASS code is IDBDatabaseException.DATA_ERR > > Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed > store.put({}) >diff --git a/LayoutTests/storage/indexeddb/keypath-edges.html b/LayoutTests/storage/indexeddb/keypath-edges.html >index 76808cac2bcf3e07dfc91a235d1aa44509c9e5fb..f8c9049b3888a6918eaa734a526b9d866d85a64d 100644 >--- a/LayoutTests/storage/indexeddb/keypath-edges.html >+++ b/LayoutTests/storage/indexeddb/keypath-edges.html >@@ -88,32 +88,31 @@ function testKeyPathsAndGenerator() > store = evalAndLog("store = transaction.objectStore('store-with-path-and-generator')"); > > debug(""); >- debug("Key path doesn't resolve to a value; should yield null, put request should raise error event"); >- request = evalAndLog("store.put(null)"); >- request.onerror = function (e) { >- testPassed("Error event raised: " + e.target.webkitErrorMessage); >- shouldBe("event.target.errorCode", "IDBDatabaseException.DATA_ERR"); >- shouldBeTrue("event.cancelable"); >- evalAndLog("event.preventDefault()"); >+ debug("Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception"); >+ evalAndExpectException("store.put(null)", "IDBDatabaseException.DATA_ERR"); >+ >+ debug(""); >+ debug("Key path doesn't resolve to a value; should yield null but insertion would fail, so put request should raise exception"); >+ evalAndExpectException("store.put('string')", "IDBDatabaseException.DATA_ERR"); >+ >+ debug(""); >+ debug("Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed"); >+ request = evalAndLog("store.put({})"); >+ request.onerror = unexpectedErrorCallback; >+ request.onsuccess = function () { >+ testPassed("store.put succeeded"); >+ >+ debug(""); >+ debug("Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR"); >+ evalAndExpectException("store.put({foo: null})", "IDBDatabaseException.DATA_ERR"); > > debug(""); >- debug("Key path doesn't resolve to a value; should yield null, key should be generated, put request should succeed"); >- request = evalAndLog("store.put({})"); >+ debug("Key path resolves to a value that is valid key; should yield 'string' key, should succeed"); >+ request = evalAndLog("store.put({foo: 'zoo'})"); > request.onerror = unexpectedErrorCallback; > request.onsuccess = function () { > testPassed("store.put succeeded"); > >- debug(""); >- debug("Key path resolves to a value that is invalid key; should yield 'invalid' key, should throw DATA_ERR"); >- evalAndExpectException("store.put({foo: null})", "IDBDatabaseException.DATA_ERR"); >- >- debug(""); >- debug("Key path resolves to a value that is valid key; should yield 'string' key, should succeed"); >- request = evalAndLog("store.put({foo: 'zoo'})"); >- request.onerror = unexpectedErrorCallback; >- request.onsuccess = function () { >- testPassed("store.put succeeded"); >- }; > }; > }; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 77374
:
125363
|
125435
| 125448