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/memory/singleton.h" | 5 #include "base/memory/singleton.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 651 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
652 test_embedder()->web_contents()->GetRenderViewHost()); | 652 test_embedder()->web_contents()->GetRenderViewHost()); |
653 GURL test_url = test_server()->GetURL("close-socket"); | 653 GURL test_url = test_server()->GetURL("close-socket"); |
654 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | 654 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( |
655 StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); | 655 StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); |
656 | 656 |
657 string16 actual_title = title_watcher.WaitAndGetTitle(); | 657 string16 actual_title = title_watcher.WaitAndGetTitle(); |
658 EXPECT_EQ(expected_title, actual_title); | 658 EXPECT_EQ(expected_title, actual_title); |
659 } | 659 } |
660 | 660 |
| 661 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) { |
| 662 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 663 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
| 664 |
| 665 const string16 expected_title = ASCIIToUTF16("redirected"); |
| 666 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 667 expected_title); |
| 668 |
| 669 // Navigate with a redirect and wait until the title changes. |
| 670 GURL redirect_url(test_server()->GetURL( |
| 671 "server-redirect?files/title1.html")); |
| 672 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 673 test_embedder()->web_contents()->GetRenderViewHost()); |
| 674 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( |
| 675 StringPrintf("SetSrc('%s');", redirect_url.spec().c_str()))); |
| 676 |
| 677 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 678 EXPECT_EQ(expected_title, actual_title); |
| 679 |
| 680 // Verify that we heard a loadRedirect during the navigation. |
| 681 base::Value* v = rvh->ExecuteJavascriptAndGetValue( |
| 682 string16(), ASCIIToUTF16("redirectOldUrl")); |
| 683 std::string result; |
| 684 EXPECT_TRUE(v->GetAsString(&result)); |
| 685 EXPECT_EQ(redirect_url.spec().c_str(), result); |
| 686 |
| 687 v = rvh->ExecuteJavascriptAndGetValue( |
| 688 string16(), ASCIIToUTF16("redirectNewUrl")); |
| 689 EXPECT_TRUE(v->GetAsString(&result)); |
| 690 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); |
| 691 } |
| 692 |
661 } // namespace content | 693 } // namespace content |
OLD | NEW |