| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 6262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6273 | 6273 |
| 6274 EXPECT_TRUE(observer.WasUserInteractionReceived()); | 6274 EXPECT_TRUE(observer.WasUserInteractionReceived()); |
| 6275 | 6275 |
| 6276 // Target an event to the main frame. | 6276 // Target an event to the main frame. |
| 6277 observer.Reset(); | 6277 observer.Reset(); |
| 6278 SimulateMouseClick(root->current_frame_host()->GetRenderWidgetHost(), 1, 1); | 6278 SimulateMouseClick(root->current_frame_host()->GetRenderWidgetHost(), 1, 1); |
| 6279 | 6279 |
| 6280 EXPECT_TRUE(observer.WasUserInteractionReceived()); | 6280 EXPECT_TRUE(observer.WasUserInteractionReceived()); |
| 6281 } | 6281 } |
| 6282 | 6282 |
| 6283 // Ensures that navigating to data: URLs present in session history will |
| 6284 // correctly commit the navigation in the same process as the parent frame. |
| 6285 // See https://crbug.com/606996. |
| 6286 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 6287 NavigateSubframeToDataUrlInSessionHistory) { |
| 6288 GURL main_url(embedded_test_server()->GetURL( |
| 6289 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); |
| 6290 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 6291 |
| 6292 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 6293 EXPECT_EQ(2U, root->child_count()); |
| 6294 EXPECT_EQ( |
| 6295 " Site A ------------ proxies for B\n" |
| 6296 " |--Site B ------- proxies for A\n" |
| 6297 " +--Site B ------- proxies for A\n" |
| 6298 "Where A = http://a.com/\n" |
| 6299 " B = http://b.com/", |
| 6300 DepictFrameTree(root)); |
| 6301 |
| 6302 TestNavigationObserver observer(shell()->web_contents()); |
| 6303 FrameTreeNode* child = root->child_at(0); |
| 6304 |
| 6305 // Navigate iframe to a data URL, which will commit in a new SiteInstance. |
| 6306 GURL data_url("data:text/html,dataurl"); |
| 6307 NavigateFrameToURL(child, data_url); |
| 6308 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 6309 EXPECT_EQ(data_url, observer.last_navigation_url()); |
| 6310 scoped_refptr<SiteInstanceImpl> orig_site_instance = |
| 6311 child->current_frame_host()->GetSiteInstance(); |
| 6312 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), orig_site_instance); |
| 6313 |
| 6314 // Navigate it to another cross-site url. |
| 6315 GURL cross_site_url(embedded_test_server()->GetURL("c.com", "/title1.html")); |
| 6316 NavigateFrameToURL(child, cross_site_url); |
| 6317 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 6318 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
| 6319 EXPECT_EQ(3, web_contents()->GetController().GetEntryCount()); |
| 6320 EXPECT_NE(orig_site_instance, child->current_frame_host()->GetSiteInstance()); |
| 6321 |
| 6322 // Go back and ensure the data: URL committed in the same SiteInstance as the |
| 6323 // original navigation. |
| 6324 EXPECT_TRUE(web_contents()->GetController().CanGoBack()); |
| 6325 TestFrameNavigationObserver frame_observer(child); |
| 6326 web_contents()->GetController().GoBack(); |
| 6327 frame_observer.WaitForCommit(); |
| 6328 EXPECT_EQ(orig_site_instance, child->current_frame_host()->GetSiteInstance()); |
| 6329 } |
| 6330 |
| 6331 // Ensures that navigating to about:blank URLs present in session history will |
| 6332 // correctly commit the navigation in the same process as the one used for |
| 6333 // the original navigation. |
| 6334 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 6335 NavigateSubframeToAboutBlankInSessionHistory) { |
| 6336 GURL main_url(embedded_test_server()->GetURL( |
| 6337 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); |
| 6338 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 6339 |
| 6340 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 6341 EXPECT_EQ(2U, root->child_count()); |
| 6342 EXPECT_EQ( |
| 6343 " Site A ------------ proxies for B\n" |
| 6344 " |--Site B ------- proxies for A\n" |
| 6345 " +--Site B ------- proxies for A\n" |
| 6346 "Where A = http://a.com/\n" |
| 6347 " B = http://b.com/", |
| 6348 DepictFrameTree(root)); |
| 6349 |
| 6350 TestNavigationObserver observer(shell()->web_contents()); |
| 6351 FrameTreeNode* child = root->child_at(0); |
| 6352 |
| 6353 // Navigate iframe to about:blank, which will commit in a new SiteInstance. |
| 6354 GURL about_blank_url("about:blank"); |
| 6355 NavigateFrameToURL(child, about_blank_url); |
| 6356 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 6357 EXPECT_EQ(about_blank_url, observer.last_navigation_url()); |
| 6358 scoped_refptr<SiteInstanceImpl> orig_site_instance = |
| 6359 child->current_frame_host()->GetSiteInstance(); |
| 6360 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), orig_site_instance); |
| 6361 |
| 6362 // Navigate it to another cross-site url. |
| 6363 GURL cross_site_url(embedded_test_server()->GetURL("c.com", "/title1.html")); |
| 6364 NavigateFrameToURL(child, cross_site_url); |
| 6365 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 6366 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
| 6367 EXPECT_EQ(3, web_contents()->GetController().GetEntryCount()); |
| 6368 EXPECT_NE(orig_site_instance, child->current_frame_host()->GetSiteInstance()); |
| 6369 |
| 6370 // Go back and ensure the about:blank URL committed in the same SiteInstance |
| 6371 // as the original navigation. |
| 6372 EXPECT_TRUE(web_contents()->GetController().CanGoBack()); |
| 6373 TestFrameNavigationObserver frame_observer(child); |
| 6374 web_contents()->GetController().GoBack(); |
| 6375 frame_observer.WaitForCommit(); |
| 6376 EXPECT_EQ(orig_site_instance, child->current_frame_host()->GetSiteInstance()); |
| 6377 } |
| 6378 |
| 6283 } // namespace content | 6379 } // namespace content |
| OLD | NEW |