Bug 897322 - Assert when scripts are created that we've fired onNewGlobalObject. r=jimb

This commit is contained in:
Bobby Holley 2013-08-01 18:38:47 -07:00
parent 629aa44c5b
commit fa44cda1c7
3 changed files with 16 additions and 0 deletions

View File

@ -42,6 +42,9 @@ JSCompartment::JSCompartment(Zone *zone, const JS::CompartmentOptions &options =
principals(NULL),
isSystem(false),
marked(true),
#ifdef DEBUG
firedOnNewGlobalObject(false),
#endif
global_(NULL),
enterCompartmentDepth(0),
lastCodeRelease(0),

View File

@ -130,6 +130,10 @@ struct JSCompartment
bool isSystem;
bool marked;
#ifdef DEBUG
bool firedOnNewGlobalObject;
#endif
void mark() { marked = true; }
private:

View File

@ -677,6 +677,11 @@ Debugger::onNewScript(JSContext *cx, HandleScript script, GlobalObject *compileA
{
JS_ASSERT_IF(script->compileAndGo, compileAndGoGlobal);
JS_ASSERT_IF(script->compileAndGo, compileAndGoGlobal == &script->global());
// We early return in slowPathOnNewScript for self-hosted scripts, so we can
// ignore those in our assertion here.
JS_ASSERT_IF(!script->compartment()->options().invisibleToDebugger &&
!script->selfHosted,
script->compartment()->firedOnNewGlobalObject);
JS_ASSERT_IF(!script->compileAndGo, !compileAndGoGlobal);
if (!script->compartment()->getDebuggees().empty())
slowPathOnNewScript(cx, script, compileAndGoGlobal);
@ -685,6 +690,10 @@ Debugger::onNewScript(JSContext *cx, HandleScript script, GlobalObject *compileA
void
Debugger::onNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global)
{
JS_ASSERT(!global->compartment()->firedOnNewGlobalObject);
#ifdef DEBUG
global->compartment()->firedOnNewGlobalObject = true;
#endif
if (!JS_CLIST_IS_EMPTY(&cx->runtime()->onNewGlobalObjectWatchers))
Debugger::slowPathOnNewGlobalObject(cx, global);
}