ipc/ipdl/test/cxx/TestBadActor.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #include "TestBadActor.h"
michael@0 2 #include "IPDLUnitTests.h"
michael@0 3 #include "mozilla/unused.h"
michael@0 4
michael@0 5 namespace mozilla {
michael@0 6 namespace _ipdltest {
michael@0 7
michael@0 8 void
michael@0 9 TestBadActorParent::Main()
michael@0 10 {
michael@0 11 // This test is designed to test a race condition where the child sends us
michael@0 12 // a message on an actor that we've already destroyed. The child process
michael@0 13 // should die, and the parent process should not abort.
michael@0 14
michael@0 15 PTestBadActorSubParent* child = SendPTestBadActorSubConstructor();
michael@0 16 if (!child)
michael@0 17 fail("Sending constructor");
michael@0 18
michael@0 19 unused << child->Call__delete__(child);
michael@0 20 }
michael@0 21
michael@0 22 PTestBadActorSubParent*
michael@0 23 TestBadActorParent::AllocPTestBadActorSubParent()
michael@0 24 {
michael@0 25 return new TestBadActorSubParent();
michael@0 26 }
michael@0 27
michael@0 28 bool
michael@0 29 TestBadActorSubParent::RecvPing()
michael@0 30 {
michael@0 31 fail("Shouldn't have received ping.");
michael@0 32 return false;
michael@0 33 }
michael@0 34
michael@0 35 PTestBadActorSubChild*
michael@0 36 TestBadActorChild::AllocPTestBadActorSubChild()
michael@0 37 {
michael@0 38 return new TestBadActorSubChild();
michael@0 39 }
michael@0 40
michael@0 41 bool
michael@0 42 TestBadActorChild::RecvPTestBadActorSubConstructor(PTestBadActorSubChild* actor)
michael@0 43 {
michael@0 44 if (!actor->SendPing()) {
michael@0 45 fail("Couldn't send ping to an actor which supposedly isn't dead yet.");
michael@0 46 }
michael@0 47 return true;
michael@0 48 }
michael@0 49
michael@0 50 } // namespace _ipdltest
michael@0 51 } // namespace mozilla

mercurial