ipc/ipdl/test/cxx/TestBadActor.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial