summaryrefslogtreecommitdiffstats
path: root/ipc/ipdl/test/cxx/TestBadActor.cpp
blob: bc1cf6f6dd6619d5deab7afd175bbdb77e7092ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "TestBadActor.h"
#include "IPDLUnitTests.h"
#include "mozilla/Unused.h"

namespace mozilla {
namespace _ipdltest {

void
TestBadActorParent::Main()
{
  // This test is designed to test a race condition where the child sends us
  // a message on an actor that we've already destroyed. The child process
  // should die, and the parent process should not abort.

  PTestBadActorSubParent* child = SendPTestBadActorSubConstructor();
  if (!child)
    fail("Sending constructor");

  Unused << child->Call__delete__(child);
}

PTestBadActorSubParent*
TestBadActorParent::AllocPTestBadActorSubParent()
{
  return new TestBadActorSubParent();
}

bool
TestBadActorSubParent::RecvPing()
{
  fail("Shouldn't have received ping.");
  return false;
}

PTestBadActorSubChild*
TestBadActorChild::AllocPTestBadActorSubChild()
{
  return new TestBadActorSubChild();
}

bool
TestBadActorChild::RecvPTestBadActorSubConstructor(PTestBadActorSubChild* actor)
{
  if (!actor->SendPing()) {
    fail("Couldn't send ping to an actor which supposedly isn't dead yet.");
  }
  return true;
}

} // namespace _ipdltest
} // namespace mozilla