1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/ipdl/test/cxx/TestBadActor.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +#include "TestBadActor.h" 1.5 +#include "IPDLUnitTests.h" 1.6 +#include "mozilla/unused.h" 1.7 + 1.8 +namespace mozilla { 1.9 +namespace _ipdltest { 1.10 + 1.11 +void 1.12 +TestBadActorParent::Main() 1.13 +{ 1.14 + // This test is designed to test a race condition where the child sends us 1.15 + // a message on an actor that we've already destroyed. The child process 1.16 + // should die, and the parent process should not abort. 1.17 + 1.18 + PTestBadActorSubParent* child = SendPTestBadActorSubConstructor(); 1.19 + if (!child) 1.20 + fail("Sending constructor"); 1.21 + 1.22 + unused << child->Call__delete__(child); 1.23 +} 1.24 + 1.25 +PTestBadActorSubParent* 1.26 +TestBadActorParent::AllocPTestBadActorSubParent() 1.27 +{ 1.28 + return new TestBadActorSubParent(); 1.29 +} 1.30 + 1.31 +bool 1.32 +TestBadActorSubParent::RecvPing() 1.33 +{ 1.34 + fail("Shouldn't have received ping."); 1.35 + return false; 1.36 +} 1.37 + 1.38 +PTestBadActorSubChild* 1.39 +TestBadActorChild::AllocPTestBadActorSubChild() 1.40 +{ 1.41 + return new TestBadActorSubChild(); 1.42 +} 1.43 + 1.44 +bool 1.45 +TestBadActorChild::RecvPTestBadActorSubConstructor(PTestBadActorSubChild* actor) 1.46 +{ 1.47 + if (!actor->SendPing()) { 1.48 + fail("Couldn't send ping to an actor which supposedly isn't dead yet."); 1.49 + } 1.50 + return true; 1.51 +} 1.52 + 1.53 +} // namespace _ipdltest 1.54 +} // namespace mozilla