Chromium Code Reviews| 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 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | |
| 2066 PopupCrossProcessNavigateAndBack) { | |
| 2067 StartServer(); | |
| 2068 | |
| 2069 // Load a page with links that open in a new window. | |
| 2070 std::string replacement_path; | |
| 2071 ASSERT_TRUE(GetFilePathWithHostAndPortReplacement( | |
| 2072 "files/click-noreferrer-links.html", | |
| 2073 foo_host_port_, | |
| 2074 &replacement_path)); | |
| 2075 NavigateToURL(shell(), test_server()->GetURL(replacement_path)); | |
| 2076 | |
| 2077 // Get the original SiteInstance for later comparison. | |
| 2078 scoped_refptr<SiteInstance> orig_site_instance( | |
| 2079 shell()->web_contents()->GetSiteInstance()); | |
| 2080 EXPECT_TRUE(orig_site_instance.get() != NULL); | |
| 2081 | |
| 2082 // Test clicking a target=foo link. | |
| 2083 ShellAddedObserver new_shell_observer; | |
| 2084 bool success = false; | |
| 2085 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 2086 shell()->web_contents(), | |
| 2087 "window.domAutomationController.send(clickSameSiteTargetedLink());", | |
| 2088 &success)); | |
| 2089 EXPECT_TRUE(success); | |
| 2090 Shell* new_shell = new_shell_observer.GetShell(); | |
| 2091 EXPECT_TRUE(new_shell->web_contents()->HasOpener()); | |
| 2092 | |
| 2093 // Wait for the navigation in the new tab to finish, if it hasn't. | |
| 2094 WaitForLoadStop(new_shell->web_contents()); | |
| 2095 EXPECT_EQ("/files/navigate_opener.html", | |
| 2096 new_shell->web_contents()->GetLastCommittedURL().path()); | |
| 2097 | |
| 2098 // Should have the same SiteInstance. | |
| 2099 scoped_refptr<SiteInstance> blank_site_instance( | |
| 2100 new_shell->web_contents()->GetSiteInstance()); | |
| 2101 EXPECT_EQ(orig_site_instance, blank_site_instance); | |
| 2102 | |
| 2103 // Capture the window reference, so we can check that accessing its location | |
| 2104 // works after navigating cross-process and back. | |
| 2105 GURL expected_url = new_shell->web_contents()->GetLastCommittedURL(); | |
| 2106 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | |
| 2107 "saveWindowReference();")); | |
| 2108 | |
| 2109 // Now navigate the new tab to a different site. | |
| 2110 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | |
| 2111 scoped_refptr<SiteInstance> new_site_instance( | |
| 2112 new_shell->web_contents()->GetSiteInstance()); | |
| 2113 EXPECT_NE(orig_site_instance, new_site_instance); | |
| 2114 EXPECT_TRUE(new_shell->web_contents()->HasOpener()); | |
| 2115 | |
| 2116 // Go back | |
|
Charlie Reis
2015/09/30 21:08:03
nit: End with period.
| |
| 2117 { | |
| 2118 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); | |
| 2119 new_shell->web_contents()->GetController().GoBack(); | |
| 2120 back_nav_load_observer.Wait(); | |
| 2121 } | |
| 2122 | |
| 2123 // Check that the location.href attribute is accessible and is correct. | |
| 2124 std::string result; | |
| 2125 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
| 2126 shell()->web_contents(), | |
| 2127 "window.domAutomationController.send(getExitingWindowLocation());", | |
| 2128 &result)); | |
| 2129 EXPECT_EQ(expected_url.spec(), result); | |
| 2130 } | |
| 2131 | |
| 2132 | |
| 2065 } // namespace content | 2133 } // namespace content |
| OLD | NEW |