[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 12:28:50 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 77b220286d640a382cba758d5a555eba9f988514
Author: jorlow at chromium.org <jorlow at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 24 15:44:07 2010 +0000

    2010-08-24  Jeremy Orlow  <jorlow at chromium.org>
    
            Reviewed by Steve Block.
    
            IndexedDB needs to manually delete all objectStore data and indexes
            https://bugs.webkit.org/show_bug.cgi?id=44522
    
            * storage/indexeddb/objectstore-removeobjectstore-expected.txt: Added.
            * storage/indexeddb/objectstore-removeobjectstore.html: Added.
            * storage/indexeddb/resources/shared.js:
            (unexpectedSuccessCallback):
    2010-08-24  Jeremy Orlow  <jorlow at chromium.org>
    
            Reviewed by Steve Block.
    
            IndexedDB needs to manually delete all objectStore data and indexes
            https://bugs.webkit.org/show_bug.cgi?id=44522
    
            Apparently it's only newer versions of SQLite that handle cascade
            delete.  The rest silently fail.  So do it manually.
    
            Test: storage/indexeddb/objectstore-removeobjectstore.html
    
            * storage/IDBDatabaseBackendImpl.cpp:
            (WebCore::IDBDatabaseBackendImpl::createObjectStore):
            (WebCore::doDelete):
            (WebCore::IDBDatabaseBackendImpl::removeObjectStore):
            * storage/IDBDatabaseBackendImpl.h:
            * storage/IDBFactoryBackendImpl.cpp:
            (WebCore::createTables):
            * storage/IDBObjectStoreBackendImpl.cpp:
            (WebCore::IDBObjectStoreBackendImpl::removeIndex):
            * storage/IDBObjectStoreBackendImpl.h:
            (WebCore::IDBObjectStoreBackendImpl::create):
            (WebCore::IDBObjectStoreBackendImpl::id):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65902 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 0897345..c548d72 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-24  Jeremy Orlow  <jorlow at chromium.org>
+
+        Reviewed by Steve Block.
+
+        IndexedDB needs to manually delete all objectStore data and indexes
+        https://bugs.webkit.org/show_bug.cgi?id=44522
+
+        * storage/indexeddb/objectstore-removeobjectstore-expected.txt: Added.
+        * storage/indexeddb/objectstore-removeobjectstore.html: Added.
+        * storage/indexeddb/resources/shared.js:
+        (unexpectedSuccessCallback):
+
 2010-08-24  Sam Weinig  <sam at webkit.org>
 
         Update skipped list for WebKit2.
diff --git a/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
new file mode 100644
index 0000000..0a3d938
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
@@ -0,0 +1,166 @@
+Test IndexedDB's IDBObjectStore.removeObjectStore().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+indexedDB.open('name', 'description')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+db = event.result
+db.createObjectStore('storeName', null)
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+event.result.add('value', 'key')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+event.source.get('key')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS event.result is "value"
+event.source.createIndex('indexName', '')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS event.source.indexNames.contains('indexName') is true
+db.removeObjectStore('storeName')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+db.createObjectStore('storeName', null)
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+event.result.get('key')
+PASS 'onsuccess' in result is true
+PASS 'onerror' in result is true
+PASS 'abort' 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
+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 'abort' in event.target is true
+PASS 'readyState' in event.target is true
+PASS event.target.readyState is event.target.DONE
+
+PASS event.code is 2
+PASS event.source.indexNames.contains('indexName') is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html
new file mode 100644
index 0000000..e842f5b
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/objectstore-removeobjectstore.html
@@ -0,0 +1,115 @@
+<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("Test IndexedDB's IDBObjectStore.removeObjectStore().");
+if (window.layoutTestController) 
+    layoutTestController.waitUntilDone();
+
+function test()
+{
+    result = evalAndLog("indexedDB.open('name', 'description')");
+    verifyResult(result);
+    result.onsuccess = createObjectStore;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function createObjectStore()
+{
+    verifySuccessEvent(event);
+    db = evalAndLog("db = event.result");
+
+    deleteAllObjectStores(db);
+
+    result = evalAndLog("db.createObjectStore('storeName', null)");
+    verifyResult(result);
+    result.onsuccess = addValue;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function addValue()
+{
+    verifySuccessEvent(event);
+
+    result = evalAndLog("event.result.add('value', 'key')");
+    verifyResult(result);
+    result.onsuccess = getValue;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function getValue()
+{
+    verifySuccessEvent(event);
+
+    result = evalAndLog("event.source.get('key')");
+    verifyResult(result);
+    result.onsuccess = addIndex;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function addIndex()
+{
+    verifySuccessEvent(event);
+    shouldBeEqualToString("event.result", "value");
+
+    result = evalAndLog("event.source.createIndex('indexName', '')");
+    verifyResult(result);
+    result.onsuccess = removeObjectStore;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function removeObjectStore()
+{
+    verifySuccessEvent(event);
+    shouldBeTrue("event.source.indexNames.contains('indexName')");
+
+    result = evalAndLog("db.removeObjectStore('storeName')");
+    verifyResult(result);
+    result.onsuccess = createObjectStoreAgain;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function createObjectStoreAgain()
+{
+    verifySuccessEvent(event);
+
+    result = evalAndLog("db.createObjectStore('storeName', null)");
+    verifyResult(result);
+    result.onsuccess = getValueAgain;
+    result.onerror = unexpectedErrorCallback;
+}
+
+function getValueAgain()
+{
+    verifySuccessEvent(event);
+
+    result = evalAndLog("event.result.get('key')");
+    verifyResult(result);
+    result.onsuccess = unexpectedSuccessCallback;
+    result.onerror = verifyError;
+}
+
+function verifyError()
+{
+    verifyErrorEvent(event);
+    // FIXME: Should just be IDBDatabaseException.NOT_FOUND_ERR but that doesn't work yet.
+    shouldBe("event.code", "2");
+    shouldBeFalse("event.source.indexNames.contains('indexName')");
+
+    done();
+}
+
+test();
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>
diff --git a/LayoutTests/storage/indexeddb/resources/shared.js b/LayoutTests/storage/indexeddb/resources/shared.js
index 9f5e11f..112bf18 100644
--- a/LayoutTests/storage/indexeddb/resources/shared.js
+++ b/LayoutTests/storage/indexeddb/resources/shared.js
@@ -51,6 +51,14 @@ function verifyResult(result)
     debug("");
 }
 
+function unexpectedSuccessCallback()
+{
+    testFailed("Success function called unexpectedly.");
+    debug("");
+    verifySuccessEvent(event);
+    done();
+}
+
 function unexpectedErrorCallback()
 {
     testFailed("Error function called unexpectedly: (" + event.code + ") " + event.message);
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4b02273..aceecc3 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2010-08-24  Jeremy Orlow  <jorlow at chromium.org>
+
+        Reviewed by Steve Block.
+
+        IndexedDB needs to manually delete all objectStore data and indexes
+        https://bugs.webkit.org/show_bug.cgi?id=44522
+
+        Apparently it's only newer versions of SQLite that handle cascade
+        delete.  The rest silently fail.  So do it manually.
+
+        Test: storage/indexeddb/objectstore-removeobjectstore.html
+
+        * storage/IDBDatabaseBackendImpl.cpp:
+        (WebCore::IDBDatabaseBackendImpl::createObjectStore):
+        (WebCore::doDelete):
+        (WebCore::IDBDatabaseBackendImpl::removeObjectStore):
+        * storage/IDBDatabaseBackendImpl.h:
+        * storage/IDBFactoryBackendImpl.cpp:
+        (WebCore::createTables):
+        * storage/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::removeIndex):
+        * storage/IDBObjectStoreBackendImpl.h:
+        (WebCore::IDBObjectStoreBackendImpl::create):
+        (WebCore::IDBObjectStoreBackendImpl::id):
+
 2010-08-23  Sam Weinig  <sam at webkit.org>
 
         Reviewed by Adam Barth.
diff --git a/WebCore/storage/IDBDatabaseBackendImpl.cpp b/WebCore/storage/IDBDatabaseBackendImpl.cpp
index a912c29..23bc44e 100644
--- a/WebCore/storage/IDBDatabaseBackendImpl.cpp
+++ b/WebCore/storage/IDBDatabaseBackendImpl.cpp
@@ -32,6 +32,7 @@
 #include "IDBTransactionCoordinator.h"
 #include "SQLiteDatabase.h"
 #include "SQLiteStatement.h"
+#include "SQLiteTransaction.h"
 
 #if ENABLE(INDEXED_DATABASE)
 
@@ -141,10 +142,10 @@ void IDBDatabaseBackendImpl::createObjectStore(const String& name, const String&
     ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
     int64_t id = sqliteDatabase().lastInsertRowID();
 
-    RefPtr<IDBObjectStoreBackendInterface> objectStore = IDBObjectStoreBackendImpl::create(this, id, name, keyPath, autoIncrement);
+    RefPtr<IDBObjectStoreBackendImpl> objectStore = IDBObjectStoreBackendImpl::create(this, id, name, keyPath, autoIncrement);
     ASSERT(objectStore->name() == name);
     m_objectStores.set(name, objectStore);
-    callbacks->onSuccess(objectStore.release());
+    callbacks->onSuccess(objectStore.get());
 }
 
 PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::objectStore(const String& name, unsigned short mode)
@@ -154,19 +155,31 @@ PassRefPtr<IDBObjectStoreBackendInterface> IDBDatabaseBackendImpl::objectStore(c
     return m_objectStores.get(name);
 }
 
+static void doDelete(SQLiteDatabase& db, const char* sql, int64_t id)
+{
+    SQLiteStatement deleteQuery(db, sql);
+    bool ok = deleteQuery.prepare() == SQLResultOk;
+    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
+    deleteQuery.bindInt64(1, id);
+    ok = deleteQuery.step() == SQLResultDone;
+    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
+}
+
 void IDBDatabaseBackendImpl::removeObjectStore(const String& name, PassRefPtr<IDBCallbacks> callbacks)
 {
-    if (!m_objectStores.contains(name)) {
+    RefPtr<IDBObjectStoreBackendImpl> objectStore = m_objectStores.get(name);
+    if (!objectStore) {
         callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::NOT_FOUND_ERR, "No objectStore with that name exists."));
         return;
     }
 
-    SQLiteStatement deleteQuery(sqliteDatabase(), "DELETE FROM ObjectStores WHERE name = ?");
-    bool ok = deleteQuery.prepare() == SQLResultOk;
-    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
-    deleteQuery.bindText(1, name);
-    ok = deleteQuery.step() == SQLResultDone;
-    ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
+    SQLiteTransaction transaction(sqliteDatabase());
+    transaction.begin();
+    doDelete(sqliteDatabase(), "DELETE FROM ObjectStores WHERE id = ?", objectStore->id());
+    doDelete(sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE objectStoreId = ?", objectStore->id());
+    doDelete(sqliteDatabase(), "DELETE FROM Indexes WHERE objectStoreId = ?", objectStore->id());
+    // FIXME: Delete index data as well.
+    transaction.commit();
 
     m_objectStores.remove(name);
     callbacks->onSuccess();
diff --git a/WebCore/storage/IDBDatabaseBackendImpl.h b/WebCore/storage/IDBDatabaseBackendImpl.h
index 8d32e27..3540b21 100644
--- a/WebCore/storage/IDBDatabaseBackendImpl.h
+++ b/WebCore/storage/IDBDatabaseBackendImpl.h
@@ -35,6 +35,7 @@
 
 namespace WebCore {
 
+class IDBObjectStoreBackendImpl;
 class IDBTransactionCoordinator;
 class SQLiteDatabase;
 
@@ -69,7 +70,7 @@ private:
     String m_description;
     String m_version;
 
-    typedef HashMap<String, RefPtr<IDBObjectStoreBackendInterface> > ObjectStoreMap;
+    typedef HashMap<String, RefPtr<IDBObjectStoreBackendImpl> > ObjectStoreMap;
     ObjectStoreMap m_objectStores;
 
     RefPtr<IDBTransactionCoordinator> m_transactionCoordinator;
diff --git a/WebCore/storage/IDBFactoryBackendImpl.cpp b/WebCore/storage/IDBFactoryBackendImpl.cpp
index 29e8b60..d656128 100644
--- a/WebCore/storage/IDBFactoryBackendImpl.cpp
+++ b/WebCore/storage/IDBFactoryBackendImpl.cpp
@@ -88,12 +88,12 @@ static bool createTables(SQLiteDatabase* sqliteDatabase)
         "CREATE UNIQUE INDEX IF NOT EXISTS ObjectStores_name ON ObjectStores(name)",
 
         "DROP TABLE IF EXISTS Indexes",
-        "CREATE TABLE IF NOT EXISTS Indexes (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id) ON DELETE CASCADE, name TEXT NOT NULL, keyPath TEXT, isUnique INTEGER NOT NULL)",
+        "CREATE TABLE IF NOT EXISTS Indexes (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), name TEXT NOT NULL, keyPath TEXT, isUnique INTEGER NOT NULL)",
         "DROP INDEX IF EXISTS Indexes_composit",
         "CREATE UNIQUE INDEX IF NOT EXISTS Indexes_composit ON Indexes(objectStoreId, name)",
 
         "DROP TABLE IF EXISTS ObjectStoreData",
-        "CREATE TABLE IF NOT EXISTS ObjectStoreData (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id) ON DELETE CASCADE, keyString TEXT, keyDate INTEGER, keyNumber INTEGER, value TEXT NOT NULL)",
+        "CREATE TABLE IF NOT EXISTS ObjectStoreData (id INTEGER PRIMARY KEY, objectStoreId INTEGER NOT NULL REFERENCES ObjectStore(id), keyString TEXT, keyDate INTEGER, keyNumber INTEGER, value TEXT NOT NULL)",
         "DROP INDEX IF EXISTS ObjectStoreData_composit",
         "CREATE UNIQUE INDEX IF NOT EXISTS ObjectStoreData_composit ON ObjectStoreData(keyString, keyDate, keyNumber, objectStoreId)"
         };
diff --git a/WebCore/storage/IDBObjectStoreBackendImpl.cpp b/WebCore/storage/IDBObjectStoreBackendImpl.cpp
index 549d0fa..1b9b76b 100755
--- a/WebCore/storage/IDBObjectStoreBackendImpl.cpp
+++ b/WebCore/storage/IDBObjectStoreBackendImpl.cpp
@@ -259,6 +259,8 @@ void IDBObjectStoreBackendImpl::removeIndex(const String& name, PassRefPtr<IDBCa
     ok = deleteQuery.step() == SQLResultDone;
     ASSERT_UNUSED(ok, ok); // FIXME: Better error handling.
 
+    // FIXME: Delete index data as well.
+
     m_indexes.remove(name);
     callbacks->onSuccess();
 }
diff --git a/WebCore/storage/IDBObjectStoreBackendImpl.h b/WebCore/storage/IDBObjectStoreBackendImpl.h
index 02dcf04..e1058c8 100644
--- a/WebCore/storage/IDBObjectStoreBackendImpl.h
+++ b/WebCore/storage/IDBObjectStoreBackendImpl.h
@@ -39,12 +39,13 @@ class SQLiteDatabase;
 
 class IDBObjectStoreBackendImpl : public IDBObjectStoreBackendInterface {
 public:
-    static PassRefPtr<IDBObjectStoreBackendInterface> create(IDBDatabaseBackendImpl* database, int64_t id, const String& name, const String& keyPath, bool autoIncrement)
+    static PassRefPtr<IDBObjectStoreBackendImpl> create(IDBDatabaseBackendImpl* database, int64_t id, const String& name, const String& keyPath, bool autoIncrement)
     {
         return adoptRef(new IDBObjectStoreBackendImpl(database, id, name, keyPath, autoIncrement));
     }
     ~IDBObjectStoreBackendImpl();
 
+    int64_t id() const { return m_id; }
     String name() const { return m_name; }
     String keyPath() const { return m_keyPath; }
     PassRefPtr<DOMStringList> indexNames() const;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list