Module: wine Branch: master Commit: 40b36d4208509d73c9cc3c91e6ba1b1104c524aa URL: https://gitlab.winehq.org/wine/wine/-/commit/40b36d4208509d73c9cc3c91e6ba1b1...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Tue Oct 17 16:18:53 2023 +0300
jscript: Fix Array.map when last element doesn't exist.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/jscript/array.c | 6 ++++-- dlls/mshtml/tests/es5.js | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 48f665da576..c673b82fed2 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -1354,14 +1354,16 @@ static HRESULT Array_map(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned if(argc > 1) context_this = argv[1];
- hres = create_array(ctx, length, &array); + hres = create_array(ctx, 0, &array); if(FAILED(hres)) goto done;
for(k = 0; k < length; k++) { hres = jsdisp_get_idx(jsthis, k, &callback_args[0]); - if(hres == DISP_E_UNKNOWNNAME) + if(hres == DISP_E_UNKNOWNNAME) { + hres = S_OK; continue; + } if(FAILED(hres)) break;
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index 7e2f66daabf..fbcb1b42f3e 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -431,6 +431,13 @@ sync_test("array_map", function() { [1,2].map(function() { ok(this.valueOf() === 137, "this.valueOf() = " + this.valueOf()); }, 137); + + r = [1,,2,].map(function(x) { return "" + x; }); + ok(r.length === 3, "[1,,2,].map length = " + r.length); + ok(r[0] === "1", "[1,,2,].map[0] = " + r[0]); + ok(r[2] === "2", "[1,,2,].map[2] = " + r[2]); + ok(!("1" in r), "[1,,2,].map[1] exists"); + ok(!("3" in r), "[1,,2,].map[3] exists"); });
sync_test("array_sort", function() {