Commit 8e9ba76b authored by jam@chromium.org's avatar jam@chromium.org

Add regression tests to ensure that IPC::Listener::OnBadMessageReceived is...

Add regression tests to ensure that IPC::Listener::OnBadMessageReceived is always called for all cases, i.e.
1) using IPC::Channel directly
2) using IPC::ChannelProxy and the IPC is dispatched on the IO thread
2) using IPC::ChannelProxy and the IPC is dispatched on the listener thread

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/282303014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271915 0039d316-1c4b-4281-b951-d872f2087c98
parent 254032b9
...@@ -207,48 +207,6 @@ TEST_F(RenderViewHostTest, DragEnteredFileURLsStillBlocked) { ...@@ -207,48 +207,6 @@ TEST_F(RenderViewHostTest, DragEnteredFileURLsStillBlocked) {
EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url)); EXPECT_FALSE(policy->CanRequestURL(id, sensitive_file_url));
EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path)); EXPECT_FALSE(policy->CanReadFile(id, sensitive_file_path));
} }
/* TODO(jam)
// The test that follow trigger DCHECKS in debug build.
#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
// Test that when we fail to de-serialize a message, RenderViewHost calls the
// ReceivedBadMessage() handler.
TEST_F(RenderViewHostTest, BadMessageHandlerRenderViewHost) {
EXPECT_EQ(0, process()->bad_msg_count());
// craft an incorrect ViewHostMsg_UpdateTargetURL message. The real one has
// two payload items but the one we construct has none.
IPC::Message message(0, ViewHostMsg_UpdateTargetURL::ID,
IPC::Message::PRIORITY_NORMAL);
test_rvh()->OnMessageReceived(message);
EXPECT_EQ(1, process()->bad_msg_count());
}
// Test that when we fail to de-serialize a message, RenderWidgetHost calls the
// ReceivedBadMessage() handler.
TEST_F(RenderViewHostTest, BadMessageHandlerRenderWidgetHost) {
EXPECT_EQ(0, process()->bad_msg_count());
// craft an incorrect ViewHostMsg_UpdateRect message. The real one has
// one payload item but the one we construct has none.
IPC::Message message(0, ViewHostMsg_UpdateRect::ID,
IPC::Message::PRIORITY_NORMAL);
test_rvh()->OnMessageReceived(message);
EXPECT_EQ(1, process()->bad_msg_count());
}
// Test that OnInputEventAck() detects bad messages.
TEST_F(RenderViewHostTest, BadMessageHandlerInputEventAck) {
EXPECT_EQ(0, process()->bad_msg_count());
// InputHostMsg_HandleInputEvent_ACK is defined taking 0 params but
// the code actually expects it to have at least one int para, this this
// bogus message will not fail at de-serialization but should fail in
// OnInputEventAck() processing.
IPC::Message message(0, InputHostMsg_HandleInputEvent_ACK::ID,
IPC::Message::PRIORITY_NORMAL);
test_rvh()->OnMessageReceived(message);
EXPECT_EQ(1, process()->bad_msg_count());
}
#endif
*/
TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) { TEST_F(RenderViewHostTest, MessageWithBadHistoryItemFiles) {
base::FilePath file_path; base::FilePath file_path;
......
This diff is collapsed.
// Copyright 2014 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 "ipc/ipc_message_macros.h"
// Singly-included section for enums and custom IPC traits.
#ifndef IPC_CHANNEL_PROXY_UNITTEST_MESSAGES_H_
#define IPC_CHANNEL_PROXY_UNITTEST_MESSAGES_H_
class BadType {
public:
BadType() {}
};
namespace IPC {
template <>
struct ParamTraits<BadType> {
static void Write(Message* m, const BadType& p) {}
static bool Read(const Message* m, PickleIterator* iter, BadType* r) {
return false;
}
static void Log(const BadType& p, std::string* l) {}
};
}
#endif // IPC_CHANNEL_PROXY_UNITTEST_MESSAGES_H_
#define IPC_MESSAGE_START TestMsgStart
IPC_MESSAGE_CONTROL0(TestMsg_Bounce)
IPC_MESSAGE_CONTROL0(TestMsg_SendBadMessage)
IPC_MESSAGE_CONTROL1(TestMsg_BadMessage, BadType)
#undef IPC_MESSAGE_START
#define IPC_MESSAGE_START UtilityMsgStart
IPC_MESSAGE_CONTROL0(UtilityMsg_Bounce)
#undef IPC_MESSAGE_START
#define IPC_MESSAGE_START WorkerMsgStart
IPC_MESSAGE_CONTROL0(WorkerMsg_Bounce)
IPC_MESSAGE_CONTROL0(WorkerMsg_Quit)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment