| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/support/test_webkit_platform_support.h" | 5 #include "webkit/support/test_webkit_platform_support.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/metrics/stats_counters.h" | 10 #include "base/metrics/stats_counters.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "cc/output/context_provider.h" | 13 #include "cc/output/context_provider.h" |
| 14 #include "media/base/media.h" | 14 #include "media/base/media.h" |
| 15 #include "net/cookies/cookie_monster.h" | 15 #include "net/cookies/cookie_monster.h" |
| 16 #include "net/http/http_cache.h" | |
| 17 #include "net/test/spawned_test_server/spawned_test_server.h" | 16 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 18 #include "third_party/WebKit/public/web/WebDatabase.h" | 17 #include "third_party/WebKit/public/web/WebDatabase.h" |
| 19 #include "third_party/WebKit/public/web/WebKit.h" | 18 #include "third_party/WebKit/public/web/WebKit.h" |
| 20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 19 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 21 #include "third_party/WebKit/public/web/WebScriptController.h" | 20 #include "third_party/WebKit/public/web/WebScriptController.h" |
| 22 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 21 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 23 #include "third_party/WebKit/public/web/WebStorageEventDispatcher.h" | 22 #include "third_party/WebKit/public/web/WebStorageEventDispatcher.h" |
| 24 #include "third_party/WebKit/public/platform/WebAudioDevice.h" | 23 #include "third_party/WebKit/public/platform/WebAudioDevice.h" |
| 25 #include "third_party/WebKit/public/platform/WebData.h" | 24 #include "third_party/WebKit/public/platform/WebData.h" |
| 26 #include "third_party/WebKit/public/platform/WebFileSystem.h" | 25 #include "third_party/WebKit/public/platform/WebFileSystem.h" |
| 27 #include "third_party/WebKit/public/platform/WebGamepads.h" | 26 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 28 #include "third_party/WebKit/public/platform/WebStorageArea.h" | 27 #include "third_party/WebKit/public/platform/WebStorageArea.h" |
| 29 #include "third_party/WebKit/public/platform/WebStorageNamespace.h" | 28 #include "third_party/WebKit/public/platform/WebStorageNamespace.h" |
| 30 #include "third_party/WebKit/public/platform/WebString.h" | 29 #include "third_party/WebKit/public/platform/WebString.h" |
| 31 #include "third_party/WebKit/public/platform/WebURL.h" | 30 #include "third_party/WebKit/public/platform/WebURL.h" |
| 32 #include "v8/include/v8.h" | 31 #include "v8/include/v8.h" |
| 33 #include "webkit/browser/database/vfs_backend.h" | 32 #include "webkit/browser/database/vfs_backend.h" |
| 34 #include "webkit/common/gpu/test_context_provider_factory.h" | 33 #include "webkit/common/gpu/test_context_provider_factory.h" |
| 35 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" | 34 #include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.
h" |
| 36 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" | 35 #include "webkit/common/gpu/webgraphicscontext3d_provider_impl.h" |
| 37 #include "webkit/glue/simple_webmimeregistry_impl.h" | 36 #include "webkit/glue/simple_webmimeregistry_impl.h" |
| 38 #include "webkit/glue/webkit_glue.h" | 37 #include "webkit/glue/webkit_glue.h" |
| 39 #include "webkit/glue/webkitplatformsupport_impl.h" | 38 #include "webkit/glue/webkitplatformsupport_impl.h" |
| 40 #include "webkit/plugins/npapi/plugin_list.h" | 39 #include "webkit/plugins/npapi/plugin_list.h" |
| 41 #include "webkit/renderer/appcache/web_application_cache_host_impl.h" | 40 #include "webkit/renderer/appcache/web_application_cache_host_impl.h" |
| 42 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h" | 41 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h" |
| 43 #include "webkit/support/gc_extension.h" | 42 #include "webkit/support/gc_extension.h" |
| 44 #include "webkit/support/mock_webclipboard_impl.h" | 43 #include "webkit/support/mock_webclipboard_impl.h" |
| 45 #include "webkit/support/simple_appcache_system.h" | |
| 46 #include "webkit/support/simple_database_system.h" | |
| 47 #include "webkit/support/simple_file_system.h" | |
| 48 #include "webkit/support/simple_resource_loader_bridge.h" | |
| 49 #include "webkit/support/simple_socket_stream_bridge.h" | |
| 50 #include "webkit/support/simple_webcookiejar_impl.h" | |
| 51 #include "webkit/support/test_shell_request_context.h" | |
| 52 #include "webkit/support/test_shell_webblobregistry_impl.h" | 44 #include "webkit/support/test_shell_webblobregistry_impl.h" |
| 53 #include "webkit/support/test_webmessageportchannel.h" | 45 #include "webkit/support/test_webmessageportchannel.h" |
| 54 #include "webkit/support/web_audio_device_mock.h" | 46 #include "webkit/support/web_audio_device_mock.h" |
| 55 #include "webkit/support/web_gesture_curve_mock.h" | 47 #include "webkit/support/web_gesture_curve_mock.h" |
| 56 #include "webkit/support/web_layer_tree_view_impl_for_testing.h" | 48 #include "webkit/support/web_layer_tree_view_impl_for_testing.h" |
| 57 #include "webkit/support/webkit_support.h" | 49 #include "webkit/support/webkit_support.h" |
| 58 #include "webkit/support/weburl_loader_mock_factory.h" | 50 #include "webkit/support/weburl_loader_mock_factory.h" |
| 59 | 51 |
| 60 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
| 61 #include "third_party/WebKit/public/platform/win/WebThemeEngine.h" | 53 #include "third_party/WebKit/public/platform/win/WebThemeEngine.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 98 |
| 107 // Construct and initialize an appcache system for this scope. | 99 // Construct and initialize an appcache system for this scope. |
| 108 // A new empty temp directory is created to house any cached | 100 // A new empty temp directory is created to house any cached |
| 109 // content during the run. Upon exit that directory is deleted. | 101 // content during the run. Upon exit that directory is deleted. |
| 110 // If we can't create a tempdir, we'll use in-memory storage. | 102 // If we can't create a tempdir, we'll use in-memory storage. |
| 111 if (!appcache_dir_.CreateUniqueTempDir()) { | 103 if (!appcache_dir_.CreateUniqueTempDir()) { |
| 112 LOG(WARNING) << "Failed to create a temp dir for the appcache, " | 104 LOG(WARNING) << "Failed to create a temp dir for the appcache, " |
| 113 "using in-memory storage."; | 105 "using in-memory storage."; |
| 114 DCHECK(appcache_dir_.path().empty()); | 106 DCHECK(appcache_dir_.path().empty()); |
| 115 } | 107 } |
| 116 SimpleAppCacheSystem::InitializeOnUIThread(appcache_dir_.path()); | |
| 117 | |
| 118 WebKit::WebDatabase::setObserver(&database_system_); | |
| 119 | 108 |
| 120 blob_registry_ = new TestShellWebBlobRegistryImpl(); | 109 blob_registry_ = new TestShellWebBlobRegistryImpl(); |
| 121 | 110 |
| 122 file_utilities_.set_sandbox_enabled(false); | 111 file_utilities_.set_sandbox_enabled(false); |
| 123 | 112 |
| 124 if (!file_system_root_.CreateUniqueTempDir()) { | 113 if (!file_system_root_.CreateUniqueTempDir()) { |
| 125 LOG(WARNING) << "Failed to create a temp dir for the filesystem." | 114 LOG(WARNING) << "Failed to create a temp dir for the filesystem." |
| 126 "FileSystem feature will be disabled."; | 115 "FileSystem feature will be disabled."; |
| 127 DCHECK(file_system_root_.path().empty()); | 116 DCHECK(file_system_root_.path().empty()); |
| 128 } | 117 } |
| 129 | 118 |
| 130 { | 119 { |
| 131 // Initialize the hyphen library with a sample dictionary. | 120 // Initialize the hyphen library with a sample dictionary. |
| 132 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); | 121 base::FilePath path = webkit_support::GetChromiumRootDirFilePath(); |
| 133 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); | 122 path = path.Append(FILE_PATH_LITERAL("third_party/hyphen/hyph_en_US.dic")); |
| 134 base::PlatformFile dict_file = base::CreatePlatformFile( | 123 base::PlatformFile dict_file = base::CreatePlatformFile( |
| 135 path, | 124 path, |
| 136 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, | 125 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, |
| 137 NULL, NULL); | 126 NULL, NULL); |
| 138 hyphenator_.LoadDictionary(dict_file); | 127 hyphenator_.LoadDictionary(dict_file); |
| 139 } | 128 } |
| 140 | 129 |
| 141 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 142 // Ensure we pick up the default theme engine. | 131 // Ensure we pick up the default theme engine. |
| 143 SetThemeEngine(NULL); | 132 SetThemeEngine(NULL); |
| 144 #endif | 133 #endif |
| 145 | 134 |
| 146 net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL; | |
| 147 net::CookieMonster::EnableFileScheme(); | 135 net::CookieMonster::EnableFileScheme(); |
| 148 | 136 |
| 149 // Initializing with a default context, which means no on-disk cookie DB, | |
| 150 // and no support for directory listings. | |
| 151 SimpleResourceLoaderBridge::Init(base::FilePath(), cache_mode, true); | |
| 152 | |
| 153 // Test shell always exposes the GC. | 137 // Test shell always exposes the GC. |
| 154 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 138 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
| 155 // Expose GCController to JavaScript. | 139 // Expose GCController to JavaScript. |
| 156 WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); | 140 WebScriptController::registerExtension(extensions_v8::GCExtension::Get()); |
| 157 } | 141 } |
| 158 | 142 |
| 159 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { | 143 TestWebKitPlatformSupport::~TestWebKitPlatformSupport() { |
| 160 } | 144 } |
| 161 | 145 |
| 162 WebKit::WebMimeRegistry* TestWebKitPlatformSupport::mimeRegistry() { | 146 WebKit::WebMimeRegistry* TestWebKitPlatformSupport::mimeRegistry() { |
| 163 return &mime_registry_; | 147 return &mime_registry_; |
| 164 } | 148 } |
| 165 | 149 |
| 166 WebKit::WebClipboard* TestWebKitPlatformSupport::clipboard() { | 150 WebKit::WebClipboard* TestWebKitPlatformSupport::clipboard() { |
| 167 // Mock out clipboard calls so that tests don't mess | 151 // Mock out clipboard calls so that tests don't mess |
| 168 // with each other's copies/pastes when running in parallel. | 152 // with each other's copies/pastes when running in parallel. |
| 169 return &mock_clipboard_; | 153 return &mock_clipboard_; |
| 170 } | 154 } |
| 171 | 155 |
| 172 WebKit::WebFileUtilities* TestWebKitPlatformSupport::fileUtilities() { | 156 WebKit::WebFileUtilities* TestWebKitPlatformSupport::fileUtilities() { |
| 173 return &file_utilities_; | 157 return &file_utilities_; |
| 174 } | 158 } |
| 175 | 159 |
| 176 WebKit::WebSandboxSupport* TestWebKitPlatformSupport::sandboxSupport() { | 160 WebKit::WebSandboxSupport* TestWebKitPlatformSupport::sandboxSupport() { |
| 177 return NULL; | 161 return NULL; |
| 178 } | 162 } |
| 179 | 163 |
| 180 WebKit::WebCookieJar* TestWebKitPlatformSupport::cookieJar() { | |
| 181 return &cookie_jar_; | |
| 182 } | |
| 183 | |
| 184 WebKit::WebBlobRegistry* TestWebKitPlatformSupport::blobRegistry() { | 164 WebKit::WebBlobRegistry* TestWebKitPlatformSupport::blobRegistry() { |
| 185 return blob_registry_.get(); | 165 return blob_registry_.get(); |
| 186 } | 166 } |
| 187 | 167 |
| 188 WebKit::WebFileSystem* TestWebKitPlatformSupport::fileSystem() { | |
| 189 return &file_system_; | |
| 190 } | |
| 191 | |
| 192 WebKit::WebHyphenator* TestWebKitPlatformSupport::hyphenator() { | 168 WebKit::WebHyphenator* TestWebKitPlatformSupport::hyphenator() { |
| 193 return &hyphenator_; | 169 return &hyphenator_; |
| 194 } | 170 } |
| 195 | 171 |
| 196 WebKit::WebIDBFactory* TestWebKitPlatformSupport::idbFactory() { | 172 WebKit::WebIDBFactory* TestWebKitPlatformSupport::idbFactory() { |
| 197 NOTREACHED() << | 173 NOTREACHED() << |
| 198 "IndexedDB cannot be tested with in-process harnesses."; | 174 "IndexedDB cannot be tested with in-process harnesses."; |
| 199 return NULL; | 175 return NULL; |
| 200 } | 176 } |
| 201 | 177 |
| 202 bool TestWebKitPlatformSupport::sandboxEnabled() { | 178 bool TestWebKitPlatformSupport::sandboxEnabled() { |
| 203 return true; | 179 return true; |
| 204 } | 180 } |
| 205 | 181 |
| 206 WebKit::Platform::FileHandle | |
| 207 TestWebKitPlatformSupport::databaseOpenFile( | |
| 208 const WebKit::WebString& vfs_file_name, int desired_flags) { | |
| 209 return SimpleDatabaseSystem::GetInstance()->OpenFile( | |
| 210 vfs_file_name, desired_flags); | |
| 211 } | |
| 212 | |
| 213 int TestWebKitPlatformSupport::databaseDeleteFile( | |
| 214 const WebKit::WebString& vfs_file_name, bool sync_dir) { | |
| 215 return SimpleDatabaseSystem::GetInstance()->DeleteFile( | |
| 216 vfs_file_name, sync_dir); | |
| 217 } | |
| 218 | |
| 219 long TestWebKitPlatformSupport::databaseGetFileAttributes( | |
| 220 const WebKit::WebString& vfs_file_name) { | |
| 221 return SimpleDatabaseSystem::GetInstance()->GetFileAttributes( | |
| 222 vfs_file_name); | |
| 223 } | |
| 224 | |
| 225 long long TestWebKitPlatformSupport::databaseGetFileSize( | |
| 226 const WebKit::WebString& vfs_file_name) { | |
| 227 return SimpleDatabaseSystem::GetInstance()->GetFileSize(vfs_file_name); | |
| 228 } | |
| 229 | |
| 230 long long TestWebKitPlatformSupport::databaseGetSpaceAvailableForOrigin( | |
| 231 const WebKit::WebString& origin_identifier) { | |
| 232 return SimpleDatabaseSystem::GetInstance()->GetSpaceAvailable( | |
| 233 origin_identifier.utf8()); | |
| 234 } | |
| 235 | |
| 236 unsigned long long TestWebKitPlatformSupport::visitedLinkHash( | 182 unsigned long long TestWebKitPlatformSupport::visitedLinkHash( |
| 237 const char* canonicalURL, size_t length) { | 183 const char* canonicalURL, size_t length) { |
| 238 return 0; | 184 return 0; |
| 239 } | 185 } |
| 240 | 186 |
| 241 bool TestWebKitPlatformSupport::isLinkVisited(unsigned long long linkHash) { | 187 bool TestWebKitPlatformSupport::isLinkVisited(unsigned long long linkHash) { |
| 242 return false; | 188 return false; |
| 243 } | 189 } |
| 244 | 190 |
| 245 WebKit::WebMessagePortChannel* | 191 WebKit::WebMessagePortChannel* |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 return ASCIIToUTF16("too long"); | 263 return ASCIIToUTF16("too long"); |
| 318 if (name == WebKit::WebLocalizedString::ValidationStepMismatch) | 264 if (name == WebKit::WebLocalizedString::ValidationStepMismatch) |
| 319 return ASCIIToUTF16("step mismatch"); | 265 return ASCIIToUTF16("step mismatch"); |
| 320 return WebKitPlatformSupportImpl::queryLocalizedString(name, value1, value2); | 266 return WebKitPlatformSupportImpl::queryLocalizedString(name, value1, value2); |
| 321 } | 267 } |
| 322 | 268 |
| 323 WebKit::WebString TestWebKitPlatformSupport::defaultLocale() { | 269 WebKit::WebString TestWebKitPlatformSupport::defaultLocale() { |
| 324 return ASCIIToUTF16("en-US"); | 270 return ASCIIToUTF16("en-US"); |
| 325 } | 271 } |
| 326 | 272 |
| 327 WebKit::WebStorageNamespace* | |
| 328 TestWebKitPlatformSupport::createLocalStorageNamespace( | |
| 329 const WebKit::WebString& path, unsigned quota) { | |
| 330 return dom_storage_system_.CreateLocalStorageNamespace(); | |
| 331 } | |
| 332 | |
| 333 #if defined(OS_WIN) || defined(OS_MACOSX) | 273 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 334 void TestWebKitPlatformSupport::SetThemeEngine(WebKit::WebThemeEngine* engine) { | 274 void TestWebKitPlatformSupport::SetThemeEngine(WebKit::WebThemeEngine* engine) { |
| 335 active_theme_engine_ = engine ? | 275 active_theme_engine_ = engine ? |
| 336 engine : WebKitPlatformSupportImpl::themeEngine(); | 276 engine : WebKitPlatformSupportImpl::themeEngine(); |
| 337 } | 277 } |
| 338 | 278 |
| 339 WebKit::WebThemeEngine* TestWebKitPlatformSupport::themeEngine() { | 279 WebKit::WebThemeEngine* TestWebKitPlatformSupport::themeEngine() { |
| 340 return active_theme_engine_; | 280 return active_theme_engine_; |
| 341 } | 281 } |
| 342 #endif | 282 #endif |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 void TestWebKitPlatformSupport::GetPlugins( | 358 void TestWebKitPlatformSupport::GetPlugins( |
| 419 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { | 359 bool refresh, std::vector<webkit::WebPluginInfo>* plugins) { |
| 420 if (refresh) | 360 if (refresh) |
| 421 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 361 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 422 webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); | 362 webkit::npapi::PluginList::Singleton()->GetPlugins(plugins); |
| 423 } | 363 } |
| 424 | 364 |
| 425 webkit_glue::ResourceLoaderBridge* | 365 webkit_glue::ResourceLoaderBridge* |
| 426 TestWebKitPlatformSupport::CreateResourceLoader( | 366 TestWebKitPlatformSupport::CreateResourceLoader( |
| 427 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { | 367 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info) { |
| 428 return SimpleResourceLoaderBridge::Create(request_info); | 368 NOTREACHED(); |
| 369 return NULL; |
| 429 } | 370 } |
| 430 | 371 |
| 431 webkit_glue::WebSocketStreamHandleBridge* | 372 webkit_glue::WebSocketStreamHandleBridge* |
| 432 TestWebKitPlatformSupport::CreateWebSocketBridge( | 373 TestWebKitPlatformSupport::CreateWebSocketBridge( |
| 433 WebKit::WebSocketStreamHandle* handle, | 374 WebKit::WebSocketStreamHandle* handle, |
| 434 webkit_glue::WebSocketStreamHandleDelegate* delegate) { | 375 webkit_glue::WebSocketStreamHandleDelegate* delegate) { |
| 435 return SimpleSocketStreamBridge::Create(handle, delegate); | 376 NOTREACHED(); |
| 377 return NULL; |
| 436 } | 378 } |
| 437 | 379 |
| 438 WebKit::WebMediaStreamCenter* | 380 WebKit::WebMediaStreamCenter* |
| 439 TestWebKitPlatformSupport::createMediaStreamCenter( | 381 TestWebKitPlatformSupport::createMediaStreamCenter( |
| 440 WebKit::WebMediaStreamCenterClient* client) { | 382 WebKit::WebMediaStreamCenterClient* client) { |
| 441 | 383 |
| 442 return webkit_glue::WebKitPlatformSupportImpl::createMediaStreamCenter( | 384 return webkit_glue::WebKitPlatformSupportImpl::createMediaStreamCenter( |
| 443 client); | 385 client); |
| 444 } | 386 } |
| 445 | 387 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return view.release(); | 447 return view.release(); |
| 506 } | 448 } |
| 507 | 449 |
| 508 WebKit::WebLayerTreeView* | 450 WebKit::WebLayerTreeView* |
| 509 TestWebKitPlatformSupport::createLayerTreeViewForTesting( | 451 TestWebKitPlatformSupport::createLayerTreeViewForTesting( |
| 510 TestViewType type) { | 452 TestViewType type) { |
| 511 DCHECK_EQ(TestViewTypeUnitTest, type); | 453 DCHECK_EQ(TestViewTypeUnitTest, type); |
| 512 return createLayerTreeViewForTesting(); | 454 return createLayerTreeViewForTesting(); |
| 513 } | 455 } |
| 514 | 456 |
| OLD | NEW |