4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007-2008 Alistair Leslie-Hughes
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "msxml2did.h"
35 #include "wine/test.h"
39 DEFINE_GUID(IID_IObjectSafety
, 0xcb5bdc81, 0x93c1, 0x11cf, 0x8f,0x20, 0x00,0x80,0x5f,0x2c,0xd0,0x64);
41 static const WCHAR szEmpty
[] = { 0 };
42 static const WCHAR szIncomplete
[] = {
43 '<','?','x','m','l',' ',
44 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
46 static const WCHAR szComplete1
[] = {
47 '<','?','x','m','l',' ',
48 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
49 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
51 static const WCHAR szComplete2
[] = {
52 '<','?','x','m','l',' ',
53 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
54 '<','o','>','<','/','o','>','\n',0
56 static const WCHAR szComplete3
[] = {
57 '<','?','x','m','l',' ',
58 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
59 '<','a','>','<','/','a','>','\n',0
61 static const WCHAR szComplete4
[] = {
62 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
63 '<','l','c',' ','d','l','=','\'','s','t','r','1','\'','>','\n',
64 '<','b','s',' ','v','r','=','\'','s','t','r','2','\'',' ','s','z','=','\'','1','2','3','4','\'','>',
65 'f','n','1','.','t','x','t','\n',
66 '<','/','b','s','>','\n',
67 '<','p','r',' ','i','d','=','\'','s','t','r','3','\'',' ','v','r','=','\'','1','.','2','.','3','\'',' ',
68 'p','n','=','\'','w','i','n','e',' ','2','0','0','5','0','8','0','4','\'','>','\n',
69 'f','n','2','.','t','x','t','\n',
70 '<','/','p','r','>','\n',
71 '<','e','m','p','t','y','>','<','/','e','m','p','t','y','>','\n',
75 '<','/','b','a','>','\n',
76 '<','/','f','o','>','\n',
77 '<','/','l','c','>','\n',0
79 static const WCHAR szComplete5
[] = {
80 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
81 'x','m','l','n','s',':','C','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y','"',
82 ' ','x','m','l','n','s',':','S','=','"','u','r','n',':','s','c','h','e','m','a','s','-','m','i','c','r','o','s','o','f','t','-','c','o','m',':','o','f','f','i','c','e',':','c','l','i','p','g','a','l','l','e','r','y',':','s','e','a','r','c','h','"','>',
83 '<','S',':','s','c','o','p','e','>',
84 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
85 '<','/','S',':','s','c','o','p','e','>',
86 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
87 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
88 'c','o','m','p','u','t','e','r',
89 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
90 '<','/','S',':','s','e','a','r','c','h','>',0
93 static const CHAR szExampleXML
[] =
94 "<?xml version='1.0' encoding='utf-8'?>\n"
95 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
100 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
101 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
102 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
110 " <c type=\"old\">C2 field</c>\n"
113 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
122 " <foo:c>C4 field</foo:c>\n"
126 static const CHAR szTransformXML
[] =
127 "<?xml version=\"1.0\"?>\n"
132 static const CHAR szTransformSSXML
[] =
133 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
134 " <xsl:output method=\"html\"/>\n"
135 " <xsl:template match=\"/\">\n"
136 " <xsl:apply-templates select=\"greeting\"/>\n"
138 " <xsl:template match=\"greeting\">\n"
142 " <xsl:value-of select=\".\"/>\n"
149 static const CHAR szTransformOutput
[] =
152 "</h1></body></html>";
154 static const CHAR szTypeValueXML
[] =
155 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
156 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
157 " <string>Wine</string>\n"
158 " <string2 dt:dt=\"string\">String</string2>\n"
159 " <number dt:dt=\"number\">12.44</number>\n"
160 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
161 " <int dt:dt=\"int\">-13</int>\n"
162 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
163 " <bool dt:dt=\"boolean\">1</bool>\n"
164 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
165 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
166 " <date dt:dt=\"date\">3721-11-01</date>\n"
167 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
168 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
169 " <i1 dt:dt=\"i1\">-13</i1>\n"
170 " <i2 dt:dt=\"i2\">31915</i2>\n"
171 " <i4 dt:dt=\"i4\">-312232</i4>\n"
172 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
173 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
174 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
175 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
176 " <r8 dt:dt=\"r8\">0.412</r8>\n"
177 " <float dt:dt=\"float\">41221.421</float>\n"
178 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
179 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
180 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
183 static const CHAR szBasicTransformSSXMLPart1
[] =
184 "<?xml version=\"1.0\"?>"
185 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
186 "<xsl:output method=\"html\"/>\n"
187 "<xsl:template match=\"/\">"
188 "<HTML><BODY><TABLE>"
189 " <xsl:apply-templates select='document(\"";
191 static const CHAR szBasicTransformSSXMLPart2
[] =
193 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
194 " </xsl:apply-templates>"
195 "</TABLE></BODY></HTML>"
197 "<xsl:template match=\"bottle\">"
198 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
200 "<xsl:template match=\"name\">"
201 " <TD><xsl:apply-templates /></TD>"
203 "<xsl:template match=\"cost\">"
204 " <TD><xsl:apply-templates /></TD>"
208 static const CHAR szBasicTransformXML
[] =
209 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
211 static const CHAR szBasicTransformOutput
[] =
212 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
214 static const WCHAR szNonExistentFile
[] = {
215 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
217 static const WCHAR szNonExistentAttribute
[] = {
218 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
220 static const WCHAR szDocument
[] = {
221 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
224 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
225 static WCHAR szdl
[] = { 'd','l',0 };
226 static const WCHAR szvr
[] = { 'v','r',0 };
227 static const WCHAR szlc
[] = { 'l','c',0 };
228 static WCHAR szbs
[] = { 'b','s',0 };
229 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
230 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
231 static const WCHAR szstar
[] = { '*',0 };
232 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
234 static WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
235 static WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
236 static WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
238 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
239 static WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
240 static WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
241 static WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
242 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
243 static WCHAR szElementXML4
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
244 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
246 static WCHAR szAttribute
[] = {'A','t','t','r',0 };
247 static WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
249 static WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
250 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
251 static WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
252 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
254 static WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
255 static WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
257 static WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
258 static WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
259 static WCHAR szStrangeChars
[] = {'&','x',' ',0x2103, 0};
261 #define expect_bstr_eq_and_free(bstr, expect) { \
262 BSTR bstrExp = alloc_str_from_narrow(expect); \
263 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
264 SysFreeString(bstr); \
265 SysFreeString(bstrExp); \
268 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
270 #define ole_check(expr) { \
272 ok(r == S_OK, #expr " returned %x\n", r); \
275 #define ole_expect(expr, expect) { \
277 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
280 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
282 static BSTR
alloc_str_from_narrow(const char *str
)
284 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
285 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
286 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
290 BSTR alloced_bstrs
[256];
291 int alloced_bstrs_count
= 0;
293 static BSTR
_bstr_(const char *str
)
295 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
296 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
297 return alloced_bstrs
[alloced_bstrs_count
++];
300 static void free_bstrs(void)
303 for (i
= 0; i
< alloced_bstrs_count
; i
++)
304 SysFreeString(alloced_bstrs
[i
]);
305 alloced_bstrs_count
= 0;
308 static VARIANT
_variantbstr_(const char *str
)
312 V_BSTR(&v
) = _bstr_(str
);
316 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
320 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
321 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
322 if (*sLeft
!= *sRight
) return FALSE
;
323 if (!*sLeft
) return TRUE
;
329 static BOOL
compareIgnoreReturnsWhitespace(BSTR sLeft
, BSTR sRight
)
331 /* MSXML3 inserts whitespace where as libxml doesn't. */
334 while (*sLeft
== '\r' || *sLeft
== '\n' || *sLeft
== ' ') sLeft
++;
335 while (*sRight
== '\r' || *sRight
== '\n' || *sRight
== ' ') sRight
++;
336 if (*sLeft
!= *sRight
) return FALSE
;
337 if (!*sLeft
) return TRUE
;
343 static void get_str_for_type(DOMNodeType type
, char *buf
)
357 wsprintfA(buf
, "[%d]", type
);
361 #define test_disp(u) _test_disp(__LINE__,u)
362 static void _test_disp(unsigned line
, IUnknown
*unk
)
364 DISPID dispid
= DISPID_XMLDOM_NODELIST_RESET
;
372 hres
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
373 ok_(__FILE__
,line
) (hres
== S_OK
, "Could not get IDispatch: %08x\n", hres
);
378 hres
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
379 ok_(__FILE__
,line
) (hres
== S_OK
, "GetTypeInfoCount failed: %08x\n", hres
);
380 ok_(__FILE__
,line
) (ticnt
== 1, "ticnt=%u\n", ticnt
);
382 sName
= SysAllocString( szstar
);
383 hres
= IDispatchEx_DeleteMemberByName(dispex
, sName
, fdexNameCaseSensitive
);
384 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
385 SysFreeString( sName
);
387 hres
= IDispatchEx_DeleteMemberByDispID(dispex
, dispid
);
388 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
390 hres
= IDispatchEx_GetMemberProperties(dispex
, dispid
, grfdexPropCanAll
, &dwProps
);
391 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
392 ok(dwProps
== 0, "expected 0 got %d\n", dwProps
);
394 hres
= IDispatchEx_GetMemberName(dispex
, dispid
, &sName
);
395 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
397 SysFreeString(sName
);
399 hres
= IDispatchEx_GetNextDispID(dispex
, fdexEnumDefault
, DISPID_XMLDOM_NODELIST_RESET
, &dispid
);
400 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
402 hres
= IDispatchEx_GetNameSpaceParent(dispex
, &pUnk
);
403 ok(hres
== E_NOTIMPL
, "expected E_NOTIMPL got %08x\n", hres
);
404 if(hres
== S_OK
&& pUnk
)
405 IUnknown_Release(pUnk
);
407 IDispatchEx_Release(dispex
);
410 static int get_node_position(IXMLDOMNode
*node
)
415 IXMLDOMNode_AddRef(node
);
418 IXMLDOMNode
*new_node
;
421 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
422 ok(SUCCEEDED(r
), "get_previousSibling failed\n");
423 IXMLDOMNode_Release(node
);
429 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
436 lstrcpyA(buf
, "(null)");
440 IXMLDOMNode_AddRef(node
);
443 IXMLDOMNode
*new_node
;
445 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
446 get_str_for_type(type
, buf
);
449 if (type
== NODE_ATTRIBUTE
)
452 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
454 wsprintfA(buf
, "%ws", bstr
);
459 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
463 int pos
= get_node_position(node
);
464 DOMNodeType parent_type
= NODE_INVALID
;
465 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
467 /* currently wine doesn't create a node for the <?xml ... ?>. To be able to test query
468 * results we "fix" it */
470 ole_check(IXMLDOMNode_get_nodeType(new_node
, &parent_type
));
471 if ((parent_type
== NODE_DOCUMENT
) && type
!= NODE_PROCESSING_INSTRUCTION
&& pos
==1)
473 todo_wine
ok(FALSE
, "The first child of the document node in MSXML is the <?xml ... ?> processing instruction\n");
476 wsprintf(buf
, "%d", pos
);
480 ok(SUCCEEDED(r
), "get_parentNode failed (%08x)\n", r
);
481 IXMLDOMNode_Release(node
);
490 static char *list_to_string(IXMLDOMNodeList
*list
)
492 static char buf
[4096];
499 lstrcpyA(buf
, "(null)");
502 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
503 for (i
= 0; i
< len
; i
++)
508 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
509 node_to_string(node
, pos
);
511 IXMLDOMNode_Release(node
);
517 #define expect_node(node, expstr) { char str[4096]; node_to_string(node, str); ok(strcmp(str, expstr)==0, "Invalid node: %s, expected %s\n", str, expstr); }
518 #define expect_list_and_release(list, expstr) { char *str = list_to_string(list); ok(strcmp(str, expstr)==0, "Invalid node list: %s, expected %s\n", str, expstr); if (list) IXMLDOMNodeList_Release(list); }
520 static void test_domdoc( void )
523 IXMLDOMDocument
*doc
= NULL
;
524 IXMLDOMParseError
*error
;
525 IXMLDOMElement
*element
= NULL
;
527 IXMLDOMText
*nodetext
= NULL
;
528 IXMLDOMComment
*node_comment
= NULL
;
529 IXMLDOMAttribute
*node_attr
= NULL
;
530 IXMLDOMNode
*nodeChild
= NULL
;
531 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
532 ISupportErrorInfo
*support_error
= NULL
;
539 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
540 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
544 test_disp((IUnknown
*)doc
);
546 /* try some stupid things */
547 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
548 ok( r
== S_FALSE
, "loadXML failed\n");
551 r
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
552 ok( r
== S_FALSE
, "loadXML failed\n");
553 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
555 /* try to load a document from a nonexistent file */
557 str
= SysAllocString( szNonExistentFile
);
559 V_VT(&var
) = VT_BSTR
;
562 r
= IXMLDOMDocument_load( doc
, var
, &b
);
563 ok( r
== S_FALSE
, "load (from file) failed\n");
564 ok( b
== VARIANT_FALSE
, "failed to load XML file\n");
565 SysFreeString( str
);
567 /* try load an empty document */
569 str
= SysAllocString( szEmpty
);
570 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
571 ok( r
== S_FALSE
, "loadXML failed\n");
572 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
573 SysFreeString( str
);
575 r
= IXMLDOMDocument_get_async( doc
, &b
);
576 ok( r
== S_OK
, "get_async failed (%08x)\n", r
);
577 ok( b
== VARIANT_TRUE
, "Wrong default value\n");
579 /* check that there's no document element */
581 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
582 ok( r
== S_FALSE
, "should be no document element\n");
584 /* try finding a node */
586 str
= SysAllocString( szstr1
);
587 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
588 ok( r
== S_FALSE
, "ret %08x\n", r
);
589 SysFreeString( str
);
592 str
= SysAllocString( szIncomplete
);
593 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
594 ok( r
== S_FALSE
, "loadXML failed\n");
595 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
596 SysFreeString( str
);
598 /* check that there's no document element */
599 element
= (IXMLDOMElement
*)1;
600 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
601 ok( r
== S_FALSE
, "should be no document element\n");
602 ok( element
== NULL
, "Element should be NULL\n");
604 /* try to load something valid */
606 str
= SysAllocString( szComplete1
);
607 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
608 ok( r
== S_OK
, "loadXML failed\n");
609 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
610 SysFreeString( str
);
612 /* check if nodename is correct */
613 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
614 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
616 /* content doesn't matter here */
618 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
619 ok ( r
== S_OK
, "get_nodeName wrong code\n");
620 ok ( str
!= NULL
, "str is null\n");
621 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
622 SysFreeString( str
);
625 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should Fail") );
626 ok( r
== E_FAIL
, "ret %08x\n", r
);
628 /* check that there's a document element */
630 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
631 ok( r
== S_OK
, "should be a document element\n");
634 IObjectIdentity
*ident
;
637 test_disp((IUnknown
*)element
);
639 r
= IXMLDOMElement_QueryInterface( element
, &IID_IObjectIdentity
, (LPVOID
*)&ident
);
640 ok( r
== E_NOINTERFACE
, "ret %08x\n", r
);
642 r
= IXMLDOMElement_get_tagName( element
, NULL
);
643 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
645 /* check if the tag is correct */
646 r
= IXMLDOMElement_get_tagName( element
, &tag
);
647 ok( r
== S_OK
, "couldn't get tag name\n");
648 ok( tag
!= NULL
, "tag was null\n");
649 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
650 SysFreeString( tag
);
652 /* figure out what happens if we try to reload the document */
653 str
= SysAllocString( szComplete2
);
654 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
655 ok( r
== S_OK
, "loadXML failed\n");
656 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
657 SysFreeString( str
);
659 /* check if the tag is still correct */
661 r
= IXMLDOMElement_get_tagName( element
, &tag
);
662 ok( r
== S_OK
, "couldn't get tag name\n");
663 ok( tag
!= NULL
, "tag was null\n");
664 ok( !lstrcmpW( tag
, szOpen
), "incorrect tag name\n");
665 SysFreeString( tag
);
667 IXMLDOMElement_Release( element
);
671 /* as soon as we call loadXML again, the document element will disappear */
673 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
674 ok( r
== S_FALSE
, "loadXML failed\n");
675 ok( b
== 2, "variant modified\n");
676 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
677 ok( r
== S_FALSE
, "should be no document element\n");
679 /* try to load something else simple and valid */
681 str
= SysAllocString( szComplete3
);
682 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
683 ok( r
== S_OK
, "loadXML failed\n");
684 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
685 SysFreeString( str
);
687 /* try something a little more complicated */
689 str
= SysAllocString( szComplete4
);
690 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
691 ok( r
== S_OK
, "loadXML failed\n");
692 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
693 SysFreeString( str
);
695 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
696 ok( r
== S_OK
, "returns %08x\n", r
);
698 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
699 ok( r
== S_FALSE
, "returns %08x\n", r
);
700 ok( code
== 0, "code %d\n", code
);
701 IXMLDOMParseError_Release( error
);
703 /* test createTextNode */
704 r
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &nodetext
);
705 ok( r
== S_OK
, "returns %08x\n", r
);
706 IXMLDOMText_Release(nodetext
);
708 str
= SysAllocString( szOpen
);
709 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
710 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
711 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
712 ok( r
== S_OK
, "returns %08x\n", r
);
713 SysFreeString( str
);
716 IXMLDOMNamedNodeMap
*pAttribs
;
718 r
= IXMLDOMText_QueryInterface(nodetext
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
719 ok(r
== E_NOINTERFACE
, "ret %08x\n", r
);
721 /* Text Last Child Checks */
722 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
723 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
725 nodeChild
= (IXMLDOMNode
*)0x1;
726 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
727 ok(r
== S_FALSE
, "ret %08x\n", r
);
728 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
730 /* test get_attributes */
731 r
= IXMLDOMText_get_attributes( nodetext
, NULL
);
732 ok( r
== E_INVALIDARG
, "get_attributes returned wrong code\n");
734 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
735 r
= IXMLDOMText_get_attributes( nodetext
, &pAttribs
);
736 ok(r
== S_FALSE
, "ret %08x\n", r
);
737 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
739 /* test get_dataType */
740 r
= IXMLDOMText_get_dataType(nodetext
, &var
);
741 ok(r
== S_FALSE
, "ret %08x\n", r
);
742 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
745 /* test length property */
746 r
= IXMLDOMText_get_length(nodetext
, NULL
);
747 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
749 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
750 ok(r
== S_OK
, "ret %08x\n", r
);
751 ok(nLength
== 4, "expected 4 got %d\n", nLength
);
753 /* test nodeTypeString */
754 r
= IXMLDOMText_get_nodeTypeString(nodetext
, &str
);
755 ok(r
== S_OK
, "ret %08x\n", r
);
756 ok( !lstrcmpW( str
, _bstr_("text") ), "incorrect nodeTypeString string\n");
760 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
761 ok(r
== S_OK
, "ret %08x\n", r
);
764 r
= IXMLDOMText_get_data(nodetext
, &str
);
765 ok(r
== S_OK
, "ret %08x\n", r
);
766 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
769 /* Confirm XML text is good */
770 r
= IXMLDOMText_get_xml(nodetext
, &str
);
771 ok(r
== S_OK
, "ret %08x\n", r
);
772 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
775 /* Confirm we get the put_data Text back */
776 r
= IXMLDOMText_get_text(nodetext
, &str
);
777 ok(r
== S_OK
, "ret %08x\n", r
);
778 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
781 /* test substringData */
782 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
783 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
785 /* test substringData - Invalid offset */
786 str
= (BSTR
)&szElement
;
787 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
788 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
789 ok( str
== NULL
, "incorrect string\n");
791 /* test substringData - Invalid offset */
792 str
= (BSTR
)&szElement
;
793 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
794 ok(r
== S_FALSE
, "ret %08x\n", r
);
795 ok( str
== NULL
, "incorrect string\n");
797 /* test substringData - Invalid size */
798 str
= (BSTR
)&szElement
;
799 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
800 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
801 ok( str
== NULL
, "incorrect string\n");
803 /* test substringData - Invalid size */
804 str
= (BSTR
)&szElement
;
805 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
806 ok(r
== S_FALSE
, "ret %08x\n", r
);
807 ok( str
== NULL
, "incorrect string\n");
809 /* test substringData - Start of string */
810 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
811 ok(r
== S_OK
, "ret %08x\n", r
);
812 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
815 /* test substringData - Middle of string */
816 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
817 ok(r
== S_OK
, "ret %08x\n", r
);
818 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
821 /* test substringData - End of string */
822 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
823 ok(r
== S_OK
, "ret %08x\n", r
);
824 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
827 /* test appendData */
828 r
= IXMLDOMText_appendData(nodetext
, NULL
);
829 ok(r
== S_OK
, "ret %08x\n", r
);
831 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
832 ok(r
== S_OK
, "ret %08x\n", r
);
834 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
835 ok(r
== S_OK
, "ret %08x\n", r
);
837 r
= IXMLDOMText_get_text(nodetext
, &str
);
838 ok(r
== S_OK
, "ret %08x\n", r
);
839 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
842 /* test insertData */
843 str
= SysAllocStringLen(NULL
, 0);
844 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
845 ok(r
== S_OK
, "ret %08x\n", r
);
847 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
848 ok(r
== S_OK
, "ret %08x\n", r
);
850 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
851 ok(r
== S_OK
, "ret %08x\n", r
);
853 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
854 ok(r
== S_OK
, "ret %08x\n", r
);
856 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
857 ok(r
== S_OK
, "ret %08x\n", r
);
859 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
860 ok(r
== S_OK
, "ret %08x\n", r
);
863 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
864 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
866 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
867 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
869 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
870 ok(r
== S_OK
, "ret %08x\n", r
);
872 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
873 ok(r
== S_OK
, "ret %08x\n", r
);
875 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
876 ok(r
== S_OK
, "ret %08x\n", r
);
878 r
= IXMLDOMText_get_text(nodetext
, &str
);
879 ok(r
== S_OK
, "ret %08x\n", r
);
880 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
884 /* invalid arguments */
885 r
= IXMLDOMText_deleteData(nodetext
, -1, 1);
886 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
888 r
= IXMLDOMText_deleteData(nodetext
, 0, 0);
889 ok(r
== S_OK
, "ret %08x\n", r
);
891 r
= IXMLDOMText_deleteData(nodetext
, 0, -1);
892 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
894 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
895 ok(r
== S_OK
, "ret %08x\n", r
);
896 ok(nLength
== 43, "expected 43 got %d\n", nLength
);
898 r
= IXMLDOMText_deleteData(nodetext
, nLength
, 1);
899 ok(r
== S_OK
, "ret %08x\n", r
);
901 r
= IXMLDOMText_deleteData(nodetext
, nLength
+1, 1);
902 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
904 /* delete from start */
905 r
= IXMLDOMText_deleteData(nodetext
, 0, 5);
906 ok(r
== S_OK
, "ret %08x\n", r
);
908 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
909 ok(r
== S_OK
, "ret %08x\n", r
);
910 ok(nLength
== 38, "expected 38 got %d\n", nLength
);
912 r
= IXMLDOMText_get_text(nodetext
, &str
);
913 ok(r
== S_OK
, "ret %08x\n", r
);
914 /* whitespace preserving needs to be handled here */
915 todo_wine
ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
918 /* delete from end */
919 r
= IXMLDOMText_deleteData(nodetext
, 35, 3);
920 ok(r
== S_OK
, "ret %08x\n", r
);
922 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
923 ok(r
== S_OK
, "ret %08x\n", r
);
924 ok(nLength
== 35, "expected 35 got %d\n", nLength
);
926 r
= IXMLDOMText_get_text(nodetext
, &str
);
927 ok(r
== S_OK
, "ret %08x\n", r
);
928 todo_wine
ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string\n");
931 /* delete from inside */
932 r
= IXMLDOMText_deleteData(nodetext
, 1, 33);
933 ok(r
== S_OK
, "ret %08x\n", r
);
935 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
936 ok(r
== S_OK
, "ret %08x\n", r
);
937 ok(nLength
== 2, "expected 2 got %d\n", nLength
);
939 r
= IXMLDOMText_get_text(nodetext
, &str
);
940 ok(r
== S_OK
, "ret %08x\n", r
);
941 todo_wine
ok( !lstrcmpW( str
, _bstr_("") ), "incorrect get_text string\n");
944 /* delete whole data ... */
945 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
946 ok(r
== S_OK
, "ret %08x\n", r
);
948 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
949 ok(r
== S_OK
, "ret %08x\n", r
);
950 /* ... and try again with empty string */
951 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
952 ok(r
== S_OK
, "ret %08x\n", r
);
955 V_VT(&var
) = VT_BSTR
;
956 V_BSTR(&var
) = SysAllocString(szstr1
);
957 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
958 ok(r
== S_OK
, "ret %08x\n", r
);
961 r
= IXMLDOMText_get_text(nodetext
, &str
);
962 ok(r
== S_OK
, "ret %08x\n", r
);
963 ok( !lstrcmpW( str
, szstr1
), "incorrect get_text string\n");
969 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
970 ok(r
== S_OK
, "ret %08x\n", r
);
973 r
= IXMLDOMText_get_text(nodetext
, &str
);
974 ok(r
== S_OK
, "ret %08x\n", r
);
975 ok( !lstrcmpW( str
, _bstr_("99") ), "incorrect get_text string\n");
978 /* ::replaceData() */
979 V_VT(&var
) = VT_BSTR
;
980 V_BSTR(&var
) = SysAllocString(szstr1
);
981 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
982 ok(r
== S_OK
, "ret %08x\n", r
);
985 r
= IXMLDOMText_replaceData(nodetext
, 6, 0, NULL
);
986 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
987 r
= IXMLDOMText_get_text(nodetext
, &str
);
988 ok(r
== S_OK
, "ret %08x\n", r
);
989 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
992 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, NULL
);
993 ok(r
== S_OK
, "ret %08x\n", r
);
994 r
= IXMLDOMText_get_text(nodetext
, &str
);
995 ok(r
== S_OK
, "ret %08x\n", r
);
996 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
999 /* NULL pointer means delete */
1000 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, NULL
);
1001 ok(r
== S_OK
, "ret %08x\n", r
);
1002 r
= IXMLDOMText_get_text(nodetext
, &str
);
1003 ok(r
== S_OK
, "ret %08x\n", r
);
1004 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string\n");
1007 /* empty string means delete */
1008 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_(""));
1009 ok(r
== S_OK
, "ret %08x\n", r
);
1010 r
= IXMLDOMText_get_text(nodetext
, &str
);
1011 ok(r
== S_OK
, "ret %08x\n", r
);
1012 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string\n");
1015 /* zero count means insert */
1016 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, _bstr_("a"));
1017 ok(r
== S_OK
, "ret %08x\n", r
);
1018 r
= IXMLDOMText_get_text(nodetext
, &str
);
1019 ok(r
== S_OK
, "ret %08x\n", r
);
1020 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string\n");
1023 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, NULL
);
1024 ok(r
== S_OK
, "ret %08x\n", r
);
1026 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("m"));
1027 ok(r
== S_OK
, "ret %08x\n", r
);
1028 r
= IXMLDOMText_get_text(nodetext
, &str
);
1029 ok(r
== S_OK
, "ret %08x\n", r
);
1030 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string\n");
1033 /* nonempty string, count greater than its length */
1034 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, _bstr_("a1.2"));
1035 ok(r
== S_OK
, "ret %08x\n", r
);
1036 r
= IXMLDOMText_get_text(nodetext
, &str
);
1037 ok(r
== S_OK
, "ret %08x\n", r
);
1038 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string\n");
1041 /* nonempty string, count less than its length */
1042 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_("wine"));
1043 ok(r
== S_OK
, "ret %08x\n", r
);
1044 r
= IXMLDOMText_get_text(nodetext
, &str
);
1045 ok(r
== S_OK
, "ret %08x\n", r
);
1046 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string\n");
1049 IXMLDOMText_Release( nodetext
);
1052 /* test Create Comment */
1053 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
1054 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1055 node_comment
= (IXMLDOMComment
*)0x1;
1058 r
= IXMLDOMDocument_createComment(doc
, _bstr_(""), &node_comment
);
1059 ok( r
== S_OK
, "returns %08x\n", r
);
1061 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1062 ok( r
== S_OK
, "returns %08x\n", r
);
1063 ok( str
&& SysStringLen(str
) == 0, "expected empty string data\n");
1064 IXMLDOMComment_Release(node_comment
);
1067 r
= IXMLDOMDocument_createComment(doc
, NULL
, &node_comment
);
1068 ok( r
== S_OK
, "returns %08x\n", r
);
1070 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1071 ok( r
== S_OK
, "returns %08x\n", r
);
1072 ok( str
&& (SysStringLen(str
) == 0), "expected empty string data\n");
1073 IXMLDOMComment_Release(node_comment
);
1076 str
= SysAllocString(szComment
);
1077 r
= IXMLDOMDocument_createComment(doc
, str
, &node_comment
);
1079 ok( r
== S_OK
, "returns %08x\n", r
);
1082 /* Last Child Checks */
1083 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
1084 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1086 nodeChild
= (IXMLDOMNode
*)0x1;
1087 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
1088 ok(r
== S_FALSE
, "ret %08x\n", r
);
1089 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
1092 str
= (BSTR
)0xdeadbeef;
1093 IXMLDOMComment_get_baseName(node_comment
, &str
);
1094 ok(r
== S_FALSE
, "ret %08x\n", r
);
1095 ok(str
== NULL
, "Expected NULL\n");
1097 IXMLDOMComment_Release( node_comment
);
1100 /* test Create Attribute */
1101 str
= SysAllocString(szAttribute
);
1102 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
1103 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1104 r
= IXMLDOMDocument_createAttribute(doc
, str
, &node_attr
);
1105 ok( r
== S_OK
, "returns %08x\n", r
);
1106 IXMLDOMText_Release( node_attr
);
1109 /* test Processing Instruction */
1110 str
= SysAllocStringLen(NULL
, 0);
1111 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
1112 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1113 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
1114 ok( r
== E_FAIL
, "returns %08x\n", r
);
1115 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
1116 ok( r
== E_FAIL
, "returns %08x\n", r
);
1119 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
1120 ok( r
== S_OK
, "returns %08x\n", r
);
1123 /* Last Child Checks */
1124 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
1125 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1127 nodeChild
= (IXMLDOMNode
*)0x1;
1128 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
1129 ok(r
== S_FALSE
, "ret %08x\n", r
);
1130 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
1132 r
= IXMLDOMProcessingInstruction_get_dataType(nodePI
, &var
);
1133 ok(r
== S_FALSE
, "ret %08x\n", r
);
1134 ok( V_VT(&var
) == VT_NULL
, "incorrect dataType type\n");
1138 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1139 ok(r
== S_OK
, "ret %08x\n", r
);
1140 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1145 r
= IXMLDOMProcessingInstruction_get_baseName(nodePI
, &str
);
1146 ok(r
== S_OK
, "ret %08x\n", r
);
1147 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1151 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
1152 ok(r
== S_OK
, "ret %08x\n", r
);
1153 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
1156 /* test nodeTypeString */
1157 r
= IXMLDOMProcessingInstruction_get_nodeTypeString(nodePI
, &str
);
1158 ok(r
== S_OK
, "ret %08x\n", r
);
1159 ok( !lstrcmpW( str
, _bstr_("processinginstruction") ), "incorrect nodeTypeString string\n");
1162 /* test get_nodeValue */
1163 r
= IXMLDOMProcessingInstruction_get_nodeValue(nodePI
, &var
);
1164 ok(r
== S_OK
, "ret %08x\n", r
);
1165 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1169 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
1170 ok(r
== S_OK
, "ret %08x\n", r
);
1171 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1175 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
1176 ok(r
== E_FAIL
, "ret %08x\n", r
);
1179 V_VT(&var
) = VT_BSTR
;
1180 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
1181 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
1182 ok(r
== E_FAIL
, "ret %08x\n", r
);
1185 /* test get nodeName */
1186 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1187 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1188 ok(r
== S_OK
, "ret %08x\n", r
);
1191 IXMLDOMProcessingInstruction_Release(nodePI
);
1194 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
1195 ok( r
== S_OK
, "ret %08x\n", r
);
1198 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMDocument
);
1199 todo_wine
ok( r
== S_OK
, "ret %08x\n", r
);
1200 ISupportErrorInfo_Release( support_error
);
1203 r
= IXMLDOMDocument_Release( doc
);
1204 ok( r
== 0, "document ref count incorrect\n");
1209 static void test_domnode( void )
1212 IXMLDOMDocument
*doc
= NULL
, *owner
= NULL
;
1213 IXMLDOMElement
*element
= NULL
;
1214 IXMLDOMNamedNodeMap
*map
= NULL
;
1215 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
1216 IXMLDOMNodeList
*list
= NULL
;
1217 IXMLDOMAttribute
*attr
= NULL
;
1218 DOMNodeType type
= NODE_INVALID
;
1224 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1225 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1229 ok( FALSE
, "no document\n");
1234 str
= SysAllocString( szComplete4
);
1235 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1236 ok( r
== S_OK
, "loadXML failed\n");
1237 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1238 SysFreeString( str
);
1241 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1242 ok( r
== S_OK
, "hasChildNoes bad return\n");
1243 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1245 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1246 ok( r
== S_OK
, "should be a document element\n");
1247 ok( element
!= NULL
, "should be an element\n");
1250 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1252 r
= IXMLDOMNode_get_nodeValue( doc
, NULL
);
1253 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
1255 r
= IXMLDOMNode_get_nodeValue( doc
, &var
);
1256 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1257 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1258 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1263 r
= IXMLDOMNode_get_ownerDocument( element
, &owner
);
1264 ok( r
== S_OK
, "get_ownerDocument return code\n");
1265 ok( owner
!= doc
, "get_ownerDocument return\n");
1266 IXMLDOMDocument_Release(owner
);
1268 type
= NODE_INVALID
;
1269 r
= IXMLDOMNode_get_nodeType( element
, &type
);
1270 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1271 ok( type
== NODE_ELEMENT
, "node not an element\n");
1274 r
= IXMLDOMNode_get_baseName( element
, &str
);
1275 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1276 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
1279 /* check if nodename is correct */
1280 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
1281 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1283 /* content doesn't matter here */
1285 r
= IXMLDOMElement_get_nodeName( element
, &str
);
1286 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1287 ok ( str
!= NULL
, "str is null\n");
1288 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
1289 SysFreeString( str
);
1291 str
= SysAllocString( szNonExistentFile
);
1293 V_I4(&var
) = 0x1234;
1294 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1295 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
1296 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
1299 r
= IXMLDOMElement_getAttributeNode( element
, str
, NULL
);
1300 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1302 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1303 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1304 ok( r
== E_FAIL
, "getAttributeNode ret %08x\n", r
);
1305 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1306 SysFreeString( str
);
1308 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
1309 str
= SysAllocString( szNonExistentAttribute
);
1310 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1311 ok( r
== S_FALSE
, "getAttributeNode ret %08x\n", r
);
1312 ok( attr
== NULL
, "getAttributeNode ret %p, expected NULL\n", attr
);
1313 SysFreeString( str
);
1315 str
= SysAllocString( szdl
);
1317 V_I4(&var
) = 0x1234;
1318 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1319 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
1320 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
1321 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
1322 VariantClear( &var
);
1324 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
1325 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1327 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
1328 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1331 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1332 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
1333 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
1336 r
= IXMLDOMAttribute_get_parentNode( attr
, NULL
);
1337 ok( r
== E_INVALIDARG
, "Expected E_INVALIDARG, ret %08x\n", r
);
1339 /* attribute doesn't have a parent in msxml interpretation */
1340 node
= (IXMLDOMNode
*)0xdeadbeef;
1341 r
= IXMLDOMAttribute_get_parentNode( attr
, &node
);
1342 ok( r
== S_FALSE
, "Expected S_FALSE, ret %08x\n", r
);
1343 ok( node
== NULL
, "Expected NULL, got %p\n", node
);
1345 IXMLDOMAttribute_Release(attr
);
1348 SysFreeString( str
);
1350 r
= IXMLDOMElement_get_attributes( element
, &map
);
1351 ok( r
== S_OK
, "get_attributes returned wrong code\n");
1352 ok( map
!= NULL
, "should be attributes\n");
1355 r
= IXMLDOMNode_hasChildNodes( element
, &b
);
1356 ok( r
== S_OK
, "hasChildNoes bad return\n");
1357 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1360 ok( FALSE
, "no element\n");
1364 ISupportErrorInfo
*support_error
;
1365 r
= IXMLDOMNamedNodeMap_QueryInterface( map
, &IID_ISupportErrorInfo
, (LPVOID
*)&support_error
);
1366 ok( r
== S_OK
, "ret %08x\n", r
);
1368 r
= ISupportErrorInfo_InterfaceSupportsErrorInfo( support_error
, &IID_IXMLDOMNamedNodeMap
);
1371 ok( r
== S_OK
, "ret %08x\n", r
);
1373 ISupportErrorInfo_Release( support_error
);
1375 str
= SysAllocString( szdl
);
1376 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1377 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1378 ok( node
!= NULL
, "should be attributes\n");
1379 IXMLDOMNode_Release(node
);
1380 SysFreeString( str
);
1382 str
= SysAllocString( szdl
);
1383 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
1384 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
1385 SysFreeString( str
);
1387 /* something that isn't in szComplete4 */
1388 str
= SysAllocString( szOpen
);
1389 node
= (IXMLDOMNode
*) 1;
1390 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1391 ok( r
== S_FALSE
, "getNamedItem found a node that wasn't there\n");
1392 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
1393 SysFreeString( str
);
1395 /* test indexed access of attributes */
1396 r
= IXMLDOMNamedNodeMap_get_length( map
, NULL
);
1397 ok ( r
== E_INVALIDARG
, "get_length should return E_INVALIDARG\n");
1399 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
1400 ok ( r
== S_OK
, "get_length wrong code\n");
1401 ok ( count
== 1, "get_length != 1\n");
1404 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
1405 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
1406 ok ( node
== NULL
, "there is no node\n");
1409 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
1410 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
1411 ok ( node
== NULL
, "there is no attribute\n");
1414 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
1415 ok ( r
== S_OK
, "get_item (0) wrong code\n");
1416 ok ( node
!= NULL
, "should be attribute\n");
1418 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
1419 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1421 /* content doesn't matter here */
1423 r
= IXMLDOMNode_get_nodeName( node
, &str
);
1424 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1425 ok ( str
!= NULL
, "str is null\n");
1426 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
1427 SysFreeString( str
);
1429 /* test sequential access of attributes */
1431 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1432 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
1433 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1435 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1436 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
1437 ok ( node
== NULL
, "nextNode, there is no attribute\n");
1439 r
= IXMLDOMNamedNodeMap_reset( map
);
1440 ok ( r
== S_OK
, "reset should return S_OK\n");
1442 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
1443 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
1444 ok ( node
!= NULL
, "nextNode, should be attribute\n");
1447 ok( FALSE
, "no map\n");
1451 type
= NODE_INVALID
;
1452 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1453 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1454 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
1457 r
= IXMLDOMNode_get_baseName( node
, NULL
);
1458 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
1461 r
= IXMLDOMNode_get_baseName( node
, &str
);
1462 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1463 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
1464 SysFreeString( str
);
1466 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1467 ok( r
== S_OK
, "returns %08x\n", r
);
1468 ok( V_VT(&var
) == VT_BSTR
, "vt %x\n", V_VT(&var
));
1469 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "nodeValue incorrect\n");
1472 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
1473 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
1475 r
= IXMLDOMNode_get_childNodes( node
, &list
);
1476 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1480 r
= IXMLDOMNodeList_nextNode( list
, &next
);
1481 ok( r
== S_OK
, "nextNode returned wrong code\n");
1484 ok( FALSE
, "no childlist\n");
1489 r
= IXMLDOMNode_hasChildNodes( next
, &b
);
1490 ok( r
== S_FALSE
, "hasChildNoes bad return\n");
1491 ok( b
== VARIANT_FALSE
, "hasChildNoes wrong result\n");
1493 type
= NODE_INVALID
;
1494 r
= IXMLDOMNode_get_nodeType( next
, &type
);
1495 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1496 ok( type
== NODE_TEXT
, "node not text\n");
1499 r
= IXMLDOMNode_get_baseName( next
, &str
);
1500 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
1501 ok( str
== NULL
, "basename was wrong\n");
1505 ok( FALSE
, "no next\n");
1508 IXMLDOMNode_Release( next
);
1511 IXMLDOMNodeList_Release( list
);
1514 IXMLDOMNode_Release( node
);
1517 ok( FALSE
, "no node\n");
1521 IXMLDOMNamedNodeMap_Release( map
);
1523 /* now traverse the tree from the root element */
1526 r
= IXMLDOMNode_get_childNodes( element
, &list
);
1527 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
1529 /* using get_item for child list doesn't advance the position */
1530 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
1531 expect_node(node
, "E2.E2.D1");
1532 IXMLDOMNode_Release(node
);
1533 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1534 expect_node(node
, "E1.E2.D1");
1535 IXMLDOMNode_Release(node
);
1536 ole_check(IXMLDOMNodeList_reset(list
));
1538 IXMLDOMNodeList_AddRef(list
);
1539 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
1540 ole_check(IXMLDOMNodeList_reset(list
));
1542 node
= (void*)0xdeadbeef;
1543 str
= SysAllocString(szdl
);
1544 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
1546 ok( r
== S_FALSE
, "ret %08x\n", r
);
1547 ok( node
== NULL
, "node %p\n", node
);
1549 str
= SysAllocString(szbs
);
1550 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
1552 ok( r
== S_OK
, "ret %08x\n", r
);
1553 r
= IXMLDOMNode_Release( node
);
1554 ok( r
== 0, "ret %08x\n", r
);
1557 ok( FALSE
, "no element\n");
1561 r
= IXMLDOMNodeList_QueryInterface(list
, &IID_IDispatch
, NULL
);
1562 ok( r
== E_INVALIDARG
|| r
== E_POINTER
, "ret %08x\n", r
);
1564 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
1565 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1567 r
= IXMLDOMNodeList_get_length(list
, NULL
);
1568 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1570 r
= IXMLDOMNodeList_get_length( list
, &count
);
1571 ok( r
== S_OK
, "get_length returns %08x\n", r
);
1572 ok( count
== 4, "get_length got %d\n", count
);
1574 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
1575 ok(r
== E_INVALIDARG
, "Exected E_INVALIDARG got %08x\n", r
);
1577 r
= IXMLDOMNodeList_nextNode( list
, &node
);
1578 ok( r
== S_OK
, "nextNode returned wrong code\n");
1581 ok( FALSE
, "no list\n");
1585 type
= NODE_INVALID
;
1586 r
= IXMLDOMNode_get_nodeType( node
, &type
);
1587 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1588 ok( type
== NODE_ELEMENT
, "node not text\n");
1591 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1592 r
= IXMLDOMNode_get_nodeValue( node
, &var
);
1593 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1594 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1595 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1597 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
1598 ok( r
== E_INVALIDARG
, "hasChildNoes bad return\n");
1601 r
= IXMLDOMNode_hasChildNodes( node
, &b
);
1602 ok( r
== S_OK
, "hasChildNoes bad return\n");
1603 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1606 r
= IXMLDOMNode_get_baseName( node
, &str
);
1607 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1608 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
1612 ok( FALSE
, "no node\n");
1615 IXMLDOMNode_Release( node
);
1617 IXMLDOMNodeList_Release( list
);
1619 IXMLDOMElement_Release( element
);
1622 str
= SysAllocString( szComplete5
);
1623 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1624 ok( r
== S_OK
, "loadXML failed\n");
1625 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1626 SysFreeString( str
);
1629 r
= IXMLDOMNode_hasChildNodes( doc
, &b
);
1630 ok( r
== S_OK
, "hasChildNoes bad return\n");
1631 ok( b
== VARIANT_TRUE
, "hasChildNoes wrong result\n");
1633 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1634 ok( r
== S_OK
, "should be a document element\n");
1635 ok( element
!= NULL
, "should be an element\n");
1639 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
1642 /* check if the tag is correct */
1643 r
= IXMLDOMElement_get_tagName( element
, &tag
);
1644 ok( r
== S_OK
, "couldn't get tag name\n");
1645 ok( tag
!= NULL
, "tag was null\n");
1646 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
1647 SysFreeString( tag
);
1651 IXMLDOMElement_Release( element
);
1652 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
1655 static void test_refs(void)
1660 IXMLDOMDocument
*doc
= NULL
;
1661 IXMLDOMElement
*element
= NULL
;
1662 IXMLDOMNode
*node
= NULL
, *node2
;
1663 IXMLDOMNodeList
*node_list
= NULL
;
1665 IUnknown
*unk
, *unk2
;
1667 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1668 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1671 ref
= IXMLDOMDocument_Release(doc
);
1672 ok( ref
== 0, "ref %d\n", ref
);
1674 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1675 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1679 str
= SysAllocString( szComplete4
);
1680 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1681 ok( r
== S_OK
, "loadXML failed\n");
1682 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1683 SysFreeString( str
);
1685 ref
= IXMLDOMDocument_AddRef( doc
);
1686 ok( ref
== 2, "ref %d\n", ref
);
1687 ref
= IXMLDOMDocument_AddRef( doc
);
1688 ok( ref
== 3, "ref %d\n", ref
);
1689 IXMLDOMDocument_Release( doc
);
1690 IXMLDOMDocument_Release( doc
);
1692 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1693 ok( r
== S_OK
, "should be a document element\n");
1694 ok( element
!= NULL
, "should be an element\n");
1696 ref
= IXMLDOMDocument_AddRef( doc
);
1697 ok( ref
== 2, "ref %d\n", ref
);
1698 IXMLDOMDocument_Release( doc
);
1700 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
1701 ok( r
== S_OK
, "rets %08x\n", r
);
1703 ref
= IXMLDOMNodeList_AddRef( node_list
);
1704 ok( ref
== 2, "ref %d\n", ref
);
1705 IXMLDOMNodeList_Release( node_list
);
1707 IXMLDOMNodeList_get_item( node_list
, 0, &node
);
1708 ok( r
== S_OK
, "rets %08x\n", r
);
1710 IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
1711 ok( r
== S_OK
, "rets %08x\n", r
);
1713 ref
= IXMLDOMNode_AddRef( node
);
1714 ok( ref
== 2, "ref %d\n", ref
);
1715 IXMLDOMNode_Release( node
);
1717 ref
= IXMLDOMNode_Release( node
);
1718 ok( ref
== 0, "ref %d\n", ref
);
1719 ref
= IXMLDOMNode_Release( node2
);
1720 ok( ref
== 0, "ref %d\n", ref
);
1722 ref
= IXMLDOMNodeList_Release( node_list
);
1723 ok( ref
== 0, "ref %d\n", ref
);
1725 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
1727 ref
= IXMLDOMDocument_Release( doc
);
1728 ok( ref
== 0, "ref %d\n", ref
);
1730 ref
= IXMLDOMElement_AddRef( element
);
1732 ok( ref
== 3, "ref %d\n", ref
);
1734 IXMLDOMElement_Release( element
);
1736 /* IUnknown must be unique however we obtain it */
1737 r
= IXMLDOMElement_QueryInterface( element
, &IID_IUnknown
, (LPVOID
*)&unk
);
1738 ok( r
== S_OK
, "rets %08x\n", r
);
1739 r
= IXMLDOMElement_QueryInterface( element
, &IID_IXMLDOMNode
, (LPVOID
*)&node
);
1740 ok( r
== S_OK
, "rets %08x\n", r
);
1741 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk2
);
1742 ok( r
== S_OK
, "rets %08x\n", r
);
1743 ok( unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
1745 IUnknown_Release( unk2
);
1746 IUnknown_Release( unk
);
1747 IXMLDOMNode_Release( node
);
1749 IXMLDOMElement_Release( element
);
1753 static void test_create(void)
1755 static const WCHAR szOne
[] = {'1',0};
1756 static const WCHAR szOneGarbage
[] = {'1','G','a','r','b','a','g','e',0};
1760 IXMLDOMDocument
*doc
;
1761 IXMLDOMElement
*element
;
1762 IXMLDOMComment
*comment
;
1764 IXMLDOMCDATASection
*cdata
;
1765 IXMLDOMNode
*root
, *node
, *child
;
1766 IXMLDOMNamedNodeMap
*attr_map
;
1771 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
1772 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
1776 /* types not supported for creation */
1778 V_I1(&var
) = NODE_DOCUMENT
;
1779 node
= (IXMLDOMNode
*)0x1;
1780 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1781 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1782 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1785 V_I1(&var
) = NODE_DOCUMENT_TYPE
;
1786 node
= (IXMLDOMNode
*)0x1;
1787 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1788 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1789 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1792 V_I1(&var
) = NODE_ENTITY
;
1793 node
= (IXMLDOMNode
*)0x1;
1794 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1795 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1796 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1799 V_I1(&var
) = NODE_NOTATION
;
1800 node
= (IXMLDOMNode
*)0x1;
1801 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1802 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1803 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1807 V_I1(&var
) = NODE_COMMENT
;
1809 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1810 ok( r
== S_OK
, "returns %08x\n", r
);
1811 ok( node
!= NULL
, "\n");
1813 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
1814 ok( r
== S_OK
, "returns %08x\n", r
);
1815 IXMLDOMNode_Release(node
);
1818 r
= IXMLDOMComment_get_data(comment
, &str
);
1819 ok( r
== S_OK
, "returns %08x\n", r
);
1820 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1821 IXMLDOMComment_Release(comment
);
1824 node
= (IXMLDOMNode
*)0x1;
1825 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1826 ok( r
== S_OK
, "returns %08x\n", r
);
1828 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
1829 ok( r
== S_OK
, "returns %08x\n", r
);
1830 IXMLDOMNode_Release(node
);
1833 r
= IXMLDOMComment_get_data(comment
, &str
);
1834 ok( r
== S_OK
, "returns %08x\n", r
);
1835 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1836 IXMLDOMComment_Release(comment
);
1839 node
= (IXMLDOMNode
*)0x1;
1840 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
1841 ok( r
== S_OK
, "returns %08x\n", r
);
1843 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
1844 ok( r
== S_OK
, "returns %08x\n", r
);
1845 IXMLDOMNode_Release(node
);
1848 r
= IXMLDOMComment_get_data(comment
, &str
);
1849 ok( r
== S_OK
, "returns %08x\n", r
);
1850 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1851 IXMLDOMComment_Release(comment
);
1856 V_I1(&var
) = NODE_TEXT
;
1858 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1859 ok( r
== S_OK
, "returns %08x\n", r
);
1860 ok( node
!= NULL
, "\n");
1862 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
1863 ok( r
== S_OK
, "returns %08x\n", r
);
1864 IXMLDOMNode_Release(node
);
1867 r
= IXMLDOMText_get_data(text
, &str
);
1868 ok( r
== S_OK
, "returns %08x\n", r
);
1869 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1870 IXMLDOMText_Release(text
);
1873 node
= (IXMLDOMNode
*)0x1;
1874 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1875 ok( r
== S_OK
, "returns %08x\n", r
);
1877 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
1878 ok( r
== S_OK
, "returns %08x\n", r
);
1879 IXMLDOMNode_Release(node
);
1882 r
= IXMLDOMText_get_data(text
, &str
);
1883 ok( r
== S_OK
, "returns %08x\n", r
);
1884 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1885 IXMLDOMText_Release(text
);
1888 node
= (IXMLDOMNode
*)0x1;
1889 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
1890 ok( r
== S_OK
, "returns %08x\n", r
);
1892 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
1893 ok( r
== S_OK
, "returns %08x\n", r
);
1894 IXMLDOMNode_Release(node
);
1897 r
= IXMLDOMText_get_data(text
, &str
);
1898 ok( r
== S_OK
, "returns %08x\n", r
);
1899 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1900 IXMLDOMText_Release(text
);
1903 /* NODE_CDATA_SECTION */
1905 V_I1(&var
) = NODE_CDATA_SECTION
;
1907 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1908 ok( r
== S_OK
, "returns %08x\n", r
);
1909 ok( node
!= NULL
, "\n");
1911 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
1912 ok( r
== S_OK
, "returns %08x\n", r
);
1913 IXMLDOMNode_Release(node
);
1916 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
1917 ok( r
== S_OK
, "returns %08x\n", r
);
1918 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1919 IXMLDOMCDATASection_Release(cdata
);
1922 node
= (IXMLDOMNode
*)0x1;
1923 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1924 ok( r
== S_OK
, "returns %08x\n", r
);
1926 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
1927 ok( r
== S_OK
, "returns %08x\n", r
);
1928 IXMLDOMNode_Release(node
);
1931 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
1932 ok( r
== S_OK
, "returns %08x\n", r
);
1933 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1934 IXMLDOMCDATASection_Release(cdata
);
1937 node
= (IXMLDOMNode
*)0x1;
1938 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
1939 ok( r
== S_OK
, "returns %08x\n", r
);
1941 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
1942 ok( r
== S_OK
, "returns %08x\n", r
);
1943 IXMLDOMNode_Release(node
);
1946 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
1947 ok( r
== S_OK
, "returns %08x\n", r
);
1948 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
1949 IXMLDOMCDATASection_Release(cdata
);
1952 /* NODE_ATTRIBUTE */
1954 V_I1(&var
) = NODE_ATTRIBUTE
;
1955 node
= (IXMLDOMNode
*)0x1;
1956 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1957 ok( r
== E_FAIL
, "returns %08x\n", r
);
1958 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1961 V_I1(&var
) = NODE_ATTRIBUTE
;
1962 node
= (IXMLDOMNode
*)0x1;
1963 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1964 ok( r
== E_FAIL
, "returns %08x\n", r
);
1965 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1968 V_I1(&var
) = NODE_ATTRIBUTE
;
1969 str
= SysAllocString( szlc
);
1970 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
1971 ok( r
== S_OK
, "returns %08x\n", r
);
1972 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
1975 /* NODE_PROCESSING_INSTRUCTION */
1977 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
1978 node
= (IXMLDOMNode
*)0x1;
1979 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
1980 ok( r
== E_FAIL
, "returns %08x\n", r
);
1981 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1984 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
1985 node
= (IXMLDOMNode
*)0x1;
1986 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
1987 ok( r
== E_FAIL
, "returns %08x\n", r
);
1988 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
1991 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
1992 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("pi"), NULL
, NULL
);
1993 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1995 /* NODE_ENTITY_REFERENCE */
1997 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
1998 node
= (IXMLDOMNode
*)0x1;
1999 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2000 ok( r
== E_FAIL
, "returns %08x\n", r
);
2001 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2004 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2005 node
= (IXMLDOMNode
*)0x1;
2006 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2007 ok( r
== E_FAIL
, "returns %08x\n", r
);
2008 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2012 V_I1(&var
) = NODE_ELEMENT
;
2013 node
= (IXMLDOMNode
*)0x1;
2014 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2015 ok( r
== E_FAIL
, "returns %08x\n", r
);
2016 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2019 V_I1(&var
) = NODE_ELEMENT
;
2020 node
= (IXMLDOMNode
*)0x1;
2021 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2022 ok( r
== E_FAIL
, "returns %08x\n", r
);
2023 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2026 V_I1(&var
) = NODE_ELEMENT
;
2027 str
= SysAllocString( szlc
);
2028 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2029 ok( r
== S_OK
, "returns %08x\n", r
);
2030 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2033 V_I1(&var
) = NODE_ELEMENT
;
2034 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, NULL
);
2035 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2038 V_R4(&var
) = NODE_ELEMENT
;
2039 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2040 ok( r
== S_OK
, "returns %08x\n", r
);
2041 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2043 V_VT(&var
) = VT_BSTR
;
2044 V_BSTR(&var
) = SysAllocString( szOne
);
2045 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2046 ok( r
== S_OK
, "returns %08x\n", r
);
2047 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2050 V_VT(&var
) = VT_BSTR
;
2051 V_BSTR(&var
) = SysAllocString( szOneGarbage
);
2052 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2053 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2054 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2058 V_I4(&var
) = NODE_ELEMENT
;
2059 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2060 ok( r
== S_OK
, "returns %08x\n", r
);
2061 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
2062 ok( r
== S_OK
, "returns %08x\n", r
);
2063 ok( node
== root
, "%p %p\n", node
, root
);
2065 ref
= IXMLDOMNode_AddRef( node
);
2066 ok(ref
== 3, "ref %d\n", ref
);
2067 IXMLDOMNode_Release( node
);
2069 ref
= IXMLDOMNode_Release( node
);
2070 ok(ref
== 1, "ref %d\n", ref
);
2071 SysFreeString( str
);
2074 V_I4(&var
) = NODE_ELEMENT
;
2075 str
= SysAllocString( szbs
);
2076 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2077 ok( r
== S_OK
, "returns %08x\n", r
);
2078 SysFreeString( str
);
2080 ref
= IXMLDOMNode_AddRef( node
);
2081 ok(ref
== 2, "ref = %d\n", ref
);
2082 IXMLDOMNode_Release( node
);
2084 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (LPVOID
*)&unk
);
2085 ok( r
== S_OK
, "returns %08x\n", r
);
2087 ref
= IXMLDOMNode_AddRef( unk
);
2088 ok(ref
== 3, "ref = %d\n", ref
);
2089 IXMLDOMNode_Release( unk
);
2091 V_VT(&var
) = VT_EMPTY
;
2092 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
2093 ok( r
== S_OK
, "returns %08x\n", r
);
2094 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
2095 IXMLDOMNode_Release( child
);
2096 IUnknown_Release( unk
);
2099 V_VT(&var
) = VT_NULL
;
2100 V_DISPATCH(&var
) = (IDispatch
*)node
;
2101 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
2102 ok( r
== S_OK
, "returns %08x\n", r
);
2103 ok( node
== child
, "%p %p\n", node
, child
);
2104 IXMLDOMNode_Release( child
);
2107 V_VT(&var
) = VT_NULL
;
2108 V_DISPATCH(&var
) = (IDispatch
*)node
;
2109 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
2110 ok( r
== S_OK
, "returns %08x\n", r
);
2111 IXMLDOMNode_Release( node
);
2113 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (LPVOID
*)&element
);
2114 ok( r
== S_OK
, "returns %08x\n", r
);
2116 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2117 ok( r
== S_OK
, "returns %08x\n", r
);
2118 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2119 ok( r
== S_OK
, "returns %08x\n", r
);
2120 ok( num
== 0, "num %d\n", num
);
2121 IXMLDOMNamedNodeMap_Release( attr_map
);
2123 V_VT(&var
) = VT_BSTR
;
2124 V_BSTR(&var
) = SysAllocString( szstr1
);
2125 name
= SysAllocString( szdl
);
2126 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2127 ok( r
== S_OK
, "returns %08x\n", r
);
2128 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2129 ok( r
== S_OK
, "returns %08x\n", r
);
2130 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2131 ok( r
== S_OK
, "returns %08x\n", r
);
2132 ok( num
== 1, "num %d\n", num
);
2133 IXMLDOMNamedNodeMap_Release( attr_map
);
2136 V_VT(&var
) = VT_BSTR
;
2137 V_BSTR(&var
) = SysAllocString( szstr2
);
2138 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2139 ok( r
== S_OK
, "returns %08x\n", r
);
2140 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2141 ok( r
== S_OK
, "returns %08x\n", r
);
2142 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2143 ok( r
== S_OK
, "returns %08x\n", r
);
2144 ok( num
== 1, "num %d\n", num
);
2145 IXMLDOMNamedNodeMap_Release( attr_map
);
2147 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2148 ok( r
== S_OK
, "returns %08x\n", r
);
2149 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
2151 SysFreeString(name
);
2153 V_VT(&var
) = VT_BSTR
;
2154 V_BSTR(&var
) = SysAllocString( szstr1
);
2155 name
= SysAllocString( szlc
);
2156 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2157 ok( r
== S_OK
, "returns %08x\n", r
);
2158 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2159 ok( r
== S_OK
, "returns %08x\n", r
);
2160 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2161 ok( r
== S_OK
, "returns %08x\n", r
);
2162 ok( num
== 2, "num %d\n", num
);
2163 IXMLDOMNamedNodeMap_Release( attr_map
);
2165 SysFreeString(name
);
2169 name
= SysAllocString( szbs
);
2170 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2171 ok( r
== S_OK
, "returns %08x\n", r
);
2173 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2174 ok( r
== S_OK
, "returns %08x\n", r
);
2175 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
2177 SysFreeString(name
);
2179 /* Create an Attribute */
2181 V_I4(&var
) = NODE_ATTRIBUTE
;
2182 str
= SysAllocString( szAttribute
);
2183 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2184 ok( r
== S_OK
, "returns %08x\n", r
);
2185 ok( node
!= NULL
, "node was null\n");
2190 r
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
2191 ok( r
== S_OK
, "returns %08x\n", r
);
2192 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
2194 IXMLDOMNode_Release( node
);
2197 IXMLDOMElement_Release( element
);
2198 IXMLDOMNode_Release( root
);
2199 IXMLDOMDocument_Release( doc
);
2202 static void test_getElementsByTagName(void)
2207 IXMLDOMDocument
*doc
;
2208 IXMLDOMNodeList
*node_list
;
2211 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2212 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2216 str
= SysAllocString( szComplete4
);
2217 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2218 ok( r
== S_OK
, "loadXML failed\n");
2219 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2220 SysFreeString( str
);
2222 str
= SysAllocString( szstar
);
2223 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2224 ok( r
== S_OK
, "ret %08x\n", r
);
2225 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2226 ok( r
== S_OK
, "ret %08x\n", r
);
2227 ok( len
== 6, "len %d\n", len
);
2229 test_disp((IUnknown
*)node_list
);
2231 IXMLDOMNodeList_Release( node_list
);
2232 SysFreeString( str
);
2234 str
= SysAllocString( szbs
);
2235 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2236 ok( r
== S_OK
, "ret %08x\n", r
);
2237 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2238 ok( r
== S_OK
, "ret %08x\n", r
);
2239 ok( len
== 1, "len %d\n", len
);
2240 IXMLDOMNodeList_Release( node_list
);
2241 SysFreeString( str
);
2243 str
= SysAllocString( szdl
);
2244 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2245 ok( r
== S_OK
, "ret %08x\n", r
);
2246 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2247 ok( r
== S_OK
, "ret %08x\n", r
);
2248 ok( len
== 0, "len %d\n", len
);
2249 IXMLDOMNodeList_Release( node_list
);
2250 SysFreeString( str
);
2252 str
= SysAllocString( szstr1
);
2253 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
2254 ok( r
== S_OK
, "ret %08x\n", r
);
2255 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2256 ok( r
== S_OK
, "ret %08x\n", r
);
2257 ok( len
== 0, "len %d\n", len
);
2258 IXMLDOMNodeList_Release( node_list
);
2259 SysFreeString( str
);
2261 IXMLDOMDocument_Release( doc
);
2264 static void test_get_text(void)
2269 IXMLDOMDocument
*doc
;
2270 IXMLDOMNode
*node
, *node2
, *node3
;
2271 IXMLDOMNode
*nodeRoot
;
2272 IXMLDOMNodeList
*node_list
;
2273 IXMLDOMNamedNodeMap
*node_map
;
2276 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2277 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2281 str
= SysAllocString( szComplete4
);
2282 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2283 ok( r
== S_OK
, "loadXML failed\n");
2284 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2285 SysFreeString( str
);
2287 str
= SysAllocString( szbs
);
2288 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
2289 ok( r
== S_OK
, "ret %08x\n", r
);
2292 /* Test to get all child node text. */
2293 r
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (LPVOID
*)&nodeRoot
);
2294 ok( r
== S_OK
, "ret %08x\n", r
);
2297 r
= IXMLDOMNode_get_text( nodeRoot
, &str
);
2298 ok( r
== S_OK
, "ret %08x\n", r
);
2299 ok( compareIgnoreReturnsWhitespace(str
, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text\n");
2302 IXMLDOMNode_Release(nodeRoot
);
2306 /* this test crashes on win9x */
2307 r
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatch
, NULL
);
2308 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2311 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
2312 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2314 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2315 ok( r
== S_OK
, "ret %08x\n", r
);
2316 ok( len
== 1, "expect 1 got %d\n", len
);
2318 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
2319 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2321 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
2322 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2324 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
2325 ok( r
== S_OK
, "ret %08x\n", r
);
2326 IXMLDOMNodeList_Release( node_list
);
2328 /* Invalid output parameter*/
2329 r
= IXMLDOMNode_get_text( node
, NULL
);
2330 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2332 r
= IXMLDOMNode_get_text( node
, &str
);
2333 ok( r
== S_OK
, "ret %08x\n", r
);
2334 ok( !memcmp(str
, szfn1_txt
, lstrlenW(szfn1_txt
) ), "wrong string\n" );
2337 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
2338 ok( r
== S_OK
, "ret %08x\n", r
);
2340 str
= SysAllocString( szvr
);
2341 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
2342 ok( r
== S_OK
, "ret %08x\n", r
);
2345 r
= IXMLDOMNode_get_text( node2
, &str
);
2346 ok( r
== S_OK
, "ret %08x\n", r
);
2347 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
2350 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
2351 ok( r
== S_OK
, "ret %08x\n", r
);
2353 r
= IXMLDOMNode_get_text( node3
, &str
);
2354 ok( r
== S_OK
, "ret %08x\n", r
);
2355 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
2359 IXMLDOMNode_Release( node3
);
2360 IXMLDOMNode_Release( node2
);
2361 IXMLDOMNamedNodeMap_Release( node_map
);
2362 IXMLDOMNode_Release( node
);
2363 IXMLDOMDocument_Release( doc
);
2366 static void test_get_childNodes(void)
2371 IXMLDOMDocument
*doc
;
2372 IXMLDOMElement
*element
;
2373 IXMLDOMNode
*node
, *node2
;
2374 IXMLDOMNodeList
*node_list
, *node_list2
;
2377 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2378 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2382 str
= SysAllocString( szComplete4
);
2383 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2384 ok( r
== S_OK
, "loadXML failed\n");
2385 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2386 SysFreeString( str
);
2388 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2389 ok( r
== S_OK
, "ret %08x\n", r
);
2391 r
= IXMLDOMElement_get_childNodes( element
, &node_list
);
2392 ok( r
== S_OK
, "ret %08x\n", r
);
2394 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
2395 ok( r
== S_OK
, "ret %08x\n", r
);
2396 ok( len
== 4, "len %d\n", len
);
2398 r
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
2399 ok( r
== S_OK
, "ret %08x\n", r
);
2401 r
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
2402 ok( r
== S_OK
, "ret %08x\n", r
);
2404 r
= IXMLDOMNodeList_get_length( node_list2
, &len
);
2405 ok( r
== S_OK
, "ret %08x\n", r
);
2406 ok( len
== 0, "len %d\n", len
);
2408 r
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
2409 ok( r
== S_FALSE
, "ret %08x\n", r
);
2411 IXMLDOMNodeList_Release( node_list2
);
2412 IXMLDOMNode_Release( node
);
2413 IXMLDOMNodeList_Release( node_list
);
2414 IXMLDOMElement_Release( element
);
2415 IXMLDOMDocument_Release( doc
);
2418 static void test_removeChild(void)
2423 IXMLDOMDocument
*doc
;
2424 IXMLDOMElement
*element
, *lc_element
;
2425 IXMLDOMNode
*fo_node
, *ba_node
, *removed_node
, *temp_node
, *lc_node
;
2426 IXMLDOMNodeList
*root_list
, *fo_list
;
2428 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2429 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2433 str
= SysAllocString( szComplete4
);
2434 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2435 ok( r
== S_OK
, "loadXML failed\n");
2436 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2437 SysFreeString( str
);
2439 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2440 ok( r
== S_OK
, "ret %08x\n", r
);
2442 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2443 ok( r
== S_OK
, "ret %08x\n", r
);
2445 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
2446 ok( r
== S_OK
, "ret %08x\n", r
);
2448 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2449 ok( r
== S_OK
, "ret %08x\n", r
);
2451 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
2452 ok( r
== S_OK
, "ret %08x\n", r
);
2454 /* invalid parameter: NULL ptr */
2455 removed_node
= (void*)0xdeadbeef;
2456 r
= IXMLDOMElement_removeChild( element
, NULL
, &removed_node
);
2457 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2458 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2460 /* ba_node is a descendant of element, but not a direct child. */
2461 removed_node
= (void*)0xdeadbeef;
2462 r
= IXMLDOMElement_removeChild( element
, ba_node
, &removed_node
);
2463 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2464 ok( removed_node
== NULL
, "%p\n", removed_node
);
2466 r
= IXMLDOMElement_removeChild( element
, fo_node
, &removed_node
);
2467 ok( r
== S_OK
, "ret %08x\n", r
);
2468 ok( fo_node
== removed_node
, "node %p node2 %p\n", fo_node
, removed_node
);
2470 /* try removing already removed child */
2471 temp_node
= (void*)0xdeadbeef;
2472 r
= IXMLDOMElement_removeChild( element
, fo_node
, &temp_node
);
2473 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2474 ok( temp_node
== NULL
, "%p\n", temp_node
);
2476 /* the removed node has no parent anymore */
2477 r
= IXMLDOMNode_get_parentNode( removed_node
, &temp_node
);
2478 ok( r
== S_FALSE
, "ret %08x\n", r
);
2479 ok( temp_node
== NULL
, "%p\n", temp_node
);
2481 IXMLDOMNode_Release( removed_node
);
2482 IXMLDOMNode_Release( ba_node
);
2483 IXMLDOMNodeList_Release( fo_list
);
2485 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
2486 ok( r
== S_OK
, "ret %08x\n", r
);
2488 r
= IXMLDOMElement_QueryInterface( lc_node
, &IID_IXMLDOMElement
, (LPVOID
*)&lc_element
);
2489 ok( r
== S_OK
, "ret %08x\n", r
);
2491 /* MS quirk: passing wrong interface pointer works, too */
2492 r
= IXMLDOMElement_removeChild( element
, (IXMLDOMNode
*)lc_element
, NULL
);
2493 ok( r
== S_OK
, "ret %08x\n", r
);
2495 r
= IXMLDOMNode_get_parentNode( lc_node
, &temp_node
);
2496 ok( r
== S_FALSE
, "ret %08x\n", r
);
2497 ok( temp_node
== NULL
, "%p\n", temp_node
);
2499 IXMLDOMNode_Release( lc_node
);
2500 IXMLDOMNodeList_Release( root_list
);
2501 IXMLDOMElement_Release( element
);
2502 IXMLDOMDocument_Release( doc
);
2505 static void test_replaceChild(void)
2510 IXMLDOMDocument
*doc
;
2511 IXMLDOMElement
*element
, *ba_element
;
2512 IXMLDOMNode
*fo_node
, *ba_node
, *lc_node
, *removed_node
, *temp_node
;
2513 IXMLDOMNodeList
*root_list
, *fo_list
;
2514 IUnknown
* unk1
, *unk2
;
2517 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2518 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2522 str
= SysAllocString( szComplete4
);
2523 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2524 ok( r
== S_OK
, "loadXML failed\n");
2525 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2526 SysFreeString( str
);
2528 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2529 ok( r
== S_OK
, "ret %08x\n", r
);
2531 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2532 ok( r
== S_OK
, "ret %08x\n", r
);
2534 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
2535 ok( r
== S_OK
, "ret %08x\n", r
);
2537 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
2538 ok( r
== S_OK
, "ret %08x\n", r
);
2540 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2541 ok( r
== S_OK
, "ret %08x\n", r
);
2543 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
2544 ok( r
== S_OK
, "ret %08x\n", r
);
2546 IXMLDOMNodeList_Release( fo_list
);
2548 /* invalid parameter: NULL ptr for element to remove */
2549 removed_node
= (void*)0xdeadbeef;
2550 r
= IXMLDOMElement_replaceChild( element
, ba_node
, NULL
, &removed_node
);
2551 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2552 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2554 /* invalid parameter: NULL for replacement element. (Sic!) */
2555 removed_node
= (void*)0xdeadbeef;
2556 r
= IXMLDOMElement_replaceChild( element
, NULL
, fo_node
, &removed_node
);
2557 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2558 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
2560 /* invalid parameter: OldNode is not a child */
2561 removed_node
= (void*)0xdeadbeef;
2562 r
= IXMLDOMElement_replaceChild( element
, lc_node
, ba_node
, &removed_node
);
2563 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2564 ok( removed_node
== NULL
, "%p\n", removed_node
);
2566 /* invalid parameter: would create loop */
2567 removed_node
= (void*)0xdeadbeef;
2568 r
= IXMLDOMNode_replaceChild( fo_node
, fo_node
, ba_node
, &removed_node
);
2569 ok( r
== E_FAIL
, "ret %08x\n", r
);
2570 ok( removed_node
== NULL
, "%p\n", removed_node
);
2572 r
= IXMLDOMElement_replaceChild( element
, ba_node
, fo_node
, NULL
);
2573 ok( r
== S_OK
, "ret %08x\n", r
);
2575 r
= IXMLDOMNodeList_get_item( root_list
, 3, &temp_node
);
2576 ok( r
== S_OK
, "ret %08x\n", r
);
2578 /* ba_node and temp_node refer to the same node, yet they
2579 are different interface pointers */
2580 ok( ba_node
!= temp_node
, "ba_node %p temp_node %p\n", ba_node
, temp_node
);
2581 r
= IXMLDOMNode_QueryInterface( temp_node
, &IID_IUnknown
, (void**)&unk1
);
2582 ok( r
== S_OK
, "ret %08x\n", r
);
2583 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IUnknown
, (void**)&unk2
);
2584 ok( r
== S_OK
, "ret %08x\n", r
);
2585 todo_wine
ok( unk1
== unk2
, "unk1 %p unk2 %p\n", unk1
, unk2
);
2587 IUnknown_Release( unk1
);
2588 IUnknown_Release( unk2
);
2590 /* ba_node should have been removed from below fo_node */
2591 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
2592 ok( r
== S_OK
, "ret %08x\n", r
);
2594 /* MS quirk: replaceChild also accepts elements instead of nodes */
2595 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IXMLDOMElement
, (void**)&ba_element
);
2596 ok( r
== S_OK
, "ret %08x\n", r
);
2598 r
= IXMLDOMElement_replaceChild( element
, ba_node
, (IXMLDOMNode
*)ba_element
, &removed_node
);
2599 ok( r
== S_OK
, "ret %08x\n", r
);
2601 r
= IXMLDOMNodeList_get_length( fo_list
, &len
);
2602 ok( r
== S_OK
, "ret %08x\n", r
);
2603 ok( len
== 0, "len %d\n", len
);
2605 IXMLDOMNodeList_Release( fo_list
);
2607 IXMLDOMNode_Release(ba_node
);
2608 IXMLDOMNode_Release(fo_node
);
2609 IXMLDOMNode_Release(temp_node
);
2610 IXMLDOMNodeList_Release( root_list
);
2611 IXMLDOMElement_Release( element
);
2612 IXMLDOMDocument_Release( doc
);
2615 static void test_removeNamedItem(void)
2617 IXMLDOMDocument
*doc
;
2618 IXMLDOMElement
*element
;
2619 IXMLDOMNode
*pr_node
, *removed_node
, *removed_node2
;
2620 IXMLDOMNodeList
*root_list
;
2621 IXMLDOMNamedNodeMap
* pr_attrs
;
2627 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2628 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2632 str
= SysAllocString( szComplete4
);
2633 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2634 ok( r
== S_OK
, "loadXML failed\n");
2635 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2636 SysFreeString( str
);
2638 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2639 ok( r
== S_OK
, "ret %08x\n", r
);
2641 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
2642 ok( r
== S_OK
, "ret %08x\n", r
);
2644 r
= IXMLDOMNodeList_get_item( root_list
, 1, &pr_node
);
2645 ok( r
== S_OK
, "ret %08x\n", r
);
2647 r
= IXMLDOMNode_get_attributes( pr_node
, &pr_attrs
);
2648 ok( r
== S_OK
, "ret %08x\n", r
);
2650 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2651 ok( r
== S_OK
, "ret %08x\n", r
);
2652 ok( len
== 3, "length %d\n", len
);
2654 removed_node
= (void*)0xdeadbeef;
2655 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, NULL
, &removed_node
);
2656 ok ( r
== E_INVALIDARG
, "ret %08x\n", r
);
2657 ok ( removed_node
== (void*)0xdeadbeef, "removed_node == %p\n", removed_node
);
2659 removed_node
= (void*)0xdeadbeef;
2660 str
= SysAllocString(szvr
);
2661 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node
);
2662 ok ( r
== S_OK
, "ret %08x\n", r
);
2664 removed_node2
= (void*)0xdeadbeef;
2665 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node2
);
2666 ok ( r
== S_FALSE
, "ret %08x\n", r
);
2667 ok ( removed_node2
== NULL
, "removed_node == %p\n", removed_node2
);
2669 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2670 ok( r
== S_OK
, "ret %08x\n", r
);
2671 ok( len
== 2, "length %d\n", len
);
2673 r
= IXMLDOMNamedNodeMap_setNamedItem( pr_attrs
, removed_node
, NULL
);
2674 ok ( r
== S_OK
, "ret %08x\n", r
);
2675 IXMLDOMNode_Release(removed_node
);
2677 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2678 ok( r
== S_OK
, "ret %08x\n", r
);
2679 ok( len
== 3, "length %d\n", len
);
2681 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
2682 ok ( r
== S_OK
, "ret %08x\n", r
);
2684 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
2685 ok( r
== S_OK
, "ret %08x\n", r
);
2686 ok( len
== 2, "length %d\n", len
);
2688 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
2689 ok ( r
== S_FALSE
, "ret %08x\n", r
);
2693 IXMLDOMNamedNodeMap_Release( pr_attrs
);
2694 IXMLDOMNode_Release( pr_node
);
2695 IXMLDOMNodeList_Release( root_list
);
2696 IXMLDOMElement_Release( element
);
2697 IXMLDOMDocument_Release( doc
);
2700 static void test_XMLHTTP(void)
2702 static const WCHAR wszBody
[] = {'m','o','d','e','=','T','e','s','t',0};
2703 static WCHAR wszPOST
[] = {'P','O','S','T',0};
2704 static WCHAR wszUrl
[] = {'h','t','t','p',':','/','/',
2705 'c','r','o','s','s','o','v','e','r','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
2706 'p','o','s','t','t','e','s','t','.','p','h','p',0};
2707 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
2708 IXMLHttpRequest
*pXMLHttpRequest
;
2709 BSTR bstrResponse
, str1
, str2
;
2713 HRESULT hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
,
2714 CLSCTX_INPROC_SERVER
, &IID_IXMLHttpRequest
,
2715 (void **)&pXMLHttpRequest
);
2716 ok(hr
== S_OK
, "CoCreateInstance(CLSID_XMLHTTPRequest) should have succeeded instead of failing with 0x%08x\n", hr
);
2720 VariantInit(&dummy
);
2721 V_VT(&dummy
) = VT_ERROR
;
2722 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
2723 VariantInit(&varfalse
);
2724 V_VT(&varfalse
) = VT_BOOL
;
2725 V_BOOL(&varfalse
) = VARIANT_FALSE
;
2726 V_VT(&varbody
) = VT_BSTR
;
2727 V_BSTR(&varbody
) = SysAllocString(wszBody
);
2729 str1
= SysAllocString(wszPOST
);
2730 str2
= SysAllocString(wszUrl
);
2731 hr
= IXMLHttpRequest_open(pXMLHttpRequest
, str1
, str2
, varfalse
, dummy
, dummy
);
2732 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_open should have succeeded instead of failing with 0x%08x\n", hr
);
2733 SysFreeString(str1
);
2734 SysFreeString(str2
);
2736 hr
= IXMLHttpRequest_send(pXMLHttpRequest
, varbody
);
2737 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_send should have succeeded instead of failing with 0x%08x\n", hr
);
2738 VariantClear(&varbody
);
2740 hr
= IXMLHttpRequest_get_responseText(pXMLHttpRequest
, &bstrResponse
);
2741 todo_wine
ok(hr
== S_OK
, "IXMLHttpRequest_get_responseText should have succeeded instead of failing with 0x%08x\n", hr
);
2742 /* the server currently returns "FAILED" because the Content-Type header is
2743 * not what the server expects */
2746 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)), "bstrResponse differs from what was expected\n");
2747 SysFreeString(bstrResponse
);
2750 IXMLHttpRequest_Release(pXMLHttpRequest
);
2753 static void test_IXMLDOMDocument2(void)
2758 IXMLDOMDocument
*doc
;
2759 IXMLDOMDocument2
*doc2
;
2760 IDispatchEx
*dispex
;
2764 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2765 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
2769 str
= SysAllocString( szComplete4
);
2770 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2771 ok( r
== S_OK
, "loadXML failed\n");
2772 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2773 SysFreeString( str
);
2775 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
2776 ok( r
== S_OK
, "ret %08x\n", r
);
2777 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
2779 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IDispatchEx
, (void**)&dispex
);
2780 ok( r
== S_OK
, "ret %08x\n", r
);
2783 IDispatchEx_Release(dispex
);
2786 /* we will check if the variant got cleared */
2787 ref
= IXMLDOMDocument2_AddRef(doc2
);
2788 expect_eq(ref
, 3, int, "%d"); /* doc, doc2, AddRef*/
2789 V_VT(&var
) = VT_UNKNOWN
;
2790 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
2793 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
2794 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
2795 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
2798 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
2799 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2800 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
2803 /* the variant didn't get cleared*/
2804 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
2806 /* setProperty tests */
2807 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
2808 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
2809 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
2810 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2811 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2812 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
2814 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
2815 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
2816 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2817 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
2819 IXMLDOMDocument2_Release( doc2
);
2820 IXMLDOMDocument_Release( doc
);
2824 static void test_XPath(void)
2829 IXMLDOMDocument2
*doc
;
2830 IXMLDOMNode
*rootNode
;
2831 IXMLDOMNode
*elem1Node
;
2833 IXMLDOMNodeList
*list
;
2835 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
,
2836 CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2840 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
));
2841 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
2843 /* switch to XPath */
2844 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
2846 /* some simple queries*/
2847 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
));
2848 ole_check(IXMLDOMNodeList_get_item(list
, 0, &rootNode
));
2849 ole_check(IXMLDOMNodeList_reset(list
));
2850 expect_list_and_release(list
, "E2.D1");
2851 if (rootNode
== NULL
)
2854 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//c"), &list
));
2855 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
2857 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
2858 expect_list_and_release(list
, "E3.E2.E2.D1");
2860 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
2861 /* using get_item for query results advances the position */
2862 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
2863 expect_node(node
, "E2.E2.D1");
2864 IXMLDOMNode_Release(node
);
2865 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
2866 expect_node(node
, "E4.E2.D1");
2867 IXMLDOMNode_Release(node
);
2868 ole_check(IXMLDOMNodeList_reset(list
));
2869 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
2871 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
2872 expect_list_and_release(list
, "E2.D1");
2874 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
2875 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
2876 ole_check(IXMLDOMNodeList_reset(list
));
2877 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
2879 /* select an attribute */
2880 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
2881 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
2883 /* would evaluate to a number */
2884 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
2885 /* would evaluate to a boolean */
2886 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
2887 /* would evaluate to a string */
2888 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
2891 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
2892 expect_list_and_release(list
, "");
2893 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("elem//c"), &list
));
2894 expect_list_and_release(list
, "");
2895 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
2896 expect_list_and_release(list
, "");
2898 /* foo undeclared in document node */
2899 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2900 /* undeclared in <root> node */
2901 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
2902 /* undeclared in <elem> node */
2903 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
2904 /* but this trick can be used */
2905 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
2906 expect_list_and_release(list
, "E3.E4.E2.D1");
2908 /* it has to be declared in SelectionNamespaces */
2909 todo_wine
ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2910 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
2912 /* now the namespace can be used */
2913 todo_wine
ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//test:c"), &list
));
2914 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2915 todo_wine
ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
2916 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2917 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
2918 todo_wine
expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
2919 todo_wine
ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
2920 todo_wine
expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1");
2922 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
2923 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2924 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
2926 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2929 todo_wine
ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
2930 todo_wine
expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
2931 if (V_VT(&var
) == VT_BSTR
)
2932 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
2934 /* extra attributes - same thing*/
2935 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
2936 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
2937 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
2939 IXMLDOMNode_Release(rootNode
);
2940 IXMLDOMNode_Release(elem1Node
);
2941 IXMLDOMDocument_Release(doc
);
2945 static void test_cloneNode(void )
2947 IXMLDOMDocument
*doc
= NULL
;
2949 IXMLDOMNodeList
*pList
;
2950 IXMLDOMNamedNodeMap
*mapAttr
;
2951 LONG nLength
= 0, nLength1
= 0;
2952 LONG nAttrCnt
= 0, nAttrCnt1
= 0;
2954 IXMLDOMNode
*node_clone
;
2955 IXMLDOMNode
*node_first
;
2958 static const WCHAR szSearch
[] = { 'l', 'c', '/', 'p', 'r', 0 };
2960 r
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
2964 str
= SysAllocString( szComplete4
);
2965 ole_check(IXMLDOMDocument_loadXML(doc
, str
, &b
));
2966 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
2972 str
= SysAllocString( szSearch
);
2973 r
= IXMLDOMNode_selectSingleNode(doc
, str
, &node
);
2974 ok( r
== S_OK
, "ret %08x\n", r
);
2975 ok( node
!= NULL
, "node %p\n", node
);
2980 IXMLDOMDocument_Release(doc
);
2984 /* Check invalid parameter */
2985 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
2986 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
2989 r
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
2990 ok( r
== S_OK
, "ret %08x\n", r
);
2991 ok( node_clone
!= NULL
, "node %p\n", node
);
2995 IXMLDOMDocument_Release(doc
);
2996 IXMLDOMNode_Release(node
);
3000 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
3001 ok( r
== S_OK
, "ret %08x\n", r
);
3004 IXMLDOMDocument
*doc2
;
3006 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
3007 ok( r
== S_OK
, "ret %08x\n", r
);
3009 IXMLDOMDocument_Release(doc2
);
3011 IXMLDOMNode_Release(node_first
);
3014 r
= IXMLDOMNode_get_childNodes(node
, &pList
);
3015 ok( r
== S_OK
, "ret %08x\n", r
);
3018 IXMLDOMNodeList_get_length(pList
, &nLength
);
3019 IXMLDOMNodeList_Release(pList
);
3022 r
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
3023 ok( r
== S_OK
, "ret %08x\n", r
);
3026 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt
);
3027 IXMLDOMNamedNodeMap_Release(mapAttr
);
3030 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
3031 ok( r
== S_OK
, "ret %08x\n", r
);
3034 IXMLDOMNodeList_get_length(pList
, &nLength1
);
3035 IXMLDOMNodeList_Release(pList
);
3038 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
3039 ok( r
== S_OK
, "ret %08x\n", r
);
3042 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
3043 IXMLDOMNamedNodeMap_Release(mapAttr
);
3046 ok(nLength
== nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
3047 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
3048 IXMLDOMNode_Release(node_clone
);
3051 r
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
3052 ok( r
== S_OK
, "ret %08x\n", r
);
3053 ok( node_clone
!= NULL
, "node %p\n", node
);
3057 IXMLDOMDocument_Release(doc
);
3058 IXMLDOMNode_Release(node
);
3062 r
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
3063 ok( r
== S_FALSE
, "ret %08x\n", r
);
3066 IXMLDOMDocument
*doc2
;
3068 r
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
3069 ok( r
== S_OK
, "ret %08x\n", r
);
3071 IXMLDOMDocument_Release(doc2
);
3073 IXMLDOMNode_Release(node_first
);
3076 r
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
3077 ok( r
== S_OK
, "ret %08x\n", r
);
3080 IXMLDOMNodeList_get_length(pList
, &nLength1
);
3081 ok( nLength1
== 0, "Length should be 0 (%d)\n", nLength1
);
3082 IXMLDOMNodeList_Release(pList
);
3085 r
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
3086 ok( r
== S_OK
, "ret %08x\n", r
);
3089 IXMLDOMNamedNodeMap_get_length(mapAttr
, &nAttrCnt1
);
3090 ok( nAttrCnt1
== 3, "Attribute count should be 3 (%d)\n", nAttrCnt1
);
3091 IXMLDOMNamedNodeMap_Release(mapAttr
);
3094 ok(nLength
!= nLength1
, "wrong Child count (%d, %d)\n", nLength
, nLength1
);
3095 ok(nAttrCnt
== nAttrCnt1
, "wrong Attribute count (%d, %d)\n", nAttrCnt
, nAttrCnt1
);
3096 IXMLDOMNode_Release(node_clone
);
3099 IXMLDOMNode_Release(node
);
3100 IXMLDOMDocument_Release(doc
);
3103 static void test_xmlTypes(void)
3105 IXMLDOMDocument
*doc
= NULL
;
3106 IXMLDOMElement
*pRoot
;
3108 IXMLDOMComment
*pComment
;
3109 IXMLDOMElement
*pElement
;
3110 IXMLDOMAttribute
*pAttribute
;
3111 IXMLDOMNamedNodeMap
*pAttribs
;
3112 IXMLDOMCDATASection
*pCDataSec
;
3113 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
3114 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
3115 IXMLDOMEntityReference
*pEntityRef
= NULL
;
3117 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1; /* Used for testing Siblings */
3121 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
3125 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
3126 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3128 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
3129 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3130 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
3132 /* test previous Sibling */
3133 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
3134 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3136 pNextChild
= (IXMLDOMNode
*)0x1;
3137 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
3138 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3139 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3141 /* test get_attributes */
3142 hr
= IXMLDOMDocument_get_attributes( doc
, NULL
);
3143 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3145 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3146 hr
= IXMLDOMDocument_get_attributes( doc
, &pAttribs
);
3147 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3148 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3150 /* test get_dataType */
3151 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
3152 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3153 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3156 /* test nodeTypeString */
3157 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
3158 ok(hr
== S_OK
, "ret %08x\n", hr
);
3159 ok( !lstrcmpW( str
, _bstr_("document") ), "incorrect nodeTypeString string\n");
3162 /* test implementation */
3163 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
3164 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3166 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
3167 ok(hr
== S_OK
, "ret %08x\n", hr
);
3170 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
3171 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
3173 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
3174 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3176 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
3177 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3179 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
3180 ok(hr
== S_OK
, "ret %08x\n", hr
);
3181 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
3183 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
3184 ok(hr
== S_OK
, "ret %08x\n", hr
);
3185 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
3187 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
3188 ok(hr
== S_OK
, "ret %08x\n", hr
);
3189 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
3191 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
3192 ok(hr
== S_OK
, "ret %08x\n", hr
);
3193 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
3195 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
3196 ok(hr
== S_OK
, "ret %08x\n", hr
);
3197 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
3199 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
3200 ok(hr
== S_OK
, "ret %08x\n", hr
);
3201 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
3203 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
3204 ok(hr
== S_OK
, "ret %08x\n", hr
);
3205 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
3207 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
3208 ok(hr
== S_OK
, "ret %08x\n", hr
);
3209 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
3211 SysFreeString(sEmpty
);
3212 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
3215 pRoot
= (IXMLDOMElement
*)0x1;
3216 hr
= IXMLDOMDocument_createElement(doc
, NULL
, &pRoot
);
3217 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3218 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
3220 pRoot
= (IXMLDOMElement
*)0x1;
3221 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(""), &pRoot
);
3222 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3223 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
3225 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
3226 ok(hr
== S_OK
, "ret %08x\n", hr
);
3229 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
3230 ok(hr
== S_OK
, "ret %08x\n", hr
);
3234 str
= SysAllocString(szComment
);
3235 hr
= IXMLDOMDocument_createComment(doc
, str
, &pComment
);
3237 ok(hr
== S_OK
, "ret %08x\n", hr
);
3240 /* test get_attributes */
3241 hr
= IXMLDOMComment_get_attributes( pComment
, NULL
);
3242 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3244 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3245 hr
= IXMLDOMComment_get_attributes( pComment
, &pAttribs
);
3246 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3247 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3249 /* test nodeTypeString */
3250 hr
= IXMLDOMComment_get_nodeTypeString(pComment
, &str
);
3251 ok(hr
== S_OK
, "ret %08x\n", hr
);
3252 ok( !lstrcmpW( str
, _bstr_("comment") ), "incorrect nodeTypeString string\n");
3255 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
3256 ok(hr
== S_OK
, "ret %08x\n", hr
);
3258 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
3259 ok(hr
== S_OK
, "ret %08x\n", hr
);
3260 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
3263 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
3264 ok(hr
== S_OK
, "ret %08x\n", hr
);
3265 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
3268 hr
= IXMLDOMComment_get_dataType(pComment
, &v
);
3269 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3270 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3273 /* put data Tests */
3274 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
3275 ok(hr
== S_OK
, "ret %08x\n", hr
);
3277 /* get data Tests */
3278 hr
= IXMLDOMComment_get_data(pComment
, &str
);
3279 ok(hr
== S_OK
, "ret %08x\n", hr
);
3280 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
3283 /* get data Tests */
3284 hr
= IXMLDOMComment_get_nodeValue(pComment
, &v
);
3285 ok(hr
== S_OK
, "ret %08x\n", hr
);
3286 ok( V_VT(&v
) == VT_BSTR
, "incorrect dataType type\n");
3287 ok( !lstrcmpW( V_BSTR(&v
), _bstr_("This &is a ; test <>\\") ), "incorrect get_nodeValue string\n");
3290 /* Confirm XML text is good */
3291 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
3292 ok(hr
== S_OK
, "ret %08x\n", hr
);
3293 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
3296 /* Confirm we get the put_data Text back */
3297 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3298 ok(hr
== S_OK
, "ret %08x\n", hr
);
3299 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
3302 /* test length property */
3303 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3304 ok(hr
== S_OK
, "ret %08x\n", hr
);
3305 ok(len
== 21, "expected 21 got %d\n", len
);
3307 /* test substringData */
3308 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
3309 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3311 /* test substringData - Invalid offset */
3312 str
= (BSTR
)&szElement
;
3313 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
3314 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3315 ok( str
== NULL
, "incorrect string\n");
3317 /* test substringData - Invalid offset */
3318 str
= (BSTR
)&szElement
;
3319 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
3320 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3321 ok( str
== NULL
, "incorrect string\n");
3323 /* test substringData - Invalid size */
3324 str
= (BSTR
)&szElement
;
3325 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
3326 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3327 ok( str
== NULL
, "incorrect string\n");
3329 /* test substringData - Invalid size */
3330 str
= (BSTR
)&szElement
;
3331 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
3332 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3333 ok( str
== NULL
, "incorrect string\n");
3335 /* test substringData - Start of string */
3336 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
3337 ok(hr
== S_OK
, "ret %08x\n", hr
);
3338 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
3341 /* test substringData - Middle of string */
3342 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
3343 ok(hr
== S_OK
, "ret %08x\n", hr
);
3344 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
3347 /* test substringData - End of string */
3348 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
3349 ok(hr
== S_OK
, "ret %08x\n", hr
);
3350 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
3353 /* test appendData */
3354 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
3355 ok(hr
== S_OK
, "ret %08x\n", hr
);
3357 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
3358 ok(hr
== S_OK
, "ret %08x\n", hr
);
3360 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
3361 ok(hr
== S_OK
, "ret %08x\n", hr
);
3363 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3364 ok(hr
== S_OK
, "ret %08x\n", hr
);
3365 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
3368 /* test insertData */
3369 str
= SysAllocStringLen(NULL
, 0);
3370 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
3371 ok(hr
== S_OK
, "ret %08x\n", hr
);
3373 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
3374 ok(hr
== S_OK
, "ret %08x\n", hr
);
3376 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
3377 ok(hr
== S_OK
, "ret %08x\n", hr
);
3379 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
3380 ok(hr
== S_OK
, "ret %08x\n", hr
);
3382 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
3383 ok(hr
== S_OK
, "ret %08x\n", hr
);
3385 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
3386 ok(hr
== S_OK
, "ret %08x\n", hr
);
3389 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
3390 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3392 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
3393 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3395 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
3396 ok(hr
== S_OK
, "ret %08x\n", hr
);
3398 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
3399 ok(hr
== S_OK
, "ret %08x\n", hr
);
3401 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
3402 ok(hr
== S_OK
, "ret %08x\n", hr
);
3404 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3405 ok(hr
== S_OK
, "ret %08x\n", hr
);
3406 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3410 /* invalid arguments */
3411 hr
= IXMLDOMComment_deleteData(pComment
, -1, 1);
3412 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3414 hr
= IXMLDOMComment_deleteData(pComment
, 0, 0);
3415 ok(hr
== S_OK
, "ret %08x\n", hr
);
3417 hr
= IXMLDOMComment_deleteData(pComment
, 0, -1);
3418 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3420 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3421 ok(hr
== S_OK
, "ret %08x\n", hr
);
3422 ok(len
== 43, "expected 43 got %d\n", len
);
3424 hr
= IXMLDOMComment_deleteData(pComment
, len
, 1);
3425 ok(hr
== S_OK
, "ret %08x\n", hr
);
3427 hr
= IXMLDOMComment_deleteData(pComment
, len
+1, 1);
3428 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3430 /* delete from start */
3431 hr
= IXMLDOMComment_deleteData(pComment
, 0, 5);
3432 ok(hr
== S_OK
, "ret %08x\n", hr
);
3434 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3435 ok(hr
== S_OK
, "ret %08x\n", hr
);
3436 ok(len
== 38, "expected 38 got %d\n", len
);
3438 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3439 ok(hr
== S_OK
, "ret %08x\n", hr
);
3440 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3443 /* delete from end */
3444 hr
= IXMLDOMComment_deleteData(pComment
, 35, 3);
3445 ok(hr
== S_OK
, "ret %08x\n", hr
);
3447 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3448 ok(hr
== S_OK
, "ret %08x\n", hr
);
3449 ok(len
== 35, "expected 35 got %d\n", len
);
3451 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3452 ok(hr
== S_OK
, "ret %08x\n", hr
);
3453 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
3456 /* delete from inside */
3457 hr
= IXMLDOMComment_deleteData(pComment
, 1, 33);
3458 ok(hr
== S_OK
, "ret %08x\n", hr
);
3460 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3461 ok(hr
== S_OK
, "ret %08x\n", hr
);
3462 ok(len
== 2, "expected 2 got %d\n", len
);
3464 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3465 ok(hr
== S_OK
, "ret %08x\n", hr
);
3466 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string\n");
3469 /* delete whole data ... */
3470 hr
= IXMLDOMComment_get_length(pComment
, &len
);
3471 ok(hr
== S_OK
, "ret %08x\n", hr
);
3473 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
3474 ok(hr
== S_OK
, "ret %08x\n", hr
);
3475 /* ... and try again with empty string */
3476 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
3477 ok(hr
== S_OK
, "ret %08x\n", hr
);
3479 /* ::replaceData() */
3481 V_BSTR(&v
) = SysAllocString(szstr1
);
3482 hr
= IXMLDOMComment_put_nodeValue(pComment
, v
);
3483 ok(hr
== S_OK
, "ret %08x\n", hr
);
3486 hr
= IXMLDOMComment_replaceData(pComment
, 6, 0, NULL
);
3487 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3488 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3489 ok(hr
== S_OK
, "ret %08x\n", hr
);
3490 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
3493 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, NULL
);
3494 ok(hr
== S_OK
, "ret %08x\n", hr
);
3495 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3496 ok(hr
== S_OK
, "ret %08x\n", hr
);
3497 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
3500 /* NULL pointer means delete */
3501 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, NULL
);
3502 ok(hr
== S_OK
, "ret %08x\n", hr
);
3503 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3504 ok(hr
== S_OK
, "ret %08x\n", hr
);
3505 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string\n");
3508 /* empty string means delete */
3509 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_(""));
3510 ok(hr
== S_OK
, "ret %08x\n", hr
);
3511 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3512 ok(hr
== S_OK
, "ret %08x\n", hr
);
3513 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string\n");
3516 /* zero count means insert */
3517 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, _bstr_("a"));
3518 ok(hr
== S_OK
, "ret %08x\n", hr
);
3519 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3520 ok(hr
== S_OK
, "ret %08x\n", hr
);
3521 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string\n");
3524 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, NULL
);
3525 ok(hr
== S_OK
, "ret %08x\n", hr
);
3527 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("m"));
3528 ok(hr
== S_OK
, "ret %08x\n", hr
);
3529 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3530 ok(hr
== S_OK
, "ret %08x\n", hr
);
3531 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string\n");
3534 /* nonempty string, count greater than its length */
3535 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, _bstr_("a1.2"));
3536 ok(hr
== S_OK
, "ret %08x\n", hr
);
3537 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3538 ok(hr
== S_OK
, "ret %08x\n", hr
);
3539 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string\n");
3542 /* nonempty string, count less than its length */
3543 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_("wine"));
3544 ok(hr
== S_OK
, "ret %08x\n", hr
);
3545 hr
= IXMLDOMComment_get_text(pComment
, &str
);
3546 ok(hr
== S_OK
, "ret %08x\n", hr
);
3547 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string\n");
3550 IXMLDOMComment_Release(pComment
);
3554 str
= SysAllocString(szElement
);
3555 hr
= IXMLDOMDocument_createElement(doc
, str
, &pElement
);
3557 ok(hr
== S_OK
, "ret %08x\n", hr
);
3560 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
3561 ok(hr
== S_OK
, "ret %08x\n", hr
);
3563 /* test nodeTypeString */
3564 hr
= IXMLDOMDocument_get_nodeTypeString(pElement
, &str
);
3565 ok(hr
== S_OK
, "ret %08x\n", hr
);
3566 ok( !lstrcmpW( str
, _bstr_("element") ), "incorrect nodeTypeString string\n");
3569 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
3570 ok(hr
== S_OK
, "ret %08x\n", hr
);
3571 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
3574 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3575 ok(hr
== S_OK
, "ret %08x\n", hr
);
3576 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
3579 hr
= IXMLDOMElement_get_dataType(pElement
, &v
);
3580 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3581 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3585 pAttribute
= (IXMLDOMAttribute
*)0x1;
3586 hr
= IXMLDOMDocument_createAttribute(doc
, NULL
, &pAttribute
);
3587 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3588 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
3590 pAttribute
= (IXMLDOMAttribute
*)0x1;
3591 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_(""), &pAttribute
);
3592 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3593 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
3595 str
= SysAllocString(szAttribute
);
3596 hr
= IXMLDOMDocument_createAttribute(doc
, str
, &pAttribute
);
3598 ok(hr
== S_OK
, "ret %08x\n", hr
);
3601 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
3603 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, NULL
);
3604 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3606 pNextChild
= (IXMLDOMNode
*)0x1;
3607 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, &pNextChild
);
3608 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3609 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3611 /* test Previous Sibling*/
3612 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, NULL
);
3613 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3615 pNextChild
= (IXMLDOMNode
*)0x1;
3616 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, &pNextChild
);
3617 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3618 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3620 /* test get_attributes */
3621 hr
= IXMLDOMAttribute_get_attributes( pAttribute
, NULL
);
3622 ok( hr
== E_INVALIDARG
, "get_attributes returned wrong code\n");
3624 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3625 hr
= IXMLDOMAttribute_get_attributes( pAttribute
, &pAttribs
);
3626 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3627 ok( pAttribs
== NULL
, "pAttribs not NULL\n");
3629 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttribute
, &pNewChild
);
3630 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
3631 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
3633 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
3634 ok(hr
== S_OK
, "ret %08x\n", hr
);
3637 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttribute
, NULL
);
3638 ok(hr
== S_OK
, "ret %08x\n", hr
);
3640 IXMLDOMNamedNodeMap_Release(pAttribs
);
3643 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
3644 ok(hr
== S_OK
, "ret %08x\n", hr
);
3645 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
3648 /* test nodeTypeString */
3649 hr
= IXMLDOMAttribute_get_nodeTypeString(pAttribute
, &str
);
3650 ok(hr
== S_OK
, "ret %08x\n", hr
);
3651 ok( !lstrcmpW( str
, _bstr_("attribute") ), "incorrect nodeTypeString string\n");
3655 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
3656 ok(hr
== S_OK
, "ret %08x\n", hr
);
3657 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
3660 /* test name property */
3661 hr
= IXMLDOMAttribute_get_name(pAttribute
, &str
);
3662 ok(hr
== S_OK
, "ret %08x\n", hr
);
3663 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
3666 hr
= IXMLDOMAttribute_get_xml(pAttribute
, &str
);
3667 ok(hr
== S_OK
, "ret %08x\n", hr
);
3668 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
3671 hr
= IXMLDOMAttribute_get_dataType(pAttribute
, &v
);
3672 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3673 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3676 IXMLDOMAttribute_Release(pAttribute
);
3678 /* Check Element again with the Add Attribute*/
3679 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3680 ok(hr
== S_OK
, "ret %08x\n", hr
);
3681 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
3685 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
3686 ok(hr
== S_OK
, "ret %08x\n", hr
);
3688 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3689 ok(hr
== S_OK
, "ret %08x\n", hr
);
3690 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
3693 /* Test for reversible escaping */
3694 str
= SysAllocString( szStrangeChars
);
3695 hr
= IXMLDOMElement_put_text(pElement
, str
);
3696 ok(hr
== S_OK
, "ret %08x\n", hr
);
3697 SysFreeString( str
);
3699 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
3700 ok(hr
== S_OK
, "ret %08x\n", hr
);
3701 ok( !lstrcmpW( str
, szElementXML4
), "incorrect element xml\n");
3704 hr
= IXMLDOMElement_get_text(pElement
, &str
);
3705 ok(hr
== S_OK
, "ret %08x\n", hr
);
3706 ok( !lstrcmpW( str
, szStrangeChars
), "incorrect element text\n");
3709 IXMLDOMElement_Release(pElement
);
3713 str
= SysAllocString(szCData
);
3714 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, NULL
);
3715 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3717 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, &pCDataSec
);
3719 ok(hr
== S_OK
, "ret %08x\n", hr
);
3722 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
3727 hr
= IXMLDOMCDATASection_QueryInterface(pCDataSec
, &IID_IXMLDOMElement
, (LPVOID
*)&pElement
);
3728 ok(hr
== E_NOINTERFACE
, "ret %08x\n", hr
);
3730 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
3731 ok(hr
== S_OK
, "ret %08x\n", hr
);
3733 /* get Attribute Tests */
3734 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, NULL
);
3735 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3737 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
3738 hr
= IXMLDOMCDATASection_get_attributes(pCDataSec
, &pAttribs
);
3739 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3740 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
3742 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
3743 ok(hr
== S_OK
, "ret %08x\n", hr
);
3744 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
3747 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
3748 ok(hr
== S_OK
, "ret %08x\n", hr
);
3749 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
3752 /* test lastChild */
3753 pNextChild
= (IXMLDOMNode
*)0x1;
3754 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
3755 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3756 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
3758 /* test get_dataType */
3759 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, NULL
);
3760 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3762 hr
= IXMLDOMCDATASection_get_dataType(pCDataSec
, &v
);
3763 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3764 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
3767 /* test nodeTypeString */
3768 hr
= IXMLDOMCDATASection_get_nodeTypeString(pCDataSec
, &str
);
3769 ok(hr
== S_OK
, "ret %08x\n", hr
);
3770 ok( !lstrcmpW( str
, _bstr_("cdatasection") ), "incorrect nodeTypeString string\n");
3773 /* put data Tests */
3774 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
3775 ok(hr
== S_OK
, "ret %08x\n", hr
);
3777 /* Confirm XML text is good */
3778 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
3779 ok(hr
== S_OK
, "ret %08x\n", hr
);
3780 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
3783 /* Confirm we get the put_data Text back */
3784 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3785 ok(hr
== S_OK
, "ret %08x\n", hr
);
3786 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3789 /* test length property */
3790 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3791 ok(hr
== S_OK
, "ret %08x\n", hr
);
3792 ok(len
== 21, "expected 21 got %d\n", len
);
3794 /* test get nodeValue */
3795 hr
= IXMLDOMCDATASection_get_nodeValue(pCDataSec
, &var
);
3796 ok(hr
== S_OK
, "ret %08x\n", hr
);
3797 ok(V_VT(&var
) == VT_BSTR
, "got vt %04x\n", V_VT(&var
));
3798 ok( !lstrcmpW( V_BSTR(&var
), _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3802 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
3803 ok(hr
== S_OK
, "ret %08x\n", hr
);
3804 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
3807 /* test substringData */
3808 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
3809 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3811 /* test substringData - Invalid offset */
3812 str
= (BSTR
)&szElement
;
3813 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
3814 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3815 ok( str
== NULL
, "incorrect string\n");
3817 /* test substringData - Invalid offset */
3818 str
= (BSTR
)&szElement
;
3819 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
3820 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3821 ok( str
== NULL
, "incorrect string\n");
3823 /* test substringData - Invalid size */
3824 str
= (BSTR
)&szElement
;
3825 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
3826 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3827 ok( str
== NULL
, "incorrect string\n");
3829 /* test substringData - Invalid size */
3830 str
= (BSTR
)&szElement
;
3831 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
3832 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
3833 ok( str
== NULL
, "incorrect string\n");
3835 /* test substringData - Start of string */
3836 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
3837 ok(hr
== S_OK
, "ret %08x\n", hr
);
3838 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
3841 /* test substringData - Middle of string */
3842 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
3843 ok(hr
== S_OK
, "ret %08x\n", hr
);
3844 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
3847 /* test substringData - End of string */
3848 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
3849 ok(hr
== S_OK
, "ret %08x\n", hr
);
3850 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
3853 /* test appendData */
3854 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
3855 ok(hr
== S_OK
, "ret %08x\n", hr
);
3857 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
3858 ok(hr
== S_OK
, "ret %08x\n", hr
);
3860 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
3861 ok(hr
== S_OK
, "ret %08x\n", hr
);
3863 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3864 ok(hr
== S_OK
, "ret %08x\n", hr
);
3865 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string\n");
3868 /* test insertData */
3869 str
= SysAllocStringLen(NULL
, 0);
3870 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
3871 ok(hr
== S_OK
, "ret %08x\n", hr
);
3873 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
3874 ok(hr
== S_OK
, "ret %08x\n", hr
);
3876 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
3877 ok(hr
== S_OK
, "ret %08x\n", hr
);
3879 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
3880 ok(hr
== S_OK
, "ret %08x\n", hr
);
3882 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
3883 ok(hr
== S_OK
, "ret %08x\n", hr
);
3885 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
3886 ok(hr
== S_OK
, "ret %08x\n", hr
);
3889 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
3890 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3892 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
3893 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3895 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
3896 ok(hr
== S_OK
, "ret %08x\n", hr
);
3898 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
3899 ok(hr
== S_OK
, "ret %08x\n", hr
);
3901 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
3902 ok(hr
== S_OK
, "ret %08x\n", hr
);
3904 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3905 ok(hr
== S_OK
, "ret %08x\n", hr
);
3906 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3910 /* invalid arguments */
3911 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, -1, 1);
3912 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3914 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 0);
3915 ok(hr
== S_OK
, "ret %08x\n", hr
);
3917 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, -1);
3918 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3920 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3921 ok(hr
== S_OK
, "ret %08x\n", hr
);
3922 ok(len
== 43, "expected 43 got %d\n", len
);
3924 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
, 1);
3925 ok(hr
== S_OK
, "ret %08x\n", hr
);
3927 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
+1, 1);
3928 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3930 /* delete from start */
3931 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 5);
3932 ok(hr
== S_OK
, "ret %08x\n", hr
);
3934 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3935 ok(hr
== S_OK
, "ret %08x\n", hr
);
3936 ok(len
== 38, "expected 38 got %d\n", len
);
3938 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3939 ok(hr
== S_OK
, "ret %08x\n", hr
);
3940 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string\n");
3943 /* delete from end */
3944 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 35, 3);
3945 ok(hr
== S_OK
, "ret %08x\n", hr
);
3947 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3948 ok(hr
== S_OK
, "ret %08x\n", hr
);
3949 ok(len
== 35, "expected 35 got %d\n", len
);
3951 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3952 ok(hr
== S_OK
, "ret %08x\n", hr
);
3953 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string\n");
3956 /* delete from inside */
3957 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 1, 33);
3958 ok(hr
== S_OK
, "ret %08x\n", hr
);
3960 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3961 ok(hr
== S_OK
, "ret %08x\n", hr
);
3962 ok(len
== 2, "expected 2 got %d\n", len
);
3964 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3965 ok(hr
== S_OK
, "ret %08x\n", hr
);
3966 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string\n");
3969 /* delete whole data ... */
3970 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
3971 ok(hr
== S_OK
, "ret %08x\n", hr
);
3973 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
3974 ok(hr
== S_OK
, "ret %08x\n", hr
);
3976 /* ... and try again with empty string */
3977 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
3978 ok(hr
== S_OK
, "ret %08x\n", hr
);
3980 /* ::replaceData() */
3982 V_BSTR(&v
) = SysAllocString(szstr1
);
3983 hr
= IXMLDOMCDATASection_put_nodeValue(pCDataSec
, v
);
3984 ok(hr
== S_OK
, "ret %08x\n", hr
);
3987 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 6, 0, NULL
);
3988 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
3989 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3990 ok(hr
== S_OK
, "ret %08x\n", hr
);
3991 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
3994 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, NULL
);
3995 ok(hr
== S_OK
, "ret %08x\n", hr
);
3996 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
3997 ok(hr
== S_OK
, "ret %08x\n", hr
);
3998 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string\n");
4001 /* NULL pointer means delete */
4002 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, NULL
);
4003 ok(hr
== S_OK
, "ret %08x\n", hr
);
4004 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4005 ok(hr
== S_OK
, "ret %08x\n", hr
);
4006 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string\n");
4009 /* empty string means delete */
4010 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_(""));
4011 ok(hr
== S_OK
, "ret %08x\n", hr
);
4012 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4013 ok(hr
== S_OK
, "ret %08x\n", hr
);
4014 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string\n");
4017 /* zero count means insert */
4018 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, _bstr_("a"));
4019 ok(hr
== S_OK
, "ret %08x\n", hr
);
4020 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4021 ok(hr
== S_OK
, "ret %08x\n", hr
);
4022 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string\n");
4025 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, NULL
);
4026 ok(hr
== S_OK
, "ret %08x\n", hr
);
4028 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("m"));
4029 ok(hr
== S_OK
, "ret %08x\n", hr
);
4030 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4031 ok(hr
== S_OK
, "ret %08x\n", hr
);
4032 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string\n");
4035 /* nonempty string, count greater than its length */
4036 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, _bstr_("a1.2"));
4037 ok(hr
== S_OK
, "ret %08x\n", hr
);
4038 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4039 ok(hr
== S_OK
, "ret %08x\n", hr
);
4040 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string\n");
4043 /* nonempty string, count less than its length */
4044 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_("wine"));
4045 ok(hr
== S_OK
, "ret %08x\n", hr
);
4046 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
4047 ok(hr
== S_OK
, "ret %08x\n", hr
);
4048 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string\n");
4051 IXMLDOMCDATASection_Release(pCDataSec
);
4054 /* Document Fragments */
4055 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
4056 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4058 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
4059 ok(hr
== S_OK
, "ret %08x\n", hr
);
4064 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, NULL
);
4065 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4067 node
= (IXMLDOMNode
*)0x1;
4068 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, &node
);
4069 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4070 ok(node
== NULL
, "expected NULL, got %p\n", node
);
4072 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
4073 ok(hr
== S_OK
, "ret %08x\n", hr
);
4075 /* get Attribute Tests */
4076 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, NULL
);
4077 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4079 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
4080 hr
= IXMLDOMDocumentFragment_get_attributes(pDocFrag
, &pAttribs
);
4081 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4082 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
4084 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
4085 ok(hr
== S_OK
, "ret %08x\n", hr
);
4086 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
4089 /* test next Sibling*/
4090 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
4091 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4093 node
= (IXMLDOMNode
*)0x1;
4094 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &node
);
4095 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4096 ok(node
== NULL
, "next sibling not NULL\n");
4098 /* test Previous Sibling*/
4099 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
4100 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4102 node
= (IXMLDOMNode
*)0x1;
4103 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &node
);
4104 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4105 ok(node
== NULL
, "previous sibling not NULL\n");
4107 /* test get_dataType */
4108 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, NULL
);
4109 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4111 hr
= IXMLDOMDocumentFragment_get_dataType(pDocFrag
, &v
);
4112 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4113 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4116 /* test nodeTypeString */
4117 hr
= IXMLDOMDocumentFragment_get_nodeTypeString(pDocFrag
, &str
);
4118 ok(hr
== S_OK
, "ret %08x\n", hr
);
4119 ok( !lstrcmpW( str
, _bstr_("documentfragment") ), "incorrect nodeTypeString string\n");
4122 IXMLDOMDocumentFragment_Release(pDocFrag
);
4125 /* Entity References */
4126 hr
= IXMLDOMDocument_createEntityReference(doc
, NULL
, &pEntityRef
);
4127 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4128 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_(""), &pEntityRef
);
4129 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4131 str
= SysAllocString(szEntityRef
);
4132 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, NULL
);
4133 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4135 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, &pEntityRef
);
4137 ok(hr
== S_OK
, "ret %08x\n", hr
);
4140 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
4141 ok(hr
== S_OK
, "ret %08x\n", hr
);
4143 /* get Attribute Tests */
4144 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, NULL
);
4145 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4147 pAttribs
= (IXMLDOMNamedNodeMap
*)0x1;
4148 hr
= IXMLDOMEntityReference_get_attributes(pEntityRef
, &pAttribs
);
4149 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4150 ok(pAttribs
== NULL
, "pAttribs != NULL\n");
4153 hr
= IXMLDOMEntityReference_get_dataType(pEntityRef
, &v
);
4154 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4155 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4158 /* test nodeTypeString */
4159 hr
= IXMLDOMEntityReference_get_nodeTypeString(pEntityRef
, &str
);
4160 ok(hr
== S_OK
, "ret %08x\n", hr
);
4161 ok( !lstrcmpW( str
, _bstr_("entityreference") ), "incorrect nodeTypeString string\n");
4165 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
4166 ok(hr
== S_OK
, "ret %08x\n", hr
);
4167 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
4170 IXMLDOMEntityReference_Release(pEntityRef
);
4173 IXMLDOMElement_Release( pRoot
);
4177 IXMLDOMDocument_Release(doc
);
4182 static void test_nodeTypeTests( void )
4184 IXMLDOMDocument
*doc
= NULL
;
4185 IXMLDOMElement
*pRoot
;
4186 IXMLDOMElement
*pElement
;
4189 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4193 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), NULL
);
4194 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4196 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4197 ok(hr
== S_OK
, "ret %08x\n", hr
);
4200 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4201 ok(hr
== S_OK
, "ret %08x\n", hr
);
4204 hr
= IXMLDOMElement_put_dataType(pRoot
, NULL
);
4205 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4208 hr
= IXMLDOMElement_put_dataType(pRoot
, _bstr_("abcdefg") );
4209 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4212 * The name passed into put_dataType is case-insensitive. So many of the names
4213 * have been changed to reflect this.
4216 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Boolean"), &pElement
);
4217 ok(hr
== S_OK
, "ret %08x\n", hr
);
4220 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4222 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Boolean") );
4223 ok(hr
== S_OK
, "ret %08x\n", hr
);
4225 IXMLDOMElement_Release(pElement
);
4229 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_String"), &pElement
);
4230 ok(hr
== S_OK
, "ret %08x\n", hr
);
4233 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4235 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("String") );
4236 ok(hr
== S_OK
, "ret %08x\n", hr
);
4238 IXMLDOMElement_Release(pElement
);
4242 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Number"), &pElement
);
4243 ok(hr
== S_OK
, "ret %08x\n", hr
);
4246 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4248 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("number") );
4249 ok(hr
== S_OK
, "ret %08x\n", hr
);
4251 IXMLDOMElement_Release(pElement
);
4255 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Int"), &pElement
);
4256 ok(hr
== S_OK
, "ret %08x\n", hr
);
4259 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4261 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("InT") );
4262 ok(hr
== S_OK
, "ret %08x\n", hr
);
4264 IXMLDOMElement_Release(pElement
);
4268 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Fixed"), &pElement
);
4269 ok(hr
== S_OK
, "ret %08x\n", hr
);
4272 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4274 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("fixed.14.4") );
4275 ok(hr
== S_OK
, "ret %08x\n", hr
);
4277 IXMLDOMElement_Release(pElement
);
4281 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime"), &pElement
);
4282 ok(hr
== S_OK
, "ret %08x\n", hr
);
4285 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4287 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime") );
4288 ok(hr
== S_OK
, "ret %08x\n", hr
);
4290 IXMLDOMElement_Release(pElement
);
4294 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_DateTime_tz"), &pElement
);
4295 ok(hr
== S_OK
, "ret %08x\n", hr
);
4298 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4300 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
4301 ok(hr
== S_OK
, "ret %08x\n", hr
);
4303 IXMLDOMElement_Release(pElement
);
4307 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Date"), &pElement
);
4308 ok(hr
== S_OK
, "ret %08x\n", hr
);
4311 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4313 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Date") );
4314 ok(hr
== S_OK
, "ret %08x\n", hr
);
4316 IXMLDOMElement_Release(pElement
);
4320 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time"), &pElement
);
4321 ok(hr
== S_OK
, "ret %08x\n", hr
);
4324 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4326 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time") );
4327 ok(hr
== S_OK
, "ret %08x\n", hr
);
4329 IXMLDOMElement_Release(pElement
);
4333 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Time_TZ"), &pElement
);
4334 ok(hr
== S_OK
, "ret %08x\n", hr
);
4337 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4339 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("Time.tz") );
4340 ok(hr
== S_OK
, "ret %08x\n", hr
);
4342 IXMLDOMElement_Release(pElement
);
4346 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I1"), &pElement
);
4347 ok(hr
== S_OK
, "ret %08x\n", hr
);
4350 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4352 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I1") );
4353 ok(hr
== S_OK
, "ret %08x\n", hr
);
4355 IXMLDOMElement_Release(pElement
);
4359 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I2"), &pElement
);
4360 ok(hr
== S_OK
, "ret %08x\n", hr
);
4363 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4365 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I2") );
4366 ok(hr
== S_OK
, "ret %08x\n", hr
);
4368 IXMLDOMElement_Release(pElement
);
4372 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_I4"), &pElement
);
4373 ok(hr
== S_OK
, "ret %08x\n", hr
);
4376 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4378 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("I4") );
4379 ok(hr
== S_OK
, "ret %08x\n", hr
);
4381 IXMLDOMElement_Release(pElement
);
4385 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI1"), &pElement
);
4386 ok(hr
== S_OK
, "ret %08x\n", hr
);
4389 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4391 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI1") );
4392 ok(hr
== S_OK
, "ret %08x\n", hr
);
4394 IXMLDOMElement_Release(pElement
);
4398 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI2"), &pElement
);
4399 ok(hr
== S_OK
, "ret %08x\n", hr
);
4402 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4404 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI2") );
4405 ok(hr
== S_OK
, "ret %08x\n", hr
);
4407 IXMLDOMElement_Release(pElement
);
4411 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_UI4"), &pElement
);
4412 ok(hr
== S_OK
, "ret %08x\n", hr
);
4415 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4417 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UI4") );
4418 ok(hr
== S_OK
, "ret %08x\n", hr
);
4420 IXMLDOMElement_Release(pElement
);
4424 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r4"), &pElement
);
4425 ok(hr
== S_OK
, "ret %08x\n", hr
);
4428 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4430 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r4") );
4431 ok(hr
== S_OK
, "ret %08x\n", hr
);
4433 IXMLDOMElement_Release(pElement
);
4437 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_r8"), &pElement
);
4438 ok(hr
== S_OK
, "ret %08x\n", hr
);
4441 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4443 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("r8") );
4444 ok(hr
== S_OK
, "ret %08x\n", hr
);
4446 IXMLDOMElement_Release(pElement
);
4450 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_float"), &pElement
);
4451 ok(hr
== S_OK
, "ret %08x\n", hr
);
4454 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4456 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("float") );
4457 ok(hr
== S_OK
, "ret %08x\n", hr
);
4459 IXMLDOMElement_Release(pElement
);
4463 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_uuid"), &pElement
);
4464 ok(hr
== S_OK
, "ret %08x\n", hr
);
4467 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4469 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("UuId") );
4470 ok(hr
== S_OK
, "ret %08x\n", hr
);
4472 IXMLDOMElement_Release(pElement
);
4476 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_hex"), &pElement
);
4477 ok(hr
== S_OK
, "ret %08x\n", hr
);
4480 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4482 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.hex") );
4483 ok(hr
== S_OK
, "ret %08x\n", hr
);
4485 IXMLDOMElement_Release(pElement
);
4489 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_bin_base64"), &pElement
);
4490 ok(hr
== S_OK
, "ret %08x\n", hr
);
4493 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4495 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("bin.base64") );
4496 ok(hr
== S_OK
, "ret %08x\n", hr
);
4498 IXMLDOMElement_Release(pElement
);
4501 /* Check changing types */
4502 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &pElement
);
4503 ok(hr
== S_OK
, "ret %08x\n", hr
);
4506 IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
4508 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("DateTime.tz") );
4509 ok(hr
== S_OK
, "ret %08x\n", hr
);
4511 hr
= IXMLDOMElement_put_dataType(pElement
, _bstr_("string") );
4512 ok(hr
== S_OK
, "ret %08x\n", hr
);
4514 IXMLDOMElement_Release(pElement
);
4517 IXMLDOMElement_Release(pRoot
);
4521 IXMLDOMDocument_Release(doc
);
4526 static void test_DocumentSaveToDocument(void)
4528 IXMLDOMDocument
*doc
= NULL
;
4529 IXMLDOMDocument
*doc2
= NULL
;
4530 IXMLDOMElement
*pRoot
;
4534 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4538 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc2
);
4541 IXMLDOMDocument_Release(doc
);
4545 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4546 ok(hr
== S_OK
, "ret %08x\n", hr
);
4549 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4550 ok(hr
== S_OK
, "ret %08x\n", hr
);
4557 V_VT(&vDoc
) = VT_UNKNOWN
;
4558 V_UNKNOWN(&vDoc
) = (IUnknown
*)doc2
;
4560 hr
= IXMLDOMDocument_save(doc
, vDoc
);
4561 ok(hr
== S_OK
, "ret %08x\n", hr
);
4563 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
4564 ok(hr
== S_OK
, "ret %08x\n", hr
);
4566 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
4567 ok(hr
== S_OK
, "ret %08x\n", hr
);
4569 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as origial\n");
4571 SysFreeString(sOrig
);
4572 SysFreeString(sNew
);
4576 IXMLDOMDocument_Release(doc2
);
4577 IXMLDOMDocument_Release(doc
);
4580 static void test_DocumentSaveToFile(void)
4582 IXMLDOMDocument
*doc
= NULL
;
4583 IXMLDOMElement
*pRoot
;
4589 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4593 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4594 ok(hr
== S_OK
, "ret %08x\n", hr
);
4597 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4598 ok(hr
== S_OK
, "ret %08x\n", hr
);
4603 V_VT(&vFile
) = VT_BSTR
;
4604 V_BSTR(&vFile
) = _bstr_("test.xml");
4606 hr
= IXMLDOMDocument_save(doc
, vFile
);
4607 ok(hr
== S_OK
, "ret %08x\n", hr
);
4611 IXMLDOMElement_Release(pRoot
);
4612 IXMLDOMDocument_Release(doc
);
4614 file
= CreateFile("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
4615 ok(file
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
4616 if(file
== INVALID_HANDLE_VALUE
)
4619 ReadFile(file
, buffer
, sizeof(buffer
), &read
, NULL
);
4620 ok(read
!= 0, "could not read file\n");
4621 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
4624 DeleteFile("test.xml");
4627 static void test_testTransforms(void)
4629 IXMLDOMDocument
*doc
= NULL
;
4630 IXMLDOMDocument
*docSS
= NULL
;
4636 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4640 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&docSS
);
4643 IXMLDOMDocument_Release(doc
);
4647 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
4648 ok(hr
== S_OK
, "ret %08x\n", hr
);
4650 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
4651 ok(hr
== S_OK
, "ret %08x\n", hr
);
4653 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
4654 ok(hr
== S_OK
, "ret %08x\n", hr
);
4659 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
4660 ok(hr
== S_OK
, "ret %08x\n", hr
);
4661 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "Stylesheet output not correct\n");
4662 SysFreeString(bOut
);
4664 IXMLDOMNode_Release(pNode
);
4667 IXMLDOMDocument_Release(docSS
);
4668 IXMLDOMDocument_Release(doc
);
4673 static void test_Namespaces(void)
4675 IXMLDOMDocument2
*doc
= NULL
;
4677 IXMLDOMNode
*pNode2
= NULL
;
4681 static const CHAR szNamespacesXML
[] =
4682 "<?xml version=\"1.0\"?>\n"
4683 "<root xmlns:WEB='http://www.winehq.org'>\n"
4684 "<WEB:Site version=\"1.0\" />\n"
4687 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4691 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szNamespacesXML
), &bSucc
);
4692 ok(hr
== S_OK
, "ret %08x\n", hr
);
4693 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4695 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root"), &pNode
);
4696 ok(hr
== S_OK
, "ret %08x\n", hr
);
4699 hr
= IXMLDOMNode_get_firstChild( pNode
, &pNode2
);
4700 ok( hr
== S_OK
, "ret %08x\n", hr
);
4701 ok( pNode2
!= NULL
, "pNode2 == NULL\n");
4703 /* Test get_prefix */
4704 hr
= IXMLDOMNode_get_prefix(pNode2
, NULL
);
4705 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4706 /* NOTE: Need to test that arg2 gets cleared on Error. */
4708 hr
= IXMLDOMNode_get_prefix(pNode2
, &str
);
4709 ok( hr
== S_OK
, "ret %08x\n", hr
);
4710 ok( !lstrcmpW( str
, _bstr_("WEB")), "incorrect prefix string\n");
4713 /* Test get_namespaceURI */
4714 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, NULL
);
4715 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4716 /* NOTE: Need to test that arg2 gets cleared on Error. */
4718 hr
= IXMLDOMNode_get_namespaceURI(pNode2
, &str
);
4719 ok( hr
== S_OK
, "ret %08x\n", hr
);
4720 ok( !lstrcmpW( str
, _bstr_("http://www.winehq.org")), "incorrect namespaceURI string\n");
4723 IXMLDOMNode_Release(pNode2
);
4724 IXMLDOMNode_Release(pNode
);
4727 IXMLDOMDocument2_Release(doc
);
4732 static void test_FormattingXML(void)
4734 IXMLDOMDocument2
*doc
= NULL
;
4735 IXMLDOMElement
*pElement
;
4739 static const CHAR szLinefeedXML
[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
4740 static const CHAR szLinefeedRootXML
[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
4742 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4746 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szLinefeedXML
), &bSucc
);
4747 ok(hr
== S_OK
, "ret %08x\n", hr
);
4748 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4750 if(bSucc
== VARIANT_TRUE
)
4752 hr
= IXMLDOMDocument2_get_documentElement(doc
, &pElement
);
4753 ok(hr
== S_OK
, "ret %08x\n", hr
);
4756 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
4757 ok(hr
== S_OK
, "ret %08x\n", hr
);
4758 ok( !lstrcmpW( str
, _bstr_(szLinefeedRootXML
) ), "incorrect element xml\n");
4761 IXMLDOMElement_Release(pElement
);
4765 IXMLDOMDocument2_Release(doc
);
4770 static void test_NodeTypeValue(void)
4772 IXMLDOMDocument2
*doc
= NULL
;
4778 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
4782 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
4783 ok(hr
== S_OK
, "ret %08x\n", hr
);
4784 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
4785 if(bSucc
== VARIANT_TRUE
)
4787 hr
= IXMLDOMDocument2_get_nodeValue(doc
, NULL
);
4788 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4792 hr
= IXMLDOMDocument2_get_nodeValue(doc
, &v
);
4793 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4794 ok(V_VT(&v
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&v
));
4796 hr
= IXMLDOMDocument2_get_nodeTypedValue(doc
, NULL
);
4797 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4799 hr
= IXMLDOMDocument2_get_nodeTypedValue(doc
, &v
);
4800 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4802 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/string"), &pNode
);
4803 ok(hr
== S_OK
, "ret %08x\n", hr
);
4808 hr
= IXMLDOMNode_get_nodeValue(pNode
, &v
);
4809 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4810 ok(V_VT(&v
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&v
));
4812 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, NULL
);
4813 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4815 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4816 ok(hr
== S_OK
, "ret %08x\n", hr
);
4817 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4818 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("Wine") ), "incorrect value\n");
4821 IXMLDOMNode_Release(pNode
);
4824 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/string2"), &pNode
);
4825 ok(hr
== S_OK
, "ret %08x\n", hr
);
4828 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4829 ok(hr
== S_OK
, "ret %08x\n", hr
);
4830 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4831 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("String") ), "incorrect value\n");
4834 IXMLDOMNode_Release(pNode
);
4837 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/number"), &pNode
);
4838 ok(hr
== S_OK
, "ret %08x\n", hr
);
4841 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4842 ok(hr
== S_OK
, "ret %08x\n", hr
);
4843 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4844 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("12.44") ), "incorrect value\n");
4847 IXMLDOMNode_Release(pNode
);
4850 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/number2"), &pNode
);
4851 ok(hr
== S_OK
, "ret %08x\n", hr
);
4854 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4855 ok(hr
== S_OK
, "ret %08x\n", hr
);
4856 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
4857 ok(!lstrcmpW( V_BSTR(&v
), _bstr_("-3.71e3") ), "incorrect value\n");
4860 IXMLDOMNode_Release(pNode
);
4863 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/int"), &pNode
);
4864 ok(hr
== S_OK
, "ret %08x\n", hr
);
4867 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4868 ok(hr
== S_OK
, "ret %08x\n", hr
);
4869 ok(V_VT(&v
) == VT_I4
, "incorrect type\n");
4870 ok(V_I4(&v
) == -13, "incorrect value\n");
4873 IXMLDOMNode_Release(pNode
);
4876 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/fixed"), &pNode
);
4877 ok(hr
== S_OK
, "ret %08x\n", hr
);
4880 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4881 ok(hr
== S_OK
, "ret %08x\n", hr
);
4882 ok(V_VT(&v
) == VT_CY
, "incorrect type\n");
4885 IXMLDOMNode_Release(pNode
);
4888 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/bool"), &pNode
);
4889 ok(hr
== S_OK
, "ret %08x\n", hr
);
4892 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4893 ok(hr
== S_OK
, "ret %08x\n", hr
);
4894 ok(V_VT(&v
) == VT_BOOL
, "incorrect type\n");
4895 ok(V_BOOL(&v
) == VARIANT_TRUE
, "incorrect value\n");
4898 IXMLDOMNode_Release(pNode
);
4901 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/datetime"), &pNode
);
4902 ok(hr
== S_OK
, "ret %08x\n", hr
);
4905 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4906 ok(hr
== S_OK
, "ret %08x\n", hr
);
4907 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4908 double_eq(40135.13996527778, V_DATE(&v
));
4911 IXMLDOMNode_Release(pNode
);
4914 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/datetimetz"), &pNode
);
4915 ok(hr
== S_OK
, "ret %08x\n", hr
);
4918 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4919 ok(hr
== S_OK
, "ret %08x\n", hr
);
4920 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4921 double_eq(37813.59302083334, V_DATE(&v
));
4924 IXMLDOMNode_Release(pNode
);
4927 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/date"), &pNode
);
4928 ok(hr
== S_OK
, "ret %08x\n", hr
);
4931 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4932 ok(hr
== S_OK
, "ret %08x\n", hr
);
4933 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4934 double_eq(665413.0, V_DATE(&v
));
4937 IXMLDOMNode_Release(pNode
);
4940 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/time"), &pNode
);
4941 ok(hr
== S_OK
, "ret %08x\n", hr
);
4944 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4945 ok(hr
== S_OK
, "ret %08x\n", hr
);
4946 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4947 double_eq(0.5813888888888888, V_DATE(&v
));
4950 IXMLDOMNode_Release(pNode
);
4953 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/timetz"), &pNode
);
4954 ok(hr
== S_OK
, "ret %08x\n", hr
);
4957 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4958 ok(hr
== S_OK
, "ret %08x\n", hr
);
4959 ok(V_VT(&v
) == VT_DATE
, "incorrect type\n");
4960 double_eq(1.112511574074074, V_DATE(&v
));
4963 IXMLDOMNode_Release(pNode
);
4966 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i1"), &pNode
);
4967 ok(hr
== S_OK
, "ret %08x\n", hr
);
4970 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4971 ok(hr
== S_OK
, "ret %08x\n", hr
);
4972 ok(V_VT(&v
) == VT_I1
, "incorrect type\n");
4973 ok(V_I1(&v
) == -13, "incorrect value\n");
4976 IXMLDOMNode_Release(pNode
);
4979 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i2"), &pNode
);
4980 ok(hr
== S_OK
, "ret %08x\n", hr
);
4983 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4984 ok(hr
== S_OK
, "ret %08x\n", hr
);
4985 ok(V_VT(&v
) == VT_I2
, "incorrect type\n");
4986 ok(V_I2(&v
) == 31915, "incorrect value\n");
4989 IXMLDOMNode_Release(pNode
);
4992 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/i4"), &pNode
);
4993 ok(hr
== S_OK
, "ret %08x\n", hr
);
4996 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
4997 ok(hr
== S_OK
, "ret %08x\n", hr
);
4998 ok(V_VT(&v
) == VT_I4
, "incorrect type\n");
4999 ok(V_I4(&v
) == -312232, "incorrect value\n");
5002 IXMLDOMNode_Release(pNode
);
5005 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui1"), &pNode
);
5006 ok(hr
== S_OK
, "ret %08x\n", hr
);
5009 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5010 ok(hr
== S_OK
, "ret %08x\n", hr
);
5011 ok(V_VT(&v
) == VT_UI1
, "incorrect type\n");
5012 ok(V_UI1(&v
) == 123, "incorrect value\n");
5015 IXMLDOMNode_Release(pNode
);
5018 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui2"), &pNode
);
5019 ok(hr
== S_OK
, "ret %08x\n", hr
);
5022 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5023 ok(hr
== S_OK
, "ret %08x\n", hr
);
5024 ok(V_VT(&v
) == VT_UI2
, "incorrect type\n");
5025 ok(V_UI2(&v
) == 48282, "incorrect value\n");
5028 IXMLDOMNode_Release(pNode
);
5031 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/ui4"), &pNode
);
5032 ok(hr
== S_OK
, "ret %08x\n", hr
);
5035 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5036 ok(hr
== S_OK
, "ret %08x\n", hr
);
5037 ok(V_VT(&v
) == VT_UI4
, "incorrect type\n");
5038 ok(V_UI4(&v
) == 949281, "incorrect value\n");
5041 IXMLDOMNode_Release(pNode
);
5044 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/r4"), &pNode
);
5045 ok(hr
== S_OK
, "ret %08x\n", hr
);
5048 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5049 ok(hr
== S_OK
, "ret %08x\n", hr
);
5050 ok(V_VT(&v
) == VT_R4
, "incorrect type\n");
5051 double_eq(213124.0, V_R4(&v
));
5054 IXMLDOMNode_Release(pNode
);
5057 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/r8"), &pNode
);
5058 ok(hr
== S_OK
, "ret %08x\n", hr
);
5061 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5062 ok(hr
== S_OK
, "ret %08x\n", hr
);
5063 ok(V_VT(&v
) == VT_R8
, "incorrect type\n");
5064 double_eq(0.412, V_R8(&v
));
5067 IXMLDOMNode_Release(pNode
);
5070 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/float"), &pNode
);
5071 ok(hr
== S_OK
, "ret %08x\n", hr
);
5074 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5075 ok(hr
== S_OK
, "ret %08x\n", hr
);
5076 ok(V_VT(&v
) == VT_R8
, "incorrect type\n");
5077 double_eq(41221.421, V_R8(&v
));
5080 IXMLDOMNode_Release(pNode
);
5083 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/uuid"), &pNode
);
5084 ok(hr
== S_OK
, "ret %08x\n", hr
);
5087 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5088 ok(hr
== S_OK
, "ret %08x\n", hr
);
5089 ok(V_VT(&v
) == VT_BSTR
, "incorrect type\n");
5090 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("333C7BC4-460F-11D0-BC04-0080C7055a83")), "incorrect value\n");
5093 IXMLDOMNode_Release(pNode
);
5096 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/binhex"), &pNode
);
5097 ok(hr
== S_OK
, "ret %08x\n", hr
);
5100 BYTE bytes
[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
5102 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5103 ok(hr
== S_OK
, "ret %08x\n", hr
);
5104 ok(V_VT(&v
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
5105 ok(V_ARRAY(&v
)->rgsabound
[0].cElements
== 6, "incorrect array size\n");
5106 if(V_ARRAY(&v
)->rgsabound
[0].cElements
== 6)
5107 ok(!memcmp(bytes
, V_ARRAY(&v
)->pvData
, sizeof(bytes
)), "incorrect value\n");
5110 IXMLDOMNode_Release(pNode
);
5113 hr
= IXMLDOMDocument2_selectSingleNode(doc
, _bstr_("root/binbase64"), &pNode
);
5114 ok(hr
== S_OK
, "ret %08x\n", hr
);
5117 BYTE bytes
[] = {0x62,0x61,0x73,0x65,0x36,0x34,0x20,0x74,0x65,0x73,0x74};
5119 hr
= IXMLDOMNode_get_nodeTypedValue(pNode
, &v
);
5120 ok(hr
== S_OK
, "ret %08x\n", hr
);
5121 ok(V_VT(&v
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
5122 ok(V_ARRAY(&v
)->rgsabound
[0].cElements
== 11, "incorrect array size\n");
5123 if(V_ARRAY(&v
)->rgsabound
[0].cElements
== 11)
5124 ok(!memcmp(bytes
, V_ARRAY(&v
)->pvData
, sizeof(bytes
)), "incorrect value\n");
5127 IXMLDOMNode_Release(pNode
);
5131 IXMLDOMDocument2_Release(doc
);
5136 static void test_TransformWithLoadingLocalFile(void)
5138 IXMLDOMDocument2
*doc
= NULL
;
5139 IXMLDOMDocument2
*xsl
= NULL
;
5145 char lpPathBuffer
[MAX_PATH
];
5148 /* Create a Temp File. */
5149 GetTempPathA(MAX_PATH
, lpPathBuffer
);
5150 strcat(lpPathBuffer
, "customers.xml" );
5152 file
= CreateFile(lpPathBuffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
5153 ok(file
!= INVALID_HANDLE_VALUE
, "Could not create file: %u\n", GetLastError());
5154 if(file
== INVALID_HANDLE_VALUE
)
5157 WriteFile(file
, szBasicTransformXML
, strlen(szBasicTransformXML
), &dwWritten
, NULL
);
5160 /* Correct path to not include a escape character. */
5161 for(i
=0; i
< strlen(lpPathBuffer
); i
++)
5163 if(lpPathBuffer
[i
] == '\\')
5164 lpPathBuffer
[i
] = '/';
5167 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&doc
);
5171 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (LPVOID
*)&xsl
);
5174 IXMLDOMDocument2_Release(doc
);
5178 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
5179 ok(hr
== S_OK
, "ret %08x\n", hr
);
5180 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
5181 if(bSucc
== VARIANT_TRUE
)
5184 BSTR sPart1
= _bstr_(szBasicTransformSSXMLPart1
);
5185 BSTR sPart2
= _bstr_(szBasicTransformSSXMLPart2
);
5186 BSTR sFileName
= _bstr_(lpPathBuffer
);
5187 int nLegnth
= lstrlenW(sPart1
) + lstrlenW(sPart2
) + lstrlenW(sFileName
) + 1;
5189 sXSL
= SysAllocStringLen(NULL
, nLegnth
);
5190 lstrcpyW(sXSL
, sPart1
);
5191 lstrcatW(sXSL
, sFileName
);
5192 lstrcatW(sXSL
, sPart2
);
5194 hr
= IXMLDOMDocument2_loadXML(xsl
, sXSL
, &bSucc
);
5195 ok(hr
== S_OK
, "ret %08x\n", hr
);
5196 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
5197 if(bSucc
== VARIANT_TRUE
)
5201 hr
= IXMLDOMDocument_QueryInterface(xsl
, &IID_IXMLDOMNode
, (LPVOID
*)&pNode
);
5202 ok(hr
== S_OK
, "ret %08x\n", hr
);
5205 /* This will load the temp file via the XSL */
5206 hr
= IXMLDOMDocument2_transformNode(doc
, pNode
, &sResult
);
5207 ok(hr
== S_OK
, "ret %08x\n", hr
);
5210 ok( compareIgnoreReturns( sResult
, _bstr_(szBasicTransformOutput
)), "Stylesheet output not correct\n");
5211 SysFreeString(sResult
);
5214 IXMLDOMNode_Release(pNode
);
5218 SysFreeString(sXSL
);
5221 IXMLDOMDocument2_Release(doc
);
5222 IXMLDOMDocument2_Release(xsl
);
5224 DeleteFile(lpPathBuffer
);
5228 static void test_put_nodeValue(void)
5230 IXMLDOMDocument
*doc
;
5231 IXMLDOMEntityReference
*entityref
;
5236 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
5240 /* test for unsupported types */
5242 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&node
);
5243 ok(hr
== S_OK
, "ret %08x\n", hr
);
5244 V_VT(&data
) = VT_BSTR
;
5245 V_BSTR(&data
) = _bstr_("one two three");
5246 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5247 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5248 IXMLDOMNode_Release(node
);
5250 /* NODE_DOCUMENT_FRAGMENT */
5251 V_VT(&type
) = VT_I1
;
5252 V_I1(&type
) = NODE_DOCUMENT_FRAGMENT
;
5253 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
5254 ok(hr
== S_OK
, "ret %08x\n", hr
);
5255 V_VT(&data
) = VT_BSTR
;
5256 V_BSTR(&data
) = _bstr_("one two three");
5257 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5258 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5259 IXMLDOMNode_Release(node
);
5262 V_VT(&type
) = VT_I1
;
5263 V_I1(&type
) = NODE_ELEMENT
;
5264 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
5265 ok(hr
== S_OK
, "ret %08x\n", hr
);
5266 V_VT(&data
) = VT_BSTR
;
5267 V_BSTR(&data
) = _bstr_("one two three");
5268 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5269 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5270 IXMLDOMNode_Release(node
);
5272 /* NODE_ENTITY_REFERENCE */
5273 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_("ref"), &entityref
);
5274 ok(hr
== S_OK
, "ret %08x\n", hr
);
5276 V_VT(&data
) = VT_BSTR
;
5277 V_BSTR(&data
) = _bstr_("one two three");
5278 hr
= IXMLDOMEntityReference_put_nodeValue(entityref
, data
);
5279 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5281 hr
= IXMLDOMEntityReference_QueryInterface(entityref
, &IID_IXMLDOMNode
, (void**)&node
);
5282 ok(hr
== S_OK
, "ret %08x\n", hr
);
5283 V_VT(&data
) = VT_BSTR
;
5284 V_BSTR(&data
) = _bstr_("one two three");
5285 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
5286 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5287 IXMLDOMNode_Release(node
);
5288 IXMLDOMEntityReference_Release(entityref
);
5292 IXMLDOMDocument_Release(doc
);
5295 static void test_IObjectSafety_set(IObjectSafety
*safety
, HRESULT result
, HRESULT result2
, DWORD set
, DWORD mask
, DWORD expected
, DWORD expected2
)
5298 DWORD enabled
, supported
;
5300 trace("testing IObjectSafety: enable=%08x, mask=%08x\n", set
, mask
);
5302 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
, set
, mask
);
5303 if (result
== result2
)
5304 ok(hr
== result
, "SetInterfaceSafetyOptions: expected %08x, returned %08x\n", result
, hr
);
5306 ok(broken(hr
== result
) || hr
== result2
,
5307 "SetInterfaceSafetyOptions: expected %08x, got %08x\n", result2
, hr
);
5309 supported
= enabled
= 0xCAFECAFE;
5310 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5311 ok(hr
== S_OK
, "ret %08x\n", hr
);
5312 if (expected
== expected2
)
5313 ok(enabled
== expected
, "Expected %08x, got %08x\n", expected
, enabled
);
5315 ok(broken(enabled
== expected
) || enabled
== expected2
,
5316 "Expected %08x, got %08x\n", expected2
, enabled
);
5318 /* reset the safety options */
5320 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
5321 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_SECURITY_MANAGER
,
5323 ok(hr
== S_OK
, "ret %08x\n", hr
);
5325 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5326 ok(hr
== S_OK
, "ret %08x\n", hr
);
5327 ok(enabled
== 0, "Expected 0, got %08x\n", enabled
);
5330 static void test_document_IObjectSafety(void)
5332 IXMLDOMDocument
*doc
;
5333 IObjectSafety
*safety
;
5334 DWORD enabled
= 0, supported
= 0;
5337 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (LPVOID
*)&doc
);
5341 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IObjectSafety
, (void**)&safety
);
5342 ok(hr
== S_OK
, "ret %08x\n", hr
);
5345 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, NULL
, &enabled
);
5346 ok(hr
== E_POINTER
, "ret %08x\n", hr
);
5347 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, NULL
);
5348 ok(hr
== E_POINTER
, "ret %08x\n", hr
);
5350 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5351 ok(hr
== S_OK
, "ret %08x\n", hr
);
5352 ok(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
5353 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
5354 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
5355 "got %08x\n", supported
);
5356 ok(enabled
== 0, "Expected 0, got %08x\n", enabled
);
5358 /* set -- individual flags */
5360 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5361 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5362 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
5364 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5365 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5366 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
);
5368 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5369 INTERFACE_USES_SECURITY_MANAGER
, INTERFACE_USES_SECURITY_MANAGER
,
5370 0, INTERFACE_USES_SECURITY_MANAGER
/* msxml3 SP8+ */);
5372 /* set INTERFACE_USES_DISPEX */
5374 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
5375 INTERFACE_USES_DISPEX
, INTERFACE_USES_DISPEX
,
5378 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
5379 INTERFACE_USES_DISPEX
, 0,
5382 test_IObjectSafety_set(safety
, S_OK
, S_OK
/* msxml3 SP8+ */,
5383 0, INTERFACE_USES_DISPEX
,
5386 /* set option masking */
5388 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5389 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5390 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5391 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5392 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
5394 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5395 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5396 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5397 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5398 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
5400 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
5401 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5402 INTERFACE_USES_SECURITY_MANAGER
,
5406 /* set -- inheriting previous settings */
5408 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
5409 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
5410 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
5411 ok(hr
== S_OK
, "ret %08x\n", hr
);
5412 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5413 ok(hr
== S_OK
, "ret %08x\n", hr
);
5415 ok(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_CALLER
) ||
5416 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
5417 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACE_USES_SECURITY_MANAGER), "
5418 "got %08x\n", enabled
);
5420 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
5421 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
5422 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
5423 ok(hr
== S_OK
, "ret %08x\n", hr
);
5424 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
5425 ok(hr
== S_OK
, "ret %08x\n", hr
);
5427 ok(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_DATA
) ||
5428 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
) /* msxml3 SP8+ */,
5429 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA), "
5430 "got %08x\n", enabled
);
5432 IObjectSafety_Release(safety
);
5434 IXMLDOMDocument_Release(doc
);
5441 r
= CoInitialize( NULL
);
5442 ok( r
== S_OK
, "failed to init com\n");
5448 test_getElementsByTagName();
5450 test_get_childNodes();
5452 test_replaceChild();
5453 test_removeNamedItem();
5455 test_IXMLDOMDocument2();
5459 test_nodeTypeTests();
5460 test_DocumentSaveToDocument();
5461 test_DocumentSaveToFile();
5462 test_testTransforms();
5464 test_FormattingXML();
5465 test_NodeTypeValue();
5466 test_TransformWithLoadingLocalFile();
5467 test_put_nodeValue();
5468 test_document_IObjectSafety();