Index: chrome/browser/extensions/extension_browsertest.cc |
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc |
index 13048673331c7fc3880d762b0c57e95c1663bdfa..181379142291159d1c6d124c3cd1a41d5a114207 100644 |
--- a/chrome/browser/extensions/extension_browsertest.cc |
+++ b/chrome/browser/extensions/extension_browsertest.cc |
@@ -226,14 +226,19 @@ ExtensionBrowserTest::LoadExtensionWithInstallParam( |
const std::string extension_id = extension->id(); |
+ // If this is an incognito test (e.g. where the test fixture appended the |
+ // --incognito flag), we need to use the original profile when we wait for |
+ // notifications. |
+ Profile* original_profile = profile()->GetOriginalProfile(); |
+ |
if (!install_param.empty()) { |
- extensions::ExtensionPrefs::Get(profile()) |
+ extensions::ExtensionPrefs::Get(original_profile) |
->SetInstallParam(extension_id, install_param); |
// Re-enable the extension if needed. |
if (registry->enabled_extensions().Contains(extension_id)) { |
content::WindowedNotificationObserver load_signal( |
extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
- content::Source<Profile>(profile())); |
+ content::Source<Profile>(original_profile)); |
// Reload the extension so that the |
// NOTIFICATION_EXTENSION_LOADED_DEPRECATED |
// observers may access |install_param|. |
@@ -251,12 +256,13 @@ ExtensionBrowserTest::LoadExtensionWithInstallParam( |
{ |
content::WindowedNotificationObserver load_signal( |
extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
- content::Source<Profile>(profile())); |
- CHECK(!extensions::util::IsIncognitoEnabled(extension_id, profile())) |
+ content::Source<Profile>(original_profile)); |
+ CHECK(!extensions::util::IsIncognitoEnabled(extension_id, original_profile)) |
<< extension_id << " is enabled in incognito, but shouldn't be"; |
if (flags & kFlagEnableIncognito) { |
- extensions::util::SetIsIncognitoEnabled(extension_id, profile(), true); |
+ extensions::util::SetIsIncognitoEnabled(extension_id, original_profile, |
+ true); |
load_signal.Wait(); |
extension = service->GetExtensionById(extension_id, false); |
CHECK(extension) << extension_id << " not found after reloading."; |
@@ -266,10 +272,11 @@ ExtensionBrowserTest::LoadExtensionWithInstallParam( |
{ |
content::WindowedNotificationObserver load_signal( |
extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
- content::Source<Profile>(profile())); |
- CHECK(extensions::util::AllowFileAccess(extension_id, profile())); |
+ content::Source<Profile>(original_profile)); |
+ CHECK(extensions::util::AllowFileAccess(extension_id, original_profile)); |
if (!(flags & kFlagEnableFileAccess)) { |
- extensions::util::SetAllowFileAccess(extension_id, profile(), false); |
+ extensions::util::SetAllowFileAccess(extension_id, original_profile, |
+ false); |
load_signal.Wait(); |
extension = service->GetExtensionById(extension_id, false); |
CHECK(extension) << extension_id << " not found after reloading."; |