Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Side by Side Diff: chrome/browser/chrome_site_per_process_browsertest.cc

Issue 2863203002: Ignore print() during page dismissal. (Closed)
Patch Set: rebase, addressing comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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, PrintIgnoredInUnloadHandler) {
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_( 570 message_loop_runner_(
529 base::MakeRefCounted<content::MessageLoopRunner>()) {} 571 base::MakeRefCounted<content::MessageLoopRunner>()) {}
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 scoped_refptr<TestSpellCheckMessageFilter> filter = 666 scoped_refptr<TestSpellCheckMessageFilter> filter =
625 browser_client.GetSpellCheckMessageFilterForProcess( 667 browser_client.GetSpellCheckMessageFilterForProcess(
626 subframe->GetProcess()); 668 subframe->GetProcess());
627 filter->Wait(); 669 filter->Wait();
628 670
629 EXPECT_EQ(base::ASCIIToUTF16("zz."), filter->last_text()); 671 EXPECT_EQ(base::ASCIIToUTF16("zz."), filter->last_text());
630 672
631 content::SetBrowserClientForTesting(old_browser_client); 673 content::SetBrowserClientForTesting(old_browser_client);
632 } 674 }
633 #endif // BUILDFLAG(ENABLE_SPELLCHECK) 675 #endif // BUILDFLAG(ENABLE_SPELLCHECK)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698