| OLD | NEW |
| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" | 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/browser_commands.h" | 7 #include "chrome/browser/ui/browser_commands.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // Ensure that we get there by checking for non-empty page content. | 33 // Ensure that we get there by checking for non-empty page content. |
| 34 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal:")); | 34 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal:")); |
| 35 bool empty_inner_html = false; | 35 bool empty_inner_html = false; |
| 36 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 36 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
| 37 browser()->tab_strip_model()->GetWebContentsAt(0), | 37 browser()->tab_strip_model()->GetWebContentsAt(0), |
| 38 "window.domAutomationController.send(document.body.innerHTML == '')", | 38 "window.domAutomationController.send(document.body.innerHTML == '')", |
| 39 &empty_inner_html)); | 39 &empty_inner_html)); |
| 40 ASSERT_FALSE(empty_inner_html); | 40 ASSERT_FALSE(empty_inner_html); |
| 41 } | 41 } |
| 42 | 42 |
| 43 #if defined(OS_WIN) | 43 // TODO(samarth): delete along with rest of NTP4 code. |
| 44 // Flaky on Windows (http://crbug.com/174819) | 44 // #if defined(OS_WIN) |
| 45 #define MAYBE_LoadNTPInExistingProcess DISABLED_LoadNTPInExistingProcess | 45 // // Flaky on Windows (http://crbug.com/174819) |
| 46 #else | 46 // #define MAYBE_LoadNTPInExistingProcess DISABLED_LoadNTPInExistingProcess |
| 47 #define MAYBE_LoadNTPInExistingProcess LoadNTPInExistingProcess | 47 // #else |
| 48 #endif | 48 // #define MAYBE_LoadNTPInExistingProcess LoadNTPInExistingProcess |
| 49 // #endif |
| 49 | 50 |
| 50 // Ensure loading a NTP with an existing SiteInstance in a reused process | 51 // Ensure loading a NTP with an existing SiteInstance in a reused process |
| 51 // doesn't cause us to kill the process. See http://crbug.com/104258. | 52 // doesn't cause us to kill the process. See http://crbug.com/104258. |
| 52 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, MAYBE_LoadNTPInExistingProcess) { | 53 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_LoadNTPInExistingProcess) { |
| 53 // Set max renderers to 1 to force running out of processes. | 54 // Set max renderers to 1 to force running out of processes. |
| 54 content::RenderProcessHost::SetMaxRendererProcessCount(1); | 55 content::RenderProcessHost::SetMaxRendererProcessCount(1); |
| 55 | 56 |
| 56 // Start server for simple page. | 57 // Start server for simple page. |
| 57 ASSERT_TRUE(test_server()->Start()); | 58 ASSERT_TRUE(test_server()->Start()); |
| 58 | 59 |
| 59 // Load a NTP in a new tab. | 60 // Load a NTP in a new tab. |
| 60 ui_test_utils::NavigateToURLWithDisposition( | 61 ui_test_utils::NavigateToURLWithDisposition( |
| 61 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, | 62 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, |
| 62 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 63 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 browser()->tab_strip_model()->GetWebContentsAt(3)->GetMaxPageID()); | 103 browser()->tab_strip_model()->GetWebContentsAt(3)->GetMaxPageID()); |
| 103 | 104 |
| 104 // Navigating to the NTP in the original tab causes a BrowsingInstance | 105 // Navigating to the NTP in the original tab causes a BrowsingInstance |
| 105 // swap, so it gets a new SiteInstance starting with page ID 1 again. | 106 // swap, so it gets a new SiteInstance starting with page ID 1 again. |
| 106 browser()->tab_strip_model()->ActivateTabAt(1, true); | 107 browser()->tab_strip_model()->ActivateTabAt(1, true); |
| 107 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 108 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 108 EXPECT_EQ(1, | 109 EXPECT_EQ(1, |
| 109 browser()->tab_strip_model()->GetWebContentsAt(1)->GetMaxPageID()); | 110 browser()->tab_strip_model()->GetWebContentsAt(1)->GetMaxPageID()); |
| 110 } | 111 } |
| 111 | 112 |
| 113 // TODO(samarth): delete along with rest of NTP4 code. |
| 112 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. | 114 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. |
| 113 // See http://crbug.com/59859. | 115 // See http://crbug.com/59859. |
| 114 // If this flakes, use http://crbug.com/87200. | 116 // If this flakes, use http://crbug.com/87200. |
| 115 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) { | 117 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, DISABLED_ChromeHangInNTP) { |
| 116 // Bring up a new tab page. | 118 // Bring up a new tab page. |
| 117 ui_test_utils::NavigateToURLWithDisposition( | 119 ui_test_utils::NavigateToURLWithDisposition( |
| 118 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, | 120 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, |
| 119 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 121 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 120 | 122 |
| 121 // Navigate to chrome://hang/ to stall the process. | 123 // Navigate to chrome://hang/ to stall the process. |
| 122 ui_test_utils::NavigateToURLWithDisposition( | 124 ui_test_utils::NavigateToURLWithDisposition( |
| 123 browser(), GURL(content::kChromeUIHangURL), CURRENT_TAB, 0); | 125 browser(), GURL(content::kChromeUIHangURL), CURRENT_TAB, 0); |
| 124 | 126 |
| 125 // Visit chrome://hang/ again in another NTP. Don't bother waiting for the | 127 // Visit chrome://hang/ again in another NTP. Don't bother waiting for the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 159 |
| 158 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits | 160 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits |
| 159 // for current loading to stop. | 161 // for current loading to stop. |
| 160 content::TestNavigationObserver observer( | 162 content::TestNavigationObserver observer( |
| 161 browser()->tab_strip_model()->GetActiveWebContents()); | 163 browser()->tab_strip_model()->GetActiveWebContents()); |
| 162 browser()->OpenURL(OpenURLParams( | 164 browser()->OpenURL(OpenURLParams( |
| 163 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, | 165 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, |
| 164 content::PAGE_TRANSITION_TYPED, false)); | 166 content::PAGE_TRANSITION_TYPED, false)); |
| 165 observer.Wait(); | 167 observer.Wait(); |
| 166 } | 168 } |
| OLD | NEW |