https://bugs.webkit.org/show_bug.cgi?id=150711
Reviewed by Alex Christensen.
Source/WebCore:
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):
LayoutTests:
* storage/indexeddb/modern/basic-add-expected.txt: Added.
* storage/indexeddb/modern/basic-add.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191795
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-10-30 Brady Eidson <beidson@apple.com>
+
+ 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 <ryanhaddad@apple.com>
Removing flaky expectations for storage/indexeddb/modern tests since the failure was fixed in r191758
--- /dev/null
+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.
+
--- /dev/null
+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>
+2015-10-30 Brady Eidson <beidson@apple.com>
+
+ 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 <hs85.jeong@samsung.com>
Use modern for-loops in WebCore/dom.
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)
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)
Ref<IDBRequest> IDBTransaction::requestGetRecord(ScriptExecutionContext& context, IDBObjectStore& objectStore, IDBKey& key)
{
- LOG(IndexedDB, "IDBTransaction::requestPutOrAdd");
+ LOG(IndexedDB, "IDBTransaction::requestGetRecord");
ASSERT(isActive());
ASSERT(key.isValid());