diff options
Diffstat (limited to 'chromium/content/browser/plugin_browsertest.cc')
-rw-r--r-- | chromium/content/browser/plugin_browsertest.cc | 131 |
1 files changed, 113 insertions, 18 deletions
diff --git a/chromium/content/browser/plugin_browsertest.cc b/chromium/content/browser/plugin_browsertest.cc index 37e1fa9449c..204a1432038 100644 --- a/chromium/content/browser/plugin_browsertest.cc +++ b/chromium/content/browser/plugin_browsertest.cc @@ -5,15 +5,21 @@ #include "base/command_line.h" #include "base/file_util.h" #include "base/path_service.h" +#include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" +#include "content/browser/loader/resource_dispatcher_host_impl.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" +#include "content/public/test/test_utils.h" #include "content/shell/browser/shell.h" #include "content/shell/common/shell_switches.h" #include "content/test/content_browser_test.h" #include "content/test/content_browser_test_utils.h" #include "content/test/net/url_request_mock_http_job.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "net/url_request/url_request.h" #include "ui/gfx/rect.h" #if defined(OS_WIN) @@ -77,17 +83,17 @@ class PluginTest : public ContentBrowserTest { } static void LoadAndWaitInWindow(Shell* window, const GURL& url) { - string16 expected_title(ASCIIToUTF16("OK")); + base::string16 expected_title(ASCIIToUTF16("OK")); TitleWatcher title_watcher(window->web_contents(), expected_title); title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); NavigateToURL(window, url); - string16 title = title_watcher.WaitAndGetTitle(); + base::string16 title = title_watcher.WaitAndGetTitle(); if (title == ASCIIToUTF16("plugin_not_found")) { const testing::TestInfo* const test_info = testing::UnitTest::GetInstance()->current_test_info(); - LOG(INFO) << "PluginTest." << test_info->name() << - " not running because plugin not installed."; + VLOG(0) << "PluginTest." << test_info->name() + << " not running because plugin not installed."; } else { EXPECT_EQ(expected_title, title); } @@ -111,8 +117,8 @@ class PluginTest : public ContentBrowserTest { if (!base::PathExists(path)) { const testing::TestInfo* const test_info = testing::UnitTest::GetInstance()->current_test_info(); - LOG(INFO) << "PluginTest." << test_info->name() << - " not running because test data wasn't found."; + VLOG(0) << "PluginTest." << test_info->name() + << " not running because test data wasn't found."; return; } @@ -164,17 +170,23 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeInSynchronousMouseUp)) { NavigateToURL(shell(), GetURL("execute_script_delete_in_mouse_up.html")); - string16 expected_title(ASCIIToUTF16("OK")); + base::string16 expected_title(ASCIIToUTF16("OK")); TitleWatcher title_watcher(shell()->web_contents(), expected_title); title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); SimulateMouseClick(shell()->web_contents(), 0, - WebKit::WebMouseEvent::ButtonLeft); + blink::WebMouseEvent::ButtonLeft); EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); } #endif -// Flaky, http://crbug.com/60071. -IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURLRequest404Response)) { +// Flaky, http://crbug.com/302274. +#if defined(OS_MACOSX) +#define MAYBE_GetURLRequest404Response DISABLED_GetURLRequest404Response +#else +#define MAYBE_GetURLRequest404Response MAYBE(GetURLRequest404Response) +#endif + +IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_GetURLRequest404Response) { GURL url(URLRequestMockHTTPJob::GetMockUrl( base::FilePath().AppendASCII("npapi"). AppendASCII("plugin_url_request_404.html"))); @@ -189,7 +201,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) { // race condition where the alert can come up before we start watching for it. shell()->LoadURL(GetURL("self_delete_plugin_invoke_alert.html")); - string16 expected_title(ASCIIToUTF16("OK")); + base::string16 expected_title(ASCIIToUTF16("OK")); TitleWatcher title_watcher(shell()->web_contents(), expected_title); title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); @@ -199,9 +211,12 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) { } // Test passing arguments to a plugin. +// crbug.com/306318 +#if !defined(OS_LINUX) IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Arguments)) { LoadAndWait(GetURL("arguments.html")); } +#endif // Test invoking many plugins within a single page. IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(ManyPlugins)) { @@ -226,7 +241,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetJavaScriptURL2)) { } // Test is flaky on linux/cros/win builders. http://crbug.com/71904 -IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_GetURLRedirectNotification) { +IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRedirectNotification) { LoadAndWait(GetURL("geturl_redirect_notify.html")); } @@ -264,10 +279,10 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInNewStream)) { LoadAndWait(GetURL("self_delete_plugin_stream.html")); } -// This test asserts on Mac in plugin_host in the NPNVWindowNPObject case. -#if !(defined(OS_MACOSX) && !defined(NDEBUG)) -// If this test flakes use http://crbug.com/95558. -IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(DeletePluginInDeallocate)) { +// On Mac this test asserts in plugin_host: http://crbug.com/95558 +// On all platforms it flakes in ~URLRequestContext: http://crbug.com/310336 +#if !defined(NDEBUG) +IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_DeletePluginInDeallocate) { LoadAndWait(GetURL("plugin_delete_in_deallocate.html")); } #endif @@ -393,7 +408,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { NavigateToURL(shell(), GetURL("convert_point.html")); - string16 expected_title(ASCIIToUTF16("OK")); + base::string16 expected_title(ASCIIToUTF16("OK")); TitleWatcher title_watcher(shell()->web_contents(), expected_title); title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); // TODO(stuartmorgan): When the automation system supports sending clicks, @@ -436,7 +451,14 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Real)) { TestPlugin("real.html"); } -IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(FlashOctetStream)) { +// http://crbug.com/320041 +#if (defined(OS_WIN) && defined(ARCH_CPU_X86_64)) || \ + (defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) +#define MAYBE_FlashOctetStream DISABLED_FlashOctetStream +#else +#define MAYBE_FlashOctetStream FlashOctetStream +#endif +IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_FlashOctetStream) { TestPlugin("flash-octet-stream.html"); } @@ -459,4 +481,77 @@ IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Silverlight)) { } #endif // defined(OS_WIN) +class TestResourceDispatcherHostDelegate + : public ResourceDispatcherHostDelegate { + public: + TestResourceDispatcherHostDelegate() : found_cookie_(false) {} + + bool found_cookie() { return found_cookie_; } + + void WaitForPluginRequest() { + if (found_cookie_) + return; + + runner_ = new MessageLoopRunner; + runner_->Run(); + } + + private: + // ResourceDispatcherHostDelegate implementation: + virtual void OnResponseStarted( + net::URLRequest* request, + ResourceContext* resource_context, + ResourceResponse* response, + IPC::Sender* sender) OVERRIDE { + // The URL below comes from plugin_geturl_test.cc. + if (!EndsWith(request->url().spec(), + "npapi/plugin_ref_target_page.html", + true)) { + return; + } + net::HttpRequestHeaders headers; + bool found_cookie = false; + if (request->GetFullRequestHeaders(&headers) && + headers.ToString().find("Cookie: blah") != std::string::npos) { + found_cookie = true; + } + BrowserThread::PostTask( + BrowserThread::UI, + FROM_HERE, + base::Bind(&TestResourceDispatcherHostDelegate::GotCookie, + base::Unretained(this), found_cookie)); + } + + void GotCookie(bool found_cookie) { + found_cookie_ = found_cookie; + if (runner_) + runner_->QuitClosure().Run(); + } + + scoped_refptr<MessageLoopRunner> runner_; + bool found_cookie_; + + DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate); +}; + +// Ensure that cookies get sent with plugin requests. +IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Cookies)) { + // Create a new browser just to ensure that the plugin process' child_id is + // not equal to its type (PROCESS_TYPE_PLUGIN), as that was the error which + // caused this bug. + NavigateToURL(CreateBrowser(), GURL("about:blank")); + + ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); + GURL url(embedded_test_server()->GetURL("/npapi/cookies.html")); + + TestResourceDispatcherHostDelegate test_delegate; + ResourceDispatcherHostDelegate* old_delegate = + ResourceDispatcherHostImpl::Get()->delegate(); + ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); + LoadAndWait(url); + test_delegate.WaitForPluginRequest(); + ASSERT_TRUE(test_delegate.found_cookie()); + ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); +} + } // namespace content |