diff options
10 files changed, 154 insertions, 97 deletions
diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/statement-error-callback-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/statement-error-callback-expected.txt new file mode 100644 index 0000000..5ea7e10 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/statement-error-callback-expected.txt @@ -0,0 +1,5 @@ +CONSOLE MESSAGE: line 54: Uncaught Exception in Statement error callback +This test confirms that if the statement error callback returns true or throws an exception we do not execute any further statements in that transaction and instead execute the transaction error callback immediately. +PASS - the transaction error callback was invoked. +PASS - the transaction error callback was invoked. +Test Complete diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/transaction-callback-exception-crash-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/transaction-callback-exception-crash-expected.txt new file mode 100644 index 0000000..49ab0e7 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/transaction-callback-exception-crash-expected.txt @@ -0,0 +1,2 @@ +CONSOLE MESSAGE: line 13: Uncaught TransactionCallbackError +If WebKit doesn't crash, this test has passed diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/transaction-error-callback-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/transaction-error-callback-expected.txt new file mode 100644 index 0000000..8fdbb95 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/transaction-error-callback-expected.txt @@ -0,0 +1,8 @@ +CONSOLE MESSAGE: line 63: Uncaught #<an Object> +CONSOLE MESSAGE: line 63: Uncaught #<an Object> +This test confirms that SQLTransactionErrorCallback is invoked correctly and regardless of its output, the transaction is always rolled back on failure. +Testing transaction failing mid-way and error callback returning true : SUCCESS +Testing transaction failing mid-way and error callback return false : SUCCESS +Testing statement callback throwing exception and error callback returning true : SUCCESS +Testing statement callback throwing exception and error callback returning false : SUCCESS +All Tests are complete. diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/statement-error-callback-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/statement-error-callback-expected.txt new file mode 100644 index 0000000..5ea7e10 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/statement-error-callback-expected.txt @@ -0,0 +1,5 @@ +CONSOLE MESSAGE: line 54: Uncaught Exception in Statement error callback +This test confirms that if the statement error callback returns true or throws an exception we do not execute any further statements in that transaction and instead execute the transaction error callback immediately. +PASS - the transaction error callback was invoked. +PASS - the transaction error callback was invoked. +Test Complete diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/transaction-callback-exception-crash-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/transaction-callback-exception-crash-expected.txt new file mode 100644 index 0000000..49ab0e7 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/transaction-callback-exception-crash-expected.txt @@ -0,0 +1,2 @@ +CONSOLE MESSAGE: line 13: Uncaught TransactionCallbackError +If WebKit doesn't crash, this test has passed diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/transaction-error-callback-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/transaction-error-callback-expected.txt new file mode 100644 index 0000000..8fdbb95 --- /dev/null +++ b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/transaction-error-callback-expected.txt @@ -0,0 +1,8 @@ +CONSOLE MESSAGE: line 63: Uncaught #<an Object> +CONSOLE MESSAGE: line 63: Uncaught #<an Object> +This test confirms that SQLTransactionErrorCallback is invoked correctly and regardless of its output, the transaction is always rolled back on failure. +Testing transaction failing mid-way and error callback returning true : SUCCESS +Testing transaction failing mid-way and error callback return false : SUCCESS +Testing statement callback throwing exception and error callback returning true : SUCCESS +Testing statement callback throwing exception and error callback returning false : SUCCESS +All Tests are complete. diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt index a184b45..8035667 100644 --- a/webkit/tools/layout_tests/test_expectations.txt +++ b/webkit/tools/layout_tests/test_expectations.txt @@ -705,34 +705,10 @@ BUG4360 : LayoutTests/http/tests/loading/deleted-host-in-resource-load-delegate- // TODO(jorlow): Is this really still slow? If so, why? BUG_JORLOW SLOW LINUX DEBUG : LayoutTests/storage/domstorage/localstorage/index-get-and-set.html = PASS -// HTML5 databases are not supported in test_shell yet -BUG4359 SKIP : LayoutTests/storage/close-during-stress-test.html = PASS -BUG4359 SKIP : LayoutTests/storage/database-lock-after-reload.html = PASS -BUG4359 SKIP : LayoutTests/storage/empty-statement.html = PASS -BUG4359 SKIP : LayoutTests/storage/execute-sql-args.html = PASS -BUG4359 SKIP : LayoutTests/storage/hash-change-with-xhr.html = PASS -BUG4359 SKIP : LayoutTests/storage/multiple-databases-garbage-collection.html = PASS -BUG4359 SKIP : LayoutTests/storage/multiple-transactions.html = PASS -BUG4359 SKIP : LayoutTests/storage/open-database-empty-version.html = PASS -BUG4359 SKIP : LayoutTests/storage/open-database-set-empty-version.html = PASS -BUG4359 SKIP : LayoutTests/storage/private-browsing-readonly.html = PASS -BUG4359 SKIP : LayoutTests/storage/quota-tracking.html = PASS -BUG4359 SKIP : LayoutTests/storage/sql-data-types.html = PASS -BUG4359 SKIP : LayoutTests/storage/sql-data-types.js = PASS -BUG4359 SKIP : LayoutTests/storage/success-callback.html = PASS -BUG4359 SKIP : LayoutTests/storage/transaction-callback-exception-crash.html = PASS -BUG4359 SKIP : LayoutTests/storage/transaction-error-callback.html = PASS -BUG4359 SKIP : LayoutTests/fast/js/exceptions-thrown-in-callbacks.html = PASS -BUG4359 SKIP : LayoutTests/storage/test-authorizer.html = PASS -BUG4359 SKIP : LayoutTests/storage/open-database-while-transaction-in-progress.html = PASS -BUG4359 SKIP : LayoutTests/storage/read-and-write-transactions-dont-run-together.html = PASS -BUG4359 SKIP : LayoutTests/storage/read-transactions-running-concurrently.html = PASS -BUG4359 SKIP : LayoutTests/storage/multiple-transactions-on-different-handles.html = PASS -BUG4359 SKIP : LayoutTests/storage/change-version-handle-reuse.html = FAIL -BUG4359 SKIP : LayoutTests/storage/change-version.html = TIMEOUT - -// Need to implement clearAllDatabases in layoutTestController. -BUG20995 SKIP : LayoutTests/storage/statement-error-callback.html = FAIL +// HTML5 DB layout tests that do not pass in test_shell +BUG27697 : LayoutTests/storage/hash-change-with-xhr.html = TIMEOUT +WONTFIX SKIP : LayoutTests/storage/private-browsing-readonly.html = PASS +WONTFIX SKIP : LayoutTests/storage/quota-tracking.html = PASS // Implement HTML5 Geolocation API. BUG11246 : LayoutTests/fast/dom/Geolocation = FAIL @@ -2949,11 +2925,6 @@ BUG_JOHNNYG LINUX DEBUG : LayoutTests/svg/custom/marker-overflow-clip.svg = PASS // Added in http://trac.webkit.org/changeset/49990 BUG25884 WIN LINUX : LayoutTests/fast/dom/Document/CaretRangeFromPoint/caretRangeFromPoint-in-zoom-and-scroll.html = FAIL -// window.openDatabase doesn't exist yet as of r29980. That's causing these -// tests to fail. -BUG26107 : LayoutTests/fast/js/global-function-resolve.html = FAIL -BUG26107 WIN LINUX : LayoutTests/http/tests/security/cross-frame-access-call.html = FAIL - BUG26344 LINUX DEBUG : LayoutTests/fast/text/atsui-partial-selection.html = CRASH BUG26344 LINUX DEBUG : LayoutTests/platform/mac/editing/deleting/backward-delete.html = CRASH diff --git a/webkit/tools/test_shell/simple_database_system.cc b/webkit/tools/test_shell/simple_database_system.cc index dd0d032..14c3249 100644 --- a/webkit/tools/test_shell/simple_database_system.cc +++ b/webkit/tools/test_shell/simple_database_system.cc @@ -13,9 +13,13 @@ #include "base/file_util.h" #include "base/platform_thread.h" #include "base/process_util.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" +#include "third_party/WebKit/WebKit/chromium/public/WebString.h" +#include "webkit/database/database_util.h" #include "webkit/database/vfs_backend.h" -#include "webkit/glue/webkit_glue.h" +using webkit_database::DatabaseTracker; +using webkit_database::DatabaseUtil; using webkit_database::VfsBackend; SimpleDatabaseSystem* SimpleDatabaseSystem::instance_ = NULL; @@ -25,63 +29,48 @@ SimpleDatabaseSystem* SimpleDatabaseSystem::GetInstance() { return instance_; } -SimpleDatabaseSystem::SimpleDatabaseSystem() - : hack_main_db_handle_(base::kInvalidPlatformFileValue) { +SimpleDatabaseSystem::SimpleDatabaseSystem() { temp_dir_.CreateUniqueTempDir(); + db_tracker_ = new DatabaseTracker(temp_dir_.path()); DCHECK(!instance_); instance_ = this; } SimpleDatabaseSystem::~SimpleDatabaseSystem() { - base::ClosePlatformFile(hack_main_db_handle_); instance_ = NULL; } base::PlatformFile SimpleDatabaseSystem::OpenFile( - const FilePath& file_name, int desired_flags, + const string16& vfs_file_name, int desired_flags, base::PlatformFile* dir_handle) { base::PlatformFile file_handle = base::kInvalidPlatformFileValue; + FilePath file_name = + DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); if (file_name.empty()) { VfsBackend::OpenTempFileInDirectory( - GetDBDir(), desired_flags, base::GetCurrentProcessHandle(), - &file_handle, dir_handle); + db_tracker_->DatabaseDirectory(), desired_flags, + base::GetCurrentProcessHandle(), &file_handle, dir_handle); } else { - VfsBackend::OpenFile(GetDBFileFullPath(file_name), desired_flags, + VfsBackend::OpenFile(file_name, desired_flags, base::GetCurrentProcessHandle(), &file_handle, dir_handle); } - // HACK: Currently, the DB object that keeps track of the main database - // (DatabaseTracker) is a singleton that is declared as a static variable - // in a function, so it gets destroyed at the very end of the program. - // Because of that, we have a handle opened to the main DB file until the - // very end of the program, which prevents temp_dir_'s destructor from - // deleting the database directory. - // - // We will properly solve this problem when we reimplement DatabaseTracker. - // For now, however, we are going to take advantage of the fact that in order - // to do anything related to DBs, we have to call openDatabase() first, which - // opens a handle to the main DB before opening handles to any other DB files. - // We are going to cache the first file handle we get, and we are going to - // manually close it in the destructor. - if (hack_main_db_handle_ == base::kInvalidPlatformFileValue) { - hack_main_db_handle_ = file_handle; - } - return file_handle; } int SimpleDatabaseSystem::DeleteFile( - const FilePath& file_name, bool sync_dir) { + const string16& vfs_file_name, bool sync_dir) { // We try to delete the file multiple times, because that's what the default // VFS does (apparently deleting a file can sometimes fail on Windows). // We sleep for 10ms between retries for the same reason. const int kNumDeleteRetries = 3; int num_retries = 0; int error_code = SQLITE_OK; + FilePath file_name = + DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name); do { - error_code = VfsBackend::DeleteFile( - GetDBFileFullPath(file_name), sync_dir); + error_code = VfsBackend::DeleteFile(file_name, sync_dir); } while ((++num_retries < kNumDeleteRetries) && (error_code == SQLITE_IOERR_DELETE) && (PlatformThread::Sleep(10), 1)); @@ -89,25 +78,65 @@ int SimpleDatabaseSystem::DeleteFile( return error_code; } -long SimpleDatabaseSystem::GetFileAttributes( - const FilePath& file_name) { - return VfsBackend::GetFileAttributes(GetDBFileFullPath(file_name)); +long SimpleDatabaseSystem::GetFileAttributes(const string16& vfs_file_name) { + return VfsBackend::GetFileAttributes( + DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name)); } -long long SimpleDatabaseSystem::GetFileSize( - const FilePath& file_name) { - return VfsBackend::GetFileSize(GetDBFileFullPath(file_name)); +long long SimpleDatabaseSystem::GetFileSize(const string16& vfs_file_name) { + return VfsBackend::GetFileSize( + DatabaseUtil::GetFullFilePathForVfsFile(db_tracker_, vfs_file_name)); } -void SimpleDatabaseSystem::ClearAllDatabases() { - // TODO(dumi): implement this once we refactor DatabaseTracker - //file_util::Delete(GetDBDir(), true); +void SimpleDatabaseSystem::DatabaseOpened(const string16& origin_identifier, + const string16& database_name, + const string16& description, + int64 estimated_size) { + int64 database_size = 0; + int64 space_available = 0; + db_tracker_->DatabaseOpened(origin_identifier, database_name, description, + estimated_size, &database_size, &space_available); + OnDatabaseSizeChanged(origin_identifier, database_name, + database_size, space_available); +} + +void SimpleDatabaseSystem::DatabaseModified(const string16& origin_identifier, + const string16& database_name) { + db_tracker_->DatabaseModified(origin_identifier, database_name); +} + +void SimpleDatabaseSystem::DatabaseClosed(const string16& origin_identifier, + const string16& database_name) { + db_tracker_->DatabaseClosed(origin_identifier, database_name); } -FilePath SimpleDatabaseSystem::GetDBDir() { - return temp_dir_.path().Append(FILE_PATH_LITERAL("databases")); +void SimpleDatabaseSystem::OnDatabaseSizeChanged( + const string16& origin_identifier, + const string16& database_name, + int64 database_size, + int64 space_available) { + WebKit::WebDatabase::updateDatabaseSize( + origin_identifier, database_name, database_size, space_available); } -FilePath SimpleDatabaseSystem::GetDBFileFullPath(const FilePath& file_name) { - return GetDBDir().Append(file_name); +void SimpleDatabaseSystem::databaseOpened(const WebKit::WebDatabase& database) { + DatabaseOpened(database.securityOrigin().databaseIdentifier(), + database.name(), database.displayName(), + database.estimatedSize()); +} + +void SimpleDatabaseSystem::databaseModified( + const WebKit::WebDatabase& database) { + DatabaseModified(database.securityOrigin().databaseIdentifier(), + database.name()); +} + +void SimpleDatabaseSystem::databaseClosed(const WebKit::WebDatabase& database) { + DatabaseClosed(database.securityOrigin().databaseIdentifier(), + database.name()); +} + +void SimpleDatabaseSystem::ClearAllDatabases() { + db_tracker_->CloseTrackerDatabaseAndClearCaches(); + file_util::Delete(db_tracker_->DatabaseDirectory(), true); } diff --git a/webkit/tools/test_shell/simple_database_system.h b/webkit/tools/test_shell/simple_database_system.h index cf8c997..f741b97 100644 --- a/webkit/tools/test_shell/simple_database_system.h +++ b/webkit/tools/test_shell/simple_database_system.h @@ -5,34 +5,57 @@ #ifndef WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ #define WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ -#include "base/file_path.h" #include "base/platform_file.h" +#include "base/ref_counted.h" #include "base/scoped_temp_dir.h" +#include "base/string16.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDatabaseObserver.h" +#include "webkit/database/database_tracker.h" -class SimpleDatabaseSystem { +class SimpleDatabaseSystem : public webkit_database::DatabaseTracker::Observer, + public WebKit::WebDatabaseObserver { public: static SimpleDatabaseSystem* GetInstance(); SimpleDatabaseSystem(); ~SimpleDatabaseSystem(); - base::PlatformFile OpenFile( - const FilePath& file_name, int desired_flags, - base::PlatformFile* dir_handle); - int DeleteFile(const FilePath& file_name, bool sync_dir); - long GetFileAttributes(const FilePath& file_name); - long long GetFileSize(const FilePath& file_name); + // VFS functions + base::PlatformFile OpenFile(const string16& vfs_file_name, + int desired_flags, + base::PlatformFile* dir_handle); + int DeleteFile(const string16& vfs_file_name, bool sync_dir); + long GetFileAttributes(const string16& vfs_file_name); + long long GetFileSize(const string16& vfs_file_name); + + // database tracker functions + void DatabaseOpened(const string16& origin_identifier, + const string16& database_name, + const string16& description, + int64 estimated_size); + void DatabaseModified(const string16& origin_identifier, + const string16& database_name); + void DatabaseClosed(const string16& origin_identifier, + const string16& database_name); + + // DatabaseTracker::Observer implementation + virtual void OnDatabaseSizeChanged(const string16& origin_identifier, + const string16& database_name, + int64 database_size, + int64 space_available); + + // WebDatabaseObserver implementation + virtual void databaseOpened(const WebKit::WebDatabase& database); + virtual void databaseModified(const WebKit::WebDatabase& database); + virtual void databaseClosed(const WebKit::WebDatabase& database); + void ClearAllDatabases(); private: - FilePath GetDBDir(); - FilePath GetDBFileFullPath(const FilePath& file_name); - static SimpleDatabaseSystem* instance_; ScopedTempDir temp_dir_; - // HACK: see OpenFile's implementation - base::PlatformFile hack_main_db_handle_; + scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; }; #endif // WEBKIT_TOOLS_TEST_SHELL_SIMPLE_DATABASE_SYSTEM_H_ diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index f67fca0..de90237 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -12,6 +12,7 @@ #include "base/string_util.h" #include "media/base/media.h" #include "third_party/WebKit/WebKit/chromium/public/WebData.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDatabase.h" #include "third_party/WebKit/WebKit/chromium/public/WebRuntimeFeatures.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebScriptController.h" @@ -58,6 +59,7 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { extensions_v8::IntervalExtension::Get()); WebKit::WebRuntimeFeatures::enableSockets(true); WebKit::WebRuntimeFeatures::enableApplicationCache(true); + WebKit::WebRuntimeFeatures::enableDatabase(true); // Load libraries for media and enable the media player. FilePath module_path; @@ -71,6 +73,8 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { if (appcache_dir_.CreateUniqueTempDir()) SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); + WebKit::WebDatabase::setObserver(&database_system_); + #if defined(OS_WIN) // Ensure we pick up the default theme engine. SetThemeEngine(NULL); @@ -104,27 +108,27 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { } virtual WebKit::WebKitClient::FileHandle databaseOpenFile( - const WebKit::WebString& file_name, int desired_flags, + const WebKit::WebString& vfs_file_name, int desired_flags, WebKit::WebKitClient::FileHandle* dir_handle) { return SimpleDatabaseSystem::GetInstance()->OpenFile( - webkit_glue::WebStringToFilePath(file_name), - desired_flags, dir_handle); + vfs_file_name, desired_flags, dir_handle); } - virtual int databaseDeleteFile(const WebKit::WebString& file_name, + virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name, bool sync_dir) { return SimpleDatabaseSystem::GetInstance()->DeleteFile( - webkit_glue::WebStringToFilePath(file_name), sync_dir); + vfs_file_name, sync_dir); } - virtual long databaseGetFileAttributes(const WebKit::WebString& file_name) { + virtual long databaseGetFileAttributes( + const WebKit::WebString& vfs_file_name) { return SimpleDatabaseSystem::GetInstance()->GetFileAttributes( - webkit_glue::WebStringToFilePath(file_name)); + vfs_file_name); } - virtual long long databaseGetFileSize(const WebKit::WebString& file_name) { - return SimpleDatabaseSystem::GetInstance()->GetFileSize( - webkit_glue::WebStringToFilePath(file_name)); + virtual long long databaseGetFileSize( + const WebKit::WebString& vfs_file_name) { + return SimpleDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name); } virtual bool getFileSize(const WebKit::WebString& path, long long& result) { |