Diff
Modified: trunk/LayoutTests/ChangeLog (191794 => 191795)
--- trunk/LayoutTests/ChangeLog 2015-10-30 17:12:38 UTC (rev 191794)
+++ trunk/LayoutTests/ChangeLog 2015-10-30 17:17:06 UTC (rev 191795)
@@ -1,3 +1,13 @@
+2015-10-30 Brady Eidson <[email protected]>
+
+ Modern IDB: IDBObjectStore.add() support.
+ https://bugs.webkit.org/show_bug.cgi?id=150711
+
+ Reviewed by Alex Christensen.
+
+ * storage/indexeddb/modern/basic-add-expected.txt: Added.
+ * storage/indexeddb/modern/basic-add.html: Added.
+
2015-10-29 Ryan Haddad <[email protected]>
Removing flaky expectations for storage/indexeddb/modern tests since the failure was fixed in r191758
Added: trunk/LayoutTests/storage/indexeddb/modern/basic-add-expected.txt (0 => 191795)
--- trunk/LayoutTests/storage/indexeddb/modern/basic-add-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/basic-add-expected.txt 2015-10-30 17:17:06 UTC (rev 191795)
@@ -0,0 +1,10 @@
+ALERT: Upgrade needed: Old version - 0 New version - 1
+ALERT: [object IDBTransaction] - versionchange
+ALERT: [object IDBDatabase]
+ALERT: put 1 succeeded - key was 'foo'
+ALERT: put 2 failed - error
+ALERT: get succeeded - key was 'bar'
+ALERT: version change transaction completed
+ALERT: Done
+This test does basic testing of IDBObjectStore.add(), making sure that an attempt to overwrite an already-existing key fails with the appropriate error.
+
Added: trunk/LayoutTests/storage/indexeddb/modern/basic-add.html (0 => 191795)
--- trunk/LayoutTests/storage/indexeddb/modern/basic-add.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/modern/basic-add.html 2015-10-30 17:17:06 UTC (rev 191795)
@@ -0,0 +1,77 @@
+This test does basic testing of IDBObjectStore.add(), making sure that an attempt to overwrite an already-existing key fails with the appropriate error.<br>
+<script>
+
+if (window.testRunner) {
+ testRunner.waitUntilDone();
+ testRunner.dumpAsText();
+}
+
+var request = window.indexedDB.open("NewDatabaseAddTestDatabase");
+
+function done()
+{
+ alert("Done");
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+
+request._onupgradeneeded_ = function(event) {
+ alert("Upgrade needed: Old version - " + event.oldVersion + " New version - " + event.newVersion);
+
+ var tx = request.transaction;
+ var db = event.target.result;
+
+ alert(tx + " - " + tx.mode);
+ alert(db);
+
+ var os = db.createObjectStore("TestObjectStore");
+ var putRequest1 = os.add("bar", "foo");
+ var putRequest2 = os.add("baz", "foo");
+
+ putRequest1._onsuccess_ = function(event) {
+ alert("put 1 succeeded - key was '" + putRequest1.result + "'");
+ }
+
+ putRequest1._onerror_ = function(event) {
+ alert("put 1 unexpectedly failed - " + event);
+ done();
+ }
+
+ putRequest2._onsuccess_ = function(event) {
+ alert("put 2 unexpectedly succeeded - key was '" + putRequest2.result + "'");
+ done();
+ }
+
+ putRequest2._onerror_ = function(event) {
+ alert("put 2 failed - " + event.type);
+
+ var getRequest = os.get("foo");
+
+ getRequest._onsuccess_ = function(event) {
+ alert("get succeeded - key was '" + getRequest.result + "'");
+ }
+
+ getRequest._onerror_ = function(event) {
+ alert("get unexpectedly failed - " + event.type);
+ done();
+ }
+
+ event.stopPropagation();
+ }
+
+ tx._onabort_ = function(event) {
+ alert("version change transaction unexpected abort");
+ done();
+ }
+
+ tx._oncomplete_ = function(event) {
+ alert("version change transaction completed");
+ done();
+ }
+
+ tx._onerror_ = function(event) {
+ alert("version change transaction unexpected error - " + event);
+ done();
+ }
+}
+</script>
Modified: trunk/Source/WebCore/ChangeLog (191794 => 191795)
--- trunk/Source/WebCore/ChangeLog 2015-10-30 17:12:38 UTC (rev 191794)
+++ trunk/Source/WebCore/ChangeLog 2015-10-30 17:17:06 UTC (rev 191795)
@@ -1,3 +1,18 @@
+2015-10-30 Brady Eidson <[email protected]>
+
+ Modern IDB: IDBObjectStore.add() support.
+ https://bugs.webkit.org/show_bug.cgi?id=150711
+
+ Reviewed by Alex Christensen.
+
+ Test: storage/indexeddb/modern/basic-add.html
+
+ * Modules/indexeddb/client/IDBObjectStoreImpl.cpp:
+ (WebCore::IDBClient::IDBObjectStore::add):
+
+ * Modules/indexeddb/client/IDBTransactionImpl.cpp:
+ (WebCore::IDBClient::IDBTransaction::requestGetRecord):
+
2015-10-30 Hunseop Jeong <[email protected]>
Use modern for-loops in WebCore/dom.
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp (191794 => 191795)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2015-10-30 17:12:38 UTC (rev 191794)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBObjectStoreImpl.cpp 2015-10-30 17:17:06 UTC (rev 191795)
@@ -86,9 +86,9 @@
return m_info.autoIncrement();
}
-RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState&, Deprecated::ScriptValue&, ExceptionCode&)
+RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& state, Deprecated::ScriptValue& value, ExceptionCode& ec)
{
- RELEASE_ASSERT_NOT_REACHED();
+ return putOrAdd(state, value, nullptr, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, ec);
}
RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& state, Deprecated::ScriptValue& value, ExceptionCode& ec)
@@ -156,9 +156,10 @@
RELEASE_ASSERT_NOT_REACHED();
}
-RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState&, Deprecated::ScriptValue&, const Deprecated::ScriptValue&, ExceptionCode&)
+RefPtr<WebCore::IDBRequest> IDBObjectStore::add(JSC::ExecState& execState, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& key, ExceptionCode& ec)
{
- RELEASE_ASSERT_NOT_REACHED();
+ auto idbKey = scriptValueToIDBKey(execState, key);
+ return putOrAdd(execState, value, idbKey, IndexedDB::ObjectStoreOverwriteMode::NoOverwrite, ec);
}
RefPtr<WebCore::IDBRequest> IDBObjectStore::put(JSC::ExecState& execState, Deprecated::ScriptValue& value, const Deprecated::ScriptValue& key, ExceptionCode& ec)
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp (191794 => 191795)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2015-10-30 17:12:38 UTC (rev 191794)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp 2015-10-30 17:17:06 UTC (rev 191795)
@@ -387,7 +387,7 @@
Ref<IDBRequest> IDBTransaction::requestGetRecord(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBKey& key)
{
- LOG(IndexedDB, "IDBTransaction::requestPutOrAdd");
+ LOG(IndexedDB, "IDBTransaction::requestGetRecord");
ASSERT(isActive());
ASSERT(key.isValid());