diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-25 12:28:22 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-25 12:28:22 +0000 |
commit | 4da06efd6d467e07ac311a59e5f79bd0cc6145d4 (patch) | |
tree | 711d378acbaa00035c56f2f6af82f09e3a301d71 /chrome | |
parent | 506398ae0dcffa9677ba4c08fd27ce4cf141426d (diff) | |
download | chromium_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
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 16 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.h | 3 | ||||
-rw-r--r-- | chrome/renderer/blocked_plugin.cc | 2 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 5 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 9 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 3 | ||||
-rw-r--r-- | chrome/test/data/npapi/click_to_play.html | 13 | ||||
-rw-r--r-- | chrome/test/plugin/plugin_test.cpp | 45 | ||||
-rw-r--r-- | chrome/test/ui/npapi_uitest.cc | 19 |
9 files changed, 114 insertions, 1 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()); +} |