mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 13:23:07 +00:00
1beb91ad2b
- Bug 1262671 - IPC sentinel checking (r=froydnj) (2bd39988fe) - Bug 1262671 - IPC ReadData/ReadBytes elimination (r=froydnj) (85b47baffd) - Bug 1272415: Don't include task.h everywhere. r=froydnj (6198aedfed) - Bug 1273312 - Add task.h to ipdl unit tests (r=khuey) (42b8d3bb90) - Bug 1268616 - Part 1: Check max message size before resizing. r=billm (6889a43e16) - Bug 1268616 - Part 2: Stop sending messages that are too large. r=billm (a68e6624be) - Bug 1268616 - Part 3: Reduce the maxmimum IPC message size. r=billm (581076632e) - Bug 1262671 - Use BufferList for Pickle (r=froydnj) (f61d8b233d) - Bug 1262671 - Introduce MFBT BufferList class (r=froydnj) (cb1aca1708) - mfbt: BufferList: VC2013 fix (93da0d98f7)
117 lines
2.4 KiB
C++
117 lines
2.4 KiB
C++
#include "TestCrashCleanup.h"
|
|
|
|
#include "base/task.h"
|
|
#include "mozilla/CondVar.h"
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "IPDLUnitTests.h" // fail etc.
|
|
#include "IPDLUnitTestSubprocess.h"
|
|
|
|
using mozilla::CondVar;
|
|
using mozilla::Mutex;
|
|
using mozilla::MutexAutoLock;
|
|
|
|
namespace mozilla {
|
|
namespace _ipdltest {
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// parent
|
|
|
|
namespace {
|
|
|
|
// NB: this test does its own shutdown, rather than going through
|
|
// QuitParent(), because it's testing degenerate edge cases
|
|
|
|
void DeleteSubprocess(Mutex* mutex, CondVar* cvar)
|
|
{
|
|
MutexAutoLock lock(*mutex);
|
|
|
|
delete gSubprocess;
|
|
gSubprocess = nullptr;
|
|
|
|
cvar->Notify();
|
|
}
|
|
|
|
void DeleteTheWorld()
|
|
{
|
|
delete static_cast<TestCrashCleanupParent*>(gParentActor);
|
|
gParentActor = nullptr;
|
|
|
|
// needs to be synchronous to avoid affecting event ordering on
|
|
// the main thread
|
|
Mutex mutex("TestCrashCleanup.DeleteTheWorld.mutex");
|
|
CondVar cvar(mutex, "TestCrashCleanup.DeleteTheWorld.cvar");
|
|
|
|
MutexAutoLock lock(mutex);
|
|
|
|
XRE_GetIOMessageLoop()->PostTask(
|
|
NewRunnableFunction(DeleteSubprocess, &mutex, &cvar));
|
|
|
|
cvar.Wait();
|
|
}
|
|
|
|
void Done()
|
|
{
|
|
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
|
nsCOMPtr<nsIAppShell> appShell (do_GetService(kAppShellCID));
|
|
appShell->Exit();
|
|
|
|
passed(__FILE__);
|
|
}
|
|
|
|
} // namespace <anon>
|
|
|
|
TestCrashCleanupParent::TestCrashCleanupParent() : mCleanedUp(false)
|
|
{
|
|
MOZ_COUNT_CTOR(TestCrashCleanupParent);
|
|
}
|
|
|
|
TestCrashCleanupParent::~TestCrashCleanupParent()
|
|
{
|
|
MOZ_COUNT_DTOR(TestCrashCleanupParent);
|
|
|
|
if (!mCleanedUp)
|
|
fail("should have been ActorDestroy()d!");
|
|
}
|
|
|
|
void
|
|
TestCrashCleanupParent::Main()
|
|
{
|
|
// NB: has to be enqueued before IO thread's error notification
|
|
MessageLoop::current()->PostTask(
|
|
NewRunnableFunction(DeleteTheWorld));
|
|
|
|
if (CallDIEDIEDIE())
|
|
fail("expected an error!");
|
|
|
|
Close();
|
|
|
|
MessageLoop::current()->PostTask(NewRunnableFunction(Done));
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// child
|
|
|
|
TestCrashCleanupChild::TestCrashCleanupChild()
|
|
{
|
|
MOZ_COUNT_CTOR(TestCrashCleanupChild);
|
|
}
|
|
|
|
TestCrashCleanupChild::~TestCrashCleanupChild()
|
|
{
|
|
MOZ_COUNT_DTOR(TestCrashCleanupChild);
|
|
}
|
|
|
|
bool
|
|
TestCrashCleanupChild::AnswerDIEDIEDIE()
|
|
{
|
|
_exit(0);
|
|
NS_RUNTIMEABORT("unreached");
|
|
return false;
|
|
}
|
|
|
|
|
|
} // namespace _ipdltest
|
|
} // namespace mozilla
|