summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-25 12:28:22 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-25 12:28:22 +0000
commit4da06efd6d467e07ac311a59e5f79bd0cc6145d4 (patch)
tree711d378acbaa00035c56f2f6af82f09e3a301d71
parent506398ae0dcffa9677ba4c08fd27ce4cf141426d (diff)
downloadchromium_src-4da06efd6d467e07ac311a59e5f79bd0cc6145d4.zip
chromium_src-4da06efd6d467e07ac311a59e5f79bd0cc6145d4.tar.gz
chromium_src-4da06efd6d467e07ac311a59e5f79bd0cc6145d4.tar.bz2
Add UI test for click-to-play.
BUG=57277 TEST=NPAPIVisiblePluginTester.ClickToPlay:ClickToPlayPluginTest.* Review URL: http://codereview.chromium.org/3539002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63722 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc16
-rw-r--r--chrome/browser/automation/testing_automation_provider.h3
-rw-r--r--chrome/renderer/blocked_plugin.cc2
-rw-r--r--chrome/test/automation/automation_messages_internal.h5
-rw-r--r--chrome/test/automation/tab_proxy.cc9
-rw-r--r--chrome/test/automation/tab_proxy.h3
-rw-r--r--chrome/test/data/npapi/click_to_play.html13
-rw-r--r--chrome/test/plugin/plugin_test.cpp45
-rw-r--r--chrome/test/ui/npapi_uitest.cc19
-rw-r--r--tools/valgrind/gtest_exclude/ui_tests.gtest_mac.txt31
-rw-r--r--webkit/glue/plugins/test/plugin_setup_test.cc22
-rw-r--r--webkit/glue/plugins/test/plugin_setup_test.h24
-rw-r--r--webkit/glue/plugins/test/plugin_test_factory.cc4
-rw-r--r--webkit/tools/test_shell/test_shell.gypi2
14 files changed, 182 insertions, 16 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 109c13b..e4e1d53 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -419,6 +419,7 @@ void TestingAutomationProvider::OnMessageReceived(
IPC_MESSAGE_HANDLER(AutomationMsg_ShutdownSessionService,
ShutdownSessionService)
IPC_MESSAGE_HANDLER(AutomationMsg_SetContentSetting, SetContentSetting)
+ IPC_MESSAGE_HANDLER(AutomationMsg_LoadBlockedPlugins, LoadBlockedPlugins)
IPC_MESSAGE_HANDLER(AutomationMsg_ResetToDefaultTheme, ResetToDefaultTheme)
IPC_MESSAGE_UNHANDLED(AutomationProvider::OnMessageReceived(message));
@@ -4052,6 +4053,21 @@ void TestingAutomationProvider::SetContentSetting(
}
}
+void TestingAutomationProvider::LoadBlockedPlugins(int tab_handle,
+ bool* success) {
+ *success = false;
+ if (tab_tracker_->ContainsHandle(tab_handle)) {
+ NavigationController* nav = tab_tracker_->GetResource(tab_handle);
+ if (!nav)
+ return;
+ TabContents* contents = nav->tab_contents();
+ if (!contents)
+ return;
+ contents->render_view_host()->LoadBlockedPlugins();
+ *success = true;
+ }
+}
+
void TestingAutomationProvider::ResetToDefaultTheme() {
profile_->ClearTheme();
}
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index 838a079..7f82ea5 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -656,6 +656,9 @@ class TestingAutomationProvider : public AutomationProvider,
ContentSetting setting,
bool* success);
+ // Load all plug-ins on the page.
+ void LoadBlockedPlugins(int tab_handle, bool* success);
+
// Resets to the default theme.
void ResetToDefaultTheme();
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
index 1aeed1c..b06fd55 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -94,9 +94,9 @@ void BlockedPlugin::LoadPlugin() {
plugin_params_);
if (new_plugin && new_plugin->initialize(container)) {
container->setPlugin(new_plugin);
- plugin_->ReplayReceivedData(new_plugin);
container->invalidate();
container->reportGeometry();
+ plugin_->ReplayReceivedData(new_plugin);
plugin_->destroy();
render_view_->Send(
new ViewHostMsg_BlockedPluginLoaded(render_view_->routing_id()));
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 537067f..adadf68 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -1441,4 +1441,9 @@ IPC_BEGIN_MESSAGES(Automation)
int /* autocomplete edit handle */,
bool /* success */)
+ // Loads all blocked plug-ins on the page.
+ IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_LoadBlockedPlugins,
+ int /* tab handle */,
+ bool /* success */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc
index d0d0426..a338de7 100644
--- a/chrome/test/automation/tab_proxy.cc
+++ b/chrome/test/automation/tab_proxy.cc
@@ -729,6 +729,15 @@ bool TabProxy::OverrideEncoding(const std::string& encoding) {
return succeeded;
}
+bool TabProxy::LoadBlockedPlugins() {
+ if (!is_valid())
+ return false;
+
+ bool succeeded = false;
+ sender_->Send(new AutomationMsg_LoadBlockedPlugins(0, handle_, &succeeded));
+ return succeeded;
+}
+
#if defined(OS_WIN)
void TabProxy::Reposition(HWND window, HWND window_insert_after, int left,
int top, int width, int height, int flags,
diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h
index 4efbb86..92a80a7 100644
--- a/chrome/test/automation/tab_proxy.h
+++ b/chrome/test/automation/tab_proxy.h
@@ -375,6 +375,9 @@ class TabProxy : public AutomationResourceProxy,
// Uses the specified encoding to override encoding of the page in the tab.
bool OverrideEncoding(const std::string& encoding) WARN_UNUSED_RESULT;
+ // Loads all blocked plug-ins on the page.
+ bool LoadBlockedPlugins() WARN_UNUSED_RESULT;
+
#if defined(OS_WIN)
// Resizes the tab window.
// The parent_window parameter allows a parent to be specified for the window
diff --git a/chrome/test/data/npapi/click_to_play.html b/chrome/test/data/npapi/click_to_play.html
new file mode 100644
index 0000000..1ad3678
--- /dev/null
+++ b/chrome/test/data/npapi/click_to_play.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+<script src="npapi.js"></script>
+</head>
+<body>
+<embed type="application/vnd.npapi-test"
+ src="foo"
+ name="setup"
+ id="1"
+ mode="np_embed"
+>
+</body>
+</html> \ No newline at end of file
diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp
index cc93c45..a0afffa 100644
--- a/chrome/test/plugin/plugin_test.cpp
+++ b/chrome/test/plugin/plugin_test.cpp
@@ -138,6 +138,51 @@ TEST_F(PluginTest, Flash) {
TestPlugin("flash.html?" + kFlashQuery, action_max_timeout_ms(), false);
}
+class ClickToPlayPluginTest : public PluginTest {
+ public:
+ ClickToPlayPluginTest() {
+ dom_automation_enabled_ = true;
+ }
+};
+
+TEST_F(ClickToPlayPluginTest, Flash) {
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+ ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
+ CONTENT_SETTING_BLOCK));
+
+ GURL url = GetTestUrl("flash-clicktoplay.html", true);
+ NavigateToURL(url);
+
+ scoped_refptr<TabProxy> tab(browser->GetTab(0));
+ ASSERT_TRUE(tab.get());
+
+ ASSERT_TRUE(tab->LoadBlockedPlugins());
+
+ WaitForFinish(action_max_timeout_ms(), true);
+}
+
+TEST_F(ClickToPlayPluginTest, FlashDocument) {
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+ ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
+ CONTENT_SETTING_BLOCK));
+
+ scoped_refptr<TabProxy> tab(browser->GetTab(0));
+ ASSERT_TRUE(tab.get());
+ GURL url = GetTestUrl("js-invoker.swf?callback=done", true);
+ NavigateToURL(url);
+
+ // Inject the callback function into the HTML page generated by the browser.
+ ASSERT_TRUE(tab->ExecuteJavaScript("window.done = function() {"
+ " window.location = \"done.html\";"
+ "}"));
+
+ ASSERT_TRUE(tab->LoadBlockedPlugins());
+
+ WaitForFinish(action_max_timeout_ms(), true);
+}
+
#if defined(OS_WIN)
// Windows only test
TEST_F(PluginTest, FlashSecurity) {
diff --git a/chrome/test/ui/npapi_uitest.cc b/chrome/test/ui/npapi_uitest.cc
index fe074e0..be46943 100644
--- a/chrome/test/ui/npapi_uitest.cc
+++ b/chrome/test/ui/npapi_uitest.cc
@@ -395,3 +395,22 @@ TEST_F(NPAPIVisiblePluginTester, PluginConvertPointTest) {
kTestCompleteSuccess, action_max_timeout_ms());
}
#endif
+
+TEST_F(NPAPIVisiblePluginTester, ClickToPlay) {
+ scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(browser.get());
+ ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS,
+ CONTENT_SETTING_BLOCK));
+
+ GURL url(URLRequestMockHTTPJob::GetMockUrl(
+ FilePath(FILE_PATH_LITERAL("npapi/click_to_play.html"))));
+ ASSERT_NO_FATAL_FAILURE(NavigateToURL(url));
+
+ scoped_refptr<TabProxy> tab(browser->GetTab(0));
+ ASSERT_TRUE(tab.get());
+
+ ASSERT_TRUE(tab->LoadBlockedPlugins());
+
+ WaitForFinish("setup", "1", url, kTestCompleteCookie,
+ kTestCompleteSuccess, action_max_timeout_ms());
+}
diff --git a/tools/valgrind/gtest_exclude/ui_tests.gtest_mac.txt b/tools/valgrind/gtest_exclude/ui_tests.gtest_mac.txt
index fa6748a..b870a14 100644
--- a/tools/valgrind/gtest_exclude/ui_tests.gtest_mac.txt
+++ b/tools/valgrind/gtest_exclude/ui_tests.gtest_mac.txt
@@ -42,30 +42,31 @@ NewTabUITest.UpdateUserPrefsVersion
VisibleBrowserTest.WindowOpenClose
# See http://crbug.com/30661 and http://crbug.com/27447.
-NPAPITesterBase.GetURL
-NPAPITesterBase.SelfDeletePluginGetUrl
-NPAPITesterBase.PluginThreadAsyncCall
-NPAPITesterBase.GetJavaScriptURL
-NPAPITesterBase.SelfDeletePluginInvoke
+LayoutPluginTester.NPObjectReleasedOnDestruction
+LayoutPluginTester.NPObjectSetException
+LayoutPluginTester.SelfDeletePluginGetUrl
+LayoutPluginTester.SelfDeletePluginInvoke
+LayoutPluginTester.UnloadNoCrash
+NPAPIIncognitoTester.PrivateEnabled
NPAPITesterBase.Arguments
+NPAPITesterBase.GetJavaScriptURL
NPAPITesterBase.GetJavaScriptURL2
-NPAPITesterBase.PrivateDisabled
-NPAPIVisiblePluginTester.PluginReferrerTest
-NPAPIVisiblePluginTester.GetURLRequestFailWrite
-NPAPIIncognitoTester.PrivateEnabled
+NPAPITesterBase.GetURL
NPAPITesterBase.ManyPlugins
NPAPITesterBase.NPObjectProxy
+NPAPITesterBase.PluginThreadAsyncCall
+NPAPITesterBase.PrivateDisabled
NPAPITesterBase.ScheduleTimer
-NPAPIVisiblePluginTester.SelfDeletePluginInNewStream
+NPAPITesterBase.SelfDeletePluginGetUrl
+NPAPITesterBase.SelfDeletePluginInvoke
+NPAPIVisiblePluginTester.ClickToPlay
+NPAPIVisiblePluginTester.GetURLRequestFailWrite
NPAPIVisiblePluginTester.MultipleInstancesSyncCalls
NPAPIVisiblePluginTester.OpenPopupWindowWithPlugin
NPAPIVisiblePluginTester.PluginConvertPointTest
+NPAPIVisiblePluginTester.PluginReferrerTest
+NPAPIVisiblePluginTester.SelfDeletePluginInNewStream
NPAPIVisiblePluginTester.SelfDeletePluginInvokeInSynchronousPaint
-LayoutPluginTester.SelfDeletePluginGetUrl
-LayoutPluginTester.SelfDeletePluginInvoke
-LayoutPluginTester.NPObjectReleasedOnDestruction
-LayoutPluginTester.NPObjectSetException
-LayoutPluginTester.UnloadNoCrash
# Possible timing related failure triggered only on mac valgrind bots.
# http://crbug.com/39401
diff --git a/webkit/glue/plugins/test/plugin_setup_test.cc b/webkit/glue/plugins/test/plugin_setup_test.cc
new file mode 100644
index 0000000..e4c4903
--- /dev/null
+++ b/webkit/glue/plugins/test/plugin_setup_test.cc
@@ -0,0 +1,22 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/basictypes.h"
+#include "base/string_util.h"
+
+#include "webkit/glue/plugins/test/plugin_setup_test.h"
+
+namespace NPAPIClient {
+
+PluginSetupTest::PluginSetupTest(NPP id, NPNetscapeFuncs *host_functions)
+ : PluginTest(id, host_functions) {
+}
+
+NPError PluginSetupTest::SetWindow(NPWindow* pNPWindow) {
+ this->SignalTestCompleted();
+
+ return NPERR_NO_ERROR;
+}
+
+} // namespace NPAPIClient
diff --git a/webkit/glue/plugins/test/plugin_setup_test.h b/webkit/glue/plugins/test/plugin_setup_test.h
new file mode 100644
index 0000000..b01bc42
--- /dev/null
+++ b/webkit/glue/plugins/test/plugin_setup_test.h
@@ -0,0 +1,24 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_SETUP_TEST_H__
+#define WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_SETUP_TEST_H__
+
+#include "webkit/glue/plugins/test/plugin_test.h"
+
+namespace NPAPIClient {
+
+// A very simple test that just sets up a new plug-in.
+class PluginSetupTest : public PluginTest {
+ public:
+ // Constructor.
+ PluginSetupTest(NPP id, NPNetscapeFuncs *host_functions);
+
+ // NPAPI SetWindow handler.
+ virtual NPError SetWindow(NPWindow* pNPWindow);
+};
+
+} // namespace NPAPIClient
+
+#endif // WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_SETUP_TEST_H__
diff --git a/webkit/glue/plugins/test/plugin_test_factory.cc b/webkit/glue/plugins/test/plugin_test_factory.cc
index 62a3977..ea9b290 100644
--- a/webkit/glue/plugins/test/plugin_test_factory.cc
+++ b/webkit/glue/plugins/test/plugin_test_factory.cc
@@ -15,6 +15,7 @@
#include "webkit/glue/plugins/test/plugin_npobject_proxy_test.h"
#include "webkit/glue/plugins/test/plugin_private_test.h"
#include "webkit/glue/plugins/test/plugin_schedule_timer_test.h"
+#include "webkit/glue/plugins/test/plugin_setup_test.h"
#include "webkit/glue/plugins/test/plugin_thread_async_call_test.h"
#include "webkit/glue/plugins/test/plugin_window_size_test.h"
#if defined(OS_WIN)
@@ -91,6 +92,9 @@ PluginTest* CreatePluginTest(const std::string& test_name,
test_name == "invoke_js_function_on_create") {
new_test = new WindowedPluginTest(instance, host_functions);
#endif
+ } else if (test_name == "setup") {
+ // "plugin" is the name for plugin documents.
+ new_test = new PluginSetupTest(instance, host_functions);
}
return new_test;
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 5beafa0..c76c3ae 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -545,6 +545,8 @@
'../../glue/plugins/test/plugin_npobject_proxy_test.h',
'../../glue/plugins/test/plugin_schedule_timer_test.cc',
'../../glue/plugins/test/plugin_schedule_timer_test.h',
+ '../../glue/plugins/test/plugin_setup_test.cc',
+ '../../glue/plugins/test/plugin_setup_test.h',
'../../glue/plugins/test/plugin_thread_async_call_test.cc',
'../../glue/plugins/test/plugin_thread_async_call_test.h',
'../../glue/plugins/test/plugin_windowed_test.cc',