diff --git a/mozilla/js/src/jsfun.c b/mozilla/js/src/jsfun.c index ae693551c94..b1431a35e3c 100644 --- a/mozilla/js/src/jsfun.c +++ b/mozilla/js/src/jsfun.c @@ -1411,6 +1411,7 @@ static JSBool fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { jsval fval, *sp, *oldsp; + JSObject *tmp; void *mark; uintN i; JSStackFrame *fp; @@ -1429,8 +1430,9 @@ fun_call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) } if (argc == 0) { - /* Call fun with its parent as the 'this' parameter if no args. */ - obj = OBJ_GET_PARENT(cx, obj); + /* Call fun with its global object as the 'this' param if no args. */ + while ((tmp = OBJ_GET_PARENT(cx, obj)) != NULL) + obj = tmp; } else { /* Otherwise convert the first arg to 'this' and skip over it. */ if (!js_ValueToObject(cx, argv[0], &obj))