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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 10 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 | 634 |
635 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 635 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
636 test_embedder()->web_contents()->GetRenderViewHost()); | 636 test_embedder()->web_contents()->GetRenderViewHost()); |
637 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | 637 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( |
638 "document.getElementById('plugin').terminate()")); | 638 "document.getElementById('plugin').terminate()")); |
639 | 639 |
640 // Expect the guest to crash. | 640 // Expect the guest to crash. |
641 test_guest()->WaitForCrashed(); | 641 test_guest()->WaitForCrashed(); |
642 } | 642 } |
643 | 643 |
644 // This test verifies that the guest is responsive after crashing and going back | |
645 // to a previous navigation entry. | |
646 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BackAfterTerminateGuest) { | |
647 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | |
648 StartBrowserPluginTest( | |
649 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); | |
650 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | |
651 test_embedder()->web_contents()->GetRenderViewHost()); | |
652 | |
653 // Navigate to P2 and verify that the navigation occurred. | |
654 { | |
655 const string16 expected_title = ASCIIToUTF16("P2"); | |
656 content::TitleWatcher title_watcher(test_guest()->web_contents(), | |
657 expected_title); | |
658 | |
659 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | |
660 StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P2").c_str()))); | |
661 | |
662 string16 actual_title = title_watcher.WaitAndGetTitle(); | |
663 EXPECT_EQ(expected_title, actual_title); | |
664 } | |
665 // Kill the guest. | |
666 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | |
667 "document.getElementById('plugin').terminate()")); | |
668 | |
669 // Expect the guest to report that it crashed. | |
670 test_guest()->WaitForCrashed(); | |
671 // Go back and verify that we're back at P1. | |
672 { | |
673 const string16 expected_title = ASCIIToUTF16("P1"); | |
674 content::TitleWatcher title_watcher(test_guest()->web_contents(), | |
675 expected_title); | |
676 | |
677 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); | |
678 | |
679 string16 actual_title = title_watcher.WaitAndGetTitle(); | |
680 EXPECT_EQ(expected_title, actual_title); | |
681 } | |
682 // Send an input event and verify that the guest receives the input. | |
683 SimulateMouseClick(test_embedder()->web_contents()); | |
Charlie Reis
2012/10/12 04:10:25
What's the reason for adding all this input event
Fady Samuel
2012/10/12 17:33:06
One of the symptoms manifested by this bug was tha
| |
684 test_guest()->WaitForInput(); | |
685 } | |
686 | |
644 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStart) { | 687 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStart) { |
645 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 688 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
646 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 689 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
647 | 690 |
648 const string16 expected_title = ASCIIToUTF16(kHTMLForGuest); | 691 const string16 expected_title = ASCIIToUTF16(kHTMLForGuest); |
649 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 692 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
650 expected_title); | 693 expected_title); |
651 // Renavigate the guest to |kHTMLForGuest|. | 694 // Renavigate the guest to |kHTMLForGuest|. |
652 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 695 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
653 test_embedder()->web_contents()->GetRenderViewHost()); | 696 test_embedder()->web_contents()->GetRenderViewHost()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 EXPECT_TRUE(v->GetAsString(&result)); | 746 EXPECT_TRUE(v->GetAsString(&result)); |
704 EXPECT_EQ(redirect_url.spec().c_str(), result); | 747 EXPECT_EQ(redirect_url.spec().c_str(), result); |
705 | 748 |
706 v = rvh->ExecuteJavascriptAndGetValue( | 749 v = rvh->ExecuteJavascriptAndGetValue( |
707 string16(), ASCIIToUTF16("redirectNewUrl")); | 750 string16(), ASCIIToUTF16("redirectNewUrl")); |
708 EXPECT_TRUE(v->GetAsString(&result)); | 751 EXPECT_TRUE(v->GetAsString(&result)); |
709 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); | 752 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); |
710 } | 753 } |
711 | 754 |
712 } // namespace content | 755 } // namespace content |
OLD | NEW |