Commit 6d69c6db authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Support undefined context value in Array.prototype.forEach.

parent ec8a3a78
......@@ -959,16 +959,21 @@ static HRESULT Array_forEach(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
TRACE("\n");
/* FIXME: Check IsCallable */
if(argc != 1 || !is_object_instance(argv[0])) {
FIXME("Unsupported arguments\n");
return E_NOTIMPL;
}
hres = get_length(ctx, vthis, &jsthis, &length);
if(FAILED(hres))
return hres;
/* Fixme check IsCallable */
if(!argc || !is_object_instance(argv[0]) || !get_object(argv[0])) {
FIXME("Invalid arg %s\n", debugstr_jsval(argc ? argv[0] : jsval_undefined()));
return E_INVALIDARG;
}
if(argc > 1 && !is_undefined(argv[1])) {
FIXME("Unsupported context this %s\n", debugstr_jsval(argv[1]));
return E_NOTIMPL;
}
for(i = 0; i < length; i++) {
hres = jsdisp_get_idx(jsthis, i, &value);
if(hres == DISP_E_UNKNOWNNAME)
......
......@@ -109,6 +109,13 @@ function test_array_forEach() {
test(new String("abc"), [[0,"a"],[1,"b"],[2,"c"]]);
test([], []);
[1,2].forEach(function() {
ok(this === window, "this != window");
});
[1,2].forEach(function() {
ok(this === window, "this != window");
}, undefined);
next_test();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment