[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jorlow at chromium.org jorlow at chromium.org
Wed Dec 22 14:46:27 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f4b8cd7807d7016a6f1fd05e9d1f3f29486ba4c3
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 19 22:10:16 2010 +0000

    2010-10-19  Jeremy Orlow  <jorlow at chromium.org>
    
            Reviewed by Nate Chapin.
    
            Fix multiple index support in IndexedDB
            https://bugs.webkit.org/show_bug.cgi?id=47919
    
            Modify an existing test to verify behavior and add another test for
            something I thought might have been related (but wasn't, but it still
            seems like a good test).
    
            * storage/indexeddb/index-basics-expected.txt:
            * storage/indexeddb/index-basics.html:
            * storage/indexeddb/queued-commands-expected.txt: Added.
            * storage/indexeddb/queued-commands.html: Added.
    2010-10-19  Jeremy Orlow  <jorlow at chromium.org>
    
            Reviewed by Nate Chapin.
    
            Fix multiple index support in IndexedDB
            https://bugs.webkit.org/show_bug.cgi?id=47919
    
            Fix 2 bugs that caused the IndexData of all but the last index to be
            properly updated:
            * The objectStoreDataId is NOT unique if there are multiple indexes. So
              remove the constraint.
            * Do not delete all existing entries with that objectStoreDataId before
              adding an entry for each index. Only do it once at the beginning.
    
            Test: storage/indexeddb/queued-commands.html
                + index-basics.html modified
    
            * storage/IDBFactoryBackendImpl.cpp:
            (WebCore::createTables):
            * storage/IDBObjectStoreBackendImpl.cpp:
            (WebCore::deleteIndexData):
            (WebCore::putIndexData):
            (WebCore::IDBObjectStoreBackendImpl::putInternal):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70093 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index e025a99..31d85cb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,19 @@
+2010-10-19  Jeremy Orlow  <jorlow at chromium.org>
+
+        Reviewed by Nate Chapin.
+
+        Fix multiple index support in IndexedDB
+        https://bugs.webkit.org/show_bug.cgi?id=47919
+
+        Modify an existing test to verify behavior and add another test for
+        something I thought might have been related (but wasn't, but it still
+        seems like a good test).
+
+        * storage/indexeddb/index-basics-expected.txt:
+        * storage/indexeddb/index-basics.html:
+        * storage/indexeddb/queued-commands-expected.txt: Added.
+        * storage/indexeddb/queued-commands.html: Added.
+
 2010-10-19  James Robinson  <jamesr at chromium.org>
 
         Update chromium expectations.
diff --git a/LayoutTests/storage/indexeddb/index-basics-expected.txt b/LayoutTests/storage/indexeddb/index-basics-expected.txt
index ccb68a3..0869d95 100644
--- a/LayoutTests/storage/indexeddb/index-basics-expected.txt
+++ b/LayoutTests/storage/indexeddb/index-basics-expected.txt
@@ -44,6 +44,7 @@ PASS trans !== null is true
 Deleted all object stores.
 db.createObjectStore('storeName', null)
 store.createIndex('indexName', 'x')
+store.createIndex('indexName2', 'y', false)
 PASS 'name' in indexObject is true
 PASS indexObject.name is "indexName"
 PASS 'storeName' in indexObject is true
@@ -108,6 +109,24 @@ PASS 'readyState' in event.target is true
 PASS event.target.readyState is event.target.DONE
 
 PASS event.result is "key"
+indexObject2.getKey('zzz')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+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 "key"
 indexObject.get('value')
 PASS 'onsuccess' in result is true
 PASS 'onerror' in result is true
diff --git a/LayoutTests/storage/indexeddb/index-basics.html b/LayoutTests/storage/indexeddb/index-basics.html
index 49cac00..f7257f1 100644
--- a/LayoutTests/storage/indexeddb/index-basics.html
+++ b/LayoutTests/storage/indexeddb/index-basics.html
@@ -45,9 +45,10 @@ function deleteExisting()
 }
 
 function createIndex()
-{
+{
     window.store = evalAndLog("db.createObjectStore('storeName', null)");
     window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
+    window.indexObject2 = evalAndLog("store.createIndex('indexName2', 'y', false)");
     addData();
 }
 
@@ -97,6 +98,17 @@ function getObjectData()
     verifySuccessEvent(event);
     shouldBeEqualToString("event.result", "key");
 
+    result = evalAndLog("indexObject2.getKey('zzz')");
+    verifyResult(result);
+    result.onsuccess = getObjectData2;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function getObjectData2()
+{
+    verifySuccessEvent(event);
+    shouldBeEqualToString("event.result", "key");
+
     result = evalAndLog("indexObject.get('value')");
     verifyResult(result);
     result.onsuccess = getDataFail;
diff --git a/LayoutTests/storage/indexeddb/queued-commands-expected.txt b/LayoutTests/storage/indexeddb/queued-commands-expected.txt
new file mode 100644
index 0000000..e2e20af
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/queued-commands-expected.txt
@@ -0,0 +1,104 @@
+Verify that queuing up several commands works (and they all fire).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitIndexedDB.open('name', 'description')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+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
+
+db = event.result
+db.setVersion('new version')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+setVersionSuccess():
+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
+
+trans = event.result
+PASS trans !== null is true
+Deleted all object stores.
+db.createObjectStore('storeName', null)
+store.createIndex('indexName', 'x')
+store.add({x: 'value', y: 'zzz'}, 'key')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+store.add({x: 'value2', y: 'zzz2'}, 'key2')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+store.put({x: 'valu2', y: 'zz2'}, 'ky2')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'readyState' in result is true
+An event should fire shortly...
+
+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 0 is 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 1 is 1
+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 2 is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/queued-commands.html b/LayoutTests/storage/indexeddb/queued-commands.html
new file mode 100644
index 0000000..7dc94c3
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/queued-commands.html
@@ -0,0 +1,87 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Verify that queuing up several commands works (and they all fire).");
+if (window.layoutTestController) 
+    layoutTestController.waitUntilDone();
+
+function test()
+{
+    result = evalAndLog("webkitIndexedDB.open('name', 'description')");
+    verifyResult(result);
+    result.onsuccess = setVersion;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function setVersion()
+{
+    verifySuccessEvent(event);
+    db = evalAndLog("db = event.result");
+
+    result = evalAndLog("db.setVersion('new version')");
+    verifyResult(result);
+    result.onsuccess = deleteExisting;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function deleteExisting()
+{
+    debug("setVersionSuccess():");
+    verifySuccessEvent(event);
+    window.trans = evalAndLog("trans = event.result");
+    shouldBeTrue("trans !== null");
+    trans.onabort = unexpectedAbortCallback;
+
+    deleteAllObjectStores(db, createIndex);
+}
+
+function createIndex()
+{
+    window.store = evalAndLog("db.createObjectStore('storeName', null)");
+    window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
+
+    result = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
+    verifyResult(result);
+    result.onsuccess = function() { verifyAdd(0); };
+    result.onerror = unexpectedErrorCallback;
+
+    result = evalAndLog("store.add({x: 'value2', y: 'zzz2'}, 'key2')");
+    verifyResult(result);
+    result.onsuccess = function() { verifyAdd(1); };
+    result.onerror = unexpectedErrorCallback;
+
+    result = evalAndLog("store.put({x: 'valu2', y: 'zz2'}, 'ky2')");
+    verifyResult(result);
+    result.onsuccess = function() { verifyAdd(2); };
+    result.onerror = unexpectedErrorCallback;
+
+    window.addCount = 0;
+}
+
+function verifyAdd(expected)
+{
+    verifySuccessEvent(event);
+    shouldBe("" + addCount++, "" + expected);
+
+    if (addCount == 3)
+        done();
+    if (addCount > 3)
+        testFailed("Unexpected call to verifyAdd!");
+}
+
+test();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 1f46aa6..456c94c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-10-19  Jeremy Orlow  <jorlow at chromium.org>
+
+        Reviewed by Nate Chapin.
+
+        Fix multiple index support in IndexedDB
+        https://bugs.webkit.org/show_bug.cgi?id=47919
+
+        Fix 2 bugs that caused the IndexData of all but the last index to be
+        properly updated:
+        * The objectStoreDataId is NOT unique if there are multiple indexes. So
+          remove the constraint.
+        * Do not delete all existing entries with that objectStoreDataId before
+          adding an entry for each index. Only do it once at the beginning.
+
+        Test: storage/indexeddb/queued-commands.html
+            + index-basics.html modified
+
+        * storage/IDBFactoryBackendImpl.cpp:
+        (WebCore::createTables):
+        * storage/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::deleteIndexData):
+        (WebCore::putIndexData):
+        (WebCore::IDBObjectStoreBackendImpl::putInternal):
+
 2010-10-19  Martin Robinson  <mrobinson at igalia.com>
 
         Fix the GTK+ build after r70072. The logic looks incorrect, but
diff --git a/WebCore/storage/IDBFactoryBackendImpl.cpp b/WebCore/storage/IDBFactoryBackendImpl.cpp
index 3063b41..c18294d 100644
--- a/WebCore/storage/IDBFactoryBackendImpl.cpp
+++ b/WebCore/storage/IDBFactoryBackendImpl.cpp
@@ -99,7 +99,7 @@ static bool createTables(SQLiteDatabase* sqliteDatabase)
         "CREATE UNIQUE INDEX IF NOT EXISTS ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)",
 
         "DROP TABLE IF EXISTS IndexData",
-        "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL UNIQUE REFERENCES ObjectStoreData(id))",
+        "CREATE TABLE IF NOT EXISTS IndexData (id INTEGER PRIMARY KEY, indexId INTEGER NOT NULL REFERENCES Indexes(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, objectStoreDataId INTEGER NOT NULL REFERENCES ObjectStoreData(id))",
         "DROP INDEX IF EXISTS IndexData_composit",
         "CREATE INDEX IF NOT EXISTS IndexData_composit ON IndexData(keyString, keyDate, keyNumber, indexId)",
         "DROP INDEX IF EXISTS IndexData_objectStoreDataId",
diff --git a/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/WebCore/storage/IDBObjectStoreBackendImpl.cpp
index 1f98612..f3aee91 100644
--- a/WebCore/storage/IDBObjectStoreBackendImpl.cpp
+++ b/WebCore/storage/IDBObjectStoreBackendImpl.cpp
@@ -154,15 +154,18 @@ static bool putObjectStoreData(SQLiteDatabase& db, IDBKey* key, SerializedScript
     return true;
 }
 
-static int putIndexData(SQLiteDatabase& db, IDBKey* key, int64_t indexId, int64_t objectStoreDataId)
+static bool deleteIndexData(SQLiteDatabase& db, int64_t objectStoreDataId)
 {
     SQLiteStatement deleteQuery(db, "DELETE FROM IndexData WHERE objectStoreDataId = ?");
     if (deleteQuery.prepare() != SQLResultOk)
         return false;
     deleteQuery.bindInt64(1, objectStoreDataId);
-    if (deleteQuery.step() != SQLResultDone)
-        return false;
 
+    return deleteQuery.step() == SQLResultDone;
+}
+
+static bool putIndexData(SQLiteDatabase& db, IDBKey* key, int64_t indexId, int64_t objectStoreDataId)
+{
     SQLiteStatement putQuery(db, "INSERT INTO IndexData (keyString, keyDate, keyNumber, indexId, objectStoreDataId) VALUES (?, ?, ?, ?, ?)");
     if (putQuery.prepare() != SQLResultOk)
         return false;
@@ -191,6 +194,8 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
     RefPtr<SerializedScriptValue> value = prpValue;
     RefPtr<IDBKey> key = prpKey;
 
+    // FIXME: Support auto-increment.
+
     if (!objectStore->m_keyPath.isNull()) {
         if (key) {
             callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "A key was supplied for an objectStore that has a keyPath."));
@@ -241,6 +246,13 @@ void IDBObjectStoreBackendImpl::putInternal(ScriptExecutionContext*, PassRefPtr<
         return;
     }
 
+    if (!deleteIndexData(objectStore->sqliteDatabase(), dataRowId)) {
+        // FIXME: The Indexed Database specification does not have an error code dedicated to I/O errors.
+        callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Error writing data to stable storage."));
+        transaction->abort();
+        return;
+    }
+
     int i = 0;
     for (IndexMap::iterator it = objectStore->m_indexes.begin(); it != objectStore->m_indexes.end(); ++it, ++i) {
         if (!putIndexData(objectStore->sqliteDatabase(), indexKeys[i].get(), it->second->id(), dataRowId)) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list