| 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
| 8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 // be created in the same SiteInstance as the parent. | 479 // be created in the same SiteInstance as the parent. |
| 480 { | 480 { |
| 481 std::string script("var f = document.createElement('iframe');" | 481 std::string script("var f = document.createElement('iframe');" |
| 482 "f.srcdoc = 'some content';" | 482 "f.srcdoc = 'some content';" |
| 483 "document.body.appendChild(f)"); | 483 "document.body.appendChild(f)"); |
| 484 TestNavigationObserver observer(shell()->web_contents()); | 484 TestNavigationObserver observer(shell()->web_contents()); |
| 485 EXPECT_TRUE(ExecuteScript(root, script)); | 485 EXPECT_TRUE(ExecuteScript(root, script)); |
| 486 EXPECT_EQ(2U, root->child_count()); | 486 EXPECT_EQ(2U, root->child_count()); |
| 487 observer.Wait(); | 487 observer.Wait(); |
| 488 | 488 |
| 489 EXPECT_EQ(GURL(url::kAboutBlankURL), root->child_at(1)->current_url()); | 489 EXPECT_EQ(GURL(kAboutSrcDocURL), root->child_at(1)->current_url()); |
| 490 EXPECT_TRUE(ExecuteScriptAndExtractString( | 490 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 491 root->child_at(1), "domAutomationController.send(document.origin);", | 491 root->child_at(1), "domAutomationController.send(document.origin);", |
| 492 &frame_origin)); | 492 &frame_origin)); |
| 493 EXPECT_EQ(root->current_frame_host()->GetLastCommittedURL().GetOrigin(), | 493 EXPECT_EQ(root->current_frame_host()->GetLastCommittedURL().GetOrigin(), |
| 494 GURL(frame_origin)); | 494 GURL(frame_origin)); |
| 495 EXPECT_NE(child->current_frame_host()->GetLastCommittedURL().GetOrigin(), | 495 EXPECT_NE(child->current_frame_host()->GetLastCommittedURL().GetOrigin(), |
| 496 GURL(frame_origin)); | 496 GURL(frame_origin)); |
| 497 } | 497 } |
| 498 | 498 |
| 499 // Set srcdoc on the existing cross-site frame. It should navigate the frame | 499 // Set srcdoc on the existing cross-site frame. It should navigate the frame |
| 500 // back to the origin of the parent. | 500 // back to the origin of the parent. |
| 501 { | 501 { |
| 502 std::string script("var f = document.getElementById('child-0');" | 502 std::string script("var f = document.getElementById('child-0');" |
| 503 "f.srcdoc = 'some content';"); | 503 "f.srcdoc = 'some content';"); |
| 504 TestNavigationObserver observer(shell()->web_contents()); | 504 TestNavigationObserver observer(shell()->web_contents()); |
| 505 EXPECT_TRUE(ExecuteScript(root, script)); | 505 EXPECT_TRUE(ExecuteScript(root, script)); |
| 506 observer.Wait(); | 506 observer.Wait(); |
| 507 | 507 |
| 508 EXPECT_EQ(GURL(url::kAboutBlankURL), child->current_url()); | 508 EXPECT_EQ(GURL(kAboutSrcDocURL), child->current_url()); |
| 509 EXPECT_TRUE(ExecuteScriptAndExtractString( | 509 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 510 child, "domAutomationController.send(document.origin);", | 510 child, "domAutomationController.send(document.origin);", |
| 511 &frame_origin)); | 511 &frame_origin)); |
| 512 EXPECT_EQ(root->current_frame_host()->GetLastCommittedURL().GetOrigin(), | 512 EXPECT_EQ(root->current_frame_host()->GetLastCommittedURL().GetOrigin(), |
| 513 GURL(frame_origin)); | 513 GURL(frame_origin)); |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 | 516 |
| 517 // Ensure that sandbox flags are correctly set when child frames are created. | 517 // Ensure that sandbox flags are correctly set when child frames are created. |
| 518 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, SandboxFlagsSetForChildFrames) { | 518 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, SandboxFlagsSetForChildFrames) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // Make sure we did a process transfer back to "b.is". | 755 // Make sure we did a process transfer back to "b.is". |
| 756 EXPECT_EQ( | 756 EXPECT_EQ( |
| 757 " Site A ------------ proxies for B\n" | 757 " Site A ------------ proxies for B\n" |
| 758 " +--Site B ------- proxies for A\n" | 758 " +--Site B ------- proxies for A\n" |
| 759 "Where A = http://a.com/\n" | 759 "Where A = http://a.com/\n" |
| 760 " B = http://b.is/", | 760 " B = http://b.is/", |
| 761 FrameTreeVisualizer().DepictFrameTree(root)); | 761 FrameTreeVisualizer().DepictFrameTree(root)); |
| 762 } | 762 } |
| 763 | 763 |
| 764 } // namespace content | 764 } // namespace content |
| OLD | NEW |