OLD | NEW |
---|---|
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 Loading... | |
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, can be still accessed through the original window reference in | |
Charlie Reis
2015/09/30 21:49:07
nit: it can
nasko
2015/09/30 21:54:56
Done.
| |
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 |
OLD | NEW |