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

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

Issue 46403006: Prevent a browser crash if dialogs are shown when navigating away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 } 464 }
465 465
466 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a 466 // Test for crbug.com/297289. Ensure that modal dialogs are closed when a
467 // cross-process navigation is ready to commit. 467 // cross-process navigation is ready to commit.
468 IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) { 468 IN_PROC_BROWSER_TEST_F(BrowserTest, CrossProcessNavCancelsDialogs) {
469 ASSERT_TRUE(test_server()->Start()); 469 ASSERT_TRUE(test_server()->Start());
470 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 470 host_resolver()->AddRule("www.example.com", "127.0.0.1");
471 GURL url(test_server()->GetURL("empty.html")); 471 GURL url(test_server()->GetURL("empty.html"));
472 ui_test_utils::NavigateToURL(browser(), url); 472 ui_test_utils::NavigateToURL(browser(), url);
473 473
474 // TODO(creis): Test this with a setInterval loop of alert dialogs to ensure
475 // that we can navigate away even if the renderer tries to synchronously
476 // create more. See http://crbug.com/312490.
474 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 477 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
475 contents->GetRenderViewHost()->ExecuteJavascriptInWebFrame( 478 contents->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
476 string16(), 479 string16(),
477 ASCIIToUTF16("alert('Dialog showing!');")); 480 ASCIIToUTF16("alert('Dialog showing!');"));
478 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); 481 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
479 EXPECT_TRUE(alert->IsValid()); 482 EXPECT_TRUE(alert->IsValid());
480 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); 483 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance();
481 EXPECT_TRUE(dialog_queue->HasActiveDialog()); 484 EXPECT_TRUE(dialog_queue->HasActiveDialog());
482 485
483 // A cross-site navigation should force the dialog to close. 486 // A cross-site navigation should force the dialog to close.
(...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 exp_commit_size.Enlarge(wcv_resize_insets.width(), 2505 exp_commit_size.Enlarge(wcv_resize_insets.width(),
2503 wcv_resize_insets.height() + height_inset); 2506 wcv_resize_insets.height() + height_inset);
2504 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2507 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2505 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2508 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2506 // Sizes of RenderWidgetHostView and WebContentsView before and after 2509 // Sizes of RenderWidgetHostView and WebContentsView before and after
2507 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. 2510 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same.
2508 EXPECT_EQ(rwhv_commit_size2, 2511 EXPECT_EQ(rwhv_commit_size2,
2509 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2512 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2510 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); 2513 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize());
2511 } 2514 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698