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

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

Issue 2814413003: Skip self-referential frame checks for POST requests. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3262 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 // This navigation shouldn't be blocked. Blocking should only occur when more 3273 // This navigation shouldn't be blocked. Blocking should only occur when more
3274 // than one ancestor has the same URL (excluding fragments), and the 3274 // than one ancestor has the same URL (excluding fragments), and the
3275 // navigating frame's current URL shouldn't count toward that. 3275 // navigating frame's current URL shouldn't count toward that.
3276 EXPECT_TRUE( 3276 EXPECT_TRUE(
3277 ExecuteScript(child, "location.href = '" + first_url.spec() + "';")); 3277 ExecuteScript(child, "location.href = '" + first_url.spec() + "';"));
3278 observer2.Wait(); 3278 observer2.Wait();
3279 3279
3280 EXPECT_EQ(child->current_url(), first_url); 3280 EXPECT_EQ(child->current_url(), first_url);
3281 } 3281 }
3282 3282
3283 // Ensures that POST requests bypass self-referential URL checks. See
3284 // https://crbug.com/710008.
3285 IN_PROC_BROWSER_TEST_F(RenderFrameHostManagerTest,
3286 SelfReferencingFramesWithPOST) {
3287 StartEmbeddedServer();
3288 GURL url(embedded_test_server()->GetURL("a.com", "/page_with_iframe.html"));
3289 EXPECT_TRUE(NavigateToURL(shell(), url));
3290
3291 WebContentsImpl* web_contents =
3292 static_cast<WebContentsImpl*>(shell()->web_contents());
3293
3294 FrameTreeNode* root = web_contents->GetFrameTree()->root();
3295 FrameTreeNode* child = root->child_at(0);
3296
3297 GURL child_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
3298 EXPECT_EQ(url, root->current_url());
3299 EXPECT_EQ(child_url, child->current_url());
3300
3301 // Navigate the child frame to the same URL as parent via POST.
3302 std::string script =
3303 "var f = document.createElement('form');\n"
3304 "f.method = 'POST';\n"
3305 "f.action = '/page_with_iframe.html';\n"
3306 "document.body.appendChild(f);\n"
3307 "f.submit();";
3308 {
3309 TestFrameNavigationObserver observer(child);
3310 EXPECT_TRUE(ExecuteScript(child, script));
3311 observer.Wait();
3312 }
3313
3314 FrameTreeNode* grandchild = child->child_at(0);
3315 EXPECT_EQ(url, child->current_url());
3316 EXPECT_EQ(child_url, grandchild->current_url());
3317
3318 // Now navigate the grandchild to the same URL as its two ancestors. This
3319 // should be allowed since it uses POST; it was blocked prior to
3320 // fixing https://crbug.com/710008.
3321 {
3322 TestFrameNavigationObserver observer(grandchild);
3323 EXPECT_TRUE(ExecuteScript(grandchild, script));
3324 observer.Wait();
3325 }
3326
3327 EXPECT_EQ(url, grandchild->current_url());
3328 ASSERT_EQ(1U, grandchild->child_count());
3329 EXPECT_EQ(child_url, grandchild->child_at(0)->current_url());
3330 }
3331
3283 } // namespace content 3332 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698