OLD | NEW |
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 "content/browser/frame_host/cross_process_frame_connector.h" | 9 #include "content/browser/frame_host/cross_process_frame_connector.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
11 #include "content/browser/frame_host/navigator.h" | 11 #include "content/browser/frame_host/navigator.h" |
12 #include "content/browser/frame_host/render_frame_proxy_host.h" | 12 #include "content/browser/frame_host/render_frame_proxy_host.h" |
13 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 13 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
14 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 15 #include "content/browser/web_contents/web_contents_impl.h" |
16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
19 #include "content/public/browser/web_contents_observer.h" | |
20 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
21 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/content_browser_test_utils.h" | 21 #include "content/public/test/content_browser_test_utils.h" |
| 22 #include "content/public/test/test_navigation_observer.h" |
23 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
24 #include "content/shell/browser/shell.h" | 24 #include "content/shell/browser/shell.h" |
25 #include "content/test/content_browser_test_utils_internal.h" | 25 #include "content/test/content_browser_test_utils_internal.h" |
26 #include "content/test/test_frame_navigation_observer.h" | 26 #include "content/test/test_frame_navigation_observer.h" |
27 #include "net/dns/mock_host_resolver.h" | 27 #include "net/dns/mock_host_resolver.h" |
28 #include "net/test/embedded_test_server/embedded_test_server.h" | 28 #include "net/test/embedded_test_server/embedded_test_server.h" |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 class SitePerProcessWebContentsObserver: public WebContentsObserver { | |
33 public: | |
34 explicit SitePerProcessWebContentsObserver(WebContents* web_contents) | |
35 : WebContentsObserver(web_contents), | |
36 navigation_succeeded_(false) {} | |
37 ~SitePerProcessWebContentsObserver() override {} | |
38 | |
39 void DidStartProvisionalLoadForFrame(RenderFrameHost* render_frame_host, | |
40 const GURL& validated_url, | |
41 bool is_error_page, | |
42 bool is_iframe_srcdoc) override { | |
43 navigation_succeeded_ = false; | |
44 } | |
45 | |
46 void DidFailProvisionalLoad( | |
47 RenderFrameHost* render_frame_host, | |
48 const GURL& validated_url, | |
49 int error_code, | |
50 const base::string16& error_description) override { | |
51 navigation_url_ = validated_url; | |
52 navigation_succeeded_ = false; | |
53 } | |
54 | |
55 void DidCommitProvisionalLoadForFrame( | |
56 RenderFrameHost* render_frame_host, | |
57 const GURL& url, | |
58 ui::PageTransition transition_type) override { | |
59 navigation_url_ = url; | |
60 navigation_succeeded_ = true; | |
61 } | |
62 | |
63 const GURL& navigation_url() const { | |
64 return navigation_url_; | |
65 } | |
66 | |
67 int navigation_succeeded() const { return navigation_succeeded_; } | |
68 | |
69 private: | |
70 GURL navigation_url_; | |
71 bool navigation_succeeded_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(SitePerProcessWebContentsObserver); | |
74 }; | |
75 | |
76 class RedirectNotificationObserver : public NotificationObserver { | 32 class RedirectNotificationObserver : public NotificationObserver { |
77 public: | 33 public: |
78 // Register to listen for notifications of the given type from either a | 34 // Register to listen for notifications of the given type from either a |
79 // specific source, or from all sources if |source| is | 35 // specific source, or from all sources if |source| is |
80 // NotificationService::AllSources(). | 36 // NotificationService::AllSources(). |
81 RedirectNotificationObserver(int notification_type, | 37 RedirectNotificationObserver(int notification_type, |
82 const NotificationSource& source); | 38 const NotificationSource& source); |
83 ~RedirectNotificationObserver() override; | 39 ~RedirectNotificationObserver() override; |
84 | 40 |
85 // Wait until the specified notification occurs. If the notification was | 41 // Wait until the specified notification occurs. If the notification was |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // correct documents are committed. | 157 // correct documents are committed. |
202 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 158 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
203 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 159 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
204 NavigateToURL(shell(), main_url); | 160 NavigateToURL(shell(), main_url); |
205 | 161 |
206 // It is safe to obtain the root frame tree node here, as it doesn't change. | 162 // It is safe to obtain the root frame tree node here, as it doesn't change. |
207 FrameTreeNode* root = | 163 FrameTreeNode* root = |
208 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 164 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
209 GetFrameTree()->root(); | 165 GetFrameTree()->root(); |
210 | 166 |
211 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 167 TestNavigationObserver observer(shell()->web_contents()); |
212 | 168 |
213 // Load same-site page into iframe. | 169 // Load same-site page into iframe. |
214 FrameTreeNode* child = root->child_at(0); | 170 FrameTreeNode* child = root->child_at(0); |
215 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 171 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
216 NavigateFrameToURL(child, http_url); | 172 NavigateFrameToURL(child, http_url); |
217 EXPECT_EQ(http_url, observer.navigation_url()); | 173 EXPECT_EQ(http_url, observer.last_navigation_url()); |
218 EXPECT_TRUE(observer.navigation_succeeded()); | 174 EXPECT_TRUE(observer.last_navigation_succeeded()); |
219 { | 175 { |
220 // There should be only one RenderWidgetHost when there are no | 176 // There should be only one RenderWidgetHost when there are no |
221 // cross-process iframes. | 177 // cross-process iframes. |
222 std::set<RenderWidgetHostView*> views_set = | 178 std::set<RenderWidgetHostView*> views_set = |
223 static_cast<WebContentsImpl*>(shell()->web_contents()) | 179 static_cast<WebContentsImpl*>(shell()->web_contents()) |
224 ->GetRenderWidgetHostViewsInTree(); | 180 ->GetRenderWidgetHostViewsInTree(); |
225 EXPECT_EQ(1U, views_set.size()); | 181 EXPECT_EQ(1U, views_set.size()); |
226 } | 182 } |
227 RenderFrameProxyHost* proxy_to_parent = | 183 RenderFrameProxyHost* proxy_to_parent = |
228 child->render_manager()->GetRenderFrameProxyHost( | 184 child->render_manager()->GetRenderFrameProxyHost( |
229 shell()->web_contents()->GetSiteInstance()); | 185 shell()->web_contents()->GetSiteInstance()); |
230 EXPECT_FALSE(proxy_to_parent); | 186 EXPECT_FALSE(proxy_to_parent); |
231 | 187 |
232 // Load cross-site page into iframe. | 188 // Load cross-site page into iframe. |
233 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 189 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
234 NavigateFrameToURL(root->child_at(0), url); | 190 NavigateFrameToURL(root->child_at(0), url); |
235 // Verify that the navigation succeeded and the expected URL was loaded. | 191 // Verify that the navigation succeeded and the expected URL was loaded. |
236 EXPECT_TRUE(observer.navigation_succeeded()); | 192 EXPECT_TRUE(observer.last_navigation_succeeded()); |
237 EXPECT_EQ(url, observer.navigation_url()); | 193 EXPECT_EQ(url, observer.last_navigation_url()); |
238 | 194 |
239 // Ensure that we have created a new process for the subframe. | 195 // Ensure that we have created a new process for the subframe. |
240 ASSERT_EQ(2U, root->child_count()); | 196 ASSERT_EQ(2U, root->child_count()); |
241 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 197 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
242 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 198 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
243 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 199 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
244 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 200 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
245 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 201 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
246 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 202 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
247 { | 203 { |
248 // There should be now two RenderWidgetHosts, one for each process | 204 // There should be now two RenderWidgetHosts, one for each process |
249 // rendering a frame. | 205 // rendering a frame. |
250 std::set<RenderWidgetHostView*> views_set = | 206 std::set<RenderWidgetHostView*> views_set = |
251 static_cast<WebContentsImpl*>(shell()->web_contents()) | 207 static_cast<WebContentsImpl*>(shell()->web_contents()) |
252 ->GetRenderWidgetHostViewsInTree(); | 208 ->GetRenderWidgetHostViewsInTree(); |
253 EXPECT_EQ(2U, views_set.size()); | 209 EXPECT_EQ(2U, views_set.size()); |
254 } | 210 } |
255 proxy_to_parent = child->render_manager()->GetProxyToParent(); | 211 proxy_to_parent = child->render_manager()->GetProxyToParent(); |
256 EXPECT_TRUE(proxy_to_parent); | 212 EXPECT_TRUE(proxy_to_parent); |
257 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); | 213 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); |
258 EXPECT_EQ( | 214 EXPECT_EQ( |
259 rvh->GetView(), | 215 rvh->GetView(), |
260 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | 216 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
261 | 217 |
262 // Load another cross-site page into the same iframe. | 218 // Load another cross-site page into the same iframe. |
263 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 219 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
264 NavigateFrameToURL(root->child_at(0), url); | 220 NavigateFrameToURL(root->child_at(0), url); |
265 EXPECT_TRUE(observer.navigation_succeeded()); | 221 EXPECT_TRUE(observer.last_navigation_succeeded()); |
266 EXPECT_EQ(url, observer.navigation_url()); | 222 EXPECT_EQ(url, observer.last_navigation_url()); |
267 | 223 |
268 // Check again that a new process is created and is different from the | 224 // Check again that a new process is created and is different from the |
269 // top level one and the previous one. | 225 // top level one and the previous one. |
270 ASSERT_EQ(2U, root->child_count()); | 226 ASSERT_EQ(2U, root->child_count()); |
271 child = root->child_at(0); | 227 child = root->child_at(0); |
272 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 228 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
273 child->current_frame_host()->render_view_host()); | 229 child->current_frame_host()->render_view_host()); |
274 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 230 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
275 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 231 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
276 child->current_frame_host()->GetSiteInstance()); | 232 child->current_frame_host()->GetSiteInstance()); |
(...skipping 17 matching lines...) Expand all Loading... |
294 | 250 |
295 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { | 251 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { |
296 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 252 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
297 NavigateToURL(shell(), main_url); | 253 NavigateToURL(shell(), main_url); |
298 | 254 |
299 // It is safe to obtain the root frame tree node here, as it doesn't change. | 255 // It is safe to obtain the root frame tree node here, as it doesn't change. |
300 FrameTreeNode* root = | 256 FrameTreeNode* root = |
301 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 257 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
302 GetFrameTree()->root(); | 258 GetFrameTree()->root(); |
303 | 259 |
304 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 260 TestNavigationObserver observer(shell()->web_contents()); |
305 | 261 |
306 // Load same-site page into iframe. | 262 // Load same-site page into iframe. |
307 FrameTreeNode* child = root->child_at(0); | 263 FrameTreeNode* child = root->child_at(0); |
308 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 264 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
309 NavigateFrameToURL(child, http_url); | 265 NavigateFrameToURL(child, http_url); |
310 EXPECT_EQ(http_url, observer.navigation_url()); | 266 EXPECT_EQ(http_url, observer.last_navigation_url()); |
311 EXPECT_TRUE(observer.navigation_succeeded()); | 267 EXPECT_TRUE(observer.last_navigation_succeeded()); |
312 | 268 |
313 // Load cross-site page into iframe. | 269 // Load cross-site page into iframe. |
314 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 270 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
315 NavigateFrameToURL(root->child_at(0), url); | 271 NavigateFrameToURL(root->child_at(0), url); |
316 EXPECT_TRUE(observer.navigation_succeeded()); | 272 EXPECT_TRUE(observer.last_navigation_succeeded()); |
317 EXPECT_EQ(url, observer.navigation_url()); | 273 EXPECT_EQ(url, observer.last_navigation_url()); |
318 | 274 |
319 // Ensure that we have created a new process for the subframe. | 275 // Ensure that we have created a new process for the subframe. |
320 ASSERT_EQ(2U, root->child_count()); | 276 ASSERT_EQ(2U, root->child_count()); |
321 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 277 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
322 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 278 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
323 | 279 |
324 // Emulate the main frame changing the src of the iframe such that it | 280 // Emulate the main frame changing the src of the iframe such that it |
325 // navigates cross-site. | 281 // navigates cross-site. |
326 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 282 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
327 NavigateIframeToURL(shell(), url, "test"); | 283 NavigateIframeToURL(shell(), url, "test"); |
328 EXPECT_TRUE(observer.navigation_succeeded()); | 284 EXPECT_TRUE(observer.last_navigation_succeeded()); |
329 EXPECT_EQ(url, observer.navigation_url()); | 285 EXPECT_EQ(url, observer.last_navigation_url()); |
330 | 286 |
331 // Check again that a new process is created and is different from the | 287 // Check again that a new process is created and is different from the |
332 // top level one and the previous one. | 288 // top level one and the previous one. |
333 ASSERT_EQ(2U, root->child_count()); | 289 ASSERT_EQ(2U, root->child_count()); |
334 child = root->child_at(0); | 290 child = root->child_at(0); |
335 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 291 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
336 child->current_frame_host()->GetSiteInstance()); | 292 child->current_frame_host()->GetSiteInstance()); |
337 EXPECT_NE(site_instance, | 293 EXPECT_NE(site_instance, |
338 child->current_frame_host()->GetSiteInstance()); | 294 child->current_frame_host()->GetSiteInstance()); |
339 | 295 |
340 // Navigate back to the parent's origin and ensure we return to the | 296 // Navigate back to the parent's origin and ensure we return to the |
341 // parent's process. | 297 // parent's process. |
342 NavigateFrameToURL(child, http_url); | 298 NavigateFrameToURL(child, http_url); |
343 EXPECT_EQ(http_url, observer.navigation_url()); | 299 EXPECT_EQ(http_url, observer.last_navigation_url()); |
344 EXPECT_TRUE(observer.navigation_succeeded()); | 300 EXPECT_TRUE(observer.last_navigation_succeeded()); |
345 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 301 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
346 child->current_frame_host()->GetSiteInstance()); | 302 child->current_frame_host()->GetSiteInstance()); |
347 } | 303 } |
348 | 304 |
349 // Crash a subframe and ensures its children are cleared from the FrameTree. | 305 // Crash a subframe and ensures its children are cleared from the FrameTree. |
350 // See http://crbug.com/338508. | 306 // See http://crbug.com/338508. |
351 // TODO(creis): Disabled for flakiness; see http://crbug.com/405582. | 307 // TODO(creis): Disabled for flakiness; see http://crbug.com/405582. |
352 // TODO(creis): Enable this on Android when we can kill the process there. | 308 // TODO(creis): Enable this on Android when we can kill the process there. |
353 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) { | 309 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_CrashSubframe) { |
354 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 310 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 net::SpawnedTestServer::kLocalhost, | 381 net::SpawnedTestServer::kLocalhost, |
426 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 382 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
427 ASSERT_TRUE(https_server.Start()); | 383 ASSERT_TRUE(https_server.Start()); |
428 | 384 |
429 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 385 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
430 GURL http_url(test_server()->GetURL("files/title1.html")); | 386 GURL http_url(test_server()->GetURL("files/title1.html")); |
431 GURL https_url(https_server.GetURL("files/title1.html")); | 387 GURL https_url(https_server.GetURL("files/title1.html")); |
432 | 388 |
433 NavigateToURL(shell(), main_url); | 389 NavigateToURL(shell(), main_url); |
434 | 390 |
435 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 391 TestNavigationObserver observer(shell()->web_contents()); |
436 { | 392 { |
437 // Load cross-site client-redirect page into Iframe. | 393 // Load cross-site client-redirect page into Iframe. |
438 // Should be blocked. | 394 // Should be blocked. |
439 GURL client_redirect_https_url(https_server.GetURL( | 395 GURL client_redirect_https_url(https_server.GetURL( |
440 "client-redirect?files/title1.html")); | 396 "client-redirect?files/title1.html")); |
441 EXPECT_TRUE(NavigateIframeToURL(shell(), | 397 EXPECT_TRUE(NavigateIframeToURL(shell(), |
442 client_redirect_https_url, "test")); | 398 client_redirect_https_url, "test")); |
443 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 399 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
444 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 400 EXPECT_EQ(observer.last_navigation_url(), client_redirect_https_url); |
445 EXPECT_FALSE(observer.navigation_succeeded()); | 401 EXPECT_FALSE(observer.last_navigation_succeeded()); |
446 } | 402 } |
447 | 403 |
448 { | 404 { |
449 // Load cross-site server-redirect page into Iframe, | 405 // Load cross-site server-redirect page into Iframe, |
450 // which redirects to same-site page. | 406 // which redirects to same-site page. |
451 GURL server_redirect_http_url(https_server.GetURL( | 407 GURL server_redirect_http_url(https_server.GetURL( |
452 "server-redirect?" + http_url.spec())); | 408 "server-redirect?" + http_url.spec())); |
453 EXPECT_TRUE(NavigateIframeToURL(shell(), | 409 EXPECT_TRUE(NavigateIframeToURL(shell(), |
454 server_redirect_http_url, "test")); | 410 server_redirect_http_url, "test")); |
455 EXPECT_EQ(observer.navigation_url(), http_url); | 411 EXPECT_EQ(observer.last_navigation_url(), http_url); |
456 EXPECT_TRUE(observer.navigation_succeeded()); | 412 EXPECT_TRUE(observer.last_navigation_succeeded()); |
457 } | 413 } |
458 | 414 |
459 { | 415 { |
460 // Load cross-site server-redirect page into Iframe, | 416 // Load cross-site server-redirect page into Iframe, |
461 // which redirects to cross-site page. | 417 // which redirects to cross-site page. |
462 GURL server_redirect_http_url(https_server.GetURL( | 418 GURL server_redirect_http_url(https_server.GetURL( |
463 "server-redirect?files/title1.html")); | 419 "server-redirect?files/title1.html")); |
464 EXPECT_TRUE(NavigateIframeToURL(shell(), | 420 EXPECT_TRUE(NavigateIframeToURL(shell(), |
465 server_redirect_http_url, "test")); | 421 server_redirect_http_url, "test")); |
466 // DidFailProvisionalLoad when navigating to https_url. | 422 // DidFailProvisionalLoad when navigating to https_url. |
467 EXPECT_EQ(observer.navigation_url(), https_url); | 423 EXPECT_EQ(observer.last_navigation_url(), https_url); |
468 EXPECT_FALSE(observer.navigation_succeeded()); | 424 EXPECT_FALSE(observer.last_navigation_succeeded()); |
469 } | 425 } |
470 | 426 |
471 { | 427 { |
472 // Load same-site server-redirect page into Iframe, | 428 // Load same-site server-redirect page into Iframe, |
473 // which redirects to cross-site page. | 429 // which redirects to cross-site page. |
474 GURL server_redirect_http_url(test_server()->GetURL( | 430 GURL server_redirect_http_url(test_server()->GetURL( |
475 "server-redirect?" + https_url.spec())); | 431 "server-redirect?" + https_url.spec())); |
476 EXPECT_TRUE(NavigateIframeToURL(shell(), | 432 EXPECT_TRUE(NavigateIframeToURL(shell(), |
477 server_redirect_http_url, "test")); | 433 server_redirect_http_url, "test")); |
478 | 434 |
479 EXPECT_EQ(observer.navigation_url(), https_url); | 435 EXPECT_EQ(observer.last_navigation_url(), https_url); |
480 EXPECT_FALSE(observer.navigation_succeeded()); | 436 EXPECT_FALSE(observer.last_navigation_succeeded()); |
481 } | 437 } |
482 | 438 |
483 { | 439 { |
484 // Load same-site client-redirect page into Iframe, | 440 // Load same-site client-redirect page into Iframe, |
485 // which redirects to cross-site page. | 441 // which redirects to cross-site page. |
486 GURL client_redirect_http_url(test_server()->GetURL( | 442 GURL client_redirect_http_url(test_server()->GetURL( |
487 "client-redirect?" + https_url.spec())); | 443 "client-redirect?" + https_url.spec())); |
488 | 444 |
489 RedirectNotificationObserver load_observer2( | 445 RedirectNotificationObserver load_observer2( |
490 NOTIFICATION_LOAD_STOP, | 446 NOTIFICATION_LOAD_STOP, |
491 Source<NavigationController>( | 447 Source<NavigationController>( |
492 &shell()->web_contents()->GetController())); | 448 &shell()->web_contents()->GetController())); |
493 | 449 |
494 EXPECT_TRUE(NavigateIframeToURL(shell(), | 450 EXPECT_TRUE(NavigateIframeToURL(shell(), |
495 client_redirect_http_url, "test")); | 451 client_redirect_http_url, "test")); |
496 | 452 |
497 // Same-site Client-Redirect Page should be loaded successfully. | 453 // Same-site Client-Redirect Page should be loaded successfully. |
498 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 454 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); |
499 EXPECT_TRUE(observer.navigation_succeeded()); | 455 EXPECT_TRUE(observer.last_navigation_succeeded()); |
500 | 456 |
501 // Redirecting to Cross-site Page should be blocked. | 457 // Redirecting to Cross-site Page should be blocked. |
502 load_observer2.Wait(); | 458 load_observer2.Wait(); |
503 EXPECT_EQ(observer.navigation_url(), https_url); | 459 EXPECT_EQ(observer.last_navigation_url(), https_url); |
504 EXPECT_FALSE(observer.navigation_succeeded()); | 460 EXPECT_FALSE(observer.last_navigation_succeeded()); |
505 } | 461 } |
506 | 462 |
507 { | 463 { |
508 // Load same-site server-redirect page into Iframe, | 464 // Load same-site server-redirect page into Iframe, |
509 // which redirects to same-site page. | 465 // which redirects to same-site page. |
510 GURL server_redirect_http_url(test_server()->GetURL( | 466 GURL server_redirect_http_url(test_server()->GetURL( |
511 "server-redirect?files/title1.html")); | 467 "server-redirect?files/title1.html")); |
512 EXPECT_TRUE(NavigateIframeToURL(shell(), | 468 EXPECT_TRUE(NavigateIframeToURL(shell(), |
513 server_redirect_http_url, "test")); | 469 server_redirect_http_url, "test")); |
514 EXPECT_EQ(observer.navigation_url(), http_url); | 470 EXPECT_EQ(observer.last_navigation_url(), http_url); |
515 EXPECT_TRUE(observer.navigation_succeeded()); | 471 EXPECT_TRUE(observer.last_navigation_succeeded()); |
516 } | 472 } |
517 | 473 |
518 { | 474 { |
519 // Load same-site client-redirect page into Iframe, | 475 // Load same-site client-redirect page into Iframe, |
520 // which redirects to same-site page. | 476 // which redirects to same-site page. |
521 GURL client_redirect_http_url(test_server()->GetURL( | 477 GURL client_redirect_http_url(test_server()->GetURL( |
522 "client-redirect?" + http_url.spec())); | 478 "client-redirect?" + http_url.spec())); |
523 RedirectNotificationObserver load_observer2( | 479 RedirectNotificationObserver load_observer2( |
524 NOTIFICATION_LOAD_STOP, | 480 NOTIFICATION_LOAD_STOP, |
525 Source<NavigationController>( | 481 Source<NavigationController>( |
526 &shell()->web_contents()->GetController())); | 482 &shell()->web_contents()->GetController())); |
527 | 483 |
528 EXPECT_TRUE(NavigateIframeToURL(shell(), | 484 EXPECT_TRUE(NavigateIframeToURL(shell(), |
529 client_redirect_http_url, "test")); | 485 client_redirect_http_url, "test")); |
530 | 486 |
531 // Same-site Client-Redirect Page should be loaded successfully. | 487 // Same-site Client-Redirect Page should be loaded successfully. |
532 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 488 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); |
533 EXPECT_TRUE(observer.navigation_succeeded()); | 489 EXPECT_TRUE(observer.last_navigation_succeeded()); |
534 | 490 |
535 // Redirecting to Same-site Page should be loaded successfully. | 491 // Redirecting to Same-site Page should be loaded successfully. |
536 load_observer2.Wait(); | 492 load_observer2.Wait(); |
537 EXPECT_EQ(observer.navigation_url(), http_url); | 493 EXPECT_EQ(observer.last_navigation_url(), http_url); |
538 EXPECT_TRUE(observer.navigation_succeeded()); | 494 EXPECT_TRUE(observer.last_navigation_succeeded()); |
539 } | 495 } |
540 } | 496 } |
541 | 497 |
542 // TODO(nasko): Disable this test until out-of-process iframes is ready and the | 498 // TODO(nasko): Disable this test until out-of-process iframes is ready and the |
543 // security checks are back in place. | 499 // security checks are back in place. |
544 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run | 500 // TODO(creis): Replace SpawnedTestServer with host_resolver to get test to run |
545 // on Android (http://crbug.com/187570). | 501 // on Android (http://crbug.com/187570). |
546 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 502 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
547 DISABLED_CrossSiteIframeRedirectTwice) { | 503 DISABLED_CrossSiteIframeRedirectTwice) { |
548 ASSERT_TRUE(test_server()->Start()); | 504 ASSERT_TRUE(test_server()->Start()); |
549 net::SpawnedTestServer https_server( | 505 net::SpawnedTestServer https_server( |
550 net::SpawnedTestServer::TYPE_HTTPS, | 506 net::SpawnedTestServer::TYPE_HTTPS, |
551 net::SpawnedTestServer::kLocalhost, | 507 net::SpawnedTestServer::kLocalhost, |
552 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); | 508 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); |
553 ASSERT_TRUE(https_server.Start()); | 509 ASSERT_TRUE(https_server.Start()); |
554 | 510 |
555 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | 511 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
556 GURL http_url(test_server()->GetURL("files/title1.html")); | 512 GURL http_url(test_server()->GetURL("files/title1.html")); |
557 GURL https_url(https_server.GetURL("files/title1.html")); | 513 GURL https_url(https_server.GetURL("files/title1.html")); |
558 | 514 |
559 NavigateToURL(shell(), main_url); | 515 NavigateToURL(shell(), main_url); |
560 | 516 |
561 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 517 TestNavigationObserver observer(shell()->web_contents()); |
562 { | 518 { |
563 // Load client-redirect page pointing to a cross-site client-redirect page, | 519 // Load client-redirect page pointing to a cross-site client-redirect page, |
564 // which eventually redirects back to same-site page. | 520 // which eventually redirects back to same-site page. |
565 GURL client_redirect_https_url(https_server.GetURL( | 521 GURL client_redirect_https_url(https_server.GetURL( |
566 "client-redirect?" + http_url.spec())); | 522 "client-redirect?" + http_url.spec())); |
567 GURL client_redirect_http_url(test_server()->GetURL( | 523 GURL client_redirect_http_url(test_server()->GetURL( |
568 "client-redirect?" + client_redirect_https_url.spec())); | 524 "client-redirect?" + client_redirect_https_url.spec())); |
569 | 525 |
570 // We should wait until second client redirect get cancelled. | 526 // We should wait until second client redirect get cancelled. |
571 RedirectNotificationObserver load_observer2( | 527 RedirectNotificationObserver load_observer2( |
572 NOTIFICATION_LOAD_STOP, | 528 NOTIFICATION_LOAD_STOP, |
573 Source<NavigationController>( | 529 Source<NavigationController>( |
574 &shell()->web_contents()->GetController())); | 530 &shell()->web_contents()->GetController())); |
575 | 531 |
576 EXPECT_TRUE(NavigateIframeToURL(shell(), client_redirect_http_url, "test")); | 532 EXPECT_TRUE(NavigateIframeToURL(shell(), client_redirect_http_url, "test")); |
577 | 533 |
578 // DidFailProvisionalLoad when navigating to client_redirect_https_url. | 534 // DidFailProvisionalLoad when navigating to client_redirect_https_url. |
579 load_observer2.Wait(); | 535 load_observer2.Wait(); |
580 EXPECT_EQ(observer.navigation_url(), client_redirect_https_url); | 536 EXPECT_EQ(observer.last_navigation_url(), client_redirect_https_url); |
581 EXPECT_FALSE(observer.navigation_succeeded()); | 537 EXPECT_FALSE(observer.last_navigation_succeeded()); |
582 } | 538 } |
583 | 539 |
584 { | 540 { |
585 // Load server-redirect page pointing to a cross-site server-redirect page, | 541 // Load server-redirect page pointing to a cross-site server-redirect page, |
586 // which eventually redirect back to same-site page. | 542 // which eventually redirect back to same-site page. |
587 GURL server_redirect_https_url(https_server.GetURL( | 543 GURL server_redirect_https_url(https_server.GetURL( |
588 "server-redirect?" + http_url.spec())); | 544 "server-redirect?" + http_url.spec())); |
589 GURL server_redirect_http_url(test_server()->GetURL( | 545 GURL server_redirect_http_url(test_server()->GetURL( |
590 "server-redirect?" + server_redirect_https_url.spec())); | 546 "server-redirect?" + server_redirect_https_url.spec())); |
591 EXPECT_TRUE(NavigateIframeToURL(shell(), | 547 EXPECT_TRUE(NavigateIframeToURL(shell(), |
592 server_redirect_http_url, "test")); | 548 server_redirect_http_url, "test")); |
593 EXPECT_EQ(observer.navigation_url(), http_url); | 549 EXPECT_EQ(observer.last_navigation_url(), http_url); |
594 EXPECT_TRUE(observer.navigation_succeeded()); | 550 EXPECT_TRUE(observer.last_navigation_succeeded()); |
595 } | 551 } |
596 | 552 |
597 { | 553 { |
598 // Load server-redirect page pointing to a cross-site server-redirect page, | 554 // Load server-redirect page pointing to a cross-site server-redirect page, |
599 // which eventually redirects back to cross-site page. | 555 // which eventually redirects back to cross-site page. |
600 GURL server_redirect_https_url(https_server.GetURL( | 556 GURL server_redirect_https_url(https_server.GetURL( |
601 "server-redirect?" + https_url.spec())); | 557 "server-redirect?" + https_url.spec())); |
602 GURL server_redirect_http_url(test_server()->GetURL( | 558 GURL server_redirect_http_url(test_server()->GetURL( |
603 "server-redirect?" + server_redirect_https_url.spec())); | 559 "server-redirect?" + server_redirect_https_url.spec())); |
604 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 560 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); |
605 | 561 |
606 // DidFailProvisionalLoad when navigating to https_url. | 562 // DidFailProvisionalLoad when navigating to https_url. |
607 EXPECT_EQ(observer.navigation_url(), https_url); | 563 EXPECT_EQ(observer.last_navigation_url(), https_url); |
608 EXPECT_FALSE(observer.navigation_succeeded()); | 564 EXPECT_FALSE(observer.last_navigation_succeeded()); |
609 } | 565 } |
610 | 566 |
611 { | 567 { |
612 // Load server-redirect page pointing to a cross-site client-redirect page, | 568 // Load server-redirect page pointing to a cross-site client-redirect page, |
613 // which eventually redirects back to same-site page. | 569 // which eventually redirects back to same-site page. |
614 GURL client_redirect_http_url(https_server.GetURL( | 570 GURL client_redirect_http_url(https_server.GetURL( |
615 "client-redirect?" + http_url.spec())); | 571 "client-redirect?" + http_url.spec())); |
616 GURL server_redirect_http_url(test_server()->GetURL( | 572 GURL server_redirect_http_url(test_server()->GetURL( |
617 "server-redirect?" + client_redirect_http_url.spec())); | 573 "server-redirect?" + client_redirect_http_url.spec())); |
618 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); | 574 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); |
619 | 575 |
620 // DidFailProvisionalLoad when navigating to client_redirect_http_url. | 576 // DidFailProvisionalLoad when navigating to client_redirect_http_url. |
621 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); | 577 EXPECT_EQ(observer.last_navigation_url(), client_redirect_http_url); |
622 EXPECT_FALSE(observer.navigation_succeeded()); | 578 EXPECT_FALSE(observer.last_navigation_succeeded()); |
623 } | 579 } |
624 } | 580 } |
625 | 581 |
626 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are | 582 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are |
627 // created in the FrameTree skipping the subtree of the navigating frame. | 583 // created in the FrameTree skipping the subtree of the navigating frame. |
628 // | 584 // |
629 // Disabled on Mac due to flakiness on ASAN. http://crbug.com/425248 | 585 // Disabled on Mac due to flakiness on ASAN. http://crbug.com/425248 |
630 #if defined(OS_MACOSX) | 586 #if defined(OS_MACOSX) |
631 #define MAYBE_ProxyCreationSkipsSubtree DISABLED_ProxyCreationSkipsSubtree | 587 #define MAYBE_ProxyCreationSkipsSubtree DISABLED_ProxyCreationSkipsSubtree |
632 #else | 588 #else |
633 #define MAYBE_ProxyCreationSkipsSubtree ProxyCreationSkipsSubtree | 589 #define MAYBE_ProxyCreationSkipsSubtree ProxyCreationSkipsSubtree |
634 #endif | 590 #endif |
635 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 591 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
636 MAYBE_ProxyCreationSkipsSubtree) { | 592 MAYBE_ProxyCreationSkipsSubtree) { |
637 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 593 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
638 NavigateToURL(shell(), main_url); | 594 NavigateToURL(shell(), main_url); |
639 | 595 |
640 // It is safe to obtain the root frame tree node here, as it doesn't change. | 596 // It is safe to obtain the root frame tree node here, as it doesn't change. |
641 FrameTreeNode* root = | 597 FrameTreeNode* root = |
642 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 598 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
643 GetFrameTree()->root(); | 599 GetFrameTree()->root(); |
644 | 600 |
645 EXPECT_TRUE(root->child_at(1) != NULL); | 601 EXPECT_TRUE(root->child_at(1) != NULL); |
646 EXPECT_EQ(2U, root->child_at(1)->child_count()); | 602 EXPECT_EQ(2U, root->child_at(1)->child_count()); |
647 | 603 |
648 { | 604 { |
649 // Load same-site page into iframe. | 605 // Load same-site page into iframe. |
650 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 606 TestNavigationObserver observer(shell()->web_contents()); |
651 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 607 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
652 NavigateFrameToURL(root->child_at(0), http_url); | 608 NavigateFrameToURL(root->child_at(0), http_url); |
653 EXPECT_EQ(http_url, observer.navigation_url()); | 609 EXPECT_EQ(http_url, observer.last_navigation_url()); |
654 EXPECT_TRUE(observer.navigation_succeeded()); | 610 EXPECT_TRUE(observer.last_navigation_succeeded()); |
655 RenderFrameProxyHost* proxy_to_parent = | 611 RenderFrameProxyHost* proxy_to_parent = |
656 root->child_at(0)->render_manager()->GetRenderFrameProxyHost( | 612 root->child_at(0)->render_manager()->GetRenderFrameProxyHost( |
657 shell()->web_contents()->GetSiteInstance()); | 613 shell()->web_contents()->GetSiteInstance()); |
658 EXPECT_FALSE(proxy_to_parent); | 614 EXPECT_FALSE(proxy_to_parent); |
659 } | 615 } |
660 | 616 |
661 // Create the cross-site URL to navigate to. | 617 // Create the cross-site URL to navigate to. |
662 GURL cross_site_url = | 618 GURL cross_site_url = |
663 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"); | 619 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"); |
664 | 620 |
665 // Load cross-site page into the second iframe without waiting for the | 621 // Load cross-site page into the second iframe without waiting for the |
666 // navigation to complete. Once LoadURLWithParams returns, we would expect | 622 // navigation to complete. Once LoadURLWithParams returns, we would expect |
667 // proxies to have been created in the frame tree, but children of the | 623 // proxies to have been created in the frame tree, but children of the |
668 // navigating frame to still be present. The reason is that we don't run the | 624 // navigating frame to still be present. The reason is that we don't run the |
669 // message loop, so no IPCs that alter the frame tree can be processed. | 625 // message loop, so no IPCs that alter the frame tree can be processed. |
670 FrameTreeNode* child = root->child_at(1); | 626 FrameTreeNode* child = root->child_at(1); |
671 SiteInstance* site = NULL; | 627 SiteInstance* site = NULL; |
672 { | 628 { |
673 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 629 TestNavigationObserver observer(shell()->web_contents()); |
674 TestFrameNavigationObserver navigation_observer(child); | 630 TestFrameNavigationObserver navigation_observer(child); |
675 NavigationController::LoadURLParams params(cross_site_url); | 631 NavigationController::LoadURLParams params(cross_site_url); |
676 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); | 632 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); |
677 params.frame_tree_node_id = child->frame_tree_node_id(); | 633 params.frame_tree_node_id = child->frame_tree_node_id(); |
678 child->navigator()->GetController()->LoadURLWithParams(params); | 634 child->navigator()->GetController()->LoadURLWithParams(params); |
679 EXPECT_TRUE(child->render_manager()->pending_frame_host()); | 635 EXPECT_TRUE(child->render_manager()->pending_frame_host()); |
680 | 636 |
681 site = child->render_manager()->pending_frame_host()->GetSiteInstance(); | 637 site = child->render_manager()->pending_frame_host()->GetSiteInstance(); |
682 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site); | 638 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site); |
683 | 639 |
684 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site)); | 640 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site)); |
685 EXPECT_TRUE( | 641 EXPECT_TRUE( |
686 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site)); | 642 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site)); |
687 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site)); | 643 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site)); |
688 for (size_t i = 0; i < child->child_count(); ++i) { | 644 for (size_t i = 0; i < child->child_count(); ++i) { |
689 EXPECT_FALSE( | 645 EXPECT_FALSE( |
690 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site)); | 646 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site)); |
691 } | 647 } |
692 // Now that the verification is done, run the message loop and wait for the | 648 // Now that the verification is done, run the message loop and wait for the |
693 // navigation to complete. | 649 // navigation to complete. |
694 navigation_observer.Wait(); | 650 navigation_observer.Wait(); |
695 EXPECT_FALSE(child->render_manager()->pending_frame_host()); | 651 EXPECT_FALSE(child->render_manager()->pending_frame_host()); |
696 EXPECT_TRUE(observer.navigation_succeeded()); | 652 EXPECT_TRUE(observer.last_navigation_succeeded()); |
697 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 653 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
698 } | 654 } |
699 | 655 |
700 // Load another cross-site page into the same iframe. | 656 // Load another cross-site page into the same iframe. |
701 cross_site_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); | 657 cross_site_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); |
702 { | 658 { |
703 // Perform the same checks as the first cross-site navigation, since | 659 // Perform the same checks as the first cross-site navigation, since |
704 // there have been issues in subsequent cross-site navigations. Also ensure | 660 // there have been issues in subsequent cross-site navigations. Also ensure |
705 // that the SiteInstance has properly changed. | 661 // that the SiteInstance has properly changed. |
706 // TODO(nasko): Once we have proper cleanup of resources, add code to | 662 // TODO(nasko): Once we have proper cleanup of resources, add code to |
707 // verify that the intermediate SiteInstance/RenderFrameHost have been | 663 // verify that the intermediate SiteInstance/RenderFrameHost have been |
708 // properly cleaned up. | 664 // properly cleaned up. |
709 SitePerProcessWebContentsObserver observer(shell()->web_contents()); | 665 TestNavigationObserver observer(shell()->web_contents()); |
710 TestFrameNavigationObserver navigation_observer(child); | 666 TestFrameNavigationObserver navigation_observer(child); |
711 NavigationController::LoadURLParams params(cross_site_url); | 667 NavigationController::LoadURLParams params(cross_site_url); |
712 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); | 668 params.transition_type = PageTransitionFromInt(ui::PAGE_TRANSITION_LINK); |
713 params.frame_tree_node_id = child->frame_tree_node_id(); | 669 params.frame_tree_node_id = child->frame_tree_node_id(); |
714 child->navigator()->GetController()->LoadURLWithParams(params); | 670 child->navigator()->GetController()->LoadURLWithParams(params); |
715 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL); | 671 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL); |
716 | 672 |
717 SiteInstance* site2 = | 673 SiteInstance* site2 = |
718 child->render_manager()->pending_frame_host()->GetSiteInstance(); | 674 child->render_manager()->pending_frame_host()->GetSiteInstance(); |
719 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2); | 675 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2); |
720 EXPECT_NE(site, site2); | 676 EXPECT_NE(site, site2); |
721 | 677 |
722 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2)); | 678 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2)); |
723 EXPECT_TRUE( | 679 EXPECT_TRUE( |
724 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2)); | 680 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2)); |
725 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2)); | 681 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2)); |
726 for (size_t i = 0; i < child->child_count(); ++i) { | 682 for (size_t i = 0; i < child->child_count(); ++i) { |
727 EXPECT_FALSE( | 683 EXPECT_FALSE( |
728 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); | 684 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2)); |
729 } | 685 } |
730 | 686 |
731 navigation_observer.Wait(); | 687 navigation_observer.Wait(); |
732 EXPECT_TRUE(observer.navigation_succeeded()); | 688 EXPECT_TRUE(observer.last_navigation_succeeded()); |
733 EXPECT_EQ(cross_site_url, observer.navigation_url()); | 689 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
734 EXPECT_EQ(0U, child->child_count()); | 690 EXPECT_EQ(0U, child->child_count()); |
735 } | 691 } |
736 } | 692 } |
737 | 693 |
738 } // namespace content | 694 } // namespace content |
OLD | NEW |