summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/tools')
-rw-r--r--webkit/tools/test_shell/layout_test_controller.cc18
-rw-r--r--webkit/tools/test_shell/layout_test_controller.h13
-rw-r--r--webkit/tools/test_shell/simple_database_system.cc23
-rw-r--r--webkit/tools/test_shell/simple_database_system.h3
4 files changed, 52 insertions, 5 deletions
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc
index 3c94a91..0dc1259 100644
--- a/webkit/tools/test_shell/layout_test_controller.cc
+++ b/webkit/tools/test_shell/layout_test_controller.cc
@@ -78,6 +78,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) :
BindMethod("dumpAsText", &LayoutTestController::dumpAsText);
BindMethod("dumpChildFrameScrollPositions", &LayoutTestController::dumpChildFrameScrollPositions);
BindMethod("dumpChildFramesAsText", &LayoutTestController::dumpChildFramesAsText);
+ BindMethod("dumpDatabaseCallbacks", &LayoutTestController::dumpDatabaseCallbacks);
BindMethod("dumpEditingCallbacks", &LayoutTestController::dumpEditingCallbacks);
BindMethod("dumpBackForwardList", &LayoutTestController::dumpBackForwardList);
BindMethod("dumpFrameLoadCallbacks", &LayoutTestController::dumpFrameLoadCallbacks);
@@ -122,6 +123,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) :
BindMethod("setWillSendRequestReturnsNull", &LayoutTestController::setWillSendRequestReturnsNull);
BindMethod("whiteListAccessFromOrigin", &LayoutTestController::whiteListAccessFromOrigin);
BindMethod("clearAllDatabases", &LayoutTestController::clearAllDatabases);
+ BindMethod("setDatabaseQuota", &LayoutTestController::setDatabaseQuota);
BindMethod("setPOSIXLocale", &LayoutTestController::setPOSIXLocale);
BindMethod("counterValueForElementById", &LayoutTestController::counterValueForElementById);
@@ -213,6 +215,12 @@ void LayoutTestController::dumpAsText(const CppArgumentList& args,
result->SetNull();
}
+void LayoutTestController::dumpDatabaseCallbacks(
+ const CppArgumentList& args, CppVariant* result) {
+ // Do nothing; we don't use this flag anywhere for now
+ result->SetNull();
+}
+
void LayoutTestController::dumpEditingCallbacks(
const CppArgumentList& args, CppVariant* result) {
dump_editing_callbacks_ = true;
@@ -455,6 +463,9 @@ void LayoutTestController::Reset() {
SimpleResourceLoaderBridge::SetAcceptAllCookies(false);
WebSecurityPolicy::resetOriginAccessWhiteLists();
+ // Reset the default quota for each origin to 5MB
+ SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(5 * 1024 * 1024);
+
setlocale(LC_ALL, "");
if (close_remaining_windows_) {
@@ -1018,6 +1029,13 @@ void LayoutTestController::clearAllDatabases(
SimpleDatabaseSystem::GetInstance()->ClearAllDatabases();
}
+void LayoutTestController::setDatabaseQuota(
+ const CppArgumentList& args, CppVariant* result) {
+ result->SetNull();
+ if ((args.size() >= 1) && args[0].isInt32())
+ SimpleDatabaseSystem::GetInstance()->SetDatabaseQuota(args[0].ToInt32());
+}
+
void LayoutTestController::setPOSIXLocale(const CppArgumentList& args,
CppVariant* result) {
result->SetNull();
diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h
index 67026867..0fe2df8 100644
--- a/webkit/tools/test_shell/layout_test_controller.h
+++ b/webkit/tools/test_shell/layout_test_controller.h
@@ -32,13 +32,20 @@ class LayoutTestController : public CppBoundClass {
// It takes no arguments, and ignores any that may be present.
void dumpAsText(const CppArgumentList& args, CppVariant* result);
+ // This function should set a flag that tells the test_shell to print a line
+ // of descriptive text for each database command. It should take no
+ // arguments, and ignore any that may be present. However, at the moment, we
+ // don't have any DB function that prints messages, so for now this function
+ // doesn't do anything.
+ void dumpDatabaseCallbacks(const CppArgumentList& args, CppVariant* result);
+
// This function sets a flag that tells the test_shell to print a line of
- // descriptive test for each editing command. It takes no arguments, and
+ // descriptive text for each editing command. It takes no arguments, and
// ignores any that may be present.
void dumpEditingCallbacks(const CppArgumentList& args, CppVariant* result);
// This function sets a flag that tells the test_shell to print a line of
- // descriptive test for each frame load callback. It takes no arguments, and
+ // descriptive text for each frame load callback. It takes no arguments, and
// ignores any that may be present.
void dumpFrameLoadCallbacks(const CppArgumentList& args, CppVariant* result);
@@ -205,6 +212,8 @@ class LayoutTestController : public CppBoundClass {
// Clears all databases.
void clearAllDatabases(const CppArgumentList& args, CppVariant* result);
+ // Sets the default quota for all origins
+ void setDatabaseQuota(const CppArgumentList& args, CppVariant* result);
// Calls setlocale(LC_ALL, ...) for a specified locale.
// Resets between tests.
diff --git a/webkit/tools/test_shell/simple_database_system.cc b/webkit/tools/test_shell/simple_database_system.cc
index 2b9afe3..a2cd8e3 100644
--- a/webkit/tools/test_shell/simple_database_system.cc
+++ b/webkit/tools/test_shell/simple_database_system.cc
@@ -10,7 +10,9 @@
#include "third_party/sqlite/preprocessed/sqlite3.h"
#endif
+#include "base/auto_reset.h"
#include "base/file_util.h"
+#include "base/message_loop.h"
#include "base/platform_thread.h"
#include "base/process_util.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h"
@@ -29,14 +31,17 @@ SimpleDatabaseSystem* SimpleDatabaseSystem::GetInstance() {
return instance_;
}
-SimpleDatabaseSystem::SimpleDatabaseSystem() {
+SimpleDatabaseSystem::SimpleDatabaseSystem()
+ : waiting_for_dbs_to_close_(false) {
temp_dir_.CreateUniqueTempDir();
db_tracker_ = new DatabaseTracker(temp_dir_.path());
+ db_tracker_->AddObserver(this);
DCHECK(!instance_);
instance_ = this;
}
SimpleDatabaseSystem::~SimpleDatabaseSystem() {
+ db_tracker_->RemoveObserver(this);
instance_ = NULL;
}
@@ -113,6 +118,9 @@ void SimpleDatabaseSystem::DatabaseClosed(const string16& origin_identifier,
origin_identifier, database_name));
db_tracker_->DatabaseClosed(origin_identifier, database_name);
database_connections_.RemoveConnection(origin_identifier, database_name);
+
+ if (waiting_for_dbs_to_close_ && database_connections_.IsEmpty())
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
}
void SimpleDatabaseSystem::OnDatabaseSizeChanged(
@@ -144,13 +152,22 @@ void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) {
}
void SimpleDatabaseSystem::ClearAllDatabases() {
- db_tracker_->CloseDatabases(database_connections_);
- database_connections_.RemoveAllConnections();
+ // Wait for all databases to be closed.
+ if (!database_connections_.IsEmpty()) {
+ AutoReset waiting_for_dbs_auto_reset(&waiting_for_dbs_to_close_, true);
+ MessageLoop::ScopedNestableTaskAllower nestable(MessageLoop::current());
+ MessageLoop::current()->Run();
+ }
+
db_tracker_->CloseTrackerDatabaseAndClearCaches();
file_util::Delete(db_tracker_->DatabaseDirectory(), true);
file_names_.clear();
}
+void SimpleDatabaseSystem::SetDatabaseQuota(int64 quota) {
+ db_tracker_->SetDefaultQuota(quota);
+}
+
void SimpleDatabaseSystem::SetFullFilePathsForVfsFile(
const string16& origin_identifier,
const string16& database_name) {
diff --git a/webkit/tools/test_shell/simple_database_system.h b/webkit/tools/test_shell/simple_database_system.h
index ff92b3f..766940e 100644
--- a/webkit/tools/test_shell/simple_database_system.h
+++ b/webkit/tools/test_shell/simple_database_system.h
@@ -53,6 +53,7 @@ class SimpleDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
virtual void databaseClosed(const WebKit::WebDatabase& database);
void ClearAllDatabases();
+ void SetDatabaseQuota(int64 quota);
private:
// The calls that come from the database tracker run on the main thread.
@@ -68,6 +69,8 @@ class SimpleDatabaseSystem : public webkit_database::DatabaseTracker::Observer,
static SimpleDatabaseSystem* instance_;
+ bool waiting_for_dbs_to_close_;
+
ScopedTempDir temp_dir_;
scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;