OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 navigation_observer.Wait(); | 391 navigation_observer.Wait(); |
392 | 392 |
393 // Should have swapped back and shown the new window again. | 393 // Should have swapped back and shown the new window again. |
394 scoped_refptr<SiteInstance> revisit_site_instance( | 394 scoped_refptr<SiteInstance> revisit_site_instance( |
395 new_shell->web_contents()->GetSiteInstance()); | 395 new_shell->web_contents()->GetSiteInstance()); |
396 EXPECT_EQ(orig_site_instance, revisit_site_instance); | 396 EXPECT_EQ(orig_site_instance, revisit_site_instance); |
397 | 397 |
398 // If it navigates away to another process, the original window should | 398 // If it navigates away to another process, the original window should |
399 // still be able to close it (using a cross-process close message). | 399 // still be able to close it (using a cross-process close message). |
400 NavigateToURL(new_shell, cross_site_url); | 400 NavigateToURL(new_shell, cross_site_url); |
401 EXPECT_EQ(new_site_instance, | 401 EXPECT_EQ(new_site_instance.get(), |
402 new_shell->web_contents()->GetSiteInstance()); | 402 new_shell->web_contents()->GetSiteInstance()); |
403 WebContentsDestroyedWatcher close_watcher(new_shell->web_contents()); | 403 WebContentsDestroyedWatcher close_watcher(new_shell->web_contents()); |
404 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 404 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
405 shell()->web_contents(), | 405 shell()->web_contents(), |
406 "window.domAutomationController.send(testCloseWindow());", | 406 "window.domAutomationController.send(testCloseWindow());", |
407 &success)); | 407 &success)); |
408 EXPECT_TRUE(success); | 408 EXPECT_TRUE(success); |
409 close_watcher.Wait(); | 409 close_watcher.Wait(); |
410 } | 410 } |
411 | 411 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 &success)); | 566 &success)); |
567 EXPECT_TRUE(success); | 567 EXPECT_TRUE(success); |
568 | 568 |
569 // Wait for the navigation in the new window to finish, if it hasn't, then | 569 // Wait for the navigation in the new window to finish, if it hasn't, then |
570 // send it to post_message.html on the original site. | 570 // send it to post_message.html on the original site. |
571 Shell* new_shell2 = new_shell_observer2.GetShell(); | 571 Shell* new_shell2 = new_shell_observer2.GetShell(); |
572 WebContents* new_contents = new_shell2->web_contents(); | 572 WebContents* new_contents = new_shell2->web_contents(); |
573 WaitForLoadStop(new_contents); | 573 WaitForLoadStop(new_contents); |
574 EXPECT_EQ("/files/title2.html", new_contents->GetLastCommittedURL().path()); | 574 EXPECT_EQ("/files/title2.html", new_contents->GetLastCommittedURL().path()); |
575 NavigateToURL(new_shell2, test_server()->GetURL("files/post_message.html")); | 575 NavigateToURL(new_shell2, test_server()->GetURL("files/post_message.html")); |
576 EXPECT_EQ(orig_site_instance, new_contents->GetSiteInstance()); | 576 EXPECT_EQ(orig_site_instance.get(), new_contents->GetSiteInstance()); |
577 RenderFrameHostManager* new_manager = | 577 RenderFrameHostManager* new_manager = |
578 static_cast<WebContentsImpl*>(new_contents)->GetRenderManagerForTesting(); | 578 static_cast<WebContentsImpl*>(new_contents)->GetRenderManagerForTesting(); |
579 | 579 |
580 // We now have three windows. The opener should have a swapped out RVH | 580 // We now have three windows. The opener should have a swapped out RVH |
581 // for the new SiteInstance, but the _blank window should not. | 581 // for the new SiteInstance, but the _blank window should not. |
582 EXPECT_EQ(3u, Shell::windows().size()); | 582 EXPECT_EQ(3u, Shell::windows().size()); |
583 EXPECT_TRUE( | 583 EXPECT_TRUE( |
584 opener_manager->GetSwappedOutRenderViewHost(foo_site_instance.get())); | 584 opener_manager->GetSwappedOutRenderViewHost(foo_site_instance.get())); |
585 EXPECT_FALSE( | 585 EXPECT_FALSE( |
586 new_manager->GetSwappedOutRenderViewHost(foo_site_instance.get())); | 586 new_manager->GetSwappedOutRenderViewHost(foo_site_instance.get())); |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 &success)); | 1265 &success)); |
1266 EXPECT_TRUE(success); | 1266 EXPECT_TRUE(success); |
1267 Shell* new_shell = new_shell_observer.GetShell(); | 1267 Shell* new_shell = new_shell_observer.GetShell(); |
1268 | 1268 |
1269 // Wait for the navigation in the new window to finish, if it hasn't. | 1269 // Wait for the navigation in the new window to finish, if it hasn't. |
1270 WaitForLoadStop(new_shell->web_contents()); | 1270 WaitForLoadStop(new_shell->web_contents()); |
1271 EXPECT_EQ("/files/title1.html", | 1271 EXPECT_EQ("/files/title1.html", |
1272 new_shell->web_contents()->GetLastCommittedURL().path()); | 1272 new_shell->web_contents()->GetLastCommittedURL().path()); |
1273 | 1273 |
1274 // Should have the same SiteInstance. | 1274 // Should have the same SiteInstance. |
1275 EXPECT_EQ(orig_site_instance, new_shell->web_contents()->GetSiteInstance()); | 1275 EXPECT_EQ(orig_site_instance.get(), |
| 1276 new_shell->web_contents()->GetSiteInstance()); |
1276 | 1277 |
1277 // 2. Send the second tab to a different process. | 1278 // 2. Send the second tab to a different process. |
1278 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | 1279 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); |
1279 scoped_refptr<SiteInstance> new_site_instance( | 1280 scoped_refptr<SiteInstance> new_site_instance( |
1280 new_shell->web_contents()->GetSiteInstance()); | 1281 new_shell->web_contents()->GetSiteInstance()); |
1281 EXPECT_NE(orig_site_instance, new_site_instance); | 1282 EXPECT_NE(orig_site_instance, new_site_instance); |
1282 | 1283 |
1283 // 3. Send the first tab to the second tab's process. | 1284 // 3. Send the first tab to the second tab's process. |
1284 NavigateToURL(shell(), GetCrossSiteURL("files/title1.html")); | 1285 NavigateToURL(shell(), GetCrossSiteURL("files/title1.html")); |
1285 | 1286 |
1286 // Make sure it ends up at the right page. | 1287 // Make sure it ends up at the right page. |
1287 WaitForLoadStop(shell()->web_contents()); | 1288 WaitForLoadStop(shell()->web_contents()); |
1288 EXPECT_EQ(GetCrossSiteURL("files/title1.html"), | 1289 EXPECT_EQ(GetCrossSiteURL("files/title1.html"), |
1289 shell()->web_contents()->GetLastCommittedURL()); | 1290 shell()->web_contents()->GetLastCommittedURL()); |
1290 EXPECT_EQ(new_site_instance, shell()->web_contents()->GetSiteInstance()); | 1291 EXPECT_EQ(new_site_instance.get(), |
| 1292 shell()->web_contents()->GetSiteInstance()); |
1291 } | 1293 } |
1292 | 1294 |
1293 // Ensure that renderer-side debug URLs do not cause a process swap, since they | 1295 // Ensure that renderer-side debug URLs do not cause a process swap, since they |
1294 // are meant to run in the current page. We had a bug where we expected a | 1296 // are meant to run in the current page. We had a bug where we expected a |
1295 // BrowsingInstance swap to occur on pages like view-source and extensions, | 1297 // BrowsingInstance swap to occur on pages like view-source and extensions, |
1296 // which broke chrome://crash and javascript: URLs. | 1298 // which broke chrome://crash and javascript: URLs. |
1297 // See http://crbug.com/335503. | 1299 // See http://crbug.com/335503. |
1298 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, RendererDebugURLsDontSwap) { | 1300 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, RendererDebugURLsDontSwap) { |
1299 ASSERT_TRUE(test_server()->Start()); | 1301 ASSERT_TRUE(test_server()->Start()); |
1300 | 1302 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 // Navigate to url1 and check bindings. | 1462 // Navigate to url1 and check bindings. |
1461 NavigateToURL(new_shell, url1); | 1463 NavigateToURL(new_shell, url1); |
1462 // The navigation should have used the first SiteInstance, otherwise | 1464 // The navigation should have used the first SiteInstance, otherwise |
1463 // |initial_rvh| did not have a chance to be used. | 1465 // |initial_rvh| did not have a chance to be used. |
1464 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); | 1466 EXPECT_EQ(new_web_contents->GetSiteInstance(), site_instance1); |
1465 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, | 1467 EXPECT_EQ(BINDINGS_POLICY_WEB_UI, |
1466 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); | 1468 new_web_contents->GetRenderViewHost()->GetEnabledBindings()); |
1467 } | 1469 } |
1468 | 1470 |
1469 } // namespace content | 1471 } // namespace content |
OLD | NEW |