From 84f7f601925f261d8bacf9d031c579ccd65fbff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Tue, 22 Nov 2022 18:53:20 +0200 Subject: [PATCH] jscript: Throw proper error when calling Map constructor as method. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu --- dlls/jscript/set.c | 3 +++ dlls/mshtml/tests/documentmode.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c index 4e2c1ffb33f..09f3746740c 100644 --- a/dlls/jscript/set.c +++ b/dlls/jscript/set.c @@ -417,6 +417,9 @@ static HRESULT Map_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, uns *r = jsval_obj(&map->dispex); return S_OK; + case DISPATCH_METHOD: + return throw_error(ctx, JS_E_WRONG_THIS, L"Map"); + default: FIXME("unimplemented flags %x\n", flags); return E_NOTIMPL; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index f968fae00df..c6a12203af6 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1301,6 +1301,13 @@ sync_test("set_obj", function() { sync_test("map_obj", function() { if(!("Map" in window)) return; + try { + var s = Map(); + ok(false, "expected exception calling constructor as method"); + }catch(e) { + ok(e.number === 0xa13fc - 0x80000000, "calling constructor as method threw " + e.number); + } + var s = new Map, r, i; ok(Object.getPrototypeOf(s) === Map.prototype, "unexpected Map prototype");