Diff
Modified: trunk/LayoutTests/ChangeLog (105328 => 105329)
--- trunk/LayoutTests/ChangeLog 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/LayoutTests/ChangeLog 2012-01-18 22:58:56 UTC (rev 105329)
@@ -1,3 +1,15 @@
+2012-01-18 Joshua Bell <jsb...@chromium.org>
+
+ IndexedDB: Invalid keys yielded by key paths should raise exceptions, not error callbacks
+ https://bugs.webkit.org/show_bug.cgi?id=76075
+
+ Reviewed by Tony Chang.
+
+ * storage/indexeddb/mozilla/bad-keypath-expected.txt:
+ * storage/indexeddb/mozilla/bad-keypath.html:
+ * storage/indexeddb/objectstore-basics-expected.txt:
+ * storage/indexeddb/objectstore-basics.html:
+
2012-01-18 James Robinson <jam...@chromium.org>
[chromium] Update chromium linux pixel baseline for svg test
Modified: trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath-expected.txt (105328 => 105329)
--- trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath-expected.txt 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath-expected.txt 2012-01-18 22:58:56 UTC (rev 105329)
@@ -13,8 +13,9 @@
Deleted all object stores.
objectStore = db.createObjectStore('foo', { keyPath: 'keyPath' });
request = objectStore.add({ keyPath: 'foo' });
-request = objectStore.add({});
-PASS event.target.errorCode is IDBDatabaseException.DATA_ERR
+Expecting exception from request = objectStore.add({});
+PASS Exception was thrown.
+PASS code is IDBDatabaseException.DATA_ERR
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath.html (105328 => 105329)
--- trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath.html 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/LayoutTests/storage/indexeddb/mozilla/bad-keypath.html 2012-01-18 22:58:56 UTC (rev 105329)
@@ -54,14 +54,7 @@
function addFirstSuccess()
{
- request = evalAndLog("request = objectStore.add({});");
- request._onsuccess_ = unexpectedSuccessCallback;
- request._onerror_ = addSecondExpectedError;
-}
-
-function addSecondExpectedError()
-{
- shouldBe("event.target.errorCode", "IDBDatabaseException.DATA_ERR");
+ evalAndExpectException("request = objectStore.add({});", "IDBDatabaseException.DATA_ERR");
done();
}
Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt (105328 => 105329)
--- trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt 2012-01-18 22:58:56 UTC (rev 105329)
@@ -135,6 +135,57 @@
Expecting exception from store.put(null, {})
PASS Exception was thrown.
PASS code is webkitIDBDatabaseException.DATA_ERR
+
+testPreConditions():
+db.setVersion('precondition version')
+storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key'})
+storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys')
+storeWithIndex = db.createObjectStore('storeWithIndex')
+index = storeWithIndex.createIndex('indexName', 'indexKey')
+
+IDBObjectStore.put()
+The object store uses in-line keys and the key parameter was provided.
+Expecting exception from storeWithInLineKeys.put({key: 1}, 'key')
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
+Expecting exception from storeWithOutOfLineKeys.put({})
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+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.
+Expecting exception from storeWithInLineKeys.put({key: null})
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+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.
+Expecting exception from storeWithInLineKeys.put({})
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+The key parameter was provided but does not contain a valid key.
+Expecting exception from storeWithOutOfLineKeys.put({}, null)
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+
+IDBObjectStore.add()
+The object store uses in-line keys and the key parameter was provided.
+Expecting exception from storeWithInLineKeys.add({key: 1}, 'key')
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+The object store uses out-of-line keys and has no key generator and the key parameter was not provided.
+Expecting exception from storeWithOutOfLineKeys.add({})
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+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.
+Expecting exception from storeWithInLineKeys.add({key: null})
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+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.
+Expecting exception from storeWithInLineKeys.add({})
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
+The key parameter was provided but does not contain a valid key.
+Expecting exception from storeWithOutOfLineKeys.add({}, null)
+PASS Exception was thrown.
+PASS code is webkitIDBDatabaseException.DATA_ERR
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics.html (105328 => 105329)
--- trunk/LayoutTests/storage/indexeddb/objectstore-basics.html 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics.html 2012-01-18 22:58:56 UTC (rev 105329)
@@ -286,9 +286,67 @@
debug("Passing an invalid key into store.put().");
evalAndExpectException("store.put(null, {})", "webkitIDBDatabaseException.DATA_ERR");
- done();
+ testPreConditions();
}
+function testPreConditions()
+{
+ debug("");
+ debug("testPreConditions():");
+ request = evalAndLog("db.setVersion('precondition version')");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onsuccess_ = function() {
+ storeWithInLineKeys = evalAndLog("storeWithInLineKeys = db.createObjectStore('storeWithInLineKeys', {keyPath: 'key'})");
+ storeWithOutOfLineKeys = evalAndLog("storeWithOutOfLineKeys = db.createObjectStore('storeWithOutIOfLineKeys')");
+ storeWithIndex = evalAndLog("storeWithIndex = db.createObjectStore('storeWithIndex')");
+ index = evalAndLog("index = storeWithIndex.createIndex('indexName', 'indexKey')");
+
+ debug("");
+ debug("IDBObjectStore.put()");
+ debug("The object store uses in-line keys and the key parameter was provided.");
+ evalAndExpectException("storeWithInLineKeys.put({key: 1}, 'key')", "webkitIDBDatabaseException.DATA_ERR");
+
+ debug("The object store uses out-of-line keys and has no key generator and the key parameter was not provided.");
+ evalAndExpectException("storeWithOutOfLineKeys.put({})", "webkitIDBDatabaseException.DATA_ERR");
+
+ 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.");
+ evalAndExpectException("storeWithInLineKeys.put({key: null})", "webkitIDBDatabaseException.DATA_ERR");
+
+ 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.");
+ evalAndExpectException("storeWithInLineKeys.put({})", "webkitIDBDatabaseException.DATA_ERR");
+
+ debug("The key parameter was provided but does not contain a valid key.");
+ evalAndExpectException("storeWithOutOfLineKeys.put({}, null)", "webkitIDBDatabaseException.DATA_ERR");
+
+ // FIXME: Add precondition checks for put() with index key paths that yield invalid keys.
+ // https://bugs.webkit.org/show_bug.cgi?id=76487
+
+ debug("");
+ debug("IDBObjectStore.add()");
+ debug("The object store uses in-line keys and the key parameter was provided.");
+ evalAndExpectException("storeWithInLineKeys.add({key: 1}, 'key')", "webkitIDBDatabaseException.DATA_ERR");
+
+ debug("The object store uses out-of-line keys and has no key generator and the key parameter was not provided.");
+ evalAndExpectException("storeWithOutOfLineKeys.add({})", "webkitIDBDatabaseException.DATA_ERR");
+
+ 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.");
+ evalAndExpectException("storeWithInLineKeys.add({key: null})", "webkitIDBDatabaseException.DATA_ERR");
+
+ 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.");
+ evalAndExpectException("storeWithInLineKeys.add({})", "webkitIDBDatabaseException.DATA_ERR");
+
+ debug("The key parameter was provided but does not contain a valid key.");
+ evalAndExpectException("storeWithOutOfLineKeys.add({}, null)", "webkitIDBDatabaseException.DATA_ERR");
+
+ // FIXME: Add precondition checks for add() with index key paths that yield invalid keys.
+ // https://bugs.webkit.org/show_bug.cgi?id=76487
+
+ done();
+ };
+}
+
+
+
test();
Modified: trunk/Source/WebCore/ChangeLog (105328 => 105329)
--- trunk/Source/WebCore/ChangeLog 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/Source/WebCore/ChangeLog 2012-01-18 22:58:56 UTC (rev 105329)
@@ -1,3 +1,15 @@
+2012-01-18 Joshua Bell <jsb...@chromium.org>
+
+ IndexedDB: Invalid keys yielded by key paths should raise exceptions, not error callbacks
+ https://bugs.webkit.org/show_bug.cgi?id=76075
+
+ Reviewed by Tony Chang.
+
+ Tests: storage/indexeddb/objectstore-basics.html
+
+ * storage/IDBObjectStoreBackendImpl.cpp:
+ (WebCore::IDBObjectStoreBackendImpl::put):
+
2012-01-18 Dana Jansens <dan...@chromium.org>
[chromium] Fix compile error from bug #76211
Modified: trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp (105328 => 105329)
--- trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp 2012-01-18 22:49:59 UTC (rev 105328)
+++ trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp 2012-01-18 22:58:56 UTC (rev 105329)
@@ -138,18 +138,29 @@
const bool autoIncrement = objectStore->autoIncrement();
const bool hasKeyPath = !objectStore->m_keyPath.isNull();
- if (!key && !autoIncrement && !hasKeyPath) {
- ec = IDBDatabaseException::DATA_ERR;
- return;
- }
- if (key && hasKeyPath && (putMode == AddOnly || putMode == AddOrUpdate)) {
- ec = IDBDatabaseException::DATA_ERR;
- return;
- }
+ if (putMode != CursorUpdate) {
+ if (!key && !autoIncrement && !hasKeyPath) {
+ ec = IDBDatabaseException::DATA_ERR;
+ return;
+ }
+ if (hasKeyPath) {
+ if (key && key->valid()) {
+ ec = IDBDatabaseException::DATA_ERR;
+ return;
+ }
+ if (!autoIncrement) {
+ RefPtr<IDBKey> keyPathKey = fetchKeyFromKeyPath(value.get(), objectStore->m_keyPath);
+ if (!keyPathKey || !keyPathKey->valid()) {
+ ec = IDBDatabaseException::DATA_ERR;
+ return;
+ }
+ }
+ }
+ // FIXME: Add precondition checks for index key paths that yield invalid keys.
+ // https://bugs.webkit.org/show_bug.cgi?id=76487
+ }
- // FIXME: This should throw a SERIAL_ERR on structured clone problems.
- // FIXME: This should throw a DATA_ERR when the wrong key/keyPath data is supplied.
if (!transaction->scheduleTask(createCallbackTask(&IDBObjectStoreBackendImpl::putInternal, objectStore, value, key, putMode, callbacks, transaction)))
ec = IDBDatabaseException::TRANSACTION_INACTIVE_ERR;
}