Commit 335e0073 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Retrieve the proper script dispatch from the named item in GetScriptDispatch.

parent c2a5aa7d
......@@ -883,6 +883,7 @@ static HRESULT WINAPI JScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR
IDispatch **ppdisp)
{
JScript *This = impl_from_IActiveScript(iface);
jsdisp_t *script_obj;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(pstrItemName), ppdisp);
......@@ -894,7 +895,14 @@ static HRESULT WINAPI JScript_GetScriptDispatch(IActiveScript *iface, LPCOLESTR
return E_UNEXPECTED;
}
*ppdisp = to_disp(This->ctx->global);
script_obj = This->ctx->global;
if(pstrItemName) {
named_item_t *item = lookup_named_item(This->ctx, pstrItemName, 0);
if(!item) return E_INVALIDARG;
if(item->script_obj) script_obj = item->script_obj;
}
*ppdisp = to_disp(script_obj);
IDispatch_AddRef(*ppdisp);
return S_OK;
}
......
......@@ -1183,6 +1183,11 @@ static void test_named_items(void)
ok(visible_named_item_ref == 0, "visible_named_item_ref = %u\n", visible_named_item_ref);
ok(visible_code_named_item_ref == 0, "visible_code_named_item_ref = %u\n", visible_code_named_item_ref);
hr = IActiveScript_GetScriptDispatch(script, L"noContext", &disp);
ok(hr == E_INVALIDARG, "GetScriptDispatch returned: %08x\n", hr);
hr = IActiveScript_GetScriptDispatch(script, L"codeONLYItem", &disp);
ok(hr == E_INVALIDARG, "GetScriptDispatch returned: %08x\n", hr);
SET_EXPECT(GetItemInfo_global_code);
hr = IActiveScript_AddNamedItem(script, L"globalCodeItem", SCRIPTITEM_GLOBALMEMBERS | SCRIPTITEM_CODEONLY);
ok(hr == S_OK, "AddNamedItem failed: %08x\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment