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

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

Issue 1303773002: Give the main frame a RenderWidget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge conflicts Created 5 years, 2 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/containers/hash_tables.h" 6 #include "base/containers/hash_tables.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" 8 #include "content/browser/dom_storage/dom_storage_context_wrapper.h"
9 #include "content/browser/dom_storage/session_storage_namespace_impl.h" 9 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
10 #include "content/browser/frame_host/navigator.h" 10 #include "content/browser/frame_host/navigator.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 terminated.Wait(); 189 terminated.Wait();
190 } 190 }
191 191
192 // This is a test for crbug.com/312016 attempting to create duplicate 192 // This is a test for crbug.com/312016 attempting to create duplicate
193 // RenderViewHosts. SetupForDuplicateHosts sets up this test case and leaves 193 // RenderViewHosts. SetupForDuplicateHosts sets up this test case and leaves
194 // it in a state with pending RenderViewHost. Before the commit of the new 194 // it in a state with pending RenderViewHost. Before the commit of the new
195 // pending RenderViewHost, this test case creates a new window through the new 195 // pending RenderViewHost, this test case creates a new window through the new
196 // process. 196 // process.
197 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, 197 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest,
198 AttemptDuplicateRenderViewHost) { 198 AttemptDuplicateRenderViewHost) {
199 int duplicate_routing_id = MSG_ROUTING_NONE; 199 int32_t duplicate_routing_id = MSG_ROUTING_NONE;
200 RenderViewHostImpl* pending_rvh = 200 RenderViewHostImpl* pending_rvh =
201 PrepareToDuplicateHosts(shell(), &duplicate_routing_id); 201 PrepareToDuplicateHosts(shell(), &duplicate_routing_id);
202 EXPECT_NE(MSG_ROUTING_NONE, duplicate_routing_id); 202 EXPECT_NE(MSG_ROUTING_NONE, duplicate_routing_id);
203 203
204 // Since this test executes on the UI thread and hopping threads might cause 204 // Since this test executes on the UI thread and hopping threads might cause
205 // different timing in the test, let's simulate a CreateNewWindow call coming 205 // different timing in the test, let's simulate a CreateNewWindow call coming
206 // from the IO thread. 206 // from the IO thread.
207 ViewHostMsg_CreateWindow_Params params; 207 ViewHostMsg_CreateWindow_Params params;
208 DOMStorageContextWrapper* dom_storage_context = 208 DOMStorageContextWrapper* dom_storage_context =
209 static_cast<DOMStorageContextWrapper*>( 209 static_cast<DOMStorageContextWrapper*>(
210 BrowserContext::GetStoragePartition( 210 BrowserContext::GetStoragePartition(
211 shell()->web_contents()->GetBrowserContext(), 211 shell()->web_contents()->GetBrowserContext(),
212 pending_rvh->GetSiteInstance())->GetDOMStorageContext()); 212 pending_rvh->GetSiteInstance())->GetDOMStorageContext());
213 scoped_refptr<SessionStorageNamespaceImpl> session_storage( 213 scoped_refptr<SessionStorageNamespaceImpl> session_storage(
214 new SessionStorageNamespaceImpl(dom_storage_context)); 214 new SessionStorageNamespaceImpl(dom_storage_context));
215 // Cause a deliberate collision in routing ids. 215 // Cause a deliberate collision in routing ids.
216 int main_frame_routing_id = duplicate_routing_id + 1; 216 int32_t main_frame_routing_id = duplicate_routing_id + 1;
217 pending_rvh->CreateNewWindow(duplicate_routing_id, 217 // TODO(avi): This should be made unique from the view routing ID once
218 main_frame_routing_id, 218 // RenderViewHostImpl has-a RenderWidgetHostImpl. https://crbug.com/545684
219 params, 219 int32_t main_frame_widget_routing_id = duplicate_routing_id;
220 pending_rvh->CreateNewWindow(duplicate_routing_id, main_frame_routing_id,
221 main_frame_widget_routing_id, params,
220 session_storage.get()); 222 session_storage.get());
221 223
222 // If the above operation doesn't cause a crash, the test has succeeded! 224 // If the above operation doesn't cause a crash, the test has succeeded!
223 } 225 }
224 226
225 // This is a test for crbug.com/312016. It tries to create two RenderWidgetHosts 227 // This is a test for crbug.com/312016. It tries to create two RenderWidgetHosts
226 // with the same process and routing ids, which causes a collision. It is almost 228 // with the same process and routing ids, which causes a collision. It is almost
227 // identical to the AttemptDuplicateRenderViewHost test case. 229 // identical to the AttemptDuplicateRenderViewHost test case.
228 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, 230 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest,
229 AttemptDuplicateRenderWidgetHost) { 231 AttemptDuplicateRenderWidgetHost) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 429 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
428 IPC::IpcSecurityTestUtil::PwnMessageReceived( 430 IPC::IpcSecurityTestUtil::PwnMessageReceived(
429 web_rfh->GetProcess()->GetChannel(), 431 web_rfh->GetProcess()->GetChannel(),
430 ResourceHostMsg_RequestResource(web_rfh->GetRoutingID(), 1, 432 ResourceHostMsg_RequestResource(web_rfh->GetRoutingID(), 1,
431 invalid_scheme_origin_msg)); 433 invalid_scheme_origin_msg));
432 web_process_killed.Wait(); 434 web_process_killed.Wait();
433 } 435 }
434 } 436 }
435 437
436 } // namespace content 438 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698