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

Unified 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: Change comment about the mock_process_. 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper_plugin_delegate_impl_unittest.cc
diff --git a/content/renderer/pepper_plugin_delegate_impl_unittest.cc b/content/renderer/pepper_plugin_delegate_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..81e1fdb130986f7d82dfe6d82aaf8f472ef1de43
--- /dev/null
+++ b/content/renderer/pepper_plugin_delegate_impl_unittest.cc
@@ -0,0 +1,34 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/pepper_plugin_delegate_impl.h"
+#include "content/test/mock_render_process.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class PepperPluginDelegateImplTest : public ::testing::Test {
+ protected:
+ MessageLoopForIO message_loop_;
+ // We need a render process for ppapi::proxy::ProxyChannel to work.
+ MockRenderProcess mock_process_;
+};
+
+// Try to initialize BrokerDispatcherWrapper with invalid ChannelHandle.
+// Initialization should fail.
+TEST_F(PepperPluginDelegateImplTest, BrokerDispatcherWrapperInitFailure) {
+ BrokerDispatcherWrapper dispatcher_wrapper;
+ base::ProcessHandle broker_process_handle = base::kNullProcessHandle;
+ IPC::ChannelHandle channel_handle; // Invalid by default.
+
+ // Try BrokerDispatcherWrapper.Init() TWICE to trigger the LOG(FATAL)
+ // of "Denying attempt to reuse initial IPC channel for ..." in
+ // IPC::Channel::ChannelImpl::CreatePipe() in case invalid ChannelHandle is
+ // not checked properly. If invalid ChannelHandle is not checked and passed
+ // all the way down to IPC::Channel::ChannelImpl::CreatePipe(), CreatePipe
+ // will be called in client mode with channel_handle.socket.fd == -1. There
+ // is a static variable "bool used_initial_channel = false" in this function.
+ // In the first test it will be set to true. In the second test the
+ // LOG(FATAL) error will be triggered.
+ EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle));
+ EXPECT_FALSE(dispatcher_wrapper.Init(broker_process_handle, channel_handle));
+}

Powered by Google App Engine
This is Rietveld 408576698