diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index bb9ce229e07..c957d4eb105 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -178,6 +178,9 @@ static HRESULT WINAPI xmlnode_get_nodeName( TRACE("%p\n", This ); + if (!name) + return E_INVALIDARG; + if ( !This->node ) return E_FAIL; @@ -186,6 +189,9 @@ static HRESULT WINAPI xmlnode_get_nodeName( case XML_TEXT_NODE: str = (const xmlChar*) "#text"; break; + case XML_DOCUMENT_NODE: + str = (const xmlChar*) "#document"; + break; default: str = This->node->name; break; diff --git a/dlls/msxml3/tests/domdoc.c b/dlls/msxml3/tests/domdoc.c index eacb747791d..5eb704d2026 100644 --- a/dlls/msxml3/tests/domdoc.c +++ b/dlls/msxml3/tests/domdoc.c @@ -64,6 +64,9 @@ static const WCHAR szComplete4[] = { static const WCHAR szNonExistentFile[] = { 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0 }; +static const WCHAR szDocument[] = { + '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0 +}; static const WCHAR szOpen[] = { 'o','p','e','n',0 }; static const WCHAR szdl[] = { 'd','l',0 }; @@ -98,9 +101,9 @@ void test_domdoc( void ) ok( r == S_FALSE, "loadXML failed\n"); ok( b == VARIANT_FALSE, "failed to load XML string\n"); - /* try to laod an document from an non-existent file */ + /* try to load an document from an non-existent file */ b = VARIANT_TRUE; - str = SysAllocString ( szNonExistentFile ); + str = SysAllocString( szNonExistentFile ); VariantInit(&var); V_VT(&var) = VT_BSTR; V_BSTR(&var) = str; @@ -151,6 +154,19 @@ void test_domdoc( void ) ok( r == S_OK, "should be no document element\n"); } + /* check if nodename is correct */ + r = IXMLDOMDocument_get_nodeName( doc, NULL ); + ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code"); + + /* content doesn't matter here */ + str = SysAllocString( szNonExistentFile ); + r = IXMLDOMDocument_get_nodeName( doc, &str ); + ok ( r == S_OK, "get_nodeName wrong code\n"); + ok ( str != NULL, "str is null\n"); + ok( !lstrcmpW( str, szDocument ), "incorrect nodeName\n"); + SysFreeString( str ); + + /* check that there's no document element */ element = NULL; r = IXMLDOMDocument_get_documentElement( doc, &element ); @@ -279,6 +295,18 @@ void test_domnode( void ) ok( r == S_OK, "get_baseName returned wrong code\n"); ok( lstrcmpW(str,szlc) == 0, "basename was wrong\n"); + /* check if nodename is correct */ + r = IXMLDOMElement_get_nodeName( element, NULL ); + ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code"); + + /* content doesn't matter here */ + str = SysAllocString( szNonExistentFile ); + r = IXMLDOMElement_get_nodeName( element, &str ); + ok ( r == S_OK, "get_nodeName wrong code\n"); + ok ( str != NULL, "str is null\n"); + ok( !lstrcmpW( str, szlc ), "incorrect nodeName\n"); + SysFreeString( str ); + r = IXMLDOMElement_get_attributes( element, &map ); ok( r == S_OK, "get_attributes returned wrong code\n"); ok( map != NULL, "should be attributes\n");