| 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // subsequent navigations work. See http://crbug/com/343265. | 616 // subsequent navigations work. See http://crbug/com/343265. |
| 617 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) { | 617 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsDialogs) { |
| 618 ASSERT_TRUE(embedded_test_server()->Start()); | 618 ASSERT_TRUE(embedded_test_server()->Start()); |
| 619 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 619 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 620 GURL beforeunload_url(embedded_test_server()->GetURL("/beforeunload.html")); | 620 GURL beforeunload_url(embedded_test_server()->GetURL("/beforeunload.html")); |
| 621 ui_test_utils::NavigateToURL(browser(), beforeunload_url); | 621 ui_test_utils::NavigateToURL(browser(), beforeunload_url); |
| 622 | 622 |
| 623 // Start a navigation to trigger the beforeunload dialog. | 623 // Start a navigation to trigger the beforeunload dialog. |
| 624 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 624 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 625 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 625 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 626 ASCIIToUTF16("window.location.href = 'data:text/html,foo'")); | 626 ASCIIToUTF16("window.location.href = 'about:blank'")); |
| 627 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 627 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 628 EXPECT_TRUE(alert->IsValid()); | 628 EXPECT_TRUE(alert->IsValid()); |
| 629 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 629 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 630 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 630 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 631 | 631 |
| 632 // Crash the renderer process and ensure the dialog is gone. | 632 // Crash the renderer process and ensure the dialog is gone. |
| 633 content::RenderProcessHost* child_process = contents->GetRenderProcessHost(); | 633 content::RenderProcessHost* child_process = contents->GetRenderProcessHost(); |
| 634 content::RenderProcessHostWatcher crash_observer( | 634 content::RenderProcessHostWatcher crash_observer( |
| 635 child_process, | 635 child_process, |
| 636 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 636 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 637 child_process->Shutdown(0, false); | 637 child_process->Shutdown(0, false); |
| 638 crash_observer.Wait(); | 638 crash_observer.Wait(); |
| 639 EXPECT_FALSE(dialog_queue->HasActiveDialog()); | 639 EXPECT_FALSE(dialog_queue->HasActiveDialog()); |
| 640 | 640 |
| 641 // Make sure subsequent navigations work. | 641 // Make sure subsequent navigations work. |
| 642 GURL url2("http://www.example.com/empty.html"); | 642 GURL url2("http://www.example.com/empty.html"); |
| 643 ui_test_utils::NavigateToURL(browser(), url2); | 643 ui_test_utils::NavigateToURL(browser(), url2); |
| 644 } | 644 } |
| 645 | 645 |
| 646 // Make sure that dialogs opened by subframes are closed when the process dies. | 646 // Make sure that dialogs opened by subframes are closed when the process dies. |
| 647 // See http://crbug.com/366510. | 647 // See http://crbug.com/366510. |
| 648 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsSubframeDialogs) { | 648 IN_PROC_BROWSER_TEST_F(BrowserTest, SadTabCancelsSubframeDialogs) { |
| 649 // Navigate to an iframe that opens an alert dialog. | |
| 650 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 649 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 650 ui_test_utils::NavigateToURL( |
| 651 browser(), GURL("data:text/html, <html><body></body></html>")); |
| 652 |
| 653 // Create an iframe that opens an alert dialog. |
| 651 contents->GetMainFrame()->ExecuteJavaScriptForTests( | 654 contents->GetMainFrame()->ExecuteJavaScriptForTests( |
| 652 ASCIIToUTF16("window.location.href = 'data:text/html," | 655 ASCIIToUTF16("f = document.createElement('iframe');" |
| 653 "<iframe srcdoc=\"<script>alert(1)</script>\">'")); | 656 "f.srcdoc = '<script>alert(1)</script>';" |
| 657 "document.body.appendChild(f);")); |
| 654 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); | 658 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 655 EXPECT_TRUE(alert->IsValid()); | 659 EXPECT_TRUE(alert->IsValid()); |
| 656 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); | 660 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 657 EXPECT_TRUE(dialog_queue->HasActiveDialog()); | 661 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 658 | 662 |
| 659 // Crash the renderer process and ensure the dialog is gone. | 663 // Crash the renderer process and ensure the dialog is gone. |
| 660 content::RenderProcessHost* child_process = contents->GetRenderProcessHost(); | 664 content::RenderProcessHost* child_process = contents->GetRenderProcessHost(); |
| 661 content::RenderProcessHostWatcher crash_observer( | 665 content::RenderProcessHostWatcher crash_observer( |
| 662 child_process, | 666 child_process, |
| 663 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 667 content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| (...skipping 2327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2991 Browser* browser = new Browser(params); | 2995 Browser* browser = new Browser(params); |
| 2992 gfx::Rect bounds = browser->window()->GetBounds(); | 2996 gfx::Rect bounds = browser->window()->GetBounds(); |
| 2993 | 2997 |
| 2994 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 2998 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
| 2995 // See https://crbug.com/567925. | 2999 // See https://crbug.com/567925. |
| 2996 EXPECT_GE(bounds.width(), 100); | 3000 EXPECT_GE(bounds.width(), 100); |
| 2997 EXPECT_EQ(122, bounds.height()); | 3001 EXPECT_EQ(122, bounds.height()); |
| 2998 browser->window()->Close(); | 3002 browser->window()->Close(); |
| 2999 } | 3003 } |
| 3000 } | 3004 } |
| OLD | NEW |