Commit 60e43f0b authored by hans@chromium.org's avatar hans@chromium.org

2011-01-20 Hans Wennborg <hans@chromium.org>

        Reviewed by Jeremy Orlow.

        IndexedDB: IDBObjectStore.get should fire onsuccess rather than onerror
        https://bugs.webkit.org/show_bug.cgi?id=52725

        Update layout tests to expect the onsuccess handler to be fired
        when looking up non-existing objects.

        * storage/indexeddb/create-and-remove-object-store-expected.txt:
        * storage/indexeddb/create-and-remove-object-store.html:
        * storage/indexeddb/cursor-delete-expected.txt:
        * storage/indexeddb/cursor-delete.html:
        * storage/indexeddb/objectstore-removeobjectstore-expected.txt:
        * storage/indexeddb/objectstore-removeobjectstore.html:
2011-01-20  Hans Wennborg  <hans@chromium.org>

        Reviewed by Jeremy Orlow.

        IndexedDB: IDBObjectStore.get should fire onsuccess rather than onerror
        https://bugs.webkit.org/show_bug.cgi?id=52725

        Let IDBObjectStore.get() fire the onsuccess handler with the value
        'undefined' for when an object does not exist in the store.

        Update SerializedScriptValue to provide such an undefined value.

        * bindings/v8/SerializedScriptValue.cpp:
        (WebCore::SerializedScriptValue::nullValue):
        (WebCore::SerializedScriptValue::undefinedValue):
        * bindings/v8/SerializedScriptValue.h:
        * storage/IDBObjectStoreBackendImpl.cpp:
        (WebCore::IDBObjectStoreBackendImpl::getInternal):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c8a06eb9
2011-01-20 Hans Wennborg <hans@chromium.org>
Reviewed by Jeremy Orlow.
IndexedDB: IDBObjectStore.get should fire onsuccess rather than onerror
https://bugs.webkit.org/show_bug.cgi?id=52725
Update layout tests to expect the onsuccess handler to be fired
when looking up non-existing objects.
* storage/indexeddb/create-and-remove-object-store-expected.txt:
* storage/indexeddb/create-and-remove-object-store.html:
* storage/indexeddb/cursor-delete-expected.txt:
* storage/indexeddb/cursor-delete.html:
* storage/indexeddb/objectstore-removeobjectstore-expected.txt:
* storage/indexeddb/objectstore-removeobjectstore.html:
2010-12-27 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Pavel Feldman.
......
......@@ -50,6 +50,18 @@ Adding 'tmp' again
PASS code is webkitIDBDatabaseException.CONSTRAINT_ERR
trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})
trans.objectStore('tmp').get(0)
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.result is undefined
Trying create
PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR
Trying remove
......
......@@ -76,12 +76,15 @@ function cleaned()
}
trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})");
req = evalAndLog("trans.objectStore('tmp').get(0)");
req.onsuccess = unexpectedSuccessCallback;
req.onerror = tryOnceMore;
req.onsuccess = tryOnceMore;
req.onerror = unexpectedErrorCallback;
}
function tryOnceMore()
{
verifySuccessEvent(event);
shouldBe("event.result", "undefined");
testCreateAndRemove();
done();
......
......@@ -115,10 +115,10 @@ PASS event.target.readyState is event.target.DONE
PASS [object IDBCursor] is non-null.
event.result.delete()
objectStore.get('myKey1')
Error event fired:
PASS 'result' in event is false
PASS 'code' in event is true
PASS 'message' in event is true
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
......@@ -126,6 +126,7 @@ PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.result is undefined
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -115,13 +115,14 @@ function deleteObject()
shouldBeNonNull(event.result);
evalAndLog("event.result.delete()");
result = evalAndLog("objectStore.get('myKey1')");
result.onsuccess = unexpectedSuccessCallback;
result.onerror = verifyObjectDeleted;
result.onsuccess = verifyObjectDeleted;
result.onerror = unexpectedErrorCallback;
}
function verifyObjectDeleted()
{
verifyErrorEvent(event);
verifySuccessEvent(event);
shouldBe("event.result", "undefined");
done();
}
......
......@@ -110,10 +110,10 @@ PASS 'onerror' in result is true
PASS 'readyState' in result is true
An event should fire shortly...
Error event fired:
PASS 'result' in event is false
PASS 'code' in event is true
PASS 'message' in event is true
Success event fired:
PASS 'result' in event is true
PASS 'code' in event is false
PASS 'message' in event is false
PASS 'source' in event is true
PASS event.source != null is true
PASS 'onsuccess' in event.target is true
......@@ -121,7 +121,7 @@ PASS 'onerror' in event.target is true
PASS 'readyState' in event.target is true
PASS event.target.readyState is event.target.DONE
PASS event.code is webkitIDBDatabaseException.NOT_FOUND_ERR
PASS event.result is undefined
PASS event.source.indexNames.contains('indexName') is false
PASS successfullyParsed is true
......
......@@ -105,14 +105,14 @@ function getValueAgain()
result = evalAndLog("store.get('key')");
verifyResult(result);
result.onsuccess = unexpectedSuccessCallback;
result.onerror = verifyError;
result.onsuccess = verifyNotFound;
result.onerror = unexpectedErrorCallback;
}
function verifyError()
function verifyNotFound()
{
verifyErrorEvent(event);
shouldBe("event.code", "webkitIDBDatabaseException.NOT_FOUND_ERR");
verifySuccessEvent(event);
shouldBe("event.result", "undefined");
shouldBeFalse("event.source.indexNames.contains('indexName')");
done();
......
2011-01-20 Hans Wennborg <hans@chromium.org>
Reviewed by Jeremy Orlow.
IndexedDB: IDBObjectStore.get should fire onsuccess rather than onerror
https://bugs.webkit.org/show_bug.cgi?id=52725
Let IDBObjectStore.get() fire the onsuccess handler with the value
'undefined' for when an object does not exist in the store.
Update SerializedScriptValue to provide such an undefined value.
* bindings/v8/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::nullValue):
(WebCore::SerializedScriptValue::undefinedValue):
* bindings/v8/SerializedScriptValue.h:
* storage/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::getInternal):
2010-12-27 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Pavel Feldman.
......@@ -1129,12 +1129,18 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::create()
return adoptRef(new SerializedScriptValue());
}
SerializedScriptValue* SerializedScriptValue::nullValue()
SerializedScriptValue* SerializedScriptValue::nullValue()
{
DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (SerializedScriptValue::create()));
return nullValue.get();
}
SerializedScriptValue* SerializedScriptValue::undefinedValue()
{
DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, undefinedValue, (SerializedScriptValue::create(v8::Undefined())));
return undefinedValue.get();
}
PassRefPtr<SerializedScriptValue> SerializedScriptValue::release()
{
RefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_data, WireData));
......
......@@ -52,8 +52,9 @@ public:
static PassRefPtr<SerializedScriptValue> createFromWire(String data);
static PassRefPtr<SerializedScriptValue> create(String data);
static PassRefPtr<SerializedScriptValue> create();
static SerializedScriptValue* nullValue();
static SerializedScriptValue* nullValue();
static SerializedScriptValue* undefinedValue();
PassRefPtr<SerializedScriptValue> release();
......
......@@ -110,7 +110,7 @@ void IDBObjectStoreBackendImpl::getInternal(ScriptExecutionContext*, PassRefPtr<
bindWhereClause(query, objectStore->id(), key.get());
if (query.step() != SQLResultRow) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store."));
callbacks->onSuccess(SerializedScriptValue::undefinedValue());
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment