OLD | NEW |
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 Loading... |
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 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 main_frame_routing_id = duplicate_routing_id + 1; |
217 pending_rvh->CreateNewWindow(duplicate_routing_id, | 217 int32 main_frame_widget_routing_id = duplicate_routing_id + 2; |
218 main_frame_routing_id, | 218 pending_rvh->CreateNewWindow(duplicate_routing_id, main_frame_routing_id, |
219 params, | 219 main_frame_widget_routing_id, params, |
220 session_storage.get()); | 220 session_storage.get()); |
221 | 221 |
222 // If the above operation doesn't cause a crash, the test has succeeded! | 222 // If the above operation doesn't cause a crash, the test has succeeded! |
223 } | 223 } |
224 | 224 |
225 // This is a test for crbug.com/312016. It tries to create two RenderWidgetHosts | 225 // 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 | 226 // with the same process and routing ids, which causes a collision. It is almost |
227 // identical to the AttemptDuplicateRenderViewHost test case. | 227 // identical to the AttemptDuplicateRenderViewHost test case. |
228 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, | 228 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, |
229 AttemptDuplicateRenderWidgetHost) { | 229 AttemptDuplicateRenderWidgetHost) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 427 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
428 IPC::IpcSecurityTestUtil::PwnMessageReceived( | 428 IPC::IpcSecurityTestUtil::PwnMessageReceived( |
429 web_rfh->GetProcess()->GetChannel(), | 429 web_rfh->GetProcess()->GetChannel(), |
430 ResourceHostMsg_RequestResource(web_rfh->GetRoutingID(), 1, | 430 ResourceHostMsg_RequestResource(web_rfh->GetRoutingID(), 1, |
431 invalid_scheme_origin_msg)); | 431 invalid_scheme_origin_msg)); |
432 web_process_killed.Wait(); | 432 web_process_killed.Wait(); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 } // namespace content | 436 } // namespace content |
OLD | NEW |