diff --git a/js/src/jsfun.c b/js/src/jsfun.c index c12d43e8180..f3788430e52 100644 --- a/js/src/jsfun.c +++ b/js/src/jsfun.c @@ -278,7 +278,7 @@ js_GetArgsObject(JSContext *cx, JSStackFrame *fp) static JSBool args_enumerate(JSContext *cx, JSObject *obj); -JSBool +JS_FRIEND_API(JSBool) js_PutArgsObject(JSContext *cx, JSStackFrame *fp) { JSObject *argsobj; @@ -589,7 +589,6 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent) callobj = fp->callobj; if (callobj) return callobj; - JS_ASSERT(fp->fun); /* The default call parent is its function's parent (static link). */ if (!parent) { @@ -616,7 +615,7 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent) static JSBool call_enumerate(JSContext *cx, JSObject *obj); -JSBool +JS_FRIEND_API(JSBool) js_PutCallObject(JSContext *cx, JSStackFrame *fp) { JSObject *callobj; diff --git a/js/src/jsfun.h b/js/src/jsfun.h index 3b331874f1b..7f83e602d11 100644 --- a/js/src/jsfun.h +++ b/js/src/jsfun.h @@ -175,7 +175,7 @@ js_ReportIsNotFunction(JSContext *cx, jsval *vp, uintN flags); extern JSObject * js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent); -extern JSBool +extern JS_FRIEND_API(JSBool) js_PutCallObject(JSContext *cx, JSStackFrame *fp); extern JSBool @@ -193,7 +193,7 @@ js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, jsval *vp); extern JSObject * js_GetArgsObject(JSContext *cx, JSStackFrame *fp); -extern JSBool +extern JS_FRIEND_API(JSBool) js_PutArgsObject(JSContext *cx, JSStackFrame *fp); extern JSBool diff --git a/js/src/liveconnect/nsCLiveconnect.cpp b/js/src/liveconnect/nsCLiveconnect.cpp index 3107856435e..d89564a0cd1 100644 --- a/js/src/liveconnect/nsCLiveconnect.cpp +++ b/js/src/liveconnect/nsCLiveconnect.cpp @@ -53,7 +53,11 @@ #include "jsj_private.h" #include "jsjava.h" +#include "jsdbgapi.h" +#include "jsarena.h" +#include "jsfun.h" #include "jscntxt.h" /* For js_ReportErrorAgain().*/ +#include "jsscript.h" #include "netscape_javascript_JSObject.h" /* javah-generated headers */ #include "nsISecurityContext.h" @@ -174,12 +178,18 @@ AutoPushJSContext::AutoPushJSContext(nsISupports* aSecuritySupports, JSPrincipals* jsprinc; principal->GetJSPrincipals(cx, &jsprinc); - mFrame.script = JS_CompileScriptForPrincipals(cx, JS_GetGlobalObject(cx), - jsprinc, "", 0, "", 1); + JSFunction *fun = JS_CompileFunctionForPrincipals(cx, JS_GetGlobalObject(cx), + jsprinc, "anonymous", 0, nsnull, + "", 0, "", 1); JSPRINCIPALS_DROP(cx, jsprinc); - if (mFrame.script) + if (fun) { + mFrame.fun = fun; + mFrame.script = JS_GetFunctionScript(cx, fun); + mFrame.pc = mFrame.script->code; + mFrame.callee = JS_GetFunctionObject(fun); + mFrame.scopeChain = JS_GetParent(cx, mFrame.callee); mFrame.down = cx->fp; cx->fp = &mFrame; } @@ -194,6 +204,11 @@ AutoPushJSContext::~AutoPushJSContext() if (mContextStack) mContextStack->Pop(nsnull); + if (mFrame.callobj) + js_PutCallObject(mContext, &mFrame); + if (mFrame.argsobj) + js_PutArgsObject(mContext, &mFrame); + JS_ClearPendingException(mContext); if (mFrame.script) mContext->fp = mFrame.down;