Chromium Code Reviews| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 // Go back and verify that we're back at P2. | 536 // Go back and verify that we're back at P2. |
| 537 { | 537 { |
| 538 const string16 expected_title = ASCIIToUTF16("P2"); | 538 const string16 expected_title = ASCIIToUTF16("P2"); |
| 539 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 539 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 540 expected_title); | 540 expected_title); |
| 541 | 541 |
| 542 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); | 542 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); |
| 543 | 543 |
| 544 string16 actual_title = title_watcher.WaitAndGetTitle(); | 544 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 545 EXPECT_EQ(expected_title, actual_title); | 545 EXPECT_EQ(expected_title, actual_title); |
| 546 | |
| 547 base::Value* value = | |
| 548 rvh->ExecuteJavascriptAndGetValue(string16(), | |
| 549 ASCIIToUTF16("CanGoBack()")); | |
| 550 bool result = false; | |
| 551 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
| 552 EXPECT_TRUE(result); | |
| 553 | |
| 554 value = rvh->ExecuteJavascriptAndGetValue(string16(), | |
| 555 ASCIIToUTF16("CanGoForward()")); | |
| 556 result = false; | |
| 557 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
| 558 EXPECT_TRUE(result); | |
| 546 } | 559 } |
| 547 | 560 |
| 548 // Go forward and verify that we're back at P3. | 561 // Go forward and verify that we're back at P3. |
| 549 { | 562 { |
| 550 const string16 expected_title = ASCIIToUTF16("P3"); | 563 const string16 expected_title = ASCIIToUTF16("P3"); |
| 551 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 564 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 552 expected_title); | 565 expected_title); |
| 553 | 566 |
| 567 base::Value* value = | |
| 568 rvh->ExecuteJavascriptAndGetValue(string16(), | |
| 569 ASCIIToUTF16("CanGoForward()")); | |
| 570 bool result = false; | |
| 571 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
| 572 EXPECT_TRUE(result); | |
|
Charlie Reis
2012/10/11 19:03:01
Please move this after the Forward() call and have
| |
| 554 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Forward();")); | 573 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Forward();")); |
| 555 | 574 |
| 556 string16 actual_title = title_watcher.WaitAndGetTitle(); | 575 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 557 EXPECT_EQ(expected_title, actual_title); | 576 EXPECT_EQ(expected_title, actual_title); |
| 558 } | 577 } |
| 559 | 578 |
| 560 // Go back two entries and verify that we're back at P1. | 579 // Go back two entries and verify that we're back at P1. |
| 561 { | 580 { |
| 562 const string16 expected_title = ASCIIToUTF16("P1"); | 581 const string16 expected_title = ASCIIToUTF16("P1"); |
| 563 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 582 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 564 expected_title); | 583 expected_title); |
| 565 | 584 |
| 566 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); | 585 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); |
| 567 | 586 |
| 568 string16 actual_title = title_watcher.WaitAndGetTitle(); | 587 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 569 EXPECT_EQ(expected_title, actual_title); | 588 EXPECT_EQ(expected_title, actual_title); |
| 589 | |
| 590 base::Value* value = | |
| 591 rvh->ExecuteJavascriptAndGetValue(string16(), | |
| 592 ASCIIToUTF16("CanGoBack()")); | |
| 593 bool result = true; | |
| 594 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
| 595 EXPECT_FALSE(result); | |
| 570 } | 596 } |
| 571 } | 597 } |
| 572 | 598 |
| 573 // This tests verifies that reloading the embedder does not crash the browser | 599 // This tests verifies that reloading the embedder does not crash the browser |
| 574 // and that the guest is reset. | 600 // and that the guest is reset. |
| 575 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { | 601 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { |
| 576 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 602 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 577 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 603 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
| 578 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 604 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 579 test_embedder()->web_contents()->GetRenderViewHost()); | 605 test_embedder()->web_contents()->GetRenderViewHost()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 EXPECT_TRUE(v->GetAsString(&result)); | 722 EXPECT_TRUE(v->GetAsString(&result)); |
| 697 EXPECT_EQ(redirect_url.spec().c_str(), result); | 723 EXPECT_EQ(redirect_url.spec().c_str(), result); |
| 698 | 724 |
| 699 v = rvh->ExecuteJavascriptAndGetValue( | 725 v = rvh->ExecuteJavascriptAndGetValue( |
| 700 string16(), ASCIIToUTF16("redirectNewUrl")); | 726 string16(), ASCIIToUTF16("redirectNewUrl")); |
| 701 EXPECT_TRUE(v->GetAsString(&result)); | 727 EXPECT_TRUE(v->GetAsString(&result)); |
| 702 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); | 728 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); |
| 703 } | 729 } |
| 704 | 730 |
| 705 } // namespace content | 731 } // namespace content |
| OLD | NEW |