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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager_browsertest.cc

Issue 2528813002: Fix Self-Referencing OOPIF Infinite Loop (Closed)
Patch Set: actually fix broken test 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 10
(...skipping 3013 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 // With OOPIFs, this navigation used a cross-process transfer. Ensure that 3024 // With OOPIFs, this navigation used a cross-process transfer. Ensure that
3025 // the iframe's old RFH still has correct origin, even though it's pending 3025 // the iframe's old RFH still has correct origin, even though it's pending
3026 // deletion. 3026 // deletion.
3027 if (AreAllSitesIsolatedForTesting()) { 3027 if (AreAllSitesIsolatedForTesting()) {
3028 EXPECT_FALSE(child_rfh_b->is_active()); 3028 EXPECT_FALSE(child_rfh_b->is_active());
3029 EXPECT_NE(child_rfh_b, child->current_frame_host()); 3029 EXPECT_NE(child_rfh_b, child->current_frame_host());
3030 EXPECT_EQ(url::Origin(url_b), child_rfh_b->GetLastCommittedOrigin()); 3030 EXPECT_EQ(url::Origin(url_b), child_rfh_b->GetLastCommittedOrigin());
3031 } 3031 }
3032 } 3032 }
3033 3033
3034 // Ensure that loading a page with cross-site coreferencing iframes
3035 // does not cause an infinite number of nested iframes to be created.
3036 // See https://crbug.com/650332 .
alexmos 2017/01/19 23:45:53 nit: rewrap comment to 80 chars. Also no space ne
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3037 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest, CoReferencingFrames) {
3038 // Load a page with a cross-site coreferencing iframe. "Coreferencing" here
3039 // refers to two separate pages that contain subframes with URLs to each
3040 // other.
3041 StartEmbeddedServer();
3042 GURL url_1(
3043 embedded_test_server()->GetURL("a.com", "/coreferencingframe_1.html"));
3044 EXPECT_TRUE(NavigateToURL(shell(), url_1));
3045
3046 WebContentsImpl* web_contents =
3047 static_cast<WebContentsImpl*>(shell()->web_contents());
3048
3049 FrameTreeNode* root = web_contents->GetFrameTree()->root();
3050
3051 // The FrameTree contains two successful instances of each site plus an
3052 // unsuccessfully-navigated third instance of B with a blank URL. When not in
3053 // site-per-process mode, the FrameTreeVisualizer depicts all nodes as
3054 // referencing Site A because iframes are identified with their root site.
3055 if (AreAllSitesIsolatedForTesting()) {
3056 EXPECT_EQ(
3057 " Site A ------------ proxies for B\n"
3058 " +--Site B ------- proxies for A\n"
3059 " +--Site A -- proxies for B\n"
3060 " +--Site B -- proxies for A\n"
3061 " +--Site B -- proxies for A\n"
3062 "Where A = http://a.com/\n"
3063 " B = http://b.com/",
3064 FrameTreeVisualizer().DepictFrameTree(root));
3065 } else {
3066 EXPECT_EQ(
3067 " Site A\n"
3068 " +--Site A\n"
3069 " +--Site A\n"
3070 " +--Site A\n"
3071 " +--Site A\n"
3072 "Where A = http://a.com/",
3073 FrameTreeVisualizer().DepictFrameTree(root));
3074 }
3075 FrameTreeNode* bottom_child =
3076 root->child_at(0)->child_at(0)->child_at(0)->child_at(0);
3077 EXPECT_TRUE(bottom_child->current_url().is_empty());
3078 EXPECT_FALSE(bottom_child->has_committed_real_load());
3079 }
3080
3081 // Ensures that nested subframes with the same URL but different fragments can
3082 // only be nested once. See https://crbug.com/650332 .
3083 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
3084 SelfReferencingFragmentFrames) {
3085 StartEmbeddedServer();
3086 GURL url(
3087 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html#123"));
3088 EXPECT_TRUE(NavigateToURL(shell(), url));
3089
3090 WebContentsImpl* web_contents =
3091 static_cast<WebContentsImpl*>(shell()->web_contents());
3092
3093 FrameTreeNode* root = web_contents->GetFrameTree()->root();
3094 FrameTreeNode* child = root->child_at(0);
3095
3096 // ExecuteScript is used here and once more below because it is important to
3097 // use renderer-initiated navigations since browser-initiated navigations are
3098 // bypassed in the self-referencing navigation check.
3099 TestFrameNavigationObserver observer1(child);
3100 EXPECT_TRUE(
3101 ExecuteScript(child, "location.href = '" + url.spec() + "456" + "';"));
3102 observer1.Wait();
3103
3104 FrameTreeNode* grandchild = child->child_at(0);
3105
alexmos 2017/01/19 23:45:54 I'd suggest moving up the definition of |expected_
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3106 // This navigation should be blocked.
3107 GURL stalled_url(embedded_test_server()->GetURL(
3108 "a.com", "/page_with_iframe.html#123456789"));
3109 TestNavigationManager delayer(web_contents, stalled_url);
alexmos 2017/01/19 23:45:54 Let's not call this "delayer", as we aren't actual
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3110 EXPECT_TRUE(ExecuteScript(grandchild,
3111 "location.href = '" + stalled_url.spec() + "';"));
3112 EXPECT_FALSE(delayer.WaitForRequestStart());
alexmos 2017/01/19 23:45:54 I'd suggest to add a comment to explain this a bit
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3113 WaitForLoadStop(web_contents);
3114
3115 // The FrameTree contains two successful instances of the url plus an
3116 // unsuccessfully-navigated third instance with a blank URL.
3117 EXPECT_EQ(
3118 " Site A\n"
3119 " +--Site A\n"
3120 " +--Site A\n"
3121 "Where A = http://a.com/",
3122 FrameTreeVisualizer().DepictFrameTree(root));
3123
3124 GURL expected_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
3125 EXPECT_EQ(expected_url, grandchild->current_url());
3126 }
3127
3128 // Ensure that loading a page with a meta refresh iframe does not cause an
3129 // infinite number of nested iframes to be created. This test loads a page with
3130 // an about:blank iframe which injects html containing a meta refresh into the
alexmos 2017/01/19 23:45:54 nit: s/which/where the page/ (it's the page injec
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3131 // iframe. This test then checks that this does not cause infinite nested
3132 // iframes to be created. See https://crbug.com/527367 .
3133 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
3134 SelfReferencingMetaRefreshFrames) {
3135 // Load a page with a blank iframe.
3136 StartEmbeddedServer();
3137 GURL url_1(embedded_test_server()->GetURL(
3138 "a.com", "/page_with_meta_refresh_frame.html"));
3139 // TODO(davidsac): add in an expect true here for something?
alexmos 2017/01/19 23:45:53 There isn't a good way to expect anything from tha
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3140 NavigateToURLBlockUntilNavigationsComplete(shell(), url_1, 3);
3141
3142 WebContentsImpl* web_contents =
3143 static_cast<WebContentsImpl*>(shell()->web_contents());
3144
3145 FrameTreeNode* root = web_contents->GetFrameTree()->root();
3146
3147 // The third navigation should fail and be cancelled, leaving a FrameTree with
3148 // a height of 2.
3149 EXPECT_EQ(
3150 " Site A\n"
3151 " +--Site A\n"
3152 " +--Site A\n"
3153 "Where A = http://a.com/",
3154 FrameTreeVisualizer().DepictFrameTree(root));
3155
3156 EXPECT_EQ(GURL(url::kAboutBlankURL),
3157 root->child_at(0)->child_at(0)->current_url());
3158
3159 EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load());
3160 }
3161
3162 // Ensure that navigating a subframe to the same url as its parent twice in a
alexmos 2017/01/19 23:45:54 nit: s/url/URL/
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3163 // row is not blocked by the self-reference check.
3164 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
3165 SelfReferencingSameURLRenavigation) {
3166 StartEmbeddedServer();
3167 GURL url(embedded_test_server()->GetURL("a.com", "/page_with_iframe.html"));
3168 EXPECT_TRUE(NavigateToURL(shell(), url));
3169
3170 WebContentsImpl* web_contents =
3171 static_cast<WebContentsImpl*>(shell()->web_contents());
3172
3173 FrameTreeNode* root = web_contents->GetFrameTree()->root();
3174 FrameTreeNode* child = root->child_at(0);
3175
3176 TestFrameNavigationObserver observer1(child);
alexmos 2017/01/19 23:45:53 I'd suggest defining url_expected here, perhaps as
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3177 EXPECT_TRUE(
3178 ExecuteScript(child, "location.href = '" + url.spec() + "#123';"));
3179 observer1.Wait();
3180
3181 EXPECT_EQ(
3182 " Site A\n"
3183 " +--Site A\n"
3184 " +--Site A\n"
3185 "Where A = http://a.com/",
3186 FrameTreeVisualizer().DepictFrameTree(root));
3187
3188 GURL url_expected(
3189 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html#123"));
3190 EXPECT_EQ(child->current_url(), url_expected);
3191
3192 TestFrameNavigationObserver observer2(child);
alexmos 2017/01/19 23:45:53 Perhaps add a comment that this navigation shouldn
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Done.
3193 EXPECT_TRUE(ExecuteScript(child, "location.href = '" + url.spec() + "';"));
3194 observer2.Wait();
3195
3196 // The FrameTree doesn't change between both loads.
3197 EXPECT_EQ(
3198 " Site A\n"
3199 " +--Site A\n"
3200 " +--Site A\n"
3201 "Where A = http://a.com/",
3202 FrameTreeVisualizer().DepictFrameTree(root));
alexmos 2017/01/19 23:45:53 I feel like the DepictFrameTree checks in this tes
davidsac (gone - try alexmos) 2017/01/24 01:16:38 Good point! Done.
3203
3204 EXPECT_EQ(child->current_url(), url);
3205 }
3206
3034 } // namespace content 3207 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698