Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2987 | 2987 |
| 2988 success = false; | 2988 success = false; |
| 2989 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 2989 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 2990 popup_root->child_at(1)->current_frame_host(), | 2990 popup_root->child_at(1)->current_frame_host(), |
| 2991 "window.domAutomationController.send(" | 2991 "window.domAutomationController.send(" |
| 2992 " window.opener === window.opener.parent.frames['frame1']);", | 2992 " window.opener === window.opener.parent.frames['frame1']);", |
| 2993 &success)); | 2993 &success)); |
| 2994 EXPECT_TRUE(success); | 2994 EXPECT_TRUE(success); |
| 2995 } | 2995 } |
| 2996 | 2996 |
| 2997 // Check that when a subframe navigates to a new SiteInstance, the new | |
| 2998 // SiteInstance will get a proxy for the opener of subframe's parent. I.e., | |
| 2999 // accessing parent.opener from the subframe should still work after a | |
| 3000 // cross-process navigation. | |
| 3001 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 3002 NavigatingSubframePreservesOpenerInParent) { | |
| 3003 GURL main_url = | |
| 3004 embedded_test_server()->GetURL("foo.com", "/post_message.html"); | |
| 3005 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 3006 | |
| 3007 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
| 3008 ->GetFrameTree() | |
| 3009 ->root(); | |
| 3010 | |
| 3011 // Open a popup with a cross-site page that has a subframe. | |
| 3012 GURL popup_url( | |
| 3013 embedded_test_server()->GetURL("bar.com", "/frame_tree/2-4.html")); | |
|
Charlie Reis
2015/08/31 20:49:43
Anything specific about this page, or can we use t
alexmos
2015/09/01 22:12:28
Done - converted to use cross_site_iframe_factory.
| |
| 3014 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); | |
| 3015 EXPECT_TRUE(popup_shell); | |
| 3016 FrameTreeNode* popup_root = | |
| 3017 static_cast<WebContentsImpl*>(popup_shell->web_contents()) | |
| 3018 ->GetFrameTree() | |
| 3019 ->root(); | |
| 3020 EXPECT_EQ(1U, popup_root->child_count()); | |
| 3021 | |
| 3022 // Check that the popup's opener is correct in the browser process. | |
| 3023 EXPECT_EQ(root, popup_root->opener()); | |
| 3024 | |
| 3025 // Navigate popup's subframe to another site. | |
| 3026 GURL frame_url( | |
| 3027 embedded_test_server()->GetURL("baz.com", "/post_message.html")); | |
| 3028 NavigateFrameToURL(popup_root->child_at(0), frame_url); | |
| 3029 EXPECT_TRUE( | |
| 3030 WaitForRenderFrameReady(popup_root->child_at(0)->current_frame_host())); | |
| 3031 | |
| 3032 // Check that the new subframe process still sees correct opener for its | |
| 3033 // parent by sending a postMessage to subframe's parent.opener. | |
| 3034 bool success = false; | |
| 3035 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 3036 popup_root->child_at(0)->current_frame_host(), | |
| 3037 "window.domAutomationController.send(!!parent.opener);", &success)); | |
| 3038 EXPECT_TRUE(success); | |
| 3039 | |
| 3040 base::string16 expected_title = base::ASCIIToUTF16("msg"); | |
| 3041 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | |
| 3042 EXPECT_TRUE(ExecuteScriptAndExtractBool( | |
| 3043 popup_root->child_at(0)->current_frame_host(), | |
| 3044 "window.domAutomationController.send(postToOpenerOfParent('msg','*'));", | |
| 3045 &success)); | |
| 3046 EXPECT_TRUE(success); | |
| 3047 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | |
| 3048 } | |
| 3049 | |
| 2997 } // namespace content | 3050 } // namespace content |
| OLD | NEW |