jscript: Throw type error from call and apply functions.
authorJacek Caban <jacek@codeweavers.com>
Wed, 23 Sep 2009 22:45:42 +0000 (00:45 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 24 Sep 2009 11:30:45 +0000 (13:30 +0200)
dlls/jscript/function.c
dlls/jscript/tests/api.js

index 88bf9c3d9f62cd22e9603a77acf60d5ca7e32d3e..cbdc08b953ea594c1f545bb8fcf3711a79c07bb4 100644 (file)
@@ -416,13 +416,10 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DI
 
     TRACE("\n");
 
-    if(!(function = function_from_vdisp(jsthis))) {
-        FIXME("dispex is not a function\n");
-        return E_FAIL;
-    }
+    if(!(function = function_this(jsthis)))
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
 
     argc = arg_cnt(dp);
-
     if(argc) {
         hres = to_object(ctx, get_arg(dp,0), &this_obj);
         if(FAILED(hres))
@@ -471,10 +468,8 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DIS
 
     TRACE("\n");
 
-    if(!(function = function_from_vdisp(jsthis))) {
-        FIXME("dispex is not a function\n");
-        return E_FAIL;
-    }
+    if(!(function = function_this(jsthis)))
+        return throw_type_error(ctx, ei, IDS_NOT_FUNC, NULL);
 
     argc = arg_cnt(dp);
     if(argc) {
index 5b215f51b8b496e28b7d8dd017223d6378c0beab..2e4b0aaebd158c277c4a7d52316446e10ca48465 100644 (file)
@@ -1688,6 +1688,14 @@ function testArrayThis(func) {
 
 testArrayThis("toString");
 
+function testFunctionThis(func) {
+    testThisExcept(Function.prototype[func], -2146823286);
+}
+
+testFunctionThis("toString");
+testFunctionThis("call");
+testFunctionThis("apply");
+
 function testArrayHostThis(func) {
     exception_test(function() { Array.prototype[func].call(testObj); }, "TypeError", -2146823274);
 }