Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: content/renderer/pepper_plugin_delegate_impl_unittest.cc

Issue 8436008: Add check on invalid file descriptor at both broker and renderer sides. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
Paweł Hajdan Jr. 2011/11/04 08:05:15 nit: 2011 not 2009.
xhwang 2011/11/04 15:44:48 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/pepper_plugin_delegate_impl.h"
6 #include "content/test/mock_render_process.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 class PepperPluginDelegateImplTest : public ::testing::Test {
10 public:
11 PepperPluginDelegateImplTest() {}
Paweł Hajdan Jr. 2011/11/04 08:05:15 nit: Is the ctor needed here? Is the dtor needed?
xhwang 2011/11/04 15:44:48 Done.
12 virtual ~PepperPluginDelegateImplTest() {}
13
14 virtual void SetUp() {
15 mock_process_.reset(new MockRenderProcess);
16 }
17
18 virtual void TearDown() {
19 mock_process_.reset();
20 }
21
22 protected:
23 MessageLoopForIO message_loop_;
24 // ppapi::proxy::ProxyChannel needs to be initialized on the render process.
25 scoped_ptr<MockRenderProcess> mock_process_;
Paweł Hajdan Jr. 2011/11/04 08:05:15 nit: I think you can just declare MockRenderProces
xhwang 2011/11/04 15:44:48 Great to know that. Thanks!
26
27 private:
28 DISALLOW_COPY_AND_ASSIGN(PepperPluginDelegateImplTest);
Paweł Hajdan Jr. 2011/11/04 08:05:15 nit: No need for this in test fixtures.
xhwang 2011/11/04 15:44:48 Done.
29 };
30
31 // Try to initialize BrokerDispatcherWrapper with invalid ChannelHandle.
32 // Initialization should fail.
33 TEST_F(PepperPluginDelegateImplTest, BrokerDispatcherWrapperInitFailure) {
34 BrokerDispatcherWrapper dispatcher_wrapper;
35 base::ProcessHandle broker_process_handle = base::kNullProcessHandle;
36 IPC::ChannelHandle channel_handle; // Invalid by default.
Paweł Hajdan Jr. 2011/11/04 08:05:15 nit: Two spaces between code and comment please.
xhwang 2011/11/04 15:44:48 Done.
37
38 // Try BrokerDispatcherWrapper.Init() TWICE to trigger the LOG(FATAL)
39 // of "Denying attempt to reuse initial IPC channel for ..." in
40 // IPC::Channel::ChannelImpl::CreatePipe() in case invalid ChannelHandle is
41 // not checked properly. If invalid ChannelHandle is not checked and passed
42 // all the way down to IPC::Channel::ChannelImpl::CreatePipe(), CreatePipe
43 // will be called in client mode with channel_handle.socket.fd == -1. There
44 // is a static variable "bool used_initial_channel = false" in this function.
45 // In the first test it will be set to true. In the second test the
46 // LOG(FATAL) error will be triggered.
47 EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle));
48 EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle));
49 }
OLDNEW
« no previous file with comments | « content/renderer/pepper_plugin_delegate_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698