| 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 "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return TaskManager::GetInstance()->model(); | 73 return TaskManager::GetInstance()->model(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void ShowTaskManager() { | 76 void ShowTaskManager() { |
| 77 EXPECT_EQ(0, model()->ResourceCount()); | 77 EXPECT_EQ(0, model()->ResourceCount()); |
| 78 | 78 |
| 79 // Show the task manager. This populates the model, and helps with debugging | 79 // Show the task manager. This populates the model, and helps with debugging |
| 80 // (you see the task manager). | 80 // (you see the task manager). |
| 81 chrome::ShowTaskManager(browser()); | 81 chrome::ShowTaskManager(browser()); |
| 82 | 82 |
| 83 // New Tab Page. | 83 // New Tab Page (visible and prerendered). |
| 84 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 84 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void Refresh() { | 87 void Refresh() { |
| 88 model()->Refresh(); | 88 model()->Refresh(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 int GetUpdateTimeMs() { | 91 int GetUpdateTimeMs() { |
| 92 return TaskManagerModel::kUpdateTimeMs; | 92 return TaskManagerModel::kUpdateTimeMs; |
| 93 } | 93 } |
| 94 | 94 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) { | 135 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) { |
| 136 // Showing task manager handled by SetUp. | 136 // Showing task manager handled by SetUp. |
| 137 } | 137 } |
| 138 | 138 |
| 139 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { | 139 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { |
| 140 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 140 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 141 // Open a new tab and make sure we notice that. | 141 // Open a new tab and make sure we notice that. |
| 142 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 142 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
| 143 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); | 143 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); |
| 144 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 144 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 145 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 145 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 146 | 146 |
| 147 // Check that the last entry is a tab contents resource whose title starts | 147 // Check that the last entry is a tab contents resource whose title starts |
| 148 // starts with "Tab:". | 148 // starts with "Tab:". |
| 149 ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL); | 149 ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL); |
| 150 string16 prefix = l10n_util::GetStringFUTF16( | 150 string16 prefix = l10n_util::GetStringFUTF16( |
| 151 IDS_TASK_MANAGER_TAB_PREFIX, string16()); | 151 IDS_TASK_MANAGER_TAB_PREFIX, string16()); |
| 152 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), prefix, | 152 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), prefix, |
| 153 true)); | 153 true)); |
| 154 | 154 |
| 155 // Close the tab and verify that we notice. | 155 // Close the tab and verify that we notice. |
| 156 browser()->tab_strip_model()->CloseWebContentsAt(0, | 156 browser()->tab_strip_model()->CloseWebContentsAt(0, |
| 157 TabStripModel::CLOSE_NONE); | 157 TabStripModel::CLOSE_NONE); |
| 158 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 158 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 159 } | 159 } |
| 160 | 160 |
| 161 #if defined(USE_ASH) | 161 #if defined(USE_ASH) |
| 162 // This test fails on Ash because task manager treats view type | 162 // This test fails on Ash because task manager treats view type |
| 163 // Panels differently for Ash. | 163 // Panels differently for Ash. |
| 164 #define MAYBE_NoticePanelChanges DISABLED_NoticePanelChanges | 164 #define MAYBE_NoticePanelChanges DISABLED_NoticePanelChanges |
| 165 #else | 165 #else |
| 166 #define MAYBE_NoticePanelChanges NoticePanelChanges | 166 #define MAYBE_NoticePanelChanges NoticePanelChanges |
| 167 #endif | 167 #endif |
| 168 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) { | 168 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) { |
| 169 ASSERT_TRUE(LoadExtension( | 169 ASSERT_TRUE(LoadExtension( |
| 170 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 170 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 171 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 171 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 172 .AppendASCII("1.0.0.0"))); | 172 .AppendASCII("1.0.0.0"))); |
| 173 | 173 |
| 174 // Browser, the New Tab Page and Extension background page. | 174 // Browser, the New Tab Page (visible and prerendered) and Extension |
| 175 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 175 // background page. |
| 176 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 176 | 177 |
| 177 // Open a new panel to an extension url and make sure we notice that. | 178 // Open a new panel to an extension url and make sure we notice that. |
| 178 GURL url( | 179 GURL url( |
| 179 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); | 180 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); |
| 180 Panel* panel = PanelManager::GetInstance()->CreatePanel( | 181 Panel* panel = PanelManager::GetInstance()->CreatePanel( |
| 181 web_app::GenerateApplicationNameFromExtensionId( | 182 web_app::GenerateApplicationNameFromExtensionId( |
| 182 last_loaded_extension_id_), | 183 last_loaded_extension_id_), |
| 183 browser()->profile(), | 184 browser()->profile(), |
| 184 url, | 185 url, |
| 185 gfx::Rect(300, 400), | 186 gfx::Rect(300, 400), |
| 186 PanelManager::CREATE_AS_DOCKED); | 187 PanelManager::CREATE_AS_DOCKED); |
| 187 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); | 188 TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); |
| 188 | 189 |
| 189 // Check that the fourth entry is a resource with the panel's web contents | 190 // Check that the fifth entry is a resource with the panel's web contents |
| 190 // and whose title starts with "Extension:". | 191 // and whose title starts with "Extension:". |
| 191 ASSERT_EQ(panel->GetWebContents(), model()->GetResourceWebContents(3)); | 192 ASSERT_EQ(panel->GetWebContents(), model()->GetResourceWebContents(4)); |
| 192 string16 prefix = l10n_util::GetStringFUTF16( | 193 string16 prefix = l10n_util::GetStringFUTF16( |
| 193 IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); | 194 IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); |
| 194 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(3), prefix, true)); | 195 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(3), prefix, true)); |
| 195 | 196 |
| 196 // Close the panel and verify that we notice. | 197 // Close the panel and verify that we notice. |
| 197 panel->Close(); | 198 panel->Close(); |
| 198 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 199 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 199 | 200 |
| 200 // Unload extension to avoid crash on Windows. | 201 // Unload extension to avoid crash on Windows. |
| 201 UnloadExtension(last_loaded_extension_id_); | 202 UnloadExtension(last_loaded_extension_id_); |
| 202 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 203 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 203 } | 204 } |
| 204 | 205 |
| 205 #if defined(USE_ASH) || defined(OS_WIN) | 206 #if defined(USE_ASH) || defined(OS_WIN) |
| 206 // This test fails on Ash because task manager treats view type | 207 // This test fails on Ash because task manager treats view type |
| 207 // Panels differently for Ash. | 208 // Panels differently for Ash. |
| 208 // This test also fails on Windows, win_rel trybot. http://crbug.com/166322 | 209 // This test also fails on Windows, win_rel trybot. http://crbug.com/166322 |
| 209 #define MAYBE_KillPanelExtension DISABLED_KillPanelExtension | 210 #define MAYBE_KillPanelExtension DISABLED_KillPanelExtension |
| 210 #else | 211 #else |
| 211 #define MAYBE_KillPanelExtension KillPanelExtension | 212 #define MAYBE_KillPanelExtension KillPanelExtension |
| 212 #endif | 213 #endif |
| 213 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { | 214 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { |
| 214 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 215 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 215 | 216 |
| 216 ASSERT_TRUE(LoadExtension( | 217 ASSERT_TRUE(LoadExtension( |
| 217 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 218 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 218 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 219 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 219 .AppendASCII("1.0.0.0"))); | 220 .AppendASCII("1.0.0.0"))); |
| 220 | 221 |
| 221 // Browser, the New Tab Page and Extension background page. | 222 // Browser, the New Tab Page (visible, prerendered) and Extension background |
| 222 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 223 // page. |
| 224 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 223 | 225 |
| 224 // Open a new panel to an extension url and make sure we notice that. | 226 // Open a new panel to an extension url and make sure we notice that. |
| 225 GURL url( | 227 GURL url( |
| 226 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); | 228 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); |
| 227 PanelManager::GetInstance()->CreatePanel( | 229 PanelManager::GetInstance()->CreatePanel( |
| 228 web_app::GenerateApplicationNameFromExtensionId( | 230 web_app::GenerateApplicationNameFromExtensionId( |
| 229 last_loaded_extension_id_), | 231 last_loaded_extension_id_), |
| 230 browser()->profile(), | 232 browser()->profile(), |
| 231 url, | 233 url, |
| 232 gfx::Rect(300, 400), | 234 gfx::Rect(300, 400), |
| 233 PanelManager::CREATE_AS_DOCKED); | 235 PanelManager::CREATE_AS_DOCKED); |
| 234 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); | 236 TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); |
| 235 | 237 |
| 236 // Kill the panel extension process and verify that it disappears from the | 238 // Kill the panel extension process and verify that it disappears from the |
| 237 // model along with its panel. | 239 // model along with its panel. |
| 238 ASSERT_TRUE(model()->IsBackgroundResource(resource_count)); | 240 ASSERT_TRUE(model()->IsBackgroundResource(resource_count)); |
| 239 TaskManager::GetInstance()->KillProcess(resource_count); | 241 TaskManager::GetInstance()->KillProcess(resource_count); |
| 240 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 242 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 241 } | 243 } |
| 242 | 244 |
| 243 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { | 245 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { |
| 244 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 246 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 245 ASSERT_TRUE(LoadExtension( | 247 ASSERT_TRUE(LoadExtension( |
| 246 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 248 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 247 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 249 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 248 .AppendASCII("1.0.0.0"))); | 250 .AppendASCII("1.0.0.0"))); |
| 249 | 251 |
| 250 // Browser, Extension background page, and the New Tab Page. | 252 // Browser, Extension background page, and the New Tab Page (visible, |
| 251 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 253 // prerenderd). |
| 254 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 252 | 255 |
| 253 // Open a new tab to an extension URL and make sure we notice that. | 256 // Open a new tab to an extension URL and make sure we notice that. |
| 254 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); | 257 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); |
| 255 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 258 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 256 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); | 259 TaskManagerBrowserTestUtil::WaitForWebResourceChange(4); |
| 257 | 260 |
| 258 // Check that the third entry (background) is an extension resource whose | 261 // Check that the third entry (background) is an extension resource whose |
| 259 // title starts with "Extension:". | 262 // title starts with "Extension:". |
| 260 ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( | 263 ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( |
| 261 resource_count)); | 264 resource_count)); |
| 262 ASSERT_TRUE(model()->GetResourceWebContents(resource_count) == NULL); | 265 ASSERT_TRUE(model()->GetResourceWebContents(resource_count) == NULL); |
| 263 ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL); | 266 ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL); |
| 264 string16 prefix = l10n_util::GetStringFUTF16( | 267 string16 prefix = l10n_util::GetStringFUTF16( |
| 265 IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); | 268 IDS_TASK_MANAGER_EXTENSION_PREFIX, string16()); |
| 266 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), | 269 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), |
| 267 prefix, true)); | 270 prefix, true)); |
| 268 | 271 |
| 269 // Check that the fourth entry (page.html) is of type extension and has both | 272 // Check that the fourth entry (page.html) is of type extension and has both |
| 270 // a tab contents and an extension. The title should start with "Extension:". | 273 // a tab contents and an extension. The title should start with "Extension:". |
| 271 ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( | 274 ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( |
| 272 resource_count + 1)); | 275 resource_count + 1)); |
| 273 ASSERT_TRUE(model()->GetResourceWebContents(resource_count + 1) != NULL); | 276 ASSERT_TRUE(model()->GetResourceWebContents(resource_count + 1) != NULL); |
| 274 ASSERT_TRUE(model()->GetResourceExtension(resource_count + 1) != NULL); | 277 ASSERT_TRUE(model()->GetResourceExtension(resource_count + 1) != NULL); |
| 275 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count + 1), | 278 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count + 1), |
| 276 prefix, true)); | 279 prefix, true)); |
| 277 | 280 |
| 278 // Unload extension to avoid crash on Windows. | 281 // Unload extension to avoid crash on Windows. |
| 279 UnloadExtension(last_loaded_extension_id_); | 282 UnloadExtension(last_loaded_extension_id_); |
| 280 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 283 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 281 } | 284 } |
| 282 | 285 |
| 283 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { | 286 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { |
| 284 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 287 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 285 ASSERT_TRUE(LoadExtension( | 288 ASSERT_TRUE(LoadExtension( |
| 286 test_data_dir_.AppendASCII("packaged_app"))); | 289 test_data_dir_.AppendASCII("packaged_app"))); |
| 287 ExtensionService* service = extensions::ExtensionSystem::Get( | 290 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 288 browser()->profile())->extension_service(); | 291 browser()->profile())->extension_service(); |
| 289 const extensions::Extension* extension = | 292 const extensions::Extension* extension = |
| 290 service->GetExtensionById(last_loaded_extension_id_, false); | 293 service->GetExtensionById(last_loaded_extension_id_, false); |
| 291 | 294 |
| 292 // New Tab Page. | 295 // New Tab Page (visible and prerendered). |
| 293 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 296 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 294 | 297 |
| 295 // Open a new tab to the app's launch URL and make sure we notice that. | 298 // Open a new tab to the app's launch URL and make sure we notice that. |
| 296 GURL url(extension->GetResourceURL("main.html")); | 299 GURL url(extension->GetResourceURL("main.html")); |
| 297 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 300 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); |
| 298 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 301 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 299 | 302 |
| 300 // Check that the third entry (main.html) is of type extension and has both | 303 // Check that the third entry (main.html) is of type extension and has both |
| 301 // a tab contents and an extension. The title should start with "App:". | 304 // a tab contents and an extension. The title should start with "App:". |
| 302 ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( | 305 ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( |
| 303 resource_count)); | 306 resource_count)); |
| 304 ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL); | 307 ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL); |
| 305 ASSERT_TRUE(model()->GetResourceExtension(resource_count) == extension); | 308 ASSERT_TRUE(model()->GetResourceExtension(resource_count) == extension); |
| 306 string16 prefix = l10n_util::GetStringFUTF16( | 309 string16 prefix = l10n_util::GetStringFUTF16( |
| 307 IDS_TASK_MANAGER_APP_PREFIX, string16()); | 310 IDS_TASK_MANAGER_APP_PREFIX, string16()); |
| 308 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), | 311 ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), |
| 309 prefix, true)); | 312 prefix, true)); |
| 310 | 313 |
| 311 // Unload extension to avoid crash on Windows. | 314 // Unload extension to avoid crash on Windows. |
| 312 UnloadExtension(last_loaded_extension_id_); | 315 UnloadExtension(last_loaded_extension_id_); |
| 313 TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); | 316 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); |
| 314 } | 317 } |
| 315 | 318 |
| 316 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) { | 319 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) { |
| 317 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 320 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 318 | 321 |
| 319 // The app under test acts on URLs whose host is "localhost", | 322 // The app under test acts on URLs whose host is "localhost", |
| 320 // so the URLs we navigate to must have host "localhost". | 323 // so the URLs we navigate to must have host "localhost". |
| 321 host_resolver()->AddRule("*", "127.0.0.1"); | 324 host_resolver()->AddRule("*", "127.0.0.1"); |
| 322 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 325 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 323 GURL::Replacements replace_host; | 326 GURL::Replacements replace_host; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 #define MAYBE_ReloadExtension ReloadExtension | 415 #define MAYBE_ReloadExtension ReloadExtension |
| 413 #endif | 416 #endif |
| 414 | 417 |
| 415 // Regression test for http://crbug.com/18693. | 418 // Regression test for http://crbug.com/18693. |
| 416 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { | 419 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { |
| 417 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 420 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 418 LOG(INFO) << "loading extension"; | 421 LOG(INFO) << "loading extension"; |
| 419 ASSERT_TRUE(LoadExtension( | 422 ASSERT_TRUE(LoadExtension( |
| 420 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); | 423 test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); |
| 421 | 424 |
| 422 // Wait until we see the loaded extension in the task manager (the three | 425 // Wait until we see the loaded extension in the task manager (the four |
| 423 // resources are: the browser process, New Tab Page, and the extension). | 426 // resources are: the browser process, visible and prerendered New Tab Page, |
| 427 // and the extension). |
| 424 LOG(INFO) << "waiting for resource change"; | 428 LOG(INFO) << "waiting for resource change"; |
| 425 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 429 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 426 | 430 |
| 427 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); | 431 EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); |
| 428 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); | 432 EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); |
| 429 ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL); | 433 ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL); |
| 430 | 434 |
| 431 const extensions::Extension* extension = model()->GetResourceExtension( | 435 const extensions::Extension* extension = model()->GetResourceExtension( |
| 432 resource_count); | 436 resource_count); |
| 433 ASSERT_TRUE(extension != NULL); | 437 ASSERT_TRUE(extension != NULL); |
| 434 | 438 |
| 435 // Reload the extension a few times and make sure our resource count | 439 // Reload the extension a few times and make sure our resource count |
| 436 // doesn't increase. | 440 // doesn't increase. |
| 437 LOG(INFO) << "First extension reload"; | 441 LOG(INFO) << "First extension reload"; |
| 438 ReloadExtension(extension->id()); | 442 ReloadExtension(extension->id()); |
| 439 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 443 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 440 extension = model()->GetResourceExtension(resource_count); | 444 extension = model()->GetResourceExtension(resource_count); |
| 441 ASSERT_TRUE(extension != NULL); | 445 ASSERT_TRUE(extension != NULL); |
| 442 | 446 |
| 443 LOG(INFO) << "Second extension reload"; | 447 LOG(INFO) << "Second extension reload"; |
| 444 ReloadExtension(extension->id()); | 448 ReloadExtension(extension->id()); |
| 445 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 449 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 446 extension = model()->GetResourceExtension(resource_count); | 450 extension = model()->GetResourceExtension(resource_count); |
| 447 ASSERT_TRUE(extension != NULL); | 451 ASSERT_TRUE(extension != NULL); |
| 448 | 452 |
| 449 LOG(INFO) << "Third extension reload"; | 453 LOG(INFO) << "Third extension reload"; |
| 450 ReloadExtension(extension->id()); | 454 ReloadExtension(extension->id()); |
| 451 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 455 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 452 } | 456 } |
| 453 | 457 |
| 454 // Crashy, http://crbug.com/42301. | 458 // Crashy, http://crbug.com/42301. |
| 455 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, | 459 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, |
| 456 DISABLED_PopulateWebCacheFields) { | 460 DISABLED_PopulateWebCacheFields) { |
| 457 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); | 461 int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); |
| 458 | 462 |
| 459 // Open a new tab and make sure we notice that. | 463 // Open a new tab and make sure we notice that. |
| 460 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 464 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
| 461 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); | 465 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 // Make sure that the devtools window is loaded before starting the task | 540 // Make sure that the devtools window is loaded before starting the task |
| 537 // manager. | 541 // manager. |
| 538 content::RunAllPendingInMessageLoop(); | 542 content::RunAllPendingInMessageLoop(); |
| 539 | 543 |
| 540 // Now add showing the task manager to the queue, and watch for the right | 544 // Now add showing the task manager to the queue, and watch for the right |
| 541 // number of reources to show up. | 545 // number of reources to show up. |
| 542 base::MessageLoop::current()->PostTask( | 546 base::MessageLoop::current()->PostTask( |
| 543 FROM_HERE, | 547 FROM_HERE, |
| 544 base::Bind(&TaskManagerNoShowBrowserTest::ShowTaskManager, | 548 base::Bind(&TaskManagerNoShowBrowserTest::ShowTaskManager, |
| 545 base::Unretained(this))); | 549 base::Unretained(this))); |
| 546 TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); | 550 TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); |
| 547 } | 551 } |
| 548 | 552 |
| 549 #endif | 553 #endif |
| OLD | NEW |