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