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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 &success)); | 125 &success)); |
126 EXPECT_TRUE(success); | 126 EXPECT_TRUE(success); |
127 Shell* new_shell = new_shell_observer.GetShell(); | 127 Shell* new_shell = new_shell_observer.GetShell(); |
128 | 128 |
129 // Wait for the navigation in the new window to finish, if it hasn't. | 129 // Wait for the navigation in the new window to finish, if it hasn't. |
130 WaitForLoadStop(new_shell->web_contents()); | 130 WaitForLoadStop(new_shell->web_contents()); |
131 EXPECT_EQ("/files/navigate_opener.html", | 131 EXPECT_EQ("/files/navigate_opener.html", |
132 new_shell->web_contents()->GetLastCommittedURL().path()); | 132 new_shell->web_contents()->GetLastCommittedURL().path()); |
133 | 133 |
134 // Should have the same SiteInstance. | 134 // Should have the same SiteInstance. |
135 scoped_refptr<SiteInstance> blank_site_instance( | 135 EXPECT_EQ(orig_site_instance, new_shell->web_contents()->GetSiteInstance()); |
136 new_shell->web_contents()->GetSiteInstance()); | |
137 EXPECT_EQ(orig_site_instance, blank_site_instance); | |
138 | 136 |
139 // We should have access to the opened window's location. | 137 // We should have access to the opened window's location. |
140 success = false; | 138 success = false; |
141 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 139 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
142 shell()->web_contents(), | 140 shell()->web_contents(), |
143 "window.domAutomationController.send(testScriptAccessToWindow());", | 141 "window.domAutomationController.send(testScriptAccessToWindow());", |
144 &success)); | 142 &success)); |
145 EXPECT_TRUE(success); | 143 EXPECT_TRUE(success); |
146 | 144 |
147 // Now navigate the new window to a different site. | 145 // Now navigate the new window to a different site. |
148 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | 146 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); |
149 scoped_refptr<SiteInstance> new_site_instance( | 147 scoped_refptr<SiteInstance> new_site_instance( |
150 new_shell->web_contents()->GetSiteInstance()); | 148 new_shell->web_contents()->GetSiteInstance()); |
151 EXPECT_NE(orig_site_instance, new_site_instance); | 149 EXPECT_NE(orig_site_instance, new_site_instance); |
152 | 150 |
153 // We should no longer have script access to the opened window's location. | 151 // We should no longer have script access to the opened window's location. |
154 success = false; | 152 success = false; |
155 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 153 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
156 shell()->web_contents(), | 154 shell()->web_contents(), |
157 "window.domAutomationController.send(testScriptAccessToWindow());", | 155 "window.domAutomationController.send(testScriptAccessToWindow());", |
158 &success)); | 156 &success)); |
159 EXPECT_FALSE(success); | 157 EXPECT_FALSE(success); |
| 158 |
| 159 // We now navigate the window to an about:blank page. |
| 160 success = false; |
| 161 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 162 shell()->web_contents(), |
| 163 "window.domAutomationController.send(clickBlankTargetedLink());", |
| 164 &success)); |
| 165 EXPECT_TRUE(success); |
| 166 |
| 167 // Wait for the navigation in the new window to finish. |
| 168 WaitForLoadStop(new_shell->web_contents()); |
| 169 GURL blank_url(url::kAboutBlankURL); |
| 170 EXPECT_EQ(blank_url, |
| 171 new_shell->web_contents()->GetLastCommittedURL()); |
| 172 EXPECT_EQ(orig_site_instance, new_shell->web_contents()->GetSiteInstance()); |
| 173 |
| 174 // We should have access to the opened window's location. |
| 175 success = false; |
| 176 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 177 shell()->web_contents(), |
| 178 "window.domAutomationController.send(testScriptAccessToWindow());", |
| 179 &success)); |
| 180 EXPECT_TRUE(success); |
160 } | 181 } |
161 | 182 |
162 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer | 183 // Test for crbug.com/24447. Following a cross-site link with rel=noreferrer |
163 // and target=_blank should create a new SiteInstance. | 184 // and target=_blank should create a new SiteInstance. |
164 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, | 185 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, |
165 SwapProcessWithRelNoreferrerAndTargetBlank) { | 186 SwapProcessWithRelNoreferrerAndTargetBlank) { |
166 StartServer(); | 187 StartServer(); |
167 | 188 |
168 // Load a page with links that open in a new window. | 189 // Load a page with links that open in a new window. |
169 std::string replacement_path; | 190 std::string replacement_path; |
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 back_nav_load_observer.Wait(); | 1663 back_nav_load_observer.Wait(); |
1643 EXPECT_NE(process_id, | 1664 EXPECT_NE(process_id, |
1644 shell()->web_contents()->GetRenderProcessHost()->GetID()); | 1665 shell()->web_contents()->GetRenderProcessHost()->GetID()); |
1645 | 1666 |
1646 // Ensure that the file access still exists in the new process ID. | 1667 // Ensure that the file access still exists in the new process ID. |
1647 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( | 1668 EXPECT_TRUE(ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile( |
1648 shell()->web_contents()->GetRenderProcessHost()->GetID(), file)); | 1669 shell()->web_contents()->GetRenderProcessHost()->GetID(), file)); |
1649 } | 1670 } |
1650 | 1671 |
1651 } // namespace content | 1672 } // namespace content |
OLD | NEW |