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

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

Issue 2879853002: PlzNavigate: Fix form submission to OOPIF frame. (Closed)
Patch Set: Addressed comments Nasko@ Created 3 years, 7 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 10155 matching lines...) Expand 10 before | Expand all | Expand 10 after
10166 ASSERT_EQ(1U, root->children.size()); 10166 ASSERT_EQ(1U, root->children.size());
10167 names.insert(root->children[0]->frame_entry->frame_unique_name()); 10167 names.insert(root->children[0]->frame_entry->frame_unique_name());
10168 } 10168 }
10169 10169
10170 // More than one entry in the set means that the subframe frame navigation 10170 // More than one entry in the set means that the subframe frame navigation
10171 // entries didn't have a consistent unique name. This will break history 10171 // entries didn't have a consistent unique name. This will break history
10172 // navigations =( 10172 // navigations =(
10173 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; 10173 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!";
10174 } 10174 }
10175 10175
10176 // Tests that POST body is not lost when it targets a OOPIF.
10177 // See https://crbug.com/710937.
10178 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PostTargetSubFrame) {
10179 // Navigate to a page with an OOPIF.
10180 GURL main_url(
10181 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html"));
10182 EXPECT_TRUE(NavigateToURL(shell(), main_url));
10183 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
10184 ->GetFrameTree()
10185 ->root();
10186
10187 // The main frame and the subframe live on different processes.
10188 EXPECT_EQ(1u, root->child_count());
10189 EXPECT_NE(root->current_frame_host()->GetSiteInstance(),
10190 root->child_at(0)->current_frame_host()->GetSiteInstance());
10191
10192 // Make a form submission from the main frame and target the OOPIF.
10193 GURL form_url(embedded_test_server()->GetURL("/echoall"));
10194 TestNavigationObserver form_post_observer(shell()->web_contents(), 1);
10195 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), R"(
10196 var form = document.createElement('form');
10197
10198 // POST form submission to /echoall.
10199 form.setAttribute("method", "POST");
10200 form.setAttribute("action", ")" + form_url.spec() + R"(");
10201
10202 // Target the OOPIF.
10203 form.setAttribute("target", "child-name-0");
10204
10205 // Add some POST data: "my_token=my_value";
10206 var input = document.createElement("input");
10207 input.setAttribute("type", "hidden");
10208 input.setAttribute("name", "my_token");
10209 input.setAttribute("value", "my_value");
10210 form.appendChild(input);
10211
10212 // Submit the form.
10213 document.body.appendChild(form);
10214 form.submit();
10215 )"));
10216 form_post_observer.Wait();
10217
10218 // Verify that POST body was correctly passed to the server and ended up in
10219 // the body of the page.
10220 std::string body;
10221 EXPECT_TRUE(ExecuteScriptAndExtractString(root->child_at(0), R"(
10222 var body = document.getElementsByTagName('pre')[0].innerText;
10223 window.domAutomationController.send(body);)",
10224 &body));
10225 EXPECT_EQ("my_token=my_value\n", body);
10226 }
10227
10176 } // namespace content 10228 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698