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" |
(...skipping 247 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 | 258 // 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 | 259 // pending RenderViewHost, this test case creates a new window through the new |
260 // process. | 260 // process. |
261 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, | 261 IN_PROC_BROWSER_TEST_F(SecurityExploitBrowserTest, |
262 AttemptDuplicateRenderViewHost) { | 262 AttemptDuplicateRenderViewHost) { |
263 int32_t duplicate_routing_id = MSG_ROUTING_NONE; | 263 int32_t duplicate_routing_id = MSG_ROUTING_NONE; |
264 RenderViewHostImpl* pending_rvh = | 264 RenderViewHostImpl* pending_rvh = |
265 PrepareToDuplicateHosts(shell(), &duplicate_routing_id); | 265 PrepareToDuplicateHosts(shell(), &duplicate_routing_id); |
266 EXPECT_NE(MSG_ROUTING_NONE, duplicate_routing_id); | 266 EXPECT_NE(MSG_ROUTING_NONE, duplicate_routing_id); |
267 | 267 |
268 // Since this test executes on the UI thread and hopping threads might cause | 268 RenderFrameHostImpl* opener = |
269 // different timing in the test, let's simulate a CreateNewWindow call coming | 269 static_cast<RenderFrameHostImpl*>(pending_rvh->GetMainFrame()); |
270 // from the IO thread. | 270 // TODO(nick,csharrison): This test doesn't test much, because new windows |
271 DOMStorageContextWrapper* dom_storage_context = | 271 // cannot be opened from RFH that are not current. It would be nice to |
272 static_cast<DOMStorageContextWrapper*>( | 272 // refactor this test to actually call into the delegate to open a new window |
273 BrowserContext::GetStoragePartition( | 273 // if possible. |
274 shell()->web_contents()->GetBrowserContext(), | 274 EXPECT_NE(opener->frame_tree_node()->current_frame_host(), opener); |
ncarter (slow)
2017/04/20 21:30:36
I remember spending some time thinking about this
Charlie Harrison
2017/04/21 15:30:07
FRIENDED and tested the mojo method directly.
| |
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! | |
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 |
299 // This test is failing in a flaky manner on Android as it appears to be | 284 // This test is failing in a flaky manner on Android as it appears to be |
(...skipping 267 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 |