Jacek Caban : mshtml: Return NULL instead of empty string in IHTMLElement: :get_className.
Alexandre Julliard
julliard at winehq.org
Mon Jun 23 16:03:58 CDT 2008
Module: wine
Branch: master
Commit: 0497c9896154350512282668e48ba4e01e0c3172
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0497c9896154350512282668e48ba4e01e0c3172
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Jun 23 09:51:28 2008 -0500
mshtml: Return NULL instead of empty string in IHTMLElement::get_className.
---
dlls/mshtml/htmlelem.c | 2 +-
dlls/mshtml/tests/dom.c | 21 ++++++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index d4e1d4d..8956065 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -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;
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index eb07b90..e67ca76 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -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);
More information about the wine-cvs
mailing list