| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 10 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 12 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| 13 #include "content/public/common/content_switches.h" | 13 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
| 15 #include "content/public/test/content_browser_test.h" | 15 #include "content/public/test/content_browser_test.h" |
| 16 #include "content/public/test/content_browser_test_utils.h" | 16 #include "content/public/test/content_browser_test_utils.h" |
| 17 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
| 18 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
| 19 #include "content/shell/common/shell_switches.h" | 19 #include "content/shell/common/shell_switches.h" |
| 20 #include "content/test/net/url_request_mock_http_job.h" | |
| 21 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "net/test/url_request/url_request_mock_http_job.h" |
| 22 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
| 23 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
| 24 | 24 |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| 26 #include "base/win/registry.h" | 26 #include "base/win/registry.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 // TODO(jschuh): Finish plugins on Win64. crbug.com/180861 | 29 // TODO(jschuh): Finish plugins on Win64. crbug.com/180861 |
| 30 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) | 30 #if defined(OS_WIN) && defined(ARCH_CPU_X86_64) |
| 31 #define MAYBE(x) DISABLED_##x | 31 #define MAYBE(x) DISABLED_##x |
| 32 #else | 32 #else |
| 33 #define MAYBE(x) x | 33 #define MAYBE(x) x |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 using base::ASCIIToUTF16; | 36 using base::ASCIIToUTF16; |
| 37 | 37 |
| 38 namespace content { | 38 namespace content { |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 void SetUrlRequestMock(const base::FilePath& path) { | 41 void SetUrlRequestMock(const base::FilePath& path) { |
| 42 URLRequestMockHTTPJob::AddUrlHandler(path); | 42 net::URLRequestMockHTTPJob::AddUrlHandler( |
| 43 path, content::BrowserThread::GetBlockingPool()); |
| 43 } | 44 } |
| 44 | 45 |
| 45 } | 46 } |
| 46 | 47 |
| 47 class PluginTest : public ContentBrowserTest { | 48 class PluginTest : public ContentBrowserTest { |
| 48 protected: | 49 protected: |
| 49 PluginTest() {} | 50 PluginTest() {} |
| 50 | 51 |
| 51 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 52 // Some NPAPI tests schedule garbage collection to force object tear-down. | 53 // Some NPAPI tests schedule garbage collection to force object tear-down. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 #endif | 180 #endif |
| 180 | 181 |
| 181 // Flaky, http://crbug.com/302274. | 182 // Flaky, http://crbug.com/302274. |
| 182 #if defined(OS_MACOSX) | 183 #if defined(OS_MACOSX) |
| 183 #define MAYBE_GetURLRequest404Response DISABLED_GetURLRequest404Response | 184 #define MAYBE_GetURLRequest404Response DISABLED_GetURLRequest404Response |
| 184 #else | 185 #else |
| 185 #define MAYBE_GetURLRequest404Response MAYBE(GetURLRequest404Response) | 186 #define MAYBE_GetURLRequest404Response MAYBE(GetURLRequest404Response) |
| 186 #endif | 187 #endif |
| 187 | 188 |
| 188 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_GetURLRequest404Response) { | 189 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_GetURLRequest404Response) { |
| 189 GURL url(URLRequestMockHTTPJob::GetMockUrl( | 190 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 190 base::FilePath().AppendASCII("npapi"). | 191 base::FilePath().AppendASCII("npapi").AppendASCII( |
| 191 AppendASCII("plugin_url_request_404.html"))); | 192 "plugin_url_request_404.html"))); |
| 192 LoadAndWait(url); | 193 LoadAndWait(url); |
| 193 } | 194 } |
| 194 | 195 |
| 195 // Tests if a plugin executing a self deleting script using Invoke with | 196 // Tests if a plugin executing a self deleting script using Invoke with |
| 196 // a modal dialog showing works without crashing or hanging | 197 // a modal dialog showing works without crashing or hanging |
| 197 // Disabled, flakily exceeds timeout, http://crbug.com/46257. | 198 // Disabled, flakily exceeds timeout, http://crbug.com/46257. |
| 198 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) { | 199 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) { |
| 199 // Navigate asynchronously because if we waitd until it completes, there's a | 200 // Navigate asynchronously because if we waitd until it completes, there's a |
| 200 // race condition where the alert can come up before we start watching for it. | 201 // race condition where the alert can come up before we start watching for it. |
| 201 shell()->LoadURL(GetURL("self_delete_plugin_invoke_alert.html")); | 202 shell()->LoadURL(GetURL("self_delete_plugin_invoke_alert.html")); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 375 |
| 375 // These used to run on Windows: http://crbug.com/396373 | 376 // These used to run on Windows: http://crbug.com/396373 |
| 376 #if defined(OS_MACOSX) | 377 #if defined(OS_MACOSX) |
| 377 // Test a browser hang due to special case of multiple | 378 // Test a browser hang due to special case of multiple |
| 378 // plugin instances indulged in sync calls across renderer. | 379 // plugin instances indulged in sync calls across renderer. |
| 379 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(MultipleInstancesSyncCalls)) { | 380 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(MultipleInstancesSyncCalls)) { |
| 380 LoadAndWait(GetURL("multiple_instances_sync_calls.html")); | 381 LoadAndWait(GetURL("multiple_instances_sync_calls.html")); |
| 381 } | 382 } |
| 382 | 383 |
| 383 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURLRequestFailWrite)) { | 384 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURLRequestFailWrite)) { |
| 384 GURL url(URLRequestMockHTTPJob::GetMockUrl( | 385 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 385 base::FilePath().AppendASCII("npapi"). | 386 base::FilePath().AppendASCII("npapi").AppendASCII( |
| 386 AppendASCII("plugin_url_request_fail_write.html"))); | 387 "plugin_url_request_fail_write.html"))); |
| 387 LoadAndWait(url); | 388 LoadAndWait(url); |
| 388 } | 389 } |
| 389 #endif | 390 #endif |
| 390 | 391 |
| 391 #if defined(OS_WIN) | 392 #if defined(OS_WIN) |
| 392 // Flaky on Windows x86. http://crbug.com/388245 | 393 // Flaky on Windows x86. http://crbug.com/388245 |
| 393 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_EnsureScriptingWorksInDestroy) { | 394 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_EnsureScriptingWorksInDestroy) { |
| 394 LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html")); | 395 LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html")); |
| 395 } | 396 } |
| 396 | 397 |
| 397 // This test uses a Windows Event to signal to the plugin that it should crash | 398 // This test uses a Windows Event to signal to the plugin that it should crash |
| 398 // on NP_Initialize. | 399 // on NP_Initialize. |
| 399 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NoHangIfInitCrashes)) { | 400 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NoHangIfInitCrashes)) { |
| 400 HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); | 401 HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); |
| 401 SetEvent(crash_event); | 402 SetEvent(crash_event); |
| 402 LoadAndWait(GetURL("no_hang_if_init_crashes.html")); | 403 LoadAndWait(GetURL("no_hang_if_init_crashes.html")); |
| 403 CloseHandle(crash_event); | 404 CloseHandle(crash_event); |
| 404 } | 405 } |
| 405 #endif | 406 #endif |
| 406 | 407 |
| 407 // If this flakes on Mac, use http://crbug.com/111508 | 408 // If this flakes on Mac, use http://crbug.com/111508 |
| 408 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PluginReferrerTest)) { | 409 IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PluginReferrerTest)) { |
| 409 GURL url(URLRequestMockHTTPJob::GetMockUrl( | 410 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 410 base::FilePath().AppendASCII("npapi"). | 411 base::FilePath().AppendASCII("npapi").AppendASCII( |
| 411 AppendASCII("plugin_url_request_referrer_test.html"))); | 412 "plugin_url_request_referrer_test.html"))); |
| 412 LoadAndWait(url); | 413 LoadAndWait(url); |
| 413 } | 414 } |
| 414 | 415 |
| 415 #if defined(OS_MACOSX) | 416 #if defined(OS_MACOSX) |
| 416 // Test is flaky, see http://crbug.com/134515. | 417 // Test is flaky, see http://crbug.com/134515. |
| 417 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { | 418 IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { |
| 418 gfx::Rect bounds(50, 50, 400, 400); | 419 gfx::Rect bounds(50, 50, 400, 400); |
| 419 SetWindowBounds(shell()->window(), bounds); | 420 SetWindowBounds(shell()->window(), bounds); |
| 420 | 421 |
| 421 NavigateToURL(shell(), GetURL("convert_point.html")); | 422 NavigateToURL(shell(), GetURL("convert_point.html")); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 ResourceDispatcherHostDelegate* old_delegate = | 562 ResourceDispatcherHostDelegate* old_delegate = |
| 562 ResourceDispatcherHostImpl::Get()->delegate(); | 563 ResourceDispatcherHostImpl::Get()->delegate(); |
| 563 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); | 564 ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); |
| 564 LoadAndWait(url); | 565 LoadAndWait(url); |
| 565 test_delegate.WaitForPluginRequest(); | 566 test_delegate.WaitForPluginRequest(); |
| 566 ASSERT_TRUE(test_delegate.found_cookie()); | 567 ASSERT_TRUE(test_delegate.found_cookie()); |
| 567 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); | 568 ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); |
| 568 } | 569 } |
| 569 | 570 |
| 570 } // namespace content | 571 } // namespace content |
| OLD | NEW |