blob: e475c02561c788a28efbf29740034f63e931a7f2 [file] [log] [blame]
[email protected]b9535422012-02-09 01:47:591// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]c2b67262009-05-19 23:32:262// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <string>
6
7#include "base/basictypes.h"
[email protected]57999812013-02-24 05:40:528#include "base/files/file_path.h"
[email protected]3985ba82010-07-29 21:44:129#include "base/process_util.h"
[email protected]b9535422012-02-09 01:47:5910#include "content/browser/child_process_security_policy_impl.h"
[email protected]93ddb3c2012-04-11 21:44:2911#include "content/browser/web_contents/web_contents_impl.h"
[email protected]f3b1a082011-11-18 00:34:3012#include "content/public/browser/render_process_host.h"
[email protected]b39ef1cb2011-10-25 04:46:5513#include "content/public/common/result_codes.h"
[email protected]4cdc9a22012-07-26 03:39:3114#include "content/shell/shell.h"
15#include "content/test/content_browser_test.h"
16#include "content/test/content_browser_test_utils.h"
[email protected]c2b67262009-05-19 23:32:2617#include "testing/gtest/include/gtest/gtest.h"
18
[email protected]46488322012-10-30 03:22:2019namespace content {
20
[email protected]c2b67262009-05-19 23:32:2621class ChildProcessSecurityPolicyInProcessBrowserTest
[email protected]46488322012-10-30 03:22:2022 : public ContentBrowserTest {
[email protected]c2b67262009-05-19 23:32:2623 public:
[email protected]d9c2e512012-10-25 18:54:3624 virtual void SetUp() {
[email protected]c2b67262009-05-19 23:32:2625 EXPECT_EQ(
[email protected]b9535422012-02-09 01:47:5926 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(),
27 0U);
[email protected]4cdc9a22012-07-26 03:39:3128 ContentBrowserTest::SetUp();
[email protected]c2b67262009-05-19 23:32:2629 }
30
[email protected]d9c2e512012-10-25 18:54:3631 virtual void TearDown() {
[email protected]c2b67262009-05-19 23:32:2632 EXPECT_EQ(
[email protected]b9535422012-02-09 01:47:5933 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(),
34 0U);
[email protected]4cdc9a22012-07-26 03:39:3135 ContentBrowserTest::TearDown();
[email protected]c2b67262009-05-19 23:32:2636 }
37};
38
[email protected]7ededb82012-07-26 04:50:3639#if !defined(NDEBUG) && defined(OS_MACOSX)
40IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, DISABLED_NoLeak) {
41#else
[email protected]c2b67262009-05-19 23:32:2642IN_PROC_BROWSER_TEST_F(ChildProcessSecurityPolicyInProcessBrowserTest, NoLeak) {
[email protected]7ededb82012-07-26 04:50:3643#endif
[email protected]46488322012-10-30 03:22:2044 GURL url = GetTestUrl("", "simple_page.html");
[email protected]c2b67262009-05-19 23:32:2645
[email protected]46488322012-10-30 03:22:2046 NavigateToURL(shell(), url);
[email protected]c2b67262009-05-19 23:32:2647 EXPECT_EQ(
[email protected]b9535422012-02-09 01:47:5948 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size(),
49 1U);
[email protected]c2b67262009-05-19 23:32:2650
[email protected]46488322012-10-30 03:22:2051 WebContents* web_contents = shell()->web_contents();
[email protected]3bbacc5b2012-04-17 17:46:1552 base::KillProcess(web_contents->GetRenderProcessHost()->GetHandle(),
[email protected]46488322012-10-30 03:22:2053 RESULT_CODE_KILLED, true);
[email protected]c2b67262009-05-19 23:32:2654
[email protected]3bbacc5b2012-04-17 17:46:1555 web_contents->GetController().Reload(true);
[email protected]c2b67262009-05-19 23:32:2656 EXPECT_EQ(
[email protected]3bbacc5b2012-04-17 17:46:1557 1U,
58 ChildProcessSecurityPolicyImpl::GetInstance()->security_state_.size());
[email protected]c2b67262009-05-19 23:32:2659}
[email protected]46488322012-10-30 03:22:2060
61} // namespace content