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/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 EXPECT_EQ(orig_site_instance, blank_site_instance); | 499 EXPECT_EQ(orig_site_instance, blank_site_instance); |
500 | 500 |
501 // Now navigate the new tab to a different site. | 501 // Now navigate the new tab to a different site. |
502 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | 502 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); |
503 scoped_refptr<SiteInstance> new_site_instance( | 503 scoped_refptr<SiteInstance> new_site_instance( |
504 new_shell->web_contents()->GetSiteInstance()); | 504 new_shell->web_contents()->GetSiteInstance()); |
505 EXPECT_NE(orig_site_instance, new_site_instance); | 505 EXPECT_NE(orig_site_instance, new_site_instance); |
506 EXPECT_TRUE(new_shell->web_contents()->HasOpener()); | 506 EXPECT_TRUE(new_shell->web_contents()->HasOpener()); |
507 | 507 |
508 // Now disown the opener. | 508 // Now disown the opener. |
| 509 LOG(ERROR) << ">>> Disowning opener"; |
509 EXPECT_TRUE(ExecuteScript(new_shell->web_contents(), | 510 EXPECT_TRUE(ExecuteScript(new_shell->web_contents(), |
510 "window.opener = null;")); | 511 "window.opener = null;")); |
| 512 LOG(ERROR) << ">>> Disowning opener - complete"; |
511 EXPECT_FALSE(new_shell->web_contents()->HasOpener()); | 513 EXPECT_FALSE(new_shell->web_contents()->HasOpener()); |
512 | 514 |
513 // Go back and ensure the opener is still null. | 515 // Go back and ensure the opener is still null. |
514 { | 516 { |
515 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); | 517 TestNavigationObserver back_nav_load_observer(new_shell->web_contents()); |
| 518 LOG(ERROR) << "Navigating back."; |
516 new_shell->web_contents()->GetController().GoBack(); | 519 new_shell->web_contents()->GetController().GoBack(); |
517 back_nav_load_observer.Wait(); | 520 back_nav_load_observer.Wait(); |
| 521 LOG(ERROR) << "Navigating back - complete!"; |
518 } | 522 } |
519 success = false; | 523 success = false; |
520 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 524 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
521 new_shell->web_contents(), | 525 new_shell->web_contents(), |
522 "window.domAutomationController.send(window.opener == null);", | 526 "window.domAutomationController.send(window.opener == null);", |
523 &success)); | 527 &success)); |
524 EXPECT_TRUE(success); | 528 EXPECT_TRUE(success); |
525 EXPECT_FALSE(new_shell->web_contents()->HasOpener()); | 529 EXPECT_FALSE(new_shell->web_contents()->HasOpener()); |
526 | 530 |
527 // Now navigate forward again (creating a new process) and check opener. | 531 // Now navigate forward again (creating a new process) and check opener. |
| 532 LOG(ERROR) << "Navigating forward."; |
528 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | 533 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); |
| 534 LOG(ERROR) << "Navigating forward - complete!"; |
529 success = false; | 535 success = false; |
530 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 536 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
531 new_shell->web_contents(), | 537 new_shell->web_contents(), |
532 "window.domAutomationController.send(window.opener == null);", | 538 "window.domAutomationController.send(window.opener == null);", |
533 &success)); | 539 &success)); |
534 EXPECT_TRUE(success); | 540 EXPECT_TRUE(success); |
535 EXPECT_FALSE(new_shell->web_contents()->HasOpener()); | 541 EXPECT_FALSE(new_shell->web_contents()->HasOpener()); |
536 } | 542 } |
537 | 543 |
538 // Test that subframes can disown their openers. http://crbug.com/225528. | 544 // Test that subframes can disown their openers. http://crbug.com/225528. |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 | 1367 |
1362 // Wait for the navigation in the new window to finish, if it hasn't. | 1368 // Wait for the navigation in the new window to finish, if it hasn't. |
1363 WaitForLoadStop(new_shell->web_contents()); | 1369 WaitForLoadStop(new_shell->web_contents()); |
1364 EXPECT_EQ("/files/title1.html", | 1370 EXPECT_EQ("/files/title1.html", |
1365 new_shell->web_contents()->GetLastCommittedURL().path()); | 1371 new_shell->web_contents()->GetLastCommittedURL().path()); |
1366 | 1372 |
1367 // Should have the same SiteInstance. | 1373 // Should have the same SiteInstance. |
1368 EXPECT_EQ(orig_site_instance.get(), | 1374 EXPECT_EQ(orig_site_instance.get(), |
1369 new_shell->web_contents()->GetSiteInstance()); | 1375 new_shell->web_contents()->GetSiteInstance()); |
1370 | 1376 |
| 1377 LOG(ERROR) << "Navigating new_shell cross-process"; |
1371 // 2. Send the second tab to a different process. | 1378 // 2. Send the second tab to a different process. |
1372 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); | 1379 NavigateToURL(new_shell, GetCrossSiteURL("files/title1.html")); |
| 1380 LOG(ERROR) << "Navigating new_shell cross-process - complete"; |
1373 scoped_refptr<SiteInstance> new_site_instance( | 1381 scoped_refptr<SiteInstance> new_site_instance( |
1374 new_shell->web_contents()->GetSiteInstance()); | 1382 new_shell->web_contents()->GetSiteInstance()); |
1375 EXPECT_NE(orig_site_instance, new_site_instance); | 1383 EXPECT_NE(orig_site_instance, new_site_instance); |
1376 | 1384 |
1377 // 3. Send the first tab to the second tab's process. | 1385 // 3. Send the first tab to the second tab's process. |
| 1386 LOG(ERROR) << "Navigating shell cross-process"; |
1378 NavigateToURL(shell(), GetCrossSiteURL("files/title1.html")); | 1387 NavigateToURL(shell(), GetCrossSiteURL("files/title1.html")); |
| 1388 LOG(ERROR) << "Navigating shell cross-process - complete"; |
1379 | 1389 |
1380 // Make sure it ends up at the right page. | 1390 // Make sure it ends up at the right page. |
1381 WaitForLoadStop(shell()->web_contents()); | 1391 WaitForLoadStop(shell()->web_contents()); |
| 1392 LOG(ERROR) << "Waiting for load stop, complete"; |
1382 EXPECT_EQ(GetCrossSiteURL("files/title1.html"), | 1393 EXPECT_EQ(GetCrossSiteURL("files/title1.html"), |
1383 shell()->web_contents()->GetLastCommittedURL()); | 1394 shell()->web_contents()->GetLastCommittedURL()); |
1384 EXPECT_EQ(new_site_instance.get(), | 1395 EXPECT_EQ(new_site_instance.get(), |
1385 shell()->web_contents()->GetSiteInstance()); | 1396 shell()->web_contents()->GetSiteInstance()); |
1386 } | 1397 } |
1387 | 1398 |
1388 // Ensure that renderer-side debug URLs do not cause a process swap, since they | 1399 // Ensure that renderer-side debug URLs do not cause a process swap, since they |
1389 // are meant to run in the current page. We had a bug where we expected a | 1400 // are meant to run in the current page. We had a bug where we expected a |
1390 // BrowsingInstance swap to occur on pages like view-source and extensions, | 1401 // BrowsingInstance swap to occur on pages like view-source and extensions, |
1391 // which broke chrome://crash and javascript: URLs. | 1402 // which broke chrome://crash and javascript: URLs. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 NavigateToURL(shell(), cross_site_url); | 1818 NavigateToURL(shell(), cross_site_url); |
1808 rfh_observer.Wait(); | 1819 rfh_observer.Wait(); |
1809 | 1820 |
1810 EXPECT_NE(orig_site_instance_id, | 1821 EXPECT_NE(orig_site_instance_id, |
1811 root->current_frame_host()->GetSiteInstance()->GetId()); | 1822 root->current_frame_host()->GetSiteInstance()->GetId()); |
1812 EXPECT_FALSE(RenderFrameHost::FromID(initial_process_id, initial_rfh_id)); | 1823 EXPECT_FALSE(RenderFrameHost::FromID(initial_process_id, initial_rfh_id)); |
1813 EXPECT_FALSE(RenderViewHost::FromID(initial_process_id, initial_rvh_id)); | 1824 EXPECT_FALSE(RenderViewHost::FromID(initial_process_id, initial_rvh_id)); |
1814 } | 1825 } |
1815 | 1826 |
1816 } // namespace content | 1827 } // namespace content |
OLD | NEW |