Commit e087d17d authored by yoz@chromium.org's avatar yoz@chromium.org

Dispatch browser action clicks to the profile for the browser window.

This fixes a bug where incognito split mode extensions were getting clicks from incognito browsers sent to the regular profile.

BUG=314142

Review URL: https://codereview.chromium.org/50433008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232968 0039d316-1c4b-4281-b951-d872f2087c98
parent d346a27b
...@@ -571,6 +571,39 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) { ...@@ -571,6 +571,39 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) {
EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1));
} }
// Tests that events are dispatched to the correct profile for split mode
// extensions.
IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoSplit) {
ResultCatcher catcher;
const Extension* extension = LoadExtensionWithFlags(
test_data_dir_.AppendASCII("browser_action/split_mode"),
kFlagEnableIncognito);
ASSERT_TRUE(extension) << message_;
// Open an incognito window.
Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile();
Browser* incognito_browser =
new Browser(Browser::CreateParams(incognito_profile,
browser()->host_desktop_type()));
// Navigate just to have a tab in this window, otherwise wonky things happen.
ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank"));
ASSERT_EQ(1,
BrowserActionTestUtil(incognito_browser).NumberOfBrowserActions());
// A click in the regular profile should open a tab in the regular profile.
ExtensionService* service = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service();
service->toolbar_model()->ExecuteBrowserAction(
extension, browser(), NULL, true);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
// A click in the incognito profile should open a tab in the
// incognito profile.
service->toolbar_model()->ExecuteBrowserAction(
extension, incognito_browser, NULL, true);
ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
}
// Disabled because of failures (crashes) on ASAN bot. // Disabled because of failures (crashes) on ASAN bot.
// See http://crbug.com/98861. // See http://crbug.com/98861.
IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DISABLED_CloseBackgroundPage) { IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DISABLED_CloseBackgroundPage) {
......
...@@ -163,7 +163,7 @@ ExtensionToolbarModel::Action ExtensionToolbarModel::ExecuteBrowserAction( ...@@ -163,7 +163,7 @@ ExtensionToolbarModel::Action ExtensionToolbarModel::ExecuteBrowserAction(
} }
extensions::ExtensionActionAPI::BrowserActionExecuted( extensions::ExtensionActionAPI::BrowserActionExecuted(
service_->profile(), *browser_action, web_contents); browser->profile(), *browser_action, web_contents);
return ACTION_NONE; return ACTION_NONE;
} }
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.create({ url: 'about:blank' }, function(newtab) {
chrome.windows.get(tab.windowId, { populate: true }, function(window) {
if (!window) {
chrome.test.notifyFail(
'Could not get window for the tab (probably due to wrong profile)');
return;
}
chrome.test.assertEq(2, window.tabs.length);
chrome.test.notifyPass();
});
});
});
{
"name": "Split mode browser action test",
"description": "",
"version": "0",
"manifest_version": 2,
"browser_action": {
"default_title": "create a tab"
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"incognito": "split"
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment