Bug 607174 - Add assertions to jsdbgapi.cpp and enter compartments where it isn't possible for the caller to do so. landing with r=gal

--HG--
extra : rebase_source : f0e69380a0ef144e07af7d75b859712fe67bb753
This commit is contained in:
Blake Kaplan 2010-10-26 19:48:51 -07:00
parent 19f2ee298f
commit 5393af7080
4 changed files with 33 additions and 2 deletions

View File

@ -2316,7 +2316,13 @@ jsdValue::GetWrappedValue()
if (result)
{
JSContext *cx;
rv = cc->GetJSContext(&cx);
if (NS_FAILED(rv))
return rv;
*result = JSD_GetValueWrappedJSVal (mCx, mValue);
if (!JS_WrapValue(cx, result))
return NS_ERROR_FAILURE;
cc->SetReturnValueWasSet(PR_TRUE);
}

View File

@ -2635,10 +2635,10 @@ Call(JSContext *cx, jsval thisv, JSObject *funObj, uintN argc, jsval *argv, jsva
return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval);
}
} // namespace JS
} /* namespace JS */
JS_BEGIN_EXTERN_C
#endif // __cplusplus
#endif /* __cplusplus */
/*
* These functions allow setting an operation callback that will be called

View File

@ -570,6 +570,10 @@ class CompartmentChecker
}
}
void check(JSStackFrame *fp) {
check(&fp->scopeChain());
}
void check(JSString *) { /* nothing for now */ }
};

View File

@ -62,6 +62,7 @@
#include "jsscript.h"
#include "jsstaticcheck.h"
#include "jsstr.h"
#include "jswrapper.h"
#include "jsatominlines.h"
#include "jsinterpinlines.h"
@ -1180,6 +1181,10 @@ JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp)
{
JS_ASSERT(cx->stack().contains(fp));
js::AutoCompartment ac(cx, &fp->scopeChain());
if (!ac.enter())
return NULL;
/* Force creation of argument and call objects if not yet created */
(void) JS_GetFrameCallObject(cx, fp);
return js_GetScopeChain(cx, fp);
@ -1193,6 +1198,10 @@ JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp)
if (!fp->isFunctionFrame())
return NULL;
js::AutoCompartment ac(cx, &fp->scopeChain());
if (!ac.enter())
return NULL;
/* Force creation of argument object if not yet created */
(void) js_GetArgsObject(cx, fp);
@ -1208,6 +1217,11 @@ JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv)
{
if (fp->isDummyFrame())
return false;
js::AutoCompartment ac(cx, &fp->scopeChain());
if (!ac.enter())
return false;
if (!fp->computeThis(cx))
return false;
*thisv = Jsvalify(fp->thisValue());
@ -1269,6 +1283,7 @@ JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp)
JS_PUBLIC_API(void)
JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval)
{
assertSameCompartment(cx, fp, rval);
fp->setReturnValue(Valueify(rval));
}
@ -1332,6 +1347,10 @@ JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
if (!scobj)
return false;
js::AutoCompartment ac(cx, scobj);
if (!ac.enter())
return NULL;
/*
* NB: This function breaks the assumption that the compiler can see all
* calls and properly compute a static level. In order to get around this,
@ -1404,6 +1423,7 @@ JS_PUBLIC_API(JSBool)
JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
JSPropertyDesc *pd)
{
assertSameCompartment(cx, obj);
Shape *shape = (Shape *) sprop;
pd->id = IdToJsval(shape->id);
@ -1457,6 +1477,7 @@ JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *sprop,
JS_PUBLIC_API(JSBool)
JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda)
{
assertSameCompartment(cx, obj);
Class *clasp = obj->getClass();
if (!obj->isNative() || (clasp->flags & JSCLASS_NEW_ENUMERATE)) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,