зеркало из https://github.com/mozilla/gecko-dev.git
Bug 513065 - Part 3, Stay on trace when calculating scope in thisObject hook. r=mrbkap.
This commit is contained in:
Родитель
58e574769e
Коммит
68c0d0f642
|
@ -1683,6 +1683,31 @@ JS_GetGlobalForObject(JSContext *cx, JSObject *obj)
|
|||
return obj->getGlobal();
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSObject *)
|
||||
JS_GetGlobalForScopeChain(JSContext *cx)
|
||||
{
|
||||
/*
|
||||
* This is essentially JS_GetScopeChain(cx)->getGlobal(), but without
|
||||
* falling off trace.
|
||||
*
|
||||
* This use of cx->fp, possibly on trace, is deliberate:
|
||||
* cx->fp->scopeChain->getGlobal() returns the same object whether we're on
|
||||
* trace or not, since we do not trace calls across global objects.
|
||||
*/
|
||||
VOUCH_DOES_NOT_REQUIRE_STACK();
|
||||
|
||||
if (cx->fp)
|
||||
return cx->fp->scopeChain->getGlobal();
|
||||
|
||||
JSObject *scope = cx->globalObject;
|
||||
if (!scope) {
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INACTIVE);
|
||||
return NULL;
|
||||
}
|
||||
OBJ_TO_INNER_OBJECT(cx, scope);
|
||||
return scope;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(jsval)
|
||||
JS_ComputeThis(JSContext *cx, jsval *vp)
|
||||
{
|
||||
|
|
|
@ -825,6 +825,9 @@ JS_GetScopeChain(JSContext *cx);
|
|||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_GetGlobalForObject(JSContext *cx, JSObject *obj);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_GetGlobalForScopeChain(JSContext *cx);
|
||||
|
||||
#ifdef JS_HAS_CTYPES
|
||||
/*
|
||||
* Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes'
|
||||
|
|
|
@ -1488,15 +1488,13 @@ XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
|
|||
if(!obj)
|
||||
return nsnull;
|
||||
|
||||
JSObject *scope = JS_GetScopeChain(cx);
|
||||
JSObject *scope = JS_GetGlobalForScopeChain(cx);
|
||||
if(!scope)
|
||||
{
|
||||
XPCThrower::Throw(NS_ERROR_FAILURE, cx);
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
scope = JS_GetGlobalForObject(cx, scope);
|
||||
|
||||
XPCPerThreadData *threadData = XPCPerThreadData::GetData(cx);
|
||||
if(!threadData)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче