| 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/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 #else | 381 #else |
| 382 #define MAYBE_GuestUnresponsive GuestUnresponsive | 382 #define MAYBE_GuestUnresponsive GuestUnresponsive |
| 383 #endif | 383 #endif |
| 384 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, | 384 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, |
| 385 MAYBE_GuestUnresponsive) { | 385 MAYBE_GuestUnresponsive) { |
| 386 // Override the hang timeout for guest to be very small. | 386 // Override the hang timeout for guest to be very small. |
| 387 content::BrowserPluginGuest::set_factory_for_testing( | 387 content::BrowserPluginGuest::set_factory_for_testing( |
| 388 TestShortHangTimeoutGuestFactory::GetInstance()); | 388 TestShortHangTimeoutGuestFactory::GetInstance()); |
| 389 const char kEmbedderURL[] = | 389 const char kEmbedderURL[] = |
| 390 "files/browser_plugin_embedder_guest_unresponsive.html"; | 390 "files/browser_plugin_embedder_guest_unresponsive.html"; |
| 391 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestBusyLoop, true, ""); | 391 StartBrowserPluginTest( |
| 392 kEmbedderURL, kHTMLForGuestBusyLoop, true, std::string()); |
| 392 // Wait until the busy loop starts. | 393 // Wait until the busy loop starts. |
| 393 { | 394 { |
| 394 const string16 expected_title = ASCIIToUTF16("start"); | 395 const string16 expected_title = ASCIIToUTF16("start"); |
| 395 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 396 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 396 expected_title); | 397 expected_title); |
| 397 // Hang the guest for a length of time. | 398 // Hang the guest for a length of time. |
| 398 int spin_time = 10 * TestTimeouts::tiny_timeout().InMilliseconds(); | 399 int spin_time = 10 * TestTimeouts::tiny_timeout().InMilliseconds(); |
| 399 ExecuteSyncJSFunction( | 400 ExecuteSyncJSFunction( |
| 400 test_guest()->web_contents()->GetRenderViewHost(), | 401 test_guest()->web_contents()->GetRenderViewHost(), |
| 401 base::StringPrintf("StartPauseMs(%d);", spin_time).c_str()); | 402 base::StringPrintf("StartPauseMs(%d);", spin_time).c_str()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, embedder_code); | 447 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, embedder_code); |
| 447 | 448 |
| 448 // Wait for the guest to receive a damage buffer of size 100x200. | 449 // Wait for the guest to receive a damage buffer of size 100x200. |
| 449 // This means the guest will be painted properly at that size. | 450 // This means the guest will be painted properly at that size. |
| 450 test_guest()->WaitForDamageBufferWithSize(nxt_size); | 451 test_guest()->WaitForDamageBufferWithSize(nxt_size); |
| 451 } | 452 } |
| 452 | 453 |
| 453 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AdvanceFocus) { | 454 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AdvanceFocus) { |
| 454 const char kEmbedderURL[] = "files/browser_plugin_focus.html"; | 455 const char kEmbedderURL[] = "files/browser_plugin_focus.html"; |
| 455 const char* kGuestURL = "files/browser_plugin_focus_child.html"; | 456 const char* kGuestURL = "files/browser_plugin_focus_child.html"; |
| 456 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); | 457 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string()); |
| 457 | 458 |
| 458 SimulateMouseClick(test_embedder()->web_contents(), 0, | 459 SimulateMouseClick(test_embedder()->web_contents(), 0, |
| 459 WebKit::WebMouseEvent::ButtonLeft); | 460 WebKit::WebMouseEvent::ButtonLeft); |
| 460 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents()); | 461 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents()); |
| 461 // Wait until we focus into the guest. | 462 // Wait until we focus into the guest. |
| 462 test_guest()->WaitForFocus(); | 463 test_guest()->WaitForFocus(); |
| 463 | 464 |
| 464 // TODO(fsamuel): A third Tab key press should not be necessary. | 465 // TODO(fsamuel): A third Tab key press should not be necessary. |
| 465 // The browser plugin will take keyboard focus but it will not | 466 // The browser plugin will take keyboard focus but it will not |
| 466 // focus an initial element. The initial element is dependent | 467 // focus an initial element. The initial element is dependent |
| (...skipping 10 matching lines...) Expand all Loading... |
| 477 // web_contents gets cleared properly. | 478 // web_contents gets cleared properly. |
| 478 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) { | 479 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) { |
| 479 net::TestServer https_server( | 480 net::TestServer https_server( |
| 480 net::TestServer::TYPE_HTTPS, | 481 net::TestServer::TYPE_HTTPS, |
| 481 net::TestServer::kLocalhost, | 482 net::TestServer::kLocalhost, |
| 482 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 483 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
| 483 ASSERT_TRUE(https_server.Start()); | 484 ASSERT_TRUE(https_server.Start()); |
| 484 | 485 |
| 485 // 1. Load an embedder page with one guest in it. | 486 // 1. Load an embedder page with one guest in it. |
| 486 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 487 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 487 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 488 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 488 | 489 |
| 489 // 2. Navigate to a URL in https, so we trigger a RenderViewHost swap. | 490 // 2. Navigate to a URL in https, so we trigger a RenderViewHost swap. |
| 490 GURL test_https_url(https_server.GetURL( | 491 GURL test_https_url(https_server.GetURL( |
| 491 "files/browser_plugin_title_change.html")); | 492 "files/browser_plugin_title_change.html")); |
| 492 content::WindowedNotificationObserver swap_observer( | 493 content::WindowedNotificationObserver swap_observer( |
| 493 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, | 494 content::NOTIFICATION_WEB_CONTENTS_SWAPPED, |
| 494 content::Source<WebContents>(test_embedder()->web_contents())); | 495 content::Source<WebContents>(test_embedder()->web_contents())); |
| 495 NavigateToURL(shell(), test_https_url); | 496 NavigateToURL(shell(), test_https_url); |
| 496 swap_observer.Wait(); | 497 swap_observer.Wait(); |
| 497 | 498 |
| 498 TestBrowserPluginEmbedder* test_embedder_after_swap = | 499 TestBrowserPluginEmbedder* test_embedder_after_swap = |
| 499 static_cast<TestBrowserPluginEmbedder*>( | 500 static_cast<TestBrowserPluginEmbedder*>( |
| 500 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 501 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 501 GetBrowserPluginEmbedder()); | 502 GetBrowserPluginEmbedder()); |
| 502 // Verify we have a no embedder in web_contents (since the new page doesn't | 503 // Verify we have a no embedder in web_contents (since the new page doesn't |
| 503 // have any browser plugin). | 504 // have any browser plugin). |
| 504 ASSERT_TRUE(!test_embedder_after_swap); | 505 ASSERT_TRUE(!test_embedder_after_swap); |
| 505 ASSERT_NE(test_embedder(), test_embedder_after_swap); | 506 ASSERT_NE(test_embedder(), test_embedder_after_swap); |
| 506 } | 507 } |
| 507 | 508 |
| 508 // This test opens two pages in http and there is no RenderViewHost swap, | 509 // This test opens two pages in http and there is no RenderViewHost swap, |
| 509 // therefore the embedder created on first page navigation stays the same in | 510 // therefore the embedder created on first page navigation stays the same in |
| 510 // web_contents. | 511 // web_contents. |
| 511 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderSameAfterNav) { | 512 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderSameAfterNav) { |
| 512 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 513 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 513 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 514 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 514 WebContentsImpl* embedder_web_contents = test_embedder()->web_contents(); | 515 WebContentsImpl* embedder_web_contents = test_embedder()->web_contents(); |
| 515 | 516 |
| 516 // Navigate to another page in same host and port, so RenderViewHost swap | 517 // Navigate to another page in same host and port, so RenderViewHost swap |
| 517 // does not happen and existing embedder doesn't change in web_contents. | 518 // does not happen and existing embedder doesn't change in web_contents. |
| 518 GURL test_url_new(test_server()->GetURL( | 519 GURL test_url_new(test_server()->GetURL( |
| 519 "files/browser_plugin_title_change.html")); | 520 "files/browser_plugin_title_change.html")); |
| 520 const string16 expected_title = ASCIIToUTF16("done"); | 521 const string16 expected_title = ASCIIToUTF16("done"); |
| 521 content::TitleWatcher title_watcher(shell()->web_contents(), expected_title); | 522 content::TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
| 522 NavigateToURL(shell(), test_url_new); | 523 NavigateToURL(shell(), test_url_new); |
| 523 LOG(INFO) << "Start waiting for title"; | 524 LOG(INFO) << "Start waiting for title"; |
| 524 string16 actual_title = title_watcher.WaitAndGetTitle(); | 525 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 525 EXPECT_EQ(expected_title, actual_title); | 526 EXPECT_EQ(expected_title, actual_title); |
| 526 LOG(INFO) << "Done navigating to second page"; | 527 LOG(INFO) << "Done navigating to second page"; |
| 527 | 528 |
| 528 TestBrowserPluginEmbedder* test_embedder_after_nav = | 529 TestBrowserPluginEmbedder* test_embedder_after_nav = |
| 529 static_cast<TestBrowserPluginEmbedder*>( | 530 static_cast<TestBrowserPluginEmbedder*>( |
| 530 embedder_web_contents->GetBrowserPluginEmbedder()); | 531 embedder_web_contents->GetBrowserPluginEmbedder()); |
| 531 // Embedder must not change in web_contents. | 532 // Embedder must not change in web_contents. |
| 532 ASSERT_EQ(test_embedder_after_nav, test_embedder()); | 533 ASSERT_EQ(test_embedder_after_nav, test_embedder()); |
| 533 } | 534 } |
| 534 | 535 |
| 535 // This test verifies that hiding the embedder also hides the guest. | 536 // This test verifies that hiding the embedder also hides the guest. |
| 536 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BrowserPluginVisibilityChanged) { | 537 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BrowserPluginVisibilityChanged) { |
| 537 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 538 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 538 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 539 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 539 | 540 |
| 540 // Hide the Browser Plugin. | 541 // Hide the Browser Plugin. |
| 541 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 542 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 542 test_embedder()->web_contents()->GetRenderViewHost()); | 543 test_embedder()->web_contents()->GetRenderViewHost()); |
| 543 ExecuteSyncJSFunction( | 544 ExecuteSyncJSFunction( |
| 544 rvh, "document.getElementById('plugin').style.visibility = 'hidden'"); | 545 rvh, "document.getElementById('plugin').style.visibility = 'hidden'"); |
| 545 | 546 |
| 546 // Make sure that the guest is hidden. | 547 // Make sure that the guest is hidden. |
| 547 test_guest()->WaitUntilHidden(); | 548 test_guest()->WaitUntilHidden(); |
| 548 } | 549 } |
| 549 | 550 |
| 550 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderVisibilityChanged) { | 551 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderVisibilityChanged) { |
| 551 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 552 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 552 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 553 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 553 | 554 |
| 554 // Hide the embedder. | 555 // Hide the embedder. |
| 555 test_embedder()->web_contents()->WasHidden(); | 556 test_embedder()->web_contents()->WasHidden(); |
| 556 | 557 |
| 557 // Make sure that hiding the embedder also hides the guest. | 558 // Make sure that hiding the embedder also hides the guest. |
| 558 test_guest()->WaitUntilHidden(); | 559 test_guest()->WaitUntilHidden(); |
| 559 } | 560 } |
| 560 | 561 |
| 561 // This test verifies that calling the reload method reloads the guest. | 562 // This test verifies that calling the reload method reloads the guest. |
| 562 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadGuest) { | 563 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadGuest) { |
| 563 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 564 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 564 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 565 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 565 | 566 |
| 566 test_guest()->ResetUpdateRectCount(); | 567 test_guest()->ResetUpdateRectCount(); |
| 567 | 568 |
| 568 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 569 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 569 test_embedder()->web_contents()->GetRenderViewHost()); | 570 test_embedder()->web_contents()->GetRenderViewHost()); |
| 570 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload()"); | 571 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload()"); |
| 571 test_guest()->WaitForReload(); | 572 test_guest()->WaitForReload(); |
| 572 } | 573 } |
| 573 | 574 |
| 574 // This test verifies that calling the stop method forwards the stop request | 575 // This test verifies that calling the stop method forwards the stop request |
| 575 // to the guest's WebContents. | 576 // to the guest's WebContents. |
| 576 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, StopGuest) { | 577 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, StopGuest) { |
| 577 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 578 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 578 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 579 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 579 | 580 |
| 580 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 581 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 581 test_embedder()->web_contents()->GetRenderViewHost()); | 582 test_embedder()->web_contents()->GetRenderViewHost()); |
| 582 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').stop()"); | 583 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').stop()"); |
| 583 test_guest()->WaitForStop(); | 584 test_guest()->WaitForStop(); |
| 584 } | 585 } |
| 585 | 586 |
| 586 // Verifies that installing/uninstalling touch-event handlers in the guest | 587 // Verifies that installing/uninstalling touch-event handlers in the guest |
| 587 // plugin correctly updates the touch-event handling state in the embedder. | 588 // plugin correctly updates the touch-event handling state in the embedder. |
| 588 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { | 589 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { |
| 589 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 590 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 590 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestTouchHandler, true, ""); | 591 StartBrowserPluginTest( |
| 592 kEmbedderURL, kHTMLForGuestTouchHandler, true, std::string()); |
| 591 | 593 |
| 592 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 594 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 593 test_embedder()->web_contents()->GetRenderViewHost()); | 595 test_embedder()->web_contents()->GetRenderViewHost()); |
| 594 // The embedder should not have any touch event handlers at this point. | 596 // The embedder should not have any touch event handlers at this point. |
| 595 EXPECT_FALSE(rvh->has_touch_handler()); | 597 EXPECT_FALSE(rvh->has_touch_handler()); |
| 596 | 598 |
| 597 // Install the touch handler in the guest. This should cause the embedder to | 599 // Install the touch handler in the guest. This should cause the embedder to |
| 598 // start listening for touch events too. | 600 // start listening for touch events too. |
| 599 RenderViewHostMessageObserver observer(rvh, | 601 RenderViewHostMessageObserver observer(rvh, |
| 600 ViewHostMsg_HasTouchEventHandlers::ID); | 602 ViewHostMsg_HasTouchEventHandlers::ID); |
| 601 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), | 603 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), |
| 602 "InstallTouchHandler();"); | 604 "InstallTouchHandler();"); |
| 603 observer.WaitUntilMessageReceived(); | 605 observer.WaitUntilMessageReceived(); |
| 604 EXPECT_TRUE(rvh->has_touch_handler()); | 606 EXPECT_TRUE(rvh->has_touch_handler()); |
| 605 | 607 |
| 606 // Uninstalling the touch-handler in guest should cause the embedder to stop | 608 // Uninstalling the touch-handler in guest should cause the embedder to stop |
| 607 // listening for touch events. | 609 // listening for touch events. |
| 608 observer.ResetState(); | 610 observer.ResetState(); |
| 609 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), | 611 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), |
| 610 "UninstallTouchHandler();"); | 612 "UninstallTouchHandler();"); |
| 611 observer.WaitUntilMessageReceived(); | 613 observer.WaitUntilMessageReceived(); |
| 612 EXPECT_FALSE(rvh->has_touch_handler()); | 614 EXPECT_FALSE(rvh->has_touch_handler()); |
| 613 } | 615 } |
| 614 | 616 |
| 615 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, Renavigate) { | 617 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, Renavigate) { |
| 616 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 618 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 617 StartBrowserPluginTest( | 619 StartBrowserPluginTest( |
| 618 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); | 620 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, std::string()); |
| 619 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 621 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 620 test_embedder()->web_contents()->GetRenderViewHost()); | 622 test_embedder()->web_contents()->GetRenderViewHost()); |
| 621 | 623 |
| 622 // Navigate to P2 and verify that the navigation occurred. | 624 // Navigate to P2 and verify that the navigation occurred. |
| 623 { | 625 { |
| 624 const string16 expected_title = ASCIIToUTF16("P2"); | 626 const string16 expected_title = ASCIIToUTF16("P2"); |
| 625 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 627 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 626 expected_title); | 628 expected_title); |
| 627 | 629 |
| 628 ExecuteSyncJSFunction( | 630 ExecuteSyncJSFunction( |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 bool result = true; | 705 bool result = true; |
| 704 ASSERT_TRUE(value->GetAsBoolean(&result)); | 706 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 705 EXPECT_FALSE(result); | 707 EXPECT_FALSE(result); |
| 706 } | 708 } |
| 707 } | 709 } |
| 708 | 710 |
| 709 // This tests verifies that reloading the embedder does not crash the browser | 711 // This tests verifies that reloading the embedder does not crash the browser |
| 710 // and that the guest is reset. | 712 // and that the guest is reset. |
| 711 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { | 713 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { |
| 712 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 714 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 713 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 715 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 714 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 716 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 715 test_embedder()->web_contents()->GetRenderViewHost()); | 717 test_embedder()->web_contents()->GetRenderViewHost()); |
| 716 | 718 |
| 717 // Change the title of the page to 'modified' so that we know that | 719 // Change the title of the page to 'modified' so that we know that |
| 718 // the page has successfully reloaded when it goes back to 'embedder' | 720 // the page has successfully reloaded when it goes back to 'embedder' |
| 719 // in the next step. | 721 // in the next step. |
| 720 { | 722 { |
| 721 const string16 expected_title = ASCIIToUTF16("modified"); | 723 const string16 expected_title = ASCIIToUTF16("modified"); |
| 722 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 724 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 723 expected_title); | 725 expected_title); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 754 test_guest_web_contents->GetBrowserPluginGuest()); | 756 test_guest_web_contents->GetBrowserPluginGuest()); |
| 755 ASSERT_TRUE(new_test_guest != NULL); | 757 ASSERT_TRUE(new_test_guest != NULL); |
| 756 | 758 |
| 757 // Wait for the guest to send an UpdateRectMsg, meaning it is ready. | 759 // Wait for the guest to send an UpdateRectMsg, meaning it is ready. |
| 758 new_test_guest->WaitForUpdateRectMsg(); | 760 new_test_guest->WaitForUpdateRectMsg(); |
| 759 } | 761 } |
| 760 } | 762 } |
| 761 | 763 |
| 762 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, TerminateGuest) { | 764 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, TerminateGuest) { |
| 763 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 765 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 764 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 766 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 765 | 767 |
| 766 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 768 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 767 test_embedder()->web_contents()->GetRenderViewHost()); | 769 test_embedder()->web_contents()->GetRenderViewHost()); |
| 768 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate()"); | 770 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate()"); |
| 769 | 771 |
| 770 // Expect the guest to crash. | 772 // Expect the guest to crash. |
| 771 test_guest()->WaitForExit(); | 773 test_guest()->WaitForExit(); |
| 772 } | 774 } |
| 773 | 775 |
| 774 // This test verifies that the guest is responsive after crashing and going back | 776 // This test verifies that the guest is responsive after crashing and going back |
| 775 // to a previous navigation entry. | 777 // to a previous navigation entry. |
| 776 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BackAfterTerminateGuest) { | 778 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BackAfterTerminateGuest) { |
| 777 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 779 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 778 StartBrowserPluginTest( | 780 StartBrowserPluginTest( |
| 779 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); | 781 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, std::string()); |
| 780 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 782 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 781 test_embedder()->web_contents()->GetRenderViewHost()); | 783 test_embedder()->web_contents()->GetRenderViewHost()); |
| 782 | 784 |
| 783 // Navigate to P2 and verify that the navigation occurred. | 785 // Navigate to P2 and verify that the navigation occurred. |
| 784 { | 786 { |
| 785 const string16 expected_title = ASCIIToUTF16("P2"); | 787 const string16 expected_title = ASCIIToUTF16("P2"); |
| 786 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 788 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 787 expected_title); | 789 expected_title); |
| 788 | 790 |
| 789 ExecuteSyncJSFunction( | 791 ExecuteSyncJSFunction( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 811 EXPECT_EQ(expected_title, actual_title); | 813 EXPECT_EQ(expected_title, actual_title); |
| 812 } | 814 } |
| 813 // Send an input event and verify that the guest receives the input. | 815 // Send an input event and verify that the guest receives the input. |
| 814 SimulateMouseClick(test_embedder()->web_contents(), 0, | 816 SimulateMouseClick(test_embedder()->web_contents(), 0, |
| 815 WebKit::WebMouseEvent::ButtonLeft); | 817 WebKit::WebMouseEvent::ButtonLeft); |
| 816 test_guest()->WaitForInput(); | 818 test_guest()->WaitForInput(); |
| 817 } | 819 } |
| 818 | 820 |
| 819 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStart) { | 821 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStart) { |
| 820 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 822 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 821 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 823 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, std::string()); |
| 822 | 824 |
| 823 const string16 expected_title = ASCIIToUTF16(kHTMLForGuest); | 825 const string16 expected_title = ASCIIToUTF16(kHTMLForGuest); |
| 824 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 826 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 825 expected_title); | 827 expected_title); |
| 826 // Renavigate the guest to |kHTMLForGuest|. | 828 // Renavigate the guest to |kHTMLForGuest|. |
| 827 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 829 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 828 test_embedder()->web_contents()->GetRenderViewHost()); | 830 test_embedder()->web_contents()->GetRenderViewHost()); |
| 829 ExecuteSyncJSFunction(rvh, | 831 ExecuteSyncJSFunction(rvh, |
| 830 base::StringPrintf("SetSrc('%s');", kHTMLForGuest)); | 832 base::StringPrintf("SetSrc('%s');", kHTMLForGuest)); |
| 831 | 833 |
| 832 string16 actual_title = title_watcher.WaitAndGetTitle(); | 834 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 833 EXPECT_EQ(expected_title, actual_title); | 835 EXPECT_EQ(expected_title, actual_title); |
| 834 } | 836 } |
| 835 | 837 |
| 836 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadAbort) { | 838 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadAbort) { |
| 837 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 839 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 838 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 840 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, std::string()); |
| 839 | 841 |
| 840 { | 842 { |
| 841 // Navigate the guest to "close-socket". | 843 // Navigate the guest to "close-socket". |
| 842 const string16 expected_title = ASCIIToUTF16("ERR_EMPTY_RESPONSE"); | 844 const string16 expected_title = ASCIIToUTF16("ERR_EMPTY_RESPONSE"); |
| 843 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 845 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 844 expected_title); | 846 expected_title); |
| 845 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 847 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 846 test_embedder()->web_contents()->GetRenderViewHost()); | 848 test_embedder()->web_contents()->GetRenderViewHost()); |
| 847 GURL test_url = test_server()->GetURL("close-socket"); | 849 GURL test_url = test_server()->GetURL("close-socket"); |
| 848 ExecuteSyncJSFunction( | 850 ExecuteSyncJSFunction( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 875 GURL test_url("file://foo"); | 877 GURL test_url("file://foo"); |
| 876 ExecuteSyncJSFunction( | 878 ExecuteSyncJSFunction( |
| 877 rvh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 879 rvh, base::StringPrintf("SetSrc('%s');", test_url.spec().c_str())); |
| 878 string16 actual_title = title_watcher.WaitAndGetTitle(); | 880 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 879 EXPECT_EQ(expected_title, actual_title); | 881 EXPECT_EQ(expected_title, actual_title); |
| 880 } | 882 } |
| 881 } | 883 } |
| 882 | 884 |
| 883 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) { | 885 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) { |
| 884 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 886 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
| 885 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 887 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, std::string()); |
| 886 | 888 |
| 887 const string16 expected_title = ASCIIToUTF16("redirected"); | 889 const string16 expected_title = ASCIIToUTF16("redirected"); |
| 888 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 890 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 889 expected_title); | 891 expected_title); |
| 890 | 892 |
| 891 // Navigate with a redirect and wait until the title changes. | 893 // Navigate with a redirect and wait until the title changes. |
| 892 GURL redirect_url(test_server()->GetURL( | 894 GURL redirect_url(test_server()->GetURL( |
| 893 "server-redirect?files/title1.html")); | 895 "server-redirect?files/title1.html")); |
| 894 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 896 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 895 test_embedder()->web_contents()->GetRenderViewHost()); | 897 test_embedder()->web_contents()->GetRenderViewHost()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 915 #if defined(OS_WIN) && defined(USE_AURA) | 917 #if defined(OS_WIN) && defined(USE_AURA) |
| 916 #define MAYBE_AcceptDragEvents DISABLED_AcceptDragEvents | 918 #define MAYBE_AcceptDragEvents DISABLED_AcceptDragEvents |
| 917 #else | 919 #else |
| 918 #define MAYBE_AcceptDragEvents AcceptDragEvents | 920 #define MAYBE_AcceptDragEvents AcceptDragEvents |
| 919 #endif | 921 #endif |
| 920 | 922 |
| 921 // Tests that a drag-n-drop over the browser plugin in the embedder happens | 923 // Tests that a drag-n-drop over the browser plugin in the embedder happens |
| 922 // correctly. | 924 // correctly. |
| 923 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, MAYBE_AcceptDragEvents) { | 925 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, MAYBE_AcceptDragEvents) { |
| 924 const char kEmbedderURL[] = "files/browser_plugin_dragging.html"; | 926 const char kEmbedderURL[] = "files/browser_plugin_dragging.html"; |
| 925 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestAcceptDrag, true, ""); | 927 StartBrowserPluginTest( |
| 928 kEmbedderURL, kHTMLForGuestAcceptDrag, true, std::string()); |
| 926 | 929 |
| 927 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 930 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 928 test_embedder()->web_contents()->GetRenderViewHost()); | 931 test_embedder()->web_contents()->GetRenderViewHost()); |
| 929 | 932 |
| 930 // Get a location in the embedder outside of the plugin. | 933 // Get a location in the embedder outside of the plugin. |
| 931 base::ListValue *start, *end; | 934 base::ListValue *start, *end; |
| 932 scoped_ptr<base::Value> value = | 935 scoped_ptr<base::Value> value = |
| 933 content::ExecuteScriptAndGetValue(rvh, "dragLocation()"); | 936 content::ExecuteScriptAndGetValue(rvh, "dragLocation()"); |
| 934 ASSERT_TRUE(value->GetAsList(&start) && start->GetSize() == 2); | 937 ASSERT_TRUE(value->GetAsList(&start) && start->GetSize() == 2); |
| 935 double start_x, start_y; | 938 double start_x, start_y; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // 3. The embedder receives the message and uses the event's source | 974 // 3. The embedder receives the message and uses the event's source |
| 972 // object to do one final reply: 'stop' | 975 // object to do one final reply: 'stop' |
| 973 // 4. The guest receives the final 'stop' message. | 976 // 4. The guest receives the final 'stop' message. |
| 974 // 5. The guest acks the 'stop' message with a 'stop_ack' message. | 977 // 5. The guest acks the 'stop' message with a 'stop_ack' message. |
| 975 // 6. The embedder changes its title to 'main guest' when it sees the 'stop_ack' | 978 // 6. The embedder changes its title to 'main guest' when it sees the 'stop_ack' |
| 976 // message. | 979 // message. |
| 977 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PostMessage) { | 980 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PostMessage) { |
| 978 const char* kTesting = "testing123"; | 981 const char* kTesting = "testing123"; |
| 979 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 982 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 980 const char* kGuestURL = "files/browser_plugin_post_message_guest.html"; | 983 const char* kGuestURL = "files/browser_plugin_post_message_guest.html"; |
| 981 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); | 984 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string()); |
| 982 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 985 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 983 test_embedder()->web_contents()->GetRenderViewHost()); | 986 test_embedder()->web_contents()->GetRenderViewHost()); |
| 984 { | 987 { |
| 985 const string16 expected_title = ASCIIToUTF16("main guest"); | 988 const string16 expected_title = ASCIIToUTF16("main guest"); |
| 986 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 989 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 987 expected_title); | 990 expected_title); |
| 988 | 991 |
| 989 // By the time we get here 'contentWindow' should be ready because the | 992 // By the time we get here 'contentWindow' should be ready because the |
| 990 // guest has completed loading. | 993 // guest has completed loading. |
| 991 ExecuteSyncJSFunction( | 994 ExecuteSyncJSFunction( |
| 992 rvh, base::StringPrintf("PostMessage('%s, false');", kTesting)); | 995 rvh, base::StringPrintf("PostMessage('%s, false');", kTesting)); |
| 993 | 996 |
| 994 // The title will be updated to "main guest" at the last stage of the | 997 // The title will be updated to "main guest" at the last stage of the |
| 995 // process described above. | 998 // process described above. |
| 996 string16 actual_title = title_watcher.WaitAndGetTitle(); | 999 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 997 EXPECT_EQ(expected_title, actual_title); | 1000 EXPECT_EQ(expected_title, actual_title); |
| 998 } | 1001 } |
| 999 } | 1002 } |
| 1000 | 1003 |
| 1001 // This is the same as BrowserPluginHostTest.PostMessage but also | 1004 // This is the same as BrowserPluginHostTest.PostMessage but also |
| 1002 // posts a message to an iframe. | 1005 // posts a message to an iframe. |
| 1003 // TODO(fsamuel): This test should replace the previous test once postMessage | 1006 // TODO(fsamuel): This test should replace the previous test once postMessage |
| 1004 // iframe targeting is fixed (see http://crbug.com/153701). | 1007 // iframe targeting is fixed (see http://crbug.com/153701). |
| 1005 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_PostMessageToIFrame) { | 1008 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_PostMessageToIFrame) { |
| 1006 const char* kTesting = "testing123"; | 1009 const char* kTesting = "testing123"; |
| 1007 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1010 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1008 const char* kGuestURL = "files/browser_plugin_post_message_guest.html"; | 1011 const char* kGuestURL = "files/browser_plugin_post_message_guest.html"; |
| 1009 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); | 1012 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string()); |
| 1010 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1013 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1011 test_embedder()->web_contents()->GetRenderViewHost()); | 1014 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1012 { | 1015 { |
| 1013 const string16 expected_title = ASCIIToUTF16("main guest"); | 1016 const string16 expected_title = ASCIIToUTF16("main guest"); |
| 1014 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1017 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 1015 expected_title); | 1018 expected_title); |
| 1016 | 1019 |
| 1017 ExecuteSyncJSFunction( | 1020 ExecuteSyncJSFunction( |
| 1018 rvh, base::StringPrintf("PostMessage('%s, false');", kTesting)); | 1021 rvh, base::StringPrintf("PostMessage('%s, false');", kTesting)); |
| 1019 | 1022 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1045 | 1048 |
| 1046 // The title will be updated to "iframe" at the last stage of the | 1049 // The title will be updated to "iframe" at the last stage of the |
| 1047 // process described above. | 1050 // process described above. |
| 1048 actual_title = iframe_watcher.WaitAndGetTitle(); | 1051 actual_title = iframe_watcher.WaitAndGetTitle(); |
| 1049 EXPECT_EQ(ASCIIToUTF16("iframe"), actual_title); | 1052 EXPECT_EQ(ASCIIToUTF16("iframe"), actual_title); |
| 1050 } | 1053 } |
| 1051 } | 1054 } |
| 1052 | 1055 |
| 1053 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStop) { | 1056 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStop) { |
| 1054 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1057 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1055 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 1058 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, std::string()); |
| 1056 | 1059 |
| 1057 const string16 expected_title = ASCIIToUTF16("loadStop"); | 1060 const string16 expected_title = ASCIIToUTF16("loadStop"); |
| 1058 content::TitleWatcher title_watcher( | 1061 content::TitleWatcher title_watcher( |
| 1059 test_embedder()->web_contents(), expected_title); | 1062 test_embedder()->web_contents(), expected_title); |
| 1060 // Renavigate the guest to |kHTMLForGuest|. | 1063 // Renavigate the guest to |kHTMLForGuest|. |
| 1061 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1064 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1062 test_embedder()->web_contents()->GetRenderViewHost()); | 1065 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1063 ExecuteSyncJSFunction(rvh, | 1066 ExecuteSyncJSFunction(rvh, |
| 1064 base::StringPrintf("SetSrc('%s');", kHTMLForGuest)); | 1067 base::StringPrintf("SetSrc('%s');", kHTMLForGuest)); |
| 1065 | 1068 |
| 1066 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1069 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 1067 EXPECT_EQ(expected_title, actual_title); | 1070 EXPECT_EQ(expected_title, actual_title); |
| 1068 } | 1071 } |
| 1069 | 1072 |
| 1070 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadCommit) { | 1073 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadCommit) { |
| 1071 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1074 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1072 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 1075 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, std::string()); |
| 1073 | 1076 |
| 1074 const string16 expected_title = ASCIIToUTF16( | 1077 const string16 expected_title = ASCIIToUTF16( |
| 1075 base::StringPrintf("loadCommit:%s", kHTMLForGuest)); | 1078 base::StringPrintf("loadCommit:%s", kHTMLForGuest)); |
| 1076 content::TitleWatcher title_watcher( | 1079 content::TitleWatcher title_watcher( |
| 1077 test_embedder()->web_contents(), expected_title); | 1080 test_embedder()->web_contents(), expected_title); |
| 1078 // Renavigate the guest to |kHTMLForGuest|. | 1081 // Renavigate the guest to |kHTMLForGuest|. |
| 1079 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1082 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1080 test_embedder()->web_contents()->GetRenderViewHost()); | 1083 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1081 ExecuteSyncJSFunction(rvh, | 1084 ExecuteSyncJSFunction(rvh, |
| 1082 base::StringPrintf("SetSrc('%s');", kHTMLForGuest)); | 1085 base::StringPrintf("SetSrc('%s');", kHTMLForGuest)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1098 "document.getElementById('plugin').style.visibility = 'hidden'"; | 1101 "document.getElementById('plugin').style.visibility = 'hidden'"; |
| 1099 StartBrowserPluginTest( | 1102 StartBrowserPluginTest( |
| 1100 kEmbedderURL, kHTMLForGuest, true, embedder_code); | 1103 kEmbedderURL, kHTMLForGuest, true, embedder_code); |
| 1101 EXPECT_FALSE(test_guest()->visible()); | 1104 EXPECT_FALSE(test_guest()->visible()); |
| 1102 } | 1105 } |
| 1103 | 1106 |
| 1104 // This test verifies that if we lose the guest, and get a new one, | 1107 // This test verifies that if we lose the guest, and get a new one, |
| 1105 // the new guest will inherit the visibility state of the old guest. | 1108 // the new guest will inherit the visibility state of the old guest. |
| 1106 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VisibilityPreservation) { | 1109 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VisibilityPreservation) { |
| 1107 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1110 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1108 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 1111 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 1109 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1112 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1110 test_embedder()->web_contents()->GetRenderViewHost()); | 1113 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1111 // Hide the BrowserPlugin. | 1114 // Hide the BrowserPlugin. |
| 1112 ExecuteSyncJSFunction( | 1115 ExecuteSyncJSFunction( |
| 1113 rvh, "document.getElementById('plugin').style.visibility = 'hidden';"); | 1116 rvh, "document.getElementById('plugin').style.visibility = 'hidden';"); |
| 1114 test_guest()->WaitUntilHidden(); | 1117 test_guest()->WaitUntilHidden(); |
| 1115 // Kill the current guest. | 1118 // Kill the current guest. |
| 1116 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate();"); | 1119 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate();"); |
| 1117 test_guest()->WaitForExit(); | 1120 test_guest()->WaitForExit(); |
| 1118 // Get a new guest. | 1121 // Get a new guest. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1138 bool result = false; | 1141 bool result = false; |
| 1139 ASSERT_TRUE(value->GetAsBoolean(&result)); | 1142 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 1140 EXPECT_TRUE(result); | 1143 EXPECT_TRUE(result); |
| 1141 } | 1144 } |
| 1142 | 1145 |
| 1143 // This test verifies that if we lose the guest, and get a new one, | 1146 // This test verifies that if we lose the guest, and get a new one, |
| 1144 // the new guest will inherit the focus state of the old guest. | 1147 // the new guest will inherit the focus state of the old guest. |
| 1145 // crbug.com/170249 | 1148 // crbug.com/170249 |
| 1146 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_FocusPreservation) { | 1149 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_FocusPreservation) { |
| 1147 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1150 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1148 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 1151 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 1149 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1152 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1150 test_embedder()->web_contents()->GetRenderViewHost()); | 1153 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1151 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 1154 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
| 1152 test_guest()->web_contents()->GetRenderViewHost()); | 1155 test_guest()->web_contents()->GetRenderViewHost()); |
| 1153 { | 1156 { |
| 1154 // Focus the BrowserPlugin. This will have the effect of also focusing the | 1157 // Focus the BrowserPlugin. This will have the effect of also focusing the |
| 1155 // current guest. | 1158 // current guest. |
| 1156 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();"); | 1159 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();"); |
| 1157 // Verify that key presses go to the guest. | 1160 // Verify that key presses go to the guest. |
| 1158 SimulateSpaceKeyPress(test_embedder()->web_contents()); | 1161 SimulateSpaceKeyPress(test_embedder()->web_contents()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1177 scoped_ptr<base::Value> value = | 1180 scoped_ptr<base::Value> value = |
| 1178 content::ExecuteScriptAndGetValue(guest_rvh, "document.hasFocus()"); | 1181 content::ExecuteScriptAndGetValue(guest_rvh, "document.hasFocus()"); |
| 1179 bool result = false; | 1182 bool result = false; |
| 1180 ASSERT_TRUE(value->GetAsBoolean(&result)); | 1183 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 1181 EXPECT_TRUE(result); | 1184 EXPECT_TRUE(result); |
| 1182 } | 1185 } |
| 1183 } | 1186 } |
| 1184 | 1187 |
| 1185 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) { | 1188 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) { |
| 1186 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1189 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1187 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 1190 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 1188 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1191 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1189 test_embedder()->web_contents()->GetRenderViewHost()); | 1192 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1190 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 1193 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
| 1191 test_guest()->web_contents()->GetRenderViewHost()); | 1194 test_guest()->web_contents()->GetRenderViewHost()); |
| 1192 { | 1195 { |
| 1193 // Focus the BrowserPlugin. This will have the effect of also focusing the | 1196 // Focus the BrowserPlugin. This will have the effect of also focusing the |
| 1194 // current guest. | 1197 // current guest. |
| 1195 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();"); | 1198 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();"); |
| 1196 // Verify that key presses go to the guest. | 1199 // Verify that key presses go to the guest. |
| 1197 SimulateSpaceKeyPress(test_embedder()->web_contents()); | 1200 SimulateSpaceKeyPress(test_embedder()->web_contents()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1222 kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code); | 1225 kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code); |
| 1223 // Verify that the guest has been auto-sized. | 1226 // Verify that the guest has been auto-sized. |
| 1224 test_guest()->WaitForViewSize(gfx::Size(300, 400)); | 1227 test_guest()->WaitForViewSize(gfx::Size(300, 400)); |
| 1225 } | 1228 } |
| 1226 | 1229 |
| 1227 // This test verifies that enabling autosize resizes the guest and triggers | 1230 // This test verifies that enabling autosize resizes the guest and triggers |
| 1228 // a 'sizechanged' event. | 1231 // a 'sizechanged' event. |
| 1229 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeAfterNavigation) { | 1232 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeAfterNavigation) { |
| 1230 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1233 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
| 1231 StartBrowserPluginTest( | 1234 StartBrowserPluginTest( |
| 1232 kEmbedderURL, kHTMLForGuestWithSize, true, ""); | 1235 kEmbedderURL, kHTMLForGuestWithSize, true, std::string()); |
| 1233 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1236 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1234 test_embedder()->web_contents()->GetRenderViewHost()); | 1237 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1235 | 1238 |
| 1236 { | 1239 { |
| 1237 const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)"); | 1240 const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)"); |
| 1238 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1241 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 1239 expected_title); | 1242 expected_title); |
| 1240 ExecuteSyncJSFunction( | 1243 ExecuteSyncJSFunction( |
| 1241 rvh, | 1244 rvh, |
| 1242 "document.getElementById('plugin').minwidth = 300;" | 1245 "document.getElementById('plugin').minwidth = 300;" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 // bounds of our guest, so this would respond with the render view host of the | 1279 // bounds of our guest, so this would respond with the render view host of the |
| 1277 // embedder. | 1280 // embedder. |
| 1278 test_embedder()->WaitForRenderViewHostAtPosition(150, 150); | 1281 test_embedder()->WaitForRenderViewHostAtPosition(150, 150); |
| 1279 ASSERT_EQ(test_embedder()->web_contents()->GetRenderViewHost(), | 1282 ASSERT_EQ(test_embedder()->web_contents()->GetRenderViewHost(), |
| 1280 test_embedder()->last_rvh_at_position_response()); | 1283 test_embedder()->last_rvh_at_position_response()); |
| 1281 } | 1284 } |
| 1282 | 1285 |
| 1283 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ChangeWindowName) { | 1286 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ChangeWindowName) { |
| 1284 const char kEmbedderURL[] = "files/browser_plugin_naming_embedder.html"; | 1287 const char kEmbedderURL[] = "files/browser_plugin_naming_embedder.html"; |
| 1285 const char* kGuestURL = "files/browser_plugin_naming_guest.html"; | 1288 const char* kGuestURL = "files/browser_plugin_naming_guest.html"; |
| 1286 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); | 1289 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string()); |
| 1287 | 1290 |
| 1288 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1291 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
| 1289 test_embedder()->web_contents()->GetRenderViewHost()); | 1292 test_embedder()->web_contents()->GetRenderViewHost()); |
| 1290 // Verify that the plugin's name is properly initialized. | 1293 // Verify that the plugin's name is properly initialized. |
| 1291 { | 1294 { |
| 1292 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( | 1295 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( |
| 1293 rvh, "document.getElementById('plugin').name"); | 1296 rvh, "document.getElementById('plugin').name"); |
| 1294 std::string result; | 1297 std::string result; |
| 1295 EXPECT_TRUE(value->GetAsString(&result)); | 1298 EXPECT_TRUE(value->GetAsString(&result)); |
| 1296 EXPECT_EQ("start", result); | 1299 EXPECT_EQ("start", result); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)"); | 1395 const string16 expected_title = ASCIIToUTF16("AutoSize(640, 480)"); |
| 1393 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1396 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
| 1394 expected_title); | 1397 expected_title); |
| 1395 RemoveAttributes(rvh, "maxwidth"); | 1398 RemoveAttributes(rvh, "maxwidth"); |
| 1396 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1399 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 1397 EXPECT_EQ(expected_title, actual_title); | 1400 EXPECT_EQ(expected_title, actual_title); |
| 1398 } | 1401 } |
| 1399 } | 1402 } |
| 1400 | 1403 |
| 1401 } // namespace content | 1404 } // namespace content |
| OLD | NEW |