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

Unified Diff: content/browser/frame_host/frame_tree_browsertest.cc

Issue 1086283002: Track frame openers in FrameTreeNodes instead of WebContents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Second round of feedback Created 5 years, 6 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/frame_host/frame_tree_browsertest.cc
diff --git a/content/browser/frame_host/frame_tree_browsertest.cc b/content/browser/frame_host/frame_tree_browsertest.cc
index c013d6a41c53b2960f5eda3415a0e0a1c2f5dd89..7b37ccfbbc7e3303c395cd0b999854bd1868fcf2 100644
--- a/content/browser/frame_host/frame_tree_browsertest.cc
+++ b/content/browser/frame_host/frame_tree_browsertest.cc
@@ -283,6 +283,37 @@ IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, SandboxFlagsSetForChildFrames) {
blink::WebSandboxFlags::All);
}
+// Ensure that a popup opened from a subframe sets its opener to the subframe's
+// FrameTreeNode, and that the opener is cleared if the subframe is destroyed.
+IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, SubframeOpenerSetForNewWindow) {
+ GURL main_url(embedded_test_server()->GetURL("/frame_tree/top.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), main_url));
+
+ // It is safe to obtain the root frame tree node here, as it doesn't change.
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
+ ->GetFrameTree()
+ ->root();
+
+ // Open a new window from a subframe.
+ ShellAddedObserver new_shell_observer;
+ GURL popup_url(embedded_test_server()->GetURL("foo.com", "/title1.html"));
+ EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(),
+ "window.open('" + popup_url.spec() + "');"));
+ Shell* new_shell = new_shell_observer.GetShell();
+ WebContents* new_contents = new_shell->web_contents();
+ WaitForLoadStop(new_contents);
+
+ // Check that the new window's opener points to the correct subframe on
+ // original window.
+ FrameTreeNode* popup_root =
+ static_cast<WebContentsImpl*>(new_contents)->GetFrameTree()->root();
+ EXPECT_EQ(root->child_at(0), popup_root->opener());
+
+ // Close the original window. This should clear the new window's opener.
+ shell()->Close();
+ EXPECT_EQ(nullptr, popup_root->opener());
+}
+
class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest {
public:
CrossProcessFrameTreeBrowserTest() {}
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.cc ('k') | content/browser/frame_host/frame_tree_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698