Module: wine Branch: master Commit: 6d69c6db51495281b1e4064066937d78aa24817a URL: https://source.winehq.org/git/wine.git/?a=commit;h=6d69c6db51495281b1e406406...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Mar 20 17:41:18 2019 +0100
jscript: Support undefined context value in Array.prototype.forEach.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/jscript/array.c | 17 +++++++++++------ dlls/mshtml/tests/es5.js | 7 +++++++ 2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index a7b1f02..0c54fc0 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -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) diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 0ee2eff..8e5b846 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -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(); }