OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "content/browser/frame_host/frame_tree.h" | 6 #include "content/browser/frame_host/frame_tree.h" |
7 #include "content/browser/frame_host/frame_tree_node.h" | 7 #include "content/browser/frame_host/frame_tree_node.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 root->child_at(2)->current_replication_state().origin.string() + "/", | 276 root->child_at(2)->current_replication_state().origin.string() + "/", |
277 main_url.GetOrigin().spec()); | 277 main_url.GetOrigin().spec()); |
278 | 278 |
279 // Navigating to a different URL should not clear sandbox flags. | 279 // Navigating to a different URL should not clear sandbox flags. |
280 GURL frame_url(embedded_test_server()->GetURL("/title1.html")); | 280 GURL frame_url(embedded_test_server()->GetURL("/title1.html")); |
281 NavigateFrameToURL(root->child_at(0), frame_url); | 281 NavigateFrameToURL(root->child_at(0), frame_url); |
282 EXPECT_EQ(root->child_at(0)->current_replication_state().sandbox_flags, | 282 EXPECT_EQ(root->child_at(0)->current_replication_state().sandbox_flags, |
283 blink::WebSandboxFlags::All); | 283 blink::WebSandboxFlags::All); |
284 } | 284 } |
285 | 285 |
| 286 // Ensure that a popup opened from a subframe sets its opener to the subframe's |
| 287 // FrameTreeNode, and that the opener is cleared if the subframe is destroyed. |
| 288 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, SubframeOpenerSetForNewWindow) { |
| 289 GURL main_url(embedded_test_server()->GetURL("/frame_tree/top.html")); |
| 290 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 291 |
| 292 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 293 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 294 ->GetFrameTree() |
| 295 ->root(); |
| 296 |
| 297 // Open a new window from a subframe. |
| 298 ShellAddedObserver new_shell_observer; |
| 299 GURL popup_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
| 300 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), |
| 301 "window.open('" + popup_url.spec() + "');")); |
| 302 Shell* new_shell = new_shell_observer.GetShell(); |
| 303 WebContents* new_contents = new_shell->web_contents(); |
| 304 WaitForLoadStop(new_contents); |
| 305 |
| 306 // Check that the new window's opener points to the correct subframe on |
| 307 // original window. |
| 308 FrameTreeNode* popup_root = |
| 309 static_cast<WebContentsImpl*>(new_contents)->GetFrameTree()->root(); |
| 310 EXPECT_EQ(root->child_at(0), popup_root->opener()); |
| 311 |
| 312 // Close the original window. This should clear the new window's opener. |
| 313 shell()->Close(); |
| 314 EXPECT_EQ(nullptr, popup_root->opener()); |
| 315 } |
| 316 |
286 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { | 317 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { |
287 public: | 318 public: |
288 CrossProcessFrameTreeBrowserTest() {} | 319 CrossProcessFrameTreeBrowserTest() {} |
289 | 320 |
290 void SetUpCommandLine(base::CommandLine* command_line) override { | 321 void SetUpCommandLine(base::CommandLine* command_line) override { |
291 command_line->AppendSwitch(switches::kSitePerProcess); | 322 command_line->AppendSwitch(switches::kSitePerProcess); |
292 } | 323 } |
293 | 324 |
294 void SetUpOnMainThread() override { | 325 void SetUpOnMainThread() override { |
295 host_resolver()->AddRule("*", "127.0.0.1"); | 326 host_resolver()->AddRule("*", "127.0.0.1"); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 GURL data_url("data:text/html,foo"); | 431 GURL data_url("data:text/html,foo"); |
401 NavigateFrameToURL(root->child_at(1), data_url); | 432 NavigateFrameToURL(root->child_at(1), data_url); |
402 | 433 |
403 // Navigating to a data URL should set a unique origin. This is represented | 434 // Navigating to a data URL should set a unique origin. This is represented |
404 // as "null" per RFC 6454. | 435 // as "null" per RFC 6454. |
405 EXPECT_EQ(root->child_at(1)->current_replication_state().origin.string(), | 436 EXPECT_EQ(root->child_at(1)->current_replication_state().origin.string(), |
406 "null"); | 437 "null"); |
407 } | 438 } |
408 | 439 |
409 } // namespace content | 440 } // namespace content |
OLD | NEW |