jscript: Fix GetIDsOfNames for more than one name.

Names after the first one are supposed to retrieve DISPIDs for parameters,
but it doesn't seem to be implemented on Windows.

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 2021-08-04 18:51:46 +03:00 committed by Alexandre Julliard
parent ecf6a16b8e
commit 678789c72f
2 changed files with 81 additions and 5 deletions

View File

@ -1489,13 +1489,21 @@ static HRESULT WINAPI DispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
lcid, rgDispId);
for(i=0; i < cNames; i++) {
hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
if(FAILED(hres))
return hres;
if(cNames == 0)
return S_OK;
hres = jsdisp_get_id(This, rgszNames[0], 0, rgDispId);
if(FAILED(hres))
return hres;
/* DISPIDs for parameters don't seem to be supported */
if(cNames > 1) {
for(i = 1; i < cNames; i++)
rgDispId[i] = DISPID_UNKNOWN;
hres = DISP_E_UNKNOWNNAME;
}
return S_OK;
return hres;
}
static HRESULT WINAPI DispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,

View File

@ -924,6 +924,73 @@ static void test_aggregation(void)
ok(!unk || broken(unk != NULL), "unk = %p\n", unk);
}
static void test_param_ids(void)
{
static const WCHAR *const names1[] = { L"test", L"c", L"foo", L"b", L"a" };
static const WCHAR *const names2[] = { L"test", L"bar" };
static const WCHAR *const names3[] = { L"bar", L"test" };
DISPID id[ARRAY_SIZE(names1)];
IActiveScriptParse *parser;
IActiveScript *script;
IDispatchEx *disp;
HRESULT hr;
script = create_jscript();
hr = IActiveScript_QueryInterface(script, &IID_IActiveScriptParse, (void**)&parser);
ok(hr == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hr);
SET_EXPECT(GetLCID);
hr = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
ok(hr == S_OK, "SetScriptSite failed: %08x\n", hr);
CHECK_CALLED(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
hr = IActiveScriptParse_InitNew(parser);
ok(hr == S_OK, "InitNew failed: %08x\n", hr);
CHECK_CALLED(OnStateChange_INITIALIZED);
SET_EXPECT(OnStateChange_CONNECTED);
hr = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
ok(hr == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hr);
CHECK_CALLED(OnStateChange_CONNECTED);
parse_script(parser, L"function test(a, b, c, foo) { return a + b + c - foo; }\nfunction bar() { }");
disp = get_script_dispatch(script, NULL);
hr = IDispatchEx_GetIDsOfNames(disp, &IID_NULL, (WCHAR**)names1, ARRAY_SIZE(names1), 0, id);
ok(hr == DISP_E_UNKNOWNNAME, "GetIDsOfNames returned %08x, expected %08x\n", hr, DISP_E_UNKNOWNNAME);
ok(id[0] > 0, "Unexpected DISPID for \"test\": %d\n", id[0]);
ok(id[4] == DISPID_UNKNOWN, "Unexpected DISPID for \"a\" parameter: %d\n", id[4]);
ok(id[3] == DISPID_UNKNOWN, "Unexpected DISPID for \"b\" parameter: %d\n", id[3]);
ok(id[1] == DISPID_UNKNOWN, "Unexpected DISPID for \"c\" parameter: %d\n", id[1]);
ok(id[2] == DISPID_UNKNOWN, "Unexpected DISPID for \"foo\" parameter: %d\n", id[2]);
hr = IDispatchEx_GetIDsOfNames(disp, &IID_NULL, (WCHAR**)names2, ARRAY_SIZE(names2), 0, id);
ok(hr == DISP_E_UNKNOWNNAME, "GetIDsOfNames returned %08x, expected %08x\n", hr, DISP_E_UNKNOWNNAME);
ok(id[0] > 0, "Unexpected DISPID for \"test\": %d\n", id[0]);
ok(id[1] == DISPID_UNKNOWN, "Unexpected DISPID for \"bar\": %d\n", id[1]);
hr = IDispatchEx_GetIDsOfNames(disp, &IID_NULL, (WCHAR**)names3, ARRAY_SIZE(names3), 0, id);
ok(hr == DISP_E_UNKNOWNNAME, "GetIDsOfNames returned %08x, expected %08x\n", hr, DISP_E_UNKNOWNNAME);
ok(id[0] > 0, "Unexpected DISPID for \"bar\": %d\n", id[0]);
ok(id[1] == DISPID_UNKNOWN, "Unexpected DISPID for \"test\": %d\n", id[1]);
IDispatchEx_Release(disp);
IActiveScriptParse_Release(parser);
SET_EXPECT(OnStateChange_DISCONNECTED);
SET_EXPECT(OnStateChange_INITIALIZED);
SET_EXPECT(OnStateChange_CLOSED);
hr = IActiveScript_Close(script);
ok(hr == S_OK, "Close failed: %08x\n", hr);
CHECK_CALLED(OnStateChange_DISCONNECTED);
CHECK_CALLED(OnStateChange_INITIALIZED);
CHECK_CALLED(OnStateChange_CLOSED);
IActiveScript_Release(script);
}
static void test_code_persistence(void)
{
IActiveScriptParse *parse;
@ -2251,6 +2318,7 @@ START_TEST(jscript)
test_jscript2();
test_jscript_uninitializing();
test_aggregation();
test_param_ids();
test_code_persistence();
test_named_items();
test_typeinfo(NULL);