diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-13 18:42:44 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-13 18:42:44 +0000 |
commit | 3001324f90ac31f78c2fbfc526e14aa13ff27422 (patch) | |
tree | 3250614a301430ed349d1cdf48bd9c13fec3f6c5 | |
parent | 362ab2b8a44d482303ac4f0218a1581ff93bb16b (diff) | |
download | chromium_src-3001324f90ac31f78c2fbfc526e14aa13ff27422.zip chromium_src-3001324f90ac31f78c2fbfc526e14aa13ff27422.tar.gz chromium_src-3001324f90ac31f78c2fbfc526e14aa13ff27422.tar.bz2 |
Merge 33599 - 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
TBR=phajdan.jr@chromium.org
Review URL: http://codereview.chromium.org/491072
git-svn-id: svn://svn.chromium.org/chrome/branches/249/src@34448 0039d316-1c4b-4281-b951-d872f2087c98
-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': [ |