Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 797813006: Replicate sandbox flags for OOPIF (Chromium part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iframe-sandbox-flags-part1
Patch Set: Rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/frame_host/cross_process_frame_connector.h" 10 #include "content/browser/frame_host/cross_process_frame_connector.h"
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 "window.domAutomationController.send(location.ancestorOrigins[0]);", 948 "window.domAutomationController.send(location.ancestorOrigins[0]);",
949 &result)); 949 &result));
950 EXPECT_EQ(result + "/", foo_url.GetOrigin().spec()); 950 EXPECT_EQ(result + "/", foo_url.GetOrigin().spec());
951 EXPECT_TRUE(ExecuteScriptAndExtractString( 951 EXPECT_TRUE(ExecuteScriptAndExtractString(
952 bottom_child->current_frame_host(), 952 bottom_child->current_frame_host(),
953 "window.domAutomationController.send(location.ancestorOrigins[1]);", 953 "window.domAutomationController.send(location.ancestorOrigins[1]);",
954 &result)); 954 &result));
955 EXPECT_EQ(result + "/", main_url.GetOrigin().spec()); 955 EXPECT_EQ(result + "/", main_url.GetOrigin().spec());
956 } 956 }
957 957
958 // Check that iframe sandbox flags are replicated correctly.
959 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsReplication) {
960 GURL main_url(embedded_test_server()->GetURL("/sandboxed_frames.html"));
961 EXPECT_TRUE(NavigateToURL(shell(), main_url));
962
963 // It is safe to obtain the root frame tree node here, as it doesn't change.
964 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
965 ->GetFrameTree()
966 ->root();
967
968 SitePerProcessWebContentsObserver observer(shell()->web_contents());
969
970 // Navigate the second (sandboxed) subframe to a cross-site page with a
971 // subframe. NavigateFrameToURL can't be used here because it doesn't
nasko 2015/01/20 23:26:49 I think it still can be used, but cannot be the co
alexmos 2015/01/21 02:10:43 Done.
972 // guarantee that FrameTreeNodes will have been created for child frames when
973 // it returns.
974 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 4);
975 GURL foo_url(
976 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"));
977 NavigationController::LoadURLParams params(foo_url);
978 params.transition_type = ui::PAGE_TRANSITION_LINK;
979 params.frame_tree_node_id = root->child_at(1)->frame_tree_node_id();
980 root->child_at(1)->navigator()->GetController()->LoadURLWithParams(params);
981 frame_observer.Wait();
982
983 // We can't use a SitePerProcessWebContentsObserver to verify the URL here,
984 // since the frame has children that may have clobbered it in the observer.
985 EXPECT_EQ(foo_url, root->child_at(1)->current_url());
986
987 // Load cross-site page into subframe's subframe.
988 ASSERT_EQ(2U, root->child_at(1)->child_count());
989 GURL bar_url(embedded_test_server()->GetURL("bar.com", "/title1.html"));
990 NavigateFrameToURL(root->child_at(1)->child_at(0), bar_url);
991 EXPECT_TRUE(observer.navigation_succeeded());
992 EXPECT_EQ(bar_url, observer.navigation_url());
993
994 // Opening a popup in the sandboxed foo.com iframe should fail.
995 bool success = false;
996 EXPECT_TRUE(
997 ExecuteScriptAndExtractBool(root->child_at(1)->current_frame_host(),
998 "window.domAutomationController.send("
999 "!window.open('data:text/html,dataurl'));",
1000 &success));
1001 EXPECT_TRUE(success);
nasko 2015/01/20 23:26:49 Might be useful to install an observer monitoring
alexmos 2015/01/21 02:10:43 Good point. I added checks that Shell::windows().
nasko 2015/01/21 17:36:37 Yes, that is totally fine.
1002
1003 // Opening a popup in a frame whose parent is sandboxed should also fail.
1004 // Here, bar.com frame's sandboxed parent frame is a remote frame in
1005 // bar.com's process.
1006 success = false;
1007 EXPECT_TRUE(ExecuteScriptAndExtractBool(
1008 root->child_at(1)->child_at(0)->current_frame_host(),
1009 "window.domAutomationController.send("
1010 "!window.open('data:text/html,dataurl'));",
1011 &success));
1012 EXPECT_TRUE(success);
1013
1014 // Same, but now try the case where bar.com frame's sandboxed parent is a
1015 // local frame in bar.com's process.
1016 success = false;
1017 EXPECT_TRUE(ExecuteScriptAndExtractBool(
1018 root->child_at(2)->child_at(0)->current_frame_host(),
1019 "window.domAutomationController.send("
1020 "!window.open('data:text/html,dataurl'));",
1021 &success));
1022 EXPECT_TRUE(success);
1023
1024 // Check that foo.com frame's location.ancestorOrigins contains the correct
1025 // origin for the parent, which should be unaffected by sandboxing.
1026 int ancestor_origins_length = 0;
1027 EXPECT_TRUE(ExecuteScriptAndExtractInt(
1028 root->child_at(1)->current_frame_host(),
1029 "window.domAutomationController.send(location.ancestorOrigins.length);",
1030 &ancestor_origins_length));
1031 EXPECT_EQ(1, ancestor_origins_length);
1032 std::string result;
1033 EXPECT_TRUE(ExecuteScriptAndExtractString(
1034 root->child_at(1)->current_frame_host(),
1035 "window.domAutomationController.send(location.ancestorOrigins[0]);",
1036 &result));
1037 EXPECT_EQ(result + "/", main_url.GetOrigin().spec());
1038
1039 // Now check location.ancestorOrigins for the bar.com frame. The middle frame
1040 // (foo.com's) origin should be unique, since that frame is sandboxed, and
1041 // the top frame should match |main_url|.
1042 FrameTreeNode* bottom_child = root->child_at(1)->child_at(0);
1043 EXPECT_TRUE(ExecuteScriptAndExtractInt(
1044 bottom_child->current_frame_host(),
1045 "window.domAutomationController.send(location.ancestorOrigins.length);",
1046 &ancestor_origins_length));
1047 EXPECT_EQ(2, ancestor_origins_length);
1048 EXPECT_TRUE(ExecuteScriptAndExtractString(
1049 bottom_child->current_frame_host(),
1050 "window.domAutomationController.send(location.ancestorOrigins[0]);",
1051 &result));
1052 EXPECT_EQ(result, "null");
1053 EXPECT_TRUE(ExecuteScriptAndExtractString(
1054 bottom_child->current_frame_host(),
1055 "window.domAutomationController.send(location.ancestorOrigins[1]);",
1056 &result));
1057 EXPECT_EQ(result + "/", main_url.GetOrigin().spec());
1058 }
1059
958 // TODO(lfg): Merge the test below with NavigateRemoteFrame test. 1060 // TODO(lfg): Merge the test below with NavigateRemoteFrame test.
959 // TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since 1061 // TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since
960 // the renderer process crashes, it causes the title watcher to never return. 1062 // the renderer process crashes, it causes the title watcher to never return.
961 // Alternatively, this could also be fixed if we could use NavigateIframeToURL 1063 // Alternatively, this could also be fixed if we could use NavigateIframeToURL
962 // and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or 1064 // and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or
963 // if we waited for DidStopLoading (currently broken -- see comment in 1065 // if we waited for DidStopLoading (currently broken -- see comment in
964 // NavigateIframeToURL). 1066 // NavigateIframeToURL).
965 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1067 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
966 DISABLED_NavigateRemoteToDataURL) { 1068 DISABLED_NavigateRemoteToDataURL) {
967 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 1069 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 params.frame_tree_node_id = child->frame_tree_node_id(); 1184 params.frame_tree_node_id = child->frame_tree_node_id();
1083 child->navigator()->GetController()->LoadURLWithParams(params); 1185 child->navigator()->GetController()->LoadURLWithParams(params);
1084 nav_observer.Wait(); 1186 nav_observer.Wait();
1085 1187
1086 // Verify that the navigation succeeded and the expected URL was loaded. 1188 // Verify that the navigation succeeded and the expected URL was loaded.
1087 EXPECT_TRUE(observer.navigation_succeeded()); 1189 EXPECT_TRUE(observer.navigation_succeeded());
1088 EXPECT_EQ(url, observer.navigation_url()); 1190 EXPECT_EQ(url, observer.navigation_url());
1089 } 1191 }
1090 1192
1091 } // namespace content 1193 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_browsertest.cc ('k') | content/common/frame_replication_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698