diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 2fd410ec5e1..ebb9bf9fa22 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -2519,10 +2519,9 @@ js::CloneFunctionScript(JSContext *cx, HandleFunction original, HandleFunction c clone->setScript(cscript); cscript->setFunction(clone); - RootedGlobalObject global(cx, script->compileAndGo ? &script->global() : NULL); - script = clone->nonLazyScript(); CallNewScriptHook(cx, script, clone); + RootedGlobalObject global(cx, script->compileAndGo ? &script->global() : NULL); Debugger::onNewScript(cx, script, global); return true; diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index 81162702dc8..dc155885e41 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -676,6 +676,7 @@ void Debugger::onNewScript(JSContext *cx, HandleScript script, GlobalObject *compileAndGoGlobal) { JS_ASSERT_IF(script->compileAndGo, compileAndGoGlobal); + JS_ASSERT_IF(script->compileAndGo, compileAndGoGlobal == &script->global()); JS_ASSERT_IF(!script->compileAndGo, !compileAndGoGlobal); if (!script->compartment()->getDebuggees().empty()) slowPathOnNewScript(cx, script, compileAndGoGlobal);