Index: content/renderer/browser_plugin/browser_plugin_browsertest.cc |
diff --git a/content/renderer/browser_plugin/browser_plugin_browsertest.cc b/content/renderer/browser_plugin/browser_plugin_browsertest.cc |
index 6d23e0cade9a60e29e69858877d2a91a49377dde..9aae3d27c49ad5f15d892921c4bb49870d669804 100644 |
--- a/content/renderer/browser_plugin/browser_plugin_browsertest.cc |
+++ b/content/renderer/browser_plugin/browser_plugin_browsertest.cc |
@@ -323,4 +323,78 @@ TEST_F(BrowserPluginTest, CustomEvents) { |
EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
} |
+TEST_F(BrowserPluginTest, StopMethod) { |
+ const char* kCallStop = |
+ "document.getElementById('browserplugin').stop();"; |
+ LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
+ ExecuteJavaScript(kCallStop); |
+ EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
+ BrowserPluginHostMsg_Stop::ID)); |
+} |
+ |
+TEST_F(BrowserPluginTest, ReloadMethod) { |
+ const char* kCallReload = |
+ "document.getElementById('browserplugin').reload();"; |
+ LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
+ ExecuteJavaScript(kCallReload); |
+ EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
+ BrowserPluginHostMsg_Reload::ID)); |
+} |
+ |
+TEST_F(BrowserPluginTest, ReloadAfterCrash) { |
+ LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
+ int instance_id = 0; |
+ // Verify that we're reporting the correct URL to navigate to based on the |
+ // src attribute. |
+ { |
+ const IPC::Message* msg = |
+ browser_plugin_manager()->sink().GetUniqueMessageMatching( |
+ BrowserPluginHostMsg_NavigateGuest::ID); |
+ ASSERT_TRUE(msg); |
+ |
+ long long frame_id; |
+ std::string src; |
+ gfx::Size size; |
+ BrowserPluginHostMsg_NavigateGuest::Read( |
+ msg, |
+ &instance_id, |
+ &frame_id, |
+ &src, |
+ &size); |
+ EXPECT_EQ("foo", src); |
+ } |
+ browser_plugin_manager()->sink().ClearMessages(); |
+ |
+ MockBrowserPlugin* browser_plugin = |
+ static_cast<MockBrowserPlugin*>( |
+ browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
+ ASSERT_TRUE(browser_plugin); |
+ // Crash the guest |
+ browser_plugin->GuestCrashed(); |
+ // Reload the crashed guest |
+ ExecuteJavaScript("document.getElementById('browserplugin').reload();"); |
+ // Verify that we do NOT issue a reload. |
+ EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
+ BrowserPluginHostMsg_Reload::ID)); |
+ EXPECT_FALSE(browser_plugin->guest_crashed_); |
+ // Verify that we've navigated back to the same page. |
+ { |
+ const IPC::Message* msg = |
+ browser_plugin_manager()->sink().GetUniqueMessageMatching( |
+ BrowserPluginHostMsg_NavigateGuest::ID); |
+ ASSERT_TRUE(msg); |
+ |
+ long long frame_id; |
+ std::string src; |
+ gfx::Size size; |
+ BrowserPluginHostMsg_NavigateGuest::Read( |
+ msg, |
+ &instance_id, |
+ &frame_id, |
+ &src, |
+ &size); |
+ EXPECT_EQ("foo", src); |
+ } |
+} |
+ |
} // namespace content |