Diff
Modified: trunk/LayoutTests/ChangeLog (99228 => 99229)
--- trunk/LayoutTests/ChangeLog 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/LayoutTests/ChangeLog 2011-11-03 19:41:31 UTC (rev 99229)
@@ -1,3 +1,18 @@
+2011-11-03 Joshua Bell <[email protected]>
+
+ IndexedDB result of deleting a record should be true or false
+ https://bugs.webkit.org/show_bug.cgi?id=60197
+
+ Reviewed by David Levin.
+
+ Add tests for IDBObjectStore.delete() - should succeed if
+ record exists or not, and return true/false as success value.
+
+ * storage/indexeddb/mozilla/delete-result-expected.txt: Added.
+ * storage/indexeddb/mozilla/delete-result.html: Added.
+ * storage/indexeddb/objectstore-basics-expected.txt:
+ * storage/indexeddb/objectstore-basics.html:
+
2011-11-03 Adam Barth <[email protected]>
Implement allow-popups for iframe@sandbox
Added: trunk/LayoutTests/storage/indexeddb/mozilla/delete-result-expected.txt (0 => 99229)
--- trunk/LayoutTests/storage/indexeddb/mozilla/delete-result-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/mozilla/delete-result-expected.txt 2011-11-03 19:41:31 UTC (rev 99229)
@@ -0,0 +1,22 @@
+Test IndexedDB: result property after deleting existing and non-existing record
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
+PASS indexedDB == null is false
+indexedDB.open(name, description)
+db = event.target.result
+request = db.setVersion('1')
+Deleted all object stores.
+objectStore = db.createObjectStore('foo', { keyPath: 'id', autoIncrement: true });
+request = objectStore.add({});
+id = event.target.result;
+request = objectStore.delete(id);
+PASS event.target.result is true
+request = objectStore.delete(id);
+PASS event.target.result is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/mozilla/delete-result.html (0 => 99229)
--- trunk/LayoutTests/storage/indexeddb/mozilla/delete-result.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/mozilla/delete-result.html 2011-11-03 19:41:31 UTC (rev 99229)
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<!--
+ original test: http://mxr.mozilla.org/mozilla2.0/source/dom/indexedDB/test/test_odd_result_order.html?raw=1
+ license of original test:
+ " Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ "
+-->
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Test IndexedDB: result property after deleting existing and non-existing record");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ indexedDB = evalAndLog("indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;");
+ shouldBeFalse("indexedDB == null");
+
+ name = window.location.pathname;
+ description = "My Test Database";
+ request = evalAndLog("indexedDB.open(name, description)");
+ request._onsuccess_ = openSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function openSuccess()
+{
+ db = evalAndLog("db = event.target.result");
+ request = evalAndLog("request = db.setVersion('1')");
+ request._onsuccess_ = createObjectStore;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function createObjectStore()
+{
+ deleteAllObjectStores(db);
+ objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { keyPath: 'id', autoIncrement: true });");
+ request = evalAndLog("request = objectStore.add({});");
+ request._onsuccess_ = deleteRecord1;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function deleteRecord1()
+{
+ id = evalAndLog("id = event.target.result;");
+ request = evalAndLog("request = objectStore.delete(id);");
+ request._onsuccess_ = deleteRecord2;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function deleteRecord2()
+{
+ shouldBe("event.target.result", "true");
+ request = evalAndLog("request = objectStore.delete(id);");
+ request._onsuccess_ = finalCheck;
+ request._onerror_ = unexpectedSuccessCallback;
+}
+
+function finalCheck()
+{
+ shouldBe("event.target.result", "false");
+ done();
+}
+
+test();
+
+</script>
+</body>
+</html>
Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt (99228 => 99229)
--- trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt 2011-11-03 19:41:31 UTC (rev 99229)
@@ -90,7 +90,10 @@
PASS event.target.result.x is "foo"
store.delete('key')
removeSuccess():
-PASS event.target.result is null
+PASS event.target.result is true
+store.delete('key')
+removeSuccessButFalse():
+PASS event.target.result is false
store = event.target.source
Passing an invalid key into store.get().
Expecting exception from store.get([])
Modified: trunk/LayoutTests/storage/indexeddb/objectstore-basics.html (99228 => 99229)
--- trunk/LayoutTests/storage/indexeddb/objectstore-basics.html 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/LayoutTests/storage/indexeddb/objectstore-basics.html 2011-11-03 19:41:31 UTC (rev 99229)
@@ -236,7 +236,17 @@
function removeSuccess()
{
debug("removeSuccess():");
- shouldBeNull("event.target.result");
+ shouldBe("event.target.result", "true");
+
+ request = evalAndLog("store.delete('key')");
+ request._onsuccess_ = removeSuccessButFalse;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function removeSuccessButFalse()
+{
+ debug("removeSuccessButFalse():");
+ shouldBe("event.target.result", "false");
var store = evalAndLog("store = event.target.source");
debug("Passing an invalid key into store.get().");
Modified: trunk/Source/WebCore/ChangeLog (99228 => 99229)
--- trunk/Source/WebCore/ChangeLog 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/Source/WebCore/ChangeLog 2011-11-03 19:41:31 UTC (rev 99229)
@@ -1,3 +1,31 @@
+2011-11-03 Joshua Bell <[email protected]>
+
+ IndexedDB result of deleting a record should be true or false
+ https://bugs.webkit.org/show_bug.cgi?id=60197
+
+ Reviewed by David Levin.
+
+ IDBObjectStore.delete() was incorrectly firing an error if there
+ was no record to remove. Match the spec, and return true/false
+ as success values instead. Bring JSC binding implementation of
+ SerializedScriptValue more in line with V8 version for methods
+ called from IDB code.
+
+ Test: storage/indexeddb/mozilla/delete-result.html
+
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::SerializedScriptValue::createFromWire):
+ (WebCore::SerializedScriptValue::undefinedValue):
+ (WebCore::SerializedScriptValue::booleanValue):
+ * bindings/js/SerializedScriptValue.h:
+ * bindings/v8/SerializedScriptValue.cpp:
+ (WebCore::SerializedScriptValue::nullValue):
+ (WebCore::SerializedScriptValue::undefinedValue):
+ (WebCore::SerializedScriptValue::booleanValue):
+ * bindings/v8/SerializedScriptValue.h:
+ * storage/IDBObjectStoreBackendImpl.cpp:
+ (WebCore::IDBObjectStoreBackendImpl::deleteInternal):
+
2011-11-03 Adam Barth <[email protected]>
Implement allow-popups for iframe@sandbox
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (99228 => 99229)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp 2011-11-03 19:41:31 UTC (rev 99229)
@@ -126,6 +126,8 @@
* | IntTag <value:int32_t>
* | ZeroTag
* | OneTag
+ * | FalseTag
+ * | TrueTag
* | DoubleTag <value:double>
* | DateTag <value:double>
* | String
@@ -272,6 +274,18 @@
return writeLittleEndian(out, s.impl()->characters(), s.length());
}
+ static void serializeUndefined(Vector<uint8_t>& out)
+ {
+ writeLittleEndian(out, CurrentVersion);
+ writeLittleEndian<uint8_t>(out, UndefinedTag);
+ }
+
+ static void serializeBoolean(bool value, Vector<uint8_t>& out)
+ {
+ writeLittleEndian(out, CurrentVersion);
+ writeLittleEndian<uint8_t>(out, value ? TrueTag : FalseTag);
+ }
+
private:
CloneSerializer(ExecState* exec, MessagePortArray* messagePorts, Vector<uint8_t>& out)
: CloneBase(exec)
@@ -1466,6 +1480,20 @@
return emptyValue.get();
}
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue()
+{
+ Vector<uint8_t> buffer;
+ CloneSerializer::serializeUndefined(buffer);
+ return adoptRef(new SerializedScriptValue(buffer));
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value)
+{
+ Vector<uint8_t> buffer;
+ CloneSerializer::serializeBoolean(value, buffer);
+ return adoptRef(new SerializedScriptValue(buffer));
+}
+
void SerializedScriptValue::maybeThrowExceptionIfSerializationFailed(ExecState* exec, SerializationReturnCode code)
{
if (code == SuccessfullyCompleted)
Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.h (99228 => 99229)
--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.h 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.h 2011-11-03 19:41:31 UTC (rev 99229)
@@ -68,6 +68,8 @@
static PassRefPtr<SerializedScriptValue> create();
static SerializedScriptValue* nullValue();
+ static PassRefPtr<SerializedScriptValue> undefinedValue();
+ static PassRefPtr<SerializedScriptValue> booleanValue(bool value);
String toString();
Modified: trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp (99228 => 99229)
--- trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/Source/WebCore/bindings/v8/SerializedScriptValue.cpp 2011-11-03 19:41:31 UTC (rev 99229)
@@ -1931,6 +1931,8 @@
SerializedScriptValue* SerializedScriptValue::nullValue()
{
+ // FIXME: This is not thread-safe. Move caching to callers.
+ // https://bugs.webkit.org/show_bug.cgi?id=70833
DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, nullValue, (0));
if (!nullValue) {
Writer writer;
@@ -1941,18 +1943,25 @@
return nullValue.get();
}
-SerializedScriptValue* SerializedScriptValue::undefinedValue()
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue()
{
- DEFINE_STATIC_LOCAL(RefPtr<SerializedScriptValue>, undefinedValue, (0));
- if (!undefinedValue) {
- Writer writer;
- writer.writeUndefined();
- String wireData = StringImpl::adopt(writer.data());
- undefinedValue = adoptRef(new SerializedScriptValue(wireData));
- }
- return undefinedValue.get();
+ Writer writer;
+ writer.writeUndefined();
+ String wireData = StringImpl::adopt(writer.data());
+ return adoptRef(new SerializedScriptValue(wireData));
}
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value)
+{
+ Writer writer;
+ if (value)
+ writer.writeTrue();
+ else
+ writer.writeFalse();
+ String wireData = StringImpl::adopt(writer.data());
+ return adoptRef(new SerializedScriptValue(wireData));
+}
+
PassRefPtr<SerializedScriptValue> SerializedScriptValue::release()
{
RefPtr<SerializedScriptValue> result = adoptRef(new SerializedScriptValue(m_data));
Modified: trunk/Source/WebCore/bindings/v8/SerializedScriptValue.h (99228 => 99229)
--- trunk/Source/WebCore/bindings/v8/SerializedScriptValue.h 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/Source/WebCore/bindings/v8/SerializedScriptValue.h 2011-11-03 19:41:31 UTC (rev 99229)
@@ -60,7 +60,8 @@
static PassRefPtr<SerializedScriptValue> create();
static SerializedScriptValue* nullValue();
- static SerializedScriptValue* undefinedValue();
+ static PassRefPtr<SerializedScriptValue> undefinedValue();
+ static PassRefPtr<SerializedScriptValue> booleanValue(bool value);
PassRefPtr<SerializedScriptValue> release();
Modified: trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp (99228 => 99229)
--- trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp 2011-11-03 19:29:20 UTC (rev 99228)
+++ trunk/Source/WebCore/storage/IDBObjectStoreBackendImpl.cpp 2011-11-03 19:41:31 UTC (rev 99229)
@@ -314,7 +314,7 @@
{
RefPtr<IDBBackingStore::ObjectStoreRecordIdentifier> recordIdentifier = objectStore->m_backingStore->createInvalidRecordIdentifier();
if (!objectStore->m_backingStore->keyExistsInObjectStore(objectStore->m_databaseId, objectStore->id(), *key, recordIdentifier.get())) {
- callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "Key does not exist in the object store."));
+ callbacks->onSuccess(SerializedScriptValue::booleanValue(false));
return;
}
@@ -327,7 +327,7 @@
}
objectStore->m_backingStore->deleteObjectStoreRecord(objectStore->m_databaseId, objectStore->id(), recordIdentifier.get());
- callbacks->onSuccess(SerializedScriptValue::nullValue());
+ callbacks->onSuccess(SerializedScriptValue::booleanValue(true));
}
void IDBObjectStoreBackendImpl::clear(PassRefPtr<IDBCallbacks> prpCallbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec)