OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/test/histogram_tester.h" | 9 #include "base/test/histogram_tester.h" |
10 #include "content/browser/bad_message.h" | 10 #include "content/browser/bad_message.h" |
11 #include "content/browser/frame_host/frame_tree.h" | 11 #include "content/browser/frame_host/frame_tree.h" |
| 12 #include "content/browser/frame_host/render_frame_message_filter.h" |
12 #include "content/browser/web_contents/web_contents_impl.h" | 13 #include "content/browser/web_contents/web_contents_impl.h" |
13 #include "content/common/frame_messages.h" | 14 #include "content/common/frame_messages.h" |
| 15 #include "content/common/render_frame_message_filter.mojom.h" |
14 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
16 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
17 #include "content/public/test/content_browser_test.h" | 19 #include "content/public/test/content_browser_test.h" |
18 #include "content/public/test/content_browser_test_utils.h" | 20 #include "content/public/test/content_browser_test_utils.h" |
19 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
20 #include "content/shell/browser/shell.h" | 22 #include "content/shell/browser/shell.h" |
21 #include "content/test/content_browser_test_utils_internal.h" | 23 #include "content/test/content_browser_test_utils_internal.h" |
22 #include "ipc/ipc_security_test_util.h" | 24 #include "ipc/ipc_security_test_util.h" |
23 #include "net/dns/mock_host_resolver.h" | 25 #include "net/dns/mock_host_resolver.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 " +--Site B ------- proxies for A\n" | 210 " +--Site B ------- proxies for A\n" |
209 "Where A = http://127.0.0.1/\n" | 211 "Where A = http://127.0.0.1/\n" |
210 " B = http://baz.com/ (no process)", | 212 " B = http://baz.com/ (no process)", |
211 v.DepictFrameTree(tab->GetFrameTree()->root())); | 213 v.DepictFrameTree(tab->GetFrameTree()->root())); |
212 | 214 |
213 // Now set a cross-site cookie from the main frame's process and wait for it | 215 // Now set a cross-site cookie from the main frame's process and wait for it |
214 // to be killed. | 216 // to be killed. |
215 RenderProcessHostWatcher main_frame_killed( | 217 RenderProcessHostWatcher main_frame_killed( |
216 tab->GetMainFrame()->GetProcess(), | 218 tab->GetMainFrame()->GetProcess(), |
217 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 219 RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
218 FrameHostMsg_SetCookie illegal_set_cookie(tab->GetMainFrame()->GetRoutingID(), | 220 |
219 GURL("https://baz.com/"), | 221 RenderProcessHostImpl* process = |
220 GURL("https://baz.com/"), "pwn=ed"); | 222 static_cast<RenderProcessHostImpl*>(tab->GetMainFrame()->GetProcess()); |
221 IPC::IpcSecurityTestUtil::PwnMessageReceived( | 223 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)->PostTask( |
222 tab->GetMainFrame()->GetProcess()->GetChannel(), illegal_set_cookie); | 224 FROM_HERE, |
| 225 base::Bind( |
| 226 &mojom::RenderFrameMessageFilter::SetCookie, |
| 227 base::Unretained(process->render_frame_message_filter()), |
| 228 tab->GetMainFrame()->GetRoutingID(), GURL("https://baz.com/"), |
| 229 GURL("https://baz.com/"), "pwn=ed")); |
223 | 230 |
224 main_frame_killed.Wait(); | 231 main_frame_killed.Wait(); |
225 | 232 |
226 EXPECT_EQ( | 233 EXPECT_EQ( |
227 " Site A\n" | 234 " Site A\n" |
228 "Where A = http://127.0.0.1/ (no process)", | 235 "Where A = http://127.0.0.1/ (no process)", |
229 v.DepictFrameTree(tab->GetFrameTree()->root())); | 236 v.DepictFrameTree(tab->GetFrameTree()->root())); |
230 } | 237 } |
231 | 238 |
232 // FrameHostMsg_RenderProcessGone is a synthetic message that's really an | 239 // FrameHostMsg_RenderProcessGone is a synthetic message that's really an |
(...skipping 22 matching lines...) Expand all Loading... |
255 // If the message had gone through, we'd have marked the RFH as dead but | 262 // If the message had gone through, we'd have marked the RFH as dead but |
256 // left the RPH and its connection alive, and the Wait below would hang. | 263 // left the RPH and its connection alive, and the Wait below would hang. |
257 web_process_killed.Wait(); | 264 web_process_killed.Wait(); |
258 | 265 |
259 ASSERT_FALSE(web_rfh->GetProcess()->HasConnection()); | 266 ASSERT_FALSE(web_rfh->GetProcess()->HasConnection()); |
260 ASSERT_FALSE(web_rfh->IsRenderFrameLive()); | 267 ASSERT_FALSE(web_rfh->IsRenderFrameLive()); |
261 ASSERT_FALSE(web_process_killed.did_exit_normally()); | 268 ASSERT_FALSE(web_process_killed.did_exit_normally()); |
262 } | 269 } |
263 | 270 |
264 } // namespace content | 271 } // namespace content |
OLD | NEW |