summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 20:48:53 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 20:48:53 +0000
commit31f772629aebba90181e0a6fb7adea5cabe68c19 (patch)
tree947357e11f532a085de710552d657996eb6e9f96
parentaf3113ef6629b7ebc0cec009786b3abd26a36cad (diff)
downloadchromium_src-31f772629aebba90181e0a6fb7adea5cabe68c19.zip
chromium_src-31f772629aebba90181e0a6fb7adea5cabe68c19.tar.gz
chromium_src-31f772629aebba90181e0a6fb7adea5cabe68c19.tar.bz2
Unload the entire extension when any part of it crashes.
Also enable the task_manager_browsertest.cc (where I added the new test) on Linux. TEST=Covered by browser_tests. BUG=21635 Review URL: http://codereview.chromium.org/465007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33599 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extensions_service.cc12
-rw-r--r--chrome/browser/task_manager_browsertest.cc21
-rwxr-xr-xchrome/chrome.gyp5
3 files changed, 35 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index b00b33d..8eba54f 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -121,6 +121,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) {
@@ -838,6 +840,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 c1104ee..01fe25e 100644
--- a/chrome/browser/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager_browsertest.cc
@@ -119,6 +119,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 7126672..9e531fb 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -84,6 +84,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',
@@ -105,9 +106,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': [
@@ -131,6 +129,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': [