Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 "var w = window.open('about:blank');\n" | 510 "var w = window.open('about:blank');\n" |
| 511 "window.domAutomationController.send(!!w);\n", | 511 "window.domAutomationController.send(!!w);\n", |
| 512 &popup_handle_is_valid)); | 512 &popup_handle_is_valid)); |
| 513 popup_observer.Wait(); | 513 popup_observer.Wait(); |
| 514 | 514 |
| 515 // The popup shouldn't be blocked. | 515 // The popup shouldn't be blocked. |
| 516 EXPECT_TRUE(popup_handle_is_valid); | 516 EXPECT_TRUE(popup_handle_is_valid); |
| 517 ASSERT_EQ(2, browser()->tab_strip_model()->count()); | 517 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 518 } | 518 } |
| 519 | 519 |
| 520 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest, PrintOnUnloadHandler) { | |
|
alexmos
2017/05/23 18:01:19
nit: the name makes it sound like we're expecting
lfg
2017/05/23 18:38:52
Done.
| |
| 521 ui_test_utils::NavigateToURL( | |
| 522 browser(), GURL(embedded_test_server()->GetURL("a.com", "/title1.html"))); | |
| 523 | |
| 524 content::WebContents* active_web_contents = | |
| 525 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 526 | |
| 527 // Create 2 iframes and navigate them to b.com. | |
| 528 EXPECT_TRUE(ExecuteScript(active_web_contents, | |
| 529 "var i = document.createElement('iframe'); i.id = " | |
| 530 "'child-0'; document.body.appendChild(i);")); | |
| 531 EXPECT_TRUE(ExecuteScript(active_web_contents, | |
| 532 "var i = document.createElement('iframe'); i.id = " | |
| 533 "'child-1'; document.body.appendChild(i);")); | |
| 534 EXPECT_TRUE(NavigateIframeToURL( | |
| 535 active_web_contents, "child-0", | |
| 536 GURL(embedded_test_server()->GetURL("b.com", "/title1.html")))); | |
| 537 EXPECT_TRUE(NavigateIframeToURL( | |
| 538 active_web_contents, "child-1", | |
| 539 GURL(embedded_test_server()->GetURL("b.com", "/title1.html")))); | |
| 540 | |
| 541 content::RenderFrameHost* child_0 = | |
| 542 ChildFrameAt(active_web_contents->GetMainFrame(), 0); | |
| 543 content::RenderFrameHost* child_1 = | |
| 544 ChildFrameAt(active_web_contents->GetMainFrame(), 1); | |
| 545 | |
| 546 // Add an unload handler that calls print() to child-0 iframe. | |
| 547 EXPECT_TRUE(ExecuteScript( | |
| 548 child_0, "document.body.onunload = function() { print(); }")); | |
| 549 | |
| 550 // Transfer child-0 to a new process hosting c.com. | |
| 551 EXPECT_TRUE(NavigateIframeToURL( | |
| 552 active_web_contents, "child-0", | |
| 553 GURL(embedded_test_server()->GetURL("c.com", "/title1.html")))); | |
| 554 | |
| 555 // Check that b.com's process is still alive. | |
| 556 bool renderer_alive = false; | |
| 557 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 558 child_1, "window.domAutomationController.send(true);", &renderer_alive)); | |
| 559 EXPECT_TRUE(renderer_alive); | |
| 560 } | |
| 561 | |
| 520 #if BUILDFLAG(ENABLE_SPELLCHECK) | 562 #if BUILDFLAG(ENABLE_SPELLCHECK) |
| 521 // Class to sniff incoming IPCs for spell check messages. | 563 // Class to sniff incoming IPCs for spell check messages. |
| 522 class TestSpellCheckMessageFilter : public content::BrowserMessageFilter { | 564 class TestSpellCheckMessageFilter : public content::BrowserMessageFilter { |
| 523 public: | 565 public: |
| 524 explicit TestSpellCheckMessageFilter(content::RenderProcessHost* process_host) | 566 explicit TestSpellCheckMessageFilter(content::RenderProcessHost* process_host) |
| 525 : content::BrowserMessageFilter(SpellCheckMsgStart), | 567 : content::BrowserMessageFilter(SpellCheckMsgStart), |
| 526 process_host_(process_host), | 568 process_host_(process_host), |
| 527 text_received_(false), | 569 text_received_(false), |
| 528 message_loop_runner_(base::MakeShared<content::MessageLoopRunner>()) {} | 570 message_loop_runner_(base::MakeShared<content::MessageLoopRunner>()) {} |
| 529 | 571 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 623 scoped_refptr<TestSpellCheckMessageFilter> filter = | 665 scoped_refptr<TestSpellCheckMessageFilter> filter = |
| 624 browser_client.GetSpellCheckMessageFilterForProcess( | 666 browser_client.GetSpellCheckMessageFilterForProcess( |
| 625 subframe->GetProcess()); | 667 subframe->GetProcess()); |
| 626 filter->Wait(); | 668 filter->Wait(); |
| 627 | 669 |
| 628 EXPECT_EQ(base::ASCIIToUTF16("zz."), filter->last_text()); | 670 EXPECT_EQ(base::ASCIIToUTF16("zz."), filter->last_text()); |
| 629 | 671 |
| 630 content::SetBrowserClientForTesting(old_browser_client); | 672 content::SetBrowserClientForTesting(old_browser_client); |
| 631 } | 673 } |
| 632 #endif // BUILDFLAG(ENABLE_SPELLCHECK) | 674 #endif // BUILDFLAG(ENABLE_SPELLCHECK) |
| OLD | NEW |