OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/browser_thread.h" | 8 #include "chrome/browser/browser_thread.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/json_pref_store.h" | 12 #include "chrome/common/json_pref_store.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/automation/browser_proxy.h" | 15 #include "chrome/test/automation/browser_proxy.h" |
15 #include "chrome/test/automation/tab_proxy.h" | 16 #include "chrome/test/automation/tab_proxy.h" |
16 #include "chrome/test/automation/window_proxy.h" | 17 #include "chrome/test/automation/window_proxy.h" |
17 #include "chrome/test/testing_pref_service.h" | 18 #include "chrome/test/testing_pref_service.h" |
18 | 19 |
19 class NewTabUITest : public UITest { | 20 class NewTabUITest : public UITest { |
20 public: | 21 public: |
21 NewTabUITest() { | 22 NewTabUITest() { |
22 dom_automation_enabled_ = true; | 23 dom_automation_enabled_ = true; |
23 // Set home page to the empty string so that we can set the home page using | 24 // Set home page to the empty string so that we can set the home page using |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 ASSERT_TRUE(tab->ExecuteAndExtractString( | 78 ASSERT_TRUE(tab->ExecuteAndExtractString( |
78 L"", | 79 L"", |
79 L"window.domAutomationController.send(" | 80 L"window.domAutomationController.send(" |
80 L"document.getElementById('login-username').innerText)", | 81 L"document.getElementById('login-username').innerText)", |
81 &displayed_username)); | 82 &displayed_username)); |
82 | 83 |
83 EXPECT_EQ(L"user@gmail.com", displayed_username); | 84 EXPECT_EQ(L"user@gmail.com", displayed_username); |
84 } | 85 } |
85 | 86 |
| 87 // Loads about:hang into two NTP tabs, ensuring we don't crash. |
| 88 // See http://crbug.com/59859. |
| 89 TEST_F(NewTabUITest, AboutHangInNTP) { |
| 90 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 91 ASSERT_TRUE(window.get()); |
| 92 |
| 93 // Bring up a new tab page. |
| 94 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
| 95 int load_time; |
| 96 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
| 97 scoped_refptr<TabProxy> tab = window->GetActiveTab(); |
| 98 ASSERT_TRUE(tab.get()); |
| 99 |
| 100 // Navigate to about:hang to stall the process. |
| 101 ASSERT_TRUE(tab->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); |
| 102 |
| 103 // Visit about:hang again in another NTP. Don't bother waiting for the |
| 104 // NTP to load, because it's hung. |
| 105 ASSERT_TRUE(window->RunCommand(IDC_NEW_TAB)); |
| 106 scoped_refptr<TabProxy> tab2 = window->GetActiveTab(); |
| 107 ASSERT_TRUE(tab2.get()); |
| 108 ASSERT_TRUE(tab2->NavigateToURLAsync(GURL(chrome::kAboutHangURL))); |
| 109 } |
| 110 |
86 // Fails about ~5% of the time on all platforms. http://crbug.com/45001 | 111 // Fails about ~5% of the time on all platforms. http://crbug.com/45001 |
87 TEST_F(NewTabUITest, FLAKY_ChromeInternalLoadsNTP) { | 112 TEST_F(NewTabUITest, FLAKY_ChromeInternalLoadsNTP) { |
88 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 113 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
89 ASSERT_TRUE(window.get()); | 114 ASSERT_TRUE(window.get()); |
90 | 115 |
91 // Go to the "new tab page" using its old url, rather than chrome://newtab. | 116 // Go to the "new tab page" using its old url, rather than chrome://newtab. |
92 scoped_refptr<TabProxy> tab = window->GetTab(0); | 117 scoped_refptr<TabProxy> tab = window->GetTab(0); |
93 ASSERT_TRUE(tab.get()); | 118 ASSERT_TRUE(tab.get()); |
94 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("chrome-internal:"))); | 119 ASSERT_TRUE(tab->NavigateToURLAsync(GURL("chrome-internal:"))); |
95 int load_time; | 120 int load_time; |
(...skipping 24 matching lines...) Expand all Loading... |
120 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); | 145 ASSERT_EQ(0, prefs->GetInteger(prefs::kNTPPrefVersion)); |
121 | 146 |
122 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); | 147 bool migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
123 ASSERT_TRUE(migrated); | 148 ASSERT_TRUE(migrated); |
124 ASSERT_EQ(NewTabUI::current_pref_version(), | 149 ASSERT_EQ(NewTabUI::current_pref_version(), |
125 prefs->GetInteger(prefs::kNTPPrefVersion)); | 150 prefs->GetInteger(prefs::kNTPPrefVersion)); |
126 | 151 |
127 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); | 152 migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get()); |
128 ASSERT_FALSE(migrated); | 153 ASSERT_FALSE(migrated); |
129 } | 154 } |
OLD | NEW |