15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/command_line.h" 61320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "base/files/file_util.h" 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/path_service.h" 8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "base/strings/string_util.h" 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/utf_string_conversions.h" 10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/browser/loader/resource_dispatcher_host_impl.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/browser_thread.h" 12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/public/browser/resource_dispatcher_host_delegate.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/content_switches.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/test/browser_test_utils.h" 15effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "content/public/test/content_browser_test.h" 16effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "content/public/test/content_browser_test_utils.h" 17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "content/public/test/test_utils.h" 183551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)#include "content/shell/browser/shell.h" 19b2df76ea8fec9e32f6f3718986dba0d95315b29cTorne (Richard Coles)#include "content/shell/common/shell_switches.h" 20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "net/test/embedded_test_server/embedded_test_server.h" 211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "net/test/url_request/url_request_mock_http_job.h" 22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "net/url_request/url_request.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/rect.h" 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/win/registry.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// TODO(jschuh): Finish plugins on Win64. crbug.com/180861 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if defined(OS_WIN) && defined(ARCH_CPU_X86_64) 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MAYBE(x) DISABLED_##x 322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#else 332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define MAYBE(x) x 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using base::ASCIIToUTF16; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void SetUrlRequestMock(const base::FilePath& path) { 421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci net::URLRequestMockHTTPJob::AddUrlHandler( 431320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci path, content::BrowserThread::GetBlockingPool()); 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class PluginTest : public ContentBrowserTest { 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PluginTest() {} 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Some NPAPI tests schedule garbage collection to force object tear-down. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose_gc"); 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const testing::TestInfo* const test_info = 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) testing::UnitTest::GetInstance()->current_test_info(); 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (strcmp(test_info->name(), "MediaPlayerNew") == 0) { 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The installer adds our process names to the registry key below. Since 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the installer might not have run on this machine, add it manually. 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base::win::RegKey regkey; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (regkey.Open(HKEY_LOCAL_MACHINE, 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) L"Software\\Microsoft\\MediaPlayer\\ShimInclusionList", 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) KEY_WRITE) == ERROR_SUCCESS) { 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) regkey.CreateKey(L"BROWSER_TESTS.EXE", KEY_READ); 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#elif defined(OS_MACOSX) 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath plugin_dir; 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PathService::Get(base::DIR_MODULE, &plugin_dir); 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) plugin_dir = plugin_dir.AppendASCII("plugins"); 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The plugins directory isn't read by default on the Mac, so it needs to be 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // explicitly registered. 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir); 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetUpOnMainThread() OVERRIDE { 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath path = GetTestFilePath("", ""); 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserThread::PostTask( 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) BrowserThread::IO, FROM_HERE, base::Bind(&SetUrlRequestMock, path)); 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static void LoadAndWaitInWindow(Shell* window, const GURL& url) { 86a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 expected_title(ASCIIToUTF16("OK")); 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TitleWatcher title_watcher(window->web_contents(), expected_title); 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found")); 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateToURL(window, url); 91a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 title = title_watcher.WaitAndGetTitle(); 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) if (title == ASCIIToUTF16("plugin_not_found")) { 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const testing::TestInfo* const test_info = 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) testing::UnitTest::GetInstance()->current_test_info(); 95f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) VLOG(0) << "PluginTest." << test_info->name() 96f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) << " not running because plugin not installed."; 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } else { 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(expected_title, title); 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void LoadAndWait(const GURL& url) { 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWaitInWindow(shell(), url); 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL GetURL(const char* filename) { 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return GetTestUrl("npapi", filename); 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void NavigateAway() { 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url = GetTestUrl("", "simple_page.html"); 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(url); 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void TestPlugin(const char* filename) { 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) base::FilePath path = GetTestFilePath("plugin", filename); 1177dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch if (!base::PathExists(path)) { 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const testing::TestInfo* const test_info = 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) testing::UnitTest::GetInstance()->current_test_info(); 120f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) VLOG(0) << "PluginTest." << test_info->name() 121f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) << " not running because test data wasn't found."; 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return; 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url = GetTestUrl("plugin", filename); 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(url); 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Make sure that navigating away from a plugin referenced by JS doesn't 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// crash. 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, UnloadNoCrash) { 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("layout_test_plugin.html")); 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateAway(); 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests if a plugin executing a self deleting script using NPN_GetURL 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// works without crashing or hanging 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky: http://crbug.com/59327 14090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginGetUrl)) { 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("self_delete_plugin_geturl.html")); 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests if a plugin executing a self deleting script using Invoke 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// works without crashing or hanging 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky. See http://crbug.com/30702 14790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvoke)) { 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("self_delete_plugin_invoke.html")); 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NPObjectReleasedOnDestruction)) { 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateToURL(shell(), GetURL("npobject_released_on_destruction.html")); 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateAway(); 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that a dialog is properly created when a plugin throws an 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// exception. Should be run for in and out of process plugins, but 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the more interesting case is out of process, where we must route 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// the exception to the correct renderer. 160868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NPObjectSetException)) { 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("npobject_set_exception.html")); 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests if a plugin executing a self deleting script in the context of 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a synchronous mouseup works correctly. 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This was never ported to Mac. The only thing remaining is to make 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// SimulateMouseClick get to Mac plugins, currently it doesn't work. 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, 17090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) MAYBE(SelfDeletePluginInvokeInSynchronousMouseUp)) { 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateToURL(shell(), GetURL("execute_script_delete_in_mouse_up.html")); 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 173a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 expected_title(ASCIIToUTF16("OK")); 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TitleWatcher title_watcher(shell()->web_contents(), expected_title); 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SimulateMouseClick(shell()->web_contents(), 0, 177f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) blink::WebMouseEvent::ButtonLeft); 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1824e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// Flaky, http://crbug.com/302274. 1834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#if defined(OS_MACOSX) 1844e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#define MAYBE_GetURLRequest404Response DISABLED_GetURLRequest404Response 1854e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#else 1864e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#define MAYBE_GetURLRequest404Response MAYBE(GetURLRequest404Response) 1874e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif 1884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 1894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_GetURLRequest404Response) { 1901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GURL url(net::URLRequestMockHTTPJob::GetMockUrl( 1911320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::FilePath().AppendASCII("npapi").AppendASCII( 1921320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci "plugin_url_request_404.html"))); 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(url); 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests if a plugin executing a self deleting script using Invoke with 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a modal dialog showing works without crashing or hanging 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Disabled, flakily exceeds timeout, http://crbug.com/46257. 19990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInvokeAlert)) { 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Navigate asynchronously because if we waitd until it completes, there's a 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // race condition where the alert can come up before we start watching for it. 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) shell()->LoadURL(GetURL("self_delete_plugin_invoke_alert.html")); 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 204a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 expected_title(ASCIIToUTF16("OK")); 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TitleWatcher title_watcher(shell()->web_contents(), expected_title); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WaitForAppModalDialog(shell()); 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test passing arguments to a plugin. 2144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)// crbug.com/306318 2154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#if !defined(OS_LINUX) 21690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Arguments)) { 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("arguments.html")); 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2194e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#endif 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test invoking many plugins within a single page. 222868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(ManyPlugins)) { 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("many_plugins.html")); 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#if !defined(OS_MACOSX) // http://crbug.com/402164 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test various calls to GetURL from a plugin. 228868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURL)) { 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("geturl.html")); 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2316e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#endif 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test various calls to GetURL for javascript URLs with 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// non NULL targets from a plugin. 235868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetJavaScriptURL)) { 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("get_javascript_url.html")); 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test that calling GetURL with a javascript URL and target=_self 2405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// works properly when the plugin is embedded in a subframe. 241868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetJavaScriptURL2)) { 2425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("get_javascript_url2.html")); 2435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test is flaky on linux/cros/win builders. http://crbug.com/71904 246f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, GetURLRedirectNotification) { 2475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("geturl_redirect_notify.html")); 2485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that identity is preserved for NPObjects passed from a plugin 2515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// into JavaScript. 252868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NPObjectIdentity)) { 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("npobject_identity.html")); 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that if an NPObject is proxies back to its original process, the 2575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// original pointer is returned and not a proxy. If this fails the plugin 2585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// will crash. 259868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NPObjectProxy)) { 2605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("npobject_proxy.html")); 2615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) || defined(OS_MACOSX) 2645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests if a plugin executing a self deleting script in the context of 2655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a synchronous paint event works correctly 2665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// http://crbug.com/44960 267868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, 268868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) MAYBE(SelfDeletePluginInvokeInSynchronousPaint)) { 2695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("execute_script_delete_in_paint.html")); 2705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 2725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that if a plugin executes a self resizing script in the context of a 2745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// synchronous paint, the plugin doesn't use deallocated memory. 2755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// http://crbug.com/139462 276868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(ResizeDuringPaint)) { 2775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("resize_during_paint.html")); 2785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 280868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInNewStream)) { 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("self_delete_plugin_stream.html")); 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// On Mac this test asserts in plugin_host: http://crbug.com/95558 2851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// On all platforms it flakes in ~URLRequestContext: http://crbug.com/310336 2861e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#if !defined(NDEBUG) 2871e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_DeletePluginInDeallocate) { 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("plugin_delete_in_deallocate.html")); 2895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 2915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 2935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 294868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(VerifyPluginWindowRect)) { 2955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("verify_plugin_window_rect.html")); 2965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that creating a new instance of a plugin while another one is handling 2995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// a paint message doesn't cause deadlock. 30003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// http://crbug.com/406184 30103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_CreateInstanceInPaint) { 3025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("create_instance_in_paint.html")); 3035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that putting up an alert in response to a paint doesn't deadlock. 3062a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_AlertInWindowMessage) { 3075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateToURL(shell(), GetURL("alert_in_window_message.html")); 3085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WaitForAppModalDialog(shell()); 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WaitForAppModalDialog(shell()); 3115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 31303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)// http://crbug.com/406184 31403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_VerifyNPObjectLifetimeTest) { 3155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("npobject_lifetime_test.html")); 3165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Tests that we don't crash or assert if NPP_New fails 319868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NewFails)) { 3205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("new_fails.html")); 3215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(SelfDeletePluginInNPNEvaluate)) { 3245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("execute_script_delete_in_npn_evaluate.html")); 3255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, 3282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) MAYBE(SelfDeleteCreatePluginInNPNEvaluate)) { 3295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("npn_plugin_delete_create_in_evaluate.html")); 3305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // OS_WIN 3335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If this flakes, reopen http://crbug.com/17645 3355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// As of 6 July 2011, this test is flaky on Windows (perhaps due to timing out). 336a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#if !defined(OS_MACOSX) && !defined(OS_LINUX) 3375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Disabled on Mac because the plugin side isn't implemented yet, see 3385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// "TODO(port)" in plugin_javascript_open_popup.cc. 339a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch// Disabled on Linux because we don't support NPAPI any more. 340868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(OpenPopupWindowWithPlugin)) { 3415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("get_javascript_open_popup_with_plugin.html")); 3425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 3445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test checking the privacy mode is off. 346868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PrivateDisabled)) { 3475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("private.html")); 3485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 350868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(ScheduleTimer)) { 3515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("schedule_timer.html")); 3525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 354868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PluginThreadAsyncCall)) { 3555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("plugin_thread_async_call.html")); 3565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3587dbb3d5cf0c15f500944d211057644d6a2f37371Ben MurdochIN_PROC_BROWSER_TEST_F(PluginTest, PluginSingleRangeRequest) { 3597dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch LoadAndWait(GetURL("plugin_single_range_request.html")); 3607dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch} 3617dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch 3625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if !defined(OS_WIN) // http://crbug.com/396373 3635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test checking the privacy mode is on. 3645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If this flakes on Linux, use http://crbug.com/104380 365868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PrivateEnabled)) { 3665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url = GetURL("private.html"); 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url = GURL(url.spec() + "?private"); 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWaitInWindow(CreateOffTheRecordBrowser(), url); 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3705f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3725f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// These used to run on Windows: http://crbug.com/396373 3735f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#if defined(OS_MACOSX) 3745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test a browser hang due to special case of multiple 3755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// plugin instances indulged in sync calls across renderer. 376868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(MultipleInstancesSyncCalls)) { 3775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("multiple_instances_sync_calls.html")); 3785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 380868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(GetURLRequestFailWrite)) { 3811320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GURL url(net::URLRequestMockHTTPJob::GetMockUrl( 3821320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::FilePath().AppendASCII("npapi").AppendASCII( 3831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci "plugin_url_request_fail_write.html"))); 3845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(url); 3855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3865f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#endif 3875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 389116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Flaky on Windows x86. http://crbug.com/388245 390116680a4aac90f2aa7413d9095a592090648e557Ben MurdochIN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_EnsureScriptingWorksInDestroy) { 3915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("ensure_scripting_works_in_destroy.html")); 3925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This test uses a Windows Event to signal to the plugin that it should crash 3955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// on NP_Initialize. 396868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(NoHangIfInitCrashes)) { 3975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) HANDLE crash_event = CreateEvent(NULL, TRUE, FALSE, L"TestPluginCrashOnInit"); 3985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SetEvent(crash_event); 3995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(GetURL("no_hang_if_init_crashes.html")); 4005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CloseHandle(crash_event); 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 4035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// If this flakes on Mac, use http://crbug.com/111508 405868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(PluginReferrerTest)) { 4061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci GURL url(net::URLRequestMockHTTPJob::GetMockUrl( 4071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci base::FilePath().AppendASCII("npapi").AppendASCII( 4081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci "plugin_url_request_referrer_test.html"))); 4095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) LoadAndWait(url); 4105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX) 4135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Test is flaky, see http://crbug.com/134515. 4145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) { 4155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect bounds(50, 50, 400, 400); 4165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SetWindowBounds(shell()->window(), bounds); 4175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) NavigateToURL(shell(), GetURL("convert_point.html")); 4195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 420a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) base::string16 expected_title(ASCIIToUTF16("OK")); 4215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TitleWatcher title_watcher(shell()->web_contents(), expected_title); 4225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); 4235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO(stuartmorgan): When the automation system supports sending clicks, 4245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // change the test to trigger on mouse-down rather than window focus. 4255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // TODO: is this code still needed? It was here when it used to run in 4275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // browser_tests. 4285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) //static_cast<WebContentsDelegate*>(shell())-> 4295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // ActivateContents(shell()->web_contents()); 4305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 4315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 4335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 434868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Flash)) { 4355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("flash.html"); 4365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 4395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Windows only test 4405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_FlashSecurity) { 4415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("flash.html"); 4425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // defined(OS_WIN) 4445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 4465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// TODO(port) Port the following tests to platforms that have the required 4475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// plugins. 4485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Flaky: http://crbug.com/55915 4496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Quicktime) { 4505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("quicktime.html"); 4515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Disabled - http://crbug.com/44662 454868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(MediaPlayerNew)) { 4555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("wmp_new.html"); 4565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Disabled - http://crbug.com/44673 459868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Real)) { 4605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("real.html"); 4615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 463f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// http://crbug.com/320041 464f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#if (defined(OS_WIN) && defined(ARCH_CPU_X86_64)) || \ 465f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) (defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) 466f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#define MAYBE_FlashOctetStream DISABLED_FlashOctetStream 467f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#else 468f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#define MAYBE_FlashOctetStream FlashOctetStream 469f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#endif 470f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE_FlashOctetStream) { 4715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("flash-octet-stream.html"); 4725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_WIN) 4755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// http://crbug.com/53926 4765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_FlashLayoutWhilePainting) { 4775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, FlashLayoutWhilePainting) { 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 4805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("flash-layout-while-painting.html"); 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// http://crbug.com/8690 4845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Java) { 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("Java.html"); 4865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4886e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)// Flaky: http://crbug.com/55915 4896e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_Silverlight) { 4905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TestPlugin("silverlight.html"); 4915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // defined(OS_WIN) 4935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 494f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)class TestResourceDispatcherHostDelegate 495f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) : public ResourceDispatcherHostDelegate { 496f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) public: 497f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) TestResourceDispatcherHostDelegate() : found_cookie_(false) {} 498f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 499f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool found_cookie() { return found_cookie_; } 500f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 501f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) void WaitForPluginRequest() { 502f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (found_cookie_) 503f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) return; 504f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 505f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) runner_ = new MessageLoopRunner; 506f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) runner_->Run(); 507f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) } 508f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 509f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) private: 510f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // ResourceDispatcherHostDelegate implementation: 511f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual void OnResponseStarted( 512f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) net::URLRequest* request, 513f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ResourceContext* resource_context, 514f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ResourceResponse* response, 515f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) IPC::Sender* sender) OVERRIDE { 516f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // The URL below comes from plugin_geturl_test.cc. 517f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (!EndsWith(request->url().spec(), 518f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) "npapi/plugin_ref_target_page.html", 519f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) true)) { 520f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) return; 521f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) } 522f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) net::HttpRequestHeaders headers; 523f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool found_cookie = false; 524f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) if (request->GetFullRequestHeaders(&headers) && 525f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) headers.ToString().find("Cookie: blah") != std::string::npos) { 526f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) found_cookie = true; 527f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) } 528f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) BrowserThread::PostTask( 529f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) BrowserThread::UI, 530f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) FROM_HERE, 531f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Bind(&TestResourceDispatcherHostDelegate::GotCookie, 532f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) base::Unretained(this), found_cookie)); 533f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) } 534f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 535f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) void GotCookie(bool found_cookie) { 536f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) found_cookie_ = found_cookie; 5371320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci if (runner_.get()) 538f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) runner_->QuitClosure().Run(); 539f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) } 540f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 541f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_refptr<MessageLoopRunner> runner_; 542f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) bool found_cookie_; 543f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 544f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcherHostDelegate); 545f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)}; 546f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 547f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)// Ensure that cookies get sent with plugin requests. 548f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)IN_PROC_BROWSER_TEST_F(PluginTest, MAYBE(Cookies)) { 549f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // Create a new browser just to ensure that the plugin process' child_id is 550f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // not equal to its type (PROCESS_TYPE_PLUGIN), as that was the error which 551f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) // caused this bug. 552f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) NavigateToURL(CreateBrowser(), GURL("about:blank")); 553f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 554f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 555f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) GURL url(embedded_test_server()->GetURL("/npapi/cookies.html")); 556f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 557f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) TestResourceDispatcherHostDelegate test_delegate; 558f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ResourceDispatcherHostDelegate* old_delegate = 559f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ResourceDispatcherHostImpl::Get()->delegate(); 560f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ResourceDispatcherHostImpl::Get()->SetDelegate(&test_delegate); 561f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) LoadAndWait(url); 562f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) test_delegate.WaitForPluginRequest(); 563f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ASSERT_TRUE(test_delegate.found_cookie()); 564f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate); 565f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)} 566f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 5675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 568