| 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 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 // Go back and verify that we're back at P2. | 543 // Go back and verify that we're back at P2. |
| 544 { | 544 { |
| 545 const string16 expected_title = ASCIIToUTF16("P2"); | 545 const string16 expected_title = ASCIIToUTF16("P2"); |
| 546 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 546 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 547 expected_title); | 547 expected_title); |
| 548 | 548 |
| 549 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); | 549 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); |
| 550 | 550 |
| 551 string16 actual_title = title_watcher.WaitAndGetTitle(); | 551 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 552 EXPECT_EQ(expected_title, actual_title); | 552 EXPECT_EQ(expected_title, actual_title); |
| 553 |
| 554 base::Value* value = |
| 555 rvh->ExecuteJavascriptAndGetValue(string16(), |
| 556 ASCIIToUTF16("CanGoBack()")); |
| 557 bool result = false; |
| 558 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 559 EXPECT_TRUE(result); |
| 560 |
| 561 value = rvh->ExecuteJavascriptAndGetValue(string16(), |
| 562 ASCIIToUTF16("CanGoForward()")); |
| 563 result = false; |
| 564 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 565 EXPECT_TRUE(result); |
| 553 } | 566 } |
| 554 | 567 |
| 555 // Go forward and verify that we're back at P3. | 568 // Go forward and verify that we're back at P3. |
| 556 { | 569 { |
| 557 const string16 expected_title = ASCIIToUTF16("P3"); | 570 const string16 expected_title = ASCIIToUTF16("P3"); |
| 558 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 571 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 559 expected_title); | 572 expected_title); |
| 560 | 573 |
| 561 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Forward();")); | 574 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Forward();")); |
| 562 | 575 |
| 563 string16 actual_title = title_watcher.WaitAndGetTitle(); | 576 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 564 EXPECT_EQ(expected_title, actual_title); | 577 EXPECT_EQ(expected_title, actual_title); |
| 578 |
| 579 base::Value* value = |
| 580 rvh->ExecuteJavascriptAndGetValue(string16(), |
| 581 ASCIIToUTF16("CanGoForward()")); |
| 582 bool result = true; |
| 583 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 584 EXPECT_FALSE(result); |
| 565 } | 585 } |
| 566 | 586 |
| 567 // Go back two entries and verify that we're back at P1. | 587 // Go back two entries and verify that we're back at P1. |
| 568 { | 588 { |
| 569 const string16 expected_title = ASCIIToUTF16("P1"); | 589 const string16 expected_title = ASCIIToUTF16("P1"); |
| 570 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 590 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 571 expected_title); | 591 expected_title); |
| 572 | 592 |
| 573 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); | 593 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); |
| 574 | 594 |
| 575 string16 actual_title = title_watcher.WaitAndGetTitle(); | 595 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 576 EXPECT_EQ(expected_title, actual_title); | 596 EXPECT_EQ(expected_title, actual_title); |
| 597 |
| 598 base::Value* value = |
| 599 rvh->ExecuteJavascriptAndGetValue(string16(), |
| 600 ASCIIToUTF16("CanGoBack()")); |
| 601 bool result = true; |
| 602 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 603 EXPECT_FALSE(result); |
| 577 } | 604 } |
| 578 } | 605 } |
| 579 | 606 |
| 580 // This tests verifies that reloading the embedder does not crash the browser | 607 // This tests verifies that reloading the embedder does not crash the browser |
| 581 // and that the guest is reset. | 608 // and that the guest is reset. |
| 582 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { | 609 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { |
| 583 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 610 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 584 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 611 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
| 585 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 612 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 586 test_embedder()->web_contents()->GetRenderViewHost()); | 613 test_embedder()->web_contents()->GetRenderViewHost()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 EXPECT_TRUE(v->GetAsString(&result)); | 730 EXPECT_TRUE(v->GetAsString(&result)); |
| 704 EXPECT_EQ(redirect_url.spec().c_str(), result); | 731 EXPECT_EQ(redirect_url.spec().c_str(), result); |
| 705 | 732 |
| 706 v = rvh->ExecuteJavascriptAndGetValue( | 733 v = rvh->ExecuteJavascriptAndGetValue( |
| 707 string16(), ASCIIToUTF16("redirectNewUrl")); | 734 string16(), ASCIIToUTF16("redirectNewUrl")); |
| 708 EXPECT_TRUE(v->GetAsString(&result)); | 735 EXPECT_TRUE(v->GetAsString(&result)); |
| 709 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); | 736 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); |
| 710 } | 737 } |
| 711 | 738 |
| 712 } // namespace content | 739 } // namespace content |
| OLD | NEW |