task_manager_browsertest.cc revision 868fa2fe829687343ffae624259930155e16dbd8
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/task_manager/task_manager.h"
6
7#include "base/files/file_path.h"
8#include "base/strings/stringprintf.h"
9#include "base/strings/utf_string_conversions.h"
10#include "chrome/browser/background/background_contents_service.h"
11#include "chrome/browser/background/background_contents_service_factory.h"
12#include "chrome/browser/browser_process.h"
13#include "chrome/browser/extensions/extension_browsertest.h"
14#include "chrome/browser/extensions/extension_service.h"
15#include "chrome/browser/extensions/extension_system.h"
16#include "chrome/browser/infobars/confirm_infobar_delegate.h"
17#include "chrome/browser/infobars/infobar_service.h"
18#include "chrome/browser/notifications/desktop_notification_service.h"
19#include "chrome/browser/notifications/notification.h"
20#include "chrome/browser/notifications/notification_test_util.h"
21#include "chrome/browser/notifications/notification_ui_manager.h"
22#include "chrome/browser/profiles/profile.h"
23#include "chrome/browser/task_manager/resource_provider.h"
24#include "chrome/browser/task_manager/task_manager_browsertest_util.h"
25#include "chrome/browser/ui/browser.h"
26#include "chrome/browser/ui/browser_dialogs.h"
27#include "chrome/browser/ui/browser_navigator.h"
28#include "chrome/browser/ui/browser_window.h"
29#include "chrome/browser/ui/panels/panel.h"
30#include "chrome/browser/ui/panels/panel_manager.h"
31#include "chrome/browser/ui/tabs/tab_strip_model.h"
32#include "chrome/browser/web_applications/web_app.h"
33#include "chrome/common/chrome_notification_types.h"
34#include "chrome/common/chrome_switches.h"
35#include "chrome/common/extensions/extension.h"
36#include "chrome/test/base/in_process_browser_test.h"
37#include "chrome/test/base/ui_test_utils.h"
38#include "content/public/browser/notification_service.h"
39#include "content/public/common/content_switches.h"
40#include "content/public/common/page_transition_types.h"
41#include "grit/generated_resources.h"
42#include "net/dns/mock_host_resolver.h"
43#include "testing/gtest/include/gtest/gtest.h"
44#include "ui/base/l10n/l10n_util.h"
45
46// http://crbug.com/31663
47// TODO(linux_aura) http://crbug.com/163931
48#if !(defined(OS_WIN) && defined(USE_AURA)) && !(defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA))
49
50using content::WebContents;
51
52// On Linux this is crashing intermittently http://crbug/84719
53// In some environments this test fails about 1/6 http://crbug/84850
54#if defined(OS_LINUX)
55#define MAYBE_KillExtension DISABLED_KillExtension
56#else
57#define MAYBE_KillExtension KillExtension
58#endif
59
60namespace {
61
62const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
63
64}  // namespace
65
66class TaskManagerBrowserTest : public ExtensionBrowserTest {
67 public:
68  TaskManagerBrowserTest() {}
69  virtual ~TaskManagerBrowserTest() {}
70
71  TaskManagerModel* model() const {
72    return TaskManager::GetInstance()->model();
73  }
74
75  virtual void SetUpOnMainThread() OVERRIDE {
76    ExtensionBrowserTest::SetUpOnMainThread();
77
78    EXPECT_EQ(0, model()->ResourceCount());
79
80    EXPECT_EQ(0, TaskManager::GetBackgroundPageCount());
81
82    // Show the task manager. This populates the model, and helps with debugging
83    // (you see the task manager).
84    chrome::ShowTaskManager(browser(), false);
85
86    // New Tab Page.
87    TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
88  }
89
90  void Refresh() {
91    model()->Refresh();
92  }
93
94 protected:
95  virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
96    ExtensionBrowserTest::SetUpCommandLine(command_line);
97
98    // Do not prelaunch the GPU process and disable accelerated compositing
99    // for these tests as the GPU process will show up in task manager but
100    // whether it appears before or after the new tab renderer process is not
101    // well defined.
102    command_line->AppendSwitch(switches::kDisableGpuProcessPrelaunch);
103    command_line->AppendSwitch(switches::kDisableAcceleratedCompositing);
104  }
105
106 private:
107  DISALLOW_COPY_AND_ASSIGN(TaskManagerBrowserTest);
108};
109
110#if defined(OS_MACOSX) || defined(OS_LINUX)
111#define MAYBE_ShutdownWhileOpen DISABLED_ShutdownWhileOpen
112#else
113#define MAYBE_ShutdownWhileOpen ShutdownWhileOpen
114#endif
115
116// Regression test for http://crbug.com/13361
117IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ShutdownWhileOpen) {
118  // Showing task manager handled by SetUp.
119}
120
121IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeTabContentsChanges) {
122  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
123  // Open a new tab and make sure we notice that.
124  GURL url(ui_test_utils::GetTestUrl(base::FilePath(
125      base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File)));
126  AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
127  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
128
129  // Check that the last entry is a tab contents resource whose title starts
130  // starts with "Tab:".
131  ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL);
132  string16 prefix = l10n_util::GetStringFUTF16(
133      IDS_TASK_MANAGER_TAB_PREFIX, string16());
134  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count), prefix,
135                         true));
136
137  // Close the tab and verify that we notice.
138  browser()->tab_strip_model()->CloseWebContentsAt(0,
139                                                   TabStripModel::CLOSE_NONE);
140  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
141}
142
143#if defined(USE_ASH)
144// This test fails on Ash because task manager treats view type
145// Panels differently for Ash.
146#define MAYBE_NoticePanelChanges DISABLED_NoticePanelChanges
147#else
148#define MAYBE_NoticePanelChanges NoticePanelChanges
149#endif
150IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticePanelChanges) {
151  ASSERT_TRUE(LoadExtension(
152      test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
153                    .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
154                    .AppendASCII("1.0.0.0")));
155
156  // Browser, the New Tab Page and Extension background page.
157  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
158
159  // Open a new panel to an extension url and make sure we notice that.
160  GURL url(
161    "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html");
162  Panel* panel = PanelManager::GetInstance()->CreatePanel(
163      web_app::GenerateApplicationNameFromExtensionId(
164          last_loaded_extension_id_),
165      browser()->profile(),
166      url,
167      gfx::Rect(300, 400),
168      PanelManager::CREATE_AS_DOCKED);
169  TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
170
171  // Check that the fourth entry is a resource with the panel's web contents
172  // and whose title starts with "Extension:".
173  ASSERT_EQ(panel->GetWebContents(), model()->GetResourceWebContents(3));
174  string16 prefix = l10n_util::GetStringFUTF16(
175      IDS_TASK_MANAGER_EXTENSION_PREFIX, string16());
176  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(3), prefix, true));
177
178  // Close the panel and verify that we notice.
179  panel->Close();
180  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
181
182  // Unload extension to avoid crash on Windows.
183  UnloadExtension(last_loaded_extension_id_);
184  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
185}
186
187IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeBGContentsChanges) {
188  // Open a new background contents and make sure we notice that.
189  GURL url(ui_test_utils::GetTestUrl(base::FilePath(
190      base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File)));
191
192  BackgroundContentsService* service =
193      BackgroundContentsServiceFactory::GetForProfile(browser()->profile());
194  string16 application_id(ASCIIToUTF16("test_app_id"));
195  service->LoadBackgroundContents(browser()->profile(),
196                                  url,
197                                  ASCIIToUTF16("background_page"),
198                                  application_id);
199  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
200  EXPECT_EQ(1, TaskManager::GetBackgroundPageCount());
201
202  // Close the background contents and verify that we notice.
203  service->ShutdownAssociatedBackgroundContents(application_id);
204  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
205  EXPECT_EQ(0, TaskManager::GetBackgroundPageCount());
206}
207
208IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillBGContents) {
209  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
210
211  // Open a new background contents and make sure we notice that.
212  GURL url(ui_test_utils::GetTestUrl(base::FilePath(
213      base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File)));
214
215  content::WindowedNotificationObserver observer(
216      chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED,
217      content::Source<Profile>(browser()->profile()));
218
219  BackgroundContentsService* service =
220      BackgroundContentsServiceFactory::GetForProfile(browser()->profile());
221  string16 application_id(ASCIIToUTF16("test_app_id"));
222  service->LoadBackgroundContents(browser()->profile(),
223                                  url,
224                                  ASCIIToUTF16("background_page"),
225                                  application_id);
226
227  // Wait for the background contents process to finish loading.
228  observer.Wait();
229
230  EXPECT_EQ(resource_count + 1, model()->ResourceCount());
231  EXPECT_EQ(1, TaskManager::GetBackgroundPageCount());
232
233  // Kill the background contents process and verify that it disappears from the
234  // model.
235  bool found = false;
236  for (int i = 0; i < model()->ResourceCount(); ++i) {
237    if (model()->IsBackgroundResource(i)) {
238      TaskManager::GetInstance()->KillProcess(i);
239      found = true;
240      break;
241    }
242  }
243  ASSERT_TRUE(found);
244  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
245  EXPECT_EQ(0, TaskManager::GetBackgroundPageCount());
246}
247
248#if defined(USE_ASH) || defined(OS_WIN)
249// This test fails on Ash because task manager treats view type
250// Panels differently for Ash.
251// This test also fails on Windows, win_rel trybot. http://crbug.com/166322
252#define MAYBE_KillPanelExtension DISABLED_KillPanelExtension
253#else
254#define MAYBE_KillPanelExtension KillPanelExtension
255#endif
256IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillPanelExtension) {
257  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
258
259  ASSERT_TRUE(LoadExtension(
260      test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
261                    .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
262                    .AppendASCII("1.0.0.0")));
263
264  // Browser, the New Tab Page and Extension background page.
265  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
266
267  // Open a new panel to an extension url and make sure we notice that.
268  GURL url(
269    "chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/french_sentence.html");
270  PanelManager::GetInstance()->CreatePanel(
271      web_app::GenerateApplicationNameFromExtensionId(
272          last_loaded_extension_id_),
273      browser()->profile(),
274      url,
275      gfx::Rect(300, 400),
276      PanelManager::CREATE_AS_DOCKED);
277  TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
278
279  // Kill the panel extension process and verify that it disappears from the
280  // model along with its panel.
281  ASSERT_TRUE(model()->IsBackgroundResource(resource_count));
282  TaskManager::GetInstance()->KillProcess(resource_count);
283  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
284}
285
286IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionChanges) {
287  // Loading an extension with a background page should result in a new
288  // resource being created for it.
289  ASSERT_TRUE(LoadExtension(
290      test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
291  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
292  EXPECT_EQ(1, TaskManager::GetBackgroundPageCount());
293
294  // Unload extension to avoid crash on Windows (see http://crbug.com/31663).
295  UnloadExtension(last_loaded_extension_id_);
296  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
297  EXPECT_EQ(0, TaskManager::GetBackgroundPageCount());
298}
299
300IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionTabs) {
301  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
302  ASSERT_TRUE(LoadExtension(
303      test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
304                    .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
305                    .AppendASCII("1.0.0.0")));
306
307  // Browser, Extension background page, and the New Tab Page.
308  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
309
310  // Open a new tab to an extension URL and make sure we notice that.
311  GURL url("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html");
312  AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
313  TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
314
315  // Check that the third entry (background) is an extension resource whose
316  // title starts with "Extension:".
317  ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType(
318      resource_count));
319  ASSERT_TRUE(model()->GetResourceWebContents(resource_count) == NULL);
320  ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL);
321  string16 prefix = l10n_util::GetStringFUTF16(
322      IDS_TASK_MANAGER_EXTENSION_PREFIX, string16());
323  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
324                         prefix, true));
325
326  // Check that the fourth entry (page.html) is of type extension and has both
327  // a tab contents and an extension. The title should start with "Extension:".
328  ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType(
329      resource_count + 1));
330  ASSERT_TRUE(model()->GetResourceWebContents(resource_count + 1) != NULL);
331  ASSERT_TRUE(model()->GetResourceExtension(resource_count + 1) != NULL);
332  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count + 1),
333                         prefix, true));
334
335  // Unload extension to avoid crash on Windows.
336  UnloadExtension(last_loaded_extension_id_);
337  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
338}
339
340IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeAppTabs) {
341  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
342  ASSERT_TRUE(LoadExtension(
343      test_data_dir_.AppendASCII("packaged_app")));
344  ExtensionService* service = extensions::ExtensionSystem::Get(
345      browser()->profile())->extension_service();
346  const extensions::Extension* extension =
347      service->GetExtensionById(last_loaded_extension_id_, false);
348
349  // New Tab Page.
350  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
351
352  // Open a new tab to the app's launch URL and make sure we notice that.
353  GURL url(extension->GetResourceURL("main.html"));
354  AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
355  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
356
357  // Check that the third entry (main.html) is of type extension and has both
358  // a tab contents and an extension. The title should start with "App:".
359  ASSERT_EQ(task_manager::Resource::EXTENSION, model()->GetResourceType(
360      resource_count));
361  ASSERT_TRUE(model()->GetResourceWebContents(resource_count) != NULL);
362  ASSERT_TRUE(model()->GetResourceExtension(resource_count) == extension);
363  string16 prefix = l10n_util::GetStringFUTF16(
364      IDS_TASK_MANAGER_APP_PREFIX, string16());
365  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
366                         prefix, true));
367
368  // Unload extension to avoid crash on Windows.
369  UnloadExtension(last_loaded_extension_id_);
370  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
371}
372
373IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeHostedAppTabs) {
374  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
375
376  // The app under test acts on URLs whose host is "localhost",
377  // so the URLs we navigate to must have host "localhost".
378  host_resolver()->AddRule("*", "127.0.0.1");
379  ASSERT_TRUE(test_server()->Start());
380  GURL::Replacements replace_host;
381  std::string host_str("localhost");  // must stay in scope with replace_host
382  replace_host.SetHostStr(host_str);
383  GURL base_url = test_server()->GetURL(
384      "files/extensions/api_test/app_process/");
385  base_url = base_url.ReplaceComponents(replace_host);
386
387  // Open a new tab to an app URL before the app is loaded.
388  GURL url(base_url.Resolve("path1/empty.html"));
389  content::WindowedNotificationObserver observer(
390      content::NOTIFICATION_NAV_ENTRY_COMMITTED,
391      content::NotificationService::AllSources());
392  AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
393  observer.Wait();
394
395  // Force the TaskManager to query the title.
396  Refresh();
397
398  // Check that the third entry's title starts with "Tab:".
399  string16 tab_prefix = l10n_util::GetStringFUTF16(
400      IDS_TASK_MANAGER_TAB_PREFIX, string16());
401  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
402                         tab_prefix, true));
403
404  // Load the hosted app and make sure it still starts with "Tab:",
405  // since it hasn't changed to an app process yet.
406  ASSERT_TRUE(LoadExtension(
407      test_data_dir_.AppendASCII("api_test").AppendASCII("app_process")));
408  // Force the TaskManager to query the title.
409  Refresh();
410  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
411                         tab_prefix, true));
412
413  // Now reload and check that the last entry's title now starts with "App:".
414  ui_test_utils::NavigateToURL(browser(), url);
415  // Force the TaskManager to query the title.
416  Refresh();
417  string16 app_prefix = l10n_util::GetStringFUTF16(
418      IDS_TASK_MANAGER_APP_PREFIX, string16());
419  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
420                         app_prefix, true));
421
422  // Disable extension and reload page.
423  DisableExtension(last_loaded_extension_id_);
424  ui_test_utils::NavigateToURL(browser(), url);
425
426  // Force the TaskManager to query the title.
427  Refresh();
428
429  // The third entry's title should be back to a normal tab.
430  ASSERT_TRUE(StartsWith(model()->GetResourceTitle(resource_count),
431                         tab_prefix, true));
432}
433
434IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_KillExtension) {
435  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
436
437  ASSERT_TRUE(LoadExtension(
438      test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
439
440  // Wait until we see the loaded extension in the task manager (the three
441  // resources are: the browser process, New Tab Page, and the extension).
442  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
443  EXPECT_EQ(1, TaskManager::GetBackgroundPageCount());
444
445  EXPECT_TRUE(model()->GetResourceExtension(0) == NULL);
446  EXPECT_TRUE(model()->GetResourceExtension(1) == NULL);
447  ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL);
448
449  // Kill the extension process and make sure we notice it.
450  TaskManager::GetInstance()->KillProcess(resource_count);
451  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
452  EXPECT_EQ(0, TaskManager::GetBackgroundPageCount());
453}
454
455// Disabled, http://crbug.com/66957.
456IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
457                       DISABLED_KillExtensionAndReload) {
458  ASSERT_TRUE(LoadExtension(
459      test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
460
461  // Wait until we see the loaded extension in the task manager (the three
462  // resources are: the browser process, New Tab Page, and the extension).
463  TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
464
465  EXPECT_TRUE(model()->GetResourceExtension(0) == NULL);
466  EXPECT_TRUE(model()->GetResourceExtension(1) == NULL);
467  ASSERT_TRUE(model()->GetResourceExtension(2) != NULL);
468
469  // Kill the extension process and make sure we notice it.
470  TaskManager::GetInstance()->KillProcess(2);
471  TaskManagerBrowserTestUtil::WaitForWebResourceChange(1);
472
473  // Reload the extension using the "crashed extension" infobar while the task
474  // manager is still visible. Make sure we don't crash and the extension
475  // gets reloaded and noticed in the task manager.
476  InfoBarService* infobar_service = InfoBarService::FromWebContents(
477      browser()->tab_strip_model()->GetActiveWebContents());
478  ASSERT_EQ(1U, infobar_service->infobar_count());
479  ConfirmInfoBarDelegate* delegate =
480      infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate();
481  ASSERT_TRUE(delegate);
482  delegate->Accept();
483  TaskManagerBrowserTestUtil::WaitForWebResourceChange(3);
484}
485
486#if defined(OS_WIN)
487// http://crbug.com/93158.
488#define MAYBE_ReloadExtension DISABLED_ReloadExtension
489#else
490#define MAYBE_ReloadExtension ReloadExtension
491#endif
492
493// Regression test for http://crbug.com/18693.
494IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_ReloadExtension) {
495  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
496  LOG(INFO) << "loading extension";
497  ASSERT_TRUE(LoadExtension(
498      test_data_dir_.AppendASCII("common").AppendASCII("background_page")));
499
500  // Wait until we see the loaded extension in the task manager (the three
501  // resources are: the browser process, New Tab Page, and the extension).
502  LOG(INFO) << "waiting for resource change";
503  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
504
505  EXPECT_TRUE(model()->GetResourceExtension(0) == NULL);
506  EXPECT_TRUE(model()->GetResourceExtension(1) == NULL);
507  ASSERT_TRUE(model()->GetResourceExtension(resource_count) != NULL);
508
509  const extensions::Extension* extension = model()->GetResourceExtension(
510      resource_count);
511  ASSERT_TRUE(extension != NULL);
512
513  // Reload the extension a few times and make sure our resource count
514  // doesn't increase.
515  LOG(INFO) << "First extension reload";
516  ReloadExtension(extension->id());
517  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
518  extension = model()->GetResourceExtension(resource_count);
519  ASSERT_TRUE(extension != NULL);
520
521  LOG(INFO) << "Second extension reload";
522  ReloadExtension(extension->id());
523  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
524  extension = model()->GetResourceExtension(resource_count);
525  ASSERT_TRUE(extension != NULL);
526
527  LOG(INFO) << "Third extension reload";
528  ReloadExtension(extension->id());
529  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
530}
531
532// Crashy, http://crbug.com/42301.
533IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest,
534                       DISABLED_PopulateWebCacheFields) {
535  int resource_count = TaskManager::GetInstance()->model()->ResourceCount();
536
537  // Open a new tab and make sure we notice that.
538  GURL url(ui_test_utils::GetTestUrl(base::FilePath(
539      base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File)));
540  AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
541  TaskManagerBrowserTestUtil::WaitForWebResourceChange(2);
542
543  // Check that we get some value for the cache columns.
544  DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(resource_count),
545            l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
546  DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(resource_count),
547            l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
548  DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(resource_count),
549            l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
550}
551
552#endif
553