Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1309043003: Handle frame openers in the same FrameTree when navigating subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@opener-cycle-detection
Patch Set: Add comment for the DCHECK Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 3031
3032 success = false; 3032 success = false;
3033 EXPECT_TRUE(ExecuteScriptAndExtractBool( 3033 EXPECT_TRUE(ExecuteScriptAndExtractBool(
3034 popup_root->child_at(1)->current_frame_host(), 3034 popup_root->child_at(1)->current_frame_host(),
3035 "window.domAutomationController.send(" 3035 "window.domAutomationController.send("
3036 " window.opener === window.opener.parent.frames['frame1']);", 3036 " window.opener === window.opener.parent.frames['frame1']);",
3037 &success)); 3037 &success));
3038 EXPECT_TRUE(success); 3038 EXPECT_TRUE(success);
3039 } 3039 }
3040 3040
3041 // Check that when a subframe navigates to a new SiteInstance, the new
3042 // SiteInstance will get a proxy for the opener of subframe's parent. I.e.,
3043 // accessing parent.opener from the subframe should still work after a
3044 // cross-process navigation.
3045 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3046 NavigatingSubframePreservesOpenerInParent) {
3047 GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html");
3048 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3049
3050 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
3051 ->GetFrameTree()
3052 ->root();
3053
3054 // Open a popup with a cross-site page that has a subframe.
3055 GURL popup_url(embedded_test_server()->GetURL(
3056 "b.com", "/cross_site_iframe_factory.html?b(b)"));
3057 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup");
3058 EXPECT_TRUE(popup_shell);
3059 FrameTreeNode* popup_root =
3060 static_cast<WebContentsImpl*>(popup_shell->web_contents())
3061 ->GetFrameTree()
3062 ->root();
3063 EXPECT_EQ(1U, popup_root->child_count());
3064
3065 // Check that the popup's opener is correct in the browser process.
3066 EXPECT_EQ(root, popup_root->opener());
3067
3068 // Navigate popup's subframe to another site.
3069 GURL frame_url(embedded_test_server()->GetURL("c.com", "/post_message.html"));
3070 NavigateFrameToURL(popup_root->child_at(0), frame_url);
3071 EXPECT_TRUE(
3072 WaitForRenderFrameReady(popup_root->child_at(0)->current_frame_host()));
3073
3074 // Check that the new subframe process still sees correct opener for its
3075 // parent by sending a postMessage to subframe's parent.opener.
3076 bool success = false;
3077 EXPECT_TRUE(ExecuteScriptAndExtractBool(
3078 popup_root->child_at(0)->current_frame_host(),
3079 "window.domAutomationController.send(!!parent.opener);", &success));
3080 EXPECT_TRUE(success);
3081
3082 base::string16 expected_title = base::ASCIIToUTF16("msg");
3083 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
3084 EXPECT_TRUE(ExecuteScriptAndExtractBool(
3085 popup_root->child_at(0)->current_frame_host(),
3086 "window.domAutomationController.send(postToOpenerOfParent('msg','*'));",
3087 &success));
3088 EXPECT_TRUE(success);
3089 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
3090 }
3091
3041 } // namespace content 3092 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_proxy_host.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698