OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/dom_ui/new_tab_ui.h" | 9 #include "chrome/browser/dom_ui/new_tab_ui.h" |
10 #include "chrome/browser/prefs/pref_value_store.h" | 10 #include "chrome/browser/prefs/pref_value_store.h" |
11 #include "chrome/browser/sync/signin_manager.h" | 11 #include "chrome/browser/sync/signin_manager.h" |
| 12 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/json_pref_store.h" | 13 #include "chrome/common/json_pref_store.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "chrome/test/automation/browser_proxy.h" | 16 #include "chrome/test/automation/browser_proxy.h" |
16 #include "chrome/test/automation/tab_proxy.h" | 17 #include "chrome/test/automation/tab_proxy.h" |
17 #include "chrome/test/automation/window_proxy.h" | 18 #include "chrome/test/automation/window_proxy.h" |
18 #include "chrome/test/testing_pref_service.h" | 19 #include "chrome/test/testing_pref_service.h" |
19 | 20 |
20 class NewTabUITest : public UITest { | 21 class NewTabUITest : public UITest { |
21 public: | 22 public: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); | 103 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); |
103 | 104 |
104 // Visit about:hang again in another NTP. Don't bother waiting for the | 105 // Visit about:hang again in another NTP. Don't bother waiting for the |
105 // NTP to load, because it's hung. | 106 // NTP to load, because it's hung. |
106 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); | 107 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
107 scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); | 108 scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); |
108 ASSERT_TRUE(tab2.get()); | 109 ASSERT_TRUE(tab2.get()); |
109 ASSERT_TRUE(tab2->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); | 110 ASSERT_TRUE(tab2->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); |
110 } | 111 } |
111 | 112 |
| 113 // Allows testing NTP in process-per-tab mode. |
| 114 class NewTabUIProcessPerTabTest : public NewTabUITest { |
| 115 public: |
| 116 NewTabUIProcessPerTabTest() : NewTabUITest() {} |
| 117 |
| 118 protected: |
| 119 virtual void SetUp() { |
| 120 launch_arguments_.AppendSwitch(switches::kProcessPerTab); |
| 121 UITest::SetUp(); |
| 122 } |
| 123 }; |
| 124 |
| 125 // Navigates away from NTP before it commits, in process-per-tab mode. |
| 126 // Ensures that we don't load the normal page in the NTP process (and thus |
| 127 // crash), as in http://crbug.com/69224. |
| 128 TEST_F(NewTabUIProcessPerTabTest, NavBeforeNTPCommits) { |
| 129 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 130 ASSERT_TRUE(window.get()); |
| 131 |
| 132 // Bring up a new tab page. |
| 133 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
| 134 int load_time; |
| 135 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
| 136 scoped_refptr<TabProxy> tab = window->GetActiveTab(); |
| 137 ASSERT_TRUE(tab.get()); |
| 138 |
| 139 // Navigate to about:hang to stall the process. |
| 140 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); |
| 141 |
| 142 // Visit a normal URL in another NTP that hasn't committed. |
| 143 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
| 144 scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); |
| 145 ASSERT_TRUE(tab2.get()); |
| 146 ASSERT_TRUE(tab2->NavigateToURL(GURL("data:text/html,hello world"))); |
| 147 } |
| 148 |
112 // Fails about ~5% of the time on all platforms. http://crbug.com/45001 | 149 // Fails about ~5% of the time on all platforms. http://crbug.com/45001 |
113 TEST_F(NewTabUITest, FLAKY_ChromeInternalLoadsNTP) { | 150 TEST_F(NewTabUITest, FLAKY_ChromeInternalLoadsNTP) { |
114 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 151 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
115 ASSERT_TRUE(window.get()); | 152 ASSERT_TRUE(window.get()); |
116 | 153 |
117 // Go to the "new tab page" using its old url, rather than chrome://newtab. | 154 // Go to the "new tab page" using its old url, rather than chrome://newtab. |
118 scoped_refptr<TabProxy> tab = window->GetTab(0); | 155 scoped_refptr<TabProxy> tab = window->GetTab(0); |
119 ASSERT_TRUE(tab.get()); | 156 ASSERT_TRUE(tab.get()); |
120 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("chrome-internal:"))); | 157 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("chrome-internal:"))); |
121 int load_time; | 158 int load_time; |
(...skipping 24 matching lines...) Expand all Loading... |
146 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); | 183 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); |
147 | 184 |
148 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); | 185 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
149 ASSERT_TRUE(migrated); | 186 ASSERT_TRUE(migrated); |
150 ASSERT_EQ(NewTabUI::current_pref_version(), | 187 ASSERT_EQ(NewTabUI::current_pref_version(), |
151 prefs->GetInteger(prefs::kNTPPrefVersion)); | 188 prefs->GetInteger(prefs::kNTPPrefVersion)); |
152 | 189 |
153 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); | 190 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
154 ASSERT_FALSE(migrated); | 191 ASSERT_FALSE(migrated); |
155 } | 192 } |
OLD | NEW |