From c577d9d9ea3c1d42ca724fc53444ff2608041eff Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Sun, 17 Apr 2005 20:15:32 +0000 Subject: [PATCH] Follow ECMA when .call is passed zero args (290488, r=shaver, a=me). git-svn-id: svn://10.0.0.236/trunk@172377 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsfun.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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))