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

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

Issue 1224363002: OOPIF: Fix window.open to work from frames with remote parent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove internal:: from ToRenderFrameHost Created 5 years, 5 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 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 " Site A\n" 2708 " Site A\n"
2709 " |--Site A\n" 2709 " |--Site A\n"
2710 " +--Site A\n" 2710 " +--Site A\n"
2711 " |--Site A\n" 2711 " |--Site A\n"
2712 " +--Site A\n" 2712 " +--Site A\n"
2713 " +--Site A\n" 2713 " +--Site A\n"
2714 "Where A = http://127.0.0.1/", 2714 "Where A = http://127.0.0.1/",
2715 DepictFrameTree(root)); 2715 DepictFrameTree(root));
2716 } 2716 }
2717 2717
2718 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenPopupWithRemoteParent) {
2719 GURL main_url(
2720 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html"));
2721 NavigateToURL(shell(), main_url);
2722
2723 // It is safe to obtain the root frame tree node here, as it doesn't change.
2724 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
2725 ->GetFrameTree()
2726 ->root();
2727
2728 // Navigate first child cross-site.
2729 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
2730 NavigateFrameToURL(root->child_at(0), frame_url);
2731
2732 // Open a popup from the first child.
2733 Shell* new_shell = OpenPopup(root->child_at(0)->current_frame_host(),
2734 GURL(url::kAboutBlankURL), "");
2735 EXPECT_TRUE(new_shell);
2736
2737 // Check that the popup's opener is correct on both the browser and renderer
2738 // sides.
2739 FrameTreeNode* popup_root =
2740 static_cast<WebContentsImpl*>(new_shell->web_contents())
2741 ->GetFrameTree()
2742 ->root();
2743 EXPECT_EQ(root->child_at(0), popup_root->opener());
2744
2745 std::string opener_url;
2746 EXPECT_TRUE(ExecuteScriptAndExtractString(
2747 popup_root->current_frame_host(),
2748 "window.domAutomationController.send(window.opener.location.href);",
2749 &opener_url));
2750 EXPECT_EQ(frame_url.spec(), opener_url);
2751
2752 // Now try the same with a cross-site popup and make sure it ends up in a new
2753 // process and with a correct opener.
2754 GURL popup_url(embedded_test_server()->GetURL("c.com", "/title2.html"));
2755 Shell* cross_site_popup =
2756 OpenPopup(root->child_at(0)->current_frame_host(), popup_url, "");
2757 EXPECT_TRUE(cross_site_popup);
2758
2759 FrameTreeNode* cross_site_popup_root =
2760 static_cast<WebContentsImpl*>(cross_site_popup->web_contents())
2761 ->GetFrameTree()
2762 ->root();
2763 EXPECT_EQ(cross_site_popup_root->current_url(), popup_url);
2764
2765 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
2766 cross_site_popup->web_contents()->GetSiteInstance());
2767 EXPECT_NE(root->child_at(0)->current_frame_host()->GetSiteInstance(),
2768 cross_site_popup->web_contents()->GetSiteInstance());
2769
2770 EXPECT_EQ(root->child_at(0), cross_site_popup_root->opener());
2771
2772 // Ensure the popup's window.opener points to the right subframe. Note that
2773 // we can't check the opener's location as above since it's cross-origin.
2774 bool success = false;
2775 EXPECT_TRUE(ExecuteScriptAndExtractBool(
2776 cross_site_popup_root->current_frame_host(),
2777 "window.domAutomationController.send("
2778 " window.opener === window.opener.top.frames[0]);",
2779 &success));
2780 EXPECT_TRUE(success);
2781 }
2782
2718 } // namespace content 2783 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698