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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 1383513005: Ensure window reference is valid when navigating cross-process and back. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing a nit. Created 5 years, 2 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <set> 5 #include <set>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 EXPECT_TRUE(success); 2055 EXPECT_TRUE(success);
2056 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 2056 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
2057 2057
2058 // Check that a non-null assignment to the opener doesn't change the opener 2058 // Check that a non-null assignment to the opener doesn't change the opener
2059 // in the browser process. 2059 // in the browser process.
2060 EXPECT_TRUE( 2060 EXPECT_TRUE(
2061 ExecuteScript(foo_shell->web_contents(), "window.opener = window;")); 2061 ExecuteScript(foo_shell->web_contents(), "window.opener = window;"));
2062 EXPECT_EQ(bar_root, foo_root->opener()); 2062 EXPECT_EQ(bar_root, foo_root->opener());
2063 } 2063 }
2064 2064
2065 // Tests that when a popup is opened, which is then navigated cross-process and
2066 // back, it can be still accessed through the original window reference in
2067 // JavaScript. See https://crbug.com/537657
2068 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
2069 PopupKeepsWindowReferenceCrossProcesAndBack) {
2070 StartServer();
2071
2072 // Load a page with links that open in a new window.
2073 std::string replacement_path;
2074 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
2075 "files/click-noreferrer-links.html",
2076 foo_host_port_,
2077 &replacement_path));
2078 NavigateToURL(shell(), test_server()->GetURL(replacement_path));
2079
2080 // Click a target=foo link to open a popup.
2081 ShellAddedObserver new_shell_observer;
2082 bool success = false;
2083 EXPECT_TRUE(ExecuteScriptAndExtractBool(
2084 shell()->web_contents(),
2085 "window.domAutomationController.send(clickSameSiteTargetedLink());",
2086 &success));
2087 EXPECT_TRUE(success);
2088 Shell* new_shell = new_shell_observer.GetShell();
2089 EXPECT_TRUE(new_shell->web_contents()->HasOpener());
2090
2091 // Wait for the navigation in the popup to finish, if it hasn't.
2092 WaitForLoadStop(new_shell->web_contents());
2093 EXPECT_EQ("/files/navigate_opener.html",
2094 new_shell->web_contents()->GetLastCommittedURL().path());
2095
2096 // Capture the window reference, so we can check that accessing its location
2097 // works after navigating cross-process and back.
2098 GURL expected_url = new_shell->web_contents()->GetLastCommittedURL();
2099 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
2100 "saveWindowReference();"));
2101
2102 // Now navigate the popup to a different site and then go back.
2103 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html"));
2104 TestNavigationObserver back_nav_load_observer(new_shell->web_contents());
2105 new_shell->web_contents()->GetController().GoBack();
2106 back_nav_load_observer.Wait();
2107
2108 // Check that the location.href window attribute is accessible and is correct.
2109 std::string result;
2110 EXPECT_TRUE(ExecuteScriptAndExtractString(
2111 shell()->web_contents(),
2112 "window.domAutomationController.send(getLastOpenedWindowLocation());",
2113 &result));
2114 EXPECT_EQ(expected_url.spec(), result);
2115 }
2116
2117
2065 } // namespace content 2118 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/test/data/click-noreferrer-links.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698