OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_browsertest.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "content/common/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin_messages.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 browser_plugin->DidNavigate(GURL(kGoogleURL)); | 316 browser_plugin->DidNavigate(GURL(kGoogleURL)); |
317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 317 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
318 | 318 |
319 ExecuteJavaScript(kRemoveEventListener); | 319 ExecuteJavaScript(kRemoveEventListener); |
320 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); | 320 browser_plugin->DidNavigate(GURL(kGoogleNewsURL)); |
321 // The URL variable should not change because we've removed the event | 321 // The URL variable should not change because we've removed the event |
322 // listener. | 322 // listener. |
323 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); | 323 EXPECT_EQ(kGoogleURL, ExecuteScriptAndReturnString("url")); |
324 } | 324 } |
325 | 325 |
| 326 TEST_F(BrowserPluginTest, StopMethod) { |
| 327 const char* kCallStop = |
| 328 "document.getElementById('browserplugin').stop();"; |
| 329 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 330 ExecuteJavaScript(kCallStop); |
| 331 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 332 BrowserPluginHostMsg_Stop::ID)); |
| 333 } |
| 334 |
| 335 TEST_F(BrowserPluginTest, ReloadMethod) { |
| 336 const char* kCallReload = |
| 337 "document.getElementById('browserplugin').reload();"; |
| 338 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 339 ExecuteJavaScript(kCallReload); |
| 340 EXPECT_TRUE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 341 BrowserPluginHostMsg_Reload::ID)); |
| 342 } |
| 343 |
| 344 TEST_F(BrowserPluginTest, ReloadAfterCrash) { |
| 345 LoadHTML(GetHTMLForBrowserPluginObject().c_str()); |
| 346 int instance_id = 0; |
| 347 // Verify that we're reporting the correct URL to navigate to based on the |
| 348 // src attribute. |
| 349 { |
| 350 const IPC::Message* msg = |
| 351 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 352 BrowserPluginHostMsg_NavigateGuest::ID); |
| 353 ASSERT_TRUE(msg); |
| 354 |
| 355 long long frame_id; |
| 356 std::string src; |
| 357 gfx::Size size; |
| 358 BrowserPluginHostMsg_NavigateGuest::Read( |
| 359 msg, |
| 360 &instance_id, |
| 361 &frame_id, |
| 362 &src, |
| 363 &size); |
| 364 EXPECT_EQ("foo", src); |
| 365 } |
| 366 browser_plugin_manager()->sink().ClearMessages(); |
| 367 |
| 368 MockBrowserPlugin* browser_plugin = |
| 369 static_cast<MockBrowserPlugin*>( |
| 370 browser_plugin_manager()->GetBrowserPlugin(instance_id)); |
| 371 ASSERT_TRUE(browser_plugin); |
| 372 // Crash the guest |
| 373 browser_plugin->GuestCrashed(); |
| 374 // Reload the crashed guest |
| 375 ExecuteJavaScript("document.getElementById('browserplugin').reload();"); |
| 376 // Verify that we do NOT issue a reload. |
| 377 EXPECT_FALSE(browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 378 BrowserPluginHostMsg_Reload::ID)); |
| 379 EXPECT_FALSE(browser_plugin->guest_crashed_); |
| 380 // Verify that we've navigated back to the same page. |
| 381 { |
| 382 const IPC::Message* msg = |
| 383 browser_plugin_manager()->sink().GetUniqueMessageMatching( |
| 384 BrowserPluginHostMsg_NavigateGuest::ID); |
| 385 ASSERT_TRUE(msg); |
| 386 |
| 387 long long frame_id; |
| 388 std::string src; |
| 389 gfx::Size size; |
| 390 BrowserPluginHostMsg_NavigateGuest::Read( |
| 391 msg, |
| 392 &instance_id, |
| 393 &frame_id, |
| 394 &src, |
| 395 &size); |
| 396 EXPECT_EQ("foo", src); |
| 397 } |
| 398 } |
| 399 |
326 } // namespace content | 400 } // namespace content |
OLD | NEW |