diff options
Diffstat (limited to 'chrome')
9 files changed, 735 insertions, 396 deletions
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc index be91b77..a487f26 100644 --- a/chrome/browser/prerender/prerender_browsertest.cc +++ b/chrome/browser/prerender/prerender_browsertest.cc @@ -101,6 +101,7 @@ using content::RenderWidgetHost; using content::TestNavigationObserver; using content::WebContents; using content::WebContentsObserver; +using task_manager::browsertest_util::WaitForTaskManagerRows; // Prerender tests work as follows: // @@ -1459,6 +1460,18 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest { base::string16(), base::ASCIIToUTF16(javascript)); } + // Returns a string for pattern-matching TaskManager tab entries. + base::string16 MatchTaskManagerTab(const char* page_title) { + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, + base::ASCIIToUTF16(page_title)); + } + + // Returns a string for pattern-matching TaskManager prerender entries. + base::string16 MatchTaskManagerPrerender(const char* page_title) { + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, + base::ASCIIToUTF16(page_title)); + } + protected: bool autostart_test_server_; @@ -2401,68 +2414,93 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderAbortPendingOnCancel) { EXPECT_TRUE(IsEmptyPrerenderLinkManager()); } -IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderTaskManager) { +IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, OpenTaskManagerBeforePrerender) { + const base::string16 any_prerender = MatchTaskManagerPrerender("*"); + const base::string16 any_tab = MatchTaskManagerTab("*"); + const base::string16 original = MatchTaskManagerTab("Preloader"); + const base::string16 prerender = MatchTaskManagerPrerender("Prerender Page"); + const base::string16 final = MatchTaskManagerTab("Prerender Page"); + // Show the task manager. This populates the model. chrome::OpenTaskManager(current_browser()); - // Wait for the model of task manager to start. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_tab)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, any_prerender)); + + // Prerender a page in addition to the original tab. + PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); + + // A TaskManager entry should appear like "Prerender: Prerender Page" + // alongside the original tab entry. There should be just these two entries. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, prerender)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, original)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, final)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_prerender)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_tab)); + + // Swap in the prerendered content. + NavigateToDestURL(); + + // The "Prerender: " TaskManager entry should disappear, being replaced by a + // "Tab: Prerender Page" entry, and nothing else. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, prerender)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, original)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, final)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_tab)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, any_prerender)); +} + +IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, OpenTaskManagerAfterPrerender) { + const base::string16 any_prerender = MatchTaskManagerPrerender("*"); + const base::string16 any_tab = MatchTaskManagerTab("*"); + const base::string16 original = MatchTaskManagerTab("Preloader"); + const base::string16 prerender = MatchTaskManagerPrerender("Prerender Page"); + const base::string16 final = MatchTaskManagerTab("Prerender Page"); // Start with two resources. PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); - // One of the resources that has a WebContents associated with it should have - // the Prerender prefix. - const base::string16 prefix = - l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PRERENDER_PREFIX, - base::string16()); - base::string16 prerender_title; - int num_prerender_tabs = 0; - - TaskManagerModel* model = GetModel(); - // The task manager caches values. Force the titles to be fresh. - model->Refresh(); - for (int i = 0; i < model->ResourceCount(); ++i) { - if (model->GetResourceWebContents(i)) { - prerender_title = model->GetResourceTitle(i); - if (StartsWith(prerender_title, prefix, true)) - ++num_prerender_tabs; - } - } - EXPECT_EQ(1, num_prerender_tabs); - const base::string16 prerender_page_title = - prerender_title.substr(prefix.length()); + // Show the task manager. This populates the model. Importantly, we're doing + // this after the prerender WebContents already exists - the task manager + // needs to find it, it can't just listen for creation. + chrome::OpenTaskManager(current_browser()); + // A TaskManager entry should appear like "Prerender: Prerender Page" + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, prerender)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, original)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, final)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_prerender)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_tab)); + + // Swap in the tab. NavigateToDestURL(); - // There should be no tabs with the Prerender prefix. - const base::string16 tab_prefix = - l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, base::string16()); - num_prerender_tabs = 0; - int num_tabs_with_prerender_page_title = 0; - model->Refresh(); - for (int i = 0; i < model->ResourceCount(); ++i) { - if (model->GetResourceWebContents(i)) { - base::string16 tab_title = model->GetResourceTitle(i); - if (StartsWith(tab_title, prefix, true)) { - ++num_prerender_tabs; - } else { - EXPECT_TRUE(StartsWith(tab_title, tab_prefix, true)); - - // The prerender tab should now be a normal tab but the title should be - // the same. Depending on timing, there may be more than one of these. - const base::string16 tab_page_title = - tab_title.substr(tab_prefix.length()); - if (prerender_page_title.compare(tab_page_title) == 0) - ++num_tabs_with_prerender_page_title; - } - } - } - EXPECT_EQ(0, num_prerender_tabs); + // The "Prerender: Prerender Page" TaskManager row should disappear, being + // replaced by "Tab: Prerender Page" + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, prerender)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, original)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, final)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_tab)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, any_prerender)); +} + +IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, OpenTaskManagerAfterSwapIn) { + const base::string16 any_prerender = MatchTaskManagerPrerender("*"); + const base::string16 any_tab = MatchTaskManagerTab("*"); + const base::string16 final = MatchTaskManagerTab("Prerender Page"); + + // Prerender, and swap it in. + PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); + NavigateToDestURL(); + + // Show the task manager. This populates the model. Importantly, we're doing + // this after the prerender has been swapped in. + chrome::OpenTaskManager(current_browser()); - // We may have deleted the prerender tab, but the swapped in tab should be - // active. - EXPECT_GE(num_tabs_with_prerender_page_title, 1); - EXPECT_LE(num_tabs_with_prerender_page_title, 2); + // We should not see a prerender resource in the task manager, just a normal + // page. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, final)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, any_tab)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, any_prerender)); } // Checks that audio loads are deferred on prerendering. diff --git a/chrome/browser/task_manager/extension_process_resource_provider.cc b/chrome/browser/task_manager/extension_process_resource_provider.cc index 247833b..b14f4e2 100644 --- a/chrome/browser/task_manager/extension_process_resource_provider.cc +++ b/chrome/browser/task_manager/extension_process_resource_provider.cc @@ -300,17 +300,12 @@ bool ExtensionProcessResourceProvider:: if (web_contents->GetRenderProcessHost()->IsGuest()) return false; extensions::ViewType view_type = extensions::GetViewType(web_contents); - // Don't add WebContents (those are handled by - // TabContentsResourceProvider) or background contents (handled - // by BackgroundResourceProvider). -#if defined(USE_ASH) - return (view_type != extensions::VIEW_TYPE_TAB_CONTENTS && - view_type != extensions::VIEW_TYPE_BACKGROUND_CONTENTS); -#else + // Don't add tab contents (those are handled by TabContentsResourceProvider) + // or background contents (handled by BackgroundResourceProvider) or panels + // (handled by PanelResourceProvider) return (view_type != extensions::VIEW_TYPE_TAB_CONTENTS && view_type != extensions::VIEW_TYPE_BACKGROUND_CONTENTS && view_type != extensions::VIEW_TYPE_PANEL); -#endif // USE_ASH } void ExtensionProcessResourceProvider::AddToTaskManager( @@ -318,10 +313,10 @@ void ExtensionProcessResourceProvider::AddToTaskManager( if (!IsHandledByThisProvider(render_view_host)) return; + if (resources_.count(render_view_host)) + return; ExtensionProcessResource* resource = new ExtensionProcessResource(render_view_host); - if (resources_.find(render_view_host) != resources_.end()) - return; resources_[render_view_host] = resource; task_manager_->AddResource(resource); } diff --git a/chrome/browser/task_manager/notification_resource_provider.cc b/chrome/browser/task_manager/notification_resource_provider.cc index 0b317c5..7aaad2c 100644 --- a/chrome/browser/task_manager/notification_resource_provider.cc +++ b/chrome/browser/task_manager/notification_resource_provider.cc @@ -205,8 +205,11 @@ void NotificationResourceProvider::Observe( void NotificationResourceProvider::AddToTaskManager( BalloonHost* balloon_host) { + // The resource may already be tracked, if the task manager was opened + // while the BalloonHost was waiting to connect. + if (resources_.count(balloon_host)) + return; NotificationResource* resource = new NotificationResource(balloon_host); - DCHECK(resources_.find(balloon_host) == resources_.end()); resources_[balloon_host] = resource; task_manager_->AddResource(resource); } diff --git a/chrome/browser/task_manager/task_manager.h b/chrome/browser/task_manager/task_manager.h index dd042fc..45a76d5 100644 --- a/chrome/browser/task_manager/task_manager.h +++ b/chrome/browser/task_manager/task_manager.h @@ -336,7 +336,7 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> { private: friend class base::RefCountedThreadSafe<TaskManagerModel>; - friend class TaskManagerNoShowBrowserTest; + friend class TaskManagerBrowserTest; FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); FRIEND_TEST_ALL_PREFIXES(TaskManagerWindowControllerTest, diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 2b24a20..a16f058 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -46,14 +46,7 @@ #include "ui/base/l10n/l10n_util.h" using content::WebContents; - -// On Linux this is crashing intermittently http://crbug/84719 -// In some environments this test fails about 1/6 http://crbug/84850 -#if defined(OS_LINUX) -#define MAYBE_KillExtension DISABLED_KillExtension -#else -#define MAYBE_KillExtension KillExtension -#endif +using task_manager::browsertest_util::WaitForTaskManagerRows; namespace { @@ -61,10 +54,10 @@ const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); } // namespace -class TaskManagerNoShowBrowserTest : public ExtensionBrowserTest { +class TaskManagerBrowserTest : public ExtensionBrowserTest { public: - TaskManagerNoShowBrowserTest() {} - virtual ~TaskManagerNoShowBrowserTest() {} + TaskManagerBrowserTest() {} + virtual ~TaskManagerBrowserTest() {} TaskManagerModel* model() const { return TaskManager::GetInstance()->model(); @@ -76,9 +69,6 @@ class TaskManagerNoShowBrowserTest : public ExtensionBrowserTest { // Show the task manager. This populates the model, and helps with debugging // (you see the task manager). chrome::ShowTaskManager(browser()); - - // New Tab Page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); } void Refresh() { @@ -89,31 +79,49 @@ class TaskManagerNoShowBrowserTest : public ExtensionBrowserTest { return TaskManagerModel::kUpdateTimeMs; } - protected: - virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { - ExtensionBrowserTest::SetUpCommandLine(command_line); + GURL GetTestURL() { + return ui_test_utils::GetTestUrl( + base::FilePath(base::FilePath::kCurrentDirectory), + base::FilePath(kTitle1File)); + } - // Do not launch the GPU process as the GPU process will show up in task - // manager but whether it appears before or after the new tab renderer - // process is not well defined. - command_line->AppendSwitch(switches::kDisableGpu); + base::string16 MatchTab(const char* title) { + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_TAB_PREFIX, + base::ASCIIToUTF16(title)); + } - // Do not launch device discovery process. - command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); + base::string16 MatchAnyTab() { return MatchTab("*"); } + + base::string16 MatchAboutBlankTab() { return MatchTab("about:blank"); } + + base::string16 MatchExtension(const char* title) { + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_EXTENSION_PREFIX, + base::ASCIIToUTF16(title)); } - private: - DISALLOW_COPY_AND_ASSIGN(TaskManagerNoShowBrowserTest); -}; + base::string16 MatchAnyExtension() { return MatchExtension("*"); } -class TaskManagerBrowserTest : public TaskManagerNoShowBrowserTest { - public: - TaskManagerBrowserTest() {} - virtual ~TaskManagerBrowserTest() {} + base::string16 MatchApp(const char* title) { + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_APP_PREFIX, + base::ASCIIToUTF16(title)); + } - virtual void SetUpOnMainThread() OVERRIDE { - TaskManagerNoShowBrowserTest::SetUpOnMainThread(); - TaskManagerNoShowBrowserTest::ShowTaskManager(); + base::string16 MatchAnyApp() { return MatchApp("*"); } + + int FindResourceIndex(const base::string16& title) { + for (int i = 0; i < model()->ResourceCount(); ++i) { + if (title == model()->GetResourceTitle(i)) + return i; + } + return -1; + } + + protected: + virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { + ExtensionBrowserTest::SetUpCommandLine(command_line); + + // Do not launch device discovery process. + command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); } private: @@ -128,48 +136,35 @@ class TaskManagerBrowserTest : public TaskManagerNoShowBrowserTest { // Regression test for http://crbug.com/13361 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) { - // Showing task manager handled by SetUp. + ShowTaskManager(); } IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { - int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); - // Open a new tab and make sure we notice that. - GURL url(ui_test_utils::GetTestUrl(base::FilePath( - base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); - AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); + + // Open a new tab and make sure the task manager notices it. + AddTabAtIndex(0, GetTestURL(), content::PAGE_TRANSITION_TYPED); - // Check that the last entry is a tab contents resource whose title starts - // starts with "Tab:". - ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL); - base::string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_TAB_PREFIX, base::string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), prefix, - true)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); // Close the tab and verify that we notice. browser()->tab_strip_model()->CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); } -#if defined(USE_ASH) -// This test fails on Ash because task manager treats view type -// Panels differently for Ash. -#define MAYBE_NoticePanelChanges DISABLED_NoticePanelChanges -#else -#define MAYBE_NoticePanelChanges NoticePanelChanges -#endif -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) { +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("good").AppendASCII("Extensions") .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") .AppendASCII("1.0.0.0"))); - // Browser, the New Tab Page and Extension background page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); - - // Open a new panel to an extension url and make sure we notice that. + // Open a new panel to an extension url. GURL url( "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); Panel* panel = PanelManager::GetInstance()->CreatePanel( @@ -179,34 +174,37 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) { url, gfx::Rect(300, 400), PanelManager::CREATE_AS_DOCKED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); - // Check that the fourth entry is a resource with the panel's web contents - // and whose title starts with "Extension:". - ASSERT_EQ(panel->GetWebContents(), model()->GetResourceWebContents(3)); - base::string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_EXTENSION_PREFIX, base::string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(3), prefix, true)); + // Make sure that a task manager model created after the panel shows the + // existence of the panel and the extension. + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( + 1, + MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); // Close the panel and verify that we notice. panel->Close(); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); - - // Unload extension to avoid crash on Windows. - UnloadExtension(last_loaded_extension_id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( + 0, + MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"))); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); } -#if defined(USE_ASH) || defined(OS_WIN) -// This test fails on Ash because task manager treats view type -// Panels differently for Ash. -// This test also fails on Windows, win_rel trybot. http://crbug.com/166322 -#define MAYBE_KillPanelExtension DISABLED_KillPanelExtension -#else -#define MAYBE_KillPanelExtension KillPanelExtension -#endif -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { - int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanelChanges) { + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("good").AppendASCII("Extensions") @@ -214,11 +212,61 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { .AppendASCII("1.0.0.0"))); // Browser, the New Tab Page and Extension background page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); // Open a new panel to an extension url and make sure we notice that. GURL url( "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); + Panel* panel = PanelManager::GetInstance()->CreatePanel( + web_app::GenerateApplicationNameFromExtensionId( + last_loaded_extension_id()), + browser()->profile(), + url, + gfx::Rect(300, 400), + PanelManager::CREATE_AS_DOCKED); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( + 1, + MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + + // Close the panel and verify that we notice. + panel->Close(); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( + 0, + MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"))); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + + // Unload extension. + UnloadExtension(last_loaded_extension_id()); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); +} + +// Kills a process that has more than one task manager entry. +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaExtensionResource) { + ShowTaskManager(); + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") + .AppendASCII("Extensions") + .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") + .AppendASCII("1.0.0.0"))); + + // Open a new panel to an extension url. + GURL url( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"); PanelManager::GetInstance()->CreatePanel( web_app::GenerateApplicationNameFromExtensionId( last_loaded_extension_id()), @@ -226,57 +274,199 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) { url, gfx::Rect(300, 400), PanelManager::CREATE_AS_DOCKED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); - // Kill the panel extension process and verify that it disappears from the - // model along with its panel. - ASSERT_TRUE(model()->IsBackgroundResource(resource_count)); - TaskManager::GetInstance()->KillProcess(resource_count); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( + 1, + MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + + // Kill the process via the BACKGROUND PAGE (not the panel). Verify that both + // the background page and the panel go away from the task manager. + int background_page = FindResourceIndex(MatchExtension("My extension 1")); + ASSERT_NE(-1, background_page); + ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); + ASSERT_FALSE(model()->CanActivate(background_page)); + TaskManager::GetInstance()->KillProcess(background_page); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); } -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) { - int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); +// Kills a process that has more than one task manager entry. This test is the +// same as KillPanelViaExtensionResource except it does the kill via the other +// entry. +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) { + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") + .AppendASCII("Extensions") + .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") + .AppendASCII("1.0.0.0"))); + + // Open a new panel to an extension url. + GURL url( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"); + PanelManager::GetInstance()->CreatePanel( + web_app::GenerateApplicationNameFromExtensionId( + last_loaded_extension_id()), + browser()->profile(), + url, + gfx::Rect(300, 400), + PanelManager::CREATE_AS_DOCKED); + + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( + 1, + MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + + int background_page = FindResourceIndex(MatchExtension("My extension 1")); + ASSERT_NE(-1, background_page); + ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); + ASSERT_FALSE(model()->CanActivate(background_page)); + + // Kill the process via the PANEL RESOURCE (not the background page). Verify + // that both the background page and the panel go away from the task manager. + int panel = FindResourceIndex(MatchExtension( + "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" + "french_sentence.html")); + ASSERT_NE(-1, panel); + ASSERT_TRUE(model()->GetResourceWebContents(panel) != NULL); + ASSERT_TRUE(model()->CanActivate(panel)); + TaskManager::GetInstance()->KillProcess(panel); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); +} + +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) { + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("good").AppendASCII("Extensions") .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") .AppendASCII("1.0.0.0"))); // Browser, Extension background page, and the New Tab Page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + + // Open a new tab to an extension URL. Afterwards, the third entry (background + // page) should be an extension resource whose title starts with "Extension:". + // The fourth entry (page.html) is also of type extension and has both a + // WebContents and an extension. The title should start with "Extension:". + GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); + AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar"))); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + + int extension_tab = FindResourceIndex(MatchExtension("Foobar")); + ASSERT_NE(-1, extension_tab); + ASSERT_TRUE(model()->GetResourceWebContents(extension_tab) != NULL); + ASSERT_TRUE(model()->CanActivate(extension_tab)); + + int background_page = FindResourceIndex(MatchExtension("My extension 1")); + ASSERT_NE(-1, background_page); + ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); + ASSERT_FALSE(model()->CanActivate(background_page)); +} - // Open a new tab to an extension URL and make sure we notice that. +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTab) { + // With the task manager closed, open a new tab to an extension URL. + // Afterwards, when we open the task manager, the third entry (background + // page) should be an extension resource whose title starts with "Extension:". + // The fourth entry (page.html) is also of type extension and has both a + // WebContents and an extension. The title should start with "Extension:". + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") + .AppendASCII("Extensions") + .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") + .AppendASCII("1.0.0.0"))); GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); - - // Check that the third entry (background) is an extension resource whose - // title starts with "Extension:". - ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( - resource_count)); - ASSERT_TRUE(model()->GetResourceWebContents(resource_count) == NULL); - ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL); - base::string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_EXTENSION_PREFIX, base::string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), - prefix, true)); - - // Check that the fourth entry (page.html) is of type extension and has both - // a tab contents and an extension. The title should start with "Extension:". - ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( - resource_count + 1)); - ASSERT_TRUE(model()->GetResourceWebContents(resource_count + 1) != NULL); - ASSERT_TRUE(model()->GetResourceExtension(resource_count + 1) != NULL); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count + 1), - prefix, true)); - - // Unload extension to avoid crash on Windows. + + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar"))); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + + int extension_tab = FindResourceIndex(MatchExtension("Foobar")); + ASSERT_NE(-1, extension_tab); + ASSERT_TRUE(model()->GetResourceWebContents(extension_tab) != NULL); + ASSERT_TRUE(model()->CanActivate(extension_tab)); + + int background_page = FindResourceIndex(MatchExtension("My extension 1")); + ASSERT_NE(-1, background_page); + ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); + ASSERT_FALSE(model()->CanActivate(background_page)); +} + +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabChanges) { + ShowTaskManager(); + + ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("packaged_app"))); + ExtensionService* service = extensions::ExtensionSystem::Get( + browser()->profile())->extension_service(); + const extensions::Extension* extension = + service->GetExtensionById(last_loaded_extension_id(), false); + + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); + + // Open a new tab to the app's launch URL and make sure we notice that. + GURL url(extension->GetResourceURL("main.html")); + AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); + + // There should be 1 "App: " tab and the original new tab page. + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchApp("Packaged App Test"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + + // Check that the third entry (main.html) is of type extension and has both + // a tab contents and an extension. + int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); + ASSERT_NE(-1, app_tab); + ASSERT_TRUE(model()->GetResourceWebContents(app_tab) != NULL); + ASSERT_TRUE(model()->CanActivate(app_tab)); + ASSERT_EQ(task_manager::Resource::EXTENSION, + model()->GetResourceType(app_tab)); + ASSERT_EQ(2, browser()->tab_strip_model()->count()); + + // Unload extension to make sure the tab goes away. UnloadExtension(last_loaded_extension_id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_EQ(1, browser()->tab_strip_model()->count()); } -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { - int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTab) { ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("packaged_app"))); ExtensionService* service = extensions::ExtensionSystem::Get( @@ -284,32 +474,30 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) { const extensions::Extension* extension = service->GetExtensionById(last_loaded_extension_id(), false); - // New Tab Page. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); - // Open a new tab to the app's launch URL and make sure we notice that. GURL url(extension->GetResourceURL("main.html")); AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + + ShowTaskManager(); + + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchApp("Packaged App Test"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); // Check that the third entry (main.html) is of type extension and has both - // a tab contents and an extension. The title should start with "App:". - ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType( - resource_count)); - ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL); - ASSERT_TRUE(model()->GetResourceExtension(resource_count) == extension); - base::string16 prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_APP_PREFIX, base::string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), - prefix, true)); - - // Unload extension to avoid crash on Windows. - UnloadExtension(last_loaded_extension_id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + // a tab contents and an extension. + int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); + ASSERT_NE(-1, app_tab); + ASSERT_TRUE(model()->GetResourceWebContents(app_tab) != NULL); + ASSERT_TRUE(model()->CanActivate(app_tab)); + ASSERT_EQ(task_manager::Resource::EXTENSION, + model()->GetResourceType(app_tab)); } -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) { - int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabChanges) { + ShowTaskManager(); // The app under test acts on URLs whose host is "localhost", // so the URLs we navigate to must have host "localhost". @@ -330,14 +518,8 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) { AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); observer.Wait(); - // Force the TaskManager to query the title. - Refresh(); - - // Check that the third entry's title starts with "Tab:". - base::string16 tab_prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_TAB_PREFIX, base::string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), - tab_prefix, true)); + // Check that the new entry's title starts with "Tab:". + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); // Load the hosted app and make sure it still starts with "Tab:", // since it hasn't changed to an app process yet. @@ -345,117 +527,146 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) { test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); // Force the TaskManager to query the title. Refresh(); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), - tab_prefix, true)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); // Now reload and check that the last entry's title now starts with "App:". ui_test_utils::NavigateToURL(browser(), url); + // Force the TaskManager to query the title. - Refresh(); - base::string16 app_prefix = l10n_util::GetStringFUTF16( - IDS_TASK_MANAGER_APP_PREFIX, base::string16()); - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), - app_prefix, true)); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchApp("Unmodified"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); - // Disable extension and reload page. + // Disable extension. DisableExtension(last_loaded_extension_id()); - ui_test_utils::NavigateToURL(browser(), url); - // Force the TaskManager to query the title. - Refresh(); + // The hosted app should now show up as a normal "Tab: ". + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); - // The third entry's title should be back to a normal tab. - ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), - tab_prefix, true)); + // Reload the page. + ui_test_utils::NavigateToURL(browser(), url); + + // No change expected. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); } -// Disabled, http://crbug.com/66957. -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, - DISABLED_KillExtensionAndReload) { +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabAfterReload) { + // The app under test acts on URLs whose host is "localhost", + // so the URLs we navigate to must have host "localhost". + host_resolver()->AddRule("*", "127.0.0.1"); + ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); + GURL::Replacements replace_host; + std::string host_str("localhost"); // must stay in scope with replace_host + replace_host.SetHostStr(host_str); + GURL base_url = + embedded_test_server()->GetURL("/extensions/api_test/app_process/"); + base_url = base_url.ReplaceComponents(replace_host); + + // Open a new tab to an app URL before the app is loaded. + GURL url(base_url.Resolve("path1/empty.html")); + content::WindowedNotificationObserver observer( + content::NOTIFICATION_NAV_ENTRY_COMMITTED, + content::NotificationService::AllSources()); + AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); + observer.Wait(); + + // Load the hosted app and make sure it still starts with "Tab:", + // since it hasn't changed to an app process yet. ASSERT_TRUE(LoadExtension( - test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); + test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); - // Wait until we see the loaded extension in the task manager (the three - // resources are: the browser process, New Tab Page, and the extension). - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); - - EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); - EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); - ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); - - // Kill the extension process and make sure we notice it. - TaskManager::GetInstance()->KillProcess(2); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); - - // Reload the extension using the "crashed extension" infobar while the task - // manager is still visible. Make sure we don't crash and the extension - // gets reloaded and noticed in the task manager. - InfoBarService* infobar_service = InfoBarService::FromWebContents( - browser()->tab_strip_model()->GetActiveWebContents()); - ASSERT_EQ(1U, infobar_service->infobar_count()); - ConfirmInfoBarDelegate* delegate = - infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); - ASSERT_TRUE(delegate); - delegate->Accept(); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + // Now reload, which should transition this tab to being an App. + ui_test_utils::NavigateToURL(browser(), url); + + ShowTaskManager(); + + // The TaskManager should show this as an "App: " + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); } -#if defined(OS_WIN) -// http://crbug.com/93158. -#define MAYBE_ReloadExtension DISABLED_ReloadExtension -#else -#define MAYBE_ReloadExtension ReloadExtension -#endif +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabBeforeReload) { + // The app under test acts on URLs whose host is "localhost", + // so the URLs we navigate to must have host "localhost". + host_resolver()->AddRule("*", "127.0.0.1"); + ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); + GURL::Replacements replace_host; + std::string host_str("localhost"); // must stay in scope with replace_host + replace_host.SetHostStr(host_str); + GURL base_url = + embedded_test_server()->GetURL("/extensions/api_test/app_process/"); + base_url = base_url.ReplaceComponents(replace_host); + + // Open a new tab to an app URL before the app is loaded. + GURL url(base_url.Resolve("path1/empty.html")); + content::WindowedNotificationObserver observer( + content::NOTIFICATION_NAV_ENTRY_COMMITTED, + content::NotificationService::AllSources()); + AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); + observer.Wait(); + + // Load the hosted app and make sure it still starts with "Tab:", + // since it hasn't changed to an app process yet. + ASSERT_TRUE(LoadExtension( + test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); + + ShowTaskManager(); + + // The TaskManager should show this as a "Tab: " because the page hasn't been + // reloaded since the hosted app was installed. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); +} // Regression test for http://crbug.com/18693. -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) { - int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); - LOG(INFO) << "loading extension"; +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, ReloadExtension) { + ShowTaskManager(); ASSERT_TRUE(LoadExtension( test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); // Wait until we see the loaded extension in the task manager (the three // resources are: the browser process, New Tab Page, and the extension). - LOG(INFO) << "waiting for resource change"; - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); - - EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); - EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); - ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL); - - const extensions::Extension* extension = model()->GetResourceExtension( - resource_count); - ASSERT_TRUE(extension != NULL); - - // Reload the extension a few times and make sure our resource count - // doesn't increase. - LOG(INFO) << "First extension reload"; - ReloadExtension(extension->id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); - extension = model()->GetResourceExtension(resource_count); - ASSERT_TRUE(extension != NULL); - - LOG(INFO) << "Second extension reload"; - ReloadExtension(extension->id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); - extension = model()->GetResourceExtension(resource_count); - ASSERT_TRUE(extension != NULL); - - LOG(INFO) << "Third extension reload"; - ReloadExtension(extension->id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("background_page"))); + + // Reload the extension a few times and make sure our resource count doesn't + // increase. + std::string extension_id = last_loaded_extension_id(); + for (int i = 1; i <= 5; i++) { + SCOPED_TRACE(testing::Message() << "Reloading extension for the " << i + << "th time."); + ReloadExtension(extension_id); + ASSERT_NO_FATAL_FAILURE( + WaitForTaskManagerRows(1, MatchExtension("background_page"))); + } } // Crashy, http://crbug.com/42301. IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DISABLED_PopulateWebCacheFields) { + ShowTaskManager(); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); // Open a new tab and make sure we notice that. - GURL url(ui_test_utils::GetTestUrl(base::FilePath( - base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); - AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + AddTabAtIndex(0, GetTestURL(), content::PAGE_TRANSITION_TYPED); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); // Check that we get some value for the cache columns. DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(resource_count), @@ -470,9 +681,7 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, // http://crbug.com/241066 // Flaky, http://crbug.com/259368 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DISABLED_WebWorkerJSHeapMemory) { - GURL url(ui_test_utils::GetTestUrl(base::FilePath( - base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); - ui_test_utils::NavigateToURL(browser(), url); + ui_test_utils::NavigateToURL(browser(), GetTestURL()); const int extra_timeout_ms = 500; size_t minimal_heap_size = 2 * 1024 * 1024 * sizeof(void*); std::string test_js = base::StringPrintf( @@ -507,29 +716,42 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DISABLED_WebWorkerJSHeapMemory) { EXPECT_GE(result, minimal_heap_size); } -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeInTabDevToolsWindow) { +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsNewDockedWindow) { + ShowTaskManager(); // Task manager shown BEFORE dev tools window. + + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); + DevToolsWindow::OpenDevToolsWindowForTest( + browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), + true); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); +} + +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsNewUndockedWindow) { + ShowTaskManager(); // Task manager shown BEFORE dev tools window. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); DevToolsWindow::OpenDevToolsWindowForTest( - model()->GetResourceWebContents(1)->GetRenderViewHost(), true); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), + false); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); } -// This test differs from TaskManagerBrowserTest.NoticeInTabDevToolsWindow in -// the order in which the devtools window and task manager are created. -IN_PROC_BROWSER_TEST_F(TaskManagerNoShowBrowserTest, - NoticeInTabDevToolsWindow) { - // First create the devtools window. +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsOldDockedWindow) { DevToolsWindow::OpenDevToolsWindowForTest( browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), true); - // Make sure that the devtools window is loaded before starting the task - // manager. - content::RunAllPendingInMessageLoop(); - - // Now add showing the task manager to the queue, and watch for the right - // number of reources to show up. - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&TaskManagerNoShowBrowserTest::ShowTaskManager, - base::Unretained(this))); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + + ShowTaskManager(); // Task manager shown AFTER dev tools window. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); +} + +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsOldUnockedWindow) { + DevToolsWindow::OpenDevToolsWindowForTest( + browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), + false); + ShowTaskManager(); // Task manager shown AFTER dev tools window. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); } diff --git a/chrome/browser/task_manager/task_manager_browsertest_util.cc b/chrome/browser/task_manager/task_manager_browsertest_util.cc index 1895ff0..d7e8011 100644 --- a/chrome/browser/task_manager/task_manager_browsertest_util.cc +++ b/chrome/browser/task_manager/task_manager_browsertest_util.cc @@ -2,50 +2,33 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/task_manager/task_manager_browsertest_util.h" + #include "base/message_loop/message_loop.h" -#include "base/strings/stringprintf.h" -#include "base/strings/utf_string_conversions.h" +#include "base/run_loop.h" +#include "base/strings/string16.h" +#include "base/strings/string_util.h" +#include "base/test/test_timeouts.h" +#include "base/timer/timer.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/task_manager/resource_provider.h" #include "chrome/browser/task_manager/task_manager.h" -#include "chrome/browser/task_manager/task_manager_browsertest_util.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_dialogs.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/web_contents.h" +#include "testing/gtest/include/gtest/gtest.h" -namespace { +namespace task_manager { +namespace browsertest_util { -int GetWebResourceCount(const TaskManagerModel* model) { - int count = 0; - for (int i = 0; i < model->ResourceCount(); i++) { - task_manager::Resource::Type type = model->GetResourceType(i); - // Skip system infrastructure resources. - if (type == task_manager::Resource::BROWSER || - type == task_manager::Resource::NACL || - type == task_manager::Resource::GPU || - type == task_manager::Resource::UTILITY || - type == task_manager::Resource::ZYGOTE || - type == task_manager::Resource::SANDBOX_HELPER) { - continue; - } - - count++; - } - return count; -} +namespace { class ResourceChangeObserver : public TaskManagerModelObserver { public: ResourceChangeObserver(const TaskManagerModel* model, - int target_resource_count) + int required_count, + const base::string16& title_pattern) : model_(model), - target_resource_count_(target_resource_count) { - } + required_count_(required_count), + title_pattern_(title_pattern) {} virtual void OnModelChanged() OVERRIDE { OnResourceChange(); @@ -63,33 +46,102 @@ class ResourceChangeObserver : public TaskManagerModelObserver { OnResourceChange(); } + void RunUntilSatisfied() { + // See if the condition is satisfied without having to run the loop. This + // check has to be placed after the installation of the + // TaskManagerModelObserver, because resources may change before that. + if (IsSatisfied()) + return; + + timer_.Start(FROM_HERE, + TestTimeouts::action_timeout(), + this, + &ResourceChangeObserver::OnTimeout); + + run_loop_.Run(); + + // If we succeeded normally (no timeout), check our post condition again + // before returning control to the test. If it is no longer satisfied, the + // test is likely flaky: we were waiting for a state that was only achieved + // emphemerally), so treat this as a failure. + if (!IsSatisfied() && timer_.IsRunning()) { + FAIL() << "Wait condition satisfied only emphemerally. Likely test " + << "problem. Maybe wait instead for the state below?\n" + << DumpTaskManagerModel(); + } + + timer_.Stop(); + } + private: void OnResourceChange() { - if (GetWebResourceCount(model_) == target_resource_count_) - base::MessageLoopForUI::current()->Quit(); + if (!IsSatisfied()) + return; + + base::MessageLoop::current()->PostTask(FROM_HERE, run_loop_.QuitClosure()); + } + + bool IsSatisfied() { return CountMatches() == required_count_; } + + int CountMatches() { + int match_count = 0; + for (int i = 0; i < model_->ResourceCount(); i++) { + task_manager::Resource::Type type = model_->GetResourceType(i); + // Skip system infrastructure resources. + if (type == task_manager::Resource::BROWSER || + type == task_manager::Resource::NACL || + type == task_manager::Resource::GPU || + type == task_manager::Resource::UTILITY || + type == task_manager::Resource::ZYGOTE || + type == task_manager::Resource::SANDBOX_HELPER) { + continue; + } + + if (MatchPattern(model_->GetResourceTitle(i), title_pattern_)) { + match_count++; + } + } + return match_count; + } + + void OnTimeout() { + base::MessageLoop::current()->PostTask(FROM_HERE, run_loop_.QuitClosure()); + FAIL() << "Timed out.\n" << DumpTaskManagerModel(); + } + + testing::Message DumpTaskManagerModel() { + testing::Message task_manager_state_dump; + task_manager_state_dump << "Waiting for exactly " << required_count_ + << " matches of wildcard pattern \"" + << UTF16ToASCII(title_pattern_) << "\"\n"; + task_manager_state_dump << "Currently there are " << CountMatches() + << " matches.\n"; + task_manager_state_dump << "Current Task Manager Model is:\n"; + for (int i = 0; i < model_->ResourceCount(); i++) { + task_manager_state_dump + << " > " << UTF16ToASCII(model_->GetResourceTitle(i)) << "\n"; + } + return task_manager_state_dump; } const TaskManagerModel* model_; - const int target_resource_count_; + const int required_count_; + const base::string16 title_pattern_; + base::RunLoop run_loop_; + base::OneShotTimer<ResourceChangeObserver> timer_; }; } // namespace -// static -void TaskManagerBrowserTestUtil::WaitForWebResourceChange(int target_count) { +void WaitForTaskManagerRows(int required_count, + const base::string16& title_pattern) { TaskManagerModel* model = TaskManager::GetInstance()->model(); - ResourceChangeObserver observer(model, target_count); + ResourceChangeObserver observer(model, required_count, title_pattern); model->AddObserver(&observer); - - // Checks that the condition has not been satisfied yet. - // This check has to be placed after the installation of the observer, - // because resources may change before that. - if (GetWebResourceCount(model) == target_count) { - model->RemoveObserver(&observer); - return; - } - - content::RunMessageLoop(); + observer.RunUntilSatisfied(); model->RemoveObserver(&observer); } + +} // namespace browsertest_util +} // namespace task_manager diff --git a/chrome/browser/task_manager/task_manager_browsertest_util.h b/chrome/browser/task_manager/task_manager_browsertest_util.h index 92c09da..dc2336d 100644 --- a/chrome/browser/task_manager/task_manager_browsertest_util.h +++ b/chrome/browser/task_manager/task_manager_browsertest_util.h @@ -5,12 +5,23 @@ #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ -#include "chrome/browser/ui/browser.h" +#include "base/strings/string16.h" -class TaskManagerBrowserTestUtil { - public: - static void WaitForWebResourceChange(int target_count); +namespace task_manager { +namespace browsertest_util { -}; +// Runs the message loop, observing the task manager, until there are exactly +// |resource_count| many resources whose titles match the pattern +// |title_pattern|. The match is done via string_util's base::MatchPattern, so +// |title_pattern| may contain wildcards like "*". +// +// If the wait times out, this test will trigger a gtest failure. To get +// meaningful errors, tests should wrap invocations of this function with +// ASSERT_NO_FATAL_FAILURE(). +void WaitForTaskManagerRows(int resource_count, + const base::string16& title_pattern); + +} // namespace browsertest_util +} // namespace task_manager #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_BROWSERTEST_UTIL_H_ diff --git a/chrome/browser/task_manager/task_manager_notification_browsertest.cc b/chrome/browser/task_manager/task_manager_notification_browsertest.cc index c9ee629..89ad198 100644 --- a/chrome/browser/task_manager/task_manager_notification_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_notification_browsertest.cc @@ -18,22 +18,25 @@ #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/common/content_switches.h" +#include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/message_center/message_center_switches.h" #include "ui/message_center/message_center_util.h" +using task_manager::browsertest_util::WaitForTaskManagerRows; + class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest { - public: - TaskManagerModel* model() const { - return TaskManager::GetInstance()->model(); - } protected: virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { ExtensionBrowserTest::SetUpCommandLine(command_line); + } - // Do not prelaunch the GPU process for these tests because it will show - // up in task manager but whether it appears before or after the new tab - // renderer process is not well defined. - command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch); + // Returns the text we expect to see in the TaskManager for a given + // notification. + base::string16 GetTitle(const char* ascii_name) { + return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NOTIFICATION_PREFIX, + base::ASCIIToUTF16(ascii_name)); } }; @@ -45,18 +48,11 @@ class TaskManagerNotificationBrowserTest : public ExtensionBrowserTest { #endif IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, MAYBE_NoticeNotificationChanges) { - // These tests do not apply with Message Center platforms + // These tests do not apply with Message Center-only platforms (e.g. Ash) // where notifications do not instantiate a new renderer. if (message_center::IsRichNotificationEnabled()) return; - EXPECT_EQ(0, model()->ResourceCount()); - - // Show the task manager. - chrome::ShowTaskManager(browser()); - // Expect to see the browser and the New Tab Page renderer. - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); - // Show a notification. NotificationUIManager* notifications = g_browser_process->notification_ui_manager(); @@ -65,6 +61,19 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, GURL(), base::ASCIIToUTF16("Hello World!"), base::string16(), blink::WebTextDirectionDefault); + // Show an initial notification before popping up the task manager. + scoped_refptr<NotificationDelegate> del0(new MockNotificationDelegate("n0")); + Notification n0( + GURL(), GURL(content), base::ASCIIToUTF16("Test 0"), base::string16(), + del0.get()); + notifications->Add(n0, browser()->profile()); + + // Show the task manager. + chrome::ShowTaskManager(browser()); + + // This notification should show up in the task manager. + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0"))); + scoped_refptr<NotificationDelegate> del1(new MockNotificationDelegate("n1")); Notification n1( GURL(), GURL(content), base::ASCIIToUTF16("Test 1"), base::string16(), @@ -74,12 +83,30 @@ IN_PROC_BROWSER_TEST_F(TaskManagerNotificationBrowserTest, GURL(), GURL(content), base::ASCIIToUTF16("Test 2"), base::string16(), del2.get()); + // Show two more notifications with the task manager running, then cancel + // all three notifications. notifications->Add(n1, browser()->profile()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 2"))); + notifications->Add(n2, browser()->profile()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(3); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 2"))); + notifications->CancelById(n1.notification_id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(2); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 0"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 2"))); + + notifications->CancelById(n0.notification_id()); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 0"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, GetTitle("Test 2"))); + notifications->CancelById(n2.notification_id()); - TaskManagerBrowserTestUtil::WaitForWebResourceChange(1); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 0"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 1"))); + ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, GetTitle("Test 2"))); } diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index f5429d7..422c4aa 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1765,15 +1765,6 @@ '../ui/events/events.gyp:events_test_support', ], }], - ['use_aura==1', { - 'sources!': [ - # http://crbug.com/31663 - # TODO(linux_aura) http://crbug.com/163931 - # TODO(vabr): There is always a GPU process on ChromeOS: - # crbug.com/331947 - 'browser/task_manager/task_manager_browsertest.cc', - ], - }], ['chromeos==0', { 'sources/': [ ['exclude', '^browser/chromeos'], |