Commit c9f51dd4 authored by nasko's avatar nasko Committed by Commit bot

Fix setting the top-level FrameTreeNode name for named windows.

BUG=486889

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

Cr-Commit-Position: refs/heads/master@{#329543}
parent 3de51de0
......@@ -1204,6 +1204,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
GetRenderManager()->Init(
params.browser_context, params.site_instance, params.routing_id,
params.main_frame_routing_id);
frame_tree_.root()->SetFrameName(params.main_frame_name);
WebContentsViewDelegate* delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
......@@ -1582,6 +1583,7 @@ void WebContentsImpl::CreateNewWindow(
CreateParams create_params(GetBrowserContext(), site_instance.get());
create_params.routing_id = route_id;
create_params.main_frame_routing_id = main_frame_route_id;
create_params.main_frame_name = base::UTF16ToUTF8(params.frame_name);
create_params.opener = this;
create_params.opener_suppressed = params.opener_suppressed;
if (params.disposition == NEW_BACKGROUND_TAB)
......
......@@ -687,4 +687,52 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, ChangeDisplayMode) {
EXPECT_EQ(base::ASCIIToUTF16("true"), shell()->web_contents()->GetTitle());
}
IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, NewNamedWindow) {
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url = embedded_test_server()->GetURL("/click-noreferrer-links.html");
EXPECT_TRUE(NavigateToURL(shell(), url));
{
ShellAddedObserver new_shell_observer;
// Open a new, named window.
EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
"window.open('about:blank','new_window');"));
Shell* new_shell = new_shell_observer.GetShell();
WaitForLoadStop(new_shell->web_contents());
EXPECT_EQ("new_window",
static_cast<WebContentsImpl*>(new_shell->web_contents())
->GetFrameTree()->root()->frame_name());
bool success = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
new_shell->web_contents(),
"window.domAutomationController.send(window.name == 'new_window');",
&success));
EXPECT_TRUE(success);
}
{
ShellAddedObserver new_shell_observer;
// Test clicking a target=foo link.
bool success = false;
EXPECT_TRUE(ExecuteScriptAndExtractBool(
shell()->web_contents(),
"window.domAutomationController.send(clickSameSiteTargetedLink());",
&success));
EXPECT_TRUE(success);
Shell* new_shell = new_shell_observer.GetShell();
WaitForLoadStop(new_shell->web_contents());
EXPECT_EQ("foo",
static_cast<WebContentsImpl*>(new_shell->web_contents())
->GetFrameTree()->root()->frame_name());
}
}
} // namespace content
......@@ -110,6 +110,11 @@ class WebContents : public PageNavigator,
int routing_id;
int main_frame_routing_id;
// The name of the top-level frame of the new window. It is non-empty
// when creating a named window (e.g. <a target="foo"> or
// window.open('', 'bar')).
std::string main_frame_name;
// Initial size of the new WebContent's view. Can be (0, 0) if not needed.
gfx::Size initial_size;
......
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