Chromium Code Reviews| 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..f18d3e65579f16b829ada05ac230dce2021b72f1 100644 |
| --- a/content/renderer/browser_plugin/browser_plugin_browsertest.cc |
| +++ b/content/renderer/browser_plugin/browser_plugin_browsertest.cc |
| @@ -323,4 +323,77 @@ 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. |
| + { |
|
lazyboy
2012/09/13 19:14:15
Out of curiosity, what does this inner scopes do?
Fady Samuel
2012/09/19 14:38:09
It limits the scope of the msg, frame_id, src, siz
lazyboy
2012/09/19 15:06:06
OK thanks. (Making sure they are just local scopes
|
| + 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)); |
| + // Verify that we've navigated back to the same page. |
|
lazyboy
2012/09/13 19:14:15
Also ASSERT_FALSE(browser_plugin_.guest_crashed_)
Fady Samuel
2012/09/19 14:38:09
Done.
|
| + { |
| + 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 |