15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/task_manager/task_manager.h" 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/files/file_path.h" 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/strings/stringprintf.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/browser_process.h" 107dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "chrome/browser/chrome_notification_types.h" 11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "chrome/browser/devtools/devtools_window_testing.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_browsertest.h" 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/extensions/extension_service.h" 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/infobars/infobar_service.h" 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/desktop_notification_service.h" 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/notification.h" 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/notification_test_util.h" 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/notifications/notification_ui_manager.h" 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/profiles/profile.h" 2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "chrome/browser/task_manager/resource_provider.h" 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/task_manager/task_manager_browsertest_util.h" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser.h" 23a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch#include "chrome/browser/ui/browser_commands.h" 242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/ui/browser_dialogs.h" 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_navigator.h" 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h" 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/panels/panel.h" 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/panels/panel_manager.h" 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/ui/tabs/tab_strip_model.h" 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/web_applications/web_app.h" 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h" 3203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "chrome/grit/generated_resources.h" 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/in_process_browser_test.h" 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/test/base/ui_test_utils.h" 35cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/infobars/core/confirm_infobar_delegate.h" 360529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch#include "components/infobars/core/infobar.h" 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/browser/notification_service.h" 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/content_switches.h" 397d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "content/public/test/browser_test_utils.h" 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extension_system.h" 41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "extensions/common/extension.h" 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "net/dns/mock_host_resolver.h" 43eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "net/test/embedded_test_server/embedded_test_server.h" 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h" 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h" 461320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "ui/base/page_transition_types.h" 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)using content::WebContents; 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchAboutBlankTab; 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchAnyApp; 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchAnyExtension; 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchAnyTab; 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchApp; 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchExtension; 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::MatchTab; 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)using task_manager::browsertest_util::WaitForTaskManagerRows; 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace { 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class TaskManagerBrowserTest : public ExtensionBrowserTest { 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) TaskManagerBrowserTest() {} 67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual ~TaskManagerBrowserTest() {} 682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) TaskManagerModel* model() const { 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return TaskManager::GetInstance()->model(); 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 734e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void ShowTaskManager() { 742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) EXPECT_EQ(0, model()->ResourceCount()); 752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Show the task manager. This populates the model, and helps with debugging 772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // (you see the task manager). 78eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch chrome::ShowTaskManager(browser()); 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void Refresh() { 822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) model()->Refresh(); 832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 857d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int GetUpdateTimeMs() { 867d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) return TaskManagerModel::kUpdateTimeMs; 877d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) } 887d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL GetTestURL() { 90a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return ui_test_utils::GetTestUrl( 91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::FilePath(base::FilePath::kCurrentDirectory), 92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base::FilePath(kTitle1File)); 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int FindResourceIndex(const base::string16& title) { 96a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (int i = 0; i < model()->ResourceCount(); ++i) { 97a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) if (title == model()->GetResourceTitle(i)) 98a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return i; 99a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 100a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) return -1; 101a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 102a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ExtensionBrowserTest::SetUpCommandLine(command_line); 1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 107d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) // Do not launch device discovery process. 108d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) command_line->AppendSwitch(switches::kDisableDeviceDiscoveryNotifications); 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest); 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX) || defined(OS_LINUX) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define MAYBE_ShutdownWhileOpen DISABLED_ShutdownWhileOpen 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#else 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define MAYBE_ShutdownWhileOpen ShutdownWhileOpen 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Regression test for http://crbug.com/13361 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) { 123a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) { 127a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 128a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 129a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 130a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); 131a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 132a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new tab and make sure the task manager notices it. 1331320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, GetTestURL(), ui::PAGE_TRANSITION_TYPED); 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 135a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); 136a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Close the tab and verify that we notice. 1392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) browser()->tab_strip_model()->CloseWebContentsAt(0, 1402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) TabStripModel::CLOSE_NONE); 141a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); 142a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochIN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillTab) { 146a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ShowTaskManager(); 147a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 148a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 149a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); 150a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 151a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Open a new tab and make sure the task manager notices it. 1521320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, GetTestURL(), ui::PAGE_TRANSITION_TYPED); 153a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 154a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); 155a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 156a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 157a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Killing the tab via task manager should remove the row. 158a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch int tab = FindResourceIndex(MatchTab("title1.html")); 159a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NE(-1, tab); 160a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_TRUE(model()->GetResourceWebContents(tab) != NULL); 161a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_TRUE(model()->CanActivate(tab)); 162a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch TaskManager::GetInstance()->KillProcess(tab); 163a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchTab("title1.html"))); 164a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 165a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 166a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch // Tab should reappear in task manager upon reload. 167a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch chrome::Reload(browser(), CURRENT_TAB); 168a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); 169a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 170a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch} 171a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 172a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanel) { 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .AppendASCII("1.0.0.0"))); 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 178a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new panel to an extension url. 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url( 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Panel* panel = PanelManager::GetInstance()->CreatePanel( 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) web_app::GenerateApplicationNameFromExtensionId( 1838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) last_loaded_extension_id()), 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->profile(), 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url, 1865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(300, 400), 1875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PanelManager::CREATE_AS_DOCKED); 1885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 189a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Make sure that a task manager model created after the panel shows the 190a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // existence of the panel and the extension. 191a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 192a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 193a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 194a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 195a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1, 196a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MatchExtension( 197a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 198a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"))); 199a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 200a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 201a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Close the panel and verify that we notice. 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) panel->Close(); 205a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); 206a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 207a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 0, 208a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MatchExtension( 209a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 210a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"))); 211a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 212a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 2135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 2145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticePanelChanges) { 216a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 217a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 218a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .AppendASCII("1.0.0.0"))); 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Browser, the New Tab Page and Extension background page. 226a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 227a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 228a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); 229a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Open a new panel to an extension url and make sure we notice that. 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url( 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html"); 234a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) Panel* panel = PanelManager::GetInstance()->CreatePanel( 235a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) web_app::GenerateApplicationNameFromExtensionId( 236a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) last_loaded_extension_id()), 237a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) browser()->profile(), 238a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) url, 239a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Rect(300, 400), 240a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) PanelManager::CREATE_AS_DOCKED); 241a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 242a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 243a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 244a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1, 245a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MatchExtension( 246a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 247a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"))); 248a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 249a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 250a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 251a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 252a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Close the panel and verify that we notice. 253a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) panel->Close(); 254a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); 255a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 256a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 0, 257a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MatchExtension( 258a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 259a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"))); 260a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 261a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 262a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 263a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Unload extension. 264a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) UnloadExtension(last_loaded_extension_id()); 265a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 266a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 267a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 268a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 269a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Kills a process that has more than one task manager entry. 270a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaExtensionResource) { 271a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 272a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 273a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("Extensions") 274a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 275a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("1.0.0.0"))); 276a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 277a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new panel to an extension url. 278a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL url( 279a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 280a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"); 2815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PanelManager::GetInstance()->CreatePanel( 2825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) web_app::GenerateApplicationNameFromExtensionId( 2838bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) last_loaded_extension_id()), 2845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) browser()->profile(), 2855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) url, 2865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Rect(300, 400), 2875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) PanelManager::CREATE_AS_DOCKED); 2885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 289a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 290a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 291a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 292a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1, 293a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MatchExtension( 294a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 295a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"))); 296a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 297a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 298a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 299a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 300a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Kill the process via the BACKGROUND PAGE (not the panel). Verify that both 301a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // the background page and the panel go away from the task manager. 302a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int background_page = FindResourceIndex(MatchExtension("My extension 1")); 303a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, background_page); 304a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 305a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(model()->CanActivate(background_page)); 306a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) TaskManager::GetInstance()->KillProcess(background_page); 307a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 308a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 3095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 3105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 311a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Kills a process that has more than one task manager entry. This test is the 312a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// same as KillPanelViaExtensionResource except it does the kill via the other 313a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// entry. 314a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillPanelViaPanelResource) { 315a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 316a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("Extensions") 317a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 318a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("1.0.0.0"))); 319a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 320a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new panel to an extension url. 321a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL url( 322a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 323a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"); 324a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) PanelManager::GetInstance()->CreatePanel( 325a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) web_app::GenerateApplicationNameFromExtensionId( 326a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) last_loaded_extension_id()), 327a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) browser()->profile(), 328a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) url, 329a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) gfx::Rect(300, 400), 330a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) PanelManager::CREATE_AS_DOCKED); 331a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 332a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 333a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 334a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 335a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows( 336a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 1, 337a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) MatchExtension( 338a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 339a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html"))); 340a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 341a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 342a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 343a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 344a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int background_page = FindResourceIndex(MatchExtension("My extension 1")); 345a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, background_page); 346a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 347a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(model()->CanActivate(background_page)); 348a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 349a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Kill the process via the PANEL RESOURCE (not the background page). Verify 350a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // that both the background page and the panel go away from the task manager. 351a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int panel = FindResourceIndex(MatchExtension( 352a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/" 353a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) "french_sentence.html")); 354a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, panel); 355a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(panel) != NULL); 356a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->CanActivate(panel)); 357a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) TaskManager::GetInstance()->KillProcess(panel); 358a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 359a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 360a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 361a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 362a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabChanges) { 363a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 364a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 365a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 366a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 3675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 3685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 3695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 3705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) .AppendASCII("1.0.0.0"))); 3715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 3725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Browser, Extension background page, and the New Tab Page. 373a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 374a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 375a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyExtension())); 376a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 377a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 378a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new tab to an extension URL. Afterwards, the third entry (background 379a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // page) should be an extension resource whose title starts with "Extension:". 380a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The fourth entry (page.html) is also of type extension and has both a 381a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // WebContents and an extension. The title should start with "Extension:". 382a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); 3831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 384a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar"))); 385a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 386a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 387a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 388a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 389a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 390a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 391a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int extension_tab = FindResourceIndex(MatchExtension("Foobar")); 392a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, extension_tab); 393a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(extension_tab) != NULL); 394a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->CanActivate(extension_tab)); 395a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 396a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int background_page = FindResourceIndex(MatchExtension("My extension 1")); 397a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, background_page); 398a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 399a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(model()->CanActivate(background_page)); 400a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 4015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 402a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTab) { 403a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // With the task manager closed, open a new tab to an extension URL. 404a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Afterwards, when we open the task manager, the third entry (background 405a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // page) should be an extension resource whose title starts with "Extension:". 406a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The fourth entry (page.html) is also of type extension and has both a 407a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // WebContents and an extension. The title should start with "Extension:". 408a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("good") 409a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("Extensions") 410a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 411a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) .AppendASCII("1.0.0.0"))); 4125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"); 4131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 414a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 415a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 416a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchExtension("Foobar"))); 417a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 418a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("My extension 1"))); 419a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyExtension())); 420a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 421a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 422a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 423a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int extension_tab = FindResourceIndex(MatchExtension("Foobar")); 424a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, extension_tab); 425a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(extension_tab) != NULL); 426a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->CanActivate(extension_tab)); 427a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 428a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int background_page = FindResourceIndex(MatchExtension("My extension 1")); 429a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, background_page); 430a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(background_page) == NULL); 431a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_FALSE(model()->CanActivate(background_page)); 432a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 433a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 434a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabChanges) { 435a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 436a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 437a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("packaged_app"))); 438a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ExtensionService* service = extensions::ExtensionSystem::Get( 439a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) browser()->profile())->extension_service(); 440a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const extensions::Extension* extension = 441a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) service->GetExtensionById(last_loaded_extension_id(), false); 442a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 443a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 444a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 445a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 446a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); 447a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 448a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new tab to the app's launch URL and make sure we notice that. 449a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL url(extension->GetResourceURL("main.html")); 4501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 451a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 452a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // There should be 1 "App: " tab and the original new tab page. 453a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 454a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchApp("Packaged App Test"))); 455a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); 456a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 457a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 458a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 459a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 460a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Check that the third entry (main.html) is of type extension and has both 461a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // a tab contents and an extension. 462a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); 463a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, app_tab); 464a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(app_tab) != NULL); 465a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->CanActivate(app_tab)); 466a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(task_manager::Resource::EXTENSION, 467a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) model()->GetResourceType(app_tab)); 468a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(2, browser()->tab_strip_model()->count()); 469a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 470a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Unload extension to make sure the tab goes away. 4718bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) UnloadExtension(last_loaded_extension_id()); 472a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 473a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 474a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); 475a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 476a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 477a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(1, browser()->tab_strip_model()->count()); 4785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 4795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 480a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTab) { 4815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 4825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_data_dir_.AppendASCII("packaged_app"))); 4832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) ExtensionService* service = extensions::ExtensionSystem::Get( 4842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) browser()->profile())->extension_service(); 4855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const extensions::Extension* extension = 4868bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) service->GetExtensionById(last_loaded_extension_id(), false); 4875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 4885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Open a new tab to the app's launch URL and make sure we notice that. 4895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url(extension->GetResourceURL("main.html")); 4901320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 491a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 492a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 493a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 494a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 495a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchApp("Packaged App Test"))); 496a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 497a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 498a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); 4995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check that the third entry (main.html) is of type extension and has both 501a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // a tab contents and an extension. 502a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) int app_tab = FindResourceIndex(MatchApp("Packaged App Test")); 503a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NE(-1, app_tab); 504a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->GetResourceWebContents(app_tab) != NULL); 505a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(model()->CanActivate(app_tab)); 506a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_EQ(task_manager::Resource::EXTENSION, 507a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) model()->GetResourceType(app_tab)); 5085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 510a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabChanges) { 511a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 5125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The app under test acts on URLs whose host is "localhost", 5145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // so the URLs we navigate to must have host "localhost". 5155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) host_resolver()->AddRule("*", "127.0.0.1"); 516eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 5175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL::Replacements replace_host; 5185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string host_str("localhost"); // must stay in scope with replace_host 5195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) replace_host.SetHostStr(host_str); 520eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch GURL base_url = embedded_test_server()->GetURL( 521eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch "/extensions/api_test/app_process/"); 5225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) base_url = base_url.ReplaceComponents(replace_host); 5235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Open a new tab to an app URL before the app is loaded. 5255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL url(base_url.Resolve("path1/empty.html")); 5265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::WindowedNotificationObserver observer( 5275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NOTIFICATION_NAV_ENTRY_COMMITTED, 5285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) content::NotificationService::AllSources()); 5291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 5305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) observer.Wait(); 5315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 532a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Check that the new entry's title starts with "Tab:". 533a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 5345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Load the hosted app and make sure it still starts with "Tab:", 5365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // since it hasn't changed to an app process yet. 5375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 5385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); 5392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Force the TaskManager to query the title. 5402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) Refresh(); 541a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 542a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 543a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); 544a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 5455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 5465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Now reload and check that the last entry's title now starts with "App:". 5475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ui_test_utils::NavigateToURL(browser(), url); 548a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 5492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) // Force the TaskManager to query the title. 550a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 551a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 552a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); 553a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchApp("Unmodified"))); 554a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 5555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 556a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Disable extension. 5578bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) DisableExtension(last_loaded_extension_id()); 5585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 559a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The hosted app should now show up as a normal "Tab: ". 560a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 561a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 562a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); 563a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 564a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); 565a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 566a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Reload the page. 567a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui_test_utils::NavigateToURL(browser(), url); 5682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 569a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // No change expected. 570a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 571a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAboutBlankTab())); 572a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("Unmodified"))); 573a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 574a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); 5755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 5765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 577a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabAfterReload) { 578a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The app under test acts on URLs whose host is "localhost", 579a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // so the URLs we navigate to must have host "localhost". 580a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) host_resolver()->AddRule("*", "127.0.0.1"); 581a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 582a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL::Replacements replace_host; 583a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string host_str("localhost"); // must stay in scope with replace_host 584a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) replace_host.SetHostStr(host_str); 585a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL base_url = 586a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) embedded_test_server()->GetURL("/extensions/api_test/app_process/"); 587a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base_url = base_url.ReplaceComponents(replace_host); 588a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 589a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new tab to an app URL before the app is loaded. 590a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL url(base_url.Resolve("path1/empty.html")); 591a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::WindowedNotificationObserver observer( 592a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::NOTIFICATION_NAV_ENTRY_COMMITTED, 593a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::NotificationService::AllSources()); 5941320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 595a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observer.Wait(); 596a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 597a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Load the hosted app and make sure it still starts with "Tab:", 598a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // since it hasn't changed to an app process yet. 5995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 600a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); 6015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 602a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Now reload, which should transition this tab to being an App. 603a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui_test_utils::NavigateToURL(browser(), url); 604a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 605a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 606a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 607a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The TaskManager should show this as an "App: " 608a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 609a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyApp())); 610a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 6115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 613a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabBeforeReload) { 614a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The app under test acts on URLs whose host is "localhost", 615a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // so the URLs we navigate to must have host "localhost". 616a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) host_resolver()->AddRule("*", "127.0.0.1"); 617a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 618a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL::Replacements replace_host; 619a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string host_str("localhost"); // must stay in scope with replace_host 620a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) replace_host.SetHostStr(host_str); 621a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL base_url = 622a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) embedded_test_server()->GetURL("/extensions/api_test/app_process/"); 623a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) base_url = base_url.ReplaceComponents(replace_host); 624a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 625a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Open a new tab to an app URL before the app is loaded. 626a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) GURL url(base_url.Resolve("path1/empty.html")); 627a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::WindowedNotificationObserver observer( 628a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::NOTIFICATION_NAV_ENTRY_COMMITTED, 629a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) content::NotificationService::AllSources()); 6301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); 631a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) observer.Wait(); 632a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 633a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Load the hosted app and make sure it still starts with "Tab:", 634a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // since it hasn't changed to an app process yet. 635a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 636a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) test_data_dir_.AppendASCII("api_test").AppendASCII("app_process"))); 637a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 638a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 639a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 640a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // The TaskManager should show this as a "Tab: " because the page hasn't been 641a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // reloaded since the hosted app was installed. 642a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 643a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyApp())); 644a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(0, MatchAnyExtension())); 645a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 6465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Regression test for http://crbug.com/18693. 648a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, ReloadExtension) { 649a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 6505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ASSERT_TRUE(LoadExtension( 6515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); 6525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Wait until we see the loaded extension in the task manager (the three 6545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // resources are: the browser process, New Tab Page, and the extension). 655a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 656a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("background_page"))); 657a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 658a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // Reload the extension a few times and make sure our resource count doesn't 659a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // increase. 660a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) std::string extension_id = last_loaded_extension_id(); 661a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) for (int i = 1; i <= 5; i++) { 662a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) SCOPED_TRACE(testing::Message() << "Reloading extension for the " << i 663a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) << "th time."); 664a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ReloadExtension(extension_id); 665a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE( 666a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) WaitForTaskManagerRows(1, MatchExtension("background_page"))); 667a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) } 6685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Crashy, http://crbug.com/42301. 6715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, 6725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISABLED_PopulateWebCacheFields) { 673a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); 674a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 675a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 6765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int resource_count = TaskManager::GetInstance()->model()->ResourceCount(); 6775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Open a new tab and make sure we notice that. 6791320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci AddTabAtIndex(0, GetTestURL(), ui::PAGE_TRANSITION_TYPED); 680a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 6815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 6825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Check that we get some value for the cache columns. 6835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(resource_count), 6845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 6855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(resource_count), 6865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 6875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(resource_count), 6885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 6895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 6902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 6917d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// Checks that task manager counts a worker thread JS heap size. 6927d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)// http://crbug.com/241066 6937dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Flaky, http://crbug.com/259368 6947dbb3d5cf0c15f500944d211057644d6a2f37371Ben MurdochIN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DISABLED_WebWorkerJSHeapMemory) { 695a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ui_test_utils::NavigateToURL(browser(), GetTestURL()); 6967d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) const int extra_timeout_ms = 500; 6977d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) size_t minimal_heap_size = 2 * 1024 * 1024 * sizeof(void*); 6987d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) std::string test_js = base::StringPrintf( 6997d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) "var blob = new Blob([\n" 7007d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) " 'mem = new Array(%lu);',\n" 7017d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) " 'for (var i = 0; i < mem.length; i += 16) mem[i] = i;',\n" 7027d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) " 'postMessage();']);\n" 7037d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) "blobURL = window.URL.createObjectURL(blob);\n" 7047d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) "worker = new Worker(blobURL);\n" 7057d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) "// Give the task manager few seconds to poll for JS heap sizes.\n" 7067d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) "worker.onmessage = setTimeout.bind(\n" 7077d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) " this,\n" 7087d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) " function () { window.domAutomationController.send(true); },\n" 7097d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) " %d);\n" 7107d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) "worker.postMessage();\n", 7117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) static_cast<unsigned long>(minimal_heap_size), 7127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) GetUpdateTimeMs() + extra_timeout_ms); 7137d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) bool ok; 7147d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 7157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) browser()->tab_strip_model()->GetActiveWebContents(), test_js, &ok)); 7167d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) ASSERT_TRUE(ok); 7177d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 7187d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int resource_index = TaskManager::GetInstance()->model()->ResourceCount() - 1; 7197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) size_t result; 7207d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 7217d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) ASSERT_TRUE(model()->GetV8Memory(resource_index, &result)); 7227d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) LOG(INFO) << "Got V8 Heap Size " << result << " bytes"; 7237d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_GE(result, minimal_heap_size); 7247d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 7257d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) ASSERT_TRUE(model()->GetV8MemoryUsed(resource_index, &result)); 7267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) LOG(INFO) << "Got V8 Used Heap Size " << result << " bytes"; 7277d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) EXPECT_GE(result, minimal_heap_size); 7287d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)} 7297d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 730a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsNewDockedWindow) { 731a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); // Task manager shown BEFORE dev tools window. 732a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 733a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 734116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindow* devtools = 735116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true); 736a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 737a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 738116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); 739a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 740a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 741a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsNewUndockedWindow) { 742a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); // Task manager shown BEFORE dev tools window. 743a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 744116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindow* devtools = 745116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); 746116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); 747116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); 748116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); 749424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} 750424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 751a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsOldDockedWindow) { 752116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindow* devtools = 753116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), true); 754a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); // Task manager shown AFTER dev tools window. 755a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 756a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(2, MatchAnyTab())); 757116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); 758a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)} 759a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 760a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DevToolsOldUnockedWindow) { 761116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindow* devtools = 762116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::OpenDevToolsWindowSync(browser(), false); 763a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ShowTaskManager(); // Task manager shown AFTER dev tools window. 764116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); 765116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(3, MatchAnyTab())); 766116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DevToolsWindowTesting::CloseDevToolsWindowSync(devtools); 7674e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)} 768