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

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 177123002: Clear any open dialogs when the renderer process goes away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('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 (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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 490
491 // A cross-site navigation should force the dialog to close. 491 // A cross-site navigation should force the dialog to close.
492 GURL url2("http://www.example.com/empty.html"); 492 GURL url2("http://www.example.com/empty.html");
493 ui_test_utils::NavigateToURL(browser(), url2); 493 ui_test_utils::NavigateToURL(browser(), url2);
494 EXPECT_FALSE(dialog_queue->HasActiveDialog()); 494 EXPECT_FALSE(dialog_queue->HasActiveDialog());
495 495
496 // Make sure input events still work in the renderer process. 496 // Make sure input events still work in the renderer process.
497 EXPECT_FALSE(contents->GetRenderProcessHost()->IgnoreInputEvents()); 497 EXPECT_FALSE(contents->GetRenderProcessHost()->IgnoreInputEvents());
498 } 498 }
499 499
500 // Make sure that dialogs are closed after a renderer process dies, and that
501 // subsequent navigations work. See http://crbug/com/343265.
502 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) {
503 ASSERT_TRUE(test_server()->Start());
504 host_resolver()->AddRule("www.example.com", "127.0.0.1");
505 GURL beforeunload_url(test_server()->GetURL("files/beforeunload.html"));
506 ui_test_utils::NavigateToURL(browser(), beforeunload_url);
507
508 // Start a navigation to trigger the beforeunload dialog.
509 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
510 contents->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
511 base::string16(),
512 ASCIIToUTF16("window.location.href = 'data:text/html,foo'"));
513 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
514 EXPECT_TRUE(alert->IsValid());
515 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance();
516 EXPECT_TRUE(dialog_queue->HasActiveDialog());
517
518 // Crash the renderer process and ensure the dialog is gone.
519 content::RenderProcessHost* child_process = contents->GetRenderProcessHost();
520 content::RenderProcessHostWatcher crash_observer(
521 child_process,
522 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
523 base::KillProcess(child_process->GetHandle(), 0, false);
524 crash_observer.Wait();
525 EXPECT_FALSE(dialog_queue->HasActiveDialog());
526
527 // Make sure subsequent navigations work.
528 GURL url2("http://www.example.com/files/empty.html");
529 ui_test_utils::NavigateToURL(browser(), url2);
530 }
531
500 // Test for crbug.com/22004. Reloading a page with a before unload handler and 532 // Test for crbug.com/22004. Reloading a page with a before unload handler and
501 // then canceling the dialog should not leave the throbber spinning. 533 // then canceling the dialog should not leave the throbber spinning.
502 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) { 534 IN_PROC_BROWSER_TEST_F(BrowserTest, ReloadThenCancelBeforeUnload) {
503 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML); 535 GURL url(std::string("data:text/html,") + kBeforeUnloadHTML);
504 ui_test_utils::NavigateToURL(browser(), url); 536 ui_test_utils::NavigateToURL(browser(), url);
505 537
506 // Navigate to another page, but click cancel in the dialog. Make sure that 538 // Navigate to another page, but click cancel in the dialog. Make sure that
507 // the throbber stops spinning. 539 // the throbber stops spinning.
508 chrome::Reload(browser(), CURRENT_TAB); 540 chrome::Reload(browser(), CURRENT_TAB);
509 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 541 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
(...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 exp_commit_size.Enlarge(wcv_resize_insets.width(), 2564 exp_commit_size.Enlarge(wcv_resize_insets.width(),
2533 wcv_resize_insets.height() + height_inset); 2565 wcv_resize_insets.height() + height_inset);
2534 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2566 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2535 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2567 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2536 // Sizes of RenderWidgetHostView and WebContentsView before and after 2568 // Sizes of RenderWidgetHostView and WebContentsView before and after
2537 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. 2569 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same.
2538 EXPECT_EQ(rwhv_commit_size2, 2570 EXPECT_EQ(rwhv_commit_size2,
2539 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2571 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2540 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); 2572 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize());
2541 } 2573 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698