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

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

Issue 974723002: OOPIF: Replicate dynamic window.name updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1178
1179 // Check that the window.name seen by the frame matches the name attribute 1179 // Check that the window.name seen by the frame matches the name attribute
1180 // specified by its parent in the iframe tag. 1180 // specified by its parent in the iframe tag.
1181 std::string result; 1181 std::string result;
1182 EXPECT_TRUE(ExecuteScriptAndExtractString( 1182 EXPECT_TRUE(ExecuteScriptAndExtractString(
1183 root->child_at(0)->current_frame_host(), 1183 root->child_at(0)->current_frame_host(),
1184 "window.domAutomationController.send(window.name);", &result)); 1184 "window.domAutomationController.send(window.name);", &result));
1185 EXPECT_EQ(result, "3-1-name"); 1185 EXPECT_EQ(result, "3-1-name");
1186 } 1186 }
1187 1187
1188 // Verify that dynamic updates to a frame's window.name propagate to the
1189 // frame's proxies, so that the latest frame names can be used in frame
nasko 2015/03/05 18:09:28 nit: s/used in frame navigations/used in navigatio
alexmos 2015/03/09 18:47:58 Done.
1190 // navigations.
1191 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicWindowName) {
1192 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html"));
1193 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1194
1195 // It is safe to obtain the root frame tree node here, as it doesn't change.
1196 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
1197 ->GetFrameTree()
1198 ->root();
1199
nasko 2015/03/05 18:09:28 nit: no need for empty line
alexmos 2015/03/09 18:47:58 Done.
1200 TestNavigationObserver observer(shell()->web_contents());
1201
1202 // Load cross-site page into iframe.
1203 GURL frame_url =
1204 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html");
1205 NavigateFrameToURL(root->child_at(0), frame_url);
1206 EXPECT_TRUE(observer.last_navigation_succeeded());
1207 EXPECT_EQ(frame_url, observer.last_navigation_url());
1208
1209 // Browser process should know the child frame's original window.name
1210 // specified in the iframe element.
1211 EXPECT_EQ(root->child_at(0)->frame_name(), "3-1-name");
1212
1213 // Update the child frame's window.name.
1214 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(),
1215 "window.domAutomationController.send("
1216 "window.name = 'updated-name');"));
1217
1218 // The change should propagate to the browser process.
1219 EXPECT_EQ(root->child_at(0)->frame_name(), "updated-name");
nasko 2015/03/05 18:09:27 What guarantees that the name has been propagated
alexmos 2015/03/09 18:47:58 If I understand correctly, the ExecuteScript in 12
nasko 2015/03/09 21:43:40 Acknowledged.
1220
1221 // The proxy in the parent process should also receive the updated name.
1222 // Check that it can reference the child frame by its new name.
1223 bool success = false;
1224 EXPECT_TRUE(
1225 ExecuteScriptAndExtractBool(shell()->web_contents(),
1226 "window.domAutomationController.send("
1227 "frames['updated-name'] == frames[0]);",
1228 &success));
1229 EXPECT_TRUE(success);
1230
1231 // Issue a renderer-initiated navigation from the root frame to the child
1232 // frame using the frame's name. Make sure correct frame is navigated.
1233 //
1234 // TODO(alexmos): When blink::createWindow is refactored to handle
1235 // RemoteFrames, this should also be tested via window.open(url, frame_name)
1236 // and a more complicated frame hierarchy.
1237 TestFrameNavigationObserver frame_observer(root->child_at(0));
1238 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
1239 "window.domAutomationController.send("
1240 "frames['updated-name'].location.href = "
1241 "'/cross-site/foo.com/title1.html');"));
nasko 2015/03/05 18:09:28 Why not use the result of embedded_test_server()->
alexmos 2015/03/09 18:47:58 Done.
1242 frame_observer.Wait();
1243 EXPECT_EQ(embedded_test_server()->GetURL("foo.com", "/title1.html"),
1244 root->child_at(0)->current_url());
1245 }
1246
1188 // TODO(lfg): Merge the test below with NavigateRemoteFrame test. 1247 // TODO(lfg): Merge the test below with NavigateRemoteFrame test.
1189 // TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since 1248 // TODO(lfg): Disabled because this triggers http://crbug.com/433012, and since
1190 // the renderer process crashes, it causes the title watcher to never return. 1249 // the renderer process crashes, it causes the title watcher to never return.
1191 // Alternatively, this could also be fixed if we could use NavigateIframeToURL 1250 // Alternatively, this could also be fixed if we could use NavigateIframeToURL
1192 // and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or 1251 // and classified the navigation as MANUAL_SUBFRAME (http://crbug.com/441863) or
1193 // if we waited for DidStopLoading (currently broken -- see comment in 1252 // if we waited for DidStopLoading (currently broken -- see comment in
1194 // NavigateIframeToURL). 1253 // NavigateIframeToURL).
1195 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1254 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1196 DISABLED_NavigateRemoteToDataURL) { 1255 DISABLED_NavigateRemoteToDataURL) {
1197 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 1256 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 TitleWatcher title_watcher(shell()->web_contents(), expected_title); 1440 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
1382 TestNavigationObserver observer(shell()->web_contents()); 1441 TestNavigationObserver observer(shell()->web_contents());
1383 NavigateFrameToURL(root->child_at(0), foo_url); 1442 NavigateFrameToURL(root->child_at(0), foo_url);
1384 EXPECT_TRUE(observer.last_navigation_succeeded()); 1443 EXPECT_TRUE(observer.last_navigation_succeeded());
1385 EXPECT_EQ(foo_url, observer.last_navigation_url()); 1444 EXPECT_EQ(foo_url, observer.last_navigation_url());
1386 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); 1445 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title);
1387 } 1446 }
1388 } 1447 }
1389 1448
1390 } // namespace content 1449 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698