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/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "chrome/common/url_constants.h" | 8 #include "chrome/common/url_constants.h" |
9 #include "chrome/test/base/in_process_browser_test.h" | 9 #include "chrome/test/base/in_process_browser_test.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 75 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
76 EXPECT_EQ(1, browser()->GetWebContentsAt(2)->GetMaxPageID()); | 76 EXPECT_EQ(1, browser()->GetWebContentsAt(2)->GetMaxPageID()); |
77 browser()->CloseTab(); | 77 browser()->CloseTab(); |
78 | 78 |
79 // Open another Web UI page in a new tab. | 79 // Open another Web UI page in a new tab. |
80 ui_test_utils::NavigateToURLWithDisposition( | 80 ui_test_utils::NavigateToURLWithDisposition( |
81 browser(), GURL(chrome::kChromeUISettingsURL), NEW_FOREGROUND_TAB, | 81 browser(), GURL(chrome::kChromeUISettingsURL), NEW_FOREGROUND_TAB, |
82 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 82 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
83 EXPECT_EQ(1, browser()->GetWebContentsAt(2)->GetMaxPageID()); | 83 EXPECT_EQ(1, browser()->GetWebContentsAt(2)->GetMaxPageID()); |
84 | 84 |
85 // At this point, opening another NTP will use the old SiteInstance in the | 85 // At this point, opening another NTP will use the existing WebUI process |
86 // existing Web UI process, but the page IDs shouldn't affect each other. | 86 // but its own SiteInstance, so the page IDs shouldn't affect each other. |
87 ui_test_utils::NavigateToURLWithDisposition( | 87 ui_test_utils::NavigateToURLWithDisposition( |
88 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, | 88 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, |
89 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 89 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
90 EXPECT_EQ(1, browser()->GetWebContentsAt(3)->GetMaxPageID()); | 90 EXPECT_EQ(1, browser()->GetWebContentsAt(3)->GetMaxPageID()); |
91 | 91 |
92 // Only navigating to the NTP in the original tab should have a higher | 92 // Navigating to the NTP in the original tab causes a BrowsingInstance |
93 // page ID. | 93 // swap, so it gets a new SiteInstance starting with page ID 1 again. |
94 browser()->ActivateTabAt(1, true); | 94 browser()->ActivateTabAt(1, true); |
95 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 95 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
96 EXPECT_EQ(2, browser()->GetWebContentsAt(1)->GetMaxPageID()); | 96 EXPECT_EQ(1, browser()->GetWebContentsAt(1)->GetMaxPageID()); |
97 } | 97 } |
98 | 98 |
99 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. | 99 // Loads chrome://hang/ into two NTP tabs, ensuring we don't crash. |
100 // See http://crbug.com/59859. | 100 // See http://crbug.com/59859. |
101 // If this flakes, use http://crbug.com/87200. | 101 // If this flakes, use http://crbug.com/87200. |
102 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) { | 102 IN_PROC_BROWSER_TEST_F(NewTabUIBrowserTest, ChromeHangInNTP) { |
103 // Bring up a new tab page. | 103 // Bring up a new tab page. |
104 ui_test_utils::NavigateToURLWithDisposition( | 104 ui_test_utils::NavigateToURLWithDisposition( |
105 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, | 105 browser(), GURL(chrome::kChromeUINewTabURL), NEW_FOREGROUND_TAB, |
106 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 106 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits | 145 // We don't use ui_test_utils::NavigateToURLWithDisposition because that waits |
146 // for current loading to stop. | 146 // for current loading to stop. |
147 content::TestNavigationObserver observer( | 147 content::TestNavigationObserver observer( |
148 content::NotificationService::AllSources()); | 148 content::NotificationService::AllSources()); |
149 browser()->OpenURL(OpenURLParams( | 149 browser()->OpenURL(OpenURLParams( |
150 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, | 150 GURL("data:text/html,hello world"), Referrer(), CURRENT_TAB, |
151 content::PAGE_TRANSITION_TYPED, false)); | 151 content::PAGE_TRANSITION_TYPED, false)); |
152 observer.Wait(); | 152 observer.Wait(); |
153 } | 153 } |
OLD | NEW |