OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "content/browser/renderer_host/render_process_host_impl.h" | 6 #include "content/browser/renderer_host/render_process_host_impl.h" |
6 #include "content/common/child_process_messages.h" | 7 #include "content/common/child_process_messages.h" |
7 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
8 #include "content/public/browser/render_process_host_observer.h" | 9 #include "content/public/browser/render_process_host_observer.h" |
9 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/common/content_switches.h" |
11 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
12 #include "content/public/test/content_browser_test.h" | 14 #include "content/public/test/content_browser_test.h" |
13 #include "content/public/test/content_browser_test_utils.h" | 15 #include "content/public/test/content_browser_test_utils.h" |
14 #include "content/shell/browser/shell.h" | 16 #include "content/shell/browser/shell.h" |
15 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
16 | 18 |
| 19 #if defined(OS_WIN) |
| 20 #include "base/win/windows_version.h" |
| 21 #endif |
| 22 |
17 namespace content { | 23 namespace content { |
18 namespace { | 24 namespace { |
19 | 25 |
20 int RenderProcessHostCount() { | 26 int RenderProcessHostCount() { |
21 content::RenderProcessHost::iterator hosts = | 27 content::RenderProcessHost::iterator hosts = |
22 content::RenderProcessHost::AllHostsIterator(); | 28 content::RenderProcessHost::AllHostsIterator(); |
23 int count = 0; | 29 int count = 0; |
24 while (!hosts.IsAtEnd()) { | 30 while (!hosts.IsAtEnd()) { |
25 if (hosts.GetCurrentValue()->HasConnection()) | 31 if (hosts.GetCurrentValue()->HasConnection()) |
26 count++; | 32 count++; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 "ObserverLogger::RenderProcessHostDestroyed ", logging_string); | 191 "ObserverLogger::RenderProcessHostDestroyed ", logging_string); |
186 | 192 |
187 // If the test fails, and somehow the RPH is still alive somehow, at least | 193 // If the test fails, and somehow the RPH is still alive somehow, at least |
188 // deregister the observers so that the test fails and doesn't also crash. | 194 // deregister the observers so that the test fails and doesn't also crash. |
189 if (!observer_logger.host_destroyed()) { | 195 if (!observer_logger.host_destroyed()) { |
190 rph->RemoveObserver(&shell_closer); | 196 rph->RemoveObserver(&shell_closer); |
191 rph->RemoveObserver(&observer_logger); | 197 rph->RemoveObserver(&observer_logger); |
192 } | 198 } |
193 } | 199 } |
194 | 200 |
| 201 #if defined(OS_WIN) |
| 202 // Provides functionality to test renderer processes with the Win32K lockdown |
| 203 // process mitigation. |
| 204 class Win32KLockdownRendererProcessHostTest : public RenderProcessHostTest { |
| 205 public: |
| 206 Win32KLockdownRendererProcessHostTest() {} |
| 207 |
| 208 virtual ~Win32KLockdownRendererProcessHostTest() {} |
| 209 |
| 210 protected: |
| 211 virtual void SetUp() OVERRIDE { |
| 212 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 213 command_line->AppendSwitch(switches::kEnableWin32kRendererLockDown); |
| 214 RenderProcessHostTest::SetUp(); |
| 215 } |
| 216 |
| 217 private: |
| 218 DISALLOW_COPY_AND_ASSIGN(Win32KLockdownRendererProcessHostTest); |
| 219 }; |
| 220 |
| 221 // Tests whether navigation requests with the Win32K lockdown mitigation set |
| 222 // work correctly. |
| 223 IN_PROC_BROWSER_TEST_F(Win32KLockdownRendererProcessHostTest, |
| 224 RendererWin32KLockdownNavigationTest) { |
| 225 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
| 226 return; |
| 227 |
| 228 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 229 |
| 230 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
| 231 NavigateToURL(shell(), test_url); |
| 232 |
| 233 EXPECT_EQ(1, RenderProcessHostCount()); |
| 234 EXPECT_EQ(0, process_exits_); |
| 235 } |
| 236 #endif |
| 237 |
195 } // namespace | 238 } // namespace |
196 } // namespace content | 239 } // namespace content |
OLD | NEW |