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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "content/browser/bad_message.h" | 12 #include "content/browser/bad_message.h" |
13 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 13 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
14 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 14 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
16 #include "content/browser/frame_host/render_frame_host_impl.h" | 16 #include "content/browser/frame_host/render_frame_host_impl.h" |
17 #include "content/browser/renderer_host/render_view_host_factory.h" | 17 #include "content/browser/renderer_host/render_view_host_factory.h" |
18 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
19 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
| 20 #include "content/common/frame.mojom.h" |
20 #include "content/common/frame_messages.h" | 21 #include "content/common/frame_messages.h" |
21 #include "content/common/render_message_filter.mojom.h" | 22 #include "content/common/render_message_filter.mojom.h" |
22 #include "content/common/resource_messages.h" | 23 #include "content/common/resource_messages.h" |
23 #include "content/common/resource_request.h" | 24 #include "content/common/resource_request.h" |
24 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
25 #include "content/public/browser/browser_context.h" | 26 #include "content/public/browser/browser_context.h" |
26 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
27 #include "content/public/browser/interstitial_page.h" | 28 #include "content/public/browser/interstitial_page.h" |
28 #include "content/public/browser/interstitial_page_delegate.h" | 29 #include "content/public/browser/interstitial_page_delegate.h" |
29 #include "content/public/browser/resource_context.h" | 30 #include "content/public/browser/resource_context.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // it in a state with pending RenderViewHost. Before the commit of the new | 259 // it in a state with pending RenderViewHost. Before the commit of the new |
259 // pending RenderViewHost, this test case creates a new window through the new | 260 // pending RenderViewHost, this test case creates a new window through the new |
260 // process. | 261 // process. |
261 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, | 262 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, |
262 AttemptDuplicateRenderViewHost) { | 263 AttemptDuplicateRenderViewHost) { |
263 int32_t duplicate_routing_id = MSG_ROUTING_NONE; | 264 int32_t duplicate_routing_id = MSG_ROUTING_NONE; |
264 RenderViewHostImpl* pending_rvh = | 265 RenderViewHostImpl* pending_rvh = |
265 PrepareToDuplicateHosts(shell(), &duplicate_routing_id); | 266 PrepareToDuplicateHosts(shell(), &duplicate_routing_id); |
266 EXPECT_NE(MSG_ROUTING_NONE, duplicate_routing_id); | 267 EXPECT_NE(MSG_ROUTING_NONE, duplicate_routing_id); |
267 | 268 |
268 // Since this test executes on the UI thread and hopping threads might cause | 269 RenderFrameHostImpl* opener = |
269 // different timing in the test, let's simulate a CreateNewWindow call coming | 270 static_cast<RenderFrameHostImpl*>(pending_rvh->GetMainFrame()); |
270 // from the IO thread. | 271 mojom::CreateNewWindowParamsPtr params; |
271 DOMStorageContextWrapper* dom_storage_context = | 272 opener->CreateNewWindow(std::move(params), |
272 static_cast<DOMStorageContextWrapper*>( | 273 base::Bind([](mojom::CreateNewWindowReplyPtr) {})); |
273 BrowserContext::GetStoragePartition( | |
274 shell()->web_contents()->GetBrowserContext(), | |
275 pending_rvh->GetSiteInstance())->GetDOMStorageContext()); | |
276 scoped_refptr<SessionStorageNamespaceImpl> session_storage( | |
277 new SessionStorageNamespaceImpl(dom_storage_context)); | |
278 // Cause a deliberate collision in routing ids. | |
279 int32_t main_frame_routing_id = duplicate_routing_id + 1; | |
280 // TODO(avi): This should be made unique from the view routing ID once | |
281 // RenderViewHostImpl has-a RenderWidgetHostImpl. https://crbug.com/545684 | |
282 int32_t main_frame_widget_routing_id = duplicate_routing_id; | |
283 static_cast<RenderFrameHostImpl*>(pending_rvh->GetMainFrame()) | |
284 ->OnCreateNewWindow(duplicate_routing_id, main_frame_routing_id, | |
285 main_frame_widget_routing_id, | |
286 mojom::CreateNewWindowParams(), | |
287 session_storage.get()); | |
288 | |
289 // If the above operation doesn't cause a crash, the test has succeeded! | 274 // If the above operation doesn't cause a crash, the test has succeeded! |
290 } | 275 } |
291 | 276 |
292 // This is a test for crbug.com/312016. It tries to create two RenderWidgetHosts | 277 // This is a test for crbug.com/312016. It tries to create two RenderWidgetHosts |
293 // with the same process and routing ids, which causes a collision. It is almost | 278 // with the same process and routing ids, which causes a collision. It is almost |
294 // identical to the AttemptDuplicateRenderViewHost test case. | 279 // identical to the AttemptDuplicateRenderViewHost test case. |
295 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, | 280 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, |
296 AttemptDuplicateRenderWidgetHost) { | 281 AttemptDuplicateRenderWidgetHost) { |
297 #if defined(OS_WIN) | 282 #if defined(OS_WIN) |
298 // PlzNavigate | 283 // PlzNavigate |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 // separate task of the message loop, so ensure that the process is still | 552 // separate task of the message loop, so ensure that the process is still |
568 // considered alive. | 553 // considered alive. |
569 EXPECT_TRUE(root->current_frame_host()->GetProcess()->HasConnection()); | 554 EXPECT_TRUE(root->current_frame_host()->GetProcess()->HasConnection()); |
570 | 555 |
571 exit_observer.Wait(); | 556 exit_observer.Wait(); |
572 EXPECT_FALSE(exit_observer.did_exit_normally()); | 557 EXPECT_FALSE(exit_observer.did_exit_normally()); |
573 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | 558 ResourceDispatcherHost::Get()->SetDelegate(nullptr); |
574 } | 559 } |
575 | 560 |
576 } // namespace content | 561 } // namespace content |
OLD | NEW |