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

Unified Diff: chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc

Issue 2537263003: [Extensions] Fix lifetime bug in ExtensionAction/IconImage (Closed)
Patch Set: Created 4 years 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/ui/toolbar/browser_actions_bar_browsertest.cc
diff --git a/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc b/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc
index 020a11f50d9ab11b69fa315bf2d47a47702b2762..7c0e3f87f7e2bb15dfb29cf5102c43fc35419ecb 100644
--- a/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc
+++ b/chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc
@@ -10,6 +10,7 @@
#include "base/bind_helpers.h"
#include "base/macros.h"
#include "base/run_loop.h"
+#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
#include "chrome/browser/extensions/browser_action_test_util.h"
#include "chrome/browser/extensions/extension_action.h"
@@ -636,3 +637,44 @@ IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, RemovePoppedOutAction) {
EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions());
EXPECT_FALSE(toolbar_actions_bar->popped_out_action());
}
+
+// A test that runs in incognito mode.
+class BrowserActionsBarIncognitoTest : public BrowserActionsBarBrowserTest {
+ public:
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ BrowserActionsBarBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch("incognito");
+ }
+};
+
+// Tests that first loading an extension action in an incognito profile, then
+// removing the incognito profile and using the extension action in a normal
+// profile doesn't crash.
+// Regression test for crbug.com/663726.
+IN_PROC_BROWSER_TEST_F(BrowserActionsBarIncognitoTest, IncognitoMode) {
+ EXPECT_TRUE(browser()->profile()->IsOffTheRecord());
+ const extensions::Extension* extension = LoadExtensionIncognito(
+ test_data_dir_.AppendASCII("api_test/browser_action_with_icon"));
+ ASSERT_TRUE(extension);
+ Browser* second_browser =
+ new Browser(Browser::CreateParams(profile()->GetOriginalProfile()));
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(second_browser->profile()->IsOffTheRecord());
+
+ content::WindowedNotificationObserver window_close_observer(
+ chrome::NOTIFICATION_BROWSER_CLOSED, content::Source<Browser>(browser()));
+ browser()->window()->Close();
+ window_close_observer.Wait();
+
+ std::vector<ToolbarActionViewController*> actions =
+ second_browser->window()->GetToolbarActionsBar()->GetActions();
+ ASSERT_EQ(1u, actions.size());
+ gfx::Image icon = actions[0]->GetIcon(
+ second_browser->tab_strip_model()->GetActiveWebContents(),
+ gfx::Size(ToolbarActionsBar::IconWidth(false),
+ ToolbarActionsBar::IconHeight()));
+ const gfx::ImageSkia* skia = icon.ToImageSkia();
+ ASSERT_TRUE(skia);
+ // Force the image to try and load a representation.
+ skia->GetRepresentation(2.0);
+}

Powered by Google App Engine
This is Rietveld 408576698