From ea75742e0c6ab199062040d765d4d84c7798bdbb Mon Sep 17 00:00:00 2001 From: Ben Turner Date: Wed, 15 Dec 2010 13:21:11 -0800 Subject: [PATCH] Bug 618135 - 'IndexedDB: Implement update() on index cursors (not on index key cursors)'. r-sicking, a=blocking. --- dom/indexedDB/AsyncConnectionHelper.cpp | 22 +- dom/indexedDB/AsyncConnectionHelper.h | 1 - dom/indexedDB/IDBCursor.cpp | 339 ++++-------------- dom/indexedDB/IDBCursor.h | 2 +- dom/indexedDB/IDBObjectStore.cpp | 45 ++- dom/indexedDB/nsIIDBCursor.idl | 3 +- dom/indexedDB/nsIIDBObjectStore.idl | 5 +- dom/indexedDB/test/Makefile.in | 1 + .../test/test_index_object_cursors.html | 161 +++++++++ dom/indexedDB/test/test_key_requirements.html | 16 + 10 files changed, 276 insertions(+), 319 deletions(-) create mode 100644 dom/indexedDB/test/test_index_object_cursors.html diff --git a/dom/indexedDB/AsyncConnectionHelper.cpp b/dom/indexedDB/AsyncConnectionHelper.cpp index d0982dcf0ae..07e04d0e025 100644 --- a/dom/indexedDB/AsyncConnectionHelper.cpp +++ b/dom/indexedDB/AsyncConnectionHelper.cpp @@ -145,7 +145,8 @@ AsyncConnectionHelper::Run() mRequest->SetDone(); } - SetCurrentTransaction(mTransaction); + IDBTransaction* oldTransaction = gCurrentTransaction; + gCurrentTransaction = mTransaction; // Call OnError if the database had an error or if the OnSuccess handler // has an error. @@ -154,9 +155,8 @@ AsyncConnectionHelper::Run() OnError(mRequest, mResultCode); } - NS_ASSERTION(GetCurrentTransaction() == mTransaction, - "Should be unchanged!"); - SetCurrentTransaction(nsnull); + NS_ASSERTION(gCurrentTransaction == mTransaction, "Should be unchanged!"); + gCurrentTransaction = oldTransaction; if (mDispatched && mTransaction) { mTransaction->OnRequestFinished(); @@ -319,20 +319,6 @@ AsyncConnectionHelper::GetCurrentTransaction() return gCurrentTransaction; } -// static -void -AsyncConnectionHelper::SetCurrentTransaction(IDBTransaction* aTransaction) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - if (aTransaction) { - NS_ASSERTION(!gCurrentTransaction, "Overwriting current transaction!"); - } - - gCurrentTransaction = aTransaction; -} - - nsresult AsyncConnectionHelper::Init() { diff --git a/dom/indexedDB/AsyncConnectionHelper.h b/dom/indexedDB/AsyncConnectionHelper.h index bae992bc01e..413106ad05c 100644 --- a/dom/indexedDB/AsyncConnectionHelper.h +++ b/dom/indexedDB/AsyncConnectionHelper.h @@ -87,7 +87,6 @@ public: } static IDBTransaction* GetCurrentTransaction(); - static void SetCurrentTransaction(IDBTransaction* aTransaction); nsISupports* GetSource() { diff --git a/dom/indexedDB/IDBCursor.cpp b/dom/indexedDB/IDBCursor.cpp index d1b7cfa4b62..4fd5fd15d52 100644 --- a/dom/indexedDB/IDBCursor.cpp +++ b/dom/indexedDB/IDBCursor.cpp @@ -63,57 +63,6 @@ USING_INDEXEDDB_NAMESPACE namespace { -class UpdateHelper : public AsyncConnectionHelper -{ -public: - UpdateHelper(IDBTransaction* aTransaction, - IDBRequest* aRequest, - PRInt64 aObjectStoreID, - const nsAString& aValue, - const Key& aKey, - bool aAutoIncrement, - nsTArray& aIndexUpdateInfo) - : AsyncConnectionHelper(aTransaction, aRequest), mOSID(aObjectStoreID), - mValue(aValue), mKey(aKey), mAutoIncrement(aAutoIncrement) - { - mIndexUpdateInfo.SwapElements(aIndexUpdateInfo); - } - - nsresult DoDatabaseWork(mozIStorageConnection* aConnection); - nsresult GetSuccessResult(nsIWritableVariant* aResult); - -private: - // In-params. - const PRInt64 mOSID; - const nsString mValue; - const Key mKey; - const bool mAutoIncrement; - nsTArray mIndexUpdateInfo; -}; - -class DeleteHelper : public AsyncConnectionHelper -{ -public: - DeleteHelper(IDBTransaction* aTransaction, - IDBRequest* aRequest, - PRInt64 aObjectStoreID, - const Key& aKey, - bool aAutoIncrement) - : AsyncConnectionHelper(aTransaction, aRequest), mOSID(aObjectStoreID), - mKey(aKey), mAutoIncrement(aAutoIncrement) - { } - - nsresult DoDatabaseWork(mozIStorageConnection* aConnection); - nsresult GetSuccessResult(nsIWritableVariant* aResult); - -private: - // In-params. - const PRInt64 mOSID; - const nsString mValue; - const Key mKey; - const bool mAutoIncrement; -}; - inline already_AddRefed GenerateRequest(IDBCursor* aCursor) @@ -247,7 +196,7 @@ IDBCursor::Create(IDBRequest* aRequest, NS_ASSERTION(cursor, "This shouldn't fail!"); cursor->mIndex = aIndex; - cursor->mType = INDEX; + cursor->mType = INDEXKEY; cursor->mKey = aKey, cursor->mObjectKey = aObjectKey; @@ -452,7 +401,7 @@ IDBCursor::GetValue(JSContext* aCx, nsresult rv; - if (mType == INDEX) { + if (mType == INDEXKEY) { NS_ASSERTION(!mObjectKey.IsUnset(), "Bad key!"); rv = IDBObjectStore::GetJSValFromKey(mObjectKey, aCx, aValue); @@ -535,7 +484,7 @@ IDBCursor::Continue(const jsval &aKey, helper = new ContinueObjectStoreHelper(this); break; - case INDEX: + case INDEXKEY: helper = new ContinueIndexHelper(this); break; @@ -561,239 +510,75 @@ IDBCursor::Update(const jsval& aValue, { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - if (!mTransaction->TransactionIsOpen() || !mTransaction->IsWriteAllowed()) { + if (mType == INDEXKEY) { return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; } - if (mType != OBJECTSTORE) { - NS_WARNING("Update for non-objectStore cursors is not implemented!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; + NS_ASSERTION(mObjectStore, "This cannot be null!"); + NS_ASSERTION(!mKey.IsUnset() , "Bad key!"); + NS_ASSERTION(mType != INDEXOBJECT || !mObjectKey.IsUnset(), "Bad key!"); + + nsresult rv; + + JSAutoRequest ar(aCx); + + const Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey; + + if (!mObjectStore->KeyPath().IsEmpty()) { + // This has to be an object. + if (JSVAL_IS_PRIMITIVE(aValue)) { + return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; + } + + // Make sure the object given has the correct keyPath value set on it. + const nsString& keyPath = mObjectStore->KeyPath(); + + jsval prop; + JSBool ok = JS_GetUCProperty(aCx, JSVAL_TO_OBJECT(aValue), + reinterpret_cast(keyPath.get()), + keyPath.Length(), &prop); + NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + + Key key; + rv = IDBObjectStore::GetKeyFromJSVal(prop, key); + if (NS_FAILED(rv)) { + return rv; + } + + if (key != objectKey) { + return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; + } + + return mObjectStore->Put(aValue, JSVAL_VOID, aCx, 0, _retval); + } + + jsval keyVal; + rv = IDBObjectStore::GetJSValFromKey(objectKey, aCx, &keyVal); + NS_ENSURE_SUCCESS(rv, rv); + + return mObjectStore->Put(aValue, keyVal, aCx, 1, _retval); +} + +NS_IMETHODIMP +IDBCursor::Delete(JSContext* aCx, + nsIIDBRequest** _retval) +{ + NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); + + if (mType == INDEXKEY) { + return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; } NS_ASSERTION(mObjectStore, "This cannot be null!"); NS_ASSERTION(!mKey.IsUnset() , "Bad key!"); - JSAutoRequest ar(aCx); + const Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey; - js::AutoValueRooter clone(aCx, aValue); + jsval key; + nsresult rv = IDBObjectStore::GetJSValFromKey(objectKey, aCx, &key); + NS_ENSURE_SUCCESS(rv, rv); - nsresult rv; - if (!mObjectStore->KeyPath().IsEmpty()) { - // Make sure the object given has the correct keyPath value set on it or - // we will add it. - const nsString& keyPath = mObjectStore->KeyPath(); - const jschar* keyPathChars = reinterpret_cast(keyPath.get()); - const size_t keyPathLen = keyPath.Length(); - - js::AutoValueRooter prop(aCx); - JSBool ok = JS_GetUCProperty(aCx, JSVAL_TO_OBJECT(clone.jsval_value()), - keyPathChars, keyPathLen, prop.jsval_addr()); - NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - if (JSVAL_IS_VOID(prop.jsval_value())) { - rv = IDBObjectStore::GetJSValFromKey(mKey, aCx, prop.jsval_addr()); - NS_ENSURE_SUCCESS(rv, rv); - - ok = JS_StructuredClone(aCx, clone.jsval_value(), clone.jsval_addr()); - NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_SERIAL_ERR); - - ok = JS_DefineUCProperty(aCx, JSVAL_TO_OBJECT(clone.jsval_value()), - keyPathChars, keyPathLen, prop.jsval_value(), nsnull, - nsnull, JSPROP_ENUMERATE); - NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - } - else { - Key newKey; - rv = IDBObjectStore::GetKeyFromJSVal(prop.jsval_value(), newKey); - NS_ENSURE_SUCCESS(rv, rv); - - if (newKey.IsUnset() || newKey != mKey) { - return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; - } - } - } - - ObjectStoreInfo* info; - if (!ObjectStoreInfo::Get(mTransaction->Database()->Id(), - mObjectStore->Name(), &info)) { - NS_ERROR("This should never fail!"); - } - - nsTArray indexUpdateInfo; - rv = IDBObjectStore::GetIndexUpdateInfo(info, aCx, clone.jsval_value(), - indexUpdateInfo); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - nsCOMPtr json(new nsJSON()); - - nsString jsonValue; - rv = json->EncodeFromJSVal(clone.jsval_addr(), aCx, jsonValue); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_SERIAL_ERR); - - nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - nsRefPtr helper = - new UpdateHelper(mTransaction, request, mObjectStore->Id(), jsonValue, mKey, - mObjectStore->IsAutoIncrement(), indexUpdateInfo); - - rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - request.forget(_retval); - return NS_OK; -} - -NS_IMETHODIMP -IDBCursor::Delete(nsIIDBRequest** _retval) -{ - NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - - if (!mTransaction->TransactionIsOpen() || !mTransaction->IsWriteAllowed()) { - return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR; - } - - if (mType != OBJECTSTORE) { - NS_WARNING("Delete for non-objectStore cursors is not implemented!"); - return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; - } - - NS_ASSERTION(mObjectStore, "This cannot be null!"); - NS_ASSERTION(!mKey.IsUnset(), "Bad key!"); - - nsRefPtr request = GenerateRequest(this); - NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - nsRefPtr helper = - new DeleteHelper(mTransaction, request, mObjectStore->Id(), mKey, - mObjectStore->IsAutoIncrement()); - - nsresult rv = helper->DispatchToTransactionPool(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - request.forget(_retval); - return NS_OK; -} - -nsresult -UpdateHelper::DoDatabaseWork(mozIStorageConnection* aConnection) -{ - NS_PRECONDITION(aConnection, "Passed a null connection!"); - - nsresult rv; - NS_ASSERTION(!mKey.IsUnset(), "Badness!"); - - nsCOMPtr stmt = - mTransaction->AddStatement(false, true, mAutoIncrement); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - mozStorageStatementScoper scoper(stmt); - - NS_NAMED_LITERAL_CSTRING(keyValue, "key_value"); - - rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mOSID); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - if (mKey.IsInt()) { - rv = stmt->BindInt64ByName(keyValue, mKey.IntValue()); - } - else if (mKey.IsString()) { - rv = stmt->BindStringByName(keyValue, mKey.StringValue()); - } - else { - NS_NOTREACHED("Unknown key type!"); - } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - rv = stmt->BindStringByName(NS_LITERAL_CSTRING("data"), mValue); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - if (NS_FAILED(stmt->Execute())) { - return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; - } - - // Update our indexes if needed. - if (!mIndexUpdateInfo.IsEmpty()) { - PRInt64 objectDataId = mAutoIncrement ? mKey.IntValue() : LL_MININT; - rv = IDBObjectStore::UpdateIndexes(mTransaction, mOSID, mKey, - mAutoIncrement, true, - objectDataId, mIndexUpdateInfo); - if (rv == NS_ERROR_STORAGE_CONSTRAINT) { - return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; - } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - } - - return NS_OK; -} - -nsresult -UpdateHelper::GetSuccessResult(nsIWritableVariant* aResult) -{ - NS_ASSERTION(!mKey.IsUnset(), "Badness!"); - - if (mKey.IsString()) { - aResult->SetAsAString(mKey.StringValue()); - } - else if (mKey.IsInt()) { - aResult->SetAsInt64(mKey.IntValue()); - } - else { - NS_NOTREACHED("Bad key!"); - } - return NS_OK; -} - -nsresult -DeleteHelper::DoDatabaseWork(mozIStorageConnection* aConnection) -{ - NS_PRECONDITION(aConnection, "Passed a null connection!"); - - nsCOMPtr stmt = - mTransaction->DeleteStatement(mAutoIncrement); - NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - mozStorageStatementScoper scoper(stmt); - - nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mOSID); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - NS_ASSERTION(!mKey.IsUnset(), "Must have a key here!"); - - NS_NAMED_LITERAL_CSTRING(key_value, "key_value"); - - if (mKey.IsInt()) { - rv = stmt->BindInt64ByName(key_value, mKey.IntValue()); - } - else if (mKey.IsString()) { - rv = stmt->BindStringByName(key_value, mKey.StringValue()); - } - else { - NS_NOTREACHED("Unknown key type!"); - } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - // Search for it! - rv = stmt->Execute(); - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - - return NS_OK; -} - -nsresult -DeleteHelper::GetSuccessResult(nsIWritableVariant* aResult) -{ - NS_ASSERTION(!mKey.IsUnset(), "Badness!"); - - if (mKey.IsString()) { - aResult->SetAsAString(mKey.StringValue()); - } - else if (mKey.IsInt()) { - aResult->SetAsInt64(mKey.IntValue()); - } - else { - NS_NOTREACHED("Unknown key type!"); - } - return NS_OK; + return mObjectStore->Delete(key, aCx, _retval); } nsresult diff --git a/dom/indexedDB/IDBCursor.h b/dom/indexedDB/IDBCursor.h index 1d53f23fa31..607df02b66e 100644 --- a/dom/indexedDB/IDBCursor.h +++ b/dom/indexedDB/IDBCursor.h @@ -118,7 +118,7 @@ public: enum Type { OBJECTSTORE = 0, - INDEX, + INDEXKEY, INDEXOBJECT }; diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index f0b2d7fff5d..33ee27d6c77 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -744,16 +744,24 @@ IDBObjectStore::GetAddInfo(JSContext* aCx, { nsresult rv; + // Return DATA_ERR if a key was passed in and this objectStore uses inline + // keys. + if (!JSVAL_IS_VOID(aKeyVal) && !mKeyPath.IsEmpty()) { + return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; + } + JSAutoRequest ar(aCx); if (mKeyPath.IsEmpty()) { + // Out-of-line keys must be passed in. rv = GetKeyFromJSVal(aKeyVal, aKey); NS_ENSURE_SUCCESS(rv, rv); } else { - // Inline keys live on the object. Make sure it is an object. + // Inline keys live on the object. Make sure that the value passed in is an + // object. if (JSVAL_IS_PRIMITIVE(aValue)) { - return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR; + return NS_ERROR_DOM_INDEXEDDB_DATA_ERR; } rv = GetKeyFromObject(aCx, JSVAL_TO_OBJECT(aValue), mKeyPath, aKey); @@ -1025,7 +1033,8 @@ IDBObjectStore::Put(const jsval& aValue, } NS_IMETHODIMP -IDBObjectStore::Delete(nsIVariant* aKey, +IDBObjectStore::Delete(const jsval& aKey, + JSContext* aCx, nsIIDBRequest** _retval) { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); @@ -1035,7 +1044,7 @@ IDBObjectStore::Delete(nsIVariant* aKey, } Key key; - nsresult rv = GetKeyFromVariant(aKey, key); + nsresult rv = GetKeyFromJSVal(aKey, key); if (NS_FAILED(rv)) { return rv; } @@ -1421,8 +1430,6 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) rv = stmt->Execute(); if (NS_FAILED(rv)) { if (mayOverwrite && rv == NS_ERROR_STORAGE_CONSTRAINT) { - scoper.Abandon(); - stmt = mTransaction->AddStatement(false, true, autoIncrement); NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); @@ -1431,20 +1438,18 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection) rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), osid); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); - if (!autoIncrement) { - NS_ASSERTION(!mKey.IsUnset(), "This shouldn't happen!"); + NS_ASSERTION(!mKey.IsUnset(), "This shouldn't happen!"); - if (mKey.IsInt()) { - rv = stmt->BindInt64ByName(keyValue, mKey.IntValue()); - } - else if (mKey.IsString()) { - rv = stmt->BindStringByName(keyValue, mKey.StringValue()); - } - else { - NS_NOTREACHED("Unknown key type!"); - } - NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); + if (mKey.IsInt()) { + rv = stmt->BindInt64ByName(keyValue, mKey.IntValue()); } + else if (mKey.IsString()) { + rv = stmt->BindStringByName(keyValue, mKey.StringValue()); + } + else { + NS_NOTREACHED("Unknown key type!"); + } + NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); rv = stmt->BindStringByName(NS_LITERAL_CSTRING("data"), mValue); NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR); @@ -1978,7 +1983,9 @@ CreateIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection) // Now we need to populate the index with data from the object store. rv = InsertDataFromObjectStore(aConnection); - NS_ENSURE_TRUE(rv, rv); + if (NS_FAILED(rv)) { + return rv; + } return NS_OK; } diff --git a/dom/indexedDB/nsIIDBCursor.idl b/dom/indexedDB/nsIIDBCursor.idl index 4c45e5f021e..9d8804a0136 100644 --- a/dom/indexedDB/nsIIDBCursor.idl +++ b/dom/indexedDB/nsIIDBCursor.idl @@ -51,7 +51,7 @@ interface nsIVariant; * http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBCursor for more * information. */ -[scriptable, uuid(12c99a5b-6e67-4d5c-8ae7-3a58da690375)] +[scriptable, uuid(585d4d50-11a8-4d65-951e-805787f59d89)] interface nsIIDBCursor : nsISupports { const unsigned short NEXT = 0; @@ -77,5 +77,6 @@ interface nsIIDBCursor : nsISupports nsIIDBRequest update(in jsval value); // Success fires IDBTransactionEvent, result == null + [implicit_jscontext] nsIIDBRequest delete(); }; diff --git a/dom/indexedDB/nsIIDBObjectStore.idl b/dom/indexedDB/nsIIDBObjectStore.idl index f41c55310b7..d24efb8b3ee 100644 --- a/dom/indexedDB/nsIIDBObjectStore.idl +++ b/dom/indexedDB/nsIIDBObjectStore.idl @@ -55,7 +55,7 @@ interface nsIDOMDOMStringList; * http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-nsIIDBObjectStore * for more information. */ -[scriptable, uuid(626fd729-d66a-4b49-bbaf-058f1c375449)] +[scriptable, uuid(64f34805-d3e3-4305-91f8-b2cafac3d33c)] interface nsIIDBObjectStore : nsISupports { readonly attribute DOMString name; @@ -89,8 +89,9 @@ interface nsIIDBObjectStore : nsISupports [optional /* undefined */] in jsval key); // Success fires IDBTransactionEvent, result == null + [implicit_jscontext] nsIIDBRequest - delete(in nsIVariant key); + delete(in jsval key); // Success fires IDBTransactionEvent, result == null nsIIDBRequest diff --git a/dom/indexedDB/test/Makefile.in b/dom/indexedDB/test/Makefile.in index 3c204ef67ca..5d71404c506 100644 --- a/dom/indexedDB/test/Makefile.in +++ b/dom/indexedDB/test/Makefile.in @@ -68,6 +68,7 @@ TEST_FILES = \ test_global_data.html \ test_index_getAll.html \ test_index_getAllObjects.html \ + test_index_object_cursors.html \ test_indexes.html \ test_indexes_bad_values.html \ test_key_requirements.html \ diff --git a/dom/indexedDB/test/test_index_object_cursors.html b/dom/indexedDB/test/test_index_object_cursors.html new file mode 100644 index 00000000000..850117c3b0e --- /dev/null +++ b/dom/indexedDB/test/test_index_object_cursors.html @@ -0,0 +1,161 @@ + + + + Indexed Database Property Test + + + + + + + + + + + + diff --git a/dom/indexedDB/test/test_key_requirements.html b/dom/indexedDB/test/test_key_requirements.html index f58f62975a6..52ba530bbab 100644 --- a/dom/indexedDB/test/test_key_requirements.html +++ b/dom/indexedDB/test/test_key_requirements.html @@ -133,6 +133,14 @@ ok(true, "add with no key threw"); } + try { + objectStore.add({id:5}, 5); + ok(false, "add with inline key and passed key should throw!"); + } + catch (e) { + ok(true, "add with inline key and passed key threw"); + } + try { objectStore.put({}); ok(false, "put with no key should throw!"); @@ -266,6 +274,14 @@ ok(true, "remove with no key threw"); } + try { + objectStore.add({id:5}, 5); + ok(false, "add with inline key and passed key should throw!"); + } + catch (e) { + ok(true, "add with inline key and passed key threw"); + } + request = objectStore.delete(key2); request.onerror = errorHandler; request.onsuccess = grabEventAndContinueHandler;