Try harder to find a scope chain so that we can report exceptions when there is no code running currently. bug 390160, r=brendan sr=jst a=brendan

This commit is contained in:
mrbkap@gmail.com 2007-08-07 19:24:52 -07:00
Родитель 356f527fb9
Коммит ec27287d22
1 изменённых файлов: 18 добавлений и 2 удалений

Просмотреть файл

@ -1664,8 +1664,24 @@ JS_GetScopeChain(JSContext *cx)
fp = cx->fp;
if (!fp) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INACTIVE);
return NULL;
/*
* There is no code active on this context. In place of an actual
* scope chain, use the context's global object, which is set in
* js_InitFunctionAndObjectClasses, and which represents the default
* scope chain for the embedding. See also js_FindClassObject.
*
* For embeddings that use the inner and outer object hooks, the inner
* object represents the ultimate global object, with the outer object
* acting as a stand-in.
*/
JSObject *obj = cx->globalObject;
if (!obj) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INACTIVE);
return NULL;
}
OBJ_TO_INNER_OBJECT(cx, obj);
return obj;
}
return js_GetScopeChain(cx, fp);
}