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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 SimulateKeyPress(web_contents, | 267 SimulateKeyPress(web_contents, |
268 ui::VKEY_TAB, | 268 ui::VKEY_TAB, |
269 false, // control. | 269 false, // control. |
270 false, // shift. | 270 false, // shift. |
271 false, // alt. | 271 false, // alt. |
272 false); // command. | 272 false); // command. |
273 } | 273 } |
274 | 274 |
275 // Executes the javascript synchronously and makes sure the returned value is | 275 // Executes the javascript synchronously and makes sure the returned value is |
276 // freed properly. | 276 // freed properly. |
277 void ExecuteSyncJSFunction(RenderViewHost* rvh, const std::string& jscript) { | 277 void ExecuteSyncJSFunction(RenderViewHost* rvh, const string16& jscript) { |
278 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( | 278 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( |
279 string16(), UTF8ToUTF16(jscript))); | 279 string16(), jscript)); |
280 } | 280 } |
281 | 281 |
282 // This helper method does the following: | 282 // This helper method does the following: |
283 // 1. Start the test server and navigate the shell to |embedder_url|. | 283 // 1. Start the test server and navigate the shell to |embedder_url|. |
284 // 2. Execute custom pre-navigation |embedder_code| if provided. | 284 // 2. Execute custom pre-navigation |embedder_code| if provided. |
285 // 3. Navigate the guest to the |guest_url|. | 285 // 3. Navigate the guest to the |guest_url|. |
286 // 4. Verify that the guest has been created and has completed loading. | 286 // 4. Verify that the guest has been created and has completed loading. |
287 void StartBrowserPluginTest(const std::string& embedder_url, | 287 void StartBrowserPluginTest(const std::string& embedder_url, |
288 const std::string& guest_url, | 288 const std::string& guest_url, |
289 bool is_guest_data_url, | 289 bool is_guest_data_url, |
290 const std::string& embedder_code) { | 290 const std::string& embedder_code) { |
291 ASSERT_TRUE(test_server()->Start()); | 291 ASSERT_TRUE(test_server()->Start()); |
292 GURL test_url(test_server()->GetURL(embedder_url)); | 292 GURL test_url(test_server()->GetURL(embedder_url)); |
293 NavigateToURL(shell(), test_url); | 293 NavigateToURL(shell(), test_url); |
294 | 294 |
295 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( | 295 WebContentsImpl* embedder_web_contents = static_cast<WebContentsImpl*>( |
296 shell()->web_contents()); | 296 shell()->web_contents()); |
297 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 297 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
298 embedder_web_contents->GetRenderViewHost()); | 298 embedder_web_contents->GetRenderViewHost()); |
299 // Focus the embedder. | 299 // Focus the embedder. |
300 rvh->Focus(); | 300 rvh->Focus(); |
301 | 301 |
302 // Allow the test to do some operations on the embedder before we perform | 302 // Allow the test to do some operations on the embedder before we perform |
303 // the first navigation of the guest. | 303 // the first navigation of the guest. |
304 if (!embedder_code.empty()) | 304 if (!embedder_code.empty()) |
305 ExecuteSyncJSFunction(rvh, embedder_code); | 305 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(embedder_code)); |
306 | 306 |
307 if (!is_guest_data_url) { | 307 if (!is_guest_data_url) { |
308 test_url = test_server()->GetURL(guest_url); | 308 test_url = test_server()->GetURL(guest_url); |
309 ExecuteSyncJSFunction( | 309 ExecuteSyncJSFunction(rvh, |
310 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 310 ASCIIToUTF16(StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); |
311 } else { | 311 } else { |
312 ExecuteSyncJSFunction( | 312 ExecuteSyncJSFunction(rvh, |
313 rvh, StringPrintf("SetSrc('%s');", guest_url.c_str())); | 313 ASCIIToUTF16(StringPrintf("SetSrc('%s');", guest_url.c_str()))); |
314 } | 314 } |
315 | 315 |
316 // Wait to make sure embedder is created/attached to WebContents. | 316 // Wait to make sure embedder is created/attached to WebContents. |
317 TestBrowserPluginHostFactory::GetInstance()->WaitForEmbedderCreation(); | 317 TestBrowserPluginHostFactory::GetInstance()->WaitForEmbedderCreation(); |
318 | 318 |
319 test_embedder_ = static_cast<TestBrowserPluginEmbedder*>( | 319 test_embedder_ = static_cast<TestBrowserPluginEmbedder*>( |
320 embedder_web_contents->GetBrowserPluginEmbedder()); | 320 embedder_web_contents->GetBrowserPluginEmbedder()); |
321 ASSERT_TRUE(test_embedder_); | 321 ASSERT_TRUE(test_embedder_); |
322 test_embedder_->WaitForGuestAdded(); | 322 test_embedder_->WaitForGuestAdded(); |
323 | 323 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 const char kEmbedderURL[] = | 359 const char kEmbedderURL[] = |
360 "files/browser_plugin_embedder_guest_unresponsive.html"; | 360 "files/browser_plugin_embedder_guest_unresponsive.html"; |
361 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestBusyLoop, true, ""); | 361 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestBusyLoop, true, ""); |
362 // Wait until the busy loop starts. | 362 // Wait until the busy loop starts. |
363 { | 363 { |
364 const string16 expected_title = ASCIIToUTF16("start"); | 364 const string16 expected_title = ASCIIToUTF16("start"); |
365 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 365 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
366 expected_title); | 366 expected_title); |
367 // Hang the guest for a length of time. | 367 // Hang the guest for a length of time. |
368 int spin_time = 10 * TestTimeouts::tiny_timeout().InMilliseconds(); | 368 int spin_time = 10 * TestTimeouts::tiny_timeout().InMilliseconds(); |
369 ExecuteSyncJSFunction( | 369 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), |
370 test_guest()->web_contents()->GetRenderViewHost(), | 370 ASCIIToUTF16(StringPrintf("StartPauseMs(%d);", spin_time).c_str())); |
371 StringPrintf("StartPauseMs(%d);", spin_time).c_str()); | |
372 | 371 |
373 string16 actual_title = title_watcher.WaitAndGetTitle(); | 372 string16 actual_title = title_watcher.WaitAndGetTitle(); |
374 EXPECT_EQ(expected_title, actual_title); | 373 EXPECT_EQ(expected_title, actual_title); |
375 } | 374 } |
376 { | 375 { |
377 const string16 expected_title = ASCIIToUTF16("done"); | 376 const string16 expected_title = ASCIIToUTF16("done"); |
378 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 377 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
379 expected_title); | 378 expected_title); |
380 | 379 |
381 // Send a mouse event to the guest. | 380 // Send a mouse event to the guest. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 } | 503 } |
505 | 504 |
506 // This test verifies that hiding the embedder also hides the guest. | 505 // This test verifies that hiding the embedder also hides the guest. |
507 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BrowserPluginVisibilityChanged) { | 506 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BrowserPluginVisibilityChanged) { |
508 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 507 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
509 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 508 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
510 | 509 |
511 // Hide the Browser Plugin. | 510 // Hide the Browser Plugin. |
512 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 511 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
513 test_embedder()->web_contents()->GetRenderViewHost()); | 512 test_embedder()->web_contents()->GetRenderViewHost()); |
514 ExecuteSyncJSFunction( | 513 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
515 rvh, "document.getElementById('plugin').style.visibility = 'hidden'"); | 514 "document.getElementById('plugin').style.visibility = 'hidden'")); |
516 | 515 |
517 // Make sure that the guest is hidden. | 516 // Make sure that the guest is hidden. |
518 test_guest()->WaitUntilHidden(); | 517 test_guest()->WaitUntilHidden(); |
519 } | 518 } |
520 | 519 |
521 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderVisibilityChanged) { | 520 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderVisibilityChanged) { |
522 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 521 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
523 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 522 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
524 | 523 |
525 // Hide the embedder. | 524 // Hide the embedder. |
526 test_embedder()->web_contents()->WasHidden(); | 525 test_embedder()->web_contents()->WasHidden(); |
527 | 526 |
528 // Make sure that hiding the embedder also hides the guest. | 527 // Make sure that hiding the embedder also hides the guest. |
529 test_guest()->WaitUntilHidden(); | 528 test_guest()->WaitUntilHidden(); |
530 } | 529 } |
531 | 530 |
532 // This test verifies that calling the reload method reloads the guest. | 531 // This test verifies that calling the reload method reloads the guest. |
533 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadGuest) { | 532 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadGuest) { |
534 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 533 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
535 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 534 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
536 | 535 |
537 test_guest()->ResetUpdateRectCount(); | 536 test_guest()->ResetUpdateRectCount(); |
538 | 537 |
539 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 538 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
540 test_embedder()->web_contents()->GetRenderViewHost()); | 539 test_embedder()->web_contents()->GetRenderViewHost()); |
541 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload()"); | 540 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 541 "document.getElementById('plugin').reload()")); |
542 test_guest()->WaitForReload(); | 542 test_guest()->WaitForReload(); |
543 } | 543 } |
544 | 544 |
545 // This test verifies that calling the stop method forwards the stop request | 545 // This test verifies that calling the stop method forwards the stop request |
546 // to the guest's WebContents. | 546 // to the guest's WebContents. |
547 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, StopGuest) { | 547 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, StopGuest) { |
548 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 548 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
549 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 549 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
550 | 550 |
551 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 551 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
552 test_embedder()->web_contents()->GetRenderViewHost()); | 552 test_embedder()->web_contents()->GetRenderViewHost()); |
553 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').stop()"); | 553 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 554 "document.getElementById('plugin').stop()")); |
554 test_guest()->WaitForStop(); | 555 test_guest()->WaitForStop(); |
555 } | 556 } |
556 | 557 |
557 // Verifies that installing/uninstalling touch-event handlers in the guest | 558 // Verifies that installing/uninstalling touch-event handlers in the guest |
558 // plugin correctly updates the touch-event handling state in the embedder. | 559 // plugin correctly updates the touch-event handling state in the embedder. |
559 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { | 560 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { |
560 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 561 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
561 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestTouchHandler, true, ""); | 562 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestTouchHandler, true, ""); |
562 | 563 |
563 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 564 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
564 test_embedder()->web_contents()->GetRenderViewHost()); | 565 test_embedder()->web_contents()->GetRenderViewHost()); |
565 // The embedder should not have any touch event handlers at this point. | 566 // The embedder should not have any touch event handlers at this point. |
566 EXPECT_FALSE(rvh->has_touch_handler()); | 567 EXPECT_FALSE(rvh->has_touch_handler()); |
567 | 568 |
568 // Install the touch handler in the guest. This should cause the embedder to | 569 // Install the touch handler in the guest. This should cause the embedder to |
569 // start listening for touch events too. | 570 // start listening for touch events too. |
570 RenderViewHostMessageObserver observer(rvh, | 571 RenderViewHostMessageObserver observer(rvh, |
571 ViewHostMsg_HasTouchEventHandlers::ID); | 572 ViewHostMsg_HasTouchEventHandlers::ID); |
572 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), | 573 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), |
573 "InstallTouchHandler();"); | 574 ASCIIToUTF16("InstallTouchHandler();")); |
574 observer.WaitUntilMessageReceived(); | 575 observer.WaitUntilMessageReceived(); |
575 EXPECT_TRUE(rvh->has_touch_handler()); | 576 EXPECT_TRUE(rvh->has_touch_handler()); |
576 | 577 |
577 // Uninstalling the touch-handler in guest should cause the embedder to stop | 578 // Uninstalling the touch-handler in guest should cause the embedder to stop |
578 // listening for touch events. | 579 // listening for touch events. |
579 observer.ResetState(); | 580 observer.ResetState(); |
580 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), | 581 ExecuteSyncJSFunction(test_guest()->web_contents()->GetRenderViewHost(), |
581 "UninstallTouchHandler();"); | 582 ASCIIToUTF16("UninstallTouchHandler();")); |
582 observer.WaitUntilMessageReceived(); | 583 observer.WaitUntilMessageReceived(); |
583 EXPECT_FALSE(rvh->has_touch_handler()); | 584 EXPECT_FALSE(rvh->has_touch_handler()); |
584 } | 585 } |
585 | 586 |
586 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, Renavigate) { | 587 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, Renavigate) { |
587 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 588 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
588 StartBrowserPluginTest( | 589 StartBrowserPluginTest( |
589 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); | 590 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); |
590 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 591 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
591 test_embedder()->web_contents()->GetRenderViewHost()); | 592 test_embedder()->web_contents()->GetRenderViewHost()); |
592 | 593 |
593 // Navigate to P2 and verify that the navigation occurred. | 594 // Navigate to P2 and verify that the navigation occurred. |
594 { | 595 { |
595 const string16 expected_title = ASCIIToUTF16("P2"); | 596 const string16 expected_title = ASCIIToUTF16("P2"); |
596 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 597 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
597 expected_title); | 598 expected_title); |
598 | 599 |
599 ExecuteSyncJSFunction( | 600 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');", |
600 rvh, | 601 GetHTMLForGuestWithTitle("P2").c_str()))); |
601 StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P2").c_str())); | |
602 | 602 |
603 string16 actual_title = title_watcher.WaitAndGetTitle(); | 603 string16 actual_title = title_watcher.WaitAndGetTitle(); |
604 EXPECT_EQ(expected_title, actual_title); | 604 EXPECT_EQ(expected_title, actual_title); |
605 } | 605 } |
606 | 606 |
607 // Navigate to P3 and verify that the navigation occurred. | 607 // Navigate to P3 and verify that the navigation occurred. |
608 { | 608 { |
609 const string16 expected_title = ASCIIToUTF16("P3"); | 609 const string16 expected_title = ASCIIToUTF16("P3"); |
610 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 610 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
611 expected_title); | 611 expected_title); |
612 | 612 |
613 ExecuteSyncJSFunction( | 613 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');", |
614 rvh, | 614 GetHTMLForGuestWithTitle("P3").c_str()))); |
615 StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P3").c_str())); | |
616 | 615 |
617 string16 actual_title = title_watcher.WaitAndGetTitle(); | 616 string16 actual_title = title_watcher.WaitAndGetTitle(); |
618 EXPECT_EQ(expected_title, actual_title); | 617 EXPECT_EQ(expected_title, actual_title); |
619 } | 618 } |
620 | 619 |
621 // Go back and verify that we're back at P2. | 620 // Go back and verify that we're back at P2. |
622 { | 621 { |
623 const string16 expected_title = ASCIIToUTF16("P2"); | 622 const string16 expected_title = ASCIIToUTF16("P2"); |
624 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 623 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
625 expected_title); | 624 expected_title); |
626 | 625 |
627 ExecuteSyncJSFunction(rvh, "Back();"); | 626 ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Back();")); |
628 string16 actual_title = title_watcher.WaitAndGetTitle(); | 627 string16 actual_title = title_watcher.WaitAndGetTitle(); |
629 EXPECT_EQ(expected_title, actual_title); | 628 EXPECT_EQ(expected_title, actual_title); |
630 | 629 |
631 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), | 630 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), |
632 ASCIIToUTF16("CanGoBack()"))); | 631 ASCIIToUTF16("CanGoBack()"))); |
633 bool result = false; | 632 bool result = false; |
634 ASSERT_TRUE(value->GetAsBoolean(&result)); | 633 ASSERT_TRUE(value->GetAsBoolean(&result)); |
635 EXPECT_TRUE(result); | 634 EXPECT_TRUE(result); |
636 | 635 |
637 value.reset(rvh->ExecuteJavascriptAndGetValue(string16(), | 636 value.reset(rvh->ExecuteJavascriptAndGetValue(string16(), |
638 ASCIIToUTF16("CanGoForward()"))); | 637 ASCIIToUTF16("CanGoForward()"))); |
639 result = false; | 638 result = false; |
640 ASSERT_TRUE(value->GetAsBoolean(&result)); | 639 ASSERT_TRUE(value->GetAsBoolean(&result)); |
641 EXPECT_TRUE(result); | 640 EXPECT_TRUE(result); |
642 } | 641 } |
643 | 642 |
644 // Go forward and verify that we're back at P3. | 643 // Go forward and verify that we're back at P3. |
645 { | 644 { |
646 const string16 expected_title = ASCIIToUTF16("P3"); | 645 const string16 expected_title = ASCIIToUTF16("P3"); |
647 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 646 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
648 expected_title); | 647 expected_title); |
649 | 648 |
650 ExecuteSyncJSFunction(rvh, "Forward();"); | 649 ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Forward();")); |
651 string16 actual_title = title_watcher.WaitAndGetTitle(); | 650 string16 actual_title = title_watcher.WaitAndGetTitle(); |
652 EXPECT_EQ(expected_title, actual_title); | 651 EXPECT_EQ(expected_title, actual_title); |
653 | 652 |
654 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), | 653 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), |
655 ASCIIToUTF16("CanGoForward()"))); | 654 ASCIIToUTF16("CanGoForward()"))); |
656 bool result = true; | 655 bool result = true; |
657 ASSERT_TRUE(value->GetAsBoolean(&result)); | 656 ASSERT_TRUE(value->GetAsBoolean(&result)); |
658 EXPECT_FALSE(result); | 657 EXPECT_FALSE(result); |
659 } | 658 } |
660 | 659 |
661 // Go back two entries and verify that we're back at P1. | 660 // Go back two entries and verify that we're back at P1. |
662 { | 661 { |
663 const string16 expected_title = ASCIIToUTF16("P1"); | 662 const string16 expected_title = ASCIIToUTF16("P1"); |
664 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 663 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
665 expected_title); | 664 expected_title); |
666 | 665 |
667 ExecuteSyncJSFunction(rvh, "Go(-2);"); | 666 ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Go(-2);")); |
668 string16 actual_title = title_watcher.WaitAndGetTitle(); | 667 string16 actual_title = title_watcher.WaitAndGetTitle(); |
669 EXPECT_EQ(expected_title, actual_title); | 668 EXPECT_EQ(expected_title, actual_title); |
670 | 669 |
671 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), | 670 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue(string16(), |
672 ASCIIToUTF16("CanGoBack()"))); | 671 ASCIIToUTF16("CanGoBack()"))); |
673 bool result = true; | 672 bool result = true; |
674 ASSERT_TRUE(value->GetAsBoolean(&result)); | 673 ASSERT_TRUE(value->GetAsBoolean(&result)); |
675 EXPECT_FALSE(result); | 674 EXPECT_FALSE(result); |
676 } | 675 } |
677 } | 676 } |
678 | 677 |
679 // This tests verifies that reloading the embedder does not crash the browser | 678 // This tests verifies that reloading the embedder does not crash the browser |
680 // and that the guest is reset. | 679 // and that the guest is reset. |
681 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { | 680 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { |
682 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 681 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
683 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 682 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
684 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 683 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
685 test_embedder()->web_contents()->GetRenderViewHost()); | 684 test_embedder()->web_contents()->GetRenderViewHost()); |
686 | 685 |
687 // Change the title of the page to 'modified' so that we know that | 686 // Change the title of the page to 'modified' so that we know that |
688 // the page has successfully reloaded when it goes back to 'embedder' | 687 // the page has successfully reloaded when it goes back to 'embedder' |
689 // in the next step. | 688 // in the next step. |
690 { | 689 { |
691 const string16 expected_title = ASCIIToUTF16("modified"); | 690 const string16 expected_title = ASCIIToUTF16("modified"); |
692 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 691 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
693 expected_title); | 692 expected_title); |
694 | 693 |
695 ExecuteSyncJSFunction(rvh, StringPrintf("SetTitle('%s');", "modified")); | 694 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetTitle('%s');", |
| 695 "modified"))); |
696 | 696 |
697 string16 actual_title = title_watcher.WaitAndGetTitle(); | 697 string16 actual_title = title_watcher.WaitAndGetTitle(); |
698 EXPECT_EQ(expected_title, actual_title); | 698 EXPECT_EQ(expected_title, actual_title); |
699 } | 699 } |
700 | 700 |
701 // Reload the embedder page, and verify that the reload was successful. | 701 // Reload the embedder page, and verify that the reload was successful. |
702 // Then navigate the guest to verify that the browser process does not crash. | 702 // Then navigate the guest to verify that the browser process does not crash. |
703 { | 703 { |
704 const string16 expected_title = ASCIIToUTF16("embedder"); | 704 const string16 expected_title = ASCIIToUTF16("embedder"); |
705 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 705 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
706 expected_title); | 706 expected_title); |
707 | 707 |
708 test_embedder()->web_contents()->GetController().Reload(false); | 708 test_embedder()->web_contents()->GetController().Reload(false); |
709 string16 actual_title = title_watcher.WaitAndGetTitle(); | 709 string16 actual_title = title_watcher.WaitAndGetTitle(); |
710 EXPECT_EQ(expected_title, actual_title); | 710 EXPECT_EQ(expected_title, actual_title); |
711 | 711 |
712 ExecuteSyncJSFunction( | 712 ExecuteSyncJSFunction(test_embedder()->web_contents()->GetRenderViewHost(), |
713 test_embedder()->web_contents()->GetRenderViewHost(), | 713 ASCIIToUTF16(StringPrintf("SetSrc('%s');", kHTMLForGuest))); |
714 StringPrintf("SetSrc('%s');", kHTMLForGuest)); | |
715 | 714 |
716 const BrowserPluginEmbedder::ContainerInstanceMap& instance_map = | 715 const BrowserPluginEmbedder::ContainerInstanceMap& instance_map = |
717 test_embedder()->guest_web_contents_for_testing(); | 716 test_embedder()->guest_web_contents_for_testing(); |
718 WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>( | 717 WebContentsImpl* test_guest_web_contents = static_cast<WebContentsImpl*>( |
719 instance_map.begin()->second); | 718 instance_map.begin()->second); |
720 TestBrowserPluginGuest* new_test_guest = | 719 TestBrowserPluginGuest* new_test_guest = |
721 static_cast<TestBrowserPluginGuest*>( | 720 static_cast<TestBrowserPluginGuest*>( |
722 test_guest_web_contents->GetBrowserPluginGuest()); | 721 test_guest_web_contents->GetBrowserPluginGuest()); |
723 | 722 |
724 // Wait for the guest to send an UpdateRectMsg, meaning it is ready. | 723 // Wait for the guest to send an UpdateRectMsg, meaning it is ready. |
725 new_test_guest->WaitForUpdateRectMsg(); | 724 new_test_guest->WaitForUpdateRectMsg(); |
726 } | 725 } |
727 } | 726 } |
728 | 727 |
729 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, TerminateGuest) { | 728 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, TerminateGuest) { |
730 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 729 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
731 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 730 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
732 | 731 |
733 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 732 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
734 test_embedder()->web_contents()->GetRenderViewHost()); | 733 test_embedder()->web_contents()->GetRenderViewHost()); |
735 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate()"); | 734 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 735 "document.getElementById('plugin').terminate()")); |
736 | 736 |
737 // Expect the guest to crash. | 737 // Expect the guest to crash. |
738 test_guest()->WaitForExit(); | 738 test_guest()->WaitForExit(); |
739 } | 739 } |
740 | 740 |
741 // This test verifies that the guest is responsive after crashing and going back | 741 // This test verifies that the guest is responsive after crashing and going back |
742 // to a previous navigation entry. | 742 // to a previous navigation entry. |
743 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BackAfterTerminateGuest) { | 743 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, BackAfterTerminateGuest) { |
744 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 744 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
745 StartBrowserPluginTest( | 745 StartBrowserPluginTest( |
746 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); | 746 kEmbedderURL, GetHTMLForGuestWithTitle("P1"), true, ""); |
747 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 747 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
748 test_embedder()->web_contents()->GetRenderViewHost()); | 748 test_embedder()->web_contents()->GetRenderViewHost()); |
749 | 749 |
750 // Navigate to P2 and verify that the navigation occurred. | 750 // Navigate to P2 and verify that the navigation occurred. |
751 { | 751 { |
752 const string16 expected_title = ASCIIToUTF16("P2"); | 752 const string16 expected_title = ASCIIToUTF16("P2"); |
753 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 753 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
754 expected_title); | 754 expected_title); |
755 | 755 |
756 ExecuteSyncJSFunction( | 756 ExecuteSyncJSFunction(rvh, ASCIIToUTF16(StringPrintf("SetSrc('%s');", |
757 rvh, | 757 GetHTMLForGuestWithTitle("P2").c_str()))); |
758 StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P2").c_str())); | |
759 | 758 |
760 string16 actual_title = title_watcher.WaitAndGetTitle(); | 759 string16 actual_title = title_watcher.WaitAndGetTitle(); |
761 EXPECT_EQ(expected_title, actual_title); | 760 EXPECT_EQ(expected_title, actual_title); |
762 } | 761 } |
763 // Kill the guest. | 762 // Kill the guest. |
764 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate()"); | 763 ExecuteSyncJSFunction(rvh, |
| 764 ASCIIToUTF16("document.getElementById('plugin').terminate()")); |
765 | 765 |
766 // Expect the guest to report that it crashed. | 766 // Expect the guest to report that it crashed. |
767 test_guest()->WaitForExit(); | 767 test_guest()->WaitForExit(); |
768 // Go back and verify that we're back at P1. | 768 // Go back and verify that we're back at P1. |
769 { | 769 { |
770 const string16 expected_title = ASCIIToUTF16("P1"); | 770 const string16 expected_title = ASCIIToUTF16("P1"); |
771 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 771 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
772 expected_title); | 772 expected_title); |
773 | 773 |
774 ExecuteSyncJSFunction(rvh, "Back();"); | 774 ExecuteSyncJSFunction(rvh, ASCIIToUTF16("Back();")); |
775 | 775 |
776 string16 actual_title = title_watcher.WaitAndGetTitle(); | 776 string16 actual_title = title_watcher.WaitAndGetTitle(); |
777 EXPECT_EQ(expected_title, actual_title); | 777 EXPECT_EQ(expected_title, actual_title); |
778 } | 778 } |
779 // Send an input event and verify that the guest receives the input. | 779 // Send an input event and verify that the guest receives the input. |
780 SimulateMouseClick(test_embedder()->web_contents(), 0, | 780 SimulateMouseClick(test_embedder()->web_contents(), 0, |
781 WebKit::WebMouseEvent::ButtonLeft); | 781 WebKit::WebMouseEvent::ButtonLeft); |
782 test_guest()->WaitForInput(); | 782 test_guest()->WaitForInput(); |
783 } | 783 } |
784 | 784 |
785 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStart) { | 785 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStart) { |
786 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 786 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
787 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 787 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
788 | 788 |
789 const string16 expected_title = ASCIIToUTF16(kHTMLForGuest); | 789 const string16 expected_title = ASCIIToUTF16(kHTMLForGuest); |
790 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 790 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
791 expected_title); | 791 expected_title); |
792 // Renavigate the guest to |kHTMLForGuest|. | 792 // Renavigate the guest to |kHTMLForGuest|. |
793 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 793 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
794 test_embedder()->web_contents()->GetRenderViewHost()); | 794 test_embedder()->web_contents()->GetRenderViewHost()); |
795 ExecuteSyncJSFunction(rvh, StringPrintf("SetSrc('%s');", kHTMLForGuest)); | 795 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 796 StringPrintf("SetSrc('%s');", kHTMLForGuest))); |
796 | 797 |
797 string16 actual_title = title_watcher.WaitAndGetTitle(); | 798 string16 actual_title = title_watcher.WaitAndGetTitle(); |
798 EXPECT_EQ(expected_title, actual_title); | 799 EXPECT_EQ(expected_title, actual_title); |
799 } | 800 } |
800 | 801 |
801 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadAbort) { | 802 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadAbort) { |
802 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 803 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
803 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 804 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
804 | 805 |
805 { | 806 { |
806 // Navigate the guest to "close-socket". | 807 // Navigate the guest to "close-socket". |
807 const string16 expected_title = ASCIIToUTF16("ERR_EMPTY_RESPONSE"); | 808 const string16 expected_title = ASCIIToUTF16("ERR_EMPTY_RESPONSE"); |
808 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 809 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
809 expected_title); | 810 expected_title); |
810 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 811 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
811 test_embedder()->web_contents()->GetRenderViewHost()); | 812 test_embedder()->web_contents()->GetRenderViewHost()); |
812 GURL test_url = test_server()->GetURL("close-socket"); | 813 GURL test_url = test_server()->GetURL("close-socket"); |
813 ExecuteSyncJSFunction( | 814 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
814 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 815 StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); |
815 string16 actual_title = title_watcher.WaitAndGetTitle(); | 816 string16 actual_title = title_watcher.WaitAndGetTitle(); |
816 EXPECT_EQ(expected_title, actual_title); | 817 EXPECT_EQ(expected_title, actual_title); |
817 } | 818 } |
818 | 819 |
819 { | 820 { |
820 // Navigate the guest to an illegal chrome:// URL. | 821 // Navigate the guest to an illegal chrome:// URL. |
821 const string16 expected_title = ASCIIToUTF16("ERR_FAILED"); | 822 const string16 expected_title = ASCIIToUTF16("ERR_FAILED"); |
822 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 823 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
823 expected_title); | 824 expected_title); |
824 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 825 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
825 test_embedder()->web_contents()->GetRenderViewHost()); | 826 test_embedder()->web_contents()->GetRenderViewHost()); |
826 GURL test_url("chrome://newtab"); | 827 GURL test_url("chrome://newtab"); |
827 ExecuteSyncJSFunction( | 828 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
828 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 829 StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); |
829 string16 actual_title = title_watcher.WaitAndGetTitle(); | 830 string16 actual_title = title_watcher.WaitAndGetTitle(); |
830 EXPECT_EQ(expected_title, actual_title); | 831 EXPECT_EQ(expected_title, actual_title); |
831 } | 832 } |
832 | 833 |
833 { | 834 { |
834 // Navigate the guest to an illegal file:// URL. | 835 // Navigate the guest to an illegal file:// URL. |
835 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED"); | 836 const string16 expected_title = ASCIIToUTF16("ERR_ABORTED"); |
836 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 837 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
837 expected_title); | 838 expected_title); |
838 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 839 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
839 test_embedder()->web_contents()->GetRenderViewHost()); | 840 test_embedder()->web_contents()->GetRenderViewHost()); |
840 GURL test_url("file://foo"); | 841 GURL test_url("file://foo"); |
841 ExecuteSyncJSFunction( | 842 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
842 rvh, StringPrintf("SetSrc('%s');", test_url.spec().c_str())); | 843 StringPrintf("SetSrc('%s');", test_url.spec().c_str()))); |
843 string16 actual_title = title_watcher.WaitAndGetTitle(); | 844 string16 actual_title = title_watcher.WaitAndGetTitle(); |
844 EXPECT_EQ(expected_title, actual_title); | 845 EXPECT_EQ(expected_title, actual_title); |
845 } | 846 } |
846 } | 847 } |
847 | 848 |
848 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) { | 849 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadRedirect) { |
849 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 850 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
850 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 851 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
851 | 852 |
852 const string16 expected_title = ASCIIToUTF16("redirected"); | 853 const string16 expected_title = ASCIIToUTF16("redirected"); |
853 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 854 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
854 expected_title); | 855 expected_title); |
855 | 856 |
856 // Navigate with a redirect and wait until the title changes. | 857 // Navigate with a redirect and wait until the title changes. |
857 GURL redirect_url(test_server()->GetURL( | 858 GURL redirect_url(test_server()->GetURL( |
858 "server-redirect?files/title1.html")); | 859 "server-redirect?files/title1.html")); |
859 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 860 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
860 test_embedder()->web_contents()->GetRenderViewHost()); | 861 test_embedder()->web_contents()->GetRenderViewHost()); |
861 ExecuteSyncJSFunction( | 862 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
862 rvh, StringPrintf("SetSrc('%s');", redirect_url.spec().c_str())); | 863 StringPrintf("SetSrc('%s');", redirect_url.spec().c_str()))); |
863 | 864 |
864 string16 actual_title = title_watcher.WaitAndGetTitle(); | 865 string16 actual_title = title_watcher.WaitAndGetTitle(); |
865 EXPECT_EQ(expected_title, actual_title); | 866 EXPECT_EQ(expected_title, actual_title); |
866 | 867 |
867 // Verify that we heard a loadRedirect during the navigation. | 868 // Verify that we heard a loadRedirect during the navigation. |
868 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( | 869 scoped_ptr<base::Value> value(rvh->ExecuteJavascriptAndGetValue( |
869 string16(), ASCIIToUTF16("redirectOldUrl"))); | 870 string16(), ASCIIToUTF16("redirectOldUrl"))); |
870 std::string result; | 871 std::string result; |
871 EXPECT_TRUE(value->GetAsString(&result)); | 872 EXPECT_TRUE(value->GetAsString(&result)); |
872 EXPECT_EQ(redirect_url.spec().c_str(), result); | 873 EXPECT_EQ(redirect_url.spec().c_str(), result); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); | 942 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); |
942 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 943 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
943 test_embedder()->web_contents()->GetRenderViewHost()); | 944 test_embedder()->web_contents()->GetRenderViewHost()); |
944 { | 945 { |
945 const string16 expected_title = ASCIIToUTF16("main guest"); | 946 const string16 expected_title = ASCIIToUTF16("main guest"); |
946 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 947 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
947 expected_title); | 948 expected_title); |
948 | 949 |
949 // By the time we get here 'contentWindow' should be ready because the | 950 // By the time we get here 'contentWindow' should be ready because the |
950 // guest has completed loading. | 951 // guest has completed loading. |
951 ExecuteSyncJSFunction( | 952 ExecuteSyncJSFunction(rvh, |
952 rvh, StringPrintf("PostMessage('%s, false');", kTesting)); | 953 ASCIIToUTF16(StringPrintf("PostMessage('%s, false');", kTesting))); |
953 | 954 |
954 // The title will be updated to "main guest" at the last stage of the | 955 // The title will be updated to "main guest" at the last stage of the |
955 // process described above. | 956 // process described above. |
956 string16 actual_title = title_watcher.WaitAndGetTitle(); | 957 string16 actual_title = title_watcher.WaitAndGetTitle(); |
957 EXPECT_EQ(expected_title, actual_title); | 958 EXPECT_EQ(expected_title, actual_title); |
958 } | 959 } |
959 } | 960 } |
960 | 961 |
961 // This is the same as BrowserPluginHostTest.PostMessage but also | 962 // This is the same as BrowserPluginHostTest.PostMessage but also |
962 // posts a message to an iframe. | 963 // posts a message to an iframe. |
963 // TODO(fsamuel): This test should replace the previous test once postMessage | 964 // TODO(fsamuel): This test should replace the previous test once postMessage |
964 // iframe targeting is fixed (see http://crbug.com/153701). | 965 // iframe targeting is fixed (see http://crbug.com/153701). |
965 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_PostMessageToIFrame) { | 966 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_PostMessageToIFrame) { |
966 const char* kTesting = "testing123"; | 967 const char* kTesting = "testing123"; |
967 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 968 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
968 const char* kGuestURL = "files/browser_plugin_post_message_guest.html"; | 969 const char* kGuestURL = "files/browser_plugin_post_message_guest.html"; |
969 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); | 970 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, ""); |
970 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 971 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
971 test_embedder()->web_contents()->GetRenderViewHost()); | 972 test_embedder()->web_contents()->GetRenderViewHost()); |
972 { | 973 { |
973 const string16 expected_title = ASCIIToUTF16("main guest"); | 974 const string16 expected_title = ASCIIToUTF16("main guest"); |
974 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 975 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
975 expected_title); | 976 expected_title); |
976 | 977 |
977 ExecuteSyncJSFunction( | 978 ExecuteSyncJSFunction(rvh, |
978 rvh, StringPrintf("PostMessage('%s, false');", kTesting)); | 979 ASCIIToUTF16(StringPrintf("PostMessage('%s, false');", kTesting))); |
979 | 980 |
980 // The title will be updated to "main guest" at the last stage of the | 981 // The title will be updated to "main guest" at the last stage of the |
981 // process described above. | 982 // process described above. |
982 string16 actual_title = title_watcher.WaitAndGetTitle(); | 983 string16 actual_title = title_watcher.WaitAndGetTitle(); |
983 EXPECT_EQ(expected_title, actual_title); | 984 EXPECT_EQ(expected_title, actual_title); |
984 } | 985 } |
985 { | 986 { |
986 content::TitleWatcher ready_watcher(test_embedder()->web_contents(), | 987 content::TitleWatcher ready_watcher(test_embedder()->web_contents(), |
987 ASCIIToUTF16("ready")); | 988 ASCIIToUTF16("ready")); |
988 | 989 |
989 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 990 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
990 test_guest()->web_contents()->GetRenderViewHost()); | 991 test_guest()->web_contents()->GetRenderViewHost()); |
991 GURL test_url = test_server()->GetURL( | 992 GURL test_url = test_server()->GetURL( |
992 "files/browser_plugin_post_message_guest.html"); | 993 "files/browser_plugin_post_message_guest.html"); |
993 ExecuteSyncJSFunction( | 994 ExecuteSyncJSFunction(guest_rvh, |
994 guest_rvh, | 995 ASCIIToUTF16(StringPrintf("CreateChildFrame('%s');", |
995 StringPrintf("CreateChildFrame('%s');", test_url.spec().c_str())); | 996 test_url.spec().c_str()))); |
996 | 997 |
997 string16 actual_title = ready_watcher.WaitAndGetTitle(); | 998 string16 actual_title = ready_watcher.WaitAndGetTitle(); |
998 EXPECT_EQ(ASCIIToUTF16("ready"), actual_title); | 999 EXPECT_EQ(ASCIIToUTF16("ready"), actual_title); |
999 | 1000 |
1000 content::TitleWatcher iframe_watcher(test_embedder()->web_contents(), | 1001 content::TitleWatcher iframe_watcher(test_embedder()->web_contents(), |
1001 ASCIIToUTF16("iframe")); | 1002 ASCIIToUTF16("iframe")); |
1002 ExecuteSyncJSFunction( | 1003 ExecuteSyncJSFunction(rvh, |
1003 rvh, StringPrintf("PostMessage('%s', true);", kTesting)); | 1004 ASCIIToUTF16(StringPrintf("PostMessage('%s', true);", kTesting))); |
1004 | 1005 |
1005 // The title will be updated to "iframe" at the last stage of the | 1006 // The title will be updated to "iframe" at the last stage of the |
1006 // process described above. | 1007 // process described above. |
1007 actual_title = iframe_watcher.WaitAndGetTitle(); | 1008 actual_title = iframe_watcher.WaitAndGetTitle(); |
1008 EXPECT_EQ(ASCIIToUTF16("iframe"), actual_title); | 1009 EXPECT_EQ(ASCIIToUTF16("iframe"), actual_title); |
1009 } | 1010 } |
1010 } | 1011 } |
1011 | 1012 |
1012 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStop) { | 1013 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadStop) { |
1013 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1014 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1014 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 1015 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
1015 | 1016 |
1016 const string16 expected_title = ASCIIToUTF16("loadStop"); | 1017 const string16 expected_title = ASCIIToUTF16("loadStop"); |
1017 content::TitleWatcher title_watcher( | 1018 content::TitleWatcher title_watcher( |
1018 test_embedder()->web_contents(), expected_title); | 1019 test_embedder()->web_contents(), expected_title); |
1019 // Renavigate the guest to |kHTMLForGuest|. | 1020 // Renavigate the guest to |kHTMLForGuest|. |
1020 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1021 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1021 test_embedder()->web_contents()->GetRenderViewHost()); | 1022 test_embedder()->web_contents()->GetRenderViewHost()); |
1022 ExecuteSyncJSFunction(rvh, StringPrintf("SetSrc('%s');", kHTMLForGuest)); | 1023 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 1024 StringPrintf("SetSrc('%s');", kHTMLForGuest))); |
1023 | 1025 |
1024 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1026 string16 actual_title = title_watcher.WaitAndGetTitle(); |
1025 EXPECT_EQ(expected_title, actual_title); | 1027 EXPECT_EQ(expected_title, actual_title); |
1026 } | 1028 } |
1027 | 1029 |
1028 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadCommit) { | 1030 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, LoadCommit) { |
1029 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1031 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1030 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); | 1032 StartBrowserPluginTest(kEmbedderURL, "about:blank", true, ""); |
1031 | 1033 |
1032 const string16 expected_title = ASCIIToUTF16( | 1034 const string16 expected_title = ASCIIToUTF16( |
1033 StringPrintf("loadCommit:%s", kHTMLForGuest)); | 1035 StringPrintf("loadCommit:%s", kHTMLForGuest)); |
1034 content::TitleWatcher title_watcher( | 1036 content::TitleWatcher title_watcher( |
1035 test_embedder()->web_contents(), expected_title); | 1037 test_embedder()->web_contents(), expected_title); |
1036 // Renavigate the guest to |kHTMLForGuest|. | 1038 // Renavigate the guest to |kHTMLForGuest|. |
1037 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1039 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1038 test_embedder()->web_contents()->GetRenderViewHost()); | 1040 test_embedder()->web_contents()->GetRenderViewHost()); |
1039 ExecuteSyncJSFunction(rvh, StringPrintf("SetSrc('%s');", kHTMLForGuest)); | 1041 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 1042 StringPrintf("SetSrc('%s');", kHTMLForGuest))); |
1040 | 1043 |
1041 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1044 string16 actual_title = title_watcher.WaitAndGetTitle(); |
1042 EXPECT_EQ(expected_title, actual_title); | 1045 EXPECT_EQ(expected_title, actual_title); |
1043 scoped_ptr<base::Value> is_top_level(rvh->ExecuteJavascriptAndGetValue( | 1046 scoped_ptr<base::Value> is_top_level(rvh->ExecuteJavascriptAndGetValue( |
1044 string16(), ASCIIToUTF16("commitIsTopLevel"))); | 1047 string16(), ASCIIToUTF16("commitIsTopLevel"))); |
1045 bool top_level_bool = false; | 1048 bool top_level_bool = false; |
1046 EXPECT_TRUE(is_top_level->GetAsBoolean(&top_level_bool)); | 1049 EXPECT_TRUE(is_top_level->GetAsBoolean(&top_level_bool)); |
1047 EXPECT_EQ(true, top_level_bool); | 1050 EXPECT_EQ(true, top_level_bool); |
1048 } | 1051 } |
1049 | 1052 |
(...skipping 12 matching lines...) Expand all Loading... |
1062 // the new guest will inherit the visibility state of the old guest. | 1065 // the new guest will inherit the visibility state of the old guest. |
1063 // | 1066 // |
1064 // Very flaky on Linux, Linux CrOS, somewhat flaky on XP, slightly on | 1067 // Very flaky on Linux, Linux CrOS, somewhat flaky on XP, slightly on |
1065 // Mac; http://crbug.com/162809. | 1068 // Mac; http://crbug.com/162809. |
1066 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_VisibilityPreservation) { | 1069 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, DISABLED_VisibilityPreservation) { |
1067 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1070 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1068 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 1071 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
1069 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1072 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1070 test_embedder()->web_contents()->GetRenderViewHost()); | 1073 test_embedder()->web_contents()->GetRenderViewHost()); |
1071 // Hide the BrowserPlugin. | 1074 // Hide the BrowserPlugin. |
1072 ExecuteSyncJSFunction( | 1075 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
1073 rvh, "document.getElementById('plugin').style.visibility = 'hidden';"); | 1076 "document.getElementById('plugin').style.visibility = 'hidden';")); |
1074 test_guest()->WaitUntilHidden(); | 1077 test_guest()->WaitUntilHidden(); |
1075 // Kill the current guest. | 1078 // Kill the current guest. |
1076 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate();"); | 1079 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 1080 "document.getElementById('plugin').terminate();")); |
1077 test_guest()->WaitForExit(); | 1081 test_guest()->WaitForExit(); |
1078 // Get a new guest. | 1082 // Get a new guest. |
1079 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload();"); | 1083 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 1084 "document.getElementById('plugin').reload();")); |
1080 test_guest()->WaitForLoadStop(); | 1085 test_guest()->WaitForLoadStop(); |
1081 // Verify that the guest is told to hide. | 1086 // Verify that the guest is told to hide. |
1082 test_guest()->WaitUntilHidden(); | 1087 test_guest()->WaitUntilHidden(); |
1083 } | 1088 } |
1084 | 1089 |
1085 // This test verifies that if a browser plugin is focused before navigation then | 1090 // This test verifies that if a browser plugin is focused before navigation then |
1086 // the guest starts off focused. | 1091 // the guest starts off focused. |
1087 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusBeforeNavigation) { | 1092 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusBeforeNavigation) { |
1088 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1093 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1089 const std::string embedder_code = | 1094 const std::string embedder_code = |
(...skipping 16 matching lines...) Expand all Loading... |
1106 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusPreservation) { | 1111 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusPreservation) { |
1107 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1112 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1108 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 1113 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
1109 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1114 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1110 test_embedder()->web_contents()->GetRenderViewHost()); | 1115 test_embedder()->web_contents()->GetRenderViewHost()); |
1111 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 1116 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
1112 test_guest()->web_contents()->GetRenderViewHost()); | 1117 test_guest()->web_contents()->GetRenderViewHost()); |
1113 { | 1118 { |
1114 // Focus the BrowserPlugin. This will have the effect of also focusing the | 1119 // Focus the BrowserPlugin. This will have the effect of also focusing the |
1115 // current guest. | 1120 // current guest. |
1116 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();"); | 1121 ExecuteSyncJSFunction( |
| 1122 rvh, ASCIIToUTF16("document.getElementById('plugin').focus();")); |
1117 // Verify that key presses go to the guest. | 1123 // Verify that key presses go to the guest. |
1118 SimulateSpaceKeyPress(test_embedder()->web_contents()); | 1124 SimulateSpaceKeyPress(test_embedder()->web_contents()); |
1119 test_guest()->WaitForInput(); | 1125 test_guest()->WaitForInput(); |
1120 // Verify that the guest is focused. | 1126 // Verify that the guest is focused. |
1121 scoped_ptr<base::Value> value( | 1127 scoped_ptr<base::Value> value( |
1122 guest_rvh->ExecuteJavascriptAndGetValue(string16(), | 1128 guest_rvh->ExecuteJavascriptAndGetValue(string16(), |
1123 ASCIIToUTF16("document.hasFocus()"))); | 1129 ASCIIToUTF16("document.hasFocus()"))); |
1124 bool result = false; | 1130 bool result = false; |
1125 ASSERT_TRUE(value->GetAsBoolean(&result)); | 1131 ASSERT_TRUE(value->GetAsBoolean(&result)); |
1126 EXPECT_TRUE(result); | 1132 EXPECT_TRUE(result); |
1127 } | 1133 } |
1128 | 1134 |
1129 // Kill the current guest. | 1135 // Kill the current guest. |
1130 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').terminate();"); | 1136 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 1137 "document.getElementById('plugin').terminate();")); |
1131 test_guest()->WaitForExit(); | 1138 test_guest()->WaitForExit(); |
1132 | 1139 |
1133 { | 1140 { |
1134 // Get a new guest. | 1141 // Get a new guest. |
1135 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').reload();"); | 1142 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
| 1143 "document.getElementById('plugin').reload();")); |
1136 test_guest()->WaitForLoadStop(); | 1144 test_guest()->WaitForLoadStop(); |
1137 // Verify that the guest is focused. | 1145 // Verify that the guest is focused. |
1138 scoped_ptr<base::Value> value( | 1146 scoped_ptr<base::Value> value( |
1139 guest_rvh->ExecuteJavascriptAndGetValue(string16(), | 1147 guest_rvh->ExecuteJavascriptAndGetValue(string16(), |
1140 ASCIIToUTF16("document.hasFocus()"))); | 1148 ASCIIToUTF16("document.hasFocus()"))); |
1141 bool result = false; | 1149 bool result = false; |
1142 ASSERT_TRUE(value->GetAsBoolean(&result)); | 1150 ASSERT_TRUE(value->GetAsBoolean(&result)); |
1143 EXPECT_TRUE(result); | 1151 EXPECT_TRUE(result); |
1144 } | 1152 } |
1145 } | 1153 } |
1146 | 1154 |
1147 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) { | 1155 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) { |
1148 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1156 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1149 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); | 1157 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, ""); |
1150 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1158 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1151 test_embedder()->web_contents()->GetRenderViewHost()); | 1159 test_embedder()->web_contents()->GetRenderViewHost()); |
1152 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 1160 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
1153 test_guest()->web_contents()->GetRenderViewHost()); | 1161 test_guest()->web_contents()->GetRenderViewHost()); |
1154 { | 1162 { |
1155 // Focus the BrowserPlugin. This will have the effect of also focusing the | 1163 // Focus the BrowserPlugin. This will have the effect of also focusing the |
1156 // current guest. | 1164 // current guest. |
1157 ExecuteSyncJSFunction(rvh, "document.getElementById('plugin').focus();"); | 1165 ExecuteSyncJSFunction( |
| 1166 rvh, ASCIIToUTF16("document.getElementById('plugin').focus();")); |
1158 // Verify that key presses go to the guest. | 1167 // Verify that key presses go to the guest. |
1159 SimulateSpaceKeyPress(test_embedder()->web_contents()); | 1168 SimulateSpaceKeyPress(test_embedder()->web_contents()); |
1160 test_guest()->WaitForInput(); | 1169 test_guest()->WaitForInput(); |
1161 // Verify that the guest is focused. | 1170 // Verify that the guest is focused. |
1162 scoped_ptr<base::Value> value( | 1171 scoped_ptr<base::Value> value( |
1163 guest_rvh->ExecuteJavascriptAndGetValue(string16(), | 1172 guest_rvh->ExecuteJavascriptAndGetValue(string16(), |
1164 ASCIIToUTF16("document.hasFocus()"))); | 1173 ASCIIToUTF16("document.hasFocus()"))); |
1165 bool result = false; | 1174 bool result = false; |
1166 ASSERT_TRUE(value->GetAsBoolean(&result)); | 1175 ASSERT_TRUE(value->GetAsBoolean(&result)); |
1167 EXPECT_TRUE(result); | 1176 EXPECT_TRUE(result); |
(...skipping 25 matching lines...) Expand all Loading... |
1193 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | 1202 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; |
1194 StartBrowserPluginTest( | 1203 StartBrowserPluginTest( |
1195 kEmbedderURL, kHTMLForGuestWithSize, true, ""); | 1204 kEmbedderURL, kHTMLForGuestWithSize, true, ""); |
1196 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 1205 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
1197 test_embedder()->web_contents()->GetRenderViewHost()); | 1206 test_embedder()->web_contents()->GetRenderViewHost()); |
1198 | 1207 |
1199 { | 1208 { |
1200 const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)"); | 1209 const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)"); |
1201 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1210 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
1202 expected_title); | 1211 expected_title); |
1203 ExecuteSyncJSFunction( | 1212 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
1204 rvh, | |
1205 "document.getElementById('plugin').minWidth = 300;" | 1213 "document.getElementById('plugin').minWidth = 300;" |
1206 "document.getElementById('plugin').minHeight = 200;" | 1214 "document.getElementById('plugin').minHeight = 200;" |
1207 "document.getElementById('plugin').maxWidth = 600;" | 1215 "document.getElementById('plugin').maxWidth = 600;" |
1208 "document.getElementById('plugin').maxHeight = 400;" | 1216 "document.getElementById('plugin').maxHeight = 400;" |
1209 "document.getElementById('plugin').autoSize = true;"); | 1217 "document.getElementById('plugin').autoSize = true;")); |
1210 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1218 string16 actual_title = title_watcher.WaitAndGetTitle(); |
1211 EXPECT_EQ(expected_title, actual_title); | 1219 EXPECT_EQ(expected_title, actual_title); |
1212 } | 1220 } |
1213 { | 1221 { |
1214 // Change the minWidth and verify that it causes relayout. | 1222 // Change the minWidth and verify that it causes relayout. |
1215 const string16 expected_title = ASCIIToUTF16("AutoSize(350, 400)"); | 1223 const string16 expected_title = ASCIIToUTF16("AutoSize(350, 400)"); |
1216 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | 1224 content::TitleWatcher title_watcher(test_embedder()->web_contents(), |
1217 expected_title); | 1225 expected_title); |
1218 ExecuteSyncJSFunction( | 1226 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
1219 rvh, "document.getElementById('plugin').minWidth = 350;"); | 1227 "document.getElementById('plugin').minWidth = 350;")); |
1220 string16 actual_title = title_watcher.WaitAndGetTitle(); | 1228 string16 actual_title = title_watcher.WaitAndGetTitle(); |
1221 EXPECT_EQ(expected_title, actual_title); | 1229 EXPECT_EQ(expected_title, actual_title); |
1222 } | 1230 } |
1223 { | 1231 { |
1224 // Turn off autoSize and verify that the guest resizes to fit the container. | 1232 // Turn off autoSize and verify that the guest resizes to fit the container. |
1225 ExecuteSyncJSFunction( | 1233 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( |
1226 rvh, "document.getElementById('plugin').autoSize = false;"); | 1234 "document.getElementById('plugin').autoSize = false;")); |
1227 test_guest()->WaitForViewSize(gfx::Size(640, 480)); | 1235 test_guest()->WaitForViewSize(gfx::Size(640, 480)); |
1228 } | 1236 } |
1229 } | 1237 } |
1230 | 1238 |
1231 // Test for regression http://crbug.com/162961. | 1239 // Test for regression http://crbug.com/162961. |
1232 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, GetRenderViewHostAtPositionTest) { | 1240 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, GetRenderViewHostAtPositionTest) { |
1233 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; | 1241 const char kEmbedderURL[] = "files/browser_plugin_embedder.html"; |
1234 const std::string embedder_code = StringPrintf("SetSize(%d, %d);", 100, 100); | 1242 const std::string embedder_code = StringPrintf("SetSize(%d, %d);", 100, 100); |
1235 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestWithSize, true, | 1243 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuestWithSize, true, |
1236 embedder_code); | 1244 embedder_code); |
1237 // Check for render view host at position (150, 150) that is outside the | 1245 // Check for render view host at position (150, 150) that is outside the |
1238 // bounds of our guest, so this would respond with the render view host of the | 1246 // bounds of our guest, so this would respond with the render view host of the |
1239 // embedder. | 1247 // embedder. |
1240 test_embedder()->WaitForRenderViewHostAtPosition(150, 150); | 1248 test_embedder()->WaitForRenderViewHostAtPosition(150, 150); |
1241 ASSERT_EQ(test_embedder()->web_contents()->GetRenderViewHost(), | 1249 ASSERT_EQ(test_embedder()->web_contents()->GetRenderViewHost(), |
1242 test_embedder()->last_rvh_at_position_response()); | 1250 test_embedder()->last_rvh_at_position_response()); |
1243 } | 1251 } |
1244 | 1252 |
1245 } // namespace content | 1253 } // namespace content |
OLD | NEW |