From 85331da4309ec93c360cce974fc7359fd38130cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Wed, 13 Nov 2024 19:32:43 +0200 Subject: [PATCH] jscript: Add basic semi-stub implementation of GetMemberProperties. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add tests for GetMemberName and DeleteMemberBy* which we did not have. Signed-off-by: Gabriel Ivăncescu --- dlls/jscript/dispex.c | 17 ++++++++- dlls/jscript/tests/run.c | 80 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 2 deletions(-) diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 91fa2c00cf4..7d5ebe2c863 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -2322,8 +2322,21 @@ static HRESULT WINAPI DispatchEx_DeleteMemberByDispID(IWineJSDispatch *iface, DI static HRESULT WINAPI DispatchEx_GetMemberProperties(IWineJSDispatch *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex) { jsdisp_t *This = impl_from_IWineJSDispatch(iface); - FIXME("(%p)->(%lx %lx %p)\n", This, id, grfdexFetch, pgrfdex); - return E_NOTIMPL; + dispex_prop_t *prop; + + TRACE("(%p)->(%lx %lx %p)\n", This, id, grfdexFetch, pgrfdex); + + prop = get_prop(This, id); + if(!prop) + return DISP_E_MEMBERNOTFOUND; + *pgrfdex = 0; + + if(grfdexFetch) { + FIXME("unimplemented flags %08lx\n", grfdexFetch); + return E_NOTIMPL; + } + + return S_OK; } static HRESULT WINAPI DispatchEx_GetMemberName(IWineJSDispatch *iface, DISPID id, BSTR *pbstrName) diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c index 1a92dca6dbb..106fd8c99d4 100644 --- a/dlls/jscript/tests/run.c +++ b/dlls/jscript/tests/run.c @@ -3641,6 +3641,85 @@ static void test_invokeex(void) IActiveScript_Release(script); } +static void test_members(void) +{ + DISPID func_id, prop_id; + IActiveScript *script; + IDispatchEx *dispex; + DWORD propflags; + HRESULT hres; + VARIANT v; + BSTR str; + + hres = parse_script_expr(L"var o = { func: function() {}, prop: 1 }; o", &v, &script); + ok(hres == S_OK, "parse_script_expr failed: %08lx\n", hres); + ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v)); + + hres = IDispatch_QueryInterface(V_DISPATCH(&v), &IID_IDispatchEx, (void**)&dispex); + ok(hres == S_OK, "Could not get IDispatchEx iface: %08lx\n", hres); + VariantClear(&v); + + str = SysAllocString(L"func"); + hres = IDispatchEx_GetDispID(dispex, str, 0, &func_id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID failed: %08lx\n", hres); + + str = SysAllocString(L"prop"); + hres = IDispatchEx_GetDispID(dispex, str, 0, &prop_id); + SysFreeString(str); + ok(hres == S_OK, "GetDispID failed: %08lx\n", hres); + + hres = IDispatchEx_GetMemberName(dispex, func_id, &str); + ok(hres == S_OK, "GetMemberName failed: %08lx\n", hres); + ok(!wcscmp(str, L"func"), "GetMemberName returned %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + hres = IDispatchEx_GetMemberName(dispex, prop_id, &str); + ok(hres == S_OK, "GetMemberName failed: %08lx\n", hres); + ok(!wcscmp(str, L"prop"), "GetMemberName returned %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + propflags = 0xdeadbeef; + hres = IDispatchEx_GetMemberProperties(dispex, func_id, 0, &propflags); + ok(hres == S_OK, "GetMemberProperties failed: %08lx\n", hres); + ok(propflags == 0, "propflags = %08lx", propflags); + + propflags = 0xdeadbeef; + hres = IDispatchEx_GetMemberProperties(dispex, prop_id, 0, &propflags); + ok(hres == S_OK, "GetMemberProperties failed: %08lx\n", hres); + ok(propflags == 0, "propflags = %08lx", propflags); + + hres = IDispatchEx_DeleteMemberByDispID(dispex, func_id); + ok(hres == S_OK, "DeleteMemberByDispID failed: %08lx\n", hres); + + hres = IDispatchEx_GetMemberName(dispex, func_id, &str); + ok(hres == DISP_E_MEMBERNOTFOUND, "GetMemberName failed: %08lx\n", hres); + hres = IDispatchEx_GetMemberProperties(dispex, func_id, 0, &propflags); + ok(hres == DISP_E_MEMBERNOTFOUND, "GetMemberProperties failed: %08lx\n", hres); + + hres = IDispatchEx_GetMemberName(dispex, prop_id, &str); + ok(hres == S_OK, "GetMemberName failed: %08lx\n", hres); + ok(!wcscmp(str, L"prop"), "GetMemberName returned %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + propflags = 0xdeadbeef; + hres = IDispatchEx_GetMemberProperties(dispex, prop_id, 0, &propflags); + ok(hres == S_OK, "GetMemberProperties failed: %08lx\n", hres); + ok(propflags == 0, "propflags = %08lx", propflags); + + str = SysAllocString(L"prop"); + hres = IDispatchEx_DeleteMemberByName(dispex, str, 0); + ok(hres == S_OK, "DeleteMemberByName failed: %08lx\n", hres); + SysFreeString(str); + + hres = IDispatchEx_GetMemberName(dispex, prop_id, &str); + ok(hres == DISP_E_MEMBERNOTFOUND, "GetMemberName failed: %08lx\n", hres); + hres = IDispatchEx_GetMemberProperties(dispex, prop_id, 0, &propflags); + ok(hres == DISP_E_MEMBERNOTFOUND, "GetMemberProperties failed: %08lx\n", hres); + + IDispatchEx_Release(dispex); + IActiveScript_Release(script); +} + static void test_destructors(void) { static const WCHAR cyclic_refs[] = L"(function() {\n" @@ -4299,6 +4378,7 @@ static BOOL run_tests(void) test_script_exprs(); test_invokeex(); + test_members(); test_destructors(); test_eval(); test_error_reports();