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

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

Issue 881413005: Fix flakyness in NavigateRemoteFrame browsertest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); 276 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent());
277 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); 277 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
278 EXPECT_NE( 278 EXPECT_NE(
279 child->current_frame_host()->render_view_host()->GetView(), 279 child->current_frame_host()->render_view_host()->GetView(),
280 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); 280 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
281 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); 281 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost());
282 } 282 }
283 283
284 // Disabled for flaky crashing: crbug.com/446575 284 // Disabled for flaky crashing: crbug.com/446575
285 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 285 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
286 DISABLED_NavigateRemoteFrame) { 286 NavigateRemoteFrame) {
287 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 287 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
288 NavigateToURL(shell(), main_url); 288 NavigateToURL(shell(), main_url);
289 289
290 // It is safe to obtain the root frame tree node here, as it doesn't change. 290 // It is safe to obtain the root frame tree node here, as it doesn't change.
291 FrameTreeNode* root = 291 FrameTreeNode* root =
292 static_cast<WebContentsImpl*>(shell()->web_contents())-> 292 static_cast<WebContentsImpl*>(shell()->web_contents())->
293 GetFrameTree()->root(); 293 GetFrameTree()->root();
294 294
295 TestNavigationObserver observer(shell()->web_contents()); 295 TestNavigationObserver observer(shell()->web_contents());
296 296
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 EXPECT_NE(site_instance, 328 EXPECT_NE(site_instance,
329 child->current_frame_host()->GetSiteInstance()); 329 child->current_frame_host()->GetSiteInstance());
330 330
331 // Navigate back to the parent's origin and ensure we return to the 331 // Navigate back to the parent's origin and ensure we return to the
332 // parent's process. 332 // parent's process.
333 NavigateFrameToURL(child, http_url); 333 NavigateFrameToURL(child, http_url);
334 EXPECT_EQ(http_url, observer.last_navigation_url()); 334 EXPECT_EQ(http_url, observer.last_navigation_url());
335 EXPECT_TRUE(observer.last_navigation_succeeded()); 335 EXPECT_TRUE(observer.last_navigation_succeeded());
336 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), 336 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
337 child->current_frame_host()->GetSiteInstance()); 337 child->current_frame_host()->GetSiteInstance());
338
339 // Load cross-site page into iframe.
nasko 2015/02/11 14:44:06 Why do we need this here? These tests belongs logi
lfg 2015/02/11 18:23:52 The reason I did it is because they basically test
340 url = embedded_test_server()->GetURL("baz.com", "/title2.html");
341 NavigateFrameToURL(root->child_at(0), url);
342 EXPECT_TRUE(observer.last_navigation_succeeded());
343 EXPECT_EQ(url, observer.last_navigation_url());
344 ASSERT_EQ(2U, root->child_count());
345 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
346 root->child_at(0)->current_frame_host()->GetSiteInstance());
347
348 // Navigate iframe to a data URL. The navigation happens from a script in the
349 // parent frame, so the data URL should be committed in the same SiteInstance
350 // as the parent frame.
351 GURL data_url("data:text/html,dataurl");
352 NavigateIframeToURL(shell()->web_contents(), "test", data_url);
353 EXPECT_TRUE(observer.last_navigation_succeeded());
354 EXPECT_EQ(data_url, observer.last_navigation_url());
355
356 // Ensure that we have navigated using the top level process.
357 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
358 root->child_at(0)->current_frame_host()->GetSiteInstance());
359
360 // Load cross-site page into iframe.
361 url = embedded_test_server()->GetURL("qux.com", "/title2.html");
362 NavigateFrameToURL(root->child_at(0), url);
363 EXPECT_TRUE(observer.last_navigation_succeeded());
364 EXPECT_EQ(url, observer.last_navigation_url());
365 ASSERT_EQ(2U, root->child_count());
366 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
367 root->child_at(0)->current_frame_host()->GetSiteInstance());
368
369 // Navigate iframe to about:blank. The navigation happens from a script in the
370 // parent frame, so it should be committed in the same SiteInstance as the
371 // parent frame.
372 GURL about_blank_url("about:blank");
373 NavigateIframeToURL(shell()->web_contents(), "test", about_blank_url);
374 EXPECT_TRUE(observer.last_navigation_succeeded());
375 EXPECT_EQ(about_blank_url, observer.last_navigation_url());
376
377 // Ensure that we have navigated using the top level process.
378 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
379 root->child_at(0)->current_frame_host()->GetSiteInstance());
338 } 380 }
339 381
340 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies 382 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies
341 // of C from the tree. 383 // of C from the tree.
342 // 384 //
343 // 1 A A 385 // 1 A A
344 // / \ / \ / \ . 386 // / \ / \ / \ .
345 // 2 3 -> B A -> Kill B -> B* A 387 // 2 3 -> B A -> Kill B -> B* A
346 // / / 388 // / /
347 // 4 C 389 // 4 C
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1082
1041 // Check that the window.name seen by the frame matches the name attribute 1083 // Check that the window.name seen by the frame matches the name attribute
1042 // specified by its parent in the iframe tag. 1084 // specified by its parent in the iframe tag.
1043 std::string result; 1085 std::string result;
1044 EXPECT_TRUE(ExecuteScriptAndExtractString( 1086 EXPECT_TRUE(ExecuteScriptAndExtractString(
1045 root->child_at(0)->current_frame_host(), 1087 root->child_at(0)->current_frame_host(),
1046 "window.domAutomationController.send(window.name);", &result)); 1088 "window.domAutomationController.send(window.name);", &result));
1047 EXPECT_EQ(result, "3-1-name"); 1089 EXPECT_EQ(result, "3-1-name");
1048 } 1090 }
1049 1091
1050 // TODO(lfg): Merge the test below with NavigateRemoteFrame test.
1051 // TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since
1052 // the renderer process crashes, it causes the title watcher to never return.
1053 // Alternatively, this could also be fixed if we could use NavigateIframeToURL
1054 // and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or
1055 // if we waited for DidStopLoading (currently broken -- see comment in
1056 // NavigateIframeToURL).
1057 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1058 DISABLED_NavigateRemoteToDataURL) {
1059 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
1060 NavigateToURL(shell(), main_url);
1061
1062 // It is safe to obtain the root frame tree node here, as it doesn't change.
1063 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1064 ->GetFrameTree()
1065 ->root();
1066
1067 TestNavigationObserver observer(shell()->web_contents());
1068
1069 // Load cross-site page into iframe.
1070 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
1071 NavigateFrameToURL(root->child_at(0), url);
1072 EXPECT_TRUE(observer.last_navigation_succeeded());
1073 EXPECT_EQ(url, observer.last_navigation_url());
1074
1075 // Ensure that we have created a new process for the subframe.
1076 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
1077 root->child_at(0)->current_frame_host()->GetSiteInstance());
1078
1079 // Navigate iframe to a data URL. The navigation happens from a script in the
1080 // parent frame, so the data URL should be committed in the same SiteInstance
1081 // as the parent frame.
1082 GURL data_url("data:text/html,dataurl");
1083 std::string script = base::StringPrintf(
1084 "setTimeout(function() {"
1085 "var iframe = document.getElementById('test');"
1086 "iframe.onload = function() { document.title = 'LOADED'; };"
1087 "iframe.src=\"%s\";"
1088 "},0);",
1089 data_url.spec().c_str());
1090 base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
1091 TitleWatcher title_watcher(shell()->web_contents(), passed_string);
1092 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
1093 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string);
1094 EXPECT_TRUE(observer.last_navigation_succeeded());
1095 EXPECT_EQ(data_url, observer.last_navigation_url());
1096
1097 // Ensure that we have navigated using the top level process.
1098 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
1099 root->child_at(0)->current_frame_host()->GetSiteInstance());
1100 }
1101
1102 // TODO(lfg): Merge the test below with NavigateRemoteFrame test.
1103 // Disabled due to the same reason as NavigateRemoteToDataURL.
1104 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1105 DISABLED_NavigateRemoteToBlankURL) {
1106 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
1107 NavigateToURL(shell(), main_url);
1108
1109 // It is safe to obtain the root frame tree node here, as it doesn't change.
1110 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1111 ->GetFrameTree()
1112 ->root();
1113
1114 TestNavigationObserver observer(shell()->web_contents());
1115
1116 // Load cross-site page into iframe.
1117 GURL url = embedded_test_server()->GetURL("foo.com", "/title1.html");
1118 NavigateFrameToURL(root->child_at(0), url);
1119 EXPECT_TRUE(observer.last_navigation_succeeded());
1120 EXPECT_EQ(url, observer.last_navigation_url());
1121
1122 // Ensure that we have created a new process for the subframe.
1123 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
1124 root->child_at(0)->current_frame_host()->GetSiteInstance());
1125
1126 // Navigate iframe to about:blank. The navigation happens from a script in the
1127 // parent frame, so it should be committed in the same SiteInstance as the
1128 // parent frame.
1129 GURL about_blank_url("about:blank");
1130 std::string script = base::StringPrintf(
1131 "setTimeout(function() {"
1132 "var iframe = document.getElementById('test');"
1133 "iframe.onload = function() { document.title = 'LOADED'; };"
1134 "iframe.src=\"%s\";"
1135 "},0);",
1136 about_blank_url.spec().c_str());
1137 base::string16 passed_string(base::UTF8ToUTF16("LOADED"));
1138 TitleWatcher title_watcher(shell()->web_contents(), passed_string);
1139 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
1140 EXPECT_EQ(title_watcher.WaitAndGetTitle(), passed_string);
1141 EXPECT_TRUE(observer.last_navigation_succeeded());
1142 EXPECT_EQ(about_blank_url, observer.last_navigation_url());
1143
1144 // Ensure that we have navigated using the top level process.
1145 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(),
1146 root->child_at(0)->current_frame_host()->GetSiteInstance());
1147 }
1148
1149 // Ensure that navigating subframes in --site-per-process mode properly fires 1092 // Ensure that navigating subframes in --site-per-process mode properly fires
1150 // the DidStopLoading event on WebContentsObserver. 1093 // the DidStopLoading event on WebContentsObserver.
1151 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { 1094 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) {
1152 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 1095 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
1153 NavigateToURL(shell(), main_url); 1096 NavigateToURL(shell(), main_url);
1154 1097
1155 // It is safe to obtain the root frame tree node here, as it doesn't change. 1098 // It is safe to obtain the root frame tree node here, as it doesn't change.
1156 FrameTreeNode* root = 1099 FrameTreeNode* root =
1157 static_cast<WebContentsImpl*>(shell()->web_contents())-> 1100 static_cast<WebContentsImpl*>(shell()->web_contents())->
1158 GetFrameTree()->root(); 1101 GetFrameTree()->root();
(...skipping 15 matching lines...) Expand all
1174 params.frame_tree_node_id = child->frame_tree_node_id(); 1117 params.frame_tree_node_id = child->frame_tree_node_id();
1175 child->navigator()->GetController()->LoadURLWithParams(params); 1118 child->navigator()->GetController()->LoadURLWithParams(params);
1176 nav_observer.Wait(); 1119 nav_observer.Wait();
1177 1120
1178 // Verify that the navigation succeeded and the expected URL was loaded. 1121 // Verify that the navigation succeeded and the expected URL was loaded.
1179 EXPECT_TRUE(observer.last_navigation_succeeded()); 1122 EXPECT_TRUE(observer.last_navigation_succeeded());
1180 EXPECT_EQ(url, observer.last_navigation_url()); 1123 EXPECT_EQ(url, observer.last_navigation_url());
1181 } 1124 }
1182 1125
1183 } // namespace content 1126 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_proxy.cc » ('j') | content/renderer/render_frame_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698