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

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

Issue 1738233002: Disallow was_within_same_page = true for a cross-process navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix is_navigation_within_page Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 converted_instance_1->GetSiteURL()); 1139 converted_instance_1->GetSiteURL());
1140 1140
1141 SiteInstance* converted_instance_2 = 1141 SiteInstance* converted_instance_2 =
1142 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get()); 1142 ConvertToSiteInstance(rfhm, descriptor, unrelated_instance.get());
1143 // Should return |unrelated_instance| because its site matches and it is 1143 // Should return |unrelated_instance| because its site matches and it is
1144 // unrelated to the current SiteInstance. 1144 // unrelated to the current SiteInstance.
1145 EXPECT_EQ(unrelated_instance.get(), converted_instance_2); 1145 EXPECT_EQ(unrelated_instance.get(), converted_instance_2);
1146 } 1146 }
1147 } 1147 }
1148 1148
1149 namespace {
1150 void SetWithinPage(const GURL& url,
1151 FrameHostMsg_DidCommitProvisionalLoad_Params* params) {
1152 params->was_within_same_page = true;
1153 params->url = url;
1154 }
1155 }
1156
1157 // A renderer might try and claim that a cross site navigation was within
1158 // the same page by setting was_within_same_page = true for
1159 // FrameHostMsg_DidCommitProvisionalLoad. Such case should be detected
1160 // on the browser side and the renderer should be killed.
nasko 2016/03/01 00:27:01 nit: s/renderer/renderer process/ in first and las
gzobqq 2016/03/01 08:31:42 Done.
1161 TEST_F(NavigatorTestWithBrowserSideNavigation, CrossSiteClaimWithinPage) {
1162 const GURL kUrl1("http://www.chromium.org/");
1163 const GURL kUrl2("http://www.google.com/");
1164
1165 contents()->NavigateAndCommit(kUrl1);
1166 FrameTreeNode* node = main_test_rfh()->frame_tree_node();
1167
1168 // Navigate to a different site.
1169 int entry_id = RequestNavigation(node, kUrl2);
1170 NavigationRequest* main_request = node->navigation_request();
1171 TestRenderFrameHost* speculative_rfh = GetSpeculativeRenderFrameHost(node);
1172
1173 // Receive the beforeUnload ACK.
1174 main_test_rfh()->SendBeforeUnloadACK(true);
nasko 2016/03/01 00:27:01 Why not call PrepareForCommit? It should abstract
gzobqq 2016/03/01 08:31:42 That's nice, done.
1175
1176 scoped_refptr<ResourceResponse> response(new ResourceResponse);
1177 GetLoaderForNavigationRequest(main_request)
1178 ->CallOnResponseStarted(response, MakeEmptyStream());
1179
1180 // Claim that the navigation was within same page.
1181 int bad_msg_count = process()->bad_msg_count();
nasko 2016/03/01 00:27:01 Is process() the right one to use? Shouldn't the b
gzobqq 2016/03/01 08:31:42 process() should be good, it has logic to select t
1182 speculative_rfh->SendNavigateWithModificationCallback(
1183 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1));
1184 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1);
1185 }
1186
1149 } // namespace content 1187 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698