mshtml: Return NULL instead of empty string in IHTMLElement::get_className.

This commit is contained in:
Jacek Caban 2008-06-23 09:51:28 -05:00 committed by Alexandre Julliard
parent 39c7951cf1
commit 0497c98961
2 changed files with 21 additions and 2 deletions

View File

@ -276,7 +276,7 @@ static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
if(NS_SUCCEEDED(nsres)) {
const PRUnichar *class;
nsAString_GetData(&class_str, &class);
*p = SysAllocString(class);
*p = *class ? SysAllocString(class) : NULL;
}else {
ERR("GetClassName failed: %08x\n", nsres);
hres = E_FAIL;

View File

@ -42,7 +42,7 @@ static const char elem_test_str[] =
"<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
"<body>text test<!-- a comment -->"
"<a href=\"http://test\" name=\"x\">link</a>"
"<input id=\"in\" />"
"<input id=\"in\" class=\"testclass\"/>"
"<select id=\"s\"><option id=\"x\">opt1</option><option id=\"y\">opt2</option></select>"
"<textarea id=\"X\">text text</textarea>"
"<table><tbody></tbody></table>"
@ -918,6 +918,23 @@ static IHTMLDOMChildrenCollection *_get_child_nodes(unsigned line, IUnknown *unk
return col;
}
#define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
{
IHTMLElement *elem = _get_elem_iface(line, unk);
BSTR class = (void*)0xdeadbeef;
HRESULT hres;
hres = IHTMLElement_get_className(elem, &class);
IHTMLElement_Release(elem);
ok_(__FILE__,line) (hres == S_OK, "get_className failed: %08x\n", hres);
if(exclass)
ok_(__FILE__,line) (!strcmp_wa(class, exclass), "unexpected className %s\n", dbgstr_w(class));
else
ok_(__FILE__,line) (!class, "class != NULL\n");
SysFreeString(class);
}
#define get_child_item(c,i) _get_child_item(__LINE__,c,i)
static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, long idx)
{
@ -1786,6 +1803,7 @@ static void test_elems(IHTMLDocument2 *doc)
test_elem_type((IUnknown*)elem, ET_SELECT);
test_elem_attr(elem, xxxW, NULL);
test_elem_attr(elem, idW, sW);
test_elem_class((IUnknown*)elem, NULL);
IHTMLElement_Release(elem);
}
@ -1846,6 +1864,7 @@ static void test_elems(IHTMLDocument2 *doc)
test_input_value((IUnknown*)elem, NULL);
test_input_put_value((IUnknown*)elem, "test");
test_input_value((IUnknown*)elem, NULL);
test_elem_class((IUnknown*)elem, "testclass");
IHTMLInputElement_Release(input);
IHTMLElement_Release(elem);