diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 12 | ||||
-rw-r--r-- | chrome/browser/task_manager_browsertest.cc | 21 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 5 |
3 files changed, 35 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 141c49d..2de031f 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -125,6 +125,8 @@ ExtensionsService::ExtensionsService(Profile* profile, registrar_.Add(this, NotificationType::EXTENSION_HOST_DID_STOP_LOADING, NotificationService::AllSources()); + registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, + Source<Profile>(profile_)); // Set up the ExtensionUpdater if (autoupdate_enabled) { @@ -834,6 +836,16 @@ void ExtensionsService::Observe(NotificationType type, break; } + case NotificationType::EXTENSION_PROCESS_CRASHED: { + DCHECK_EQ(profile_, Source<Profile>(source).ptr()); + ExtensionHost* host = Details<ExtensionHost>(details).ptr(); + + // Unload the entire extension. We want it to be in a consistent state: + // either fully working or not loaded at all, but never half-crashed. + UnloadExtension(host->extension()->id()); + break; + } + default: NOTREACHED() << "Unexpected notification type."; } diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc index cedcc84..feefdcc 100644 --- a/chrome/browser/task_manager_browsertest.cc +++ b/chrome/browser/task_manager_browsertest.cc @@ -118,6 +118,27 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeExtensionChanges) { WaitForResourceChange(4); } +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, KillExtension) { + // Show the task manager. This populates the model, and helps with debugging + // (you see the task manager). + browser()->window()->ShowTaskManager(); + + ASSERT_TRUE(LoadExtension( + test_data_dir_.AppendASCII("common").AppendASCII("background_page"))); + + // Wait until we see the loaded extension in the task manager (the three + // resources are: the browser process, New Tab Page, and the extension). + WaitForResourceChange(3); + + EXPECT_TRUE(model()->GetResourceExtension(0) == NULL); + EXPECT_TRUE(model()->GetResourceExtension(1) == NULL); + ASSERT_TRUE(model()->GetResourceExtension(2) != NULL); + + // Kill the extension process and make sure we notice it. + TaskManager::GetInstance()->KillProcess(2); + WaitForResourceChange(2); +} + // Regression test for http://crbug.com/18693. IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, ReloadExtension) { // Show the task manager. This populates the model, and helps with debugging diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index cafef0a..0888468 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -82,6 +82,7 @@ 'browser/net/ftp_browsertest.cc', 'browser/privacy_blacklist/blacklist_manager_browsertest.cc', 'browser/ssl/ssl_browser_tests.cc', + 'browser/task_manager_browsertest.cc', ], 'browser_tests_sources_gtk_specific': [ 'browser/gtk/view_id_util_browsertest.cc', @@ -103,9 +104,6 @@ 'browser/child_process_security_policy_browser_test.cc', 'browser/renderer_host/test/web_cache_manager_browsertest.cc', 'browser/renderer_host/test/render_view_host_manager_browsertest.cc', - # TODO(jcampan): once the task manager works on Mac, move this test to the - # non win specific section. - 'browser/task_manager_browsertest.cc', 'browser/views/browser_views_accessibility_browsertest.cc', ], 'browser_tests_sources_exclude_on_mac': [ @@ -128,6 +126,7 @@ 'browser/extensions/stubs_apitest.cc', 'browser/privacy_blacklist/blacklist_manager_browsertest.cc', 'browser/ssl/ssl_browser_tests.cc', + 'browser/task_manager_browsertest.cc', ], # TODO(jcampan): move these vars to views.gyp. 'views_unit_tests_sources': [ |