diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index 82a6dc329e26..27b3faf1cc90 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -60,6 +60,9 @@ #include "nsIScriptContext.h" #include "nsIJSContextStack.h" +/* XXX private JS headers. */ +#include "jscompartment.h" + /* * defining CAUTIOUS_SCRIPTHOOK makes jsds disable GC while calling out to the * script hook. This was a hack to avoid some js engine problems that should @@ -1319,10 +1322,14 @@ jsdScript::GetFunctionSource(nsAString & aFunctionSource) JSAutoRequest ar(cx); JSString *jsstr; - if (fun) + if (fun) { + JSAutoEnterCompartment ac; + if (!ac.enter(cx, JS_GetFunctionObject(fun))) + return NS_ERROR_FAILURE; jsstr = JS_DecompileFunction (cx, fun, 4); - else { + } else { JSScript *script = JSD_GetJSScript (mCx, mScript); + js::SwitchToCompartment sc(cx, script->compartment); jsstr = JS_DecompileScript (cx, script, "ppscript", 4); } if (!jsstr) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index e995585841db..b4ab6eab2554 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4744,7 +4744,10 @@ JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN inde JSString *str; CHECK_REQUEST(cx); - assertSameCompartment(cx, script); +#ifdef DEBUG + if (cx->compartment != script->compartment) + CompartmentChecker::fail(cx->compartment, script->compartment); +#endif jp = js_NewPrinter(cx, name, NULL, indent & ~JS_DONT_PRETTY_PRINT, !(indent & JS_DONT_PRETTY_PRINT),