Jacek Caban : mshtml: Return VT_NULL instead of empty string in getAttribute.

Alexandre Julliard julliard at winehq.org
Thu Apr 24 15:56:42 CDT 2008


Module: wine
Branch: master
Commit: 872810e6419876c03d1d4c2a7dc69d77ab944338
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=872810e6419876c03d1d4c2a7dc69d77ab944338

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Apr 24 18:22:26 2008 +0200

mshtml: Return VT_NULL instead of empty string in getAttribute.

---

 dlls/mshtml/htmlelem.c  |    4 ++--
 dlls/mshtml/tests/dom.c |   33 +++++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 748faf6..67e19bd 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -178,7 +178,7 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
 
     WARN("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
 
-    VariantInit(AttributeValue);
+    V_VT(AttributeValue) = VT_NULL;
 
     nsAString_Init(&attr_str, strAttributeName);
     nsAString_Init(&value_str, NULL);
@@ -206,7 +206,7 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
                     TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
                 }
             }
-        }else {
+        }else if(*value) {
             V_VT(AttributeValue) = VT_BSTR;
             V_BSTR(AttributeValue) = SysAllocString(value);
             TRACE("attr_value=%s\n", debugstr_w(V_BSTR(AttributeValue)));
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 893a9c9..0bdeb16 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -58,6 +58,8 @@ static WCHAR wordW[] = {'w','o','r','d',0};
 
 static const WCHAR text_javascriptW[] = {'t','e','x','t','/','j','a','v','a','s','c','r','i','p','t',0};
 
+static const WCHAR idW[] = {'i','d',0};
+
 typedef enum {
     ET_NONE,
     ET_HTML,
@@ -364,6 +366,30 @@ static void _test_elem_type(unsigned line, IUnknown *unk, elem_type_t type)
         _test_disp(line, unk, elem_type_infos[type].dispiid);
 }
 
+#define test_elem_attr(e,n,v) _test_elem_attr(__LINE__,e,n,v)
+static void _test_elem_attr(unsigned line, IHTMLElement *elem, LPCWSTR name, LPCWSTR exval)
+{
+    VARIANT value;
+    BSTR tmp;
+    HRESULT hres;
+
+    VariantInit(&value);
+
+    tmp = SysAllocString(name);
+    hres = IHTMLElement_getAttribute(elem, tmp, 0, &value);
+    SysFreeString(tmp);
+    ok_(__FILE__,line) (hres == S_OK, "getAttribute failed: %08x\n", hres);
+
+    if(exval) {
+        ok_(__FILE__,line) (V_VT(&value) == VT_BSTR, "vt=%d\n", V_VT(&value));
+        ok_(__FILE__,line) (!lstrcmpW(exval, V_BSTR(&value)), "unexpected value %s\n", dbgstr_w(V_BSTR(&value)));
+    }else {
+        ok_(__FILE__,line) (V_VT(&value) == VT_NULL, "vt=%d\n", V_VT(&value));
+    }
+
+    VariantClear(&value);
+}
+
 static void test_doc_elem(IHTMLDocument2 *doc)
 {
     IHTMLElement *elem;
@@ -1400,9 +1426,12 @@ static void test_elems(IHTMLDocument2 *doc)
 
     elem = get_doc_elem_by_id(doc, sW);
     ok(elem != NULL, "elem == NULL\n");
-    test_elem_type((IUnknown*)elem, ET_SELECT);
-    if(elem)
+    if(elem) {
+        test_elem_type((IUnknown*)elem, ET_SELECT);
+        test_elem_attr(elem, xxxW, NULL);
+        test_elem_attr(elem, idW, sW);
         IHTMLElement_Release(elem);
+    }
 
     elem = get_elem_by_id(doc, sW, TRUE);
     if(elem) {




More information about the wine-cvs mailing list