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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/render_frame_host_manager_browsertest.cc
diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc
index 8ee53ea1bf7ad70aa44880c4a863895e4e223fb5..03b26c6372c4ab8216ddf43a82eabac23cc399a4 100644
--- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc
@@ -2062,4 +2062,57 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, UpdateOpener) {
EXPECT_EQ(bar_root, foo_root->opener());
}
+// Tests that when a popup is opened, which is then navigated cross-process and
+// back, it can be still accessed through the original window reference in
+// JavaScript. See https://crbug.com/537657
+IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
+ PopupKeepsWindowReferenceCrossProcesAndBack) {
+ StartServer();
+
+ // Load a page with links that open in a new window.
+ std::string replacement_path;
+ ASSERT_TRUE(GetFilePathWithHostAndPortReplacement(
+ "files/click-noreferrer-links.html",
+ foo_host_port_,
+ &replacement_path));
+ NavigateToURL(shell(), test_server()->GetURL(replacement_path));
+
+ // Click a target=foo link to open a popup.
+ ShellAddedObserver new_shell_observer;
+ bool success = false;
+ EXPECT_TRUE(ExecuteScriptAndExtractBool(
+ shell()->web_contents(),
+ "window.domAutomationController.send(clickSameSiteTargetedLink());",
+ &success));
+ EXPECT_TRUE(success);
+ Shell* new_shell = new_shell_observer.GetShell();
+ EXPECT_TRUE(new_shell->web_contents()->HasOpener());
+
+ // Wait for the navigation in the popup to finish, if it hasn't.
+ WaitForLoadStop(new_shell->web_contents());
+ EXPECT_EQ("/files/navigate_opener.html",
+ new_shell->web_contents()->GetLastCommittedURL().path());
+
+ // Capture the window reference, so we can check that accessing its location
+ // works after navigating cross-process and back.
+ GURL expected_url = new_shell->web_contents()->GetLastCommittedURL();
+ EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
+ "saveWindowReference();"));
+
+ // Now navigate the popup to a different site and then go back.
+ NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html"));
+ TestNavigationObserver back_nav_load_observer(new_shell->web_contents());
+ new_shell->web_contents()->GetController().GoBack();
+ back_nav_load_observer.Wait();
+
+ // Check that the location.href window attribute is accessible and is correct.
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ shell()->web_contents(),
+ "window.domAutomationController.send(getLastOpenedWindowLocation());",
+ &result));
+ EXPECT_EQ(expected_url.spec(), result);
+}
+
+
} // namespace content
« 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