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

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

Issue 743773003: OOPIF: Data URLs are now rendered in the renderer that initiated the navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 "content/browser/frame_host/cross_process_frame_connector.h" 10 #include "content/browser/frame_host/cross_process_frame_connector.h"
10 #include "content/browser/frame_host/frame_tree.h" 11 #include "content/browser/frame_host/frame_tree.h"
11 #include "content/browser/frame_host/navigator.h" 12 #include "content/browser/frame_host/navigator.h"
12 #include "content/browser/frame_host/render_frame_proxy_host.h" 13 #include "content/browser/frame_host/render_frame_proxy_host.h"
13 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 14 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
14 #include "content/browser/renderer_host/render_view_host_impl.h" 15 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 16 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // for commit. 225 // for commit.
225 std::string script = base::StringPrintf( 226 std::string script = base::StringPrintf(
226 "setTimeout(\"" 227 "setTimeout(\""
227 "var iframes = document.getElementById('%s');iframes.src='%s';" 228 "var iframes = document.getElementById('%s');iframes.src='%s';"
228 "\",0)", 229 "\",0)",
229 iframe_id.c_str(), url.spec().c_str()); 230 iframe_id.c_str(), url.spec().c_str());
230 WindowedNotificationObserver load_observer( 231 WindowedNotificationObserver load_observer(
231 NOTIFICATION_NAV_ENTRY_COMMITTED, 232 NOTIFICATION_NAV_ENTRY_COMMITTED,
232 Source<NavigationController>( 233 Source<NavigationController>(
233 &window->web_contents()->GetController())); 234 &window->web_contents()->GetController()));
234 bool result = ExecuteScript(window->web_contents(), script); 235 if (!ExecuteScript(window->web_contents(), script))
236 return false;
235 load_observer.Wait(); 237 load_observer.Wait();
236 return result; 238
239 return true;
237 } 240 }
238 241
239 void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) { 242 void SitePerProcessBrowserTest::SetUpCommandLine(CommandLine* command_line) {
240 command_line->AppendSwitch(switches::kSitePerProcess); 243 command_line->AppendSwitch(switches::kSitePerProcess);
241 }; 244 };
242 245
243 void SitePerProcessBrowserTest::SetUpOnMainThread() { 246 void SitePerProcessBrowserTest::SetUpOnMainThread() {
244 host_resolver()->AddRule("*", "127.0.0.1"); 247 host_resolver()->AddRule("*", "127.0.0.1");
245 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 248 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
246 SetupCrossSiteRedirector(embedded_test_server()); 249 SetupCrossSiteRedirector(embedded_test_server());
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 "window.domAutomationController.send(location.ancestorOrigins[0]);", 864 "window.domAutomationController.send(location.ancestorOrigins[0]);",
862 &result)); 865 &result));
863 EXPECT_EQ(result + "/", foo_url.GetOrigin().spec()); 866 EXPECT_EQ(result + "/", foo_url.GetOrigin().spec());
864 EXPECT_TRUE(ExecuteScriptAndExtractString( 867 EXPECT_TRUE(ExecuteScriptAndExtractString(
865 bottom_child->current_frame_host(), 868 bottom_child->current_frame_host(),
866 "window.domAutomationController.send(location.ancestorOrigins[1]);", 869 "window.domAutomationController.send(location.ancestorOrigins[1]);",
867 &result)); 870 &result));
868 EXPECT_EQ(result + "/", main_url.GetOrigin().spec()); 871 EXPECT_EQ(result + "/", main_url.GetOrigin().spec());
869 } 872 }
870 873
874 // TODO(lfg): Merge the test below with NavigateRemoteFrame test.
875 // TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since
876 // the renderer process crashes, it causes the title watcher to never return.
877 // Alternatively, this could also be fixed if we could use NavigateIframeToURL
878 // and classified the navigation as MANUAL_SUBFRAME or if we waited for
Charlie Reis 2014/12/12 20:19:22 Let's reference http://crbug.com/441863 for the cl
lfg 2014/12/12 21:54:08 Done.
879 // DidStopLoading (currently broken -- see comment in NavigateIframeToURL).
880 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
881 DISABLED_NavigateRemoteToDataURL) {
882 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
883 NavigateToURL(shell(), main_url);
884
885 // It is safe to obtain the root frame tree node here, as it doesn't change.
886 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
887 ->GetFrameTree()
888 ->root();
889
890 SitePerProcessWebContentsObserver observer(shell()->web_contents());
891
892 // Load cross-site page into iframe.
893 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
894 NavigateFrameToURL(root->child_at(0), url);
895 EXPECT_TRUE(observer.navigation_succeeded());
896 EXPECT_EQ(url, observer.navigation_url());
897
898 // Ensure that we have created a new process for the subframe.
899 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
900 root->child_at(0)->current_frame_host()->GetSiteInstance());
901
902 // Navigate iframe to a data URL. The navigation happens from a script in the
903 // parent frame, so the data URL should be committed in the same SiteInstance
904 // as the parent frame.
905 GURL data_url("data:text/html,dataurl");
906 std::string script = base::StringPrintf(
907 "setTimeout(function() {"
908 "var iframe = document.getElementById('test');"
909 "iframe.onload = function() { document.title = 'LOADED'; };"
910 "iframe.src=\"%s\";"
911 "},0);",
912 data_url.spec().c_str());
913 base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
914 TitleWatcher title_watcher(shell()->web_contents(), passed_string);
915 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
916 (void)title_watcher.WaitAndGetTitle();
917 EXPECT_TRUE(observer.navigation_succeeded());
918 EXPECT_EQ(data_url, observer.navigation_url());
919
920 // Ensure that we have navigated using the top level process.
921 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
922 root->child_at(0)->current_frame_host()->GetSiteInstance());
923 }
924
925 // TODO(lfg): Merge the test below with NavigateRemoteFrame test.
926 // Disabled due to the same reason as NavigateRemoteToDataURL.
927 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
928 DISABLED_NavigateRemoteToBlankURL) {
929 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
930 NavigateToURL(shell(), main_url);
931
932 // It is safe to obtain the root frame tree node here, as it doesn't change.
933 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
934 ->GetFrameTree()
935 ->root();
936
937 SitePerProcessWebContentsObserver observer(shell()->web_contents());
938
939 // Load cross-site page into iframe.
940 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
941 NavigateFrameToURL(root->child_at(0), url);
942 EXPECT_TRUE(observer.navigation_succeeded());
943 EXPECT_EQ(url, observer.navigation_url());
944
945 // Ensure that we have created a new process for the subframe.
946 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
947 root->child_at(0)->current_frame_host()->GetSiteInstance());
948
949 // Navigate iframe to about:blank. The navigation happens from a script in the
950 // parent frame, so it should be committed in the same SiteInstance as the
951 // parent frame.
952 GURL about_blank_url("about:blank");
953 std::string script = base::StringPrintf(
954 "setTimeout(function() {"
955 "var iframe = document.getElementById('test');"
956 "iframe.onload = function() { document.title = 'LOADED'; };"
957 "iframe.src=\"%s\";"
958 "},0);",
959 about_blank_url.spec().c_str());
960 base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
961 TitleWatcher title_watcher(shell()->web_contents(), passed_string);
962 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
963 (void)title_watcher.WaitAndGetTitle();
964 EXPECT_TRUE(observer.navigation_succeeded());
965 EXPECT_EQ(about_blank_url, observer.navigation_url());
966
967 // Ensure that we have navigated using the top level process.
968 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
969 root->child_at(0)->current_frame_host()->GetSiteInstance());
970 }
971
871 } // namespace content 972 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/security_exploit_browsertest.cc ('k') | content/public/browser/navigation_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698