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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index 7eb719a891a224ba59e65602d6bf22499005e977..786321bd57bcdb9720de2c4d56a915e12a397223 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -3038,4 +3038,55 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, UpdateSubframeOpener) {
EXPECT_TRUE(success);
}
+// Check that when a subframe navigates to a new SiteInstance, the new
+// SiteInstance will get a proxy for the opener of subframe's parent. I.e.,
+// accessing parent.opener from the subframe should still work after a
+// cross-process navigation.
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
+ NavigatingSubframePreservesOpenerInParent) {
+ GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html");
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+
+ // Open a popup with a cross-site page that has a subframe.
+ GURL popup_url(embedded_test_server()->GetURL(
+ "b.com", "/cross_site_iframe_factory.html?b(b)"));
+ Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup");
+ EXPECT_TRUE(popup_shell);
+ FrameTreeNode* popup_root =
+ static_cast<WebContentsImpl*>(popup_shell->web_contents())
+ ->GetFrameTree()
+ ->root();
+ EXPECT_EQ(1U, popup_root->child_count());
+
+ // Check that the popup's opener is correct in the browser process.
+ EXPECT_EQ(root, popup_root->opener());
+
+ // Navigate popup's subframe to another site.
+ GURL frame_url(embedded_test_server()->GetURL("c.com", "/post_message.html"));
+ NavigateFrameToURL(popup_root->child_at(0), frame_url);
+ EXPECT_TRUE(
+ WaitForRenderFrameReady(popup_root->child_at(0)->current_frame_host()));
+
+ // Check that the new subframe process still sees correct opener for its
+ // parent by sending a postMessage to subframe's parent.opener.
+ bool success = false;
+ EXPECT_TRUE(ExecuteScriptAndExtractBool(
+ popup_root->child_at(0)->current_frame_host(),
+ "window.domAutomationController.send(!!parent.opener);", &success));
+ EXPECT_TRUE(success);
+
+ base::string16 expected_title = base::ASCIIToUTF16("msg");
+ TitleWatcher title_watcher(shell()->web_contents(), expected_title);
+ EXPECT_TRUE(ExecuteScriptAndExtractBool(
+ popup_root->child_at(0)->current_frame_host(),
+ "window.domAutomationController.send(postToOpenerOfParent('msg','*'));",
+ &success));
+ EXPECT_TRUE(success);
+ EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
+}
+
} // namespace content
« 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