OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
12 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
13 #include "content/public/common/result_codes.h" | 13 #include "content/public/common/result_codes.h" |
14 #include "content/shell/shell.h" | 14 #include "content/shell/shell.h" |
15 #include "content/test/content_browser_test.h" | 15 #include "content/test/content_browser_test.h" |
16 #include "content/test/content_browser_test_utils.h" | 16 #include "content/test/content_browser_test_utils.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
| 19 namespace content { |
| 20 |
19 class ChildProcessSecurityPolicyInProcessBrowserTest | 21 class ChildProcessSecurityPolicyInProcessBrowserTest |
20 : public content::ContentBrowserTest { | 22 : public ContentBrowserTest { |
21 public: | 23 public: |
22 virtual void SetUp() { | 24 virtual void SetUp() OVERRIDE { |
23 EXPECT_EQ( | 25 EXPECT_EQ( |
24 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), | 26 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), |
25 0U); | 27 0U); |
26 ContentBrowserTest::SetUp(); | 28 ContentBrowserTest::SetUp(); |
27 } | 29 } |
28 | 30 |
29 virtual void TearDown() { | 31 virtual void TearDown() OVERRIDE { |
30 EXPECT_EQ( | 32 EXPECT_EQ( |
31 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), | 33 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), |
32 0U); | 34 0U); |
33 ContentBrowserTest::TearDown(); | 35 ContentBrowserTest::TearDown(); |
34 } | 36 } |
35 }; | 37 }; |
36 | 38 |
37 #if !defined(NDEBUG) && defined(OS_MACOSX) | 39 #if !defined(NDEBUG) && defined(OS_MACOSX) |
38 IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, DISABLED_
NoLeak) { | 40 IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, DISABLED_
NoLeak) { |
39 #else | 41 #else |
40 IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) { | 42 IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) { |
41 #endif | 43 #endif |
42 GURL url = content::GetTestUrl("", "simple_page.html"); | 44 GURL url = GetTestUrl("", "simple_page.html"); |
43 | 45 |
44 content::NavigateToURL(shell(), url); | 46 NavigateToURL(shell(), url); |
45 EXPECT_EQ( | 47 EXPECT_EQ( |
46 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), | 48 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), |
47 1U); | 49 1U); |
48 | 50 |
49 content::WebContents* web_contents = shell()->web_contents(); | 51 WebContents* web_contents = shell()->web_contents(); |
50 base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(), | 52 base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(), |
51 content::RESULT_CODE_KILLED, true); | 53 RESULT_CODE_KILLED, true); |
52 | 54 |
53 web_contents->GetController().Reload(true); | 55 web_contents->GetController().Reload(true); |
54 EXPECT_EQ( | 56 EXPECT_EQ( |
55 1U, | 57 1U, |
56 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size()); | 58 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size()); |
57 } | 59 } |
| 60 |
| 61 } // namespace content |
OLD | NEW |