mshtml: Properly convert VT_NULL to string in get_elem_attr_value_by_dispid.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-01-05 18:53:21 +01:00 committed by Alexandre Julliard
parent ad1d215774
commit f394dca92a
2 changed files with 20 additions and 1 deletions

View File

@ -644,6 +644,8 @@ HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD fl
EXCEPINFO excep;
HRESULT hres;
static const WCHAR nullW[] = {'n','u','l','l',0};
hres = IDispatchEx_InvokeEx(&elem->node.event_target.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYGET, &dispParams, ret, &excep, NULL);
if(FAILED(hres))
@ -653,6 +655,12 @@ HRESULT get_elem_attr_value_by_dispid(HTMLElement *elem, DISPID dispid, DWORD fl
switch(V_VT(ret)) {
case VT_BSTR:
break;
case VT_NULL:
V_BSTR(ret) = SysAllocString(nullW);
if(!V_BSTR(ret))
return E_OUTOFMEMORY;
V_VT(ret) = VT_BSTR;
break;
case VT_DISPATCH:
IDispatch_Release(V_DISPATCH(ret));
V_VT(ret) = VT_BSTR;

View File

@ -1411,8 +1411,19 @@ static void test_get_set_attr(IHTMLDocument2 *doc)
ok(V_VT(&val) == VT_BOOL, "variant type should have been VT_BOOL (0x%x), was: 0x%x\n", VT_BOOL, V_VT(&val));
ok(V_BOOL(&val) == VARIANT_TRUE, "variant value should have been VARIANT_TRUE (0x%x), was %d\n", VARIANT_TRUE, V_BOOL(&val));
VariantClear(&val);
SysFreeString(bstr);
/* overwrite the attribute with null */
V_VT(&val) = VT_NULL;
hres = IHTMLElement_setAttribute(elem, bstr, val, 0);
ok(hres == S_OK, "setAttribute failed: %08x\n", hres);
hres = IHTMLElement_getAttribute(elem, bstr, 2, &val);
ok(hres == S_OK, "getAttribute failed: %08x\n", hres);
ok(V_VT(&val) == VT_BSTR, "V_VT(val) = %u, expected VT_BSTR", V_VT(&val));
ok(!strcmp_wa(V_BSTR(&val), "null"), "V_BSTR(val) = %s, expected \"null\"\n", wine_dbgstr_w(V_BSTR(&val)));
VariantClear(&val);
SysFreeString(bstr);
IHTMLElement_Release(elem);
}