Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/jscript/set.c | 14 +++++++++----- dlls/mshtml/tests/documentmode.js | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index dd6829d..281049a 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -166,6 +166,7 @@ static HRESULT set_map_entry(MapInstance *map, jsval_t key, jsval_t value, jsval static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, jsval_t *argv, jsval_t *r) { struct jsval_map_entry *entry; + IDispatch *context_obj = NULL; HRESULT hres;
if(!argc || !is_object_instance(argv[0])) { @@ -173,9 +174,12 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j return E_FAIL; }
- if(argc > 1) { - FIXME("Unsupported argument\n"); - return E_NOTIMPL; + if(argc > 1 && !is_undefined(argv[1])) { + if(!is_object_instance(argv[1])) { + FIXME("Unsupported context this %s\n", debugstr_jsval(argv[1])); + return E_NOTIMPL; + } + context_obj = get_object(argv[1]); }
LIST_FOR_EACH_ENTRY(entry, &map->entries, struct jsval_map_entry, list_entry) { @@ -186,8 +190,8 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j 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); + hres = disp_call_value(ctx, get_object(argv[0]), context_obj, + DISPATCH_METHOD, ARRAY_SIZE(args), args, &v); release_map_entry(entry); if(FAILED(hres)) return hres; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index ed41ac1..0da8d12 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1004,8 +1004,9 @@ sync_test("map_obj", function() { ok(value === key + 1, "value = " + value); } ok(map === s, "map = " + map); + ok(this === test_keys, "this = " + this); i++; - }); + }, test_keys); ok(i === test_keys.length, "i = " + i); ok(r === undefined, "forEach returned " + r);