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 "chrome/browser/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/devtools/devtools_window_testing.h" | 12 #include "chrome/browser/devtools/devtools_window_testing.h" |
12 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/infobars/infobar_service.h" | 15 #include "chrome/browser/infobars/infobar_service.h" |
15 #include "chrome/browser/notifications/desktop_notification_service.h" | 16 #include "chrome/browser/notifications/desktop_notification_service.h" |
16 #include "chrome/browser/notifications/notification.h" | 17 #include "chrome/browser/notifications/notification.h" |
17 #include "chrome/browser/notifications/notification_test_util.h" | 18 #include "chrome/browser/notifications/notification_test_util.h" |
18 #include "chrome/browser/notifications/notification_ui_manager.h" | 19 #include "chrome/browser/notifications/notification_ui_manager.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 TaskManager::GetInstance()->KillProcess(tab); | 200 TaskManager::GetInstance()->KillProcess(tab); |
200 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); | 201 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); |
201 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 202 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
202 | 203 |
203 // Tab should reappear in task manager upon reload. | 204 // Tab should reappear in task manager upon reload. |
204 chrome::Reload(browser(), CURRENT_TAB); | 205 chrome::Reload(browser(), CURRENT_TAB); |
205 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); | 206 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); |
206 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); | 207 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
207 } | 208 } |
208 | 209 |
| 210 // Test for http://crbug.com/444722, which is not fixed yet. |
| 211 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, |
| 212 DISABLED_NavigateAwayFromHungRenderer) { |
| 213 host_resolver()->AddRule("*", "127.0.0.1"); |
| 214 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 215 ShowTaskManager(); |
| 216 |
| 217 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
| 218 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
| 219 |
| 220 GURL url1(embedded_test_server()->GetURL("/title2.html")); |
| 221 GURL url3(embedded_test_server()->GetURL("a.com", "/iframe.html")); |
| 222 |
| 223 // Open a new tab and make sure the task manager notices it. |
| 224 AddTabAtIndex(0, url1, ui::PAGE_TRANSITION_TYPED); |
| 225 ASSERT_NO_FATAL_FAILURE( |
| 226 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); |
| 227 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); |
| 228 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); |
| 229 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents(); |
| 230 |
| 231 // Initiate a navigation that will create a new WebContents in the same |
| 232 // SiteInstace... |
| 233 content::WebContentsAddedObserver web_contents_added_observer; |
| 234 tab1->GetMainFrame()->ExecuteJavaScriptForTests( |
| 235 base::ASCIIToUTF16("window.open('title3.html', '_blank');")); |
| 236 // ... then immediately hang the renderer so that title3.html can't load. |
| 237 tab1->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16("while(1);")); |
| 238 |
| 239 // Blocks until a new WebContents appears. |
| 240 WebContents* tab2 = web_contents_added_observer.GetWebContents(); |
| 241 |
| 242 // Make sure the new WebContents is in tab1's hung renderer process. |
| 243 ASSERT_NE(nullptr, tab2); |
| 244 ASSERT_NE(tab1, tab2); |
| 245 ASSERT_EQ(tab1->GetMainFrame()->GetProcess(), |
| 246 tab2->GetMainFrame()->GetProcess()) |
| 247 << "New WebContents must be in the same process as the old WebContents, " |
| 248 << "so that the new tab doesn't finish loading (what this test is all " |
| 249 << "about)"; |
| 250 ASSERT_EQ(tab1->GetSiteInstance(), tab2->GetSiteInstance()) |
| 251 << "New WebContents must initially be in the same site instance as the " |
| 252 << "old WebContents"; |
| 253 |
| 254 // Now navigate this tab to a different site. This should wind up in a |
| 255 // different renderer process, so it should complete and show up in the task |
| 256 // manager. |
| 257 tab2->OpenURL(content::OpenURLParams(url3, content::Referrer(), CURRENT_TAB, |
| 258 ui::PAGE_TRANSITION_TYPED, false)); |
| 259 |
| 260 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); |
| 261 } |
| 262 |
209 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { | 263 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { |
210 ASSERT_TRUE(LoadExtension( | 264 ASSERT_TRUE(LoadExtension( |
211 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 265 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
212 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 266 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
213 .AppendASCII("1.0.0.0"))); | 267 .AppendASCII("1.0.0.0"))); |
214 | 268 |
215 // Open a new panel to an extension url. | 269 // Open a new panel to an extension url. |
216 GURL url( | 270 GURL url( |
217 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); | 271 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); |
218 Panel* panel = PanelManager::GetInstance()->CreatePanel( | 272 Panel* panel = PanelManager::GetInstance()->CreatePanel( |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 } else { | 1090 } else { |
1037 ASSERT_NO_FATAL_FAILURE( | 1091 ASSERT_NO_FATAL_FAILURE( |
1038 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); | 1092 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); |
1039 ASSERT_NO_FATAL_FAILURE( | 1093 ASSERT_NO_FATAL_FAILURE( |
1040 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); | 1094 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); |
1041 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); | 1095 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); |
1042 } | 1096 } |
1043 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); | 1097 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); |
1044 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 1098 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
1045 } | 1099 } |
OLD | NEW |