diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 9b4314275d2..0af6df1c6dc 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -74,10 +74,8 @@ static HRESULT Array_length(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAM else len = floor(V_R8(&num)); - if(len!=(DWORD)len) { - FIXME("Throw RangeError\n"); - return E_FAIL; - } + if(len!=(DWORD)len) + return throw_range_error(dispex->ctx, ei, IDS_INVALID_LENGTH, NULL); for(i=len; ilength; i++) { hres = jsdisp_delete_idx(dispex, i); @@ -850,10 +848,8 @@ static HRESULT ArrayConstr_value(DispatchEx *dispex, LCID lcid, WORD flags, DISP case DISPATCH_METHOD: case DISPATCH_CONSTRUCT: { if(arg_cnt(dp) == 1 && V_VT((arg_var = get_arg(dp, 0))) == VT_I4) { - if(V_I4(arg_var) < 0) { - FIXME("throw RangeError\n"); - return E_FAIL; - } + if(V_I4(arg_var) < 0) + return throw_range_error(dispex->ctx, ei, IDS_INVALID_LENGTH, NULL); hres = create_array(dispex->ctx, V_I4(arg_var), &obj); if(FAILED(hres)) diff --git a/dlls/jscript/jscript_En.rc b/dlls/jscript/jscript_En.rc index cee271889ec..161b761c419 100644 --- a/dlls/jscript/jscript_En.rc +++ b/dlls/jscript/jscript_En.rc @@ -23,4 +23,5 @@ LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT STRINGTABLE DISCARDABLE { IDS_NOT_DATE "'[object]' is not a date object" + IDS_INVALID_LENGTH "Array length must be a finite positive integer" } diff --git a/dlls/jscript/resource.h b/dlls/jscript/resource.h index e0f66613c66..5041e2792d4 100644 --- a/dlls/jscript/resource.h +++ b/dlls/jscript/resource.h @@ -19,3 +19,4 @@ #include #define IDS_NOT_DATE 0x138E +#define IDS_INVALID_LENGTH 0x13A5 diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index 36fb191c1ec..f36ec80901e 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -1298,5 +1298,6 @@ function exception_test(func, type) { ok(ret === type, "Exception test, ret = " + ret + ", expected " + type +". Executed function: " + func.toString()); } exception_test(function() {arr.toString = Date.prototype.toString; arr.toString();}, "TypeError"); +exception_test(function() {Array(-3);}, "RangeError"); reportSuccess();