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 "chrome/browser/ui/browser.h" | |
11 #include "chrome/browser/ui/browser_tabstrip.h" | |
12 #include "chrome/test/base/in_process_browser_test.h" | |
13 #include "chrome/test/base/ui_test_utils.h" | |
14 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
15 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
16 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
17 #include "content/public/common/result_codes.h" | 13 #include "content/public/common/result_codes.h" |
| 14 #include "content/shell/shell.h" |
| 15 #include "content/test/content_browser_test.h" |
| 16 #include "content/test/content_browser_test_utils.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
19 | 18 |
20 using content::WebContents; | |
21 | |
22 class ChildProcessSecurityPolicyInProcessBrowserTest | 19 class ChildProcessSecurityPolicyInProcessBrowserTest |
23 : public InProcessBrowserTest { | 20 : public content::ContentBrowserTest { |
24 public: | 21 public: |
25 virtual void SetUp() { | 22 virtual void SetUp() { |
26 EXPECT_EQ( | 23 EXPECT_EQ( |
27 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), | 24 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), |
28 0U); | 25 0U); |
29 InProcessBrowserTest::SetUp(); | 26 ContentBrowserTest::SetUp(); |
30 } | 27 } |
31 | 28 |
32 virtual void TearDown() { | 29 virtual void TearDown() { |
33 EXPECT_EQ( | 30 EXPECT_EQ( |
34 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), | 31 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), |
35 0U); | 32 0U); |
36 InProcessBrowserTest::TearDown(); | 33 ContentBrowserTest::TearDown(); |
37 } | 34 } |
38 }; | 35 }; |
39 | 36 |
40 IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) { | 37 IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) { |
41 const FilePath kTestDir(FILE_PATH_LITERAL("google")); | 38 GURL url = content::GetTestUrl("", "simple_page.html"); |
42 const FilePath kTestFile(FILE_PATH_LITERAL("google.html")); | |
43 GURL url(ui_test_utils::GetTestUrl(kTestDir, kTestFile)); | |
44 | 39 |
45 ui_test_utils::NavigateToURL(browser(), url); | 40 content::NavigateToURL(shell(), url); |
46 EXPECT_EQ( | 41 EXPECT_EQ( |
47 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), | 42 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(), |
48 1U); | 43 1U); |
49 | 44 |
50 WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0); | 45 content::WebContents* web_contents = shell()->web_contents(); |
51 ASSERT_TRUE(web_contents != NULL); | |
52 base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(), | 46 base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(), |
53 content::RESULT_CODE_KILLED, true); | 47 content::RESULT_CODE_KILLED, true); |
54 | 48 |
55 web_contents->GetController().Reload(true); | 49 web_contents->GetController().Reload(true); |
56 EXPECT_EQ( | 50 EXPECT_EQ( |
57 1U, | 51 1U, |
58 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size()); | 52 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size()); |
59 } | 53 } |
OLD | NEW |