Diff
Modified: trunk/LayoutTests/ChangeLog (88357 => 88358)
--- trunk/LayoutTests/ChangeLog 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/LayoutTests/ChangeLog 2011-06-08 17:50:29 UTC (rev 88358)
@@ -1,3 +1,14 @@
+2011-06-08 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Test migration from sqlite to leveldb for IndexedDB
+ backend.
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ * storage/indexeddb/migrate-basics-expected.txt: Added.
+ * storage/indexeddb/migrate-basics.html: Added.
+
2011-06-08 James Simonsen <[email protected]>
[Chromium] Unreviewed, skip two failing tests. Bugs filed.
Added: trunk/LayoutTests/storage/indexeddb/migrate-basics-expected.txt (0 => 88358)
--- trunk/LayoutTests/storage/indexeddb/migrate-basics-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/migrate-basics-expected.txt 2011-06-08 17:50:29 UTC (rev 88358)
@@ -0,0 +1,36 @@
+Test migration from SQLite to LevelDB.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitIndexedDB.open('MigrationDatabase')
+sqliteCreateSuccess():
+db = event.target.result
+db.setVersion('new version')
+sqliteSetVersionSuccess():
+window.db.createObjectStore('MigrationPlainOldStore', {autoIncrement: false})
+store = window.db.createObjectStore('MigrationStoreWithKeyPath', {keyPath: 'id', autoIncrement: true})
+window.db.createObjectStore('MigrationStoreWithAutoIncrement', {autoIncrement: true})
+trans = db.transaction([], webkitIDBTransaction.READ_WRITE)
+index = store.createIndex('ExampleIndex','id', false)
+sqliteTestAddRecords1():
+store = trans.objectStore('MigrationPlainOldStore')
+store = store.add({name: 'George'},1)
+sqliteTestAddRecords2():
+store = trans.objectStore('MigrationStoreWithKeyPath')
+store.add({name: 'Thomas', id: 3})
+sqliteTestAddRecords3():
+store = trans.objectStore('MigrationStoreWithAutoIncrement')
+store.add({name: 'Lincoln', number: '7012'}, 5)
+leveldbOpenSuccess():
+db = event.target.result
+trans = db.transaction([], webkitIDBTransaction.READ_WRITE, 0)
+leveldbCheckPlainOldStore():
+store = trans.objectStore('MigrationPlainOldStore')
+FAIL store = trans.objectStore('MigrationPlainOldStore') threw exception Error: NOT_FOUND_ERR: DOM IDBDatabase Exception 3
+request = store.openCursor(keyRange)
+FAIL request = store.openCursor(keyRange) threw exception TypeError: Cannot call method 'openCursor' of undefined
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/indexeddb/migrate-basics.html (0 => 88358)
--- trunk/LayoutTests/storage/indexeddb/migrate-basics.html (rev 0)
+++ trunk/LayoutTests/storage/indexeddb/migrate-basics.html 2011-06-08 17:50:29 UTC (rev 88358)
@@ -0,0 +1,199 @@
+<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 migration from SQLite to LevelDB.");
+
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ if (window.layoutTestController)
+ layoutTestController.setOverrideIndexedDBBackingStore("sqlite");
+
+ request = evalAndLog("webkitIndexedDB.open('MigrationDatabase')");
+ request._onsuccess_ = sqliteOpenSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function sqliteOpenSuccess()
+{
+ debug("sqliteCreateSuccess():");
+ window.db = evalAndLog("db = event.target.result");
+
+ request = evalAndLog("db.setVersion('new version')");
+ request._onsuccess_ = sqliteSetVersionSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function sqliteSetVersionSuccess()
+{
+ debug("sqliteSetVersionSuccess():");
+ evalAndLog("window.db.createObjectStore('MigrationPlainOldStore', {autoIncrement: false})");
+ window.store = evalAndLog("store = window.db.createObjectStore('MigrationStoreWithKeyPath', {keyPath: 'id', autoIncrement: true})");
+ evalAndLog("window.db.createObjectStore('MigrationStoreWithAutoIncrement', {autoIncrement: true})");
+
+ window.trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE)");
+ window.index = evalAndLog("index = store.createIndex('ExampleIndex','id', false)");
+
+
+ sqliteTestAddRecords1();
+}
+
+function sqliteTestAddRecords1()
+{
+ debug("sqliteTestAddRecords1():");
+ window.store = evalAndLog("store = trans.objectStore('MigrationPlainOldStore')");
+ request = evalAndLog("store = store.add({name: 'George'},1)");
+ request._onsuccess_ = sqliteTestAddRecords2;
+ request._onfailure_ = unexpectedErrorCallback;
+}
+
+function sqliteTestAddRecords2()
+{
+ debug("sqliteTestAddRecords2():");
+ window.store = evalAndLog("store = trans.objectStore('MigrationStoreWithKeyPath')");
+
+ request = evalAndLog("store.add({name: 'Thomas', id: 3})");
+ request._onsuccess_ = sqliteTestAddRecords3;
+ request._onfailure_ = unexpectedErrorCallback;
+}
+
+function sqliteTestAddRecords3()
+{
+ debug("sqliteTestAddRecords3():");
+ window.store = evalAndLog("store = trans.objectStore('MigrationStoreWithAutoIncrement')");
+ request = evalAndLog("store.add({name: 'Lincoln', number: '7012'}, 5)");
+ request._onsuccess_ = sqliteCloseDatabase;
+ request._onfailure_ = unexpectedErrorCallback;
+}
+
+
+function sqliteCloseDatabase()
+{
+ window.db.close();
+ window.db = null;
+ window.trans = null;
+ leveldbOpen();
+}
+
+function leveldbOpen()
+{
+ if (window.layoutTestController)
+ layoutTestController.setOverrideIndexedDBBackingStore("leveldb");
+
+ // This next line will trigger the migration.
+ request = webkitIndexedDB.open('MigrationDatabase');
+ request._onsuccess_ = leveldbOpenSuccess;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function leveldbOpenSuccess()
+{
+ debug("leveldbOpenSuccess():");
+ window.db = evalAndLog("db = event.target.result");
+ window.trans = evalAndLog("trans = db.transaction([], webkitIDBTransaction.READ_WRITE, 0)");
+ leveldbCheckPlainOldStore();
+}
+
+function leveldbCheckPlainOldStore()
+{
+ debug("leveldbCheckPlainOldStore():");
+ window.store = evalAndLog("store = trans.objectStore('MigrationPlainOldStore')");
+ window.keyRange = webkitIDBKeyRange.lowerBound(0);
+ request = evalAndLog("request = store.openCursor(keyRange)");
+ if (!request) {
+ testMigrationEnd();
+ return;
+ }
+ request._onsuccess_ = leveldbCheckPlainOldStoreCursorNext;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function leveldbCheckPlainOldStoreCursorNext()
+{
+ debug("leveldbCheckPlainOldStoreCursorNext():");
+ window.cursor = event.target.result;
+ if (!window.cursor) {
+ leveldbCheckStoreWithKeyPath();
+ return;
+ }
+
+ shouldBeTrue("cursor.value.name == 'George'");
+ cursor.continue();
+}
+
+function leveldbCheckStoreWithKeyPath()
+{
+ debug("leveldbCheckStoreWithKeyPath():");
+ window.store = evalAndLog("store = trans.objectStore('MigrationStoreWithKeyPath')");
+ var keyRange = webkitIDBKeyRange.lowerBound(0);
+ request = store.openCursor(keyRange);
+ request._onsuccess_ = leveldbCheckStoreWithKeyPathCursorNext;
+ request._onerror_ = unexpectedErrorCallback;
+}
+
+function leveldbCheckStoreWithKeyPathCursorNext()
+{
+ debug("leveldbCheckStoreWithKeyPathCursorNext():");
+ window.cursor = event.target.result;
+ if (!window.cursor) {
+ leveldbCheckStoreWithAutoIncrement();
+ return;
+ }
+
+ shouldBeTrue("cursor.value.name == 'Thomas'");
+ shouldBeTrue("cursor.value.id == '3'");
+ cursor.continue();
+}
+
+function leveldbCheckStoreWithAutoIncrement()
+{
+ debug("leveldbCheckStoreWithAutoIncrement():");
+ window.store = evalAndLog("store = trans.objectStore('MigrationStoreWithAutoIncrement')");
+ var keyRange = webkitIDBKeyRange.lowerBound(0);
+ request = store.openCursor(keyRange);
+ request._onsuccess_ = leveldbCheckStoreWithAutoIncrementCursorNext;
+ request._onerror_ = unexpectedErrorCallback;
+}
+function leveldbCheckStoreWithAutoIncrementCursorNext()
+{
+ debug("leveldbCheckStoreWithAutoIncrementCursorNext():");
+ window.cursor = event.target.result;
+ if (!window.cursor) {
+ testMigrationEnd();
+ return;
+ }
+
+ shouldBeTrue("cursor.value.name == 'Lincoln'");
+ shouldBeTrue("cursor.value.number == '7012'");
+ cursor.continue();
+}
+
+
+function testMigrationEnd()
+{
+ window.db.close();
+ window.db = null;
+ if (window.layoutTestController)
+ layoutTestController.setOverrideIndexedDBBackingStore("default");
+ layoutTestController.clearAllDatabases();
+ done();
+}
+
+test();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (88357 => 88358)
--- trunk/Source/WebCore/ChangeLog 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/ChangeLog 2011-06-08 17:50:29 UTC (rev 88358)
@@ -1,3 +1,27 @@
+2011-06-08 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ Test: storage/indexeddb/migrate-basics.html
+
+ * storage/IDBBackingStore.h:
+ * storage/IDBFactoryBackendImpl.cpp:
+ (WebCore::IDBFactoryBackendImpl::open):
+ (WebCore::IDBFactoryBackendImpl::migrate):
+ * storage/IDBFactoryBackendImpl.h:
+ * storage/IDBFactoryBackendInterface.h:
+ * storage/IDBLevelDBBackingStore.cpp:
+ (WebCore::IDBLevelDBBackingStore::backingStoreExists):
+ * storage/IDBLevelDBBackingStore.h:
+ (WebCore::IDBLevelDBBackingStore::backingStoreType):
+ * storage/IDBSQLiteBackingStore.cpp:
+ (WebCore::IDBSQLiteBackingStore::backingStoreExists):
+ * storage/IDBSQLiteBackingStore.h:
+ (WebCore::IDBSQLiteBackingStore::backingStoreType):
+
2011-06-08 Dmitry Lomov <[email protected]>
Reviewed by Adam Barth.
Modified: trunk/Source/WebCore/storage/IDBBackingStore.h (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBBackingStore.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBBackingStore.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -29,6 +29,7 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBCursor.h"
+#include "IDBFactoryBackendInterface.h"
#include "SQLiteDatabase.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
@@ -37,7 +38,6 @@
namespace WebCore {
-class IDBFactoryBackendImpl;
class IDBKey;
class IDBKeyRange;
class SecurityOrigin;
@@ -107,6 +107,7 @@
virtual void rollback() = 0;
};
virtual PassRefPtr<Transaction> createTransaction() = 0;
+ virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() const = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBFactoryBackendImpl.cpp 2011-06-08 17:50:29 UTC (rev 88358)
@@ -72,8 +72,7 @@
void IDBFactoryBackendImpl::open(const String& name, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType backingStoreType)
{
- String fileIdentifier = securityOrigin->databaseIdentifier();
- String uniqueIdentifier = fileIdentifier + "@" + name;
+ String uniqueIdentifier = securityOrigin->databaseIdentifier() + "@" + name + String::format("@%d", (int)backingStoreType);
IDBDatabaseBackendMap::iterator it = m_databaseBackendMap.find(uniqueIdentifier);
if (it != m_databaseBackendMap.end()) {
callbacks->onSuccess(it->second);
@@ -83,15 +82,30 @@
// FIXME: Everything from now on should be done on another thread.
RefPtr<IDBBackingStore> backingStore;
- IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(fileIdentifier);
- if (it2 != m_backingStoreMap.end())
+ IDBBackingStoreMap::iterator it2 = m_backingStoreMap.find(uniqueIdentifier);
+ if (it2 != m_backingStoreMap.end() && (backingStoreType == it2->second->backingStoreType()))
backingStore = it2->second;
else {
- if (backingStoreType == DefaultBackingStore)
- backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
#if ENABLE(LEVELDB)
+ // Should we migrate this backing store?
+ bool hasSQLBackingStore = IDBSQLiteBackingStore::backingStoreExists(securityOrigin.get(), dataDir);
+ bool hasLevelDBBackingStore = IDBLevelDBBackingStore::backingStoreExists(securityOrigin.get(), dataDir);
+
+ if (hasSQLBackingStore && hasLevelDBBackingStore)
+ backingStoreType = LevelDBBackingStore;
+
+ // Migration: if the database exists and is SQLite we want to migrate it to LevelDB.
+ if (hasSQLBackingStore && !hasLevelDBBackingStore) {
+ if (migrate(name, securityOrigin.get(), dataDir, maximumSize))
+ backingStoreType = LevelDBBackingStore;
+ }
+#endif
+
+ if (backingStoreType == DefaultBackingStore || backingStoreType == SQLiteBackingStore)
+ backingStore = IDBSQLiteBackingStore::open(securityOrigin.get(), dataDir, maximumSize, uniqueIdentifier, this);
+#if ENABLE(LEVELDB)
else if (backingStoreType == LevelDBBackingStore)
- backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, fileIdentifier, this);
+ backingStore = IDBLevelDBBackingStore::open(securityOrigin.get(), dataDir, maximumSize, uniqueIdentifier, this);
#endif
if (!backingStore) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error."));
@@ -104,6 +118,11 @@
m_databaseBackendMap.set(uniqueIdentifier, databaseBackend.get());
}
+bool IDBFactoryBackendImpl::migrate(const String& name, SecurityOrigin* securityOrigin, const String& dataDir, int64_t maximumSize)
+{
+ return false;
+}
+
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBFactoryBackendImpl.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -59,6 +59,7 @@
private:
IDBFactoryBackendImpl();
+ bool migrate(const String& name, SecurityOrigin*, const String& dataDir, int64_t maximumSize);
typedef HashMap<String, IDBDatabaseBackendImpl*> IDBDatabaseBackendMap;
IDBDatabaseBackendMap m_databaseBackendMap;
Modified: trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBFactoryBackendInterface.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -53,7 +53,8 @@
enum BackingStoreType {
DefaultBackingStore,
- LevelDBBackingStore
+ LevelDBBackingStore,
+ SQLiteBackingStore
};
virtual void open(const String& name, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*, const String& dataDir, int64_t maximumSize, BackingStoreType) = 0;
Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.cpp 2011-06-08 17:50:29 UTC (rev 88358)
@@ -1304,6 +1304,23 @@
m_backingStore->m_currentTransaction.clear();
}
+bool IDBLevelDBBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBaseArg)
+{
+ String pathBase = pathBaseArg;
+
+ if (pathBase.isEmpty())
+ return false;
+
+ // FIXME: We should eventually use the same LevelDB database for all origins.
+ String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb");
+
+ // FIXME: It would be more thorough to open the database here but also more expensive.
+ if (fileExists(path+"/CURRENT"))
+ return true;
+
+ return false;
+}
+
// FIXME: deleteDatabase should be part of IDBBackingStore.
} // namespace WebCore
Modified: trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBLevelDBBackingStore.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -37,6 +37,7 @@
class LevelDBComparator;
class LevelDBDatabase;
class LevelDBTransaction;
+class IDBFactoryBackendImpl;
class IDBLevelDBBackingStore : public IDBBackingStore {
public:
@@ -73,7 +74,10 @@
virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction);
virtual PassRefPtr<Transaction> createTransaction();
+ virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() const { return IDBFactoryBackendInterface::LevelDBBackingStore; }
+ static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
+
private:
IDBLevelDBBackingStore(String identifier, IDBFactoryBackendImpl*, PassOwnPtr<LevelDBDatabase>);
Modified: trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBSQLiteBackingStore.cpp 2011-06-08 17:50:29 UTC (rev 88358)
@@ -991,6 +991,18 @@
return cursor.release();
}
+bool IDBSQLiteBackingStore::backingStoreExists(SecurityOrigin* securityOrigin, const String& pathBase)
+{
+ String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb");
+
+ SQLiteDatabase db;
+ if (!db.open(path))
+ return false;
+
+ db.close();
+ return true;
+}
+
namespace {
class TransactionImpl : public IDBBackingStore::Transaction {
Modified: trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h (88357 => 88358)
--- trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebCore/storage/IDBSQLiteBackingStore.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -31,6 +31,8 @@
#include "IDBBackingStore.h"
namespace WebCore {
+
+class IDBFactoryBackendImpl;
class IDBSQLiteBackingStore : public IDBBackingStore {
public:
@@ -67,7 +69,10 @@
virtual PassRefPtr<Cursor> openIndexCursor(int64_t databaseId, int64_t objectStoreId, int64_t indexId, const IDBKeyRange*, IDBCursor::Direction);
virtual PassRefPtr<Transaction> createTransaction();
+ virtual IDBFactoryBackendInterface::BackingStoreType backingStoreType() const { return IDBFactoryBackendInterface::SQLiteBackingStore; }
+ static bool backingStoreExists(SecurityOrigin*, const String& pathBase);
+
private:
IDBSQLiteBackingStore(String identifier, IDBFactoryBackendImpl*);
Modified: trunk/Source/WebKit/chromium/ChangeLog (88357 => 88358)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-06-08 17:50:29 UTC (rev 88358)
@@ -1,3 +1,17 @@
+2011-06-08 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ * public/WebIDBFactory.h:
+ * src/AssertMatchingEnums.cpp:
+ * src/WebIDBFactoryImpl.cpp:
+ (WebKit::WebIDBFactory::setOverrideBackingStoreType):
+ (WebKit::WebIDBFactory::setTemporaryDatabaseFolder):
+ (WebKit::WebIDBFactoryImpl::open):
+
2011-06-08 Dominic Mazzoni <[email protected]>
Reviewed by Dimitri Glazkov.
Modified: trunk/Source/WebKit/chromium/public/WebIDBFactory.h (88357 => 88358)
--- trunk/Source/WebKit/chromium/public/WebIDBFactory.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebKit/chromium/public/WebIDBFactory.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -53,13 +53,18 @@
enum BackingStoreType {
DefaultBackingStore,
- LevelDBBackingStore
+ LevelDBBackingStore,
+ SQLiteBackingStore
};
// The WebKit implementation of open ignores the WebFrame* parameter.
virtual void open(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType) { WEBKIT_ASSERT_NOT_REACHED(); }
virtual void deleteDatabase(const WebString& name, WebIDBCallbacks*, const WebSecurityOrigin&, WebFrame*, const WebString& dataDir) { WEBKIT_ASSERT_NOT_REACHED(); }
+
+ // Used for DumpRenderTree tests.
+ WEBKIT_API static void setOverrideBackingStoreType(BackingStoreType);
+ WEBKIT_API static void setTemporaryDatabaseFolder(const WebString& path);
};
} // namespace WebKit
Modified: trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp (88357 => 88358)
--- trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebKit/chromium/src/AssertMatchingEnums.cpp 2011-06-08 17:50:29 UTC (rev 88358)
@@ -399,6 +399,7 @@
COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::DefaultBackingStore, IDBFactoryBackendInterface::DefaultBackingStore);
COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::LevelDBBackingStore, IDBFactoryBackendInterface::LevelDBBackingStore);
+COMPILE_ASSERT_MATCHING_ENUM(WebIDBFactory::SQLiteBackingStore, IDBFactoryBackendInterface::SQLiteBackingStore);
#if ENABLE(FILE_SYSTEM)
COMPILE_ASSERT_MATCHING_ENUM(WebFileSystem::TypeTemporary, AsyncFileSystem::Temporary);
Modified: trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp (88357 => 88358)
--- trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Source/WebKit/chromium/src/WebIDBFactoryImpl.cpp 2011-06-08 17:50:29 UTC (rev 88358)
@@ -44,11 +44,24 @@
namespace WebKit {
+static WebIDBFactory::BackingStoreType overriddenBackingStoreType = WebIDBFactory::DefaultBackingStore;
+static WebString tempDatabaseFolder;
+
WebIDBFactory* WebIDBFactory::create()
{
return new WebIDBFactoryImpl();
}
+void WebIDBFactory::setOverrideBackingStoreType(BackingStoreType type)
+{
+ overriddenBackingStoreType = type;
+}
+
+void WebIDBFactory::setTemporaryDatabaseFolder(const WebString& path)
+{
+ tempDatabaseFolder = path;
+}
+
WebIDBFactoryImpl::WebIDBFactoryImpl()
: m_idbFactoryBackend(IDBFactoryBackendImpl::create())
{
@@ -60,7 +73,19 @@
void WebIDBFactoryImpl::open(const WebString& name, WebIDBCallbacks* callbacks, const WebSecurityOrigin& origin, WebFrame*, const WebString& dataDir, unsigned long long maximumSize, BackingStoreType backingStoreType)
{
- m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, dataDir, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType));
+ WebString path = dataDir;
+ if (overriddenBackingStoreType != DefaultBackingStore) {
+ backingStoreType = overriddenBackingStoreType;
+
+ // The dataDir is empty for two reasons: LevelDB in icognito mode or
+ // LevelDB from DumpRenderTree. The first case is taken care of inside
+ // IDBFactoryBackendImpl.cpp by forcing SQLITE backend for incognito.
+ // For the DumpRenderTree case we need to keep track of the location
+ // so we can wipe it out when we're done with the test.
+ if (dataDir.isEmpty() && backingStoreType == LevelDBBackingStore)
+ path = tempDatabaseFolder;
+ }
+ m_idbFactoryBackend->open(name, IDBCallbacksProxy::create(adoptPtr(callbacks)), origin, 0, path, maximumSize, static_cast<IDBFactoryBackendInterface::BackingStoreType>(backingStoreType));
}
} // namespace WebKit
Modified: trunk/Tools/ChangeLog (88357 => 88358)
--- trunk/Tools/ChangeLog 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Tools/ChangeLog 2011-06-08 17:50:29 UTC (rev 88358)
@@ -1,3 +1,16 @@
+2011-06-08 Greg Simon <[email protected]>
+
+ Reviewed by Dimitri Glazkov.
+
+ Control Indexeddb backends from LayoutTestController
+ https://bugs.webkit.org/show_bug.cgi?id=61000
+
+ * DumpRenderTree/chromium/LayoutTestController.cpp:
+ (LayoutTestController::LayoutTestController):
+ (LayoutTestController::setOverrideIndexedDBBackingStore):
+ (LayoutTestController::clearAllDatabases):
+ * DumpRenderTree/chromium/LayoutTestController.h:
+
2011-06-08 Andreas Kling <[email protected]>
Add Pierre Rossi to contributors list for EZ-CC.
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (88357 => 88358)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp 2011-06-08 17:50:29 UTC (rev 88358)
@@ -44,6 +44,7 @@
#include "WebElement.h"
#include "WebFrame.h"
#include "WebGeolocationClientMock.h"
+#include "WebIDBFactory.h"
#include "WebInputElement.h"
#include "WebKit.h"
#include "WebNotificationPresenter.h"
@@ -83,6 +84,7 @@
// names to their methods will be done by calling bindToJavaScript() (defined
// by CppBoundClass, the parent to LayoutTestController).
bindMethod("addFileToPasteboardOnDrag", &LayoutTestController::addFileToPasteboardOnDrag);
+ bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
bindMethod("addOriginAccessWhitelistEntry", &LayoutTestController::addOriginAccessWhitelistEntry);
bindMethod("addUserScript", &LayoutTestController::addUserScript);
bindMethod("addUserStyleSheet", &LayoutTestController::addUserStyleSheet);
@@ -162,7 +164,7 @@
bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation);
bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError);
bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition);
- bindMethod("addMockSpeechInputResult", &LayoutTestController::addMockSpeechInputResult);
+ bindMethod("setOverrideIndexedDBBackingStore", &LayoutTestController::setOverrideIndexedDBBackingStore);
bindMethod("setPageVisibility", &LayoutTestController::setPageVisibility);
bindMethod("setPluginsEnabled", &LayoutTestController::setPluginsEnabled);
bindMethod("setPopupBlockingEnabled", &LayoutTestController::setPopupBlockingEnabled);
@@ -1147,6 +1149,29 @@
result->setNull();
}
+void LayoutTestController::setOverrideIndexedDBBackingStore(const CppArgumentList& arguments, CppVariant* result)
+{
+ result->setNull();
+#if ENABLE(INDEXED_DATABASE)
+ if (arguments.size() < 1 || !arguments[0].isString())
+ return;
+ string name = arguments[0].toString();
+ if (name == "default")
+ WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::DefaultBackingStore);
+ else if (name == "sqlite")
+ WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::SQLiteBackingStore);
+ else if (name == "leveldb") {
+ WebIDBFactory::setOverrideBackingStoreType(WebIDBFactory::LevelDBBackingStore);
+
+ m_tempFolder = adoptPtr(webkit_support::CreateScopedTempDirectory());
+ if (m_tempFolder) {
+ if (m_tempFolder->CreateUniqueTempDir())
+ WebIDBFactory::setTemporaryDatabaseFolder(WebString::fromUTF8(m_tempFolder->path().c_str()));
+ }
+ }
+#endif
+}
+
void LayoutTestController::callShouldCloseOnWebView(const CppArgumentList&, CppVariant* result)
{
result->set(m_shell->webView()->dispatchBeforeUnloadEvent());
@@ -1524,6 +1549,7 @@
{
result->setNull();
webkit_support::ClearAllDatabases();
+ m_tempFolder.clear();
}
void LayoutTestController::setDatabaseQuota(const CppArgumentList& arguments, CppVariant* result)
Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (88357 => 88358)
--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h 2011-06-08 17:31:03 UTC (rev 88357)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h 2011-06-08 17:50:29 UTC (rev 88358)
@@ -56,6 +56,10 @@
class WebSpeechInputListener;
}
+namespace webkit_support {
+class ScopedTempDirectory;
+}
+
class TestShell;
class LayoutTestController : public CppBoundClass {
@@ -306,6 +310,8 @@
void clearAllDatabases(const CppArgumentList&, CppVariant*);
// Sets the default quota for all origins
void setDatabaseQuota(const CppArgumentList&, CppVariant*);
+ // Overrides the backend for IndexedDB
+ void setOverrideIndexedDBBackingStore(const CppArgumentList&, CppVariant*);
// Calls setlocale(LC_ALL, ...) for a specified locale.
// Resets between tests.
@@ -599,6 +605,9 @@
CppVariant m_globalFlag;
+ // Used to create and destroy temporary folders.
+ OwnPtr<webkit_support::ScopedTempDirectory> m_tempFolder;
+
// Bound variable counting the number of top URLs visited.
CppVariant m_webHistoryItemCount;