Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: chrome/browser/task_manager/task_manager_browsertest.cc

Issue 818263004: Add a test that is a repro case for bug 444945. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autofill_crash'
Patch Set: Self-review fixes Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/public/test/browser_test_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 content::SetupCrossSiteRedirector(embedded_test_server());
nasko 2014/12/23 23:44:04 nit: You don't need the content::SetupCrossSiteRed
ncarter (slow) 2014/12/23 23:54:42 Good call.
216 ShowTaskManager();
217
218 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
219 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
220
221 GURL url1(embedded_test_server()->GetURL("/title2.html"));
222 GURL url2(embedded_test_server()->GetURL("/title3.html"));
223 GURL url3(embedded_test_server()->GetURL("a.com", "/iframe.html"));
224
225 // Open a new tab and make sure the task manager notices it.
226 AddTabAtIndex(0, url1, ui::PAGE_TRANSITION_TYPED);
227 ASSERT_NO_FATAL_FAILURE(
228 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness")));
229 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
230 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab()));
231 WebContents* tab1 = browser()->tab_strip_model()->GetActiveWebContents();
232
233 // Initiate a navigation that will create a new WebContents in the same
234 // SiteInstace...
235 content::WebContentsAddedObserver web_contents_added_observer;
236 tab1->GetMainFrame()->ExecuteJavaScriptForTests(
237 base::ASCIIToUTF16("window.open('title3.html', '_blank');"));
238 // ... then immediately hang the renderer so that title3.html can't load.
239 tab1->GetMainFrame()->ExecuteJavaScript(base::ASCIIToUTF16("while(1);"));
nasko 2014/12/23 23:44:04 Wouldn't it be flaky to send these two as separate
ncarter (slow) 2014/12/23 23:54:42 Because WebContentses are created on the UI thread
nasko 2014/12/24 00:22:57 Yes, thanks for the explanation.
240
241 // Blocks until a new WebContents appears.
242 WebContents* tab2 = web_contents_added_observer.GetWebContents();
243
244 // Make sure the new WebContents is in tab1's hung renderer process.
245 ASSERT_NE(nullptr, tab2);
246 ASSERT_NE(tab1, tab2);
247 ASSERT_EQ(tab1->GetMainFrame()->GetProcess(),
248 tab2->GetMainFrame()->GetProcess())
249 << "New WebContents must be in the same process as the old WebContents, "
250 << "so that the new tab doesn't finish loading (what this test is all "
251 << "about)";
252 ASSERT_EQ(tab1->GetSiteInstance(), tab2->GetSiteInstance())
253 << "New WebContents must initially be in the same site instance as the "
254 << "old WebContents";
255
256 // Now navigate this tab to a different site. This should wind up in a
257 // different renderer process, so it should complete and show up in the task
258 // manager.
259 tab2->OpenURL(content::OpenURLParams(url3, content::Referrer(), CURRENT_TAB,
260 ui::PAGE_TRANSITION_TYPED, false));
261
262 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test")));
263 }
264
209 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { 265 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) {
210 ASSERT_TRUE(LoadExtension( 266 ASSERT_TRUE(LoadExtension(
211 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 267 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
212 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 268 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
213 .AppendASCII("1.0.0.0"))); 269 .AppendASCII("1.0.0.0")));
214 270
215 // Open a new panel to an extension url. 271 // Open a new panel to an extension url.
216 GURL url( 272 GURL url(
217 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); 273 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html");
218 Panel* panel = PanelManager::GetInstance()->CreatePanel( 274 Panel* panel = PanelManager::GetInstance()->CreatePanel(
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 } else { 1092 } else {
1037 ASSERT_NO_FATAL_FAILURE( 1093 ASSERT_NO_FATAL_FAILURE(
1038 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); 1094 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/")));
1039 ASSERT_NO_FATAL_FAILURE( 1095 ASSERT_NO_FATAL_FAILURE(
1040 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); 1096 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/")));
1041 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); 1097 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe()));
1042 } 1098 }
1043 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); 1099 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac")));
1044 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 1100 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
1045 } 1101 }
OLDNEW
« no previous file with comments | « no previous file | content/public/test/browser_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698