>From e8311e761fbf9d5004d55084464121c6675d50fc Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Tue, 22 Nov 2011 23:02:54 +0300
Subject: [PATCH 1/1] Fixed ISupportErrorInfo for IXMLDOMNamedNodeMap

---
 dlls/msxml3/nodemap.c      |    7 +++--
 dlls/msxml3/tests/domdoc.c |   55 ++++++++++++++++++++++++++++++++++++-------
 2 files changed, 50 insertions(+), 12 deletions(-)

diff --git a/dlls/msxml3/nodemap.c b/dlls/msxml3/nodemap.c
index d8cc8f3..c075ac6 100644
--- a/dlls/msxml3/nodemap.c
+++ b/dlls/msxml3/nodemap.c
@@ -308,7 +308,7 @@ static HRESULT WINAPI support_error_QueryInterface(
     REFIID riid, void** ppvObject )
 {
     xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
-    TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
+    TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
     return IXMLDOMNamedNodeMap_QueryInterface(&This->IXMLDOMNamedNodeMap_iface, riid, ppvObject);
 }
 
@@ -330,8 +330,9 @@ static HRESULT WINAPI support_error_InterfaceSupportsErrorInfo(
     ISupportErrorInfo *iface,
     REFIID riid )
 {
-    FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
-    return S_FALSE;
+    xmlnodemap *This = impl_from_ISupportErrorInfo( iface );
+    TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
+    return IsEqualGUID(riid, &IID_IXMLDOMNamedNodeMap) ? S_OK : S_FALSE;
 }
 
 static const struct ISupportErrorInfoVtbl support_error_vtbl =
diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c
index 8757886..0e36ae7 100644
--- a/dlls/msxml3/tests/domdoc.c
+++ b/dlls/msxml3/tests/domdoc.c
@@ -2815,14 +2815,6 @@ static void test_domnode( void )
 
     if (map)
     {
-        ISupportErrorInfo *support_error;
-        r = IXMLDOMNamedNodeMap_QueryInterface( map, &IID_ISupportErrorInfo, (void**)&support_error );
-        ok( r == S_OK, "ret %08x\n", r );
-
-        r = ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error, &IID_IXMLDOMNamedNodeMap );
-        todo_wine EXPECT_HR(r, S_OK);
-        ISupportErrorInfo_Release( support_error );
-
         str = SysAllocString( szdl );
         r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
         ok( r == S_OK, "getNamedItem returned wrong code\n");
@@ -10733,10 +10725,14 @@ static const supporterror_t supporterror_test[] = {
 
 static void test_supporterrorinfo(void)
 {
-    static REFIID iids[4] = { &IID_IXMLDOMDocument, &IID_IXMLDOMDocument2, &IID_IXMLDOMDocument3 };
+    static REFIID iids[5] = { &IID_IXMLDOMNode, &IID_IXMLDOMDocument,
+                              &IID_IXMLDOMDocument2, &IID_IXMLDOMDocument3 };
     const supporterror_t *ptr = supporterror_test;
     ISupportErrorInfo *errorinfo, *info2;
+    IXMLDOMNamedNodeMap *map, *map2;
     IXMLDOMDocument *doc;
+    IXMLDOMElement *elem;
+    VARIANT_BOOL b;
     IUnknown *unk;
     REFIID *iid;
     void *dummy;
@@ -10794,8 +10790,13 @@ static void test_supporterrorinfo(void)
         hr = IXMLDOMDocument_createNode(doc, type, _bstr_(ptr->name), NULL, &node);
         ok(hr == S_OK, "%d: got 0x%08x\n", ptr->type, hr);
 
+        EXPECT_REF(node, 1);
         hr = IXMLDOMNode_QueryInterface(node, &IID_ISupportErrorInfo, (void**)&errorinfo);
         ok(hr == S_OK, "%d: got 0x%08x\n", ptr->type, hr);
+        EXPECT_REF(node, 1);
+
+        hr = ISupportErrorInfo_QueryInterface(errorinfo, &IID_IXMLDOMNode, &dummy);
+        ok(hr == E_NOINTERFACE, "%d: got 0x%08x\n", ptr->type, hr);
 
         iid = ptr->iids;
 
@@ -10817,6 +10818,42 @@ static void test_supporterrorinfo(void)
         ptr++;
     }
 
+    /* IXMLDOMNamedNodeMap */
+    b = VARIANT_FALSE;
+    hr = IXMLDOMDocument_loadXML(doc, _bstr_(complete4A), &b);
+    EXPECT_HR(hr, S_OK);
+    ok(b == VARIANT_TRUE, "got %d\n", b);
+
+    hr = IXMLDOMDocument_get_documentElement(doc, &elem);
+    EXPECT_HR(hr, S_OK);
+
+    hr = IXMLDOMElement_get_attributes(elem, &map);
+    EXPECT_HR(hr, S_OK);
+
+    EXPECT_REF(map, 1);
+    hr = IXMLDOMNamedNodeMap_QueryInterface(map, &IID_ISupportErrorInfo, (void**)&errorinfo);
+    EXPECT_HR(hr, S_OK);
+    EXPECT_REF(map, 2);
+
+    hr = ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo, &IID_IXMLDOMNamedNodeMap);
+    EXPECT_HR(hr, S_OK);
+
+    hr = ISupportErrorInfo_QueryInterface(errorinfo, &IID_IXMLDOMNamedNodeMap, (void**)&map2);
+    EXPECT_HR(hr, S_OK);
+    ok(map == map2, "got %p\n", map2);
+    IXMLDOMNamedNodeMap_Release(map2);
+
+    EXPECT_REF(errorinfo, 2);
+    hr = ISupportErrorInfo_QueryInterface(errorinfo, &IID_IUnknown, (void**)&unk);
+    EXPECT_HR(hr, S_OK);
+    EXPECT_REF(errorinfo, 3);
+    EXPECT_REF(map, 3);
+    IUnknown_Release(unk);
+
+    ISupportErrorInfo_Release(errorinfo);
+    IXMLDOMNamedNodeMap_Release(map);
+    IXMLDOMElement_Release(elem);
+
     IXMLDOMDocument_Release(doc);
     free_bstrs();
 }
-- 
1.5.6.5

