Bug 1103324 - Instantiate an AutoNoJSAPI when dispatching IPC messages. r=billm

This commit is contained in:
Bobby Holley 2014-12-06 09:51:14 -08:00
parent 0dc2747b42
commit 6e61fa1c76
3 changed files with 16 additions and 1 deletions

View File

@ -104,11 +104,18 @@ InitScriptSettings()
sScriptSettingsTLS.set(nullptr);
}
void DestroyScriptSettings()
void
DestroyScriptSettings()
{
MOZ_ASSERT(sScriptSettingsTLS.get() == nullptr);
}
bool
ScriptSettingsInitialized()
{
return sScriptSettingsTLS.initialized();
}
ScriptSettingsStackEntry::ScriptSettingsStackEntry(nsIGlobalObject *aGlobal,
bool aCandidate)
: mGlobalObject(aGlobal)

View File

@ -63,6 +63,7 @@ private:
*/
void InitScriptSettings();
void DestroyScriptSettings();
bool ScriptSettingsInitialized();
/*
* Static helpers in ScriptSettings which track the number of listeners

View File

@ -8,6 +8,8 @@
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/Assertions.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Move.h"
@ -79,6 +81,8 @@
using namespace mozilla;
using namespace std;
using mozilla::dom::AutoNoJSAPI;
using mozilla::dom::ScriptSettingsInitialized;
using mozilla::MonitorAutoLock;
using mozilla::MonitorAutoUnlock;
@ -1058,6 +1062,9 @@ MessageChannel::OnMaybeDequeueOne()
void
MessageChannel::DispatchMessage(const Message &aMsg)
{
Maybe<AutoNoJSAPI> nojsapi;
if (ScriptSettingsInitialized() && NS_IsMainThread())
nojsapi.emplace();
if (aMsg.is_sync())
DispatchSyncMessage(aMsg);
else if (aMsg.is_interrupt())