| 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/browser_tabstrip.h" | 8 #include "chrome/browser/ui/browser_tabstrip.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" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 14 #include "content/public/browser/notification_types.h" | 14 #include "content/public/browser/notification_types.h" |
| 15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/test/browser_test_utils.h" |
| 17 #include "content/public/test/test_navigation_observer.h" | 18 #include "content/public/test/test_navigation_observer.h" |
| 18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 19 | 20 |
| 20 using content::OpenURLParams; | 21 using content::OpenURLParams; |
| 21 using content::Referrer; | 22 using content::Referrer; |
| 22 | 23 |
| 23 class NewTabUIBrowserTest : public InProcessBrowserTest { | 24 class NewTabUIBrowserTest : public InProcessBrowserTest { |
| 24 public: | 25 public: |
| 25 NewTabUIBrowserTest() {} | 26 NewTabUIBrowserTest() {} |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 // Ensure that chrome-internal: still loads the NTP. | 29 // Ensure that chrome-internal: still loads the NTP. |
| 29 // See http://crbug.com/6564. | 30 // See http://crbug.com/6564. |
| 30 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeInternalLoadsNTP) { | 31 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeInternalLoadsNTP) { |
| 31 // Go to the "new tab page" using its old url, rather than chrome://newtab. | 32 // Go to the "new tab page" using its old url, rather than chrome://newtab. |
| 32 // 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. |
| 33 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal:")); | 34 ui_test_utils::NavigateToURL(browser(), GURL("chrome-internal:")); |
| 34 bool empty_inner_html = false; | 35 bool empty_inner_html = false; |
| 35 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 36 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool( |
| 36 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), L"", | 37 chrome::GetWebContentsAt(browser(), 0)->GetRenderViewHost(), L"", |
| 37 L"window.domAutomationController.send(document.body.innerHTML == '')", | 38 L"window.domAutomationController.send(document.body.innerHTML == '')", |
| 38 &empty_inner_html)); | 39 &empty_inner_html)); |
| 39 ASSERT_FALSE(empty_inner_html); | 40 ASSERT_FALSE(empty_inner_html); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // Ensure loading a NTP with an existing SiteInstance in a reused process | 43 // Ensure loading a NTP with an existing SiteInstance in a reused process |
| 43 // doesn't cause us to kill the process. See http://crbug.com/104258. | 44 // doesn't cause us to kill the process. See http://crbug.com/104258. |
| 44 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, LoadNTPInExistingProcess) { | 45 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, LoadNTPInExistingProcess) { |
| 45 // Set max renderers to 1 to force running out of processes. | 46 // Set max renderers to 1 to force running out of processes. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 145 |
| 145 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits | 146 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits |
| 146 // for current loading to stop. | 147 // for current loading to stop. |
| 147 content::TestNavigationObserver observer( | 148 content::TestNavigationObserver observer( |
| 148 content::NotificationService::AllSources()); | 149 content::NotificationService::AllSources()); |
| 149 browser()->OpenURL(OpenURLParams( | 150 browser()->OpenURL(OpenURLParams( |
| 150 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, | 151 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, |
| 151 content::PAGE_TRANSITION_TYPED, false)); | 152 content::PAGE_TRANSITION_TYPED, false)); |
| 152 observer.Wait(); | 153 observer.Wait(); |
| 153 } | 154 } |
| OLD | NEW |