jscript: Pass the Map object to the callback when iterating.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2022-04-14 19:24:42 +03:00 committed by Alexandre Julliard
parent 477026a55b
commit 399f8b6f06
2 changed files with 4 additions and 2 deletions

View File

@ -179,11 +179,12 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j
}
LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) {
jsval_t args[2], v;
jsval_t args[3], v;
if(entry->deleted)
continue;
args[0] = entry->value;
args[1] = entry->key;
args[2] = jsval_obj(&map->dispex);
grab_map_entry(entry);
hres = disp_call_value(ctx, get_object(argv[0]), NULL, DISPATCH_METHOD,
ARRAY_SIZE(args), args, &v);

View File

@ -995,7 +995,7 @@ sync_test("map_obj", function() {
var calls = [];
i = 0;
r = s.forEach(function(value, key) {
r = s.forEach(function(value, key, map) {
if(isNaN(test_keys[i])) {
ok(isNaN(key), "key = " + key + " expected NaN");
ok(isNaN(value), "value = " + value + " expected NaN");
@ -1003,6 +1003,7 @@ sync_test("map_obj", function() {
ok(key === test_keys[i], "key = " + key + " expected " + test_keys[i]);
ok(value === key + 1, "value = " + value);
}
ok(map === s, "map = " + map);
i++;
});
ok(i === test_keys.length, "i = " + i);