Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(493)

Unified Diff: chrome/browser/extensions/extension_browsertest.cc

Issue 2537263003: [Extensions] Fix lifetime bug in ExtensionAction/IconImage (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.";
« no previous file with comments | « chrome/browser/extensions/extension_action_manager.cc ('k') | chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698