Chromium Code Reviews| Index: chrome/browser/extensions/api/management/management_api_browsertest.cc |
| diff --git a/chrome/browser/extensions/api/management/management_api_browsertest.cc b/chrome/browser/extensions/api/management/management_api_browsertest.cc |
| index 51663c98415db6101b3ea3d65db2aeb34f51bb78..84d213c6cadb5078cda5ae7e8b6664361a8161c0 100644 |
| --- a/chrome/browser/extensions/api/management/management_api_browsertest.cc |
| +++ b/chrome/browser/extensions/api/management/management_api_browsertest.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/common/chrome_switches.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/common/url_constants.h" |
| +#include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/test_utils.h" |
| namespace keys = extension_management_api_constants; |
| @@ -31,18 +32,12 @@ namespace extensions { |
| class ExtensionManagementApiBrowserTest : public ExtensionBrowserTest { |
| protected: |
| bool CrashEnabledExtension(const std::string& extension_id) { |
| - content::WindowedNotificationObserver extension_crash_observer( |
| - chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| - content::NotificationService::AllSources()); |
| ExtensionHost* background_host = |
| ExtensionSystem::Get(browser()->profile())-> |
| process_manager()->GetBackgroundHostForExtension(extension_id); |
| if (!background_host) |
| return false; |
| - background_host->host_contents()->GetController().LoadURL( |
| - GURL(content::kChromeUICrashURL), content::Referrer(), |
| - content::PAGE_TRANSITION_LINK, std::string()); |
| - extension_crash_observer.Wait(); |
| + content::CrashTab(background_host->host_contents()); |
| return true; |
| } |
| }; |
| @@ -257,27 +252,41 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, |
| IN_PROC_BROWSER_TEST_F(ExtensionManagementApiEscalationTest, |
| SetEnabled) { |
| + LOG(INFO) << "SetEnabled: start of test."; |
| // Expect an error about no gesture. |
| SetEnabled(true, false, keys::kGestureNeededForEscalationError); |
| + LOG(INFO) << "SetEnabled: setenabled with gesture error."; |
|
ncarter (slow)
2013/11/12 03:38:26
Don't forget to remove these LOG(INFO)s
Charlie Reis
2013/11/12 16:09:35
Done.
|
| // Expect an error that user cancelled the dialog. |
| CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| switches::kAppsGalleryInstallAutoConfirmForTests, "cancel"); |
| SetEnabled(true, true, keys::kUserDidNotReEnableError); |
| + LOG(INFO) << "SetEnabled: setenabled with user cancel error."; |
| - // This should succeed when user accepts dialog. |
| + // This should succeed when user accepts dialog. We must wait for the process |
| + // to connect before trying to crash it. |
| + content::WindowedNotificationObserver observer( |
| + content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
|
ncarter (slow)
2013/11/12 03:38:26
Change this to chrome::NOTIFICATION_EXTENSION_HOST
Charlie Reis
2013/11/12 16:09:35
Done.
|
| + content::NotificationService::AllSources()); |
| CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); |
| SetEnabled(true, true, std::string()); |
| + LOG(INFO) << "SetEnabled: setenabled success."; |
| + observer.Wait(); |
| + LOG(INFO) << "SetEnabled: process created."; |
| // Crash the extension. Mock a reload by disabling and then enabling. The |
| // extension should be reloaded and enabled. |
| ASSERT_TRUE(CrashEnabledExtension(kId)); |
| + LOG(INFO) << "SetEnabled: extension process crashed."; |
| SetEnabled(false, true, std::string()); |
| + LOG(INFO) << "SetEnabled: disabled."; |
| SetEnabled(true, true, std::string()); |
| + LOG(INFO) << "SetEnabled: enabled."; |
| const Extension* extension = ExtensionSystem::Get(browser()->profile()) |
| ->extension_service()->GetExtensionById(kId, false); |
| EXPECT_TRUE(extension); |
| + LOG(INFO) << "SetEnabled: done."; |
| } |
| } // namespace extensions |