From 4c5f7a4d5b98fe917bd2cc876ba737d1e6717e89 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 6 May 2014 23:17:43 -0700 Subject: [PATCH] Bug 1001198 - Stop firing onNewGlobalObject for the SafeJSContext global. r=gabor --- js/xpconnect/src/XPCJSContextStack.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/xpconnect/src/XPCJSContextStack.cpp b/js/xpconnect/src/XPCJSContextStack.cpp index 514d59951141..77028aa7d7e9 100644 --- a/js/xpconnect/src/XPCJSContextStack.cpp +++ b/js/xpconnect/src/XPCJSContextStack.cpp @@ -173,6 +173,13 @@ XPCJSContextStack::InitSafeJSContext() JS_SetErrorReporter(mSafeJSContext, xpc::SystemErrorReporter); + // Note - We intentionally avoid firing OnNewGlobalObject while + // simultaneously skipping the call to setInvisibleToDebugger(true) here. + // This lets us piggy-back on the assertions in the JS engine (which make + // sure that, for non-invisible globals, we always fire onNewGlobalObject + // before creating scripts), to assert that we never create scripts with + // the SafeJSContextGlobal. This is all happening way before anyone could be + // listening for debugger notifications anyway. JS::CompartmentOptions options; options.setZone(JS::SystemZone) .setTrace(TraceXPCGlobal); @@ -194,8 +201,5 @@ XPCJSContextStack::InitSafeJSContext() if (NS_FAILED(xpc->InitClasses(mSafeJSContext, mSafeJSContextGlobal))) MOZ_CRASH(); - JS::RootedObject glob(mSafeJSContext, mSafeJSContextGlobal); - JS_FireOnNewGlobalObject(mSafeJSContext, glob); - return mSafeJSContext; }