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

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

Issue 1922683003: Make old task manager tests work against new task manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 using task_manager::browsertest_util::MatchAnyApp; 55 using task_manager::browsertest_util::MatchAnyApp;
56 using task_manager::browsertest_util::MatchAnyExtension; 56 using task_manager::browsertest_util::MatchAnyExtension;
57 using task_manager::browsertest_util::MatchAnySubframe; 57 using task_manager::browsertest_util::MatchAnySubframe;
58 using task_manager::browsertest_util::MatchAnyTab; 58 using task_manager::browsertest_util::MatchAnyTab;
59 using task_manager::browsertest_util::MatchAnyUtility; 59 using task_manager::browsertest_util::MatchAnyUtility;
60 using task_manager::browsertest_util::MatchApp; 60 using task_manager::browsertest_util::MatchApp;
61 using task_manager::browsertest_util::MatchExtension; 61 using task_manager::browsertest_util::MatchExtension;
62 using task_manager::browsertest_util::MatchSubframe; 62 using task_manager::browsertest_util::MatchSubframe;
63 using task_manager::browsertest_util::MatchTab; 63 using task_manager::browsertest_util::MatchTab;
64 using task_manager::browsertest_util::MatchUtility; 64 using task_manager::browsertest_util::MatchUtility;
65 using task_manager::browsertest_util::TaskManagerTesterInterface;
65 using task_manager::browsertest_util::WaitForTaskManagerRows; 66 using task_manager::browsertest_util::WaitForTaskManagerRows;
66 using task_manager::browsertest_util::WaitForTaskManagerStatToExceed; 67 using task_manager::browsertest_util::WaitForTaskManagerStatToExceed;
67 68
68 namespace { 69 namespace {
69 70
70 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 71 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
71 72
72 } // namespace 73 } // namespace
73 74
74 class TaskManagerBrowserTest : public ExtensionBrowserTest { 75 class TaskManagerBrowserTest : public ExtensionBrowserTest {
75 public: 76 public:
76 TaskManagerBrowserTest() {} 77 TaskManagerBrowserTest() {}
77 ~TaskManagerBrowserTest() override {} 78 ~TaskManagerBrowserTest() override {}
78 79
79 TaskManagerModel* model() const { 80 TaskManagerTesterInterface* model() { return model_.get(); }
80 return TaskManager::GetInstance()->model();
81 }
82 81
83 void ShowTaskManager() { 82 void ShowTaskManager() {
84 EXPECT_EQ(0, model()->ResourceCount());
85
86 // Show the task manager. This populates the model, and helps with debugging 83 // Show the task manager. This populates the model, and helps with debugging
87 // (you see the task manager). 84 // (you see the task manager).
88 chrome::ShowTaskManager(browser()); 85 chrome::ShowTaskManager(browser());
86 model_ = task_manager::browsertest_util::GetTaskManagerTester();
89 } 87 }
90 88
91 void HideTaskManager() { 89 void HideTaskManager() {
92 // Hide the task manager, and wait for the model to be depopulated. 90 model_.reset();
91
92 // Hide the task manager, and wait for it to go.
93 chrome::HideTaskManager(); 93 chrome::HideTaskManager();
94 base::RunLoop().RunUntilIdle(); // OnWindowClosed happens asynchronously. 94 base::RunLoop().RunUntilIdle(); // OnWindowClosed happens asynchronously.
95 EXPECT_EQ(0, model()->ResourceCount());
96 } 95 }
97 96
98 void Refresh() { 97 void Refresh() {
99 model()->Refresh(); 98 // Refresh() isn't ever needed on the new task manager.
100 } 99 if (switches::NewTaskManagerEnabled())
101 100 return;
102 int GetUpdateTimeMs() { 101 TaskManager::GetInstance()->model()->Refresh();
103 return TaskManagerModel::kUpdateTimeMs;
104 } 102 }
105 103
106 GURL GetTestURL() { 104 GURL GetTestURL() {
107 return ui_test_utils::GetTestUrl( 105 return ui_test_utils::GetTestUrl(
108 base::FilePath(base::FilePath::kCurrentDirectory), 106 base::FilePath(base::FilePath::kCurrentDirectory),
109 base::FilePath(kTitle1File)); 107 base::FilePath(kTitle1File));
110 } 108 }
111 109
112 int FindResourceIndex(const base::string16& title) { 110 int FindResourceIndex(const base::string16& title) {
113 for (int i = 0; i < model()->ResourceCount(); ++i) { 111 for (int i = 0; i < model_->GetRowCount(); ++i) {
114 if (title == model()->GetResourceTitle(i)) 112 if (title == model_->GetRowTitle(i))
115 return i; 113 return i;
116 } 114 }
117 return -1; 115 return -1;
118 } 116 }
119 117
120 protected: 118 protected:
121 void SetUpCommandLine(base::CommandLine* command_line) override { 119 void SetUpCommandLine(base::CommandLine* command_line) override {
122 ExtensionBrowserTest::SetUpCommandLine(command_line); 120 ExtensionBrowserTest::SetUpCommandLine(command_line);
123 121
124 // These tests are for the old implementation of the task manager. We must
125 // explicitly disable the new one.
126 task_manager::browsertest_util::EnableOldTaskManager();
127
128 // Do not launch device discovery process. 122 // Do not launch device discovery process.
129 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); 123 command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications);
130 } 124 }
131 125
132 private: 126 private:
127 std::unique_ptr<TaskManagerTesterInterface> model_;
133 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest); 128 DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest);
134 }; 129 };
135 130
136 class TaskManagerUtilityProcessBrowserTest : public TaskManagerBrowserTest { 131 class TaskManagerUtilityProcessBrowserTest : public TaskManagerBrowserTest {
137 public: 132 public:
138 TaskManagerUtilityProcessBrowserTest() {} 133 TaskManagerUtilityProcessBrowserTest() {}
139 134
140 protected: 135 protected:
141 void SetUpCommandLine(base::CommandLine* command_line) override { 136 void SetUpCommandLine(base::CommandLine* command_line) override {
142 TaskManagerBrowserTest::SetUpCommandLine(command_line); 137 TaskManagerBrowserTest::SetUpCommandLine(command_line);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 210
216 // Open a new tab and make sure the task manager notices it. 211 // Open a new tab and make sure the task manager notices it.
217 AddTabAtIndex(0, GetTestURL(), ui::PAGE_TRANSITION_TYPED); 212 AddTabAtIndex(0, GetTestURL(), ui::PAGE_TRANSITION_TYPED);
218 213
219 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); 214 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html")));
220 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 215 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab()));
221 216
222 // Killing the tab via task manager should remove the row. 217 // Killing the tab via task manager should remove the row.
223 int tab = FindResourceIndex(MatchTab("title1.html")); 218 int tab = FindResourceIndex(MatchTab("title1.html"));
224 ASSERT_NE(-1, tab); 219 ASSERT_NE(-1, tab);
225 ASSERT_TRUE(model()->GetResourceWebContents(tab) != NULL); 220 ASSERT_NE(-1, model()->GetTabId(tab));
226 ASSERT_TRUE(model()->CanActivate(tab)); 221 model()->Kill(tab);
227 TaskManager::GetInstance()->KillProcess(tab);
228 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); 222 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html")));
229 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 223 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
230 224
231 // Tab should reappear in task manager upon reload. 225 // Tab should reappear in task manager upon reload.
232 chrome::Reload(browser(), CURRENT_TAB); 226 chrome::Reload(browser(), CURRENT_TAB);
233 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); 227 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html")));
234 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 228 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab()));
235 } 229 }
236 230
237 // Test for http://crbug.com/444945, which is not fixed yet. 231 // Test for http://crbug.com/444945, which is not fixed yet.
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 410 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
417 "french_sentence.html"))); 411 "french_sentence.html")));
418 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 412 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
419 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 413 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
420 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 414 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
421 415
422 // Kill the process via the BACKGROUND PAGE (not the panel). Verify that both 416 // Kill the process via the BACKGROUND PAGE (not the panel). Verify that both
423 // the background page and the panel go away from the task manager. 417 // the background page and the panel go away from the task manager.
424 int background_page = FindResourceIndex(MatchExtension("My extension 1")); 418 int background_page = FindResourceIndex(MatchExtension("My extension 1"));
425 ASSERT_NE(-1, background_page); 419 ASSERT_NE(-1, background_page);
426 ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 420 ASSERT_EQ(-1, model()->GetTabId(background_page));
427 ASSERT_FALSE(model()->CanActivate(background_page)); 421 model()->Kill(background_page);
428 TaskManager::GetInstance()->KillProcess(background_page);
429 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 422 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension()));
430 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 423 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
431 } 424 }
432 425
433 // Kills a process that has more than one task manager entry. This test is the 426 // Kills a process that has more than one task manager entry. This test is the
434 // same as KillPanelViaExtensionResource except it does the kill via the other 427 // same as KillPanelViaExtensionResource except it does the kill via the other
435 // entry. 428 // entry.
436 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) { 429 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) {
437 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 430 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good")
438 .AppendASCII("Extensions") 431 .AppendASCII("Extensions")
(...skipping 20 matching lines...) Expand all
459 1, 452 1,
460 MatchExtension( 453 MatchExtension(
461 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 454 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
462 "french_sentence.html"))); 455 "french_sentence.html")));
463 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 456 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
464 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 457 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
465 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 458 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
466 459
467 int background_page = FindResourceIndex(MatchExtension("My extension 1")); 460 int background_page = FindResourceIndex(MatchExtension("My extension 1"));
468 ASSERT_NE(-1, background_page); 461 ASSERT_NE(-1, background_page);
469 ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 462 ASSERT_EQ(-1, model()->GetTabId(background_page));
470 ASSERT_FALSE(model()->CanActivate(background_page));
471 463
472 // Kill the process via the PANEL RESOURCE (not the background page). Verify 464 // Kill the process via the PANEL RESOURCE (not the background page). Verify
473 // that both the background page and the panel go away from the task manager. 465 // that both the background page and the panel go away from the task manager.
474 int panel = FindResourceIndex(MatchExtension( 466 int panel = FindResourceIndex(MatchExtension(
475 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 467 "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/"
476 "french_sentence.html")); 468 "french_sentence.html"));
477 ASSERT_NE(-1, panel); 469 ASSERT_NE(-1, panel);
478 ASSERT_TRUE(model()->GetResourceWebContents(panel) != NULL); 470 ASSERT_NE(-1, model()->GetTabId(panel));
479 ASSERT_TRUE(model()->CanActivate(panel)); 471 model()->Kill(panel);
480 TaskManager::GetInstance()->KillProcess(panel);
481 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 472 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension()));
482 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 473 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
483 } 474 }
484 475
485 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) { 476 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) {
486 ShowTaskManager(); 477 ShowTaskManager();
487 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 478 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
488 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 479 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
489 480
490 ASSERT_TRUE(LoadExtension( 481 ASSERT_TRUE(LoadExtension(
(...skipping 15 matching lines...) Expand all
506 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 497 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED);
507 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar"))); 498 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar")));
508 ASSERT_NO_FATAL_FAILURE( 499 ASSERT_NO_FATAL_FAILURE(
509 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 500 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
510 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 501 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
511 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 502 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
512 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 503 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
513 504
514 int extension_tab = FindResourceIndex(MatchExtension("Foobar")); 505 int extension_tab = FindResourceIndex(MatchExtension("Foobar"));
515 ASSERT_NE(-1, extension_tab); 506 ASSERT_NE(-1, extension_tab);
516 ASSERT_TRUE(model()->GetResourceWebContents(extension_tab) != NULL); 507 ASSERT_NE(-1, model()->GetTabId(extension_tab));
517 ASSERT_TRUE(model()->CanActivate(extension_tab));
518 508
519 int background_page = FindResourceIndex(MatchExtension("My extension 1")); 509 int background_page = FindResourceIndex(MatchExtension("My extension 1"));
520 ASSERT_NE(-1, background_page); 510 ASSERT_NE(-1, background_page);
521 ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 511 ASSERT_EQ(-1, model()->GetTabId(background_page));
522 ASSERT_FALSE(model()->CanActivate(background_page));
523 } 512 }
524 513
525 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTab) { 514 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTab) {
526 // With the task manager closed, open a new tab to an extension URL. 515 // With the task manager closed, open a new tab to an extension URL.
527 // Afterwards, when we open the task manager, the third entry (background 516 // Afterwards, when we open the task manager, the third entry (background
528 // page) should be an extension resource whose title starts with "Extension:". 517 // page) should be an extension resource whose title starts with "Extension:".
529 // The fourth entry (page.html) is also of type extension and has both a 518 // The fourth entry (page.html) is also of type extension and has both a
530 // WebContents and an extension. The title should start with "Extension:". 519 // WebContents and an extension. The title should start with "Extension:".
531 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 520 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good")
532 .AppendASCII("Extensions") 521 .AppendASCII("Extensions")
533 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 522 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
534 .AppendASCII("1.0.0.0"))); 523 .AppendASCII("1.0.0.0")));
535 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); 524 GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html");
536 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 525 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED);
537 526
538 ShowTaskManager(); 527 ShowTaskManager();
539 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar"))); 528 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar")));
540 ASSERT_NO_FATAL_FAILURE( 529 ASSERT_NO_FATAL_FAILURE(
541 WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 530 WaitForTaskManagerRows(1, MatchExtension("My extension 1")));
542 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 531 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension()));
543 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 532 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
544 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 533 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
545 534
546 int extension_tab = FindResourceIndex(MatchExtension("Foobar")); 535 int extension_tab = FindResourceIndex(MatchExtension("Foobar"));
547 ASSERT_NE(-1, extension_tab); 536 ASSERT_NE(-1, extension_tab);
548 ASSERT_TRUE(model()->GetResourceWebContents(extension_tab) != NULL); 537 ASSERT_NE(-1, model()->GetTabId(extension_tab));
549 ASSERT_TRUE(model()->CanActivate(extension_tab));
550 538
551 int background_page = FindResourceIndex(MatchExtension("My extension 1")); 539 int background_page = FindResourceIndex(MatchExtension("My extension 1"));
552 ASSERT_NE(-1, background_page); 540 ASSERT_NE(-1, background_page);
553 ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 541 ASSERT_EQ(-1, model()->GetTabId(background_page));
554 ASSERT_FALSE(model()->CanActivate(background_page));
555 } 542 }
556 543
557 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabChanges) { 544 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabChanges) {
558 ShowTaskManager(); 545 ShowTaskManager();
559 546
560 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("packaged_app"))); 547 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("packaged_app")));
561 ExtensionService* service = extensions::ExtensionSystem::Get( 548 ExtensionService* service = extensions::ExtensionSystem::Get(
562 browser()->profile())->extension_service(); 549 browser()->profile())->extension_service();
563 const extensions::Extension* extension = 550 const extensions::Extension* extension =
564 service->GetExtensionById(last_loaded_extension_id(), false); 551 service->GetExtensionById(last_loaded_extension_id(), false);
(...skipping 12 matching lines...) Expand all
577 WaitForTaskManagerRows(1, MatchApp("Packaged App Test"))); 564 WaitForTaskManagerRows(1, MatchApp("Packaged App Test")));
578 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); 565 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp()));
579 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 566 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
580 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 567 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
581 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 568 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension()));
582 569
583 // Check that the third entry (main.html) is of type extension and has both 570 // Check that the third entry (main.html) is of type extension and has both
584 // a tab contents and an extension. 571 // a tab contents and an extension.
585 int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); 572 int app_tab = FindResourceIndex(MatchApp("Packaged App Test"));
586 ASSERT_NE(-1, app_tab); 573 ASSERT_NE(-1, app_tab);
587 ASSERT_TRUE(model()->GetResourceWebContents(app_tab) != NULL); 574 ASSERT_NE(-1, model()->GetTabId(app_tab));
588 ASSERT_TRUE(model()->CanActivate(app_tab));
589 ASSERT_EQ(task_manager::Resource::EXTENSION,
590 model()->GetResourceType(app_tab));
591 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 575 ASSERT_EQ(2, browser()->tab_strip_model()->count());
592 576
593 // Unload extension to make sure the tab goes away. 577 // Unload extension to make sure the tab goes away.
594 UnloadExtension(last_loaded_extension_id()); 578 UnloadExtension(last_loaded_extension_id());
595 579
596 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 580 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
597 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); 581 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp()));
598 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 582 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension()));
599 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 583 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab()));
600 ASSERT_EQ(1, browser()->tab_strip_model()->count()); 584 ASSERT_EQ(1, browser()->tab_strip_model()->count());
(...skipping 16 matching lines...) Expand all
617 ASSERT_NO_FATAL_FAILURE( 601 ASSERT_NO_FATAL_FAILURE(
618 WaitForTaskManagerRows(1, MatchApp("Packaged App Test"))); 602 WaitForTaskManagerRows(1, MatchApp("Packaged App Test")));
619 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 603 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
620 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 604 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension()));
621 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); 605 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp()));
622 606
623 // Check that the third entry (main.html) is of type extension and has both 607 // Check that the third entry (main.html) is of type extension and has both
624 // a tab contents and an extension. 608 // a tab contents and an extension.
625 int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); 609 int app_tab = FindResourceIndex(MatchApp("Packaged App Test"));
626 ASSERT_NE(-1, app_tab); 610 ASSERT_NE(-1, app_tab);
627 ASSERT_TRUE(model()->GetResourceWebContents(app_tab) != NULL); 611 ASSERT_NE(-1, model()->GetTabId(app_tab));
628 ASSERT_TRUE(model()->CanActivate(app_tab));
629 ASSERT_EQ(task_manager::Resource::EXTENSION,
630 model()->GetResourceType(app_tab));
631 } 612 }
632 613
633 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabChanges) { 614 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabChanges) {
634 ShowTaskManager(); 615 ShowTaskManager();
635 616
636 // The app under test acts on URLs whose host is "localhost", 617 // The app under test acts on URLs whose host is "localhost",
637 // so the URLs we navigate to must have host "localhost". 618 // so the URLs we navigate to must have host "localhost".
638 host_resolver()->AddRule("*", "127.0.0.1"); 619 host_resolver()->AddRule("*", "127.0.0.1");
639 ASSERT_TRUE(embedded_test_server()->Start()); 620 ASSERT_TRUE(embedded_test_server()->Start());
640 GURL::Replacements replace_host; 621 GURL::Replacements replace_host;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 std::string extension_id = last_loaded_extension_id(); 761 std::string extension_id = last_loaded_extension_id();
781 for (int i = 1; i <= 5; i++) { 762 for (int i = 1; i <= 5; i++) {
782 SCOPED_TRACE(testing::Message() << "Reloading extension for the " << i 763 SCOPED_TRACE(testing::Message() << "Reloading extension for the " << i
783 << "th time."); 764 << "th time.");
784 ReloadExtension(extension_id); 765 ReloadExtension(extension_id);
785 ASSERT_NO_FATAL_FAILURE( 766 ASSERT_NO_FATAL_FAILURE(
786 WaitForTaskManagerRows(1, MatchExtension("background_page"))); 767 WaitForTaskManagerRows(1, MatchExtension("background_page")));
787 } 768 }
788 } 769 }
789 770
790 // Crashy, http://crbug.com/42301.
791 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
792 DISABLED_PopulateWebCacheFields) {
793 ShowTaskManager();
794 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
795
796 int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
797
798 // Open a new tab and make sure we notice that.
799 AddTabAtIndex(0, GetTestURL(), ui::PAGE_TRANSITION_TYPED);
800 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab()));
801
802 // Check that we get some value for the cache columns.
803 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(resource_count),
804 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
805 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(resource_count),
806 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
807 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(resource_count),
808 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
809 }
810
811 // Checks that task manager counts a worker thread JS heap size. 771 // Checks that task manager counts a worker thread JS heap size.
812 // http://crbug.com/241066 772 // http://crbug.com/241066
813 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, WebWorkerJSHeapMemory) { 773 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, WebWorkerJSHeapMemory) {
814 ShowTaskManager(); 774 ShowTaskManager();
815 ui_test_utils::NavigateToURL(browser(), GetTestURL()); 775 ui_test_utils::NavigateToURL(browser(), GetTestURL());
816 size_t minimal_heap_size = 4 * 1024 * 1024 * sizeof(void*); 776 size_t minimal_heap_size = 4 * 1024 * 1024 * sizeof(void*);
817 std::string test_js = base::StringPrintf( 777 std::string test_js = base::StringPrintf(
818 "var blob = new Blob([\n" 778 "var blob = new Blob([\n"
819 " 'mem = new Array(%lu);',\n" 779 " 'mem = new Array(%lu);',\n"
820 " 'for (var i = 0; i < mem.length; i += 16)'," 780 " 'for (var i = 0; i < mem.length; i += 16)',"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 if (!ShouldExpectSubframes()) { 914 if (!ShouldExpectSubframes()) {
955 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 915 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
956 } else { 916 } else {
957 ASSERT_NO_FATAL_FAILURE( 917 ASSERT_NO_FATAL_FAILURE(
958 WaitForTaskManagerRows(1, MatchSubframe("http://b.com/"))); 918 WaitForTaskManagerRows(1, MatchSubframe("http://b.com/")));
959 ASSERT_NO_FATAL_FAILURE( 919 ASSERT_NO_FATAL_FAILURE(
960 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); 920 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/")));
961 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe())); 921 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnySubframe()));
962 int subframe_b = FindResourceIndex(MatchSubframe("http://b.com/")); 922 int subframe_b = FindResourceIndex(MatchSubframe("http://b.com/"));
963 ASSERT_NE(-1, subframe_b); 923 ASSERT_NE(-1, subframe_b);
964 ASSERT_TRUE(model()->GetResourceWebContents(subframe_b) != NULL); 924 ASSERT_NE(-1, model()->GetTabId(subframe_b));
965 ASSERT_TRUE(model()->CanActivate(subframe_b));
966 925
967 TaskManager::GetInstance()->KillProcess(subframe_b); 926 model()->Kill(subframe_b);
968 927
969 ASSERT_NO_FATAL_FAILURE( 928 ASSERT_NO_FATAL_FAILURE(
970 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); 929 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/")));
971 ASSERT_NO_FATAL_FAILURE( 930 ASSERT_NO_FATAL_FAILURE(
972 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); 931 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/")));
973 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); 932 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe()));
974 ASSERT_NO_FATAL_FAILURE( 933 ASSERT_NO_FATAL_FAILURE(
975 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); 934 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test")));
976 } 935 }
977 936
978 HideTaskManager(); 937 HideTaskManager();
979 ShowTaskManager(); 938 ShowTaskManager();
980 939
981 if (!ShouldExpectSubframes()) { 940 if (!ShouldExpectSubframes()) {
982 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 941 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
983 } else { 942 } else {
984 ASSERT_NO_FATAL_FAILURE( 943 ASSERT_NO_FATAL_FAILURE(
985 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); 944 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/")));
986 ASSERT_NO_FATAL_FAILURE( 945 ASSERT_NO_FATAL_FAILURE(
987 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); 946 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/")));
988 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); 947 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe()));
989 ASSERT_NO_FATAL_FAILURE( 948 ASSERT_NO_FATAL_FAILURE(
990 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test"))); 949 WaitForTaskManagerRows(1, MatchTab("cross-site iframe test")));
991 } 950 }
992 } 951 }
993 952
994 // Tests what happens when a tab navigates to a site (a.com) that it previously 953 // Tests what happens when a tab navigates to a site (a.com) that it previously
995 // has a cross-process subframe into (b.com). 954 // has a cross-process subframe into (b.com).
996 // 955 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, NavigateToSubframeProcess) {
997 // TODO(nick): http://crbug.com/442532. Disabled because the second navigation
998 // hits an ASSERT(frame()) in WebLocalFrameImpl::loadRequest under --site-per-
999 // process.
1000 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest,
1001 DISABLED_NavigateToSubframeProcess) {
1002 ShowTaskManager(); 956 ShowTaskManager();
1003 957
1004 host_resolver()->AddRule("*", "127.0.0.1"); 958 host_resolver()->AddRule("*", "127.0.0.1");
1005 ASSERT_TRUE(embedded_test_server()->Start()); 959 ASSERT_TRUE(embedded_test_server()->Start());
1006 content::SetupCrossSiteRedirector(embedded_test_server()); 960 content::SetupCrossSiteRedirector(embedded_test_server());
1007 961
1008 // Navigate the tab to a page on a.com with cross-process subframes to 962 // Navigate the tab to a page on a.com with cross-process subframes to
1009 // b.com and c.com. 963 // b.com and c.com.
1010 GURL a_dotcom(embedded_test_server()->GetURL( 964 GURL a_dotcom(embedded_test_server()->GetURL(
1011 "/cross-site/a.com/iframe_cross_site.html")); 965 "/cross-site/a.com/iframe_cross_site.html"));
(...skipping 27 matching lines...) Expand all
1039 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); 993 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test")));
1040 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 994 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
1041 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 995 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
1042 HideTaskManager(); 996 HideTaskManager();
1043 ShowTaskManager(); 997 ShowTaskManager();
1044 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test"))); 998 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("iframe test")));
1045 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 999 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
1046 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 1000 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
1047 } 1001 }
1048 1002
1049 // TODO(nick): Fails flakily under OOPIF due to a ASSERT_NOT_REACHED in
1050 // WebRemoteFrame, at least under debug OSX. http://crbug.com/437956
1051 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, 1003 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest,
1052 DISABLED_NavigateToSiteWithSubframeToOriginalSite) { 1004 NavigateToSiteWithSubframeToOriginalSite) {
1053 ShowTaskManager(); 1005 ShowTaskManager();
1054 1006
1055 host_resolver()->AddRule("*", "127.0.0.1"); 1007 host_resolver()->AddRule("*", "127.0.0.1");
1056 ASSERT_TRUE(embedded_test_server()->Start()); 1008 ASSERT_TRUE(embedded_test_server()->Start());
1057 content::SetupCrossSiteRedirector(embedded_test_server()); 1009 content::SetupCrossSiteRedirector(embedded_test_server());
1058 1010
1059 // Navigate to a page on b.com with a simple (same-site) iframe. 1011 // Navigate to a page on b.com with a simple (same-site) iframe.
1060 // This should not show any subframe resources in the task manager. 1012 // This should not show any subframe resources in the task manager.
1061 GURL b_dotcom( 1013 GURL b_dotcom(
1062 embedded_test_server()->GetURL("/cross-site/b.com/iframe.html")); 1014 embedded_test_server()->GetURL("/cross-site/b.com/iframe.html"));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 ASSERT_NO_FATAL_FAILURE( 1117 ASSERT_NO_FATAL_FAILURE(
1166 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); 1118 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/")));
1167 ASSERT_NO_FATAL_FAILURE( 1119 ASSERT_NO_FATAL_FAILURE(
1168 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); 1120 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/")));
1169 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); 1121 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe()));
1170 } 1122 }
1171 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); 1123 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac")));
1172 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 1124 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
1173 } 1125 }
1174 1126
1175 // Tests what happens when a tab does a same-site navigation away from a page
1176 // with cross-site iframes.
1177 // Flaky on Windows. http://crbug.com/528282.
1178 #if defined(OS_WIN)
1179 #define MAYBE_LeavePageWithCrossSiteIframes DISABLED_LeavePageWithCrossSiteIfram es
1180 #else
1181 #define MAYBE_LeavePageWithCrossSiteIframes LeavePageWithCrossSiteIframes
1182 #endif
1183 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest, 1127 IN_PROC_BROWSER_TEST_P(TaskManagerOOPIFBrowserTest,
1184 MAYBE_LeavePageWithCrossSiteIframes) { 1128 LeavePageWithCrossSiteIframes) {
1185 ShowTaskManager(); 1129 ShowTaskManager();
1186 1130
1187 host_resolver()->AddRule("*", "127.0.0.1"); 1131 host_resolver()->AddRule("*", "127.0.0.1");
1188 ASSERT_TRUE(embedded_test_server()->Start()); 1132 ASSERT_TRUE(embedded_test_server()->Start());
1189 content::SetupCrossSiteRedirector(embedded_test_server()); 1133 content::SetupCrossSiteRedirector(embedded_test_server());
1190 1134
1191 // Navigate the tab to a page on a.com with cross-process subframes. 1135 // Navigate the tab to a page on a.com with cross-process subframes.
1192 GURL a_dotcom_with_iframes(embedded_test_server()->GetURL( 1136 GURL a_dotcom_with_iframes(embedded_test_server()->GetURL(
1193 "/cross-site/a.com/iframe_cross_site.html")); 1137 "/cross-site/a.com/iframe_cross_site.html"));
1194 browser()->OpenURL(content::OpenURLParams(a_dotcom_with_iframes, 1138 browser()->OpenURL(content::OpenURLParams(a_dotcom_with_iframes,
(...skipping 25 matching lines...) Expand all
1220 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); 1164 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness")));
1221 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 1165 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
1222 1166
1223 HideTaskManager(); 1167 HideTaskManager();
1224 ShowTaskManager(); 1168 ShowTaskManager();
1225 1169
1226 ASSERT_NO_FATAL_FAILURE( 1170 ASSERT_NO_FATAL_FAILURE(
1227 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness"))); 1171 WaitForTaskManagerRows(1, MatchTab("Title Of Awesomeness")));
1228 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe())); 1172 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnySubframe()));
1229 } 1173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698