OLD | NEW |
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 10066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10077 ASSERT_EQ(1U, root->children.size()); | 10077 ASSERT_EQ(1U, root->children.size()); |
10078 names.insert(root->children[0]->frame_entry->frame_unique_name()); | 10078 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
10079 } | 10079 } |
10080 | 10080 |
10081 // More than one entry in the set means that the subframe frame navigation | 10081 // More than one entry in the set means that the subframe frame navigation |
10082 // entries didn't have a consistent unique name. This will break history | 10082 // entries didn't have a consistent unique name. This will break history |
10083 // navigations =( | 10083 // navigations =( |
10084 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 10084 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
10085 } | 10085 } |
10086 | 10086 |
| 10087 // Tests that POST body is not lost when it targets a OOPIF. |
| 10088 // See https://crbug.com/710937. |
| 10089 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PostTargetSubFrame) { |
| 10090 // Navigate to a page with an OOPIF. |
| 10091 GURL main_url( |
| 10092 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); |
| 10093 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 10094 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 10095 ->GetFrameTree() |
| 10096 ->root(); |
| 10097 |
| 10098 // The main frame and the subframe live on different processes. |
| 10099 EXPECT_EQ(1u, root->child_count()); |
| 10100 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), |
| 10101 root->child_at(0)->current_frame_host()->GetSiteInstance()); |
| 10102 |
| 10103 // Make a form submission from the main frame and target the OOPIF. |
| 10104 GURL form_url(embedded_test_server()->GetURL("/echoall")); |
| 10105 TestNavigationObserver form_post_observer(shell()->web_contents(), 1); |
| 10106 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), R"( |
| 10107 var form = document.createElement('form'); |
| 10108 |
| 10109 // POST form submission to /echoall. |
| 10110 form.setAttribute("method", "POST"); |
| 10111 form.setAttribute("action", ")" + form_url.spec() + R"("); |
| 10112 |
| 10113 // Target the OOPIF. |
| 10114 form.setAttribute("target", "child-name-0"); |
| 10115 |
| 10116 // Add some POST data: "my_token=my_value"; |
| 10117 var input = document.createElement("input"); |
| 10118 input.setAttribute("type", "hidden"); |
| 10119 input.setAttribute("name", "my_token"); |
| 10120 input.setAttribute("value", "my_value"); |
| 10121 form.appendChild(input); |
| 10122 |
| 10123 // Submit the form. |
| 10124 document.body.appendChild(form); |
| 10125 form.submit(); |
| 10126 )")); |
| 10127 form_post_observer.Wait(); |
| 10128 |
| 10129 NavigationEntryImpl* entry = static_cast<NavigationEntryImpl*>( |
| 10130 shell()->web_contents()->GetController().GetLastCommittedEntry()); |
| 10131 // TODO(arthursonzogni): This is wrong. The last committed entry was |
| 10132 // renderer-initiated. See https://crbug.com/722251. |
| 10133 EXPECT_FALSE(entry->is_renderer_initiated()); |
| 10134 |
| 10135 // Verify that POST body was correctly passed to the server and ended up in |
| 10136 // the body of the page. |
| 10137 std::string body; |
| 10138 EXPECT_TRUE(ExecuteScriptAndExtractString(root->child_at(0), R"( |
| 10139 var body = document.getElementsByTagName('pre')[0].innerText; |
| 10140 window.domAutomationController.send(body);)", |
| 10141 &body)); |
| 10142 EXPECT_EQ("my_token=my_value\n", body); |
| 10143 } |
| 10144 |
10087 } // namespace content | 10145 } // namespace content |
OLD | NEW |