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

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

Issue 2528813002: Fix Self-Referencing OOPIF Infinite Loop (Closed)
Patch Set: Add |state_| change in |WillStartRequest| and |WillRedirectRequest| Created 3 years, 11 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/render_frame_host_manager_browsertest.cc
diff --git a/content/browser/frame_host/render_frame_host_manager_browsertest.cc b/content/browser/frame_host/render_frame_host_manager_browsertest.cc
index f30d331b88ced2fe98878bbaad2bd1404257f4ab..abcb56f601cd169395f3fcde99d906f340fd8bb0 100644
--- a/content/browser/frame_host/render_frame_host_manager_browsertest.cc
+++ b/content/browser/frame_host/render_frame_host_manager_browsertest.cc
@@ -3030,4 +3030,170 @@ IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, LastCommittedOrigin) {
}
}
+// Ensure that loading a page with a cross-site coreferencing iframe
alexmos 2017/01/06 02:27:29 nit: s/a cross-site coreferencing iframe/cross-sit
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+// does not cause an infinite number of nested iframes to be created.
+// TODO(davidsac): This test should be broken until issue 527367 is resolved.
alexmos 2017/01/06 02:27:29 I think we can also remove the TODO, right? I don
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, CoReferencingFrames) {
+ // Load a page with a cross-site coreferencing iframe.
alexmos 2017/01/06 02:27:29 Perhaps add a comment here to clarify what "corefe
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+ StartEmbeddedServer();
+ GURL url_1(
+ embedded_test_server()->GetURL("a.com", "/coreferencingframe_1.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), url_1));
+
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+
+ FrameTreeNode* root = web_contents->GetFrameTree()->root();
+
+ // The FrameTree contains two successful instances of each site plus an
+ // unsuccessfully-navigated third instance of B with a blank URL. The
alexmos 2017/01/06 02:27:29 nit: I'd move "when outside of site-per-process mo
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+ // FrameTreeVisualizer depicts all nodes as referencing Site A because iframes
+ // are identified with their root site when outside of site-per-process mode.
+ if (AreAllSitesIsolatedForTesting()) {
+ EXPECT_EQ(
+ " Site A ------------ proxies for B\n"
+ " +--Site B ------- proxies for A\n"
+ " +--Site A -- proxies for B\n"
+ " +--Site B -- proxies for A\n"
+ " +--Site B -- proxies for A\n"
+ "Where A = http://a.com/\n"
+ " B = http://b.com/",
+ FrameTreeVisualizer().DepictFrameTree(root));
+ } else {
+ EXPECT_EQ(
+ " Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ "Where A = http://a.com/",
+ FrameTreeVisualizer().DepictFrameTree(root));
+ }
+
+ EXPECT_TRUE(root->child_at(0)
alexmos 2017/01/06 02:27:29 You could declare "FrameTreeNode* bottom_child = r
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+ ->child_at(0)
+ ->child_at(0)
+ ->child_at(0)
+ ->current_url()
+ .is_empty());
+
+ EXPECT_FALSE(root->child_at(0)
+ ->child_at(0)
+ ->child_at(0)
+ ->child_at(0)
+ ->has_committed_real_load());
+}
+
+// Ensure that loading a page with fragments
alexmos 2017/01/06 02:27:29 Finish the comment to explain what the test is doi
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+// TODO(davidsac): This test should be broken until issue 527367 is resolved.
+IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
+ SelfReferencingFragmentFrames) {
+ StartEmbeddedServer();
+ GURL url(embedded_test_server()->GetURL("a.com", "/iframe.html#123"));
+ EXPECT_TRUE(NavigateToURL(shell(), url));
+
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+
+ FrameTreeNode* root = web_contents->GetFrameTree()->root();
+ FrameTreeNode* child = root->child_at(0);
+
+ TestFrameNavigationObserver observer1(child);
alexmos 2017/01/06 02:27:29 Let's add a comment that it's important to use ren
davidsac (gone - try alexmos) 2017/01/19 18:26:23 Done.
+ EXPECT_TRUE(
+ ExecuteScript(child, "location.href = '" + url.spec() + "456" + "';"));
+ observer1.Wait();
+
+ FrameTreeNode* grandchild = child->child_at(0);
+
+ TestFrameNavigationObserver observer2(grandchild);
alexmos 2017/01/06 02:27:29 Add a comment that this navigation should be block
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+ EXPECT_TRUE(ExecuteScript(
+ grandchild, "location.href = '" + url.spec() + "456789" + "';"));
+ observer2.Wait();
+
+ // The FrameTree contains two successful instances of the url plus an
+ // unsuccessfully-navigated third instance with a blank URL.
+ EXPECT_EQ(
+ " Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ "Where A = http://a.com/",
+ FrameTreeVisualizer().DepictFrameTree(root));
+
alexmos 2017/01/06 02:27:29 Can you include an EXPECT_EQ() for the grandchild'
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+ EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load());
+}
+
+// Ensure that loading a page with a meta refresh iframe
alexmos 2017/01/06 02:27:29 nit: rewrap comment to 80 lines. Your editor shou
davidsac (gone - try alexmos) 2017/01/19 18:26:24 Done.
+// does not cause an infinite number of nested iframes to be created.
+// TODO(davidsac): This test should be broken until issue 527367 is resolved.
alexmos 2017/01/06 02:27:29 Instead of TODO, just reference https://crbug.com/
davidsac (gone - try alexmos) 2017/01/19 18:26:23 Done.
+IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, MetaRefreshFrames) {
alexmos 2017/01/06 02:27:29 Perhaps add "SelfReferencing" prefix to the test n
davidsac (gone - try alexmos) 2017/01/19 18:26:23 Done.
+ // Load a page with a cross-site coreferencing iframe.
+ StartEmbeddedServer();
+ GURL url_1(embedded_test_server()->GetURL(
+ "a.com", "/page_with_meta_refresh_frame.html"));
+ // TODO(davidsac): add in an expect true here for something?
+ NavigateToURLBlockUntilNavigationsComplete(shell(), url_1, 3);
+
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+
+ FrameTreeNode* root = web_contents->GetFrameTree()->root();
+
+ // The third navigation should fail and be cancelled, leaving a FrameTree with
+ // a height of 2.
+ EXPECT_EQ(
+ " Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ "Where A = http://a.com/",
+ FrameTreeVisualizer().DepictFrameTree(root));
+
+ EXPECT_FALSE(root->child_at(0)->current_url().is_empty());
alexmos 2017/01/06 02:27:29 Instead of this, can we check that current_url() i
davidsac (gone - try alexmos) 2017/01/19 18:26:23 Done.
+
+ EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load());
+}
+
+// Ensure that navigating a subframe to the same url as its parent twice in a
+// row is not blocked by the self-reference check.
+IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, SameOriginRenavigation) {
+ StartEmbeddedServer();
+ GURL url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), url));
+
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+
+ FrameTreeNode* root = web_contents->GetFrameTree()->root();
+ FrameTreeNode* child = root->child_at(0);
+
+ TestFrameNavigationObserver observer1(child);
+ EXPECT_TRUE(
+ ExecuteScript(child, "location.href = '" + url.spec() + "#123';"));
+ observer1.Wait();
+
+ EXPECT_EQ(
+ " Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ "Where A = http://a.com/",
+ FrameTreeVisualizer().DepictFrameTree(root));
+
+ GURL url_expected(
+ embedded_test_server()->GetURL("a.com", "/iframe.html#123"));
+ EXPECT_EQ(child->current_url(), url_expected);
+
+ TestFrameNavigationObserver observer2(child);
alexmos 2017/01/06 02:27:29 This setup is very similar to the test in SelfRefe
davidsac (gone - try alexmos) 2017/01/19 18:26:24 I feel like that would make it a bit confusing wha
alexmos 2017/01/19 23:45:53 Acknowledged.
+ EXPECT_TRUE(ExecuteScript(child, "location.href = '" + url.spec() + "';"));
+ observer2.Wait();
+
+ // The FrameTree doesn't change between both loads.
+ EXPECT_EQ(
+ " Site A\n"
+ " +--Site A\n"
+ " +--Site A\n"
+ "Where A = http://a.com/",
+ FrameTreeVisualizer().DepictFrameTree(root));
+
+ EXPECT_EQ(child->current_url(), url);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698