OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 476 matching lines...) Loading... |
487 const char kEmbedderURL[] = "/browser_plugin_embedder.html"; | 487 const char kEmbedderURL[] = "/browser_plugin_embedder.html"; |
488 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); | 488 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
489 | 489 |
490 // Hide the embedder. | 490 // Hide the embedder. |
491 test_embedder()->web_contents()->WasHidden(); | 491 test_embedder()->web_contents()->WasHidden(); |
492 | 492 |
493 // Make sure that hiding the embedder also hides the guest. | 493 // Make sure that hiding the embedder also hides the guest. |
494 test_guest()->WaitUntilHidden(); | 494 test_guest()->WaitUntilHidden(); |
495 } | 495 } |
496 | 496 |
| 497 // Verifies that setting the src attribute prior to DOM attachment works, i.e. |
| 498 // that the BrowserPlugin is created without having a renderer. |
| 499 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PluginCreatedWithoutRenderer) { |
| 500 const char kEmbedderURL[] = "/browser_plugin_embedder_late_attach.html"; |
| 501 const char kGuestTitle[] = "late attach"; |
| 502 StartBrowserPluginTest( |
| 503 kEmbedderURL, GetHTMLForGuestWithTitle(kGuestTitle), true, std::string()); |
| 504 |
| 505 // Attach the browser plugin to the dom. We don't pass this to |
| 506 // StartBrowserPluginTest since we want it to execute after the src parameter |
| 507 // is set. |
| 508 ExecuteSyncJSFunction(shell()->web_contents()->GetRenderViewHost(), |
| 509 "attachPlugin();"); |
| 510 |
| 511 // Verify attachment with src attribute intact. |
| 512 EXPECT_FALSE( |
| 513 IsAttributeNull(shell()->web_contents()->GetRenderViewHost(), "src")); |
| 514 |
| 515 // Verify page loaded properly by checking title. |
| 516 const string16 expected_title = ASCIIToUTF16(kGuestTitle); |
| 517 EXPECT_EQ(expected_title, test_guest()->web_contents()->GetTitle()); |
| 518 } |
| 519 |
| 520 // Verifies that browser-plugin state survives setting "display = none", i.e. |
| 521 // that the BrowserPlugin object is persisted. |
| 522 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, PluginPersists) { |
| 523 const char kEmbedderURL[] = "/browser_plugin_embedder.html"; |
| 524 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); |
| 525 |
| 526 const char kGuestTitle[] = "persisted"; |
| 527 const char kGuestTitleModified[] = "still persisted"; |
| 528 |
| 529 // Verify title is seen. |
| 530 const string16 expected_title = ASCIIToUTF16(kGuestTitle); |
| 531 { |
| 532 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
| 533 expected_title); |
| 534 ExecuteSyncJSFunction( |
| 535 test_embedder()->web_contents()->GetRenderViewHost(), |
| 536 base::StringPrintf("SetSrc('%s');", |
| 537 GetHTMLForGuestWithTitle(kGuestTitle).c_str())); |
| 538 string16 actual_title = title_watcher.WaitAndGetTitle(); |
| 539 EXPECT_EQ(expected_title, actual_title); |
| 540 } |
| 541 |
| 542 // Set display none, verify title not seen. |
| 543 ExecuteSyncJSFunction( |
| 544 shell()->web_contents()->GetRenderViewHost(), |
| 545 "document.getElementById('plugin').style.display = 'none'"); |
| 546 |
| 547 ExecuteSyncJSFunction( |
| 548 test_guest()->web_contents()->GetRenderViewHost(), |
| 549 base::StringPrintf("document.title = '%s'", kGuestTitleModified)); |
| 550 |
| 551 // Clear display none. |
| 552 ExecuteSyncJSFunction( |
| 553 shell()->web_contents()->GetRenderViewHost(), |
| 554 "document.getElementById('plugin').style.display = 'block'"); |
| 555 |
| 556 // The guest title should have survived the display:none. |
| 557 const string16 expected_title_modified = ASCIIToUTF16(kGuestTitleModified); |
| 558 EXPECT_EQ(test_guest()->web_contents()->GetTitle(), expected_title_modified); |
| 559 } |
| 560 |
497 // Verifies that installing/uninstalling touch-event handlers in the guest | 561 // Verifies that installing/uninstalling touch-event handlers in the guest |
498 // plugin correctly updates the touch-event handling state in the embedder. | 562 // plugin correctly updates the touch-event handling state in the embedder. |
499 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { | 563 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AcceptTouchEvents) { |
500 const char kEmbedderURL[] = "/browser_plugin_embedder.html"; | 564 const char kEmbedderURL[] = "/browser_plugin_embedder.html"; |
501 StartBrowserPluginTest( | 565 StartBrowserPluginTest( |
502 kEmbedderURL, kHTMLForGuestTouchHandler, true, std::string()); | 566 kEmbedderURL, kHTMLForGuestTouchHandler, true, std::string()); |
503 | 567 |
504 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 568 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( |
505 test_embedder()->web_contents()->GetRenderViewHost()); | 569 test_embedder()->web_contents()->GetRenderViewHost()); |
506 // The embedder should not have any touch event handlers at this point. | 570 // The embedder should not have any touch event handlers at this point. |
(...skipping 297 matching lines...) Loading... |
804 // Attempt a navigation to chrome-guest://abc123, which is a valid URL. But it | 868 // Attempt a navigation to chrome-guest://abc123, which is a valid URL. But it |
805 // should be blocked because the scheme isn't web-safe or a pseudo-scheme. | 869 // should be blocked because the scheme isn't web-safe or a pseudo-scheme. |
806 ExecuteSyncJSFunction( | 870 ExecuteSyncJSFunction( |
807 test_embedder()->web_contents()->GetRenderViewHost(), | 871 test_embedder()->web_contents()->GetRenderViewHost(), |
808 base::StringPrintf("SetSrc('%s://abc123');", kGuestScheme)); | 872 base::StringPrintf("SetSrc('%s://abc123');", kGuestScheme)); |
809 EXPECT_TRUE(delegate->load_aborted()); | 873 EXPECT_TRUE(delegate->load_aborted()); |
810 EXPECT_TRUE(delegate->load_aborted_url().is_valid()); | 874 EXPECT_TRUE(delegate->load_aborted_url().is_valid()); |
811 } | 875 } |
812 | 876 |
813 } // namespace content | 877 } // namespace content |
OLD | NEW |