| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 // Wait for the navigation in the new tab to finish, if it hasn't. | 2647 // Wait for the navigation in the new tab to finish, if it hasn't. |
| 2648 WaitForLoadStop(new_shell->web_contents()); | 2648 WaitForLoadStop(new_shell->web_contents()); |
| 2649 EXPECT_EQ("/navigate_opener.html", | 2649 EXPECT_EQ("/navigate_opener.html", |
| 2650 new_shell->web_contents()->GetLastCommittedURL().path()); | 2650 new_shell->web_contents()->GetLastCommittedURL().path()); |
| 2651 | 2651 |
| 2652 // Do a cross-site navigation that winds up same-site. The same-site | 2652 // Do a cross-site navigation that winds up same-site. The same-site |
| 2653 // navigation to a.com will commit in a different process than the original | 2653 // navigation to a.com will commit in a different process than the original |
| 2654 // a.com window. | 2654 // a.com window. |
| 2655 NavigateToURL(new_shell, embedded_test_server()->GetURL( | 2655 NavigateToURL(new_shell, embedded_test_server()->GetURL( |
| 2656 "b.com", "/cross-site/a.com/title1.html")); | 2656 "b.com", "/cross-site/a.com/title1.html")); |
| 2657 if (AreAllSitesIsolatedForTesting()) { | 2657 if (AreAllSitesIsolatedForTesting() || IsBrowserSideNavigationEnabled()) { |
| 2658 // In --site-per-process mode, both windows will actually be in the same | 2658 // In --site-per-process mode, both windows will actually be in the same |
| 2659 // process. | 2659 // process. |
| 2660 // PlzNavigate: the SiteInstance for the navigation is determined after the |
| 2661 // redirect. So both windows will actually be in the same process. |
| 2660 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 2662 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| 2661 new_shell->web_contents()->GetSiteInstance()); | 2663 new_shell->web_contents()->GetSiteInstance()); |
| 2662 } else { | 2664 } else { |
| 2663 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 2665 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 2664 new_shell->web_contents()->GetSiteInstance()); | 2666 new_shell->web_contents()->GetSiteInstance()); |
| 2665 } | 2667 } |
| 2666 | 2668 |
| 2667 std::string result; | 2669 std::string result; |
| 2668 EXPECT_TRUE(ExecuteScriptAndExtractString( | 2670 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 2669 shell()->web_contents(), | 2671 shell()->web_contents(), |
| 2670 "window.domAutomationController.send((function() {\n" | 2672 "window.domAutomationController.send((function() {\n" |
| 2671 " try {\n" | 2673 " try {\n" |
| 2672 " return getLastOpenedWindowLocation();\n" | 2674 " return getLastOpenedWindowLocation();\n" |
| 2673 " } catch (e) {\n" | 2675 " } catch (e) {\n" |
| 2674 " return e.toString();\n" | 2676 " return e.toString();\n" |
| 2675 " }\n" | 2677 " }\n" |
| 2676 "})())", | 2678 "})())", |
| 2677 &result)); | 2679 &result)); |
| 2678 if (AreAllSitesIsolatedForTesting()) { | 2680 if (AreAllSitesIsolatedForTesting() || IsBrowserSideNavigationEnabled()) { |
| 2679 EXPECT_THAT(result, | 2681 EXPECT_THAT(result, |
| 2680 ::testing::MatchesRegex("http://a.com:\\d+/title1.html")); | 2682 ::testing::MatchesRegex("http://a.com:\\d+/title1.html")); |
| 2681 } else { | 2683 } else { |
| 2682 // Accessing a property with normal security checks should throw a | 2684 // Accessing a property with normal security checks should throw a |
| 2683 // SecurityError if the same-origin windows are in different processes. | 2685 // SecurityError if the same-origin windows are in different processes. |
| 2684 EXPECT_THAT(result, | 2686 EXPECT_THAT(result, |
| 2685 ::testing::MatchesRegex("SecurityError: Blocked a frame with " | 2687 ::testing::MatchesRegex("SecurityError: Blocked a frame with " |
| 2686 "origin \"http://a.com:\\d+\" from " | 2688 "origin \"http://a.com:\\d+\" from " |
| 2687 "accessing a cross-origin frame.")); | 2689 "accessing a cross-origin frame.")); |
| 2688 } | 2690 } |
| 2689 } | 2691 } |
| 2690 | 2692 |
| 2691 } // namespace content | 2693 } // namespace content |
| OLD | NEW |