4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2007-2008 Alistair Leslie-Hughes
6 * Copyright 2010-2011 Adam Martinson for CodeWeavers
7 * Copyright 2010-2013 Nikolay Sivov for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
35 #include "msxml2did.h"
41 #include "wine/test.h"
43 /* undef the #define in msxml2 so that we can access all versions */
44 #undef CLSID_DOMDocument
46 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
48 static int g_unexpectedcall
, g_expectedcall
;
50 struct msxmlsupported_data_t
58 static struct msxmlsupported_data_t domdoc_support_data
[] =
60 { &CLSID_DOMDocument
, "DOMDocument", {&IID_IXMLDOMDocument
, &IID_IXMLDOMDocument2
} },
61 { &CLSID_DOMDocument2
, "DOMDocument2", {&IID_IXMLDOMDocument
, &IID_IXMLDOMDocument2
} },
62 { &CLSID_DOMDocument30
, "DOMDocument30", {&IID_IXMLDOMDocument
, &IID_IXMLDOMDocument2
} },
63 { &CLSID_DOMDocument40
, "DOMDocument40", {&IID_IXMLDOMDocument
, &IID_IXMLDOMDocument2
} },
64 { &CLSID_DOMDocument60
, "DOMDocument60", {&IID_IXMLDOMDocument
, &IID_IXMLDOMDocument2
, &IID_IXMLDOMDocument3
} },
65 { &CLSID_FreeThreadedDOMDocument
, "FreeThreadedDOMDocument", {&IID_IXMLDOMDocument
, &IID_IXMLDOMDocument2
} },
66 { &CLSID_XMLSchemaCache
, "XMLSchemaCache", {&IID_IXMLDOMSchemaCollection
} },
67 { &CLSID_XSLTemplate
, "XSLTemplate", {&IID_IXSLTemplate
} },
68 { &CLSID_MXNamespaceManager40
, "MXNamespaceManager40", {&IID_IMXNamespaceManager
} },
72 static const char *debugstr_msxml_guid(REFIID riid
)
77 if (IsEqualIID(&IID_IXMLDOMDocument
, riid
))
78 return "IXMLDOMDocument";
79 else if (IsEqualIID(&IID_IXMLDOMDocument2
, riid
))
80 return "IXMLDOMDocument2";
81 else if (IsEqualIID(&IID_IXMLDOMDocument3
, riid
))
82 return "IXMLDOMDocument3";
83 else if (IsEqualIID(&IID_IXMLDOMSchemaCollection
, riid
))
84 return "IXMLDOMSchemaCollection";
85 else if (IsEqualIID(&IID_IXSLTemplate
, riid
))
86 return "IXSLTemplate";
87 else if (IsEqualIID(&IID_IMXNamespaceManager
, riid
))
88 return "IMXNamespaceManager";
90 return wine_dbgstr_guid(riid
);
93 static void get_class_support_data(struct msxmlsupported_data_t
*table
)
101 for (i
= 0; i
< sizeof(table
->ifaces
)/sizeof(table
->ifaces
[0]) && table
->ifaces
[i
] != NULL
; i
++)
103 hr
= CoCreateInstance(table
->clsid
, NULL
, CLSCTX_INPROC_SERVER
, table
->ifaces
[i
], (void**)&unk
);
104 if (hr
== S_OK
) IUnknown_Release(unk
);
106 table
->supported
[i
] = hr
== S_OK
;
107 if (hr
!= S_OK
) win_skip("class %s, iface %s not supported\n", table
->name
, debugstr_msxml_guid(table
->ifaces
[i
]));
114 static BOOL
is_clsid_supported(const GUID
*clsid
, REFIID riid
)
116 const struct msxmlsupported_data_t
*table
= domdoc_support_data
;
119 if (table
->clsid
== clsid
)
123 for (i
= 0; i
< sizeof(table
->ifaces
)/sizeof(table
->ifaces
[0]) && table
->ifaces
[i
] != NULL
; i
++)
124 if (table
->ifaces
[i
] == riid
) return table
->supported
[i
];
134 IDispatch IDispatch_iface
;
138 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
140 return CONTAINING_RECORD(iface
, dispevent
, IDispatch_iface
);
143 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
147 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
148 IsEqualGUID( riid
, &IID_IUnknown
) )
153 return E_NOINTERFACE
;
155 IDispatch_AddRef( iface
);
160 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
162 dispevent
*This
= impl_from_IDispatch( iface
);
163 return InterlockedIncrement( &This
->ref
);
166 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
168 dispevent
*This
= impl_from_IDispatch( iface
);
169 ULONG ref
= InterlockedDecrement( &This
->ref
);
172 HeapFree(GetProcessHeap(), 0, This
);
177 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
184 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
185 LCID lcid
, ITypeInfo
**ppTInfo
)
191 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
192 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
198 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
199 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
200 EXCEPINFO
*excepInfo
, UINT
*argErr
)
202 ok(member
== 0, "expected 0 member, got %d\n", member
);
203 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
204 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
206 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
207 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
208 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
209 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
211 ok(result
== NULL
, "got %p\n", result
);
212 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
213 ok(argErr
== NULL
, "got %p\n", argErr
);
219 static const IDispatchVtbl dispeventVtbl
=
221 dispevent_QueryInterface
,
224 dispevent_GetTypeInfoCount
,
225 dispevent_GetTypeInfo
,
226 dispevent_GetIDsOfNames
,
230 static IDispatch
* create_dispevent(void)
232 dispevent
*event
= HeapAlloc(GetProcessHeap(), 0, sizeof(*event
));
234 event
->IDispatch_iface
.lpVtbl
= &dispeventVtbl
;
237 return (IDispatch
*)&event
->IDispatch_iface
;
241 static HRESULT WINAPI
istream_QueryInterface(IStream
*iface
, REFIID riid
, void **ppvObject
)
245 if (IsEqualGUID(riid
, &IID_IStream
) ||
246 IsEqualGUID(riid
, &IID_IUnknown
))
249 return E_NOINTERFACE
;
254 static ULONG WINAPI
istream_AddRef(IStream
*iface
)
259 static ULONG WINAPI
istream_Release(IStream
*iface
)
264 static HRESULT WINAPI
istream_Read(IStream
*iface
, void *ptr
, ULONG len
, ULONG
*pread
)
266 ok(0, "unexpected call\n");
270 static HRESULT WINAPI
istream_Write(IStream
*iface
, const void *ptr
, ULONG len
, ULONG
*written
)
276 static HRESULT WINAPI
istream_Seek(IStream
*iface
, LARGE_INTEGER move
, DWORD origin
, ULARGE_INTEGER
*new_pos
)
278 ok(0, "unexpected call\n");
282 static HRESULT WINAPI
istream_SetSize(IStream
*iface
, ULARGE_INTEGER size
)
284 ok(0, "unexpected call\n");
288 static HRESULT WINAPI
istream_CopyTo(IStream
*iface
, IStream
*stream
, ULARGE_INTEGER len
,
289 ULARGE_INTEGER
*pread
, ULARGE_INTEGER
*written
)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI
istream_Commit(IStream
*iface
, DWORD flags
)
297 ok(0, "unexpected call\n");
301 static HRESULT WINAPI
istream_Revert(IStream
*iface
)
303 ok(0, "unexpected call\n");
307 static HRESULT WINAPI
istream_LockRegion(IStream
*iface
, ULARGE_INTEGER offset
,
308 ULARGE_INTEGER len
, DWORD locktype
)
310 ok(0, "unexpected call\n");
314 static HRESULT WINAPI
istream_UnlockRegion(IStream
*iface
, ULARGE_INTEGER offset
,
315 ULARGE_INTEGER len
, DWORD locktype
)
317 ok(0, "unexpected call\n");
321 static HRESULT WINAPI
istream_Stat(IStream
*iface
, STATSTG
*pstatstg
, DWORD flag
)
323 ok(0, "unexpected call\n");
327 static HRESULT WINAPI
istream_Clone(IStream
*iface
, IStream
**stream
)
329 ok(0, "unexpected call\n");
333 static const IStreamVtbl StreamVtbl
= {
334 istream_QueryInterface
,
345 istream_UnlockRegion
,
350 static IStream savestream
= { &StreamVtbl
};
352 #define EXPECT_CHILDREN(node) _expect_children((IXMLDOMNode*)node, __LINE__)
353 static void _expect_children(IXMLDOMNode
*node
, int line
)
359 hr
= IXMLDOMNode_hasChildNodes(node
, &b
);
360 ok_(__FILE__
,line
)(hr
== S_OK
, "hasChildNodes() failed, 0x%08x\n", hr
);
361 ok_(__FILE__
,line
)(b
== VARIANT_TRUE
, "no children, %d\n", b
);
364 #define EXPECT_NO_CHILDREN(node) _expect_no_children((IXMLDOMNode*)node, __LINE__)
365 static void _expect_no_children(IXMLDOMNode
*node
, int line
)
371 hr
= IXMLDOMNode_hasChildNodes(node
, &b
);
372 ok_(__FILE__
,line
)(hr
== S_FALSE
, "hasChildNodes() failed, 0x%08x\n", hr
);
373 ok_(__FILE__
,line
)(b
== VARIANT_FALSE
, "no children, %d\n", b
);
376 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__)
377 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
380 IUnknown_AddRef(obj
);
381 rc
= IUnknown_Release(obj
);
382 ok_(__FILE__
,line
)(rc
== ref
, "expected refcount %d, got %d\n", ref
, rc
);
385 #define EXPECT_LIST_LEN(list,len) _expect_list_len(list, len, __LINE__)
386 static void _expect_list_len(IXMLDOMNodeList
*list
, LONG len
, int line
)
392 hr
= IXMLDOMNodeList_get_length(list
, &length
);
393 ok_(__FILE__
,line
)(hr
== S_OK
, "got 0x%08x\n", hr
);
394 ok_(__FILE__
,line
)(length
== len
, "got %d, expected %d\n", length
, len
);
397 #define EXPECT_HR(hr,hr_exp) \
398 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
400 static const WCHAR szEmpty
[] = { 0 };
401 static const WCHAR szIncomplete
[] = {
402 '<','?','x','m','l',' ',
403 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
405 static const WCHAR szComplete1
[] = {
406 '<','?','x','m','l',' ',
407 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
408 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
410 static const WCHAR szComplete2
[] = {
411 '<','?','x','m','l',' ',
412 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
413 '<','a','>','<','/','a','>','\n',0
415 static const char complete4A
[] =
416 "<?xml version=\'1.0\'?>\n"
418 "<bs vr=\'str2\' sz=\'1234\'>"
421 "<pr id=\'str3\' vr=\'1.2.3\' pn=\'wine 20050804\'>\n"
432 static const WCHAR szComplete5
[] = {
433 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
434 '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','"',
435 ' ','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','"','>',
436 '<','S',':','s','c','o','p','e','>',
437 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
438 '<','/','S',':','s','c','o','p','e','>',
439 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
440 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
441 'c','o','m','p','u','t','e','r',
442 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
443 '<','/','S',':','s','e','a','r','c','h','>',0
446 static const WCHAR szComplete6
[] = {
447 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'',' ',
448 'e','n','c','o','d','i','n','g','=','\'','W','i','n','d','o','w','s','-','1','2','5','2','\'','?','>','\n',
449 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
452 static const char complete7
[] = {
453 "<?xml version=\"1.0\"?>\n\t"
461 #define DECL_WIN_1252 \
462 "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>"
464 static const char win1252xml
[] =
468 static const char win1252decl
[] =
472 static const char nocontent
[] = "no xml content here";
474 static const char szExampleXML
[] =
475 "<?xml version='1.0' encoding='utf-8'?>\n"
476 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' a=\"attr a\" foo:b=\"attr b\" >\n"
482 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
483 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
484 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
486 " <html xml:space='preserve' xmlns='http://www.w3.org/1999/xhtml'>\n"
487 " This is <strong>a</strong> <i>description</i> with preserved whitespace. <bar:x/>\n"
495 " <c type=\"old\">C2 field</c>\n"
499 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
508 " <foo:c>C4 field</foo:c>\n"
513 static const char charrefsxml
[] =
514 "<?xml version='1.0'?>"
516 "<b1> Text A end </b1>"
517 "<b2>AB C </b2>"
520 static const CHAR szNodeTypesXML
[] =
521 "<?xml version='1.0'?>"
522 "<!-- comment node 0 -->"
523 "<root id='0' depth='0'>"
524 " <!-- comment node 1 -->"
526 " <x id='1' depth='1'>"
527 " <?foo value='PI for x'?>"
528 " <!-- comment node 2 -->"
530 " <a id='3' depth='2'/>"
531 " <b id='4' depth='2'/>"
532 " <c id='5' depth='2'/>"
534 " <y id='2' depth='1'>"
535 " <?bar value='PI for y'?>"
536 " <!-- comment node 3 -->"
538 " <a id='6' depth='2'/>"
539 " <b id='7' depth='2'/>"
540 " <c id='8' depth='2'/>"
544 static const CHAR szTransformXML
[] =
545 "<?xml version=\"1.0\"?>\n"
550 static const CHAR szTransformSSXML
[] =
551 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
552 " <xsl:output method=\"html\"/>\n"
553 " <xsl:template match=\"/\">\n"
554 " <xsl:apply-templates select=\"greeting\"/>\n"
556 " <xsl:template match=\"greeting\">\n"
560 " <xsl:value-of select=\".\"/>\n"
567 static const CHAR szTransformOutput
[] =
570 "</h1></body></html>";
572 static const CHAR szTypeValueXML
[] =
573 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
574 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
575 " <string>Wine</string>\n"
576 " <string2 dt:dt=\"string\">String</string2>\n"
577 " <number dt:dt=\"number\">12.44</number>\n"
578 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
579 " <int dt:dt=\"int\">-13</int>\n"
580 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
581 " <bool dt:dt=\"boolean\">1</bool>\n"
582 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
583 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
584 " <date dt:dt=\"date\">3721-11-01</date>\n"
585 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
586 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
587 " <i1 dt:dt=\"i1\">-13</i1>\n"
588 " <i2 dt:dt=\"i2\">31915</i2>\n"
589 " <i4 dt:dt=\"i4\">-312232</i4>\n"
590 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
591 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
592 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
593 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
594 " <r8 dt:dt=\"r8\">0.412</r8>\n"
595 " <float dt:dt=\"float\">41221.421</float>\n"
596 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
597 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
598 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
599 " <binbase64_1 dt:dt=\"bin.base64\">\nYmFzZTY0\nIHRlc3Q=\n</binbase64_1>\n"
600 " <binbase64_2 dt:dt=\"bin.base64\">\nYmF\r\t z ZTY0\nIHRlc3Q=\n</binbase64_2>\n"
603 static const CHAR szBasicTransformSSXMLPart1
[] =
604 "<?xml version=\"1.0\"?>"
605 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
606 "<xsl:output method=\"html\"/>\n"
607 "<xsl:template match=\"/\">"
608 "<HTML><BODY><TABLE>"
609 " <xsl:apply-templates select='document(\"";
611 static const CHAR szBasicTransformSSXMLPart2
[] =
613 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
614 " </xsl:apply-templates>"
615 "</TABLE></BODY></HTML>"
617 "<xsl:template match=\"bottle\">"
618 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
620 "<xsl:template match=\"name\">"
621 " <TD><xsl:apply-templates /></TD>"
623 "<xsl:template match=\"cost\">"
624 " <TD><xsl:apply-templates /></TD>"
628 static const CHAR szBasicTransformXML
[] =
629 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
631 static const CHAR szBasicTransformOutput
[] =
632 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
634 #define SZ_EMAIL_DTD \
636 " <!ELEMENT email (recipients,from,reply-to?,subject,body,attachment*)>"\
637 " <!ATTLIST email attachments IDREFS #REQUIRED>"\
638 " <!ATTLIST email sent (yes|no) \"no\">"\
639 " <!ELEMENT recipients (to+,cc*)>"\
640 " <!ELEMENT to (#PCDATA)>"\
641 " <!ATTLIST to name CDATA #IMPLIED>"\
642 " <!ELEMENT cc (#PCDATA)>"\
643 " <!ATTLIST cc name CDATA #IMPLIED>"\
644 " <!ELEMENT from (#PCDATA)>"\
645 " <!ATTLIST from name CDATA #IMPLIED>"\
646 " <!ELEMENT reply-to (#PCDATA)>"\
647 " <!ATTLIST reply-to name CDATA #IMPLIED>"\
648 " <!ELEMENT subject ANY>"\
649 " <!ELEMENT body ANY>"\
650 " <!ATTLIST body enc CDATA #FIXED \"UTF-8\">"\
651 " <!ELEMENT attachment (#PCDATA)>"\
652 " <!ATTLIST attachment id ID #REQUIRED>"\
655 static const CHAR szEmailXML
[] =
656 "<?xml version=\"1.0\"?>"
658 "<email attachments=\"patch1\">"
660 " <to>wine-patches@winehq.org</to>"
662 " <from name=\"Anonymous\">user@localhost</from>"
663 " <subject>msxml3/tests: DTD validation (try 87)</subject>"
665 " It no longer causes spontaneous combustion..."
667 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
670 static const CHAR szEmailXML_0D
[] =
671 "<?xml version=\"1.0\"?>"
673 "<email attachments=\"patch1\">"
675 " <to>wine-patches@winehq.org</to>"
677 " <from name=\"Anonymous\">user@localhost</from>"
678 " <subject>msxml3/tests: DTD validation (try 88)</subject>"
681 " XML_ELEMENT_UNDECLARED 0xC00CE00D"
683 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
686 static const CHAR szEmailXML_0E
[] =
687 "<?xml version=\"1.0\"?>"
689 "<email attachments=\"patch1\">"
691 " <to>wine-patches@winehq.org</to>"
693 " <from name=\"Anonymous\">user@localhost</from>"
694 " <subject>msxml3/tests: DTD validation (try 89)</subject>"
696 " XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E"
698 " <attachment id=\"patch\">0001-msxml3-tests-DTD-validation.patch</attachment>"
701 static const CHAR szEmailXML_11
[] =
702 "<?xml version=\"1.0\"?>"
704 "<email attachments=\"patch1\">"
707 " <from name=\"Anonymous\">user@localhost</from>"
708 " <subject>msxml3/tests: DTD validation (try 90)</subject>"
710 " XML_EMPTY_NOT_ALLOWED 0xC00CE011"
712 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
715 static const CHAR szEmailXML_13
[] =
716 "<?xml version=\"1.0\"?>"
718 "<msg attachments=\"patch1\">"
720 " <to>wine-patches@winehq.org</to>"
722 " <from name=\"Anonymous\">user@localhost</from>"
723 " <subject>msxml3/tests: DTD validation (try 91)</subject>"
725 " XML_ROOT_NAME_MISMATCH 0xC00CE013"
727 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
730 static const CHAR szEmailXML_14
[] =
731 "<?xml version=\"1.0\"?>"
733 "<email attachments=\"patch1\">"
734 " <to>wine-patches@winehq.org</to>"
735 " <from name=\"Anonymous\">user@localhost</from>"
736 " <subject>msxml3/tests: DTD validation (try 92)</subject>"
738 " XML_INVALID_CONTENT 0xC00CE014"
740 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
743 static const CHAR szEmailXML_15
[] =
744 "<?xml version=\"1.0\"?>"
746 "<email attachments=\"patch1\" ip=\"127.0.0.1\">"
748 " <to>wine-patches@winehq.org</to>"
750 " <from name=\"Anonymous\">user@localhost</from>"
751 " <subject>msxml3/tests: DTD validation (try 93)</subject>"
753 " XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015"
755 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
758 static const CHAR szEmailXML_16
[] =
759 "<?xml version=\"1.0\"?>"
761 "<email attachments=\"patch1\">"
763 " <to>wine-patches@winehq.org</to>"
765 " <from name=\"Anonymous\">user@localhost</from>"
766 " <subject>msxml3/tests: DTD validation (try 94)</subject>"
767 " <body enc=\"ASCII\">"
768 " XML_ATTRIBUTE_FIXED 0xC00CE016"
770 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
773 static const CHAR szEmailXML_17
[] =
774 "<?xml version=\"1.0\"?>"
776 "<email attachments=\"patch1\" sent=\"true\">"
778 " <to>wine-patches@winehq.org</to>"
780 " <from name=\"Anonymous\">user@localhost</from>"
781 " <subject>msxml3/tests: DTD validation (try 95)</subject>"
783 " XML_ATTRIBUTE_VALUE 0xC00CE017"
785 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
788 static const CHAR szEmailXML_18
[] =
789 "<?xml version=\"1.0\"?>"
791 "<email attachments=\"patch1\">"
794 " <to>wine-patches@winehq.org</to>"
796 " <from name=\"Anonymous\">user@localhost</from>"
797 " <subject>msxml3/tests: DTD validation (try 96)</subject>"
799 " XML_ILLEGAL_TEXT 0xC00CE018"
801 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
804 static const CHAR szEmailXML_20
[] =
805 "<?xml version=\"1.0\"?>"
809 " <to>wine-patches@winehq.org</to>"
811 " <from name=\"Anonymous\">user@localhost</from>"
812 " <subject>msxml3/tests: DTD validation (try 97)</subject>"
814 " XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020"
816 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
819 static const char xpath_simple_list
[] =
820 "<?xml version=\"1.0\"?>"
822 " <a attr1=\"1\" attr2=\"2\" />"
828 static const char default_ns_doc
[] = {
829 "<?xml version=\"1.0\"?>"
830 "<a xmlns:ns=\"nshref\" xml:lang=\"ru\" ns:b=\"b attr\" xml:c=\"c attr\" "
834 static const char attributes_map
[] = {
835 "<?xml version=\"1.0\"?>"
836 "<a attr1=\"value1\" attr2=\"value2\" attr3=\"value3\" attr4=\"value4\" />"
839 static const WCHAR nonexistent_fileW
[] = {
840 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
842 static const WCHAR nonexistent_attrW
[] = {
843 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
845 static const WCHAR szDocument
[] = {
846 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
849 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
850 static const WCHAR szdl
[] = { 'd','l',0 };
851 static const WCHAR szvr
[] = { 'v','r',0 };
852 static const WCHAR szlc
[] = { 'l','c',0 };
853 static const WCHAR szbs
[] = { 'b','s',0 };
854 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
855 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
856 static const WCHAR szstar
[] = { '*',0 };
857 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
859 static const WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
860 static const WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
861 static const WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
863 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
864 static const WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
865 static const WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
866 static const WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
867 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
868 static const WCHAR szElementXML4
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
869 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
871 static const WCHAR szAttribute
[] = {'A','t','t','r',0 };
872 static const WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
874 static const WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
875 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
876 static const WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
877 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
879 static const WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
880 static const WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
882 static const WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
883 static const WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
884 static const WCHAR szStrangeChars
[] = {'&','x',' ',0x2103, 0};
886 #define expect_bstr_eq_and_free(bstr, expect) { \
887 BSTR bstrExp = alloc_str_from_narrow(expect); \
888 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
889 SysFreeString(bstr); \
890 SysFreeString(bstrExp); \
893 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
895 #define ole_check(expr) { \
897 ok(r == S_OK, #expr " returned %x\n", r); \
900 #define ole_expect(expr, expect) { \
902 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
905 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
907 static void* _create_object(const GUID
*clsid
, const char *name
, const IID
*iid
, int line
)
912 hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, iid
, &obj
);
913 ok(hr
== S_OK
, "failed to create %s instance: 0x%08x\n", name
, hr
);
918 #define _create(cls) cls, #cls
920 #define create_document(iid) _create_object(&_create(CLSID_DOMDocument2), iid, __LINE__)
921 #define create_document_version(v, iid) _create_object(&_create(CLSID_DOMDocument ## v), iid, __LINE__)
922 #define create_cache(iid) _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__)
923 #define create_xsltemplate(iid) _create_object(&_create(CLSID_XSLTemplate), iid, __LINE__)
925 static BSTR
alloc_str_from_narrow(const char *str
)
927 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
928 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
929 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
933 static BSTR alloced_bstrs
[256];
934 static int alloced_bstrs_count
;
936 static BSTR
_bstr_(const char *str
)
938 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
939 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
940 return alloced_bstrs
[alloced_bstrs_count
++];
943 static void free_bstrs(void)
946 for (i
= 0; i
< alloced_bstrs_count
; i
++)
947 SysFreeString(alloced_bstrs
[i
]);
948 alloced_bstrs_count
= 0;
951 static VARIANT
_variantbstr_(const char *str
)
955 V_BSTR(&v
) = _bstr_(str
);
959 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
963 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
964 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
965 if (*sLeft
!= *sRight
) return FALSE
;
966 if (!*sLeft
) return TRUE
;
972 static void get_str_for_type(DOMNodeType type
, char *buf
)
991 case NODE_PROCESSING_INSTRUCTION
:
995 wsprintfA(buf
, "[%d]", type
);
999 static int get_node_position(IXMLDOMNode
*node
)
1004 IXMLDOMNode_AddRef(node
);
1007 IXMLDOMNode
*new_node
;
1010 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
1011 ok(SUCCEEDED(r
), "get_previousSibling failed\n");
1012 IXMLDOMNode_Release(node
);
1014 } while (r
== S_OK
);
1018 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
1025 lstrcpyA(buf
, "(null)");
1029 IXMLDOMNode_AddRef(node
);
1032 IXMLDOMNode
*new_node
;
1034 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
1035 get_str_for_type(type
, buf
);
1038 if (type
== NODE_ATTRIBUTE
)
1041 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
1043 wsprintfA(buf
, "%ws", bstr
);
1046 SysFreeString(bstr
);
1048 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
1052 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
1053 sprintf(buf
, "%d", get_node_position(node
));
1057 ok(SUCCEEDED(r
), "get_parentNode failed (%08x)\n", r
);
1058 IXMLDOMNode_Release(node
);
1067 static char *list_to_string(IXMLDOMNodeList
*list
)
1069 static char buf
[4096];
1077 strcpy(buf
, "(null)");
1080 hr
= IXMLDOMNodeList_get_length(list
, &len
);
1081 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1082 for (i
= 0; i
< len
; i
++)
1087 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1088 node_to_string(node
, pos
);
1090 IXMLDOMNode_Release(node
);
1096 #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); }
1097 #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); }
1099 struct docload_ret_t
{
1104 struct leading_spaces_t
{
1107 struct docload_ret_t ret
[2]; /* 0 - ::load(), 1 - ::loadXML() */
1110 static const struct leading_spaces_t leading_spaces_classdata
[] = {
1111 { &CLSID_DOMDocument
, "CLSID_DOMDocument", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_TRUE
, S_OK
} }},
1112 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
1113 { &CLSID_DOMDocument26
, "CLSID_DOMDocument26", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_TRUE
, S_OK
} }},
1114 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
1115 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
1116 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
1120 static const char* leading_spaces_xmldata
[] = {
1121 "\n<?xml version=\"1.0\" encoding=\"UTF-16\" ?><root/>",
1122 " <?xml version=\"1.0\"?><root/>",
1123 "\n<?xml version=\"1.0\"?><root/>",
1124 "\t<?xml version=\"1.0\"?><root/>",
1125 "\r\n<?xml version=\"1.0\"?><root/>",
1126 "\r<?xml version=\"1.0\"?><root/>",
1127 "\r\r\r\r\t\t \n\n <?xml version=\"1.0\"?><root/>",
1131 static void test_domdoc( void )
1134 IXMLDOMDocument
*doc
;
1135 IXMLDOMParseError
*error
;
1136 IXMLDOMElement
*element
= NULL
;
1138 IXMLDOMText
*nodetext
= NULL
;
1139 IXMLDOMComment
*node_comment
= NULL
;
1140 IXMLDOMAttribute
*node_attr
= NULL
;
1141 IXMLDOMNode
*nodeChild
= NULL
;
1142 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
1143 const struct leading_spaces_t
*class_ptr
;
1144 const char **data_ptr
;
1151 char path
[MAX_PATH
];
1154 GetTempPathA(MAX_PATH
, path
);
1155 strcat(path
, "leading_spaces.xml");
1157 /* Load document with leading spaces
1159 * Test all CLSIDs with all test data XML strings
1161 class_ptr
= leading_spaces_classdata
;
1163 while (class_ptr
->clsid
)
1168 if (is_clsid_supported(class_ptr
->clsid
, &IID_IXMLDOMDocument
))
1170 hr
= CoCreateInstance(class_ptr
->clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
1179 data_ptr
= leading_spaces_xmldata
;
1182 BSTR data
= _bstr_(*data_ptr
);
1186 file
= CreateFileA(path
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1187 ok(file
!= INVALID_HANDLE_VALUE
, "can't create file %s: %u\n", path
, GetLastError());
1189 WriteFile(file
, data
, lstrlenW(data
)*sizeof(WCHAR
), &written
, NULL
);
1193 V_VT(&var
) = VT_BSTR
;
1194 V_BSTR(&var
) = _bstr_(path
);
1195 hr
= IXMLDOMDocument_load(doc
, var
, &b
);
1196 EXPECT_HR(hr
, class_ptr
->ret
[0].hr
);
1197 ok(b
== class_ptr
->ret
[0].b
, "%d:%d, got %d, expected %d\n", index
, i
, b
, class_ptr
->ret
[0].b
);
1202 hr
= IXMLDOMDocument_loadXML(doc
, data
, &b
);
1203 EXPECT_HR(hr
, class_ptr
->ret
[1].hr
);
1204 ok(b
== class_ptr
->ret
[1].b
, "%d:%d, got %d, expected %d\n", index
, i
, b
, class_ptr
->ret
[1].b
);
1215 doc
= create_document(&IID_IXMLDOMDocument
);
1220 /* crashes on native */
1221 IXMLDOMDocument_loadXML( doc
, (BSTR
)0x1, NULL
);
1224 /* try some stupid things */
1225 hr
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
1226 EXPECT_HR(hr
, S_FALSE
);
1229 hr
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
1230 EXPECT_HR(hr
, S_FALSE
);
1231 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
1233 /* try to load a document from a nonexistent file */
1235 str
= SysAllocString( nonexistent_fileW
);
1237 V_VT(&var
) = VT_BSTR
;
1240 r
= IXMLDOMDocument_load( doc
, var
, &b
);
1241 ok( r
== S_FALSE
, "loadXML succeeded\n");
1242 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1243 SysFreeString( str
);
1246 hr
= IXMLDOMDocument_get_url(doc
, &str
);
1247 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
1248 ok(str
== NULL
, "got %p\n", str
);
1250 /* try load an empty document */
1252 str
= SysAllocString( szEmpty
);
1253 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1254 ok( r
== S_FALSE
, "loadXML succeeded\n");
1255 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1256 SysFreeString( str
);
1258 r
= IXMLDOMDocument_get_async( doc
, &b
);
1259 ok( r
== S_OK
, "get_async failed (%08x)\n", r
);
1260 ok( b
== VARIANT_TRUE
, "Wrong default value\n");
1262 /* check that there's no document element */
1264 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1265 ok( r
== S_FALSE
, "should be no document element\n");
1267 /* try finding a node */
1269 str
= SysAllocString( szstr1
);
1270 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
1271 ok( r
== S_FALSE
, "ret %08x\n", r
);
1272 SysFreeString( str
);
1275 str
= SysAllocString( szIncomplete
);
1276 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1277 ok( r
== S_FALSE
, "loadXML succeeded\n");
1278 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1279 SysFreeString( str
);
1281 /* check that there's no document element */
1282 element
= (IXMLDOMElement
*)1;
1283 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1284 ok( r
== S_FALSE
, "should be no document element\n");
1285 ok( element
== NULL
, "Element should be NULL\n");
1287 /* test for BSTR handling, pass broken BSTR */
1288 memcpy(&buff
[2], szComplete1
, sizeof(szComplete1
));
1289 /* just a big length */
1290 *(DWORD
*)buff
= 0xf0f0;
1292 r
= IXMLDOMDocument_loadXML( doc
, &buff
[2], &b
);
1293 ok( r
== S_OK
, "loadXML failed\n");
1294 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1296 /* loadXML ignores the encoding attribute and always expects Unicode */
1298 str
= SysAllocString( szComplete6
);
1299 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1300 ok( r
== S_OK
, "loadXML failed\n");
1301 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1302 SysFreeString( str
);
1304 /* try a BSTR containing a Windows-1252 document */
1306 str
= SysAllocStringByteLen( win1252xml
, strlen(win1252xml
) );
1307 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1308 ok( r
== S_FALSE
, "loadXML succeeded\n");
1309 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
1310 SysFreeString( str
);
1312 /* try to load something valid */
1314 str
= SysAllocString( szComplete1
);
1315 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1316 ok( r
== S_OK
, "loadXML failed\n");
1317 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1318 SysFreeString( str
);
1320 /* check if nodename is correct */
1321 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
1322 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1324 str
= (BSTR
)0xdeadbeef;
1325 r
= IXMLDOMDocument_get_baseName( doc
, &str
);
1326 ok ( r
== S_FALSE
, "got 0x%08x\n", r
);
1327 ok (str
== NULL
, "got %p\n", str
);
1329 /* content doesn't matter here */
1331 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
1332 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1333 ok ( str
!= NULL
, "str is null\n");
1334 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
1335 SysFreeString( str
);
1338 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should fail") );
1339 ok( r
== E_FAIL
, "ret %08x\n", r
);
1341 /* check that there's a document element */
1343 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1344 ok( r
== S_OK
, "should be a document element\n");
1347 IObjectIdentity
*ident
;
1349 r
= IXMLDOMElement_QueryInterface( element
, &IID_IObjectIdentity
, (void**)&ident
);
1350 ok( r
== E_NOINTERFACE
, "ret %08x\n", r
);
1352 IXMLDOMElement_Release( element
);
1356 /* as soon as we call loadXML again, the document element will disappear */
1358 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
1359 ok( r
== S_FALSE
, "loadXML failed\n");
1360 ok( b
== 2, "variant modified\n");
1361 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1362 ok( r
== S_FALSE
, "should be no document element\n");
1364 /* try to load something else simple and valid */
1366 str
= SysAllocString( szComplete2
);
1367 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
1368 ok( r
== S_OK
, "loadXML failed\n");
1369 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1370 SysFreeString( str
);
1372 /* try something a little more complicated */
1374 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
1375 ok( r
== S_OK
, "loadXML failed\n");
1376 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1378 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
1379 ok( r
== S_OK
, "returns %08x\n", r
);
1381 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
1382 ok( r
== S_FALSE
, "returns %08x\n", r
);
1383 ok( code
== 0, "code %d\n", code
);
1384 IXMLDOMParseError_Release( error
);
1386 /* test createTextNode */
1387 r
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &nodetext
);
1388 ok( r
== S_OK
, "returns %08x\n", r
);
1389 IXMLDOMText_Release(nodetext
);
1391 str
= SysAllocString( szOpen
);
1392 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
1393 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1394 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
1395 ok( r
== S_OK
, "returns %08x\n", r
);
1396 SysFreeString( str
);
1399 r
= IXMLDOMText_QueryInterface(nodetext
, &IID_IXMLDOMElement
, (void**)&element
);
1400 ok(r
== E_NOINTERFACE
, "ret %08x\n", r
);
1402 /* Text Last Child Checks */
1403 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
1404 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1406 nodeChild
= (IXMLDOMNode
*)0x1;
1407 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
1408 ok(r
== S_FALSE
, "ret %08x\n", r
);
1409 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
1411 /* test length property */
1412 r
= IXMLDOMText_get_length(nodetext
, NULL
);
1413 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1415 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1416 ok(r
== S_OK
, "ret %08x\n", r
);
1417 ok(nLength
== 4, "expected 4 got %d\n", nLength
);
1419 /* put data Tests */
1420 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
1421 ok(r
== S_OK
, "ret %08x\n", r
);
1423 /* get data Tests */
1424 r
= IXMLDOMText_get_data(nodetext
, &str
);
1425 ok(r
== S_OK
, "ret %08x\n", r
);
1426 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
1429 /* Confirm XML text is good */
1430 r
= IXMLDOMText_get_xml(nodetext
, &str
);
1431 ok(r
== S_OK
, "ret %08x\n", r
);
1432 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
1435 /* Confirm we get the put_data Text back */
1436 r
= IXMLDOMText_get_text(nodetext
, &str
);
1437 ok(r
== S_OK
, "ret %08x\n", r
);
1438 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
1441 /* test substringData */
1442 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
1443 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1445 /* test substringData - Invalid offset */
1446 str
= (BSTR
)&szElement
;
1447 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
1448 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1449 ok( str
== NULL
, "incorrect string\n");
1451 /* test substringData - Invalid offset */
1452 str
= (BSTR
)&szElement
;
1453 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
1454 ok(r
== S_FALSE
, "ret %08x\n", r
);
1455 ok( str
== NULL
, "incorrect string\n");
1457 /* test substringData - Invalid size */
1458 str
= (BSTR
)&szElement
;
1459 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
1460 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1461 ok( str
== NULL
, "incorrect string\n");
1463 /* test substringData - Invalid size */
1464 str
= (BSTR
)&szElement
;
1465 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
1466 ok(r
== S_FALSE
, "ret %08x\n", r
);
1467 ok( str
== NULL
, "incorrect string\n");
1469 /* test substringData - Start of string */
1470 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
1471 ok(r
== S_OK
, "ret %08x\n", r
);
1472 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
1475 /* test substringData - Middle of string */
1476 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
1477 ok(r
== S_OK
, "ret %08x\n", r
);
1478 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
1481 /* test substringData - End of string */
1482 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
1483 ok(r
== S_OK
, "ret %08x\n", r
);
1484 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
1487 /* test appendData */
1488 r
= IXMLDOMText_appendData(nodetext
, NULL
);
1489 ok(r
== S_OK
, "ret %08x\n", r
);
1491 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
1492 ok(r
== S_OK
, "ret %08x\n", r
);
1494 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
1495 ok(r
== S_OK
, "ret %08x\n", r
);
1497 r
= IXMLDOMText_get_text(nodetext
, &str
);
1498 ok(r
== S_OK
, "ret %08x\n", r
);
1499 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1502 /* test insertData */
1503 str
= SysAllocStringLen(NULL
, 0);
1504 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
1505 ok(r
== S_OK
, "ret %08x\n", r
);
1507 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
1508 ok(r
== S_OK
, "ret %08x\n", r
);
1510 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
1511 ok(r
== S_OK
, "ret %08x\n", r
);
1513 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
1514 ok(r
== S_OK
, "ret %08x\n", r
);
1516 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
1517 ok(r
== S_OK
, "ret %08x\n", r
);
1519 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
1520 ok(r
== S_OK
, "ret %08x\n", r
);
1523 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
1524 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1526 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
1527 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1529 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
1530 ok(r
== S_OK
, "ret %08x\n", r
);
1532 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
1533 ok(r
== S_OK
, "ret %08x\n", r
);
1535 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
1536 ok(r
== S_OK
, "ret %08x\n", r
);
1538 r
= IXMLDOMText_get_text(nodetext
, &str
);
1539 ok(r
== S_OK
, "ret %08x\n", r
);
1540 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1544 /* invalid arguments */
1545 r
= IXMLDOMText_deleteData(nodetext
, -1, 1);
1546 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1548 r
= IXMLDOMText_deleteData(nodetext
, 0, 0);
1549 ok(r
== S_OK
, "ret %08x\n", r
);
1551 r
= IXMLDOMText_deleteData(nodetext
, 0, -1);
1552 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1554 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1555 ok(r
== S_OK
, "ret %08x\n", r
);
1556 ok(nLength
== 43, "expected 43 got %d\n", nLength
);
1558 r
= IXMLDOMText_deleteData(nodetext
, nLength
, 1);
1559 ok(r
== S_OK
, "ret %08x\n", r
);
1561 r
= IXMLDOMText_deleteData(nodetext
, nLength
+1, 1);
1562 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1564 /* delete from start */
1565 r
= IXMLDOMText_deleteData(nodetext
, 0, 5);
1566 ok(r
== S_OK
, "ret %08x\n", r
);
1568 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1569 ok(r
== S_OK
, "ret %08x\n", r
);
1570 ok(nLength
== 38, "expected 38 got %d\n", nLength
);
1572 r
= IXMLDOMText_get_text(nodetext
, &str
);
1573 ok(r
== S_OK
, "ret %08x\n", r
);
1574 ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1577 /* delete from end */
1578 r
= IXMLDOMText_deleteData(nodetext
, 35, 3);
1579 ok(r
== S_OK
, "ret %08x\n", r
);
1581 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1582 ok(r
== S_OK
, "ret %08x\n", r
);
1583 ok(nLength
== 35, "expected 35 got %d\n", nLength
);
1585 r
= IXMLDOMText_get_text(nodetext
, &str
);
1586 ok(r
== S_OK
, "ret %08x\n", r
);
1587 ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1590 /* delete from inside */
1591 r
= IXMLDOMText_deleteData(nodetext
, 1, 33);
1592 ok(r
== S_OK
, "ret %08x\n", r
);
1594 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1595 ok(r
== S_OK
, "ret %08x\n", r
);
1596 ok(nLength
== 2, "expected 2 got %d\n", nLength
);
1598 r
= IXMLDOMText_get_text(nodetext
, &str
);
1599 ok(r
== S_OK
, "ret %08x\n", r
);
1600 ok( !lstrcmpW( str
, _bstr_("") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1603 /* delete whole data ... */
1604 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
1605 ok(r
== S_OK
, "ret %08x\n", r
);
1607 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
1608 ok(r
== S_OK
, "ret %08x\n", r
);
1609 /* ... and try again with empty string */
1610 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
1611 ok(r
== S_OK
, "ret %08x\n", r
);
1614 V_VT(&var
) = VT_BSTR
;
1615 V_BSTR(&var
) = SysAllocString(szstr1
);
1616 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1617 ok(r
== S_OK
, "ret %08x\n", r
);
1620 r
= IXMLDOMText_get_text(nodetext
, &str
);
1621 ok(r
== S_OK
, "ret %08x\n", r
);
1622 ok( !lstrcmpW( str
, szstr1
), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1628 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1629 ok(r
== S_OK
, "ret %08x\n", r
);
1632 r
= IXMLDOMText_get_text(nodetext
, &str
);
1633 ok(r
== S_OK
, "ret %08x\n", r
);
1634 ok( !lstrcmpW( str
, _bstr_("99") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1637 /* ::replaceData() */
1638 V_VT(&var
) = VT_BSTR
;
1639 V_BSTR(&var
) = SysAllocString(szstr1
);
1640 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
1641 ok(r
== S_OK
, "ret %08x\n", r
);
1644 r
= IXMLDOMText_replaceData(nodetext
, 6, 0, NULL
);
1645 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1646 r
= IXMLDOMText_get_text(nodetext
, &str
);
1647 ok(r
== S_OK
, "ret %08x\n", r
);
1648 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1651 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, NULL
);
1652 ok(r
== S_OK
, "ret %08x\n", r
);
1653 r
= IXMLDOMText_get_text(nodetext
, &str
);
1654 ok(r
== S_OK
, "ret %08x\n", r
);
1655 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1658 /* NULL pointer means delete */
1659 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, NULL
);
1660 ok(r
== S_OK
, "ret %08x\n", r
);
1661 r
= IXMLDOMText_get_text(nodetext
, &str
);
1662 ok(r
== S_OK
, "ret %08x\n", r
);
1663 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1666 /* empty string means delete */
1667 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_(""));
1668 ok(r
== S_OK
, "ret %08x\n", r
);
1669 r
= IXMLDOMText_get_text(nodetext
, &str
);
1670 ok(r
== S_OK
, "ret %08x\n", r
);
1671 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1674 /* zero count means insert */
1675 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, _bstr_("a"));
1676 ok(r
== S_OK
, "ret %08x\n", r
);
1677 r
= IXMLDOMText_get_text(nodetext
, &str
);
1678 ok(r
== S_OK
, "ret %08x\n", r
);
1679 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1682 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, NULL
);
1683 ok(r
== S_OK
, "ret %08x\n", r
);
1685 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("m"));
1686 ok(r
== S_OK
, "ret %08x\n", r
);
1687 r
= IXMLDOMText_get_text(nodetext
, &str
);
1688 ok(r
== S_OK
, "ret %08x\n", r
);
1689 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1692 /* nonempty string, count greater than its length */
1693 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, _bstr_("a1.2"));
1694 ok(r
== S_OK
, "ret %08x\n", r
);
1695 r
= IXMLDOMText_get_text(nodetext
, &str
);
1696 ok(r
== S_OK
, "ret %08x\n", r
);
1697 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1700 /* nonempty string, count less than its length */
1701 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_("wine"));
1702 ok(r
== S_OK
, "ret %08x\n", r
);
1703 r
= IXMLDOMText_get_text(nodetext
, &str
);
1704 ok(r
== S_OK
, "ret %08x\n", r
);
1705 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
1708 IXMLDOMText_Release( nodetext
);
1711 /* test Create Comment */
1712 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
1713 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1714 node_comment
= (IXMLDOMComment
*)0x1;
1717 r
= IXMLDOMDocument_createComment(doc
, _bstr_(""), &node_comment
);
1718 ok( r
== S_OK
, "returns %08x\n", r
);
1720 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1721 ok( r
== S_OK
, "returns %08x\n", r
);
1722 ok( str
&& SysStringLen(str
) == 0, "expected empty string data\n");
1723 IXMLDOMComment_Release(node_comment
);
1726 r
= IXMLDOMDocument_createComment(doc
, NULL
, &node_comment
);
1727 ok( r
== S_OK
, "returns %08x\n", r
);
1729 r
= IXMLDOMComment_get_data(node_comment
, &str
);
1730 ok( r
== S_OK
, "returns %08x\n", r
);
1731 ok( str
&& (SysStringLen(str
) == 0), "expected empty string data\n");
1732 IXMLDOMComment_Release(node_comment
);
1735 str
= SysAllocString(szComment
);
1736 r
= IXMLDOMDocument_createComment(doc
, str
, &node_comment
);
1738 ok( r
== S_OK
, "returns %08x\n", r
);
1741 /* Last Child Checks */
1742 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
1743 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1745 nodeChild
= (IXMLDOMNode
*)0x1;
1746 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
1747 ok(r
== S_FALSE
, "ret %08x\n", r
);
1748 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
1751 str
= (BSTR
)0xdeadbeef;
1752 r
= IXMLDOMComment_get_baseName(node_comment
, &str
);
1753 ok(r
== S_FALSE
, "ret %08x\n", r
);
1754 ok(str
== NULL
, "Expected NULL\n");
1756 IXMLDOMComment_Release( node_comment
);
1759 /* test Create Attribute */
1760 str
= SysAllocString(szAttribute
);
1761 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
1762 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1763 r
= IXMLDOMDocument_createAttribute(doc
, str
, &node_attr
);
1764 ok( r
== S_OK
, "returns %08x\n", r
);
1765 IXMLDOMAttribute_Release( node_attr
);
1768 /* test Processing Instruction */
1769 str
= SysAllocStringLen(NULL
, 0);
1770 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
1771 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
1772 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
1773 ok( r
== E_FAIL
, "returns %08x\n", r
);
1774 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
1775 ok( r
== E_FAIL
, "returns %08x\n", r
);
1778 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
1779 ok( r
== S_OK
, "returns %08x\n", r
);
1782 /* Last Child Checks */
1783 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
1784 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
1786 nodeChild
= (IXMLDOMNode
*)0x1;
1787 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
1788 ok(r
== S_FALSE
, "ret %08x\n", r
);
1789 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
1792 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1793 ok(r
== S_OK
, "ret %08x\n", r
);
1794 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1799 r
= IXMLDOMProcessingInstruction_get_baseName(nodePI
, &str
);
1800 ok(r
== S_OK
, "ret %08x\n", r
);
1801 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1805 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
1806 ok(r
== S_OK
, "ret %08x\n", r
);
1807 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
1811 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
1812 ok(r
== S_OK
, "ret %08x\n", r
);
1813 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
1817 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
1818 ok(r
== E_FAIL
, "ret %08x\n", r
);
1821 V_VT(&var
) = VT_BSTR
;
1822 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
1823 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
1824 ok(r
== E_FAIL
, "ret %08x\n", r
);
1827 /* test get nodeName */
1828 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
1829 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
1830 ok(r
== S_OK
, "ret %08x\n", r
);
1833 IXMLDOMProcessingInstruction_Release(nodePI
);
1836 ref
= IXMLDOMDocument_Release( doc
);
1837 ok( ref
== 0, "got %d\n", ref
);
1842 static void test_persiststreaminit(void)
1844 IXMLDOMDocument
*doc
;
1845 IPersistStreamInit
*streaminit
;
1846 ULARGE_INTEGER size
;
1849 doc
= create_document(&IID_IXMLDOMDocument
);
1851 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&streaminit
);
1852 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1854 hr
= IPersistStreamInit_InitNew(streaminit
);
1855 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1857 hr
= IPersistStreamInit_GetSizeMax(streaminit
, &size
);
1858 ok(hr
== E_NOTIMPL
, "got 0x%08x\n", hr
);
1860 IXMLDOMDocument_Release(doc
);
1863 static void test_domnode( void )
1866 IXMLDOMDocument
*doc
, *owner
= NULL
;
1867 IXMLDOMElement
*element
= NULL
;
1868 IXMLDOMNamedNodeMap
*map
= NULL
;
1869 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
1870 IXMLDOMNodeList
*list
= NULL
;
1871 IXMLDOMAttribute
*attr
= NULL
;
1872 DOMNodeType type
= NODE_INVALID
;
1878 doc
= create_document(&IID_IXMLDOMDocument
);
1881 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
1882 ok( r
== S_OK
, "loadXML failed\n");
1883 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
1885 EXPECT_CHILDREN(doc
);
1887 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
1888 ok( r
== S_OK
, "should be a document element\n");
1889 ok( element
!= NULL
, "should be an element\n");
1892 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
1894 r
= IXMLDOMDocument_get_nodeValue( doc
, NULL
);
1895 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
1897 r
= IXMLDOMDocument_get_nodeValue( doc
, &var
);
1898 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
1899 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
1900 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
1905 r
= IXMLDOMElement_get_ownerDocument( element
, &owner
);
1906 ok( r
== S_OK
, "get_ownerDocument return code\n");
1907 ok( owner
!= doc
, "get_ownerDocument return\n");
1908 IXMLDOMDocument_Release(owner
);
1910 type
= NODE_INVALID
;
1911 r
= IXMLDOMElement_get_nodeType( element
, &type
);
1912 ok( r
== S_OK
, "got %08x\n", r
);
1913 ok( type
== NODE_ELEMENT
, "node not an element\n");
1916 r
= IXMLDOMElement_get_baseName( element
, &str
);
1917 ok( r
== S_OK
, "get_baseName returned wrong code\n");
1918 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
1921 /* check if nodename is correct */
1922 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
1923 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
1925 /* content doesn't matter here */
1927 r
= IXMLDOMElement_get_nodeName( element
, &str
);
1928 ok ( r
== S_OK
, "get_nodeName wrong code\n");
1929 ok ( str
!= NULL
, "str is null\n");
1930 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
1931 SysFreeString( str
);
1933 str
= SysAllocString( nonexistent_fileW
);
1935 V_I4(&var
) = 0x1234;
1936 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1937 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
1938 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
1942 str
= SysAllocString( szdl
);
1944 V_I4(&var
) = 0x1234;
1945 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
1946 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
1947 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
1948 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
1949 VariantClear( &var
);
1951 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
1952 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1954 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
1955 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
1958 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
1959 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
1960 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
1963 r
= IXMLDOMAttribute_get_parentNode( attr
, NULL
);
1964 ok( r
== E_INVALIDARG
, "Expected E_INVALIDARG, ret %08x\n", r
);
1966 /* attribute doesn't have a parent in msxml interpretation */
1967 node
= (IXMLDOMNode
*)0xdeadbeef;
1968 r
= IXMLDOMAttribute_get_parentNode( attr
, &node
);
1969 ok( r
== S_FALSE
, "Expected S_FALSE, ret %08x\n", r
);
1970 ok( node
== NULL
, "Expected NULL, got %p\n", node
);
1972 IXMLDOMAttribute_Release(attr
);
1975 SysFreeString( str
);
1977 r
= IXMLDOMElement_get_attributes( element
, &map
);
1978 ok( r
== S_OK
, "get_attributes returned wrong code\n");
1979 ok( map
!= NULL
, "should be attributes\n");
1981 EXPECT_CHILDREN(element
);
1984 ok( FALSE
, "no element\n");
1988 str
= SysAllocString( szdl
);
1989 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
1990 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
1991 ok( node
!= NULL
, "should be attributes\n");
1992 IXMLDOMNode_Release(node
);
1993 SysFreeString( str
);
1995 str
= SysAllocString( szdl
);
1996 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
1997 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
1998 SysFreeString( str
);
2000 /* something that isn't in complete4A */
2001 str
= SysAllocString( szOpen
);
2002 node
= (IXMLDOMNode
*) 1;
2003 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
2004 ok( r
== S_FALSE
, "getNamedItem found a node that wasn't there\n");
2005 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
2006 SysFreeString( str
);
2008 /* test indexed access of attributes */
2009 r
= IXMLDOMNamedNodeMap_get_length( map
, NULL
);
2010 ok ( r
== E_INVALIDARG
, "get_length should return E_INVALIDARG\n");
2012 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
2013 ok ( r
== S_OK
, "get_length wrong code\n");
2014 ok ( count
== 1, "get_length != 1\n");
2017 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
2018 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
2019 ok ( node
== NULL
, "there is no node\n");
2022 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
2023 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
2024 ok ( node
== NULL
, "there is no attribute\n");
2027 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
2028 ok ( r
== S_OK
, "get_item (0) wrong code\n");
2029 ok ( node
!= NULL
, "should be attribute\n");
2031 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
2032 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
2034 /* content doesn't matter here */
2036 r
= IXMLDOMNode_get_nodeName( node
, &str
);
2037 ok ( r
== S_OK
, "get_nodeName wrong code\n");
2038 ok ( str
!= NULL
, "str is null\n");
2039 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
2040 SysFreeString( str
);
2041 IXMLDOMNode_Release( node
);
2043 /* test sequential access of attributes */
2045 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2046 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
2047 ok ( node
!= NULL
, "nextNode, should be attribute\n");
2048 IXMLDOMNode_Release( node
);
2050 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2051 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
2052 ok ( node
== NULL
, "nextNode, there is no attribute\n");
2054 r
= IXMLDOMNamedNodeMap_reset( map
);
2055 ok ( r
== S_OK
, "reset should return S_OK\n");
2057 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2058 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
2059 ok ( node
!= NULL
, "nextNode, should be attribute\n");
2062 ok( FALSE
, "no map\n");
2066 type
= NODE_INVALID
;
2067 r
= IXMLDOMNode_get_nodeType( node
, &type
);
2068 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2069 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
2072 r
= IXMLDOMNode_get_baseName( node
, NULL
);
2073 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
2076 r
= IXMLDOMNode_get_baseName( node
, &str
);
2077 ok( r
== S_OK
, "get_baseName returned wrong code\n");
2078 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
2079 SysFreeString( str
);
2081 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
2082 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
2084 r
= IXMLDOMNode_get_childNodes( node
, &list
);
2085 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
2089 r
= IXMLDOMNodeList_nextNode( list
, &next
);
2090 ok( r
== S_OK
, "nextNode returned wrong code\n");
2093 ok( FALSE
, "no childlist\n");
2097 EXPECT_NO_CHILDREN(next
);
2099 type
= NODE_INVALID
;
2100 r
= IXMLDOMNode_get_nodeType( next
, &type
);
2101 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2102 ok( type
== NODE_TEXT
, "node not text\n");
2105 r
= IXMLDOMNode_get_baseName( next
, &str
);
2106 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
2107 ok( str
== NULL
, "basename was wrong\n");
2111 ok( FALSE
, "no next\n");
2114 IXMLDOMNode_Release( next
);
2117 IXMLDOMNodeList_Release( list
);
2120 IXMLDOMNode_Release( node
);
2123 ok( FALSE
, "no node\n");
2127 IXMLDOMNamedNodeMap_Release( map
);
2129 /* now traverse the tree from the root element */
2132 r
= IXMLDOMElement_get_childNodes( element
, &list
);
2133 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
2135 /* using get_item for child list doesn't advance the position */
2136 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
2137 expect_node(node
, "E2.E2.D1");
2138 IXMLDOMNode_Release(node
);
2139 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
2140 expect_node(node
, "E1.E2.D1");
2141 IXMLDOMNode_Release(node
);
2142 ole_check(IXMLDOMNodeList_reset(list
));
2144 IXMLDOMNodeList_AddRef(list
);
2145 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
2146 ole_check(IXMLDOMNodeList_reset(list
));
2148 node
= (void*)0xdeadbeef;
2149 str
= SysAllocString(szdl
);
2150 r
= IXMLDOMElement_selectSingleNode( element
, str
, &node
);
2152 ok( r
== S_FALSE
, "ret %08x\n", r
);
2153 ok( node
== NULL
, "node %p\n", node
);
2155 str
= SysAllocString(szbs
);
2156 r
= IXMLDOMElement_selectSingleNode( element
, str
, &node
);
2158 ok( r
== S_OK
, "ret %08x\n", r
);
2159 r
= IXMLDOMNode_Release( node
);
2160 ok( r
== 0, "ret %08x\n", r
);
2163 ok( FALSE
, "no element\n");
2167 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
2168 ok(r
== E_INVALIDARG
, "Expected E_INVALIDARG got %08x\n", r
);
2170 r
= IXMLDOMNodeList_get_length(list
, NULL
);
2171 ok(r
== E_INVALIDARG
, "Expected E_INVALIDARG got %08x\n", r
);
2173 r
= IXMLDOMNodeList_get_length( list
, &count
);
2174 ok( r
== S_OK
, "get_length returns %08x\n", r
);
2175 ok( count
== 4, "get_length got %d\n", count
);
2177 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
2178 ok(r
== E_INVALIDARG
, "Expected E_INVALIDARG got %08x\n", r
);
2180 r
= IXMLDOMNodeList_nextNode( list
, &node
);
2181 ok( r
== S_OK
, "nextNode returned wrong code\n");
2184 ok( FALSE
, "no list\n");
2188 type
= NODE_INVALID
;
2189 r
= IXMLDOMNode_get_nodeType( node
, &type
);
2190 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2191 ok( type
== NODE_ELEMENT
, "node not text\n");
2193 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
2194 ok( r
== E_INVALIDARG
, "hasChildNodes bad return\n");
2196 EXPECT_CHILDREN(node
);
2199 r
= IXMLDOMNode_get_baseName( node
, &str
);
2200 ok( r
== S_OK
, "get_baseName returned wrong code\n");
2201 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
2205 ok( FALSE
, "no node\n");
2208 IXMLDOMNode_Release( node
);
2210 IXMLDOMNodeList_Release( list
);
2212 IXMLDOMElement_Release( element
);
2215 str
= SysAllocString( szComplete5
);
2216 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2217 ok( r
== S_OK
, "loadXML failed\n");
2218 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2219 SysFreeString( str
);
2221 EXPECT_CHILDREN(doc
);
2223 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2224 ok( r
== S_OK
, "should be a document element\n");
2225 ok( element
!= NULL
, "should be an element\n");
2229 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
2232 /* check if the tag is correct */
2233 r
= IXMLDOMElement_get_tagName( element
, &tag
);
2234 ok( r
== S_OK
, "couldn't get tag name\n");
2235 ok( tag
!= NULL
, "tag was null\n");
2236 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
2237 SysFreeString( tag
);
2239 IXMLDOMElement_Release( element
);
2241 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
2251 static const refcount_test_t refcount_test
[] = {
2252 { NODE_ELEMENT
, &IID_IXMLDOMElement
},
2253 { NODE_ATTRIBUTE
, &IID_IXMLDOMAttribute
},
2254 { NODE_TEXT
, &IID_IXMLDOMText
},
2255 { NODE_CDATA_SECTION
, &IID_IXMLDOMCDATASection
},
2256 { NODE_ENTITY_REFERENCE
, &IID_IXMLDOMEntityReference
},
2257 { NODE_PROCESSING_INSTRUCTION
, &IID_IXMLDOMProcessingInstruction
},
2258 { NODE_COMMENT
, &IID_IXMLDOMComment
},
2259 { NODE_DOCUMENT_FRAGMENT
, &IID_IXMLDOMDocumentFragment
},
2260 { NODE_INVALID
, &IID_NULL
}
2263 static void test_refs(void)
2265 IXMLDOMImplementation
*impl
, *impl2
;
2266 IXMLDOMElement
*element
, *elem2
;
2267 IXMLDOMNodeList
*node_list
= NULL
;
2268 IXMLDOMNode
*node
, *node2
, *node3
;
2269 const refcount_test_t
*ptr
;
2270 IXMLDOMDocument
*doc
;
2271 IUnknown
*unk
, *unk2
;
2276 doc
= create_document(&IID_IXMLDOMDocument
);
2278 ptr
= refcount_test
;
2279 while (ptr
->type
!= NODE_INVALID
)
2281 IUnknown
*node_typed
, *node_typed2
;
2282 IDispatchEx
*dispex
, *dispex2
;
2283 IDispatch
*disp
, *disp2
;
2286 V_VT(&type
) = VT_I1
;
2287 V_I1(&type
) = ptr
->type
;
2290 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("name"), NULL
, &node
);
2291 EXPECT_HR(hr
, S_OK
);
2293 EXPECT_REF(node
, 1);
2295 /* try IDispatch and IUnknown from IXMLDOMNode */
2296 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IUnknown
, (void**)&unk
);
2297 EXPECT_HR(hr
, S_OK
);
2300 EXPECT_REF(node
, 1);
2301 ok(unk
!= (IUnknown
*)node
, "%d: got %p and %p\n", ptr
->type
, unk
, node
);
2304 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
2305 EXPECT_HR(hr
, S_OK
);
2306 todo_wine
ok(unk
!= (IUnknown
*)disp
, "%d: got %p and %p\n", ptr
->type
, unk
, disp
);
2308 todo_wine
EXPECT_REF(disp
, 1);
2311 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp2
);
2312 EXPECT_HR(hr
, S_OK
);
2313 todo_wine
ok(disp
!= disp2
, "%d: got %p and %p\n", ptr
->type
, disp
, disp2
);
2315 todo_wine
EXPECT_REF(disp2
, 1);
2317 IDispatch_Release(disp
);
2318 IDispatch_Release(disp2
);
2320 /* get IXMLDOMNode from this IUnknown */
2322 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMNode
, (void**)&node2
);
2323 EXPECT_HR(hr
, S_OK
);
2324 todo_wine
ok(unk
!= (IUnknown
*)node2
, "%d: got %p and %p\n", ptr
->type
, unk
, node2
);
2326 todo_wine
EXPECT_REF(node2
, 1);
2329 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMNode
, (void**)&node3
);
2330 EXPECT_HR(hr
, S_OK
);
2331 todo_wine
ok(node2
!= node3
, "%d: got %p and %p\n", ptr
->type
, node2
, node3
);
2333 todo_wine
EXPECT_REF(node3
, 1);
2335 IXMLDOMNode_Release(node2
);
2336 IXMLDOMNode_Release(node3
);
2338 /* try IDispatchEx from IUnknown */
2340 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
2341 EXPECT_HR(hr
, S_OK
);
2342 ok(unk
!= (IUnknown
*)dispex
, "%d: got %p and %p\n", ptr
->type
, unk
, dispex
);
2344 todo_wine
EXPECT_REF(dispex
, 1);
2347 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex2
);
2348 EXPECT_HR(hr
, S_OK
);
2349 todo_wine
ok(dispex
!= dispex2
, "%d: got %p and %p\n", ptr
->type
, dispex
, dispex2
);
2351 todo_wine
EXPECT_REF(dispex2
, 1);
2353 IDispatchEx_Release(dispex
);
2354 IDispatchEx_Release(dispex2
);
2356 /* try corresponding IXMLDOM* */
2358 hr
= IUnknown_QueryInterface(unk
, ptr
->iid
, (void**)&node_typed
);
2359 EXPECT_HR(hr
, S_OK
);
2361 hr
= IUnknown_QueryInterface(unk
, ptr
->iid
, (void**)&node_typed2
);
2362 EXPECT_HR(hr
, S_OK
);
2364 todo_wine
ok(node_typed
!= node_typed2
, "%d: got %p and %p\n", ptr
->type
, node_typed
, node_typed2
);
2365 IUnknown_Release(node_typed
);
2366 IUnknown_Release(node_typed2
);
2368 /* try invalid IXMLDOM* */
2369 hr
= IUnknown_QueryInterface(unk
, (ptr
+1)->iid
, (void**)&node_typed
);
2370 EXPECT_HR(hr
, E_NOINTERFACE
);
2372 IUnknown_Release(unk
);
2374 EXPECT_REF(node
, 1);
2375 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMNode
, (void**)&node2
);
2376 EXPECT_HR(hr
, S_OK
);
2377 EXPECT_REF(node
, 2);
2378 ok(node
== node2
, "%d: got %p and %p\n", ptr
->type
, node
, node2
);
2380 EXPECT_REF(node
, 2);
2381 hr
= IXMLDOMNode_QueryInterface(node
, ptr
->iid
, (void**)&node_typed
);
2382 EXPECT_HR(hr
, S_OK
);
2383 EXPECT_REF(node
, 3);
2385 EXPECT_REF(node_typed
, 2);
2386 ok((IUnknown
*)node
!= node_typed
, "%d: got %p and %p\n", ptr
->type
, node
, node_typed
);
2388 IUnknown_Release(node_typed
);
2390 IXMLDOMNode_Release(node2
);
2391 IXMLDOMNode_Release(node
);
2397 ref
= IXMLDOMDocument_Release(doc
);
2398 ok( ref
== 0, "ref %d\n", ref
);
2400 /* check IUnknown after releasing DOM iface */
2401 doc
= create_document(&IID_IXMLDOMDocument
);
2403 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
2404 EXPECT_HR(hr
, S_OK
);
2409 IXMLDOMDocument_Release(doc
);
2411 IUnknown_Release(unk
);
2413 doc
= create_document(&IID_IXMLDOMDocument
);
2416 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
2417 EXPECT_HR(hr
, S_OK
);
2422 IUnknown_Release(unk
);
2424 /* IXMLDOMImplementation */
2426 hr
= IXMLDOMDocument_get_implementation(doc
, &impl
);
2427 EXPECT_HR(hr
, S_OK
);
2429 EXPECT_REF(impl
, 1);
2430 hr
= IXMLDOMDocument_get_implementation(doc
, &impl2
);
2431 EXPECT_HR(hr
, S_OK
);
2433 EXPECT_REF(impl2
, 1);
2434 ok(impl
!= impl2
, "got %p, %p\n", impl
, impl2
);
2435 IXMLDOMImplementation_Release(impl
);
2436 IXMLDOMImplementation_Release(impl2
);
2438 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
2439 EXPECT_HR(hr
, S_OK
);
2440 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2443 IXMLDOMDocument_AddRef( doc
);
2445 IXMLDOMDocument_AddRef( doc
);
2448 IXMLDOMDocument_Release( doc
);
2449 IXMLDOMDocument_Release( doc
);
2452 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
2453 EXPECT_HR(hr
, S_OK
);
2458 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
2459 EXPECT_HR(hr
, S_OK
);
2462 EXPECT_REF(element
, 2);
2464 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem2
);
2465 EXPECT_HR(hr
, S_OK
);
2469 EXPECT_REF(element
, 2);
2470 EXPECT_REF(elem2
, 2);
2472 IXMLDOMElement_AddRef(element
);
2473 todo_wine
EXPECT_REF(element
, 3);
2474 IXMLDOMElement_Release(element
);
2476 /* get IUnknown from a node doesn't touch node instance refcount */
2477 hr
= IXMLDOMElement_QueryInterface(element
, &IID_IUnknown
, (void**)&unk
);
2478 EXPECT_HR(hr
, S_OK
);
2479 EXPECT_REF(element
, 2);
2482 EXPECT_REF(elem2
, 2);
2484 hr
= IXMLDOMElement_QueryInterface(elem2
, &IID_IUnknown
, (void**)&unk2
);
2485 EXPECT_HR(hr
, S_OK
);
2488 EXPECT_REF(unk2
, 5);
2490 EXPECT_REF(element
, 2);
2491 EXPECT_REF(elem2
, 2);
2493 todo_wine
ok(unk
== unk2
, "got %p and %p\n", unk
, unk2
);
2494 IUnknown_Release(unk
);
2496 /* IUnknown refcount is not affected by node refcount */
2497 todo_wine
EXPECT_REF(unk2
, 4);
2498 IXMLDOMElement_AddRef(elem2
);
2499 todo_wine
EXPECT_REF(unk2
, 4);
2500 IXMLDOMElement_Release(elem2
);
2502 IXMLDOMElement_Release(elem2
);
2503 todo_wine
EXPECT_REF(unk2
, 3);
2505 IUnknown_Release(unk2
);
2507 hr
= IXMLDOMElement_get_childNodes( element
, &node_list
);
2508 EXPECT_HR(hr
, S_OK
);
2510 todo_wine
EXPECT_REF(element
, 2);
2511 EXPECT_REF(node_list
, 1);
2513 hr
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
2514 EXPECT_HR(hr
, S_OK
);
2515 EXPECT_REF(node_list
, 1);
2516 EXPECT_REF(node
, 1);
2518 hr
= IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
2519 EXPECT_HR(hr
, S_OK
);
2520 EXPECT_REF(node_list
, 1);
2521 EXPECT_REF(node2
, 1);
2523 ref
= IXMLDOMNode_Release( node
);
2524 ok( ref
== 0, "ref %d\n", ref
);
2525 ref
= IXMLDOMNode_Release( node2
);
2526 ok( ref
== 0, "ref %d\n", ref
);
2528 ref
= IXMLDOMNodeList_Release( node_list
);
2529 ok( ref
== 0, "ref %d\n", ref
);
2531 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
2533 ref
= IXMLDOMDocument_Release( doc
);
2534 todo_wine
ok( ref
== 0, "ref %d\n", ref
);
2536 todo_wine
EXPECT_REF(element
, 2);
2538 /* IUnknown must be unique however we obtain it */
2539 hr
= IXMLDOMElement_QueryInterface(element
, &IID_IUnknown
, (void**)&unk
);
2540 EXPECT_HR(hr
, S_OK
);
2541 EXPECT_REF(element
, 2);
2542 hr
= IXMLDOMElement_QueryInterface(element
, &IID_IXMLDOMNode
, (void**)&node
);
2543 EXPECT_HR(hr
, S_OK
);
2544 todo_wine
EXPECT_REF(element
, 2);
2545 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IUnknown
, (void**)&unk2
);
2546 EXPECT_HR(hr
, S_OK
);
2547 todo_wine
EXPECT_REF(element
, 2);
2548 ok(unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
2549 todo_wine
ok(element
!= (void*)node
, "node %p element %p\n", node
, element
);
2551 IUnknown_Release( unk2
);
2552 IUnknown_Release( unk
);
2553 IXMLDOMNode_Release( node
);
2554 todo_wine
EXPECT_REF(element
, 2);
2556 IXMLDOMElement_Release( element
);
2561 static void test_create(void)
2563 static const WCHAR szOne
[] = {'1',0};
2564 static const WCHAR szOneGarbage
[] = {'1','G','a','r','b','a','g','e',0};
2568 IXMLDOMDocument
*doc
;
2569 IXMLDOMElement
*element
;
2570 IXMLDOMComment
*comment
;
2572 IXMLDOMCDATASection
*cdata
;
2573 IXMLDOMNode
*root
, *node
, *child
;
2574 IXMLDOMNamedNodeMap
*attr_map
;
2579 doc
= create_document(&IID_IXMLDOMDocument
);
2583 /* types not supported for creation */
2585 V_I1(&var
) = NODE_DOCUMENT
;
2586 node
= (IXMLDOMNode
*)0x1;
2587 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2588 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2589 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2592 V_I1(&var
) = NODE_DOCUMENT_TYPE
;
2593 node
= (IXMLDOMNode
*)0x1;
2594 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2595 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2596 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2599 V_I1(&var
) = NODE_ENTITY
;
2600 node
= (IXMLDOMNode
*)0x1;
2601 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2602 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2603 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2606 V_I1(&var
) = NODE_NOTATION
;
2607 node
= (IXMLDOMNode
*)0x1;
2608 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2609 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2610 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2614 V_I1(&var
) = NODE_COMMENT
;
2616 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2617 ok( r
== S_OK
, "returns %08x\n", r
);
2618 ok( node
!= NULL
, "\n");
2620 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
2621 ok( r
== S_OK
, "returns %08x\n", r
);
2622 IXMLDOMNode_Release(node
);
2625 r
= IXMLDOMComment_get_data(comment
, &str
);
2626 ok( r
== S_OK
, "returns %08x\n", r
);
2627 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2628 IXMLDOMComment_Release(comment
);
2631 node
= (IXMLDOMNode
*)0x1;
2632 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2633 ok( r
== S_OK
, "returns %08x\n", r
);
2635 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
2636 ok( r
== S_OK
, "returns %08x\n", r
);
2637 IXMLDOMNode_Release(node
);
2640 r
= IXMLDOMComment_get_data(comment
, &str
);
2641 ok( r
== S_OK
, "returns %08x\n", r
);
2642 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2643 IXMLDOMComment_Release(comment
);
2646 node
= (IXMLDOMNode
*)0x1;
2647 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
2648 ok( r
== S_OK
, "returns %08x\n", r
);
2650 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
2651 ok( r
== S_OK
, "returns %08x\n", r
);
2652 IXMLDOMNode_Release(node
);
2655 r
= IXMLDOMComment_get_data(comment
, &str
);
2656 ok( r
== S_OK
, "returns %08x\n", r
);
2657 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2658 IXMLDOMComment_Release(comment
);
2663 V_I1(&var
) = NODE_TEXT
;
2665 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2666 ok( r
== S_OK
, "returns %08x\n", r
);
2667 ok( node
!= NULL
, "\n");
2669 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
2670 ok( r
== S_OK
, "returns %08x\n", r
);
2671 IXMLDOMNode_Release(node
);
2674 r
= IXMLDOMText_get_data(text
, &str
);
2675 ok( r
== S_OK
, "returns %08x\n", r
);
2676 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2677 IXMLDOMText_Release(text
);
2680 node
= (IXMLDOMNode
*)0x1;
2681 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2682 ok( r
== S_OK
, "returns %08x\n", r
);
2684 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
2685 ok( r
== S_OK
, "returns %08x\n", r
);
2686 IXMLDOMNode_Release(node
);
2689 r
= IXMLDOMText_get_data(text
, &str
);
2690 ok( r
== S_OK
, "returns %08x\n", r
);
2691 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2692 IXMLDOMText_Release(text
);
2695 node
= (IXMLDOMNode
*)0x1;
2696 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
2697 ok( r
== S_OK
, "returns %08x\n", r
);
2699 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
2700 ok( r
== S_OK
, "returns %08x\n", r
);
2701 IXMLDOMNode_Release(node
);
2704 r
= IXMLDOMText_get_data(text
, &str
);
2705 ok( r
== S_OK
, "returns %08x\n", r
);
2706 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2707 IXMLDOMText_Release(text
);
2710 /* NODE_CDATA_SECTION */
2712 V_I1(&var
) = NODE_CDATA_SECTION
;
2714 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2715 ok( r
== S_OK
, "returns %08x\n", r
);
2716 ok( node
!= NULL
, "\n");
2718 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
2719 ok( r
== S_OK
, "returns %08x\n", r
);
2720 IXMLDOMNode_Release(node
);
2723 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
2724 ok( r
== S_OK
, "returns %08x\n", r
);
2725 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2726 IXMLDOMCDATASection_Release(cdata
);
2729 node
= (IXMLDOMNode
*)0x1;
2730 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2731 ok( r
== S_OK
, "returns %08x\n", r
);
2733 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
2734 ok( r
== S_OK
, "returns %08x\n", r
);
2735 IXMLDOMNode_Release(node
);
2738 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
2739 ok( r
== S_OK
, "returns %08x\n", r
);
2740 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2741 IXMLDOMCDATASection_Release(cdata
);
2744 node
= (IXMLDOMNode
*)0x1;
2745 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
2746 ok( r
== S_OK
, "returns %08x\n", r
);
2748 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
2749 ok( r
== S_OK
, "returns %08x\n", r
);
2750 IXMLDOMNode_Release(node
);
2753 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
2754 ok( r
== S_OK
, "returns %08x\n", r
);
2755 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
2756 IXMLDOMCDATASection_Release(cdata
);
2759 /* NODE_ATTRIBUTE */
2761 V_I1(&var
) = NODE_ATTRIBUTE
;
2762 node
= (IXMLDOMNode
*)0x1;
2763 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2764 ok( r
== E_FAIL
, "returns %08x\n", r
);
2765 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2768 V_I1(&var
) = NODE_ATTRIBUTE
;
2769 node
= (IXMLDOMNode
*)0x1;
2770 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2771 ok( r
== E_FAIL
, "returns %08x\n", r
);
2772 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2775 V_I1(&var
) = NODE_ATTRIBUTE
;
2776 str
= SysAllocString( szlc
);
2777 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2778 ok( r
== S_OK
, "returns %08x\n", r
);
2779 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2782 /* a name is required for attribute, try a BSTR with first null wchar */
2784 V_I1(&var
) = NODE_ATTRIBUTE
;
2785 str
= SysAllocString( szstr1
);
2787 node
= (IXMLDOMNode
*)0x1;
2788 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2789 ok( r
== E_FAIL
, "returns %08x\n", r
);
2790 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2793 /* NODE_PROCESSING_INSTRUCTION */
2795 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2796 node
= (IXMLDOMNode
*)0x1;
2797 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2798 ok( r
== E_FAIL
, "returns %08x\n", r
);
2799 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2802 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2803 node
= (IXMLDOMNode
*)0x1;
2804 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2805 ok( r
== E_FAIL
, "returns %08x\n", r
);
2806 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2809 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
2810 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("pi"), NULL
, NULL
);
2811 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2813 /* NODE_ENTITY_REFERENCE */
2815 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2816 node
= (IXMLDOMNode
*)0x1;
2817 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2818 ok( r
== E_FAIL
, "returns %08x\n", r
);
2819 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2822 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
2823 node
= (IXMLDOMNode
*)0x1;
2824 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2825 ok( r
== E_FAIL
, "returns %08x\n", r
);
2826 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2830 V_I1(&var
) = NODE_ELEMENT
;
2831 node
= (IXMLDOMNode
*)0x1;
2832 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
2833 ok( r
== E_FAIL
, "returns %08x\n", r
);
2834 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2837 V_I1(&var
) = NODE_ELEMENT
;
2838 node
= (IXMLDOMNode
*)0x1;
2839 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
2840 ok( r
== E_FAIL
, "returns %08x\n", r
);
2841 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
2844 V_I1(&var
) = NODE_ELEMENT
;
2845 str
= SysAllocString( szlc
);
2846 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2847 ok( r
== S_OK
, "returns %08x\n", r
);
2848 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2851 V_I1(&var
) = NODE_ELEMENT
;
2852 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, NULL
);
2853 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2856 V_R4(&var
) = NODE_ELEMENT
;
2857 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2858 ok( r
== S_OK
, "returns %08x\n", r
);
2859 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2861 V_VT(&var
) = VT_BSTR
;
2862 V_BSTR(&var
) = SysAllocString( szOne
);
2863 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2864 ok( r
== S_OK
, "returns %08x\n", r
);
2865 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2868 V_VT(&var
) = VT_BSTR
;
2869 V_BSTR(&var
) = SysAllocString( szOneGarbage
);
2870 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2871 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2872 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
2876 V_I4(&var
) = NODE_ELEMENT
;
2877 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2878 ok( r
== S_OK
, "returns %08x\n", r
);
2881 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
2882 ok( r
== S_OK
, "returns %08x\n", r
);
2883 ok( node
== root
, "%p %p\n", node
, root
);
2886 EXPECT_REF(node
, 2);
2888 ref
= IXMLDOMNode_Release( node
);
2889 ok(ref
== 1, "ref %d\n", ref
);
2890 SysFreeString( str
);
2893 V_I4(&var
) = NODE_ELEMENT
;
2894 str
= SysAllocString( szbs
);
2895 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
2896 ok( r
== S_OK
, "returns %08x\n", r
);
2897 SysFreeString( str
);
2899 EXPECT_REF(node
, 1);
2901 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (void**)&unk
);
2902 ok( r
== S_OK
, "returns %08x\n", r
);
2906 V_VT(&var
) = VT_EMPTY
;
2908 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
2909 ok( r
== S_OK
, "returns %08x\n", r
);
2910 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
2912 todo_wine
EXPECT_REF(unk
, 4);
2914 IXMLDOMNode_Release( child
);
2915 IUnknown_Release( unk
);
2917 V_VT(&var
) = VT_NULL
;
2918 V_DISPATCH(&var
) = (IDispatch
*)node
;
2919 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
2920 ok( r
== S_OK
, "returns %08x\n", r
);
2921 ok( node
== child
, "%p %p\n", node
, child
);
2922 IXMLDOMNode_Release( child
);
2924 V_VT(&var
) = VT_NULL
;
2925 V_DISPATCH(&var
) = (IDispatch
*)node
;
2926 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
2927 ok( r
== S_OK
, "returns %08x\n", r
);
2928 IXMLDOMNode_Release( node
);
2930 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (void**)&element
);
2931 ok( r
== S_OK
, "returns %08x\n", r
);
2933 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2934 ok( r
== S_OK
, "returns %08x\n", r
);
2935 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2936 ok( r
== S_OK
, "returns %08x\n", r
);
2937 ok( num
== 0, "num %d\n", num
);
2938 IXMLDOMNamedNodeMap_Release( attr_map
);
2940 V_VT(&var
) = VT_BSTR
;
2941 V_BSTR(&var
) = SysAllocString( szstr1
);
2942 name
= SysAllocString( szdl
);
2943 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2944 ok( r
== S_OK
, "returns %08x\n", r
);
2945 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2946 ok( r
== S_OK
, "returns %08x\n", r
);
2947 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2948 ok( r
== S_OK
, "returns %08x\n", r
);
2949 ok( num
== 1, "num %d\n", num
);
2950 IXMLDOMNamedNodeMap_Release( attr_map
);
2953 V_VT(&var
) = VT_BSTR
;
2954 V_BSTR(&var
) = SysAllocString( szstr2
);
2955 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2956 ok( r
== S_OK
, "returns %08x\n", r
);
2957 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2958 ok( r
== S_OK
, "returns %08x\n", r
);
2959 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2960 ok( r
== S_OK
, "returns %08x\n", r
);
2961 ok( num
== 1, "num %d\n", num
);
2962 IXMLDOMNamedNodeMap_Release( attr_map
);
2964 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2965 ok( r
== S_OK
, "returns %08x\n", r
);
2966 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
2968 SysFreeString(name
);
2970 V_VT(&var
) = VT_BSTR
;
2971 V_BSTR(&var
) = SysAllocString( szstr1
);
2972 name
= SysAllocString( szlc
);
2973 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2974 ok( r
== S_OK
, "returns %08x\n", r
);
2975 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
2976 ok( r
== S_OK
, "returns %08x\n", r
);
2977 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
2978 ok( r
== S_OK
, "returns %08x\n", r
);
2979 ok( num
== 2, "num %d\n", num
);
2980 IXMLDOMNamedNodeMap_Release( attr_map
);
2982 SysFreeString(name
);
2986 name
= SysAllocString( szbs
);
2987 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
2988 ok( r
== S_OK
, "returns %08x\n", r
);
2990 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
2991 ok( r
== S_OK
, "returns %08x\n", r
);
2992 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
2994 SysFreeString(name
);
2996 /* Create an Attribute */
2998 V_I4(&var
) = NODE_ATTRIBUTE
;
2999 str
= SysAllocString( szAttribute
);
3000 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3001 ok( r
== S_OK
, "returns %08x\n", r
);
3002 ok( node
!= NULL
, "node was null\n");
3005 IXMLDOMElement_Release( element
);
3006 IXMLDOMNode_Release( root
);
3007 IXMLDOMDocument_Release( doc
);
3010 struct queryresult_t
{
3016 static const struct queryresult_t elementsbytagname
[] = {
3017 { "", "P1.D1 E2.D1 E1.E2.D1 T1.E1.E2.D1 E2.E2.D1 T1.E2.E2.D1 E3.E2.D1 E4.E2.D1 E1.E4.E2.D1 T1.E1.E4.E2.D1", 10 },
3018 { "*", "E2.D1 E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1 E1.E4.E2.D1", 6 },
3019 { "bs", "E1.E2.D1", 1 },
3025 static void test_getElementsByTagName(void)
3027 const struct queryresult_t
*ptr
= elementsbytagname
;
3028 IXMLDOMNodeList
*node_list
;
3029 IXMLDOMDocument
*doc
;
3030 IXMLDOMElement
*elem
;
3037 doc
= create_document(&IID_IXMLDOMDocument
);
3039 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3040 ok( r
== S_OK
, "loadXML failed\n");
3041 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3043 /* null arguments cases */
3044 r
= IXMLDOMDocument_getElementsByTagName(doc
, NULL
, &node_list
);
3045 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3046 r
= IXMLDOMDocument_getElementsByTagName(doc
, _bstr_("*"), NULL
);
3047 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3051 r
= IXMLDOMDocument_getElementsByTagName(doc
, _bstr_(ptr
->query
), &node_list
);
3052 ok(r
== S_OK
, "ret %08x\n", r
);
3053 r
= IXMLDOMNodeList_get_length(node_list
, &len
);
3054 ok(r
== S_OK
, "ret %08x\n", r
);
3055 ok(len
== ptr
->len
, "%s: got len %d, expected %d\n", ptr
->query
, len
, ptr
->len
);
3056 expect_list_and_release(node_list
, ptr
->result
);
3062 /* broken query BSTR */
3063 memcpy(&buff
[2], szstar
, sizeof(szstar
));
3064 /* just a big length */
3065 *(DWORD
*)buff
= 0xf0f0;
3066 r
= IXMLDOMDocument_getElementsByTagName(doc
, &buff
[2], &node_list
);
3067 ok( r
== S_OK
, "ret %08x\n", r
);
3068 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3069 ok( r
== S_OK
, "ret %08x\n", r
);
3070 ok( len
== 6, "len %d\n", len
);
3071 IXMLDOMNodeList_Release( node_list
);
3073 /* test for element */
3074 r
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
3075 ok( r
== S_OK
, "ret %08x\n", r
);
3077 str
= SysAllocString( szstar
);
3079 /* null arguments cases */
3080 r
= IXMLDOMElement_getElementsByTagName(elem
, NULL
, &node_list
);
3081 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3082 r
= IXMLDOMElement_getElementsByTagName(elem
, str
, NULL
);
3083 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3085 r
= IXMLDOMElement_getElementsByTagName(elem
, str
, &node_list
);
3086 ok( r
== S_OK
, "ret %08x\n", r
);
3087 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3088 ok( r
== S_OK
, "ret %08x\n", r
);
3089 ok( len
== 5, "len %d\n", len
);
3090 expect_list_and_release(node_list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1 E1.E4.E2.D1");
3091 SysFreeString( str
);
3093 /* broken query BSTR */
3094 memcpy(&buff
[2], szstar
, sizeof(szstar
));
3095 /* just a big length */
3096 *(DWORD
*)buff
= 0xf0f0;
3097 r
= IXMLDOMElement_getElementsByTagName(elem
, &buff
[2], &node_list
);
3098 ok( r
== S_OK
, "ret %08x\n", r
);
3099 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3100 ok( r
== S_OK
, "ret %08x\n", r
);
3101 ok( len
== 5, "len %d\n", len
);
3102 IXMLDOMNodeList_Release( node_list
);
3104 IXMLDOMElement_Release(elem
);
3106 IXMLDOMDocument_Release( doc
);
3111 static void test_get_text(void)
3116 IXMLDOMDocument
*doc
;
3117 IXMLDOMNode
*node
, *node2
, *node3
;
3118 IXMLDOMNode
*nodeRoot
;
3119 IXMLDOMNodeList
*node_list
;
3120 IXMLDOMNamedNodeMap
*node_map
;
3123 doc
= create_document(&IID_IXMLDOMDocument
);
3125 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3126 ok( r
== S_OK
, "loadXML failed\n");
3127 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3129 str
= SysAllocString( szbs
);
3130 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
3131 ok( r
== S_OK
, "ret %08x\n", r
);
3134 /* Test to get all child node text. */
3135 r
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&nodeRoot
);
3136 ok( r
== S_OK
, "ret %08x\n", r
);
3139 r
= IXMLDOMNode_get_text( nodeRoot
, &str
);
3140 ok( r
== S_OK
, "ret %08x\n", r
);
3141 ok( compareIgnoreReturns(str
, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text: %s\n", wine_dbgstr_w(str
));
3144 IXMLDOMNode_Release(nodeRoot
);
3147 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
3148 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3150 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3151 ok( r
== S_OK
, "ret %08x\n", r
);
3152 ok( len
== 1, "expect 1 got %d\n", len
);
3154 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
3155 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3157 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
3158 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3160 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
3161 ok( r
== S_OK
, "ret %08x\n", r
);
3162 IXMLDOMNodeList_Release( node_list
);
3164 /* Invalid output parameter*/
3165 r
= IXMLDOMNode_get_text( node
, NULL
);
3166 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3168 r
= IXMLDOMNode_get_text( node
, &str
);
3169 ok( r
== S_OK
, "ret %08x\n", r
);
3170 ok( !memcmp(str
, szfn1_txt
, lstrlenW(szfn1_txt
) ), "wrong string\n" );
3173 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
3174 ok( r
== S_OK
, "ret %08x\n", r
);
3176 str
= SysAllocString( szvr
);
3177 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
3178 ok( r
== S_OK
, "ret %08x\n", r
);
3181 r
= IXMLDOMNode_get_text( node2
, &str
);
3182 ok( r
== S_OK
, "ret %08x\n", r
);
3183 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
3186 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
3187 ok( r
== S_OK
, "ret %08x\n", r
);
3189 r
= IXMLDOMNode_get_text( node3
, &str
);
3190 ok( r
== S_OK
, "ret %08x\n", r
);
3191 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
3195 IXMLDOMNode_Release( node3
);
3196 IXMLDOMNode_Release( node2
);
3197 IXMLDOMNamedNodeMap_Release( node_map
);
3198 IXMLDOMNode_Release( node
);
3199 IXMLDOMDocument_Release( doc
);
3204 static void test_get_childNodes(void)
3206 IXMLDOMNodeList
*node_list
, *node_list2
;
3207 IEnumVARIANT
*enum1
, *enum2
, *enum3
;
3209 IXMLDOMDocument
*doc
;
3210 IXMLDOMNode
*node
, *node2
;
3211 IXMLDOMElement
*element
;
3212 IUnknown
*unk1
, *unk2
;
3218 doc
= create_document(&IID_IXMLDOMDocument
);
3220 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3221 EXPECT_HR(hr
, S_OK
);
3222 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3224 hr
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3225 EXPECT_HR(hr
, S_OK
);
3227 hr
= IXMLDOMElement_get_childNodes( element
, &node_list
);
3228 EXPECT_HR(hr
, S_OK
);
3230 hr
= IXMLDOMNodeList_get_length( node_list
, &len
);
3231 EXPECT_HR(hr
, S_OK
);
3232 ok( len
== 4, "len %d\n", len
);
3234 /* refcount tests for IEnumVARIANT support */
3235 EXPECT_REF(node_list
, 1);
3236 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IEnumVARIANT
, (void**)&enum1
);
3237 EXPECT_HR(hr
, S_OK
);
3238 EXPECT_REF(node_list
, 1);
3239 EXPECT_REF(enum1
, 2);
3241 EXPECT_REF(node_list
, 1);
3242 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IEnumVARIANT
, (void**)&enum2
);
3243 EXPECT_HR(hr
, S_OK
);
3244 EXPECT_REF(node_list
, 1);
3245 ok(enum2
== enum1
, "got %p, %p\n", enum2
, enum1
);
3246 IEnumVARIANT_Release(enum2
);
3248 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IUnknown
, (void**)&unk1
);
3249 EXPECT_HR(hr
, S_OK
);
3250 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IUnknown
, (void**)&unk2
);
3251 EXPECT_HR(hr
, S_OK
);
3252 EXPECT_REF(node_list
, 3);
3253 EXPECT_REF(enum1
, 2);
3254 ok(unk1
== unk2
, "got %p, %p\n", unk1
, unk2
);
3255 IUnknown_Release(unk1
);
3256 IUnknown_Release(unk2
);
3258 EXPECT_REF(node_list
, 1);
3259 hr
= IXMLDOMNodeList__newEnum(node_list
, (IUnknown
**)&enum2
);
3260 EXPECT_HR(hr
, S_OK
);
3261 EXPECT_REF(node_list
, 2);
3262 EXPECT_REF(enum2
, 1);
3263 ok(enum2
!= enum1
, "got %p, %p\n", enum2
, enum1
);
3265 /* enumerator created with _newEnum() doesn't share IUnknown* with main object */
3266 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IUnknown
, (void**)&unk1
);
3267 EXPECT_HR(hr
, S_OK
);
3268 hr
= IEnumVARIANT_QueryInterface(enum2
, &IID_IUnknown
, (void**)&unk2
);
3269 EXPECT_HR(hr
, S_OK
);
3270 EXPECT_REF(node_list
, 3);
3271 EXPECT_REF(enum2
, 2);
3272 ok(unk1
!= unk2
, "got %p, %p\n", unk1
, unk2
);
3273 IUnknown_Release(unk1
);
3274 IUnknown_Release(unk2
);
3276 hr
= IXMLDOMNodeList__newEnum(node_list
, (IUnknown
**)&enum3
);
3277 EXPECT_HR(hr
, S_OK
);
3278 ok(enum2
!= enum3
, "got %p, %p\n", enum2
, enum3
);
3279 IEnumVARIANT_Release(enum3
);
3280 IEnumVARIANT_Release(enum2
);
3282 /* iteration tests */
3283 hr
= IXMLDOMNodeList_get_item(node_list
, 0, &node
);
3284 EXPECT_HR(hr
, S_OK
);
3285 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
3286 EXPECT_HR(hr
, S_OK
);
3287 ok(!lstrcmpW(str
, _bstr_("bs")), "got %s\n", wine_dbgstr_w(str
));
3289 IXMLDOMNode_Release(node
);
3291 hr
= IXMLDOMNodeList_nextNode(node_list
, &node
);
3292 EXPECT_HR(hr
, S_OK
);
3293 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
3294 EXPECT_HR(hr
, S_OK
);
3295 ok(!lstrcmpW(str
, _bstr_("bs")), "got %s\n", wine_dbgstr_w(str
));
3297 IXMLDOMNode_Release(node
);
3299 V_VT(&v
) = VT_EMPTY
;
3300 hr
= IEnumVARIANT_Next(enum1
, 1, &v
, NULL
);
3301 EXPECT_HR(hr
, S_OK
);
3302 ok(V_VT(&v
) == VT_DISPATCH
, "got var type %d\n", V_VT(&v
));
3303 hr
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IXMLDOMNode
, (void**)&node
);
3304 EXPECT_HR(hr
, S_OK
);
3305 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
3306 EXPECT_HR(hr
, S_OK
);
3307 ok(!lstrcmpW(str
, _bstr_("bs")), "got node name %s\n", wine_dbgstr_w(str
));
3309 IXMLDOMNode_Release(node
);
3312 hr
= IXMLDOMNodeList_nextNode(node_list
, &node
);
3313 EXPECT_HR(hr
, S_OK
);
3314 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
3315 EXPECT_HR(hr
, S_OK
);
3316 ok(!lstrcmpW(str
, _bstr_("pr")), "got %s\n", wine_dbgstr_w(str
));
3318 IXMLDOMNode_Release(node
);
3320 IEnumVARIANT_Release(enum1
);
3322 hr
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
3323 EXPECT_HR(hr
, S_OK
);
3325 hr
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
3326 EXPECT_HR(hr
, S_OK
);
3328 hr
= IXMLDOMNodeList_get_length( node_list2
, &len
);
3329 EXPECT_HR(hr
, S_OK
);
3330 ok( len
== 0, "len %d\n", len
);
3332 hr
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
3333 EXPECT_HR(hr
, S_FALSE
);
3335 IXMLDOMNodeList_Release( node_list2
);
3336 IXMLDOMNode_Release( node
);
3337 IXMLDOMNodeList_Release( node_list
);
3338 IXMLDOMElement_Release( element
);
3340 /* test for children of <?xml ..?> node */
3341 hr
= IXMLDOMDocument_get_firstChild(doc
, &node
);
3342 EXPECT_HR(hr
, S_OK
);
3345 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
3346 EXPECT_HR(hr
, S_OK
);
3347 ok(!lstrcmpW(str
, _bstr_("xml")), "got %s\n", wine_dbgstr_w(str
));
3350 /* it returns empty but valid node list */
3351 node_list
= (void*)0xdeadbeef;
3352 hr
= IXMLDOMNode_get_childNodes(node
, &node_list
);
3353 EXPECT_HR(hr
, S_OK
);
3356 hr
= IXMLDOMNodeList_get_length(node_list
, &len
);
3357 EXPECT_HR(hr
, S_OK
);
3358 ok(len
== 0, "got %d\n", len
);
3360 IXMLDOMNodeList_Release( node_list
);
3361 IXMLDOMNode_Release(node
);
3363 IXMLDOMDocument_Release( doc
);
3367 static void test_get_firstChild(void)
3369 static const WCHAR xmlW
[] = {'x','m','l',0};
3370 IXMLDOMDocument
*doc
;
3376 doc
= create_document(&IID_IXMLDOMDocument
);
3378 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3379 ok( r
== S_OK
, "loadXML failed\n");
3380 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3382 r
= IXMLDOMDocument_get_firstChild( doc
, &node
);
3383 ok( r
== S_OK
, "ret %08x\n", r
);
3385 r
= IXMLDOMNode_get_nodeName( node
, &str
);
3386 ok( r
== S_OK
, "ret %08x\n", r
);
3388 ok(!lstrcmpW(str
, xmlW
), "expected \"xml\" node name, got %s\n", wine_dbgstr_w(str
));
3391 IXMLDOMNode_Release( node
);
3392 IXMLDOMDocument_Release( doc
);
3397 static void test_get_lastChild(void)
3399 static const WCHAR lcW
[] = {'l','c',0};
3400 static const WCHAR foW
[] = {'f','o',0};
3401 IXMLDOMDocument
*doc
;
3402 IXMLDOMNode
*node
, *child
;
3407 doc
= create_document(&IID_IXMLDOMDocument
);
3409 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3410 ok( r
== S_OK
, "loadXML failed\n");
3411 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3413 r
= IXMLDOMDocument_get_lastChild( doc
, &node
);
3414 ok( r
== S_OK
, "ret %08x\n", r
);
3416 r
= IXMLDOMNode_get_nodeName( node
, &str
);
3417 ok( r
== S_OK
, "ret %08x\n", r
);
3419 ok(memcmp(str
, lcW
, sizeof(lcW
)) == 0, "expected \"lc\" node name\n");
3422 r
= IXMLDOMNode_get_lastChild( node
, &child
);
3423 ok( r
== S_OK
, "ret %08x\n", r
);
3425 r
= IXMLDOMNode_get_nodeName( child
, &str
);
3426 ok( r
== S_OK
, "ret %08x\n", r
);
3428 ok(memcmp(str
, foW
, sizeof(foW
)) == 0, "expected \"fo\" node name\n");
3431 IXMLDOMNode_Release( child
);
3432 IXMLDOMNode_Release( node
);
3433 IXMLDOMDocument_Release( doc
);
3438 static void test_removeChild(void)
3442 IXMLDOMDocument
*doc
;
3443 IXMLDOMElement
*element
, *lc_element
;
3444 IXMLDOMNode
*fo_node
, *ba_node
, *removed_node
, *temp_node
, *lc_node
;
3445 IXMLDOMNodeList
*root_list
, *fo_list
;
3447 doc
= create_document(&IID_IXMLDOMDocument
);
3449 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3450 ok( r
== S_OK
, "loadXML failed\n");
3451 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3453 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3454 ok( r
== S_OK
, "ret %08x\n", r
);
3455 todo_wine
EXPECT_REF(element
, 2);
3457 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
3458 ok( r
== S_OK
, "ret %08x\n", r
);
3459 EXPECT_REF(root_list
, 1);
3461 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
3462 ok( r
== S_OK
, "ret %08x\n", r
);
3463 EXPECT_REF(fo_node
, 1);
3465 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
3466 ok( r
== S_OK
, "ret %08x\n", r
);
3467 EXPECT_REF(fo_list
, 1);
3469 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
3470 ok( r
== S_OK
, "ret %08x\n", r
);
3471 EXPECT_REF(ba_node
, 1);
3473 /* invalid parameter: NULL ptr */
3474 removed_node
= (void*)0xdeadbeef;
3475 r
= IXMLDOMElement_removeChild( element
, NULL
, &removed_node
);
3476 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3477 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
3479 /* ba_node is a descendant of element, but not a direct child. */
3480 removed_node
= (void*)0xdeadbeef;
3481 EXPECT_REF(ba_node
, 1);
3482 EXPECT_CHILDREN(fo_node
);
3483 r
= IXMLDOMElement_removeChild( element
, ba_node
, &removed_node
);
3484 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3485 ok( removed_node
== NULL
, "%p\n", removed_node
);
3486 EXPECT_REF(ba_node
, 1);
3487 EXPECT_CHILDREN(fo_node
);
3489 EXPECT_REF(ba_node
, 1);
3490 EXPECT_REF(fo_node
, 1);
3491 r
= IXMLDOMElement_removeChild( element
, fo_node
, &removed_node
);
3492 ok( r
== S_OK
, "ret %08x\n", r
);
3493 ok( fo_node
== removed_node
, "node %p node2 %p\n", fo_node
, removed_node
);
3494 EXPECT_REF(fo_node
, 2);
3495 EXPECT_REF(ba_node
, 1);
3497 /* try removing already removed child */
3498 temp_node
= (void*)0xdeadbeef;
3499 r
= IXMLDOMElement_removeChild( element
, fo_node
, &temp_node
);
3500 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3501 ok( temp_node
== NULL
, "%p\n", temp_node
);
3502 IXMLDOMNode_Release( fo_node
);
3504 /* the removed node has no parent anymore */
3505 r
= IXMLDOMNode_get_parentNode( removed_node
, &temp_node
);
3506 ok( r
== S_FALSE
, "ret %08x\n", r
);
3507 ok( temp_node
== NULL
, "%p\n", temp_node
);
3509 IXMLDOMNode_Release( removed_node
);
3510 IXMLDOMNode_Release( ba_node
);
3511 IXMLDOMNodeList_Release( fo_list
);
3513 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
3514 ok( r
== S_OK
, "ret %08x\n", r
);
3516 r
= IXMLDOMNode_QueryInterface( lc_node
, &IID_IXMLDOMElement
, (void**)&lc_element
);
3517 ok( r
== S_OK
, "ret %08x\n", r
);
3519 /* MS quirk: passing wrong interface pointer works, too */
3520 r
= IXMLDOMElement_removeChild( element
, (IXMLDOMNode
*)lc_element
, NULL
);
3521 ok( r
== S_OK
, "ret %08x\n", r
);
3522 IXMLDOMElement_Release( lc_element
);
3524 temp_node
= (void*)0xdeadbeef;
3525 r
= IXMLDOMNode_get_parentNode( lc_node
, &temp_node
);
3526 ok( r
== S_FALSE
, "ret %08x\n", r
);
3527 ok( temp_node
== NULL
, "%p\n", temp_node
);
3529 IXMLDOMNode_Release( lc_node
);
3530 IXMLDOMNodeList_Release( root_list
);
3531 IXMLDOMElement_Release( element
);
3532 IXMLDOMDocument_Release( doc
);
3537 static void test_replaceChild(void)
3541 IXMLDOMDocument
*doc
;
3542 IXMLDOMElement
*element
, *ba_element
;
3543 IXMLDOMNode
*fo_node
, *ba_node
, *lc_node
, *removed_node
, *temp_node
;
3544 IXMLDOMNodeList
*root_list
, *fo_list
;
3545 IUnknown
* unk1
, *unk2
;
3548 doc
= create_document(&IID_IXMLDOMDocument
);
3550 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3551 ok( r
== S_OK
, "loadXML failed\n");
3552 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3554 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3555 ok( r
== S_OK
, "ret %08x\n", r
);
3557 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
3558 ok( r
== S_OK
, "ret %08x\n", r
);
3560 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
3561 ok( r
== S_OK
, "ret %08x\n", r
);
3563 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
3564 ok( r
== S_OK
, "ret %08x\n", r
);
3566 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
3567 ok( r
== S_OK
, "ret %08x\n", r
);
3569 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
3570 ok( r
== S_OK
, "ret %08x\n", r
);
3572 IXMLDOMNodeList_Release( fo_list
);
3574 /* invalid parameter: NULL ptr for element to remove */
3575 removed_node
= (void*)0xdeadbeef;
3576 r
= IXMLDOMElement_replaceChild( element
, ba_node
, NULL
, &removed_node
);
3577 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3578 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
3580 /* invalid parameter: NULL for replacement element. (Sic!) */
3581 removed_node
= (void*)0xdeadbeef;
3582 r
= IXMLDOMElement_replaceChild( element
, NULL
, fo_node
, &removed_node
);
3583 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3584 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
3586 /* invalid parameter: OldNode is not a child */
3587 removed_node
= (void*)0xdeadbeef;
3588 r
= IXMLDOMElement_replaceChild( element
, lc_node
, ba_node
, &removed_node
);
3589 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3590 ok( removed_node
== NULL
, "%p\n", removed_node
);
3591 IXMLDOMNode_Release( lc_node
);
3593 /* invalid parameter: would create loop */
3594 removed_node
= (void*)0xdeadbeef;
3595 r
= IXMLDOMNode_replaceChild( fo_node
, fo_node
, ba_node
, &removed_node
);
3596 ok( r
== E_FAIL
, "ret %08x\n", r
);
3597 ok( removed_node
== NULL
, "%p\n", removed_node
);
3599 r
= IXMLDOMElement_replaceChild( element
, ba_node
, fo_node
, NULL
);
3600 ok( r
== S_OK
, "ret %08x\n", r
);
3602 r
= IXMLDOMNodeList_get_item( root_list
, 3, &temp_node
);
3603 ok( r
== S_OK
, "ret %08x\n", r
);
3605 /* ba_node and temp_node refer to the same node, yet they
3606 are different interface pointers */
3607 ok( ba_node
!= temp_node
, "ba_node %p temp_node %p\n", ba_node
, temp_node
);
3608 r
= IXMLDOMNode_QueryInterface( temp_node
, &IID_IUnknown
, (void**)&unk1
);
3609 ok( r
== S_OK
, "ret %08x\n", r
);
3610 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IUnknown
, (void**)&unk2
);
3611 ok( r
== S_OK
, "ret %08x\n", r
);
3612 todo_wine
ok( unk1
== unk2
, "unk1 %p unk2 %p\n", unk1
, unk2
);
3614 IUnknown_Release( unk1
);
3615 IUnknown_Release( unk2
);
3617 /* ba_node should have been removed from below fo_node */
3618 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
3619 ok( r
== S_OK
, "ret %08x\n", r
);
3621 /* MS quirk: replaceChild also accepts elements instead of nodes */
3622 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IXMLDOMElement
, (void**)&ba_element
);
3623 ok( r
== S_OK
, "ret %08x\n", r
);
3624 EXPECT_REF(ba_element
, 2);
3626 removed_node
= NULL
;
3627 r
= IXMLDOMElement_replaceChild( element
, ba_node
, (IXMLDOMNode
*)ba_element
, &removed_node
);
3628 ok( r
== S_OK
, "ret %08x\n", r
);
3629 ok( removed_node
!= NULL
, "got %p\n", removed_node
);
3630 EXPECT_REF(ba_element
, 3);
3631 IXMLDOMElement_Release( ba_element
);
3633 r
= IXMLDOMNodeList_get_length( fo_list
, &len
);
3634 ok( r
== S_OK
, "ret %08x\n", r
);
3635 ok( len
== 0, "len %d\n", len
);
3637 IXMLDOMNodeList_Release( fo_list
);
3639 IXMLDOMNode_Release(ba_node
);
3640 IXMLDOMNode_Release(fo_node
);
3641 IXMLDOMNode_Release(temp_node
);
3642 IXMLDOMNodeList_Release( root_list
);
3643 IXMLDOMElement_Release( element
);
3644 IXMLDOMDocument_Release( doc
);
3649 static void test_removeNamedItem(void)
3651 IXMLDOMDocument
*doc
;
3652 IXMLDOMElement
*element
;
3653 IXMLDOMNode
*pr_node
, *removed_node
, *removed_node2
;
3654 IXMLDOMNodeList
*root_list
;
3655 IXMLDOMNamedNodeMap
* pr_attrs
;
3661 doc
= create_document(&IID_IXMLDOMDocument
);
3663 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3664 ok( r
== S_OK
, "loadXML failed\n");
3665 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3667 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3668 ok( r
== S_OK
, "ret %08x\n", r
);
3670 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
3671 ok( r
== S_OK
, "ret %08x\n", r
);
3673 r
= IXMLDOMNodeList_get_item( root_list
, 1, &pr_node
);
3674 ok( r
== S_OK
, "ret %08x\n", r
);
3676 r
= IXMLDOMNode_get_attributes( pr_node
, &pr_attrs
);
3677 ok( r
== S_OK
, "ret %08x\n", r
);
3679 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3680 ok( r
== S_OK
, "ret %08x\n", r
);
3681 ok( len
== 3, "length %d\n", len
);
3683 removed_node
= (void*)0xdeadbeef;
3684 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, NULL
, &removed_node
);
3685 ok ( r
== E_INVALIDARG
, "ret %08x\n", r
);
3686 ok ( removed_node
== (void*)0xdeadbeef, "got %p\n", removed_node
);
3688 removed_node
= (void*)0xdeadbeef;
3689 str
= SysAllocString(szvr
);
3690 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node
);
3691 ok ( r
== S_OK
, "ret %08x\n", r
);
3693 removed_node2
= (void*)0xdeadbeef;
3694 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node2
);
3695 ok ( r
== S_FALSE
, "ret %08x\n", r
);
3696 ok ( removed_node2
== NULL
, "got %p\n", removed_node2
);
3698 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3699 ok( r
== S_OK
, "ret %08x\n", r
);
3700 ok( len
== 2, "length %d\n", len
);
3702 r
= IXMLDOMNamedNodeMap_setNamedItem( pr_attrs
, removed_node
, NULL
);
3703 ok ( r
== S_OK
, "ret %08x\n", r
);
3704 IXMLDOMNode_Release(removed_node
);
3706 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3707 ok( r
== S_OK
, "ret %08x\n", r
);
3708 ok( len
== 3, "length %d\n", len
);
3710 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
3711 ok ( r
== S_OK
, "ret %08x\n", r
);
3713 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
3714 ok( r
== S_OK
, "ret %08x\n", r
);
3715 ok( len
== 2, "length %d\n", len
);
3717 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
3718 ok ( r
== S_FALSE
, "ret %08x\n", r
);
3722 IXMLDOMNamedNodeMap_Release( pr_attrs
);
3723 IXMLDOMNode_Release( pr_node
);
3724 IXMLDOMNodeList_Release( root_list
);
3725 IXMLDOMElement_Release( element
);
3726 IXMLDOMDocument_Release( doc
);
3731 #define test_IObjectSafety_set(p, r, r2, s, m, e, e2) _test_IObjectSafety_set(__LINE__,p, r, r2, s, m, e, e2)
3732 static void _test_IObjectSafety_set(unsigned line
, IObjectSafety
*safety
, HRESULT result
,
3733 HRESULT result2
, DWORD set
, DWORD mask
, DWORD expected
,
3736 DWORD enabled
, supported
;
3739 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
, set
, mask
);
3740 if (result
== result2
)
3741 ok_(__FILE__
,line
)(hr
== result
, "SetInterfaceSafetyOptions: expected %08x, returned %08x\n", result
, hr
);
3743 ok_(__FILE__
,line
)(broken(hr
== result
) || hr
== result2
,
3744 "SetInterfaceSafetyOptions: expected %08x, got %08x\n", result2
, hr
);
3746 supported
= enabled
= 0xCAFECAFE;
3747 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
3748 ok(hr
== S_OK
, "ret %08x\n", hr
);
3749 if (expected
== expected2
)
3750 ok_(__FILE__
,line
)(enabled
== expected
, "Expected %08x, got %08x\n", expected
, enabled
);
3752 ok_(__FILE__
,line
)(broken(enabled
== expected
) || enabled
== expected2
,
3753 "Expected %08x, got %08x\n", expected2
, enabled
);
3755 /* reset the safety options */
3757 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
3758 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_SECURITY_MANAGER
,
3760 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3762 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
3763 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3764 ok_(__FILE__
,line
)(enabled
== 0, "Expected 0, got %08x\n", enabled
);
3767 #define test_IObjectSafety_common(s) _test_IObjectSafety_common(__LINE__,s)
3768 static void _test_IObjectSafety_common(unsigned line
, IObjectSafety
*safety
)
3770 DWORD enabled
= 0, supported
= 0;
3774 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, NULL
, &enabled
);
3775 ok_(__FILE__
,line
)(hr
== E_POINTER
, "ret %08x\n", hr
);
3776 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, NULL
);
3777 ok_(__FILE__
,line
)(hr
== E_POINTER
, "ret %08x\n", hr
);
3779 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
3780 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3781 ok_(__FILE__
,line
)(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
3782 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
3783 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
3784 "got %08x\n", supported
);
3785 ok_(__FILE__
,line
)(enabled
== 0, "Expected 0, got %08x\n", enabled
);
3787 /* set -- individual flags */
3789 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
3790 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
3791 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
3793 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
3794 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3795 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
);
3797 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
3798 INTERFACE_USES_SECURITY_MANAGER
, INTERFACE_USES_SECURITY_MANAGER
,
3799 0, INTERFACE_USES_SECURITY_MANAGER
/* msxml3 SP8+ */);
3801 /* set INTERFACE_USES_DISPEX */
3803 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
3804 INTERFACE_USES_DISPEX
, INTERFACE_USES_DISPEX
,
3807 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
3808 INTERFACE_USES_DISPEX
, 0,
3811 test_IObjectSafety_set(safety
, S_OK
, S_OK
/* msxml3 SP8+ */,
3812 0, INTERFACE_USES_DISPEX
,
3815 /* set option masking */
3817 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
3818 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3819 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
3820 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
3821 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
3823 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
3824 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3825 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3826 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3827 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
3829 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
3830 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3831 INTERFACE_USES_SECURITY_MANAGER
,
3835 /* set -- inheriting previous settings */
3837 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
3838 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
3839 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
3840 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3841 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
3842 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3843 ok_(__FILE__
,line
)(enabled
== INTERFACESAFE_FOR_UNTRUSTED_CALLER
, "Expected INTERFACESAFE_FOR_UNTRUSTED_CALLER got %08x\n", enabled
);
3844 ok_(__FILE__
,line
)(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
3845 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
3846 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
3847 "got %08x\n", supported
);
3849 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
3850 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
3851 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
3852 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3853 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
3854 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
3855 ok_(__FILE__
,line
)(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_DATA
) ||
3856 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
),
3857 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA) got %08x\n", enabled
);
3858 ok_(__FILE__
,line
)(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
3859 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
3860 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
3861 "got %08x\n", supported
);
3864 static void test_IXMLDOMDocument2(void)
3866 static const WCHAR emptyW
[] = {0};
3867 IXMLDOMDocument2
*doc2
, *dtddoc2
;
3868 IXMLDOMDocument
*doc
;
3869 IXMLDOMParseError
* err
;
3870 IDispatchEx
*dispex
;
3876 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument2
)) return;
3878 doc
= create_document(&IID_IXMLDOMDocument
);
3879 dtddoc2
= create_document(&IID_IXMLDOMDocument2
);
3881 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
3882 ok( r
== S_OK
, "ret %08x\n", r
);
3883 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
3885 ole_expect(IXMLDOMDocument2_get_readyState(doc2
, NULL
), E_INVALIDARG
);
3886 ole_check(IXMLDOMDocument2_get_readyState(doc2
, &res
));
3887 ok(res
== READYSTATE_COMPLETE
, "expected READYSTATE_COMPLETE (4), got %i\n", res
);
3890 ole_expect(IXMLDOMDocument2_validate(doc2
, NULL
), S_FALSE
);
3891 ole_expect(IXMLDOMDocument2_validate(doc2
, &err
), S_FALSE
);
3892 ok(err
!= NULL
, "expected a pointer\n");
3896 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3898 ok(res
== E_XML_NOTWF
, "got %08x\n", res
);
3899 IXMLDOMParseError_Release(err
);
3902 r
= IXMLDOMDocument2_loadXML( doc2
, _bstr_(complete4A
), &b
);
3903 ok( r
== S_OK
, "loadXML failed\n");
3904 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3906 ole_check(IXMLDOMDocument_get_readyState(doc
, &res
));
3907 ok(res
== READYSTATE_COMPLETE
, "expected READYSTATE_COMPLETE (4), got %i\n", res
);
3910 ole_expect(IXMLDOMDocument2_validate(doc2
, &err
), S_FALSE
);
3911 ok(err
!= NULL
, "expected a pointer\n");
3915 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
3917 ok(res
== E_XML_NODTD
, "got %08x\n", res
);
3918 IXMLDOMParseError_Release(err
);
3921 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IDispatchEx
, (void**)&dispex
);
3922 ok( r
== S_OK
, "ret %08x\n", r
);
3925 IDispatchEx_Release(dispex
);
3928 /* we will check if the variant got cleared */
3929 IXMLDOMDocument2_AddRef(doc2
);
3930 EXPECT_REF(doc2
, 3); /* doc, doc2, AddRef*/
3932 V_VT(&var
) = VT_UNKNOWN
;
3933 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
3936 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
3937 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
3938 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
3941 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
3942 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
3943 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
3946 /* the variant didn't get cleared*/
3947 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
3949 /* setProperty tests */
3950 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
3951 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
3952 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
3953 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
3954 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
3955 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
3957 V_VT(&var
) = VT_BSTR
;
3958 V_BSTR(&var
) = SysAllocString(emptyW
);
3959 r
= IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionNamespaces"), var
);
3960 ok(r
== S_OK
, "got 0x%08x\n", r
);
3965 r
= IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionNamespaces"), var
);
3966 ok(r
== E_FAIL
, "got 0x%08x\n", r
);
3968 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
3969 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
3970 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
3971 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
3973 IXMLDOMDocument2_Release( doc2
);
3974 IXMLDOMDocument_Release( doc
);
3976 /* DTD validation */
3977 ole_check(IXMLDOMDocument2_put_validateOnParse(dtddoc2
, VARIANT_FALSE
));
3978 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML
), &b
));
3979 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3981 ole_check(IXMLDOMDocument2_validate(dtddoc2
, &err
));
3982 ok(err
!= NULL
, "expected pointer\n");
3986 ole_expect(IXMLDOMParseError_get_errorCode(err
, &res
), S_FALSE
);
3987 ok(res
== 0, "got %08x\n", res
);
3988 IXMLDOMParseError_Release(err
);
3991 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_0D
), &b
));
3992 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3994 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
3995 ok(err
!= NULL
, "expected pointer\n");
3999 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4000 /* XML_ELEMENT_UNDECLARED */
4001 todo_wine
ok(res
== 0xC00CE00D, "got %08x\n", res
);
4002 IXMLDOMParseError_Release(err
);
4005 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_0E
), &b
));
4006 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4008 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4009 ok(err
!= NULL
, "expected pointer\n");
4013 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4014 /* XML_ELEMENT_ID_NOT_FOUND */
4015 todo_wine
ok(res
== 0xC00CE00E, "got %08x\n", res
);
4016 IXMLDOMParseError_Release(err
);
4019 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_11
), &b
));
4020 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4022 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4023 ok(err
!= NULL
, "expected pointer\n");
4027 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4028 /* XML_EMPTY_NOT_ALLOWED */
4029 todo_wine
ok(res
== 0xC00CE011, "got %08x\n", res
);
4030 IXMLDOMParseError_Release(err
);
4033 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_13
), &b
));
4034 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4036 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4037 ok(err
!= NULL
, "expected pointer\n");
4041 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4042 /* XML_ROOT_NAME_MISMATCH */
4043 todo_wine
ok(res
== 0xC00CE013, "got %08x\n", res
);
4044 IXMLDOMParseError_Release(err
);
4047 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_14
), &b
));
4048 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4050 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4051 ok(err
!= NULL
, "expected pointer\n");
4055 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4056 /* XML_INVALID_CONTENT */
4057 todo_wine
ok(res
== 0xC00CE014, "got %08x\n", res
);
4058 IXMLDOMParseError_Release(err
);
4061 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_15
), &b
));
4062 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4064 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4065 ok(err
!= NULL
, "expected pointer\n");
4069 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4070 /* XML_ATTRIBUTE_NOT_DEFINED */
4071 todo_wine
ok(res
== 0xC00CE015, "got %08x\n", res
);
4072 IXMLDOMParseError_Release(err
);
4075 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_16
), &b
));
4076 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4078 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4079 ok(err
!= NULL
, "expected pointer\n");
4083 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4084 /* XML_ATTRIBUTE_FIXED */
4085 todo_wine
ok(res
== 0xC00CE016, "got %08x\n", res
);
4086 IXMLDOMParseError_Release(err
);
4089 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_17
), &b
));
4090 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4092 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4093 ok(err
!= NULL
, "expected pointer\n");
4097 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4098 /* XML_ATTRIBUTE_VALUE */
4099 todo_wine
ok(res
== 0xC00CE017, "got %08x\n", res
);
4100 IXMLDOMParseError_Release(err
);
4103 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_18
), &b
));
4104 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4106 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4107 ok(err
!= NULL
, "expected pointer\n");
4111 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4112 /* XML_ILLEGAL_TEXT */
4113 todo_wine
ok(res
== 0xC00CE018, "got %08x\n", res
);
4114 IXMLDOMParseError_Release(err
);
4117 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_20
), &b
));
4118 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4120 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
4121 ok(err
!= NULL
, "expected pointer\n");
4125 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
4126 /* XML_REQUIRED_ATTRIBUTE_MISSING */
4127 todo_wine
ok(res
== 0xC00CE020, "got %08x\n", res
);
4128 IXMLDOMParseError_Release(err
);
4131 IXMLDOMDocument2_Release( dtddoc2
);
4135 #define helper_ole_check(expr) { \
4137 ok_(__FILE__, line)(r == S_OK, "=> %i: " #expr " returned %08x\n", __LINE__, r); \
4140 #define helper_expect_list_and_release(list, expstr) { \
4141 char *str = list_to_string(list); \
4142 ok_(__FILE__, line)(strcmp(str, expstr)==0, "=> %i: Invalid node list: %s, expected %s\n", __LINE__, str, expstr); \
4143 if (list) IXMLDOMNodeList_Release(list); \
4146 #define helper_expect_bstr_and_release(bstr, str) { \
4147 ok_(__FILE__, line)(lstrcmpW(bstr, _bstr_(str)) == 0, \
4148 "=> %i: got %s\n", __LINE__, wine_dbgstr_w(bstr)); \
4149 SysFreeString(bstr); \
4152 #define check_ws_ignored(doc, str) _check_ws_ignored(__LINE__, doc, str)
4153 static inline void _check_ws_ignored(int line
, IXMLDOMDocument2
* doc
, char const* str
)
4155 IXMLDOMNode
*node1
, *node2
;
4156 IXMLDOMNodeList
*list
;
4159 helper_ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//*[local-name()='html']"), &list
));
4160 helper_ole_check(IXMLDOMNodeList_get_item(list
, 0, &node1
));
4161 helper_ole_check(IXMLDOMNodeList_get_item(list
, 1, &node2
));
4162 helper_ole_check(IXMLDOMNodeList_reset(list
));
4163 helper_expect_list_and_release(list
, "E1.E5.E1.E2.D1 E2.E5.E1.E2.D1");
4165 helper_ole_check(IXMLDOMNode_get_childNodes(node1
, &list
));
4166 helper_expect_list_and_release(list
, "T1.E1.E5.E1.E2.D1 E2.E1.E5.E1.E2.D1 E3.E1.E5.E1.E2.D1 T4.E1.E5.E1.E2.D1 E5.E1.E5.E1.E2.D1");
4167 helper_ole_check(IXMLDOMNode_get_text(node1
, &bstr
));
4170 helper_expect_bstr_and_release(bstr
, str
);
4174 helper_expect_bstr_and_release(bstr
, "This is a description.");
4176 IXMLDOMNode_Release(node1
);
4178 helper_ole_check(IXMLDOMNode_get_childNodes(node2
, &list
));
4179 helper_expect_list_and_release(list
, "T1.E2.E5.E1.E2.D1 E2.E2.E5.E1.E2.D1 T3.E2.E5.E1.E2.D1 E4.E2.E5.E1.E2.D1 T5.E2.E5.E1.E2.D1 E6.E2.E5.E1.E2.D1 T7.E2.E5.E1.E2.D1");
4180 helper_ole_check(IXMLDOMNode_get_text(node2
, &bstr
));
4181 helper_expect_bstr_and_release(bstr
, "\n This is a description with preserved whitespace. \n ");
4182 IXMLDOMNode_Release(node2
);
4185 #define check_ws_preserved(doc, str) _check_ws_preserved(__LINE__, doc, str)
4186 static inline void _check_ws_preserved(int line
, IXMLDOMDocument2
* doc
, char const* str
)
4188 IXMLDOMNode
*node1
, *node2
;
4189 IXMLDOMNodeList
*list
;
4192 helper_ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//*[local-name()='html']"), &list
));
4193 helper_ole_check(IXMLDOMNodeList_get_item(list
, 0, &node1
));
4194 helper_ole_check(IXMLDOMNodeList_get_item(list
, 1, &node2
));
4195 helper_ole_check(IXMLDOMNodeList_reset(list
));
4196 helper_expect_list_and_release(list
, "E2.E10.E2.E2.D1 E4.E10.E2.E2.D1");
4198 helper_ole_check(IXMLDOMNode_get_childNodes(node1
, &list
));
4199 helper_expect_list_and_release(list
, "T1.E2.E10.E2.E2.D1 E2.E2.E10.E2.E2.D1 T3.E2.E10.E2.E2.D1 E4.E2.E10.E2.E2.D1 T5.E2.E10.E2.E2.D1 E6.E2.E10.E2.E2.D1 T7.E2.E10.E2.E2.D1");
4200 helper_ole_check(IXMLDOMNode_get_text(node1
, &bstr
));
4203 helper_expect_bstr_and_release(bstr
, str
);
4207 helper_expect_bstr_and_release(bstr
, "\n This is a description. \n ");
4209 IXMLDOMNode_Release(node1
);
4211 helper_ole_check(IXMLDOMNode_get_childNodes(node2
, &list
));
4212 helper_expect_list_and_release(list
, "T1.E4.E10.E2.E2.D1 E2.E4.E10.E2.E2.D1 T3.E4.E10.E2.E2.D1 E4.E4.E10.E2.E2.D1 T5.E4.E10.E2.E2.D1 E6.E4.E10.E2.E2.D1 T7.E4.E10.E2.E2.D1");
4213 helper_ole_check(IXMLDOMNode_get_text(node2
, &bstr
));
4214 helper_expect_bstr_and_release(bstr
, "\n This is a description with preserved whitespace. \n ");
4215 IXMLDOMNode_Release(node2
);
4218 static void test_preserve_charref(IXMLDOMDocument2
*doc
, VARIANT_BOOL preserve
)
4220 static const WCHAR b1_p
[] = {' ','T','e','x','t',' ','A',' ','e','n','d',' ',0};
4221 static const WCHAR b1_i
[] = {'T','e','x','t',' ','A',' ','e','n','d',0};
4222 static const WCHAR b2_p
[] = {'A','B',' ','C',' ',0};
4223 static const WCHAR b2_i
[] = {'A','B',' ','C',0};
4224 IXMLDOMNodeList
*list
;
4225 IXMLDOMElement
*root
;
4232 hr
= IXMLDOMDocument2_put_preserveWhiteSpace(doc
, preserve
);
4233 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4235 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(charrefsxml
), &b
);
4236 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4238 hr
= IXMLDOMDocument2_get_documentElement(doc
, &root
);
4239 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4241 hr
= IXMLDOMElement_get_childNodes(root
, &list
);
4242 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4243 IXMLDOMElement_Release(root
);
4245 text
= preserve
== VARIANT_TRUE
? b1_p
: b1_i
;
4246 hr
= IXMLDOMNodeList_get_item(list
, 0, &node
);
4247 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4248 hr
= IXMLDOMNode_get_text(node
, &s
);
4249 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4250 ok(!lstrcmpW(s
, text
), "0x%x, got %s\n", preserve
, wine_dbgstr_w(s
));
4252 IXMLDOMNode_Release(node
);
4254 text
= preserve
== VARIANT_TRUE
? b2_p
: b2_i
;
4255 hr
= IXMLDOMNodeList_get_item(list
, 1, &node
);
4256 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4257 hr
= IXMLDOMNode_get_text(node
, &s
);
4258 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4259 ok(!lstrcmpW(s
, text
), "0x%x, got %s\n", preserve
, wine_dbgstr_w(s
));
4261 IXMLDOMNode_Release(node
);
4263 IXMLDOMNodeList_Release(list
);
4266 static void test_whitespace(void)
4268 IXMLDOMDocument2
*doc1
, *doc2
, *doc3
, *doc4
;
4269 IXMLDOMNodeList
*list
;
4270 IXMLDOMElement
*root
;
4275 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument2
)) return;
4276 doc1
= create_document(&IID_IXMLDOMDocument2
);
4277 doc2
= create_document(&IID_IXMLDOMDocument2
);
4279 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc2
, VARIANT_TRUE
));
4280 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc1
, &b
));
4281 ok(b
== VARIANT_FALSE
, "expected false\n");
4282 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc2
, &b
));
4283 ok(b
== VARIANT_TRUE
, "expected true\n");
4285 ole_check(IXMLDOMDocument2_loadXML(doc1
, _bstr_(szExampleXML
), &b
));
4286 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4287 ole_check(IXMLDOMDocument2_loadXML(doc2
, _bstr_(szExampleXML
), &b
));
4288 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4290 /* switch to XPath */
4291 ole_check(IXMLDOMDocument2_setProperty(doc1
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
4292 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
4294 check_ws_ignored(doc1
, NULL
);
4295 check_ws_preserved(doc2
, NULL
);
4297 /* new instances copy the property */
4298 ole_check(IXMLDOMDocument2_QueryInterface(doc1
, &IID_IXMLDOMDocument2
, (void**) &doc3
));
4299 ole_check(IXMLDOMDocument2_QueryInterface(doc2
, &IID_IXMLDOMDocument2
, (void**) &doc4
));
4301 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc3
, &b
));
4302 ok(b
== VARIANT_FALSE
, "expected false\n");
4303 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc4
, &b
));
4304 ok(b
== VARIANT_TRUE
, "expected true\n");
4306 check_ws_ignored(doc3
, NULL
);
4307 check_ws_preserved(doc4
, NULL
);
4309 /* setting after loading xml affects trimming of leading/trailing ws only */
4310 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc1
, VARIANT_TRUE
));
4311 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc2
, VARIANT_FALSE
));
4313 /* the trailing "\n " isn't there, because it was ws-only node */
4314 check_ws_ignored(doc1
, "\n This is a description. ");
4315 check_ws_preserved(doc2
, "This is a description.");
4317 /* it takes effect on reload */
4318 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc1
, &b
));
4319 ok(b
== VARIANT_TRUE
, "expected true\n");
4320 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc2
, &b
));
4321 ok(b
== VARIANT_FALSE
, "expected false\n");
4323 ole_check(IXMLDOMDocument2_loadXML(doc1
, _bstr_(szExampleXML
), &b
));
4324 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4325 ole_check(IXMLDOMDocument2_loadXML(doc2
, _bstr_(szExampleXML
), &b
));
4326 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4328 check_ws_preserved(doc1
, NULL
);
4329 check_ws_ignored(doc2
, NULL
);
4331 /* other instances follow suit */
4332 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc3
, &b
));
4333 ok(b
== VARIANT_TRUE
, "expected true\n");
4334 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc4
, &b
));
4335 ok(b
== VARIANT_FALSE
, "expected false\n");
4337 check_ws_preserved(doc3
, NULL
);
4338 check_ws_ignored(doc4
, NULL
);
4340 IXMLDOMDocument2_Release(doc2
);
4341 IXMLDOMDocument2_Release(doc3
);
4342 IXMLDOMDocument2_Release(doc4
);
4344 /* text with char references */
4345 test_preserve_charref(doc1
, VARIANT_TRUE
);
4346 test_preserve_charref(doc1
, VARIANT_FALSE
);
4348 /* formatting whitespaces */
4349 hr
= IXMLDOMDocument2_put_preserveWhiteSpace(doc1
, VARIANT_FALSE
);
4350 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4352 hr
= IXMLDOMDocument2_loadXML(doc1
, _bstr_(complete7
), &b
);
4353 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4354 ok(b
== VARIANT_TRUE
, "for %x\n", b
);
4356 hr
= IXMLDOMDocument2_get_documentElement(doc1
, &root
);
4357 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4358 hr
= IXMLDOMElement_get_childNodes(root
, &list
);
4359 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4361 hr
= IXMLDOMNodeList_get_length(list
, &len
);
4362 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4363 ok(len
== 3, "got %d\n", len
);
4364 IXMLDOMNodeList_Release(list
);
4365 IXMLDOMElement_Release(root
);
4367 IXMLDOMDocument2_Release(doc1
);
4379 /* supposed to be tested with szExampleXML */
4380 static const selection_ns_t selection_ns_data
[] = {
4381 { &CLSID_DOMDocument
, "CLSID_DOMDocument", "\txmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4382 { &CLSID_DOMDocument
, "CLSID_DOMDocument", "\n\rxmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4383 { &CLSID_DOMDocument
, "CLSID_DOMDocument", " xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4384 { &CLSID_DOMDocument
, "CLSID_DOMDocument", "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' ", S_OK
},
4386 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2", "\txmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4387 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2", "\n\rxmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4388 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2", " xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4389 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2", "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' ", S_OK
},
4391 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", "\txmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4392 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", "\n\rxmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4393 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", " xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4394 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' ", S_OK
},
4396 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", "\txmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4397 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", "\n\rxmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4398 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", " xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4399 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' ", S_OK
},
4401 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", "\txmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4402 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", "\n\rxmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4403 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", " xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'", S_OK
},
4404 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' ", S_OK
},
4414 static const xpath_test_t xpath_test
[] = {
4415 { "*/a", "E1.E1.E2.D1 E1.E2.E2.D1 E1.E4.E2.D1" },
4416 { "*/b", "E2.E1.E2.D1 E2.E2.E2.D1 E2.E4.E2.D1" },
4417 { "*/c", "E3.E1.E2.D1 E3.E2.E2.D1" },
4418 { "*/d", "E4.E1.E2.D1 E4.E2.E2.D1 E4.E4.E2.D1" },
4419 { "//a", "E1.E1.E2.D1 E1.E2.E2.D1 E1.E4.E2.D1" },
4420 { "//b", "E2.E1.E2.D1 E2.E2.E2.D1 E2.E4.E2.D1" },
4421 { "//c", "E3.E1.E2.D1 E3.E2.E2.D1" },
4422 { "//d", "E4.E1.E2.D1 E4.E2.E2.D1 E4.E4.E2.D1" },
4423 { "//c[@type]", "E3.E2.E2.D1" },
4424 { "//c[@type]/ancestor::node()[1]", "E2.E2.D1" },
4425 { "//c[@type]/ancestor-or-self::node()[1]", "E3.E2.E2.D1" },
4426 { "//c[@type]/attribute::node()[1]", "A'type'.E3.E2.E2.D1" },
4427 { "//c[@type]/child::node()[1]", "T1.E3.E2.E2.D1" },
4428 { "//c[@type]/descendant::node()[1]", "T1.E3.E2.E2.D1" },
4429 { "//c[@type]/descendant-or-self::node()[1]", "E3.E2.E2.D1" },
4430 { "//c[@type]/following::node()[1]", "E4.E2.E2.D1" },
4431 { "//c[@type]/following-sibling::node()[1]", "E4.E2.E2.D1" },
4432 { "//c[@type]/parent::node()[1]", "E2.E2.D1" },
4433 { "//c[@type]/preceding::node()[1]", "T1.E2.E2.E2.D1" },
4434 { "//c[@type]/self::node()[1]", "E3.E2.E2.D1" },
4435 { "child::*", "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1" },
4436 { "child::node()", "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1" },
4437 { "child::text()", "" },
4438 { "child::*/..", "E2.D1" },
4439 { "child::*//@*/..", "E2.E5.E1.E2.D1 E2.E2.D1 E3.E2.E2.D1" },
4440 { "self::node()", "E2.D1" },
4441 { "ancestor::node()", "D1" },
4442 { "elem[c][last()]/a", "E1.E2.E2.D1"},
4443 { "ancestor-or-self::node()[1]", "E2.D1" },
4444 { "((//a)[1])[last()]", "E1.E1.E2.D1" },
4445 { "//elem[@*]", "E2.E2.D1" },
4449 static void test_XPath(void)
4451 const selection_ns_t
*ptr
= selection_ns_data
;
4452 const xpath_test_t
*xptest
= xpath_test
;
4455 IXMLDOMDocument2
*doc
;
4456 IXMLDOMDocument
*doc2
;
4457 IXMLDOMNode
*rootNode
;
4458 IXMLDOMNode
*elem1Node
;
4460 IXMLDOMNodeList
*list
;
4461 IXMLDOMElement
*elem
;
4462 IXMLDOMAttribute
*attr
;
4468 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument2
)) return;
4469 doc
= create_document(&IID_IXMLDOMDocument2
);
4471 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
4472 EXPECT_HR(hr
, S_OK
);
4473 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4475 /* switch to XPath */
4476 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
4478 /* some simple queries*/
4480 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
4481 EXPECT_HR(hr
, S_OK
);
4483 EXPECT_LIST_LEN(list
, 1);
4485 EXPECT_REF(list
, 1);
4486 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
4487 EXPECT_HR(hr
, S_OK
);
4488 EXPECT_REF(list
, 1);
4489 EXPECT_REF(rootNode
, 1);
4491 hr
= IXMLDOMNodeList_reset(list
);
4492 EXPECT_HR(hr
, S_OK
);
4493 expect_list_and_release(list
, "E2.D1");
4495 /* peform xpath tests */
4496 for ( ; xptest
->query
; xptest
++ )
4500 hr
= IXMLDOMNode_selectNodes(rootNode
, _bstr_(xptest
->query
), &list
);
4501 ok(hr
== S_OK
, "query evaluation failed for query=%s\n", xptest
->query
);
4506 str
= list_to_string(list
);
4508 ok(!strcmp(str
, xptest
->list
), "query=%s, invalid node list: \"%s\", expected \"%s\"\n",
4509 xptest
->query
, str
, xptest
->list
);
4512 IXMLDOMNodeList_Release(list
);
4517 /* namespace:: axis test is disabled until namespace definitions
4518 are supported as attribute nodes, currently it's another node type */
4519 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("/root/namespace::*"), &list
);
4520 EXPECT_HR(hr
, S_OK
);
4522 hr
= IXMLDOMNodeList_get_length(list
, &len
);
4523 EXPECT_HR(hr
, S_OK
);
4524 ok(len
== 2, "got %d\n", len
);
4526 hr
= IXMLDOMNodeList_nextNode(list
, &node
);
4527 EXPECT_HR(hr
, S_OK
);
4528 type
= NODE_INVALID
;
4529 hr
= IXMLDOMNode_get_nodeType(node
, &type
);
4530 EXPECT_HR(hr
, S_OK
);
4531 ok(type
== NODE_ATTRIBUTE
, "got %d\n", type
);
4532 IXMLDOMNode_Release(node
);
4534 IXMLDOMNodeList_Release(list
);
4537 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//c"), &list
));
4538 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
4540 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
4541 expect_list_and_release(list
, "E3.E2.E2.D1");
4543 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
4544 /* using get_item for query results advances the position */
4545 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
4546 expect_node(node
, "E2.E2.D1");
4547 IXMLDOMNode_Release(node
);
4548 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
4549 expect_node(node
, "E4.E2.D1");
4550 IXMLDOMNode_Release(node
);
4551 ole_check(IXMLDOMNodeList_reset(list
));
4552 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
4554 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
4555 expect_list_and_release(list
, "E2.D1");
4557 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
4558 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
4559 ole_check(IXMLDOMNodeList_reset(list
));
4560 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
4562 /* select an attribute */
4563 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
4564 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
4566 /* would evaluate to a number */
4567 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
4568 /* would evaluate to a boolean */
4569 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
4570 /* would evaluate to a string */
4571 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
4574 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
4575 expect_list_and_release(list
, "");
4576 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("elem//c"), &list
));
4577 expect_list_and_release(list
, "");
4578 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
4579 expect_list_and_release(list
, "");
4580 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//elem[0]"), &list
));
4581 expect_list_and_release(list
, "");
4583 /* foo undeclared in document node */
4584 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
4585 /* undeclared in <root> node */
4586 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
4587 /* undeclared in <elem> node */
4588 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
4589 /* but this trick can be used */
4590 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
4591 expect_list_and_release(list
, "E3.E4.E2.D1");
4593 /* it has to be declared in SelectionNamespaces */
4594 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
4595 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
4597 /* now the namespace can be used */
4598 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//test:c"), &list
));
4599 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4600 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
4601 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4602 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
4603 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4604 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
4605 expect_list_and_release(list
, "E5.E1.E5.E1.E2.D1 E6.E2.E5.E1.E2.D1");
4607 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
4608 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
4609 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
4611 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
4614 ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
4615 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
4616 if (V_VT(&var
) == VT_BSTR
)
4617 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
4619 /* extra attributes - same thing*/
4620 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
4621 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
4622 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
4624 IXMLDOMNode_Release(rootNode
);
4625 IXMLDOMNode_Release(elem1Node
);
4627 /* alter document with already built list */
4628 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
4629 EXPECT_HR(hr
, S_OK
);
4630 EXPECT_LIST_LEN(list
, 1);
4632 hr
= IXMLDOMDocument2_get_lastChild(doc
, &rootNode
);
4633 EXPECT_HR(hr
, S_OK
);
4634 EXPECT_REF(rootNode
, 1);
4637 hr
= IXMLDOMDocument2_removeChild(doc
, rootNode
, NULL
);
4638 EXPECT_HR(hr
, S_OK
);
4639 IXMLDOMNode_Release(rootNode
);
4641 EXPECT_LIST_LEN(list
, 1);
4643 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
4644 EXPECT_HR(hr
, S_OK
);
4645 EXPECT_REF(rootNode
, 1);
4647 IXMLDOMNodeList_Release(list
);
4649 hr
= IXMLDOMNode_get_nodeName(rootNode
, &str
);
4650 EXPECT_HR(hr
, S_OK
);
4651 ok(!lstrcmpW(str
, _bstr_("root")), "got %s\n", wine_dbgstr_w(str
));
4653 IXMLDOMNode_Release(rootNode
);
4655 /* alter node from list and get it another time */
4656 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
4657 EXPECT_HR(hr
, S_OK
);
4658 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4660 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
4661 EXPECT_HR(hr
, S_OK
);
4662 EXPECT_LIST_LEN(list
, 1);
4664 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
4665 EXPECT_HR(hr
, S_OK
);
4667 hr
= IXMLDOMNode_QueryInterface(rootNode
, &IID_IXMLDOMElement
, (void**)&elem
);
4668 EXPECT_HR(hr
, S_OK
);
4672 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("attrtest"), var
);
4673 EXPECT_HR(hr
, S_OK
);
4674 IXMLDOMElement_Release(elem
);
4675 IXMLDOMNode_Release(rootNode
);
4677 /* now check attribute to be present */
4678 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
4679 EXPECT_HR(hr
, S_OK
);
4681 hr
= IXMLDOMNode_QueryInterface(rootNode
, &IID_IXMLDOMElement
, (void**)&elem
);
4682 EXPECT_HR(hr
, S_OK
);
4684 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attrtest"), &attr
);
4685 EXPECT_HR(hr
, S_OK
);
4686 IXMLDOMAttribute_Release(attr
);
4688 IXMLDOMElement_Release(elem
);
4689 IXMLDOMNode_Release(rootNode
);
4691 /* and now check for attribute in original document */
4692 hr
= IXMLDOMDocument2_get_documentElement(doc
, &elem
);
4693 EXPECT_HR(hr
, S_OK
);
4695 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attrtest"), &attr
);
4696 EXPECT_HR(hr
, S_OK
);
4697 IXMLDOMAttribute_Release(attr
);
4699 IXMLDOMElement_Release(elem
);
4701 /* attach node from list to another document */
4702 doc2
= create_document(&IID_IXMLDOMDocument
);
4704 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
4705 EXPECT_HR(hr
, S_OK
);
4706 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4708 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
4709 EXPECT_HR(hr
, S_OK
);
4710 EXPECT_LIST_LEN(list
, 1);
4712 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
4713 EXPECT_HR(hr
, S_OK
);
4714 EXPECT_REF(rootNode
, 1);
4716 hr
= IXMLDOMDocument_appendChild(doc2
, rootNode
, NULL
);
4717 EXPECT_HR(hr
, S_OK
);
4718 EXPECT_REF(rootNode
, 1);
4719 EXPECT_REF(doc2
, 1);
4720 EXPECT_REF(list
, 1);
4722 EXPECT_LIST_LEN(list
, 1);
4724 IXMLDOMNode_Release(rootNode
);
4725 IXMLDOMNodeList_Release(list
);
4726 IXMLDOMDocument_Release(doc2
);
4727 IXMLDOMDocument2_Release(doc
);
4731 if (is_clsid_supported(ptr
->clsid
, &IID_IXMLDOMDocument2
))
4733 hr
= CoCreateInstance(ptr
->clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (void**)&doc
);
4734 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
4742 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
4743 EXPECT_HR(hr
, S_OK
);
4744 ok(b
== VARIANT_TRUE
, "failed to load, %s\n", ptr
->name
);
4746 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath"));
4747 EXPECT_HR(hr
, S_OK
);
4749 V_VT(&var
) = VT_BSTR
;
4750 V_BSTR(&var
) = _bstr_(ptr
->ns
);
4752 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), var
);
4753 ok(hr
== ptr
->hr
, "got 0x%08x, for %s, %s\n", hr
, ptr
->name
, ptr
->ns
);
4755 V_VT(&var
) = VT_EMPTY
;
4756 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
);
4757 EXPECT_HR(hr
, S_OK
);
4758 ok(V_VT(&var
) == VT_BSTR
, "got wrong property type %d\n", V_VT(&var
));
4759 ok(!lstrcmpW(V_BSTR(&var
), _bstr_(ptr
->ns
)), "got wrong value %s\n", wine_dbgstr_w(V_BSTR(&var
)));
4762 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//test:c"), &list
);
4763 EXPECT_HR(hr
, S_OK
);
4765 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
4767 IXMLDOMDocument2_Release(doc
);
4775 static void test_cloneNode(void )
4777 IXMLDOMDocument
*doc
, *doc2
;
4779 IXMLDOMNodeList
*pList
;
4780 IXMLDOMNamedNodeMap
*mapAttr
;
4781 LONG length
, length1
;
4782 LONG attr_cnt
, attr_cnt1
;
4783 IXMLDOMNode
*node
, *attr
;
4784 IXMLDOMNode
*node_clone
;
4785 IXMLDOMNode
*node_first
;
4788 doc
= create_document(&IID_IXMLDOMDocument
);
4790 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
));
4791 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
4793 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc/pr"), &node
);
4794 ok( hr
== S_OK
, "ret %08x\n", hr
);
4795 ok( node
!= NULL
, "node %p\n", node
);
4797 /* Check invalid parameter */
4798 hr
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
4799 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4802 hr
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
4803 ok( hr
== S_OK
, "ret %08x\n", hr
);
4804 ok( node_clone
!= NULL
, "node %p\n", node
);
4806 hr
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
4807 ok( hr
== S_OK
, "ret %08x\n", hr
);
4808 hr
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
4809 ok( hr
== S_OK
, "ret %08x\n", hr
);
4810 IXMLDOMDocument_Release(doc2
);
4811 IXMLDOMNode_Release(node_first
);
4813 hr
= IXMLDOMNode_get_childNodes(node
, &pList
);
4814 ok( hr
== S_OK
, "ret %08x\n", hr
);
4816 hr
= IXMLDOMNodeList_get_length(pList
, &length
);
4817 ok( hr
== S_OK
, "ret %08x\n", hr
);
4818 ok(length
== 1, "got %d\n", length
);
4819 IXMLDOMNodeList_Release(pList
);
4821 hr
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
4822 ok( hr
== S_OK
, "ret %08x\n", hr
);
4824 hr
= IXMLDOMNamedNodeMap_get_length(mapAttr
, &attr_cnt
);
4825 ok( hr
== S_OK
, "ret %08x\n", hr
);
4826 ok(attr_cnt
== 3, "got %d\n", attr_cnt
);
4827 IXMLDOMNamedNodeMap_Release(mapAttr
);
4829 hr
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
4830 ok( hr
== S_OK
, "ret %08x\n", hr
);
4832 hr
= IXMLDOMNodeList_get_length(pList
, &length1
);
4833 ok(length1
== 1, "got %d\n", length1
);
4834 ok( hr
== S_OK
, "ret %08x\n", hr
);
4835 IXMLDOMNodeList_Release(pList
);
4837 hr
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
4838 ok( hr
== S_OK
, "ret %08x\n", hr
);
4840 hr
= IXMLDOMNamedNodeMap_get_length(mapAttr
, &attr_cnt1
);
4841 ok( hr
== S_OK
, "ret %08x\n", hr
);
4842 ok(attr_cnt1
== 3, "got %d\n", attr_cnt1
);
4843 /* now really get some attributes from cloned element */
4845 hr
= IXMLDOMNamedNodeMap_getNamedItem(mapAttr
, _bstr_("id"), &attr
);
4846 ok(hr
== S_OK
, "ret %08x\n", hr
);
4847 IXMLDOMNode_Release(attr
);
4848 IXMLDOMNamedNodeMap_Release(mapAttr
);
4850 ok(length
== length1
, "wrong Child count (%d, %d)\n", length
, length1
);
4851 ok(attr_cnt
== attr_cnt1
, "wrong Attribute count (%d, %d)\n", attr_cnt
, attr_cnt1
);
4852 IXMLDOMNode_Release(node_clone
);
4855 hr
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
4856 ok( hr
== S_OK
, "ret %08x\n", hr
);
4857 ok( node_clone
!= NULL
, "node %p\n", node
);
4859 hr
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
4860 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4862 hr
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
4863 ok(hr
== S_OK
, "ret %08x\n", hr
);
4864 hr
= IXMLDOMNodeList_get_length(pList
, &length1
);
4865 ok(hr
== S_OK
, "ret %08x\n", hr
);
4866 ok( length1
== 0, "Length should be 0 (%d)\n", length1
);
4867 IXMLDOMNodeList_Release(pList
);
4869 hr
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
4870 ok(hr
== S_OK
, "ret %08x\n", hr
);
4871 hr
= IXMLDOMNamedNodeMap_get_length(mapAttr
, &attr_cnt1
);
4872 ok(hr
== S_OK
, "ret %08x\n", hr
);
4873 ok(attr_cnt1
== 3, "Attribute count should be 3 (%d)\n", attr_cnt1
);
4874 IXMLDOMNamedNodeMap_Release(mapAttr
);
4876 ok(length
!= length1
, "wrong Child count (%d, %d)\n", length
, length1
);
4877 ok(attr_cnt
== attr_cnt1
, "wrong Attribute count (%d, %d)\n", attr_cnt
, attr_cnt1
);
4878 IXMLDOMNode_Release(node_clone
);
4880 IXMLDOMNode_Release(node
);
4881 IXMLDOMDocument_Release(doc
);
4885 static void test_xmlTypes(void)
4887 IXMLDOMDocument
*doc
;
4888 IXMLDOMElement
*pRoot
;
4890 IXMLDOMComment
*pComment
;
4891 IXMLDOMElement
*pElement
;
4892 IXMLDOMAttribute
*pAttribute
;
4893 IXMLDOMNamedNodeMap
*pAttribs
;
4894 IXMLDOMCDATASection
*pCDataSec
;
4895 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
4896 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
4897 IXMLDOMEntityReference
*pEntityRef
= NULL
;
4899 IXMLDOMNode
*pNextChild
;
4903 doc
= create_document(&IID_IXMLDOMDocument
);
4905 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
4906 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4908 pNextChild
= (void*)0xdeadbeef;
4909 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
4910 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4911 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
4913 /* test previous Sibling */
4914 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
4915 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4917 pNextChild
= (void*)0xdeadbeef;
4918 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
4919 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4920 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
4922 /* test get_dataType */
4923 V_VT(&v
) = VT_EMPTY
;
4924 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
4925 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
4926 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
4929 /* test implementation */
4930 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
4931 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4933 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
4934 ok(hr
== S_OK
, "ret %08x\n", hr
);
4937 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
4938 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
4940 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
4941 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4943 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
4944 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4946 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
4947 ok(hr
== S_OK
, "ret %08x\n", hr
);
4948 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
4950 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
4951 ok(hr
== S_OK
, "ret %08x\n", hr
);
4952 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
4954 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
4955 ok(hr
== S_OK
, "ret %08x\n", hr
);
4956 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
4958 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
4959 ok(hr
== S_OK
, "ret %08x\n", hr
);
4960 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
4962 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
4963 ok(hr
== S_OK
, "ret %08x\n", hr
);
4964 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
4966 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
4967 ok(hr
== S_OK
, "ret %08x\n", hr
);
4968 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
4970 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
4971 ok(hr
== S_OK
, "ret %08x\n", hr
);
4972 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
4974 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
4975 ok(hr
== S_OK
, "ret %08x\n", hr
);
4976 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
4978 SysFreeString(sEmpty
);
4979 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
4982 pRoot
= (IXMLDOMElement
*)0x1;
4983 hr
= IXMLDOMDocument_createElement(doc
, NULL
, &pRoot
);
4984 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
4985 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
4987 pRoot
= (IXMLDOMElement
*)0x1;
4988 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(""), &pRoot
);
4989 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
4990 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
4992 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
4993 ok(hr
== S_OK
, "ret %08x\n", hr
);
4996 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
4997 ok(hr
== S_OK
, "ret %08x\n", hr
);
5001 str
= SysAllocString(szComment
);
5002 hr
= IXMLDOMDocument_createComment(doc
, str
, &pComment
);
5004 ok(hr
== S_OK
, "ret %08x\n", hr
);
5007 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
5008 ok(hr
== S_OK
, "ret %08x\n", hr
);
5010 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
5011 ok(hr
== S_OK
, "ret %08x\n", hr
);
5012 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
5015 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
5016 ok(hr
== S_OK
, "ret %08x\n", hr
);
5017 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
5020 /* put data Tests */
5021 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
5022 ok(hr
== S_OK
, "ret %08x\n", hr
);
5024 /* get data Tests */
5025 hr
= IXMLDOMComment_get_data(pComment
, &str
);
5026 ok(hr
== S_OK
, "ret %08x\n", hr
);
5027 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
5030 /* Confirm XML text is good */
5031 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
5032 ok(hr
== S_OK
, "ret %08x\n", hr
);
5033 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
5036 /* Confirm we get the put_data Text back */
5037 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5038 ok(hr
== S_OK
, "ret %08x\n", hr
);
5039 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
5042 /* test length property */
5043 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5044 ok(hr
== S_OK
, "ret %08x\n", hr
);
5045 ok(len
== 21, "expected 21 got %d\n", len
);
5047 /* test substringData */
5048 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
5049 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5051 /* test substringData - Invalid offset */
5052 str
= (BSTR
)&szElement
;
5053 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
5054 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5055 ok( str
== NULL
, "incorrect string\n");
5057 /* test substringData - Invalid offset */
5058 str
= (BSTR
)&szElement
;
5059 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
5060 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5061 ok( str
== NULL
, "incorrect string\n");
5063 /* test substringData - Invalid size */
5064 str
= (BSTR
)&szElement
;
5065 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
5066 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5067 ok( str
== NULL
, "incorrect string\n");
5069 /* test substringData - Invalid size */
5070 str
= (BSTR
)&szElement
;
5071 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
5072 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5073 ok( str
== NULL
, "incorrect string\n");
5075 /* test substringData - Start of string */
5076 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
5077 ok(hr
== S_OK
, "ret %08x\n", hr
);
5078 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
5081 /* test substringData - Middle of string */
5082 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
5083 ok(hr
== S_OK
, "ret %08x\n", hr
);
5084 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
5087 /* test substringData - End of string */
5088 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
5089 ok(hr
== S_OK
, "ret %08x\n", hr
);
5090 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
5093 /* test appendData */
5094 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
5095 ok(hr
== S_OK
, "ret %08x\n", hr
);
5097 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
5098 ok(hr
== S_OK
, "ret %08x\n", hr
);
5100 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
5101 ok(hr
== S_OK
, "ret %08x\n", hr
);
5103 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5104 ok(hr
== S_OK
, "ret %08x\n", hr
);
5105 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5108 /* test insertData */
5109 str
= SysAllocStringLen(NULL
, 0);
5110 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
5111 ok(hr
== S_OK
, "ret %08x\n", hr
);
5113 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
5114 ok(hr
== S_OK
, "ret %08x\n", hr
);
5116 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
5117 ok(hr
== S_OK
, "ret %08x\n", hr
);
5119 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
5120 ok(hr
== S_OK
, "ret %08x\n", hr
);
5122 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
5123 ok(hr
== S_OK
, "ret %08x\n", hr
);
5125 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
5126 ok(hr
== S_OK
, "ret %08x\n", hr
);
5129 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
5130 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5132 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
5133 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5135 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
5136 ok(hr
== S_OK
, "ret %08x\n", hr
);
5138 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
5139 ok(hr
== S_OK
, "ret %08x\n", hr
);
5141 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
5142 ok(hr
== S_OK
, "ret %08x\n", hr
);
5144 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5145 ok(hr
== S_OK
, "ret %08x\n", hr
);
5146 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5150 /* invalid arguments */
5151 hr
= IXMLDOMComment_deleteData(pComment
, -1, 1);
5152 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5154 hr
= IXMLDOMComment_deleteData(pComment
, 0, 0);
5155 ok(hr
== S_OK
, "ret %08x\n", hr
);
5157 hr
= IXMLDOMComment_deleteData(pComment
, 0, -1);
5158 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5160 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5161 ok(hr
== S_OK
, "ret %08x\n", hr
);
5162 ok(len
== 43, "expected 43 got %d\n", len
);
5164 hr
= IXMLDOMComment_deleteData(pComment
, len
, 1);
5165 ok(hr
== S_OK
, "ret %08x\n", hr
);
5167 hr
= IXMLDOMComment_deleteData(pComment
, len
+1, 1);
5168 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5170 /* delete from start */
5171 hr
= IXMLDOMComment_deleteData(pComment
, 0, 5);
5172 ok(hr
== S_OK
, "ret %08x\n", hr
);
5174 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5175 ok(hr
== S_OK
, "ret %08x\n", hr
);
5176 ok(len
== 38, "expected 38 got %d\n", len
);
5178 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5179 ok(hr
== S_OK
, "ret %08x\n", hr
);
5180 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5183 /* delete from end */
5184 hr
= IXMLDOMComment_deleteData(pComment
, 35, 3);
5185 ok(hr
== S_OK
, "ret %08x\n", hr
);
5187 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5188 ok(hr
== S_OK
, "ret %08x\n", hr
);
5189 ok(len
== 35, "expected 35 got %d\n", len
);
5191 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5192 ok(hr
== S_OK
, "ret %08x\n", hr
);
5193 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5196 /* delete from inside */
5197 hr
= IXMLDOMComment_deleteData(pComment
, 1, 33);
5198 ok(hr
== S_OK
, "ret %08x\n", hr
);
5200 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5201 ok(hr
== S_OK
, "ret %08x\n", hr
);
5202 ok(len
== 2, "expected 2 got %d\n", len
);
5204 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5205 ok(hr
== S_OK
, "ret %08x\n", hr
);
5206 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5209 /* delete whole data ... */
5210 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5211 ok(hr
== S_OK
, "ret %08x\n", hr
);
5213 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
5214 ok(hr
== S_OK
, "ret %08x\n", hr
);
5215 /* ... and try again with empty string */
5216 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
5217 ok(hr
== S_OK
, "ret %08x\n", hr
);
5219 /* ::replaceData() */
5221 V_BSTR(&v
) = SysAllocString(szstr1
);
5222 hr
= IXMLDOMComment_put_nodeValue(pComment
, v
);
5223 ok(hr
== S_OK
, "ret %08x\n", hr
);
5226 hr
= IXMLDOMComment_replaceData(pComment
, 6, 0, NULL
);
5227 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5228 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5229 ok(hr
== S_OK
, "ret %08x\n", hr
);
5230 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5233 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, NULL
);
5234 ok(hr
== S_OK
, "ret %08x\n", hr
);
5235 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5236 ok(hr
== S_OK
, "ret %08x\n", hr
);
5237 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5240 /* NULL pointer means delete */
5241 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, NULL
);
5242 ok(hr
== S_OK
, "ret %08x\n", hr
);
5243 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5244 ok(hr
== S_OK
, "ret %08x\n", hr
);
5245 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5248 /* empty string means delete */
5249 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_(""));
5250 ok(hr
== S_OK
, "ret %08x\n", hr
);
5251 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5252 ok(hr
== S_OK
, "ret %08x\n", hr
);
5253 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5256 /* zero count means insert */
5257 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, _bstr_("a"));
5258 ok(hr
== S_OK
, "ret %08x\n", hr
);
5259 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5260 ok(hr
== S_OK
, "ret %08x\n", hr
);
5261 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5264 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, NULL
);
5265 ok(hr
== S_OK
, "ret %08x\n", hr
);
5267 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("m"));
5268 ok(hr
== S_OK
, "ret %08x\n", hr
);
5269 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5270 ok(hr
== S_OK
, "ret %08x\n", hr
);
5271 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5274 /* nonempty string, count greater than its length */
5275 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, _bstr_("a1.2"));
5276 ok(hr
== S_OK
, "ret %08x\n", hr
);
5277 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5278 ok(hr
== S_OK
, "ret %08x\n", hr
);
5279 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5282 /* nonempty string, count less than its length */
5283 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_("wine"));
5284 ok(hr
== S_OK
, "ret %08x\n", hr
);
5285 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5286 ok(hr
== S_OK
, "ret %08x\n", hr
);
5287 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5290 IXMLDOMComment_Release(pComment
);
5294 str
= SysAllocString(szElement
);
5295 hr
= IXMLDOMDocument_createElement(doc
, str
, &pElement
);
5297 ok(hr
== S_OK
, "ret %08x\n", hr
);
5300 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
5301 ok(hr
== S_OK
, "ret %08x\n", hr
);
5303 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
5304 ok(hr
== S_OK
, "ret %08x\n", hr
);
5305 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
5308 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
5309 ok(hr
== S_OK
, "ret %08x\n", hr
);
5310 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
5314 pAttribute
= (IXMLDOMAttribute
*)0x1;
5315 hr
= IXMLDOMDocument_createAttribute(doc
, NULL
, &pAttribute
);
5316 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5317 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
5319 pAttribute
= (IXMLDOMAttribute
*)0x1;
5320 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_(""), &pAttribute
);
5321 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5322 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
5324 str
= SysAllocString(szAttribute
);
5325 hr
= IXMLDOMDocument_createAttribute(doc
, str
, &pAttribute
);
5327 ok(hr
== S_OK
, "ret %08x\n", hr
);
5330 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
5332 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, NULL
);
5333 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5335 pNextChild
= (IXMLDOMNode
*)0x1;
5336 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, &pNextChild
);
5337 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5338 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
5340 /* test Previous Sibling*/
5341 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, NULL
);
5342 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5344 pNextChild
= (IXMLDOMNode
*)0x1;
5345 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, &pNextChild
);
5346 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5347 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
5349 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttribute
, &pNewChild
);
5350 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5351 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
5353 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
5354 ok(hr
== S_OK
, "ret %08x\n", hr
);
5357 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttribute
, NULL
);
5358 ok(hr
== S_OK
, "ret %08x\n", hr
);
5360 IXMLDOMNamedNodeMap_Release(pAttribs
);
5363 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
5364 ok(hr
== S_OK
, "ret %08x\n", hr
);
5365 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
5369 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
5370 ok(hr
== S_OK
, "ret %08x\n", hr
);
5371 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
5374 /* test name property */
5375 hr
= IXMLDOMAttribute_get_name(pAttribute
, &str
);
5376 ok(hr
== S_OK
, "ret %08x\n", hr
);
5377 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
5380 hr
= IXMLDOMAttribute_get_xml(pAttribute
, &str
);
5381 ok(hr
== S_OK
, "ret %08x\n", hr
);
5382 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
5385 IXMLDOMAttribute_Release(pAttribute
);
5387 /* Check Element again with the Add Attribute*/
5388 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
5389 ok(hr
== S_OK
, "ret %08x\n", hr
);
5390 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
5394 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
5395 ok(hr
== S_OK
, "ret %08x\n", hr
);
5397 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
5398 ok(hr
== S_OK
, "ret %08x\n", hr
);
5399 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
5402 /* Test for reversible escaping */
5403 str
= SysAllocString( szStrangeChars
);
5404 hr
= IXMLDOMElement_put_text(pElement
, str
);
5405 ok(hr
== S_OK
, "ret %08x\n", hr
);
5406 SysFreeString( str
);
5408 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
5409 ok(hr
== S_OK
, "ret %08x\n", hr
);
5410 ok( !lstrcmpW( str
, szElementXML4
), "incorrect element xml\n");
5413 hr
= IXMLDOMElement_get_text(pElement
, &str
);
5414 ok(hr
== S_OK
, "ret %08x\n", hr
);
5415 ok( !lstrcmpW( str
, szStrangeChars
), "incorrect element text\n");
5418 IXMLDOMElement_Release(pElement
);
5422 str
= SysAllocString(szCData
);
5423 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, NULL
);
5424 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5426 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, &pCDataSec
);
5428 ok(hr
== S_OK
, "ret %08x\n", hr
);
5431 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
5436 hr
= IXMLDOMCDATASection_QueryInterface(pCDataSec
, &IID_IXMLDOMElement
, (void**)&pElement
);
5437 ok(hr
== E_NOINTERFACE
, "ret %08x\n", hr
);
5439 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
5440 ok(hr
== S_OK
, "ret %08x\n", hr
);
5442 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
5443 ok(hr
== S_OK
, "ret %08x\n", hr
);
5444 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
5447 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
5448 ok(hr
== S_OK
, "ret %08x\n", hr
);
5449 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
5452 /* test lastChild */
5453 pNextChild
= (IXMLDOMNode
*)0x1;
5454 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
5455 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5456 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
5458 /* put data Tests */
5459 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
5460 ok(hr
== S_OK
, "ret %08x\n", hr
);
5462 /* Confirm XML text is good */
5463 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
5464 ok(hr
== S_OK
, "ret %08x\n", hr
);
5465 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
5468 /* Confirm we get the put_data Text back */
5469 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5470 ok(hr
== S_OK
, "ret %08x\n", hr
);
5471 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
5474 /* test length property */
5475 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5476 ok(hr
== S_OK
, "ret %08x\n", hr
);
5477 ok(len
== 21, "expected 21 got %d\n", len
);
5480 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
5481 ok(hr
== S_OK
, "ret %08x\n", hr
);
5482 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
5485 /* test substringData */
5486 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
5487 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5489 /* test substringData - Invalid offset */
5490 str
= (BSTR
)&szElement
;
5491 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
5492 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5493 ok( str
== NULL
, "incorrect string\n");
5495 /* test substringData - Invalid offset */
5496 str
= (BSTR
)&szElement
;
5497 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
5498 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5499 ok( str
== NULL
, "incorrect string\n");
5501 /* test substringData - Invalid size */
5502 str
= (BSTR
)&szElement
;
5503 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
5504 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5505 ok( str
== NULL
, "incorrect string\n");
5507 /* test substringData - Invalid size */
5508 str
= (BSTR
)&szElement
;
5509 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
5510 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5511 ok( str
== NULL
, "incorrect string\n");
5513 /* test substringData - Start of string */
5514 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
5515 ok(hr
== S_OK
, "ret %08x\n", hr
);
5516 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
5519 /* test substringData - Middle of string */
5520 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
5521 ok(hr
== S_OK
, "ret %08x\n", hr
);
5522 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
5525 /* test substringData - End of string */
5526 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
5527 ok(hr
== S_OK
, "ret %08x\n", hr
);
5528 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
5531 /* test appendData */
5532 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
5533 ok(hr
== S_OK
, "ret %08x\n", hr
);
5535 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
5536 ok(hr
== S_OK
, "ret %08x\n", hr
);
5538 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
5539 ok(hr
== S_OK
, "ret %08x\n", hr
);
5541 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5542 ok(hr
== S_OK
, "ret %08x\n", hr
);
5543 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5546 /* test insertData */
5547 str
= SysAllocStringLen(NULL
, 0);
5548 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
5549 ok(hr
== S_OK
, "ret %08x\n", hr
);
5551 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
5552 ok(hr
== S_OK
, "ret %08x\n", hr
);
5554 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
5555 ok(hr
== S_OK
, "ret %08x\n", hr
);
5557 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
5558 ok(hr
== S_OK
, "ret %08x\n", hr
);
5560 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
5561 ok(hr
== S_OK
, "ret %08x\n", hr
);
5563 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
5564 ok(hr
== S_OK
, "ret %08x\n", hr
);
5567 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
5568 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5570 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
5571 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5573 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
5574 ok(hr
== S_OK
, "ret %08x\n", hr
);
5576 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
5577 ok(hr
== S_OK
, "ret %08x\n", hr
);
5579 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
5580 ok(hr
== S_OK
, "ret %08x\n", hr
);
5582 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5583 ok(hr
== S_OK
, "ret %08x\n", hr
);
5584 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5588 /* invalid arguments */
5589 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, -1, 1);
5590 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5592 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 0);
5593 ok(hr
== S_OK
, "ret %08x\n", hr
);
5595 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, -1);
5596 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5598 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5599 ok(hr
== S_OK
, "ret %08x\n", hr
);
5600 ok(len
== 43, "expected 43 got %d\n", len
);
5602 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
, 1);
5603 ok(hr
== S_OK
, "ret %08x\n", hr
);
5605 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
+1, 1);
5606 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5608 /* delete from start */
5609 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 5);
5610 ok(hr
== S_OK
, "ret %08x\n", hr
);
5612 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5613 ok(hr
== S_OK
, "ret %08x\n", hr
);
5614 ok(len
== 38, "expected 38 got %d\n", len
);
5616 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5617 ok(hr
== S_OK
, "ret %08x\n", hr
);
5618 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5621 /* delete from end */
5622 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 35, 3);
5623 ok(hr
== S_OK
, "ret %08x\n", hr
);
5625 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5626 ok(hr
== S_OK
, "ret %08x\n", hr
);
5627 ok(len
== 35, "expected 35 got %d\n", len
);
5629 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5630 ok(hr
== S_OK
, "ret %08x\n", hr
);
5631 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5634 /* delete from inside */
5635 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 1, 33);
5636 ok(hr
== S_OK
, "ret %08x\n", hr
);
5638 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5639 ok(hr
== S_OK
, "ret %08x\n", hr
);
5640 ok(len
== 2, "expected 2 got %d\n", len
);
5642 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5643 ok(hr
== S_OK
, "ret %08x\n", hr
);
5644 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5647 /* delete whole data ... */
5648 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
5649 ok(hr
== S_OK
, "ret %08x\n", hr
);
5651 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
5652 ok(hr
== S_OK
, "ret %08x\n", hr
);
5654 /* ... and try again with empty string */
5655 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
5656 ok(hr
== S_OK
, "ret %08x\n", hr
);
5658 /* ::replaceData() */
5660 V_BSTR(&v
) = SysAllocString(szstr1
);
5661 hr
= IXMLDOMCDATASection_put_nodeValue(pCDataSec
, v
);
5662 ok(hr
== S_OK
, "ret %08x\n", hr
);
5665 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 6, 0, NULL
);
5666 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5667 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5668 ok(hr
== S_OK
, "ret %08x\n", hr
);
5669 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5672 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, NULL
);
5673 ok(hr
== S_OK
, "ret %08x\n", hr
);
5674 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5675 ok(hr
== S_OK
, "ret %08x\n", hr
);
5676 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5679 /* NULL pointer means delete */
5680 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, NULL
);
5681 ok(hr
== S_OK
, "ret %08x\n", hr
);
5682 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5683 ok(hr
== S_OK
, "ret %08x\n", hr
);
5684 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5687 /* empty string means delete */
5688 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_(""));
5689 ok(hr
== S_OK
, "ret %08x\n", hr
);
5690 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5691 ok(hr
== S_OK
, "ret %08x\n", hr
);
5692 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5695 /* zero count means insert */
5696 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, _bstr_("a"));
5697 ok(hr
== S_OK
, "ret %08x\n", hr
);
5698 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5699 ok(hr
== S_OK
, "ret %08x\n", hr
);
5700 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5703 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, NULL
);
5704 ok(hr
== S_OK
, "ret %08x\n", hr
);
5706 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("m"));
5707 ok(hr
== S_OK
, "ret %08x\n", hr
);
5708 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5709 ok(hr
== S_OK
, "ret %08x\n", hr
);
5710 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5713 /* nonempty string, count greater than its length */
5714 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, _bstr_("a1.2"));
5715 ok(hr
== S_OK
, "ret %08x\n", hr
);
5716 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5717 ok(hr
== S_OK
, "ret %08x\n", hr
);
5718 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5721 /* nonempty string, count less than its length */
5722 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_("wine"));
5723 ok(hr
== S_OK
, "ret %08x\n", hr
);
5724 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
5725 ok(hr
== S_OK
, "ret %08x\n", hr
);
5726 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
5729 IXMLDOMCDATASection_Release(pCDataSec
);
5732 /* Document Fragments */
5733 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
5734 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5736 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
5737 ok(hr
== S_OK
, "ret %08x\n", hr
);
5742 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, NULL
);
5743 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5745 node
= (IXMLDOMNode
*)0x1;
5746 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, &node
);
5747 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5748 ok(node
== NULL
, "expected NULL, got %p\n", node
);
5750 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
5751 ok(hr
== S_OK
, "ret %08x\n", hr
);
5753 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
5754 ok(hr
== S_OK
, "ret %08x\n", hr
);
5755 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
5758 /* test next Sibling*/
5759 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
5760 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5762 node
= (IXMLDOMNode
*)0x1;
5763 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &node
);
5764 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5765 ok(node
== NULL
, "next sibling not NULL\n");
5767 /* test Previous Sibling*/
5768 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
5769 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5771 node
= (IXMLDOMNode
*)0x1;
5772 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &node
);
5773 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5774 ok(node
== NULL
, "previous sibling not NULL\n");
5776 IXMLDOMDocumentFragment_Release(pDocFrag
);
5779 /* Entity References */
5780 hr
= IXMLDOMDocument_createEntityReference(doc
, NULL
, &pEntityRef
);
5781 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5782 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_(""), &pEntityRef
);
5783 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5785 str
= SysAllocString(szEntityRef
);
5786 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, NULL
);
5787 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5789 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, &pEntityRef
);
5791 ok(hr
== S_OK
, "ret %08x\n", hr
);
5794 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
5795 ok(hr
== S_OK
, "ret %08x\n", hr
);
5798 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
5799 ok(hr
== S_OK
, "ret %08x\n", hr
);
5800 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
5803 IXMLDOMEntityReference_Release(pEntityRef
);
5806 IXMLDOMElement_Release( pRoot
);
5810 IXMLDOMDocument_Release(doc
);
5821 /* Type test for elements only. Name passed into put_dataType is case-insensitive.
5822 So many of the names have been changed to reflect this. */
5823 static put_datatype_t put_datatype_data
[] = {
5824 { "test_inval", "abcdefg", E_FAIL
},
5825 { "test_bool", "Boolean", S_OK
},
5826 { "test_string", "String", S_OK
},
5827 { "test_number", "number", S_OK
},
5828 { "test_int", "InT", S_OK
},
5829 { "test_fixed", "fixed.14.4", S_OK
},
5830 { "test_datetime", "DateTime", S_OK
},
5831 { "test_datetimetz", "DateTime.tz", S_OK
},
5832 { "test_date", "Date", S_OK
},
5833 { "test_time", "Time", S_OK
},
5834 { "test_timetz", "Time.tz", S_OK
},
5835 { "test_I1", "I1", S_OK
},
5836 { "test_I2", "I2", S_OK
},
5837 { "test_I4", "I4", S_OK
},
5838 { "test_UI1", "UI1", S_OK
},
5839 { "test_UI2", "UI2", S_OK
},
5840 { "test_UI4", "UI4", S_OK
},
5841 { "test_r4", "r4", S_OK
},
5842 { "test_r8", "r8", S_OK
},
5843 { "test_float", "float", S_OK
},
5844 { "test_uuid", "UuId", S_OK
},
5845 { "test_binhex", "bin.hex", S_OK
},
5846 { "test_binbase64", "bin.base64", S_OK
},
5853 } put_datatype_notype_t
;
5855 static put_datatype_notype_t put_dt_notype
[] = {
5856 { NODE_PROCESSING_INSTRUCTION
, E_FAIL
},
5857 { NODE_DOCUMENT_FRAGMENT
, E_FAIL
},
5858 { NODE_ENTITY_REFERENCE
, E_FAIL
},
5859 { NODE_CDATA_SECTION
, E_FAIL
},
5860 { NODE_COMMENT
, E_FAIL
},
5864 static void test_put_dataType( void )
5866 const put_datatype_notype_t
*ptr2
= put_dt_notype
;
5867 const put_datatype_t
*ptr
= put_datatype_data
;
5868 IXMLDOMElement
*root
, *element
;
5869 BSTR nameW
, type1W
, type2W
;
5870 IXMLDOMDocument
*doc
;
5873 doc
= create_document(&IID_IXMLDOMDocument
);
5875 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), NULL
);
5876 EXPECT_HR(hr
, E_INVALIDARG
);
5878 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &root
);
5879 EXPECT_HR(hr
, S_OK
);
5881 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)root
, NULL
);
5882 EXPECT_HR(hr
, S_OK
);
5884 hr
= IXMLDOMElement_put_dataType(root
, NULL
);
5885 EXPECT_HR(hr
, E_INVALIDARG
);
5889 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(ptr
->name
), &element
);
5890 EXPECT_HR(hr
, S_OK
);
5893 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)element
, NULL
);
5894 EXPECT_HR(hr
, S_OK
);
5896 hr
= IXMLDOMElement_put_dataType(element
, _bstr_(ptr
->type
));
5897 ok(hr
== ptr
->hr
, "failed for %s:%s, 0x%08x\n", ptr
->name
, ptr
->type
, ptr
->hr
);
5899 IXMLDOMElement_Release(element
);
5904 /* check changing types */
5905 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &element
);
5906 EXPECT_HR(hr
, S_OK
);
5908 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)element
, NULL
);
5909 EXPECT_HR(hr
, S_OK
);
5911 hr
= IXMLDOMElement_put_dataType(element
, _bstr_("DateTime.tz"));
5912 EXPECT_HR(hr
, S_OK
);
5914 hr
= IXMLDOMElement_put_dataType(element
, _bstr_("string"));
5915 EXPECT_HR(hr
, S_OK
);
5917 IXMLDOMElement_Release(element
);
5919 /* try to set type for node without a type */
5920 nameW
= _bstr_("testname");
5921 type1W
= _bstr_("string");
5922 type2W
= _bstr_("number");
5923 while (ptr2
->type
!= NODE_INVALID
)
5928 V_VT(&type
) = VT_I2
;
5929 V_I2(&type
) = ptr2
->type
;
5931 hr
= IXMLDOMDocument_createNode(doc
, type
, nameW
, NULL
, &node
);
5932 EXPECT_HR(hr
, S_OK
);
5935 hr
= IXMLDOMElement_appendChild(root
, node
, NULL
);
5936 EXPECT_HR(hr
, S_OK
);
5938 hr
= IXMLDOMNode_put_dataType(node
, NULL
);
5939 EXPECT_HR(hr
, E_INVALIDARG
);
5941 hr
= IXMLDOMNode_put_dataType(node
, type1W
);
5942 ok(hr
== ptr2
->hr
, "failed for type %d, 0x%08x\n", ptr2
->type
, ptr
->hr
);
5943 hr
= IXMLDOMNode_put_dataType(node
, type2W
);
5944 ok(hr
== ptr2
->hr
, "failed for type %d, 0x%08x\n", ptr2
->type
, ptr
->hr
);
5946 IXMLDOMNode_Release(node
);
5951 IXMLDOMElement_Release(root
);
5952 IXMLDOMDocument_Release(doc
);
5956 static void test_save(void)
5958 IXMLDOMDocument
*doc
, *doc2
;
5959 IXMLDOMElement
*root
;
5960 BSTR sOrig
, sNew
, filename
;
5971 doc
= create_document(&IID_IXMLDOMDocument
);
5972 doc2
= create_document(&IID_IXMLDOMDocument
);
5974 /* save to IXMLDOMDocument */
5975 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &root
);
5976 EXPECT_HR(hr
, S_OK
);
5978 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)root
, NULL
);
5979 EXPECT_HR(hr
, S_OK
);
5981 V_VT(&dest
) = VT_UNKNOWN
;
5982 V_UNKNOWN(&dest
) = (IUnknown
*)doc2
;
5984 hr
= IXMLDOMDocument_save(doc
, dest
);
5985 EXPECT_HR(hr
, S_OK
);
5987 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
5988 EXPECT_HR(hr
, S_OK
);
5990 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
5991 EXPECT_HR(hr
, S_OK
);
5993 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as original\n");
5995 SysFreeString(sOrig
);
5996 SysFreeString(sNew
);
5998 IXMLDOMElement_Release(root
);
5999 IXMLDOMDocument_Release(doc2
);
6002 V_VT(&dest
) = VT_BSTR
;
6003 V_BSTR(&dest
) = _bstr_("test.xml");
6005 hr
= IXMLDOMDocument_save(doc
, dest
);
6006 EXPECT_HR(hr
, S_OK
);
6008 hfile
= CreateFileA("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6009 ok(hfile
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
6010 if(hfile
== INVALID_HANDLE_VALUE
) return;
6012 ReadFile(hfile
, buffer
, sizeof(buffer
), &read
, NULL
);
6013 ok(read
!= 0, "could not read file\n");
6014 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
6017 DeleteFileA("test.xml");
6019 /* save to path VT_BSTR | VT_BYREF */
6020 filename
= _bstr_("test.xml");
6021 V_VT(&dest
) = VT_BSTR
| VT_BYREF
;
6022 V_BSTRREF(&dest
) = &filename
;
6024 hr
= IXMLDOMDocument_save(doc
, dest
);
6025 EXPECT_HR(hr
, S_OK
);
6027 hfile
= CreateFileA("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6028 ok(hfile
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
6029 if(hfile
== INVALID_HANDLE_VALUE
) return;
6031 if (hfile
!= INVALID_HANDLE_VALUE
)
6033 ReadFile(hfile
, buffer
, sizeof(buffer
), &read
, NULL
);
6034 ok(read
!= 0, "could not read file\n");
6035 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
6038 DeleteFileA("test.xml");
6041 /* save to stream */
6042 V_VT(&dest
) = VT_UNKNOWN
;
6043 V_UNKNOWN(&dest
) = (IUnknown
*)&savestream
;
6045 hr
= IXMLDOMDocument_save(doc
, dest
);
6046 EXPECT_HR(hr
, S_OK
);
6048 /* loaded data contains xml declaration */
6049 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(win1252xml
), &b
);
6050 EXPECT_HR(hr
, S_OK
);
6052 CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
6053 V_VT(&dest
) = VT_UNKNOWN
;
6054 V_UNKNOWN(&dest
) = (IUnknown
*)stream
;
6055 hr
= IXMLDOMDocument_save(doc
, dest
);
6056 EXPECT_HR(hr
, S_OK
);
6058 hr
= GetHGlobalFromStream(stream
, &global
);
6059 EXPECT_HR(hr
, S_OK
);
6060 ptr
= GlobalLock(global
);
6061 ok(!memcmp(ptr
, win1252decl
, strlen(win1252decl
)), "got wrong xml declaration\n");
6062 GlobalUnlock(global
);
6063 IStream_Release(stream
);
6065 /* loaded data without xml declaration */
6066 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_("<a/>"), &b
);
6067 EXPECT_HR(hr
, S_OK
);
6069 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
6070 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6071 V_VT(&dest
) = VT_UNKNOWN
;
6072 V_UNKNOWN(&dest
) = (IUnknown
*)stream
;
6073 hr
= IXMLDOMDocument_save(doc
, dest
);
6074 EXPECT_HR(hr
, S_OK
);
6076 hr
= GetHGlobalFromStream(stream
, &global
);
6077 EXPECT_HR(hr
, S_OK
);
6078 ptr
= GlobalLock(global
);
6079 ok(ptr
[0] == '<' && ptr
[1] != '?', "got wrong start tag %c%c\n", ptr
[0], ptr
[1]);
6080 GlobalUnlock(global
);
6081 IStream_Release(stream
);
6083 IXMLDOMDocument_Release(doc
);
6087 static void test_testTransforms(void)
6089 IXMLDOMDocument
*doc
, *docSS
;
6094 doc
= create_document(&IID_IXMLDOMDocument
);
6095 docSS
= create_document(&IID_IXMLDOMDocument
);
6097 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
6098 ok(hr
== S_OK
, "ret %08x\n", hr
);
6100 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
6101 ok(hr
== S_OK
, "ret %08x\n", hr
);
6103 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (void**)&pNode
);
6104 ok(hr
== S_OK
, "ret %08x\n", hr
);
6109 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
6110 ok(hr
== S_OK
, "ret %08x\n", hr
);
6113 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "got output %s\n", wine_dbgstr_w(bOut
));
6114 SysFreeString(bOut
);
6117 IXMLDOMNode_Release(pNode
);
6120 IXMLDOMDocument_Release(docSS
);
6121 IXMLDOMDocument_Release(doc
);
6126 struct namespaces_change_t
{
6131 static const struct namespaces_change_t namespaces_change_test_data
[] = {
6132 { &CLSID_DOMDocument
, "CLSID_DOMDocument" },
6133 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2" },
6134 { &CLSID_DOMDocument26
, "CLSID_DOMDocument26" },
6135 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30" },
6136 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40" },
6137 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60" },
6141 static void test_namespaces_change(void)
6143 const struct namespaces_change_t
*class_ptr
= namespaces_change_test_data
;
6145 while (class_ptr
->clsid
)
6147 IXMLDOMDocument
*doc
= NULL
;
6148 IXMLDOMElement
*elem
= NULL
;
6149 IXMLDOMNode
*node
= NULL
;
6155 if (!is_clsid_supported(class_ptr
->clsid
, &IID_IXMLDOMDocument
))
6161 hr
= CoCreateInstance(class_ptr
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
6162 &IID_IXMLDOMDocument
, (void**)&doc
);
6163 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6166 V_I2(&var
) = NODE_ELEMENT
;
6168 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("ns:elem"), _bstr_("ns/uri"), &node
);
6169 EXPECT_HR(hr
, S_OK
);
6171 hr
= IXMLDOMDocument_appendChild(doc
, node
, NULL
);
6172 EXPECT_HR(hr
, S_OK
);
6174 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
6175 EXPECT_HR(hr
, S_OK
);
6177 /* try same prefix, different uri */
6178 V_VT(&var
) = VT_BSTR
;
6179 V_BSTR(&var
) = _bstr_("ns/uri2");
6181 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("xmlns:ns"), var
);
6182 EXPECT_HR(hr
, E_INVALIDARG
);
6184 /* try same prefix and uri */
6185 V_VT(&var
) = VT_BSTR
;
6186 V_BSTR(&var
) = _bstr_("ns/uri");
6188 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("xmlns:ns"), var
);
6189 EXPECT_HR(hr
, S_OK
);
6191 hr
= IXMLDOMElement_get_xml(elem
, &str
);
6192 EXPECT_HR(hr
, S_OK
);
6193 ok(!lstrcmpW(str
, _bstr_("<ns:elem xmlns:ns=\"ns/uri\"/>")), "got element %s for %s\n",
6194 wine_dbgstr_w(str
), class_ptr
->name
);
6197 IXMLDOMElement_Release(elem
);
6198 IXMLDOMDocument_Release(doc
);
6206 static void test_namespaces_basic(void)
6208 static const CHAR namespaces_xmlA
[] =
6209 "<?xml version=\"1.0\"?>\n"
6210 "<XMI xmi.version=\"1.1\" xmlns:Model=\"http://omg.org/mof.Model/1.3\">"
6212 " <Model:Package name=\"WinePackage\" Model:name2=\"name2 attr\" />"
6216 IXMLDOMDocument
*doc
;
6217 IXMLDOMElement
*elem
;
6224 doc
= create_document(&IID_IXMLDOMDocument
);
6226 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(namespaces_xmlA
), &b
);
6227 EXPECT_HR(hr
, S_OK
);
6228 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
6230 str
= (BSTR
)0xdeadbeef;
6231 hr
= IXMLDOMDocument_get_namespaceURI(doc
, &str
);
6232 EXPECT_HR(hr
, S_FALSE
);
6233 ok(str
== NULL
, "got %p\n", str
);
6235 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("//XMI.content"), &node
);
6236 EXPECT_HR(hr
, S_OK
);
6239 IXMLDOMAttribute
*attr
;
6242 hr
= IXMLDOMNode_get_firstChild(node
, &node2
);
6243 EXPECT_HR(hr
, S_OK
);
6244 ok(node2
!= NULL
, "got %p\n", node2
);
6246 /* Test get_prefix */
6247 hr
= IXMLDOMNode_get_prefix(node2
, NULL
);
6248 EXPECT_HR(hr
, E_INVALIDARG
);
6249 /* NOTE: Need to test that arg2 gets cleared on Error. */
6251 hr
= IXMLDOMNode_get_prefix(node2
, &str
);
6252 EXPECT_HR(hr
, S_OK
);
6253 ok( !lstrcmpW( str
, _bstr_("Model")), "got %s\n", wine_dbgstr_w(str
));
6256 hr
= IXMLDOMNode_get_nodeName(node2
, &str
);
6257 EXPECT_HR(hr
, S_OK
);
6258 ok(!lstrcmpW( str
, _bstr_("Model:Package")), "got %s\n", wine_dbgstr_w(str
));
6261 /* Test get_namespaceURI */
6262 hr
= IXMLDOMNode_get_namespaceURI(node2
, NULL
);
6263 EXPECT_HR(hr
, E_INVALIDARG
);
6264 /* NOTE: Need to test that arg2 gets cleared on Error. */
6266 hr
= IXMLDOMNode_get_namespaceURI(node2
, &str
);
6267 EXPECT_HR(hr
, S_OK
);
6268 ok(!lstrcmpW( str
, _bstr_("http://omg.org/mof.Model/1.3")), "got %s\n", wine_dbgstr_w(str
));
6271 hr
= IXMLDOMNode_QueryInterface(node2
, &IID_IXMLDOMElement
, (void**)&elem
);
6272 EXPECT_HR(hr
, S_OK
);
6274 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("Model:name2"), &attr
);
6275 EXPECT_HR(hr
, S_OK
);
6277 hr
= IXMLDOMAttribute_get_nodeName(attr
, &str
);
6278 EXPECT_HR(hr
, S_OK
);
6279 ok(!lstrcmpW( str
, _bstr_("Model:name2")), "got %s\n", wine_dbgstr_w(str
));
6282 hr
= IXMLDOMAttribute_get_prefix(attr
, &str
);
6283 EXPECT_HR(hr
, S_OK
);
6284 ok(!lstrcmpW( str
, _bstr_("Model")), "got %s\n", wine_dbgstr_w(str
));
6287 IXMLDOMAttribute_Release(attr
);
6288 IXMLDOMElement_Release(elem
);
6290 IXMLDOMNode_Release(node2
);
6291 IXMLDOMNode_Release(node
);
6294 IXMLDOMDocument_Release(doc
);
6299 static void test_FormattingXML(void)
6301 IXMLDOMDocument
*doc
;
6302 IXMLDOMElement
*pElement
;
6306 static const CHAR szLinefeedXML
[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
6307 static const CHAR szLinefeedRootXML
[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
6309 doc
= create_document(&IID_IXMLDOMDocument
);
6311 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szLinefeedXML
), &bSucc
);
6312 ok(hr
== S_OK
, "ret %08x\n", hr
);
6313 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
6315 if(bSucc
== VARIANT_TRUE
)
6317 hr
= IXMLDOMDocument_get_documentElement(doc
, &pElement
);
6318 ok(hr
== S_OK
, "ret %08x\n", hr
);
6321 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
6322 ok(hr
== S_OK
, "ret %08x\n", hr
);
6323 ok( !lstrcmpW( str
, _bstr_(szLinefeedRootXML
) ), "incorrect element xml\n");
6326 IXMLDOMElement_Release(pElement
);
6330 IXMLDOMDocument_Release(doc
);
6335 typedef struct _nodetypedvalue_t
{
6338 const char *value
; /* value in string format */
6341 static const nodetypedvalue_t get_nodetypedvalue
[] = {
6342 { "root/string", VT_BSTR
, "Wine" },
6343 { "root/string2", VT_BSTR
, "String" },
6344 { "root/number", VT_BSTR
, "12.44" },
6345 { "root/number2", VT_BSTR
, "-3.71e3" },
6346 { "root/int", VT_I4
, "-13" },
6347 { "root/fixed", VT_CY
, "7322.9371" },
6348 { "root/bool", VT_BOOL
, "-1" },
6349 { "root/datetime", VT_DATE
, "40135.14" },
6350 { "root/datetimetz",VT_DATE
, "37813.59" },
6351 { "root/date", VT_DATE
, "665413" },
6352 { "root/time", VT_DATE
, "0.5813889" },
6353 { "root/timetz", VT_DATE
, "1.112512" },
6354 { "root/i1", VT_I1
, "-13" },
6355 { "root/i2", VT_I2
, "31915" },
6356 { "root/i4", VT_I4
, "-312232" },
6357 { "root/ui1", VT_UI1
, "123" },
6358 { "root/ui2", VT_UI2
, "48282" },
6359 { "root/ui4", VT_UI4
, "949281" },
6360 { "root/r4", VT_R4
, "213124" },
6361 { "root/r8", VT_R8
, "0.412" },
6362 { "root/float", VT_R8
, "41221.421" },
6363 { "root/uuid", VT_BSTR
, "333C7BC4-460F-11D0-BC04-0080C7055a83" },
6364 { "root/binbase64", VT_ARRAY
|VT_UI1
, "base64 test" },
6365 { "root/binbase64_1", VT_ARRAY
|VT_UI1
, "base64 test" },
6366 { "root/binbase64_2", VT_ARRAY
|VT_UI1
, "base64 test" },
6370 static void test_nodeTypedValue(void)
6372 const nodetypedvalue_t
*entry
= get_nodetypedvalue
;
6373 IXMLDOMDocumentType
*doctype
, *doctype2
;
6374 IXMLDOMProcessingInstruction
*pi
;
6375 IXMLDOMDocumentFragment
*frag
;
6376 IXMLDOMDocument
*doc
, *doc2
;
6377 IXMLDOMCDATASection
*cdata
;
6378 IXMLDOMComment
*comment
;
6384 doc
= create_document(&IID_IXMLDOMDocument
);
6387 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTypeValueXML
), &b
);
6388 ok(hr
== S_OK
, "ret %08x\n", hr
);
6389 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
6391 hr
= IXMLDOMDocument_get_nodeValue(doc
, NULL
);
6392 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6394 V_VT(&value
) = VT_BSTR
;
6395 V_BSTR(&value
) = NULL
;
6396 hr
= IXMLDOMDocument_get_nodeValue(doc
, &value
);
6397 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6398 ok(V_VT(&value
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&value
));
6400 hr
= IXMLDOMDocument_get_nodeTypedValue(doc
, NULL
);
6401 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6403 V_VT(&value
) = VT_EMPTY
;
6404 hr
= IXMLDOMDocument_get_nodeTypedValue(doc
, &value
);
6405 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6406 ok(V_VT(&value
) == VT_NULL
, "got %d\n", V_VT(&value
));
6408 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/string"), &node
);
6409 ok(hr
== S_OK
, "ret %08x\n", hr
);
6411 V_VT(&value
) = VT_BSTR
;
6412 V_BSTR(&value
) = NULL
;
6413 hr
= IXMLDOMNode_get_nodeValue(node
, &value
);
6414 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6415 ok(V_VT(&value
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&value
));
6417 hr
= IXMLDOMNode_get_nodeTypedValue(node
, NULL
);
6418 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6420 IXMLDOMNode_Release(node
);
6422 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/binhex"), &node
);
6423 ok(hr
== S_OK
, "ret %08x\n", hr
);
6425 BYTE bytes
[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
6427 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
6428 ok(hr
== S_OK
, "ret %08x\n", hr
);
6429 ok(V_VT(&value
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
6430 ok(V_ARRAY(&value
)->rgsabound
[0].cElements
== 6, "incorrect array size\n");
6431 if(V_ARRAY(&value
)->rgsabound
[0].cElements
== 6)
6432 ok(!memcmp(bytes
, V_ARRAY(&value
)->pvData
, sizeof(bytes
)), "incorrect value\n");
6433 VariantClear(&value
);
6434 IXMLDOMNode_Release(node
);
6437 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("foo"), _bstr_("value"), &pi
);
6438 ok(hr
== S_OK
, "ret %08x\n", hr
);
6440 V_VT(&value
) = VT_NULL
;
6441 V_BSTR(&value
) = (void*)0xdeadbeef;
6442 hr
= IXMLDOMProcessingInstruction_get_nodeTypedValue(pi
, &value
);
6443 ok(hr
== S_OK
, "ret %08x\n", hr
);
6444 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
6445 ok(!lstrcmpW(V_BSTR(&value
), _bstr_("value")), "got wrong value\n");
6446 IXMLDOMProcessingInstruction_Release(pi
);
6447 VariantClear(&value
);
6450 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("[1]*2=3; &gee that's not right!"), &cdata
);
6451 ok(hr
== S_OK
, "ret %08x\n", hr
);
6453 V_VT(&value
) = VT_NULL
;
6454 V_BSTR(&value
) = (void*)0xdeadbeef;
6455 hr
= IXMLDOMCDATASection_get_nodeTypedValue(cdata
, &value
);
6456 ok(hr
== S_OK
, "ret %08x\n", hr
);
6457 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
6458 ok(!lstrcmpW(V_BSTR(&value
), _bstr_("[1]*2=3; &gee that's not right!")), "got wrong value\n");
6459 IXMLDOMCDATASection_Release(cdata
);
6460 VariantClear(&value
);
6463 hr
= IXMLDOMDocument_createComment(doc
, _bstr_("comment"), &comment
);
6464 ok(hr
== S_OK
, "ret %08x\n", hr
);
6466 V_VT(&value
) = VT_NULL
;
6467 V_BSTR(&value
) = (void*)0xdeadbeef;
6468 hr
= IXMLDOMComment_get_nodeTypedValue(comment
, &value
);
6469 ok(hr
== S_OK
, "ret %08x\n", hr
);
6470 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
6471 ok(!lstrcmpW(V_BSTR(&value
), _bstr_("comment")), "got wrong value\n");
6472 IXMLDOMComment_Release(comment
);
6473 VariantClear(&value
);
6476 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &frag
);
6477 ok(hr
== S_OK
, "ret %08x\n", hr
);
6479 V_VT(&value
) = VT_EMPTY
;
6480 hr
= IXMLDOMDocumentFragment_get_nodeTypedValue(frag
, &value
);
6481 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6482 ok(V_VT(&value
) == VT_NULL
, "got %d\n", V_VT(&value
));
6483 IXMLDOMDocumentFragment_Release(frag
);
6486 doc2
= create_document(&IID_IXMLDOMDocument
);
6489 hr
= IXMLDOMDocument_loadXML(doc2
, _bstr_(szEmailXML
), &b
);
6490 ok(hr
== S_OK
, "ret %08x\n", hr
);
6491 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
6493 EXPECT_REF(doc2
, 1);
6495 hr
= IXMLDOMDocument_get_doctype(doc2
, &doctype
);
6496 ok(hr
== S_OK
, "ret %08x\n", hr
);
6498 EXPECT_REF(doc2
, 1);
6499 todo_wine
EXPECT_REF(doctype
, 2);
6502 V_VT(&value
) = VT_EMPTY
;
6503 hr
= IXMLDOMDocumentType_get_nodeTypedValue(doctype
, &value
);
6504 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6505 ok(V_VT(&value
) == VT_NULL
, "got %d\n", V_VT(&value
));
6508 hr
= IXMLDOMDocument_get_doctype(doc2
, &doctype2
);
6509 ok(hr
== S_OK
, "ret %08x\n", hr
);
6510 ok(doctype
!= doctype2
, "got %p, was %p\n", doctype2
, doctype
);
6512 IXMLDOMDocumentType_Release(doctype2
);
6513 IXMLDOMDocumentType_Release(doctype
);
6515 IXMLDOMDocument_Release(doc2
);
6519 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_(entry
->name
), &node
);
6520 ok(hr
== S_OK
, "ret %08x\n", hr
);
6522 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
6523 ok(hr
== S_OK
, "ret %08x\n", hr
);
6524 ok(V_VT(&value
) == entry
->type
, "incorrect type, expected %d, got %d\n", entry
->type
, V_VT(&value
));
6526 if (entry
->type
== (VT_ARRAY
|VT_UI1
))
6528 ok(V_ARRAY(&value
)->rgsabound
[0].cElements
== strlen(entry
->value
),
6529 "incorrect array size %d\n", V_ARRAY(&value
)->rgsabound
[0].cElements
);
6532 if (entry
->type
!= VT_BSTR
)
6534 if (entry
->type
== VT_DATE
||
6535 entry
->type
== VT_R8
||
6536 entry
->type
== VT_CY
)
6538 if (entry
->type
== VT_DATE
)
6540 hr
= VariantChangeType(&value
, &value
, 0, VT_R4
);
6541 ok(hr
== S_OK
, "ret %08x\n", hr
);
6543 hr
= VariantChangeTypeEx(&value
, &value
,
6544 MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
),
6545 VARIANT_NOUSEROVERRIDE
, VT_BSTR
);
6546 ok(hr
== S_OK
, "ret %08x\n", hr
);
6550 hr
= VariantChangeType(&value
, &value
, 0, VT_BSTR
);
6551 ok(hr
== S_OK
, "ret %08x\n", hr
);
6554 /* for byte array from VT_ARRAY|VT_UI1 it's not a WCHAR buffer */
6555 if (entry
->type
== (VT_ARRAY
|VT_UI1
))
6557 ok(!memcmp( V_BSTR(&value
), entry
->value
, strlen(entry
->value
)),
6558 "expected %s\n", entry
->value
);
6561 ok(lstrcmpW( V_BSTR(&value
), _bstr_(entry
->value
)) == 0,
6562 "expected %s, got %s\n", entry
->value
, wine_dbgstr_w(V_BSTR(&value
)));
6565 ok(lstrcmpW( V_BSTR(&value
), _bstr_(entry
->value
)) == 0,
6566 "expected %s, got %s\n", entry
->value
, wine_dbgstr_w(V_BSTR(&value
)));
6568 VariantClear( &value
);
6569 IXMLDOMNode_Release(node
);
6574 IXMLDOMDocument_Release(doc
);
6578 static void test_TransformWithLoadingLocalFile(void)
6580 IXMLDOMDocument
*doc
;
6581 IXMLDOMDocument
*xsl
;
6587 char lpPathBuffer
[MAX_PATH
];
6590 /* Create a Temp File. */
6591 GetTempPathA(MAX_PATH
, lpPathBuffer
);
6592 strcat(lpPathBuffer
, "customers.xml" );
6594 file
= CreateFileA(lpPathBuffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6595 ok(file
!= INVALID_HANDLE_VALUE
, "Could not create file: %u\n", GetLastError());
6596 if(file
== INVALID_HANDLE_VALUE
)
6599 WriteFile(file
, szBasicTransformXML
, strlen(szBasicTransformXML
), &dwWritten
, NULL
);
6602 /* Correct path to not include an escape character. */
6603 for(i
=0; i
< strlen(lpPathBuffer
); i
++)
6605 if(lpPathBuffer
[i
] == '\\')
6606 lpPathBuffer
[i
] = '/';
6609 doc
= create_document(&IID_IXMLDOMDocument
);
6610 xsl
= create_document(&IID_IXMLDOMDocument
);
6612 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
6613 ok(hr
== S_OK
, "ret %08x\n", hr
);
6614 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
6615 if(bSucc
== VARIANT_TRUE
)
6618 BSTR sPart1
= _bstr_(szBasicTransformSSXMLPart1
);
6619 BSTR sPart2
= _bstr_(szBasicTransformSSXMLPart2
);
6620 BSTR sFileName
= _bstr_(lpPathBuffer
);
6621 int nLegnth
= lstrlenW(sPart1
) + lstrlenW(sPart2
) + lstrlenW(sFileName
) + 1;
6623 sXSL
= SysAllocStringLen(NULL
, nLegnth
);
6624 lstrcpyW(sXSL
, sPart1
);
6625 lstrcatW(sXSL
, sFileName
);
6626 lstrcatW(sXSL
, sPart2
);
6628 hr
= IXMLDOMDocument_loadXML(xsl
, sXSL
, &bSucc
);
6629 ok(hr
== S_OK
, "ret %08x\n", hr
);
6630 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
6631 if(bSucc
== VARIANT_TRUE
)
6635 hr
= IXMLDOMDocument_QueryInterface(xsl
, &IID_IXMLDOMNode
, (void**)&pNode
);
6636 ok(hr
== S_OK
, "ret %08x\n", hr
);
6639 /* This will load the temp file via the XSL */
6640 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &sResult
);
6641 ok(hr
== S_OK
, "ret %08x\n", hr
);
6644 ok( compareIgnoreReturns( sResult
, _bstr_(szBasicTransformOutput
)), "Stylesheet output not correct\n");
6645 SysFreeString(sResult
);
6648 IXMLDOMNode_Release(pNode
);
6652 SysFreeString(sXSL
);
6655 IXMLDOMDocument_Release(doc
);
6656 IXMLDOMDocument_Release(xsl
);
6658 DeleteFileA(lpPathBuffer
);
6662 static void test_put_nodeValue(void)
6664 static const WCHAR jeevesW
[] = {'J','e','e','v','e','s',' ','&',' ','W','o','o','s','t','e','r',0};
6665 IXMLDOMDocument
*doc
;
6667 IXMLDOMEntityReference
*entityref
;
6668 IXMLDOMAttribute
*attr
;
6673 doc
= create_document(&IID_IXMLDOMDocument
);
6675 /* test for unsupported types */
6677 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&node
);
6678 ok(hr
== S_OK
, "ret %08x\n", hr
);
6679 V_VT(&data
) = VT_BSTR
;
6680 V_BSTR(&data
) = _bstr_("one two three");
6681 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6682 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6683 IXMLDOMNode_Release(node
);
6685 /* NODE_DOCUMENT_FRAGMENT */
6686 V_VT(&type
) = VT_I1
;
6687 V_I1(&type
) = NODE_DOCUMENT_FRAGMENT
;
6688 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
6689 ok(hr
== S_OK
, "ret %08x\n", hr
);
6690 V_VT(&data
) = VT_BSTR
;
6691 V_BSTR(&data
) = _bstr_("one two three");
6692 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6693 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6694 IXMLDOMNode_Release(node
);
6697 V_VT(&type
) = VT_I1
;
6698 V_I1(&type
) = NODE_ELEMENT
;
6699 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
6700 ok(hr
== S_OK
, "ret %08x\n", hr
);
6701 V_VT(&data
) = VT_BSTR
;
6702 V_BSTR(&data
) = _bstr_("one two three");
6703 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6704 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6705 IXMLDOMNode_Release(node
);
6707 /* NODE_ENTITY_REFERENCE */
6708 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_("ref"), &entityref
);
6709 ok(hr
== S_OK
, "ret %08x\n", hr
);
6711 V_VT(&data
) = VT_BSTR
;
6712 V_BSTR(&data
) = _bstr_("one two three");
6713 hr
= IXMLDOMEntityReference_put_nodeValue(entityref
, data
);
6714 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6716 hr
= IXMLDOMEntityReference_QueryInterface(entityref
, &IID_IXMLDOMNode
, (void**)&node
);
6717 ok(hr
== S_OK
, "ret %08x\n", hr
);
6718 V_VT(&data
) = VT_BSTR
;
6719 V_BSTR(&data
) = _bstr_("one two three");
6720 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
6721 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6722 IXMLDOMNode_Release(node
);
6723 IXMLDOMEntityReference_Release(entityref
);
6725 /* supported types */
6726 hr
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &text
);
6727 ok(hr
== S_OK
, "ret %08x\n", hr
);
6728 V_VT(&data
) = VT_BSTR
;
6729 V_BSTR(&data
) = _bstr_("Jeeves & Wooster");
6730 hr
= IXMLDOMText_put_nodeValue(text
, data
);
6731 ok(hr
== S_OK
, "ret %08x\n", hr
);
6732 IXMLDOMText_Release(text
);
6734 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
6735 ok(hr
== S_OK
, "ret %08x\n", hr
);
6736 V_VT(&data
) = VT_BSTR
;
6737 V_BSTR(&data
) = _bstr_("Jeeves & Wooster");
6738 hr
= IXMLDOMAttribute_put_nodeValue(attr
, data
);
6739 ok(hr
== S_OK
, "ret %08x\n", hr
);
6740 hr
= IXMLDOMAttribute_get_nodeValue(attr
, &data
);
6741 ok(hr
== S_OK
, "ret %08x\n", hr
);
6742 ok(memcmp(V_BSTR(&data
), jeevesW
, sizeof(jeevesW
)) == 0, "got %s\n",
6743 wine_dbgstr_w(V_BSTR(&data
)));
6744 VariantClear(&data
);
6745 IXMLDOMAttribute_Release(attr
);
6749 IXMLDOMDocument_Release(doc
);
6752 static void test_IObjectSafety(void)
6754 IXMLDOMDocument
*doc
;
6755 IObjectSafety
*safety
;
6758 doc
= create_document(&IID_IXMLDOMDocument
);
6760 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IObjectSafety
, (void**)&safety
);
6761 ok(hr
== S_OK
, "ret %08x\n", hr
);
6763 test_IObjectSafety_common(safety
);
6765 IObjectSafety_Release(safety
);
6766 IXMLDOMDocument_Release(doc
);
6768 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
6769 &IID_IObjectSafety
, (void**)&safety
);
6770 ok(hr
== S_OK
, "Could not create XMLHTTPRequest instance: %08x\n", hr
);
6772 test_IObjectSafety_common(safety
);
6774 IObjectSafety_Release(safety
);
6778 typedef struct _property_test_t
{
6781 const char *property
;
6785 static const property_test_t properties_test_data
[] = {
6786 { &CLSID_DOMDocument
, "CLSID_DOMDocument" , "SelectionLanguage", "XSLPattern" },
6787 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2" , "SelectionLanguage", "XSLPattern" },
6788 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", "SelectionLanguage", "XSLPattern" },
6789 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", "SelectionLanguage", "XPath" },
6790 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", "SelectionLanguage", "XPath" },
6794 static void test_default_properties(void)
6796 const property_test_t
*entry
= properties_test_data
;
6800 IXMLDOMDocument2
*doc
;
6804 if (!is_clsid_supported(entry
->guid
, &IID_IXMLDOMDocument2
))
6810 hr
= CoCreateInstance(entry
->guid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (void**)&doc
);
6811 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6813 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_(entry
->property
), &var
);
6814 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
6815 ok(lstrcmpW(V_BSTR(&var
), _bstr_(entry
->value
)) == 0, "expected %s, for %s\n",
6816 entry
->value
, entry
->clsid
);
6819 IXMLDOMDocument2_Release(doc
);
6829 } xslpattern_test_t
;
6831 static const xslpattern_test_t xslpattern_test
[] = {
6832 { "root//elem[0]", "E1.E2.D1" },
6833 { "root//elem[index()=1]", "E2.E2.D1" },
6834 { "root//elem[index() $eq$ 1]", "E2.E2.D1" },
6835 { "root//elem[end()]", "E4.E2.D1" },
6836 { "root//elem[$not$ end()]", "E1.E2.D1 E2.E2.D1 E3.E2.D1" },
6837 { "root//elem[index() != 0]", "E2.E2.D1 E3.E2.D1 E4.E2.D1" },
6838 { "root//elem[index() $ne$ 0]", "E2.E2.D1 E3.E2.D1 E4.E2.D1" },
6839 { "root//elem[index() < 2]", "E1.E2.D1 E2.E2.D1" },
6840 { "root//elem[index() $lt$ 2]", "E1.E2.D1 E2.E2.D1" },
6841 { "root//elem[index() <= 1]", "E1.E2.D1 E2.E2.D1" },
6842 { "root//elem[index() $le$ 1]", "E1.E2.D1 E2.E2.D1" },
6843 { "root//elem[index() > 1]", "E3.E2.D1 E4.E2.D1" },
6844 { "root//elem[index() $gt$ 1]", "E3.E2.D1 E4.E2.D1" },
6845 { "root//elem[index() >= 2]", "E3.E2.D1 E4.E2.D1" },
6846 { "root//elem[index() $ge$ 2]", "E3.E2.D1 E4.E2.D1" },
6847 { "root//elem[a $ieq$ 'a2 field']", "E2.E2.D1" },
6848 { "root//elem[a $ine$ 'a2 field']", "E1.E2.D1 E3.E2.D1 E4.E2.D1" },
6849 { "root//elem[a $ilt$ 'a3 field']", "E1.E2.D1 E2.E2.D1" },
6850 { "root//elem[a $ile$ 'a2 field']", "E1.E2.D1 E2.E2.D1" },
6851 { "root//elem[a $igt$ 'a2 field']", "E3.E2.D1 E4.E2.D1" },
6852 { "root//elem[a $ige$ 'a3 field']", "E3.E2.D1 E4.E2.D1" },
6853 { "root//elem[$any$ *='B2 field']", "E2.E2.D1" },
6854 { "root//elem[$all$ *!='B2 field']", "E1.E2.D1 E3.E2.D1 E4.E2.D1" },
6855 { "root//elem[index()=0 or end()]", "E1.E2.D1 E4.E2.D1" },
6856 { "root//elem[index()=0 $or$ end()]", "E1.E2.D1 E4.E2.D1" },
6857 { "root//elem[index()=0 || end()]", "E1.E2.D1 E4.E2.D1" },
6858 { "root//elem[index()>0 and $not$ end()]", "E2.E2.D1 E3.E2.D1" },
6859 { "root//elem[index()>0 $and$ $not$ end()]", "E2.E2.D1 E3.E2.D1" },
6860 { "root//elem[index()>0 && $not$ end()]", "E2.E2.D1 E3.E2.D1" },
6861 { "root/elem[0]", "E1.E2.D1" },
6862 { "root/elem[index()=1]", "E2.E2.D1" },
6863 { "root/elem[index() $eq$ 1]", "E2.E2.D1" },
6864 { "root/elem[end()]", "E4.E2.D1" },
6865 { "root/elem[$not$ end()]", "E1.E2.D1 E2.E2.D1 E3.E2.D1" },
6866 { "root/elem[index() != 0]", "E2.E2.D1 E3.E2.D1 E4.E2.D1" },
6867 { "root/elem[index() $ne$ 0]", "E2.E2.D1 E3.E2.D1 E4.E2.D1" },
6868 { "root/elem[index() < 2]", "E1.E2.D1 E2.E2.D1" },
6869 { "root/elem[index() $lt$ 2]", "E1.E2.D1 E2.E2.D1" },
6870 { "root/elem[index() <= 1]", "E1.E2.D1 E2.E2.D1" },
6871 { "root/elem[index() $le$ 1]", "E1.E2.D1 E2.E2.D1" },
6872 { "root/elem[index() > 1]", "E3.E2.D1 E4.E2.D1" },
6873 { "root/elem[index() $gt$ 1]", "E3.E2.D1 E4.E2.D1" },
6874 { "root/elem[index() >= 2]", "E3.E2.D1 E4.E2.D1" },
6875 { "root/elem[index() $ge$ 2]", "E3.E2.D1 E4.E2.D1" },
6876 { "root/elem[a $ieq$ 'a2 field']", "E2.E2.D1" },
6877 { "root/elem[a $ine$ 'a2 field']", "E1.E2.D1 E3.E2.D1 E4.E2.D1" },
6878 { "root/elem[a $ilt$ 'a3 field']", "E1.E2.D1 E2.E2.D1" },
6879 { "root/elem[a $ile$ 'a2 field']", "E1.E2.D1 E2.E2.D1" },
6880 { "root/elem[a $igt$ 'a2 field']", "E3.E2.D1 E4.E2.D1" },
6881 { "root/elem[a $ige$ 'a3 field']", "E3.E2.D1 E4.E2.D1" },
6882 { "root/elem[$any$ *='B2 field']", "E2.E2.D1" },
6883 { "root/elem[$all$ *!='B2 field']", "E1.E2.D1 E3.E2.D1 E4.E2.D1" },
6884 { "root/elem[index()=0 or end()]", "E1.E2.D1 E4.E2.D1" },
6885 { "root/elem[index()=0 $or$ end()]", "E1.E2.D1 E4.E2.D1" },
6886 { "root/elem[index()=0 || end()]", "E1.E2.D1 E4.E2.D1" },
6887 { "root/elem[index()>0 and $not$ end()]", "E2.E2.D1 E3.E2.D1" },
6888 { "root/elem[index()>0 $and$ $not$ end()]", "E2.E2.D1 E3.E2.D1" },
6889 { "root/elem[index()>0 && $not$ end()]", "E2.E2.D1 E3.E2.D1" },
6890 { "root/elem[d]", "E1.E2.D1 E2.E2.D1 E4.E2.D1" },
6891 { "root/elem[@*]", "E2.E2.D1 E3.E2.D1", TRUE
},
6895 static const xslpattern_test_t xslpattern_test_no_ns
[] = {
6896 /* prefixes don't need to be registered, you may use them as they are in the doc */
6897 { "//bar:x", "E5.E1.E5.E1.E2.D1 E6.E2.E5.E1.E2.D1" },
6898 /* prefixes must be explicitly specified in the name */
6899 { "//foo:elem", "" },
6900 { "//foo:c", "E3.E4.E2.D1" },
6904 static const xslpattern_test_t xslpattern_test_func
[] = {
6905 { "attribute()", "" },
6906 { "attribute('depth')", "" },
6907 { "root/attribute('depth')", "A'depth'.E3.D1" },
6908 { "//x/attribute()", "A'id'.E3.E3.D1 A'depth'.E3.E3.D1" },
6909 { "//x//attribute(id)", NULL
},
6910 { "//x//attribute('id')", "A'id'.E3.E3.D1 A'id'.E4.E3.E3.D1 A'id'.E5.E3.E3.D1 A'id'.E6.E3.E3.D1" },
6911 { "comment()", "C2.D1" },
6912 { "//comment()", "C2.D1 C1.E3.D1 C2.E3.E3.D1 C2.E4.E3.D1" },
6913 { "element()", "E3.D1" },
6914 { "root/y/element()", "E4.E4.E3.D1 E5.E4.E3.D1 E6.E4.E3.D1" },
6915 { "//element(a)", NULL
},
6916 { "//element('a')", "E4.E3.E3.D1 E4.E4.E3.D1" },
6917 { "node()", "P1.D1 C2.D1 E3.D1" },
6918 { "//x/node()", "P1.E3.E3.D1 C2.E3.E3.D1 T3.E3.E3.D1 E4.E3.E3.D1 E5.E3.E3.D1 E6.E3.E3.D1" },
6919 { "//x/node()[nodeType()=1]", "E4.E3.E3.D1 E5.E3.E3.D1 E6.E3.E3.D1" },
6920 { "//x/node()[nodeType()=3]", "T3.E3.E3.D1" },
6921 { "//x/node()[nodeType()=7]", "P1.E3.E3.D1" },
6922 { "//x/node()[nodeType()=8]", "C2.E3.E3.D1" },
6923 { "pi()", "P1.D1" },
6924 { "//y/pi()", "P1.E4.E3.D1" },
6925 { "root/textnode()", "T2.E3.D1" },
6926 { "root/element()/textnode()", "T3.E3.E3.D1 T3.E4.E3.D1" },
6930 static void test_XSLPattern(void)
6932 const xslpattern_test_t
*ptr
= xslpattern_test
;
6933 IXMLDOMDocument2
*doc
;
6934 IXMLDOMNodeList
*list
;
6939 doc
= create_document(&IID_IXMLDOMDocument2
);
6942 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
6943 EXPECT_HR(hr
, S_OK
);
6944 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
6946 /* switch to XSLPattern */
6947 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern"));
6948 EXPECT_HR(hr
, S_OK
);
6950 /* XPath doesn't select elements with non-null default namespace with unqualified selectors, XSLPattern does */
6951 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("//elem/c"), &list
);
6952 EXPECT_HR(hr
, S_OK
);
6955 hr
= IXMLDOMNodeList_get_length(list
, &len
);
6956 EXPECT_HR(hr
, S_OK
);
6957 /* should select <elem><c> and <elem xmlns='...'><c> but not <elem><foo:c> */
6958 ok(len
== 3, "expected 3 entries in list, got %d\n", len
);
6959 IXMLDOMNodeList_Release(list
);
6964 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_(ptr
->query
), &list
);
6965 ok(hr
== S_OK
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
6967 hr
= IXMLDOMNodeList_get_length(list
, &len
);
6968 ok(len
!= 0, "query=%s, empty list\n", ptr
->query
);
6971 char *str
= list_to_string(list
);
6973 ok(!strcmp(str
, ptr
->list
), "Invalid node list: %s, expected %s\n", str
, ptr
->list
);
6974 IXMLDOMNodeList_Release(list
);
6977 expect_list_and_release(list
, ptr
->list
);
6983 /* namespace handling */
6984 /* no registered namespaces */
6985 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_(""));
6986 EXPECT_HR(hr
, S_OK
);
6988 ptr
= xslpattern_test_no_ns
;
6992 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_(ptr
->query
), &list
);
6993 ok(hr
== S_OK
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
6998 hr
= IXMLDOMNodeList_get_length(list
, &len
);
6999 EXPECT_HR(hr
, S_OK
);
7000 ok(len
!= 0, "query=%s, empty list\n", ptr
->query
);
7005 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7006 EXPECT_HR(hr
, S_OK
);
7007 ok(len
== 0, "query=%s, empty list\n", ptr
->query
);
7010 expect_list_and_release(list
, ptr
->list
);
7015 /* explicitly register prefix foo */
7016 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
7018 /* now we get the same behavior as XPath */
7019 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
);
7020 EXPECT_HR(hr
, S_OK
);
7022 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7023 EXPECT_HR(hr
, S_OK
);
7024 ok(len
!= 0, "expected filled list\n");
7026 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
7028 /* set prefix foo to some nonexistent namespace */
7029 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:foo='urn:nonexistent-foo'"));
7030 EXPECT_HR(hr
, S_OK
);
7032 /* the registered prefix takes precedence */
7033 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
);
7034 EXPECT_HR(hr
, S_OK
);
7036 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7037 EXPECT_HR(hr
, S_OK
);
7038 ok(len
== 0, "expected empty list\n");
7039 IXMLDOMNodeList_Release(list
);
7041 IXMLDOMDocument2_Release(doc
);
7043 doc
= create_document(&IID_IXMLDOMDocument2
);
7045 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szNodeTypesXML
), &b
);
7046 EXPECT_HR(hr
, S_OK
);
7047 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7049 ptr
= xslpattern_test_func
;
7053 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_(ptr
->query
), &list
);
7056 ok(hr
== S_OK
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
7058 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7061 ok(len
!= 0, "query=%s, empty list\n", ptr
->query
);
7063 expect_list_and_release(list
, ptr
->list
);
7066 ok(len
== 0, "query=%s, filled list\n", ptr
->query
);
7069 ok(hr
== E_FAIL
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
7074 IXMLDOMDocument2_Release(doc
);
7078 static void test_splitText(void)
7080 IXMLDOMCDATASection
*cdata
;
7081 IXMLDOMElement
*root
;
7082 IXMLDOMDocument
*doc
;
7083 IXMLDOMText
*text
, *text2
;
7086 VARIANT_BOOL success
;
7090 doc
= create_document(&IID_IXMLDOMDocument
);
7092 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_("<root></root>"), &success
);
7093 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7095 hr
= IXMLDOMDocument_get_documentElement(doc
, &root
);
7096 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7098 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("beautiful plumage"), &cdata
);
7099 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7101 V_VT(&var
) = VT_EMPTY
;
7102 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)cdata
, NULL
);
7103 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7106 hr
= IXMLDOMCDATASection_get_length(cdata
, &length
);
7107 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7108 ok(length
> 0, "got %d\n", length
);
7110 hr
= IXMLDOMCDATASection_splitText(cdata
, 0, NULL
);
7111 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7113 text
= (void*)0xdeadbeef;
7114 /* negative offset */
7115 hr
= IXMLDOMCDATASection_splitText(cdata
, -1, &text
);
7116 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7117 ok(text
== (void*)0xdeadbeef, "got %p\n", text
);
7119 text
= (void*)0xdeadbeef;
7120 /* offset outside data */
7121 hr
= IXMLDOMCDATASection_splitText(cdata
, length
+ 1, &text
);
7122 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7123 ok(text
== 0, "got %p\n", text
);
7125 text
= (void*)0xdeadbeef;
7126 /* offset outside data */
7127 hr
= IXMLDOMCDATASection_splitText(cdata
, length
, &text
);
7128 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7129 ok(text
== 0, "got %p\n", text
);
7131 /* no empty node created */
7132 node
= (void*)0xdeadbeef;
7133 hr
= IXMLDOMCDATASection_get_nextSibling(cdata
, &node
);
7134 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7135 ok(node
== 0, "got %p\n", text
);
7137 hr
= IXMLDOMCDATASection_splitText(cdata
, 10, &text
);
7138 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7141 hr
= IXMLDOMText_get_length(text
, &length
);
7142 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7143 ok(length
== 7, "got %d\n", length
);
7145 hr
= IXMLDOMCDATASection_get_nextSibling(cdata
, &node
);
7146 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7147 IXMLDOMNode_Release(node
);
7149 /* split new text node */
7150 hr
= IXMLDOMText_get_length(text
, &length
);
7151 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7153 node
= (void*)0xdeadbeef;
7154 hr
= IXMLDOMText_get_nextSibling(text
, &node
);
7155 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7156 ok(node
== 0, "got %p\n", text
);
7158 hr
= IXMLDOMText_splitText(text
, 0, NULL
);
7159 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7161 text2
= (void*)0xdeadbeef;
7162 /* negative offset */
7163 hr
= IXMLDOMText_splitText(text
, -1, &text2
);
7164 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7165 ok(text2
== (void*)0xdeadbeef, "got %p\n", text2
);
7167 text2
= (void*)0xdeadbeef;
7168 /* offset outside data */
7169 hr
= IXMLDOMText_splitText(text
, length
+ 1, &text2
);
7170 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7171 ok(text2
== 0, "got %p\n", text2
);
7173 text2
= (void*)0xdeadbeef;
7174 /* offset outside data */
7175 hr
= IXMLDOMText_splitText(text
, length
, &text2
);
7176 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7177 ok(text2
== 0, "got %p\n", text
);
7180 hr
= IXMLDOMText_splitText(text
, 4, &text2
);
7181 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7182 if (text2
) IXMLDOMText_Release(text2
);
7185 hr
= IXMLDOMText_get_nextSibling(text
, &node
);
7186 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7187 if (node
) IXMLDOMNode_Release(node
);
7189 IXMLDOMText_Release(text
);
7190 IXMLDOMElement_Release(root
);
7191 IXMLDOMCDATASection_Release(cdata
);
7201 /* default_ns_doc used */
7202 static const ns_item_t qualified_item_tests
[] = {
7203 { "xml:lang", NULL
, S_FALSE
},
7204 { "xml:lang", "http://www.w3.org/XML/1998/namespace", S_FALSE
},
7205 { "lang", "http://www.w3.org/XML/1998/namespace", S_OK
},
7206 { "ns:b", NULL
, S_FALSE
},
7207 { "ns:b", "nshref", S_FALSE
},
7208 { "b", "nshref", S_OK
},
7209 { "d", NULL
, S_OK
},
7213 static const ns_item_t named_item_tests
[] = {
7214 { "xml:lang", NULL
, S_OK
},
7215 { "lang", NULL
, S_FALSE
},
7216 { "ns:b", NULL
, S_OK
},
7217 { "b", NULL
, S_FALSE
},
7218 { "d", NULL
, S_OK
},
7222 static void test_getQualifiedItem(void)
7224 IXMLDOMNode
*pr_node
, *node
;
7225 IXMLDOMNodeList
*root_list
;
7226 IXMLDOMNamedNodeMap
*map
;
7227 IXMLDOMElement
*element
;
7228 const ns_item_t
* ptr
;
7229 IXMLDOMDocument
*doc
;
7234 doc
= create_document(&IID_IXMLDOMDocument
);
7236 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
7237 EXPECT_HR(hr
, S_OK
);
7238 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7240 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
7241 EXPECT_HR(hr
, S_OK
);
7243 hr
= IXMLDOMElement_get_childNodes(element
, &root_list
);
7244 EXPECT_HR(hr
, S_OK
);
7246 hr
= IXMLDOMNodeList_get_item(root_list
, 1, &pr_node
);
7247 EXPECT_HR(hr
, S_OK
);
7248 IXMLDOMNodeList_Release(root_list
);
7250 hr
= IXMLDOMNode_get_attributes(pr_node
, &map
);
7251 EXPECT_HR(hr
, S_OK
);
7252 IXMLDOMNode_Release(pr_node
);
7255 hr
= IXMLDOMNamedNodeMap_get_length(map
, &len
);
7256 EXPECT_HR(hr
, S_OK
);
7257 ok( len
== 3, "length %d\n", len
);
7259 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, NULL
, NULL
, NULL
);
7260 EXPECT_HR(hr
, E_INVALIDARG
);
7262 node
= (void*)0xdeadbeef;
7263 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, NULL
, NULL
, &node
);
7264 EXPECT_HR(hr
, E_INVALIDARG
);
7265 ok( node
== (void*)0xdeadbeef, "got %p\n", node
);
7267 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
7268 EXPECT_HR(hr
, E_INVALIDARG
);
7270 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_("id"), NULL
, &node
);
7271 EXPECT_HR(hr
, S_OK
);
7273 IXMLDOMNode_Release(node
);
7274 IXMLDOMNamedNodeMap_Release(map
);
7275 IXMLDOMElement_Release(element
);
7277 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(default_ns_doc
), &b
);
7278 EXPECT_HR(hr
, S_OK
);
7280 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("a"), &node
);
7281 EXPECT_HR(hr
, S_OK
);
7283 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&element
);
7284 EXPECT_HR(hr
, S_OK
);
7285 IXMLDOMNode_Release(node
);
7287 hr
= IXMLDOMElement_get_attributes(element
, &map
);
7288 EXPECT_HR(hr
, S_OK
);
7290 ptr
= qualified_item_tests
;
7293 node
= (void*)0xdeadbeef;
7294 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_(ptr
->name
), _bstr_(ptr
->uri
), &node
);
7295 ok(hr
== ptr
->hr
, "%s, %s: got 0x%08x, expected 0x%08x\n", ptr
->name
, ptr
->uri
, hr
, ptr
->hr
);
7297 IXMLDOMNode_Release(node
);
7299 ok(node
== NULL
, "%s, %s: got %p\n", ptr
->name
, ptr
->uri
, node
);
7303 ptr
= named_item_tests
;
7306 node
= (void*)0xdeadbeef;
7307 hr
= IXMLDOMNamedNodeMap_getNamedItem(map
, _bstr_(ptr
->name
), &node
);
7308 ok(hr
== ptr
->hr
, "%s: got 0x%08x, expected 0x%08x\n", ptr
->name
, hr
, ptr
->hr
);
7310 IXMLDOMNode_Release(node
);
7312 ok(node
== NULL
, "%s: got %p\n", ptr
->name
, node
);
7316 IXMLDOMNamedNodeMap_Release(map
);
7318 IXMLDOMElement_Release(element
);
7319 IXMLDOMDocument_Release(doc
);
7323 static void test_removeQualifiedItem(void)
7325 IXMLDOMDocument
*doc
;
7326 IXMLDOMElement
*element
;
7327 IXMLDOMNode
*pr_node
, *node
;
7328 IXMLDOMNodeList
*root_list
;
7329 IXMLDOMNamedNodeMap
*map
;
7334 doc
= create_document(&IID_IXMLDOMDocument
);
7336 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
7337 ok( hr
== S_OK
, "loadXML failed\n");
7338 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7340 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
7341 ok( hr
== S_OK
, "ret %08x\n", hr
);
7343 hr
= IXMLDOMElement_get_childNodes(element
, &root_list
);
7344 ok( hr
== S_OK
, "ret %08x\n", hr
);
7346 hr
= IXMLDOMNodeList_get_item(root_list
, 1, &pr_node
);
7347 ok( hr
== S_OK
, "ret %08x\n", hr
);
7348 IXMLDOMNodeList_Release(root_list
);
7350 hr
= IXMLDOMNode_get_attributes(pr_node
, &map
);
7351 ok( hr
== S_OK
, "ret %08x\n", hr
);
7352 IXMLDOMNode_Release(pr_node
);
7354 hr
= IXMLDOMNamedNodeMap_get_length(map
, &len
);
7355 ok( hr
== S_OK
, "ret %08x\n", hr
);
7356 ok( len
== 3, "length %d\n", len
);
7358 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, NULL
, NULL
, NULL
);
7359 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7361 node
= (void*)0xdeadbeef;
7362 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, NULL
, NULL
, &node
);
7363 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7364 ok( node
== (void*)0xdeadbeef, "got %p\n", node
);
7366 /* out pointer is optional */
7367 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
7368 ok( hr
== S_OK
, "ret %08x\n", hr
);
7370 /* already removed */
7371 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
7372 ok( hr
== S_FALSE
, "ret %08x\n", hr
);
7374 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("vr"), NULL
, &node
);
7375 ok( hr
== S_OK
, "ret %08x\n", hr
);
7376 IXMLDOMNode_Release(node
);
7378 IXMLDOMNamedNodeMap_Release( map
);
7379 IXMLDOMElement_Release( element
);
7380 IXMLDOMDocument_Release( doc
);
7384 #define check_default_props(doc) _check_default_props(__LINE__, doc)
7385 static inline void _check_default_props(int line
, IXMLDOMDocument2
* doc
)
7392 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionLanguage"), &var
));
7393 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("XSLPattern")) == 0, "expected XSLPattern\n");
7396 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
7397 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("")) == 0, "expected empty string\n");
7400 helper_ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc
, &b
));
7401 ok_(__FILE__
, line
)(b
== VARIANT_FALSE
, "expected FALSE\n");
7403 hr
= IXMLDOMDocument2_get_schemas(doc
, &var
);
7404 ok_(__FILE__
, line
)(hr
== S_FALSE
, "got %08x\n", hr
);
7408 #define check_set_props(doc) _check_set_props(__LINE__, doc)
7409 static inline void _check_set_props(int line
, IXMLDOMDocument2
* doc
)
7415 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionLanguage"), &var
));
7416 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("XPath")) == 0, "expected XPath\n");
7419 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
7420 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("xmlns:wi=\'www.winehq.org\'")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
7423 helper_ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc
, &b
));
7424 ok_(__FILE__
, line
)(b
== VARIANT_TRUE
, "expected TRUE\n");
7426 helper_ole_check(IXMLDOMDocument2_get_schemas(doc
, &var
));
7427 ok_(__FILE__
, line
)(V_VT(&var
) != VT_NULL
, "expected pointer\n");
7431 #define set_props(doc, cache) _set_props(__LINE__, doc, cache)
7432 static inline void _set_props(int line
, IXMLDOMDocument2
* doc
, IXMLDOMSchemaCollection
* cache
)
7437 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
7438 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:wi=\'www.winehq.org\'")));
7439 helper_ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc
, VARIANT_TRUE
));
7440 V_VT(&var
) = VT_DISPATCH
;
7441 V_DISPATCH(&var
) = NULL
;
7442 helper_ole_check(IXMLDOMSchemaCollection_QueryInterface(cache
, &IID_IDispatch
, (void**)&V_DISPATCH(&var
)));
7443 ok_(__FILE__
, line
)(V_DISPATCH(&var
) != NULL
, "expected pointer\n");
7444 helper_ole_check(IXMLDOMDocument2_putref_schemas(doc
, var
));
7448 #define unset_props(doc) _unset_props(__LINE__, doc)
7449 static inline void _unset_props(int line
, IXMLDOMDocument2
* doc
)
7454 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
7455 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("")));
7456 helper_ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc
, VARIANT_FALSE
));
7457 V_VT(&var
) = VT_NULL
;
7458 helper_ole_check(IXMLDOMDocument2_putref_schemas(doc
, var
));
7462 static void test_get_ownerDocument(void)
7464 IXMLDOMDocument
*doc1
, *doc2
, *doc3
;
7465 IXMLDOMDocument2
*doc
, *doc_owner
;
7467 IXMLDOMSchemaCollection
*cache
;
7471 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument2
)) return;
7472 if (!is_clsid_supported(&CLSID_XMLSchemaCache
, &IID_IXMLDOMSchemaCollection
)) return;
7474 doc
= create_document(&IID_IXMLDOMDocument2
);
7475 cache
= create_cache(&IID_IXMLDOMSchemaCollection
);
7479 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(complete4A
), &b
));
7480 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7482 check_default_props(doc
);
7484 /* set properties and check that new instances use them */
7485 set_props(doc
, cache
);
7486 check_set_props(doc
);
7488 ole_check(IXMLDOMDocument2_get_firstChild(doc
, &node
));
7489 ole_check(IXMLDOMNode_get_ownerDocument(node
, &doc1
));
7491 /* new interface keeps props */
7492 ole_check(IXMLDOMDocument_QueryInterface(doc1
, &IID_IXMLDOMDocument2
, (void**)&doc_owner
));
7493 ok( doc_owner
!= doc
, "got %p, doc %p\n", doc_owner
, doc
);
7494 check_set_props(doc_owner
);
7495 IXMLDOMDocument2_Release(doc_owner
);
7497 ole_check(IXMLDOMNode_get_ownerDocument(node
, &doc2
));
7498 IXMLDOMNode_Release(node
);
7500 ok(doc1
!= doc2
, "got %p, expected %p. original %p\n", doc2
, doc1
, doc
);
7503 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(complete4A
), &b
));
7504 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7506 /* properties retained even after reload */
7507 check_set_props(doc
);
7509 ole_check(IXMLDOMDocument2_get_firstChild(doc
, &node
));
7510 ole_check(IXMLDOMNode_get_ownerDocument(node
, &doc3
));
7511 IXMLDOMNode_Release(node
);
7513 ole_check(IXMLDOMDocument_QueryInterface(doc3
, &IID_IXMLDOMDocument2
, (void**)&doc_owner
));
7514 ok(doc3
!= doc1
&& doc3
!= doc2
&& doc_owner
!= doc
, "got %p, (%p, %p, %p)\n", doc3
, doc
, doc1
, doc2
);
7515 check_set_props(doc_owner
);
7517 /* changing properties for one instance changes them for all */
7518 unset_props(doc_owner
);
7519 check_default_props(doc_owner
);
7520 check_default_props(doc
);
7522 IXMLDOMSchemaCollection_Release(cache
);
7523 IXMLDOMDocument_Release(doc1
);
7524 IXMLDOMDocument_Release(doc2
);
7525 IXMLDOMDocument_Release(doc3
);
7526 IXMLDOMDocument2_Release(doc
);
7527 IXMLDOMDocument2_Release(doc_owner
);
7531 static void test_setAttributeNode(void)
7533 IXMLDOMDocument
*doc
, *doc2
;
7534 IXMLDOMElement
*elem
, *elem2
;
7535 IXMLDOMAttribute
*attr
, *attr2
, *ret_attr
;
7542 doc
= create_document(&IID_IXMLDOMDocument
);
7544 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
7545 ok( hr
== S_OK
, "loadXML failed\n");
7546 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7548 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
7549 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7551 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem2
);
7552 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7553 ok( elem2
!= elem
, "got same instance\n");
7555 ret_attr
= (void*)0xdeadbeef;
7556 hr
= IXMLDOMElement_setAttributeNode(elem
, NULL
, &ret_attr
);
7557 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7558 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
7560 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
7561 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7563 ref1
= IXMLDOMElement_AddRef(elem
);
7564 IXMLDOMElement_Release(elem
);
7566 ret_attr
= (void*)0xdeadbeef;
7567 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7568 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7569 ok( ret_attr
== NULL
, "got %p\n", ret_attr
);
7571 /* no reference added */
7572 ref2
= IXMLDOMElement_AddRef(elem
);
7573 IXMLDOMElement_Release(elem
);
7574 ok(ref2
== ref1
, "got %d, expected %d\n", ref2
, ref1
);
7576 EXPECT_CHILDREN(elem
);
7577 EXPECT_CHILDREN(elem2
);
7579 IXMLDOMElement_Release(elem2
);
7582 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attr"), &attr2
);
7583 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7584 ok( attr2
!= attr
, "got same instance %p\n", attr2
);
7585 IXMLDOMAttribute_Release(attr2
);
7587 /* try to add it another time */
7588 ret_attr
= (void*)0xdeadbeef;
7589 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7590 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
7591 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
7593 IXMLDOMElement_Release(elem
);
7595 /* initially used element is released, attribute still 'has' a container */
7596 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
7597 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7598 ret_attr
= (void*)0xdeadbeef;
7599 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7600 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
7601 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
7602 IXMLDOMElement_Release(elem
);
7604 /* add attribute already attached to another document */
7605 doc2
= create_document(&IID_IXMLDOMDocument
);
7607 hr
= IXMLDOMDocument_loadXML( doc2
, _bstr_(complete4A
), &b
);
7608 ok( hr
== S_OK
, "loadXML failed\n");
7609 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7611 hr
= IXMLDOMDocument_get_documentElement(doc2
, &elem
);
7612 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7613 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, NULL
);
7614 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
7615 IXMLDOMElement_Release(elem
);
7617 IXMLDOMAttribute_Release(attr
);
7619 /* create element, add attribute, see if it's copied or linked */
7620 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("test"), &elem
);
7621 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7624 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
7625 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7626 ok(attr
!= NULL
, "got %p\n", attr
);
7628 ref1
= IXMLDOMAttribute_AddRef(attr
);
7629 IXMLDOMAttribute_Release(attr
);
7632 V_BSTR(&v
) = _bstr_("attrvalue1");
7633 hr
= IXMLDOMAttribute_put_nodeValue(attr
, v
);
7634 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7637 hr
= IXMLDOMAttribute_get_xml(attr
, &str
);
7638 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7639 ok( lstrcmpW(str
, _bstr_("attr=\"attrvalue1\"")) == 0,
7640 "got %s\n", wine_dbgstr_w(str
));
7643 ret_attr
= (void*)0xdeadbeef;
7644 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
7645 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7646 ok(ret_attr
== NULL
, "got %p\n", ret_attr
);
7648 /* attribute reference increased */
7649 ref2
= IXMLDOMAttribute_AddRef(attr
);
7650 IXMLDOMAttribute_Release(attr
);
7651 ok(ref1
== ref2
, "got %d, expected %d\n", ref2
, ref1
);
7653 hr
= IXMLDOMElement_get_xml(elem
, &str
);
7654 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7655 ok( lstrcmpW(str
, _bstr_("<test attr=\"attrvalue1\"/>")) == 0,
7656 "got %s\n", wine_dbgstr_w(str
));
7660 V_BSTR(&v
) = _bstr_("attrvalue2");
7661 hr
= IXMLDOMAttribute_put_nodeValue(attr
, v
);
7662 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7664 hr
= IXMLDOMElement_get_xml(elem
, &str
);
7665 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7666 todo_wine
ok( lstrcmpW(str
, _bstr_("<test attr=\"attrvalue2\"/>")) == 0,
7667 "got %s\n", wine_dbgstr_w(str
));
7670 IXMLDOMElement_Release(elem
);
7671 IXMLDOMAttribute_Release(attr
);
7672 IXMLDOMDocument_Release(doc2
);
7673 IXMLDOMDocument_Release(doc
);
7677 static void test_createNode(void)
7679 IXMLDOMDocument
*doc
;
7680 IXMLDOMElement
*elem
;
7687 doc
= create_document(&IID_IXMLDOMDocument
);
7691 /* reference count tests */
7692 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem
);
7693 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7695 /* initial reference is 2 */
7697 EXPECT_REF(elem
, 2);
7698 ref
= IXMLDOMElement_Release(elem
);
7699 ok(ref
== 1, "got %d\n", ref
);
7700 /* it's released already, attempt to release now will crash it */
7703 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem
);
7704 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7705 todo_wine
EXPECT_REF(elem
, 2);
7706 IXMLDOMDocument_Release(doc
);
7707 todo_wine
EXPECT_REF(elem
, 2);
7708 IXMLDOMElement_Release(elem
);
7710 doc
= create_document(&IID_IXMLDOMDocument
);
7712 /* NODE_ELEMENT nodes */
7713 /* 1. specified namespace */
7715 V_I4(&v
) = NODE_ELEMENT
;
7717 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("ns1:test"), _bstr_("http://winehq.org"), &node
);
7718 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7720 hr
= IXMLDOMNode_get_prefix(node
, &prefix
);
7721 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7722 ok(lstrcmpW(prefix
, _bstr_("ns1")) == 0, "wrong prefix\n");
7723 SysFreeString(prefix
);
7724 IXMLDOMNode_Release(node
);
7726 /* 2. default namespace */
7727 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("test"), _bstr_("http://winehq.org/default"), &node
);
7728 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7729 prefix
= (void*)0xdeadbeef;
7730 hr
= IXMLDOMNode_get_prefix(node
, &prefix
);
7731 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
7732 ok(prefix
== 0, "expected empty prefix, got %p\n", prefix
);
7734 hr
= IXMLDOMNode_get_xml(node
, &str
);
7735 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7736 ok( lstrcmpW(str
, _bstr_("<test xmlns=\"http://winehq.org/default\"/>")) == 0,
7737 "got %s\n", wine_dbgstr_w(str
));
7740 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
7741 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7743 V_VT(&var
) = VT_BSTR
;
7744 hr
= IXMLDOMElement_getAttribute(elem
, _bstr_("xmlns"), &var
);
7745 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
7746 ok( V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
7749 hr
= IXMLDOMElement_get_namespaceURI(elem
, &str
);
7750 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7751 ok( lstrcmpW(str
, _bstr_("http://winehq.org/default")) == 0, "expected default namespace\n");
7754 IXMLDOMElement_Release(elem
);
7755 IXMLDOMNode_Release(node
);
7757 IXMLDOMDocument_Release(doc
);
7761 static const char get_prefix_doc
[] =
7762 "<?xml version=\"1.0\" ?>"
7763 "<a xmlns:ns1=\"ns1 href\" />";
7765 static void test_get_prefix(void)
7767 IXMLDOMDocumentFragment
*fragment
;
7768 IXMLDOMCDATASection
*cdata
;
7769 IXMLDOMElement
*element
;
7770 IXMLDOMComment
*comment
;
7771 IXMLDOMDocument
*doc
;
7776 doc
= create_document(&IID_IXMLDOMDocument
);
7778 /* nodes that can't support prefix */
7780 str
= (void*)0xdeadbeef;
7781 hr
= IXMLDOMDocument_get_prefix(doc
, &str
);
7782 EXPECT_HR(hr
, S_FALSE
);
7783 ok(str
== NULL
, "got %p\n", str
);
7785 hr
= IXMLDOMDocument_get_prefix(doc
, NULL
);
7786 EXPECT_HR(hr
, E_INVALIDARG
);
7789 hr
= IXMLDOMDocument_createCDATASection(doc
, NULL
, &cdata
);
7790 ok(hr
== S_OK
, "got %08x\n", hr
);
7792 str
= (void*)0xdeadbeef;
7793 hr
= IXMLDOMCDATASection_get_prefix(cdata
, &str
);
7794 ok(hr
== S_FALSE
, "got %08x\n", hr
);
7795 ok( str
== 0, "got %p\n", str
);
7797 hr
= IXMLDOMCDATASection_get_prefix(cdata
, NULL
);
7798 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
7799 IXMLDOMCDATASection_Release(cdata
);
7802 hr
= IXMLDOMDocument_createComment(doc
, NULL
, &comment
);
7803 ok(hr
== S_OK
, "got %08x\n", hr
);
7805 str
= (void*)0xdeadbeef;
7806 hr
= IXMLDOMComment_get_prefix(comment
, &str
);
7807 ok(hr
== S_FALSE
, "got %08x\n", hr
);
7808 ok( str
== 0, "got %p\n", str
);
7810 hr
= IXMLDOMComment_get_prefix(comment
, NULL
);
7811 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
7812 IXMLDOMComment_Release(comment
);
7815 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &fragment
);
7816 ok(hr
== S_OK
, "got %08x\n", hr
);
7818 str
= (void*)0xdeadbeef;
7819 hr
= IXMLDOMDocumentFragment_get_prefix(fragment
, &str
);
7820 ok(hr
== S_FALSE
, "got %08x\n", hr
);
7821 ok( str
== 0, "got %p\n", str
);
7823 hr
= IXMLDOMDocumentFragment_get_prefix(fragment
, NULL
);
7824 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
7825 IXMLDOMDocumentFragment_Release(fragment
);
7828 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &element
);
7829 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7831 hr
= IXMLDOMElement_get_prefix(element
, NULL
);
7832 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7834 str
= (void*)0xdeadbeef;
7835 hr
= IXMLDOMElement_get_prefix(element
, &str
);
7836 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
7837 ok( str
== 0, "got %p\n", str
);
7839 IXMLDOMElement_Release(element
);
7842 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("a:elem"), &element
);
7843 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7845 str
= (void*)0xdeadbeef;
7846 hr
= IXMLDOMElement_get_prefix(element
, &str
);
7847 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
7848 ok( lstrcmpW(str
, _bstr_("a")) == 0, "expected prefix \"a\"\n");
7851 str
= (void*)0xdeadbeef;
7852 hr
= IXMLDOMElement_get_namespaceURI(element
, &str
);
7853 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
7854 ok( str
== 0, "got %p\n", str
);
7856 IXMLDOMElement_Release(element
);
7858 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(get_prefix_doc
), &b
);
7859 EXPECT_HR(hr
, S_OK
);
7861 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
7862 EXPECT_HR(hr
, S_OK
);
7864 str
= (void*)0xdeadbeef;
7865 hr
= IXMLDOMElement_get_prefix(element
, &str
);
7866 EXPECT_HR(hr
, S_FALSE
);
7867 ok(str
== NULL
, "got %p\n", str
);
7869 str
= (void*)0xdeadbeef;
7870 hr
= IXMLDOMElement_get_namespaceURI(element
, &str
);
7871 EXPECT_HR(hr
, S_FALSE
);
7872 ok(str
== NULL
, "got %s\n", wine_dbgstr_w(str
));
7874 IXMLDOMDocument_Release(doc
);
7878 static void test_selectSingleNode(void)
7880 IXMLDOMDocument
*doc
;
7881 IXMLDOMNodeList
*list
;
7887 doc
= create_document(&IID_IXMLDOMDocument
);
7889 hr
= IXMLDOMDocument_selectSingleNode(doc
, NULL
, NULL
);
7890 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7892 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, NULL
);
7893 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7895 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
7896 ok( hr
== S_OK
, "loadXML failed\n");
7897 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
7899 hr
= IXMLDOMDocument_selectSingleNode(doc
, NULL
, NULL
);
7900 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7902 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, NULL
);
7903 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7905 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc"), NULL
);
7906 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7908 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("lc"), NULL
);
7909 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7911 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc"), &node
);
7912 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7913 IXMLDOMNode_Release(node
);
7915 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("lc"), &list
);
7916 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7917 IXMLDOMNodeList_Release(list
);
7919 list
= (void*)0xdeadbeef;
7920 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, &list
);
7921 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7922 ok(list
== (void*)0xdeadbeef, "got %p\n", list
);
7924 node
= (void*)0xdeadbeef;
7925 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("nonexistent"), &node
);
7926 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7927 ok(node
== 0, "got %p\n", node
);
7929 list
= (void*)0xdeadbeef;
7930 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("nonexistent"), &list
);
7931 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7933 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7934 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7935 ok(len
== 0, "got %d\n", len
);
7936 IXMLDOMNodeList_Release(list
);
7938 IXMLDOMDocument_Release(doc
);
7942 static void test_events(void)
7944 IConnectionPointContainer
*conn
;
7945 IConnectionPoint
*point
;
7946 IXMLDOMDocument
*doc
;
7951 doc
= create_document(&IID_IXMLDOMDocument
);
7953 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IConnectionPointContainer
, (void**)&conn
);
7954 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7956 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &IID_IDispatch
, &point
);
7957 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7958 IConnectionPoint_Release(point
);
7959 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &IID_IPropertyNotifySink
, &point
);
7960 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7961 IConnectionPoint_Release(point
);
7962 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &DIID_XMLDOMDocumentEvents
, &point
);
7963 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7964 IConnectionPoint_Release(point
);
7966 IConnectionPointContainer_Release(conn
);
7968 /* ready state callback */
7970 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
7971 ok(hr
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hr
);
7973 event
= create_dispevent();
7974 V_VT(&v
) = VT_UNKNOWN
;
7975 V_UNKNOWN(&v
) = (IUnknown
*)event
;
7977 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
7978 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7979 EXPECT_REF(event
, 2);
7981 V_VT(&v
) = VT_DISPATCH
;
7982 V_DISPATCH(&v
) = event
;
7984 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
7985 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7986 EXPECT_REF(event
, 2);
7988 /* VT_NULL doesn't reset event handler */
7990 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
7991 ok(hr
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hr
);
7992 EXPECT_REF(event
, 2);
7994 V_VT(&v
) = VT_DISPATCH
;
7995 V_DISPATCH(&v
) = NULL
;
7997 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
7998 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7999 EXPECT_REF(event
, 1);
8001 V_VT(&v
) = VT_UNKNOWN
;
8002 V_DISPATCH(&v
) = NULL
;
8003 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8004 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8006 IDispatch_Release(event
);
8008 IXMLDOMDocument_Release(doc
);
8011 static void test_createProcessingInstruction(void)
8013 static const WCHAR bodyW
[] = {'t','e','s','t',0};
8014 IXMLDOMProcessingInstruction
*pi
;
8015 IXMLDOMDocument
*doc
;
8019 doc
= create_document(&IID_IXMLDOMDocument
);
8021 /* test for BSTR handling, pass broken BSTR */
8022 memcpy(&buff
[2], bodyW
, sizeof(bodyW
));
8023 /* just a big length */
8024 *(DWORD
*)buff
= 0xf0f0;
8025 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("test"), &buff
[2], &pi
);
8026 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8028 IXMLDOMProcessingInstruction_Release(pi
);
8029 IXMLDOMDocument_Release(doc
);
8032 static void test_put_nodeTypedValue(void)
8034 static const BYTE binhexdata
[16] =
8035 {0,1,2,3,4,5,6,7,8,9,0xa,0xb,0xc,0xd,0xe,0xf};
8036 IXMLDOMDocument
*doc
;
8037 IXMLDOMElement
*elem
;
8038 VARIANT type
, value
;
8039 LONG ubound
, lbound
;
8046 doc
= create_document(&IID_IXMLDOMDocument
);
8048 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Element"), &elem
);
8049 EXPECT_HR(hr
, S_OK
);
8051 V_VT(&type
) = VT_EMPTY
;
8052 hr
= IXMLDOMElement_get_dataType(elem
, &type
);
8053 EXPECT_HR(hr
, S_FALSE
);
8054 ok(V_VT(&type
) == VT_NULL
, "got %d, expected VT_NULL\n", V_VT(&type
));
8056 /* set typed value for untyped node */
8057 V_VT(&type
) = VT_I1
;
8059 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, type
);
8060 EXPECT_HR(hr
, S_OK
);
8062 V_VT(&type
) = VT_EMPTY
;
8063 hr
= IXMLDOMElement_get_dataType(elem
, &type
);
8064 EXPECT_HR(hr
, S_FALSE
);
8065 ok(V_VT(&type
) == VT_NULL
, "got %d, expected VT_NULL\n", V_VT(&type
));
8067 /* no type info stored */
8068 V_VT(&type
) = VT_EMPTY
;
8069 hr
= IXMLDOMElement_get_nodeTypedValue(elem
, &type
);
8070 EXPECT_HR(hr
, S_OK
);
8071 ok(V_VT(&type
) == VT_BSTR
, "got %d, expected VT_BSTR\n", V_VT(&type
));
8072 ok(memcmp(V_BSTR(&type
), _bstr_("1"), 2*sizeof(WCHAR
)) == 0,
8073 "got %s, expected \"1\"\n", wine_dbgstr_w(V_BSTR(&type
)));
8074 VariantClear(&type
);
8076 hr
= IXMLDOMElement_get_firstChild(elem
, &node
);
8077 EXPECT_HR(hr
, S_OK
);
8078 hr
= IXMLDOMElement_removeChild(elem
, node
, NULL
);
8079 EXPECT_HR(hr
, S_OK
);
8080 IXMLDOMNode_Release(node
);
8082 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)elem
, NULL
);
8083 EXPECT_HR(hr
, S_OK
);
8086 hr
= IXMLDOMElement_put_dataType(elem
, _bstr_("bin.base64"));
8087 EXPECT_HR(hr
, S_OK
);
8089 V_VT(&value
) = VT_BSTR
;
8090 V_BSTR(&value
) = _bstr_("ABCD");
8091 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, value
);
8092 EXPECT_HR(hr
, S_OK
);
8094 V_VT(&value
) = VT_EMPTY
;
8095 hr
= IXMLDOMElement_get_nodeTypedValue(elem
, &value
);
8096 EXPECT_HR(hr
, S_OK
);
8097 ok(V_VT(&value
) == (VT_UI1
|VT_ARRAY
), "got %d\n", V_VT(&value
));
8098 ok(SafeArrayGetDim(V_ARRAY(&value
)) == 1, "got wrong dimension\n");
8100 hr
= SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
8101 EXPECT_HR(hr
, S_OK
);
8102 ok(ubound
== 2, "got %d\n", ubound
);
8104 hr
= SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
8105 EXPECT_HR(hr
, S_OK
);
8106 ok(lbound
== 0, "got %d\n", lbound
);
8107 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
8108 EXPECT_HR(hr
, S_OK
);
8109 ok(ptr
[0] == 0, "got %x\n", ptr
[0]);
8110 ok(ptr
[1] == 0x10, "got %x\n", ptr
[1]);
8111 ok(ptr
[2] == 0x83, "got %x\n", ptr
[2]);
8112 SafeArrayUnaccessData(V_ARRAY(&value
));
8113 VariantClear(&value
);
8115 /* when set as VT_BSTR it's stored as is */
8116 hr
= IXMLDOMElement_get_firstChild(elem
, &node
);
8117 EXPECT_HR(hr
, S_OK
);
8118 hr
= IXMLDOMNode_get_text(node
, &str
);
8119 EXPECT_HR(hr
, S_OK
);
8120 ok(!lstrcmpW(str
, _bstr_("ABCD")), "%s\n", wine_dbgstr_w(str
));
8121 IXMLDOMNode_Release(node
);
8124 array
= SafeArrayCreateVector(VT_UI1
, 0, 7);
8125 hr
= SafeArrayAccessData(array
, (void*)&ptr
);
8126 EXPECT_HR(hr
, S_OK
);
8127 memcpy(ptr
, "dGVzdA=", strlen("dGVzdA="));
8128 SafeArrayUnaccessData(array
);
8130 V_VT(&value
) = VT_UI1
|VT_ARRAY
;
8131 V_ARRAY(&value
) = array
;
8132 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, value
);
8133 EXPECT_HR(hr
, S_OK
);
8135 V_VT(&value
) = VT_EMPTY
;
8136 hr
= IXMLDOMElement_get_nodeTypedValue(elem
, &value
);
8137 EXPECT_HR(hr
, S_OK
);
8138 ok(V_VT(&value
) == (VT_UI1
|VT_ARRAY
), "got %d\n", V_VT(&value
));
8139 ok(SafeArrayGetDim(V_ARRAY(&value
)) == 1, "got wrong dimension\n");
8141 hr
= SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
8142 EXPECT_HR(hr
, S_OK
);
8143 ok(ubound
== 6, "got %d\n", ubound
);
8145 hr
= SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
8146 EXPECT_HR(hr
, S_OK
);
8147 ok(lbound
== 0, "got %d\n", lbound
);
8148 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
8149 EXPECT_HR(hr
, S_OK
);
8150 ok(!memcmp(ptr
, "dGVzdA=", strlen("dGVzdA=")), "got wrong data, %s\n", ptr
);
8151 SafeArrayUnaccessData(V_ARRAY(&value
));
8152 VariantClear(&value
);
8154 /* if set with VT_UI1|VT_ARRAY it's encoded */
8155 hr
= IXMLDOMElement_get_firstChild(elem
, &node
);
8156 EXPECT_HR(hr
, S_OK
);
8157 hr
= IXMLDOMNode_get_text(node
, &str
);
8158 EXPECT_HR(hr
, S_OK
);
8159 ok(!lstrcmpW(str
, _bstr_("ZEdWemRBPQ==")), "%s\n", wine_dbgstr_w(str
));
8160 IXMLDOMNode_Release(node
);
8161 SafeArrayDestroyData(array
);
8165 V_VT(&value
) = VT_BSTR
;
8166 V_BSTR(&value
) = _bstr_("");
8167 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, value
);
8168 EXPECT_HR(hr
, S_OK
);
8170 hr
= IXMLDOMElement_put_dataType(elem
, _bstr_("bin.hex"));
8171 EXPECT_HR(hr
, S_OK
);
8173 array
= SafeArrayCreateVector(VT_UI1
, 0, 16);
8174 hr
= SafeArrayAccessData(array
, (void*)&ptr
);
8175 EXPECT_HR(hr
, S_OK
);
8176 memcpy(ptr
, binhexdata
, sizeof(binhexdata
));
8177 SafeArrayUnaccessData(array
);
8179 V_VT(&value
) = VT_UI1
|VT_ARRAY
;
8180 V_ARRAY(&value
) = array
;
8181 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, value
);
8182 EXPECT_HR(hr
, S_OK
);
8184 V_VT(&value
) = VT_EMPTY
;
8185 hr
= IXMLDOMElement_get_nodeTypedValue(elem
, &value
);
8186 EXPECT_HR(hr
, S_OK
);
8187 ok(V_VT(&value
) == (VT_UI1
|VT_ARRAY
), "got %d\n", V_VT(&value
));
8188 ok(SafeArrayGetDim(V_ARRAY(&value
)) == 1, "got wrong dimension\n");
8190 hr
= SafeArrayGetUBound(V_ARRAY(&value
), 1, &ubound
);
8191 EXPECT_HR(hr
, S_OK
);
8192 ok(ubound
== 15, "got %d\n", ubound
);
8194 hr
= SafeArrayGetLBound(V_ARRAY(&value
), 1, &lbound
);
8195 EXPECT_HR(hr
, S_OK
);
8196 ok(lbound
== 0, "got %d\n", lbound
);
8197 hr
= SafeArrayAccessData(V_ARRAY(&value
), (void*)&ptr
);
8198 EXPECT_HR(hr
, S_OK
);
8199 ok(!memcmp(ptr
, binhexdata
, sizeof(binhexdata
)), "got wrong data\n");
8200 SafeArrayUnaccessData(V_ARRAY(&value
));
8201 VariantClear(&value
);
8203 /* if set with VT_UI1|VT_ARRAY it's encoded */
8204 hr
= IXMLDOMElement_get_firstChild(elem
, &node
);
8205 EXPECT_HR(hr
, S_OK
);
8206 hr
= IXMLDOMNode_get_text(node
, &str
);
8207 EXPECT_HR(hr
, S_OK
);
8208 ok(!lstrcmpW(str
, _bstr_("000102030405060708090a0b0c0d0e0f")), "%s\n", wine_dbgstr_w(str
));
8209 IXMLDOMNode_Release(node
);
8210 SafeArrayDestroyData(array
);
8213 IXMLDOMElement_Release(elem
);
8214 IXMLDOMDocument_Release(doc
);
8218 static void test_get_xml(void)
8220 static const char xmlA
[] = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n<a>test</a>\r\n";
8221 static const char attrA
[] = "attr=\""a & b"\"";
8222 static const char attr2A
[] = "\"a & b\"";
8223 static const char attr3A
[] = "attr=\"&quot;a\"";
8224 static const char attr4A
[] = ""a";
8225 static const char fooA
[] = "<foo/>";
8226 IXMLDOMProcessingInstruction
*pi
;
8228 IXMLDOMElement
*elem
= NULL
;
8229 IXMLDOMAttribute
*attr
;
8230 IXMLDOMDocument
*doc
;
8236 doc
= create_document(&IID_IXMLDOMDocument
);
8239 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_("<a>test</a>"), &b
);
8240 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8241 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8243 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"),
8244 _bstr_("version=\"1.0\" encoding=\"UTF-16\""), &pi
);
8245 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8247 hr
= IXMLDOMDocument_get_firstChild(doc
, &first
);
8248 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8250 V_UNKNOWN(&v
) = (IUnknown
*)first
;
8251 V_VT(&v
) = VT_UNKNOWN
;
8253 hr
= IXMLDOMDocument_insertBefore(doc
, (IXMLDOMNode
*)pi
, v
, NULL
);
8254 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8256 IXMLDOMProcessingInstruction_Release(pi
);
8257 IXMLDOMNode_Release(first
);
8259 hr
= IXMLDOMDocument_get_xml(doc
, &xml
);
8260 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8262 ok(memcmp(xml
, _bstr_(xmlA
), sizeof(xmlA
)*sizeof(WCHAR
)) == 0,
8263 "got %s, expected %s\n", wine_dbgstr_w(xml
), xmlA
);
8266 IXMLDOMDocument_Release(doc
);
8268 doc
= create_document(&IID_IXMLDOMDocument
);
8270 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("foo"), &elem
);
8271 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8273 hr
= IXMLDOMDocument_putref_documentElement(doc
, elem
);
8274 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8276 hr
= IXMLDOMDocument_get_xml(doc
, &xml
);
8277 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8279 ok(memcmp(xml
, _bstr_(fooA
), (sizeof(fooA
)-1)*sizeof(WCHAR
)) == 0,
8280 "got %s, expected %s\n", wine_dbgstr_w(xml
), fooA
);
8283 IXMLDOMElement_Release(elem
);
8285 /* attribute node */
8286 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
8287 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8290 V_BSTR(&v
) = _bstr_("\"a & b\"");
8291 hr
= IXMLDOMAttribute_put_value(attr
, v
);
8292 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8295 hr
= IXMLDOMAttribute_get_xml(attr
, &xml
);
8296 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8297 ok(!memcmp(xml
, _bstr_(attrA
), (sizeof(attrA
)-1)*sizeof(WCHAR
)), "got %s\n", wine_dbgstr_w(xml
));
8301 hr
= IXMLDOMAttribute_get_value(attr
, &v
);
8302 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8303 ok(V_VT(&v
) == VT_BSTR
, "got type %d\n", V_VT(&v
));
8304 ok(!memcmp(V_BSTR(&v
), _bstr_(attr2A
), (sizeof(attr2A
)-1)*sizeof(WCHAR
)),
8305 "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8309 V_BSTR(&v
) = _bstr_(""a");
8310 hr
= IXMLDOMAttribute_put_value(attr
, v
);
8311 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8314 hr
= IXMLDOMAttribute_get_xml(attr
, &xml
);
8315 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8316 ok(!memcmp(xml
, _bstr_(attr3A
), (sizeof(attr3A
)-1)*sizeof(WCHAR
)), "got %s\n", wine_dbgstr_w(xml
));
8320 hr
= IXMLDOMAttribute_get_value(attr
, &v
);
8321 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8322 ok(V_VT(&v
) == VT_BSTR
, "got type %d\n", V_VT(&v
));
8323 ok(!memcmp(V_BSTR(&v
), _bstr_(attr4A
), (sizeof(attr4A
)-1)*sizeof(WCHAR
)),
8324 "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8327 IXMLDOMAttribute_Release(attr
);
8329 IXMLDOMDocument_Release(doc
);
8334 static void test_xsltemplate(void)
8336 IXSLTemplate
*template;
8337 IXSLProcessor
*processor
;
8338 IXMLDOMDocument
*doc
, *doc2
;
8345 if (!is_clsid_supported(&CLSID_XSLTemplate
, &IID_IXSLTemplate
)) return;
8346 template = create_xsltemplate(&IID_IXSLTemplate
);
8348 /* works as reset */
8349 hr
= IXSLTemplate_putref_stylesheet(template, NULL
);
8350 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8352 doc
= create_document(&IID_IXMLDOMDocument
);
8355 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_("<a>test</a>"), &b
);
8356 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8357 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8359 /* putref with non-xsl document */
8360 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
8361 todo_wine
ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8364 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(szTransformSSXML
), &b
);
8365 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8366 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8368 /* not a freethreaded document */
8369 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
8370 todo_wine
ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8372 IXMLDOMDocument_Release(doc
);
8374 if (!is_clsid_supported(&CLSID_FreeThreadedDOMDocument
, &IID_IXMLDOMDocument
))
8376 IXSLTemplate_Release(template);
8380 hr
= CoCreateInstance(&CLSID_FreeThreadedDOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
8381 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8384 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(szTransformSSXML
), &b
);
8385 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8386 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8388 /* freethreaded document */
8389 ref1
= IXMLDOMDocument_AddRef(doc
);
8390 IXMLDOMDocument_Release(doc
);
8391 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
8392 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8393 ref2
= IXMLDOMDocument_AddRef(doc
);
8394 IXMLDOMDocument_Release(doc
);
8395 ok(ref2
> ref1
, "got %d\n", ref2
);
8398 hr
= IXSLTemplate_createProcessor(template, NULL
);
8399 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8401 EXPECT_REF(template, 1);
8402 hr
= IXSLTemplate_createProcessor(template, &processor
);
8403 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8404 EXPECT_REF(template, 2);
8406 /* input no set yet */
8409 hr
= IXSLProcessor_get_input(processor
, &v
);
8411 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8412 ok(V_VT(&v
) == VT_EMPTY
, "got %d\n", V_VT(&v
));
8415 hr
= IXSLProcessor_get_output(processor
, NULL
);
8416 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8418 /* reset before it was set */
8419 V_VT(&v
) = VT_EMPTY
;
8420 hr
= IXSLProcessor_put_output(processor
, v
);
8421 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8423 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
8424 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8425 EXPECT_REF(stream
, 1);
8427 V_VT(&v
) = VT_UNKNOWN
;
8428 V_UNKNOWN(&v
) = (IUnknown
*)stream
;
8429 hr
= IXSLProcessor_put_output(processor
, v
);
8430 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8432 /* it seems processor grabs 2 references */
8433 todo_wine
EXPECT_REF(stream
, 3);
8435 V_VT(&v
) = VT_EMPTY
;
8436 hr
= IXSLProcessor_get_output(processor
, &v
);
8437 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8438 ok(V_VT(&v
) == VT_UNKNOWN
, "got type %d\n", V_VT(&v
));
8439 ok(V_UNKNOWN(&v
) == (IUnknown
*)stream
, "got %p\n", V_UNKNOWN(&v
));
8441 todo_wine
EXPECT_REF(stream
, 4);
8444 hr
= IXSLProcessor_transform(processor
, NULL
);
8445 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8447 /* reset and check stream refcount */
8448 V_VT(&v
) = VT_EMPTY
;
8449 hr
= IXSLProcessor_put_output(processor
, v
);
8450 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8452 EXPECT_REF(stream
, 1);
8454 IStream_Release(stream
);
8456 /* no output interface set, check output */
8457 doc2
= create_document(&IID_IXMLDOMDocument
);
8460 hr
= IXMLDOMDocument_loadXML( doc2
, _bstr_("<a>test</a>"), &b
);
8461 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8462 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8464 V_VT(&v
) = VT_UNKNOWN
;
8465 V_UNKNOWN(&v
) = (IUnknown
*)doc2
;
8466 hr
= IXSLProcessor_put_input(processor
, v
);
8467 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8469 hr
= IXSLProcessor_transform(processor
, &b
);
8470 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8472 V_VT(&v
) = VT_EMPTY
;
8473 hr
= IXSLProcessor_get_output(processor
, &v
);
8474 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8475 ok(V_VT(&v
) == VT_BSTR
, "got type %d\n", V_VT(&v
));
8476 ok(*V_BSTR(&v
) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
8477 IXMLDOMDocument_Release(doc2
);
8480 IXSLProcessor_Release(processor
);
8482 /* drop reference */
8483 hr
= IXSLTemplate_putref_stylesheet(template, NULL
);
8484 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8485 ref2
= IXMLDOMDocument_AddRef(doc
);
8486 IXMLDOMDocument_Release(doc
);
8487 ok(ref2
== ref1
, "got %d\n", ref2
);
8489 IXMLDOMDocument_Release(doc
);
8490 IXSLTemplate_Release(template);
8494 static void test_insertBefore(void)
8496 IXMLDOMDocument
*doc
, *doc2
, *doc3
;
8497 IXMLDOMAttribute
*attr
;
8498 IXMLDOMElement
*elem1
, *elem2
, *elem3
, *elem4
, *elem5
;
8499 IXMLDOMNode
*node
, *newnode
, *cdata
;
8504 doc
= create_document(&IID_IXMLDOMDocument
);
8505 doc3
= create_document(&IID_IXMLDOMDocument
);
8507 /* document to document */
8509 node
= (void*)0xdeadbeef;
8510 hr
= IXMLDOMDocument_insertBefore(doc
, (IXMLDOMNode
*)doc3
, v
, &node
);
8511 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8512 ok(node
== NULL
, "got %p\n", node
);
8514 /* document to itself */
8516 node
= (void*)0xdeadbeef;
8517 hr
= IXMLDOMDocument_insertBefore(doc
, (IXMLDOMNode
*)doc
, v
, &node
);
8518 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8519 ok(node
== NULL
, "got %p\n", node
);
8521 /* insertBefore behaviour for attribute node */
8523 V_I4(&v
) = NODE_ATTRIBUTE
;
8526 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("attr"), NULL
, (IXMLDOMNode
**)&attr
);
8527 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8528 ok(attr
!= NULL
, "got %p\n", attr
);
8530 /* attribute to document */
8532 node
= (void*)0xdeadbeef;
8533 hr
= IXMLDOMDocument_insertBefore(doc3
, (IXMLDOMNode
*)attr
, v
, &node
);
8534 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8535 ok(node
== NULL
, "got %p\n", node
);
8537 /* cdata to document */
8539 V_I4(&v
) = NODE_CDATA_SECTION
;
8542 hr
= IXMLDOMDocument_createNode(doc3
, v
, _bstr_("cdata"), NULL
, &cdata
);
8543 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8544 ok(cdata
!= NULL
, "got %p\n", cdata
);
8546 EXPECT_NO_CHILDREN(cdata
);
8548 /* attribute to cdata */
8550 node
= (void*)0xdeadbeef;
8551 hr
= IXMLDOMNode_insertBefore(cdata
, (IXMLDOMNode
*)attr
, v
, &node
);
8552 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8553 ok(node
== NULL
, "got %p\n", node
);
8555 /* document to cdata */
8557 node
= (void*)0xdeadbeef;
8558 hr
= IXMLDOMNode_insertBefore(cdata
, (IXMLDOMNode
*)doc
, v
, &node
);
8559 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8560 ok(node
== NULL
, "got %p\n", node
);
8563 node
= (void*)0xdeadbeef;
8564 hr
= IXMLDOMDocument_insertBefore(doc3
, cdata
, v
, &node
);
8565 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8566 ok(node
== NULL
, "got %p\n", node
);
8568 IXMLDOMNode_Release(cdata
);
8569 IXMLDOMDocument_Release(doc3
);
8571 /* attribute to attribute */
8573 V_I4(&v
) = NODE_ATTRIBUTE
;
8575 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("attr2"), NULL
, &newnode
);
8576 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8577 ok(newnode
!= NULL
, "got %p\n", newnode
);
8580 node
= (void*)0xdeadbeef;
8581 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
8582 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8583 ok(node
== NULL
, "got %p\n", node
);
8585 V_VT(&v
) = VT_UNKNOWN
;
8586 V_UNKNOWN(&v
) = (IUnknown
*)attr
;
8587 node
= (void*)0xdeadbeef;
8588 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
8589 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8590 ok(node
== NULL
, "got %p\n", node
);
8591 IXMLDOMNode_Release(newnode
);
8593 /* cdata to attribute */
8595 V_I4(&v
) = NODE_CDATA_SECTION
;
8597 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
8598 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8599 ok(newnode
!= NULL
, "got %p\n", newnode
);
8602 node
= (void*)0xdeadbeef;
8603 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
8604 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8605 ok(node
== NULL
, "got %p\n", node
);
8606 IXMLDOMNode_Release(newnode
);
8608 /* comment to attribute */
8610 V_I4(&v
) = NODE_COMMENT
;
8612 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
8613 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8614 ok(newnode
!= NULL
, "got %p\n", newnode
);
8617 node
= (void*)0xdeadbeef;
8618 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
8619 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8620 ok(node
== NULL
, "got %p\n", node
);
8621 IXMLDOMNode_Release(newnode
);
8623 /* element to attribute */
8625 V_I4(&v
) = NODE_ELEMENT
;
8627 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
8628 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8629 ok(newnode
!= NULL
, "got %p\n", newnode
);
8632 node
= (void*)0xdeadbeef;
8633 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
8634 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8635 ok(node
== NULL
, "got %p\n", node
);
8636 IXMLDOMNode_Release(newnode
);
8638 /* pi to attribute */
8640 V_I4(&v
) = NODE_PROCESSING_INSTRUCTION
;
8642 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
8643 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8644 ok(newnode
!= NULL
, "got %p\n", newnode
);
8647 node
= (void*)0xdeadbeef;
8648 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
8649 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8650 ok(node
== NULL
, "got %p\n", node
);
8651 IXMLDOMNode_Release(newnode
);
8652 IXMLDOMAttribute_Release(attr
);
8654 /* insertBefore for elements */
8655 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem1
);
8656 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8658 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem2"), &elem2
);
8659 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8661 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem3"), &elem3
);
8662 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8664 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem3"), &elem3
);
8665 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8667 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem4"), &elem4
);
8668 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8670 EXPECT_NO_CHILDREN(elem1
);
8671 EXPECT_NO_CHILDREN(elem2
);
8672 EXPECT_NO_CHILDREN(elem3
);
8674 todo_wine
EXPECT_REF(elem2
, 2);
8676 /* document to element */
8677 V_VT(&v
) = VT_DISPATCH
;
8678 V_DISPATCH(&v
) = NULL
;
8679 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)doc
, v
, NULL
);
8680 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
8682 V_VT(&v
) = VT_DISPATCH
;
8683 V_DISPATCH(&v
) = NULL
;
8685 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem4
, v
, &node
);
8686 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8687 ok(node
== (void*)elem4
, "got %p\n", node
);
8689 EXPECT_CHILDREN(elem1
);
8690 hr
= IXMLDOMElement_removeChild(elem1
, (IXMLDOMNode
*)elem4
, NULL
);
8691 EXPECT_HR(hr
, S_OK
);
8692 IXMLDOMElement_Release(elem4
);
8694 EXPECT_NO_CHILDREN(elem1
);
8698 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, &node
);
8699 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8700 ok(node
== (void*)elem2
, "got %p\n", node
);
8702 EXPECT_CHILDREN(elem1
);
8703 todo_wine
EXPECT_REF(elem2
, 3);
8704 IXMLDOMNode_Release(node
);
8706 /* again for already linked node */
8709 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, &node
);
8710 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8711 ok(node
== (void*)elem2
, "got %p\n", node
);
8713 EXPECT_CHILDREN(elem1
);
8715 /* increments each time */
8716 todo_wine
EXPECT_REF(elem2
, 3);
8717 IXMLDOMNode_Release(node
);
8719 /* try to add to another element */
8721 node
= (void*)0xdeadbeef;
8722 hr
= IXMLDOMElement_insertBefore(elem3
, (IXMLDOMNode
*)elem2
, v
, &node
);
8723 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8724 ok(node
== (void*)elem2
, "got %p\n", node
);
8726 EXPECT_CHILDREN(elem3
);
8727 EXPECT_NO_CHILDREN(elem1
);
8729 IXMLDOMNode_Release(node
);
8731 /* cross document case - try to add as child to a node created with other doc */
8732 doc2
= create_document(&IID_IXMLDOMDocument
);
8734 hr
= IXMLDOMDocument_createElement(doc2
, _bstr_("elem4"), &elem4
);
8735 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8736 todo_wine
EXPECT_REF(elem4
, 2);
8738 /* same name, another instance */
8739 hr
= IXMLDOMDocument_createElement(doc2
, _bstr_("elem4"), &elem5
);
8740 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8741 todo_wine
EXPECT_REF(elem5
, 2);
8743 todo_wine
EXPECT_REF(elem3
, 2);
8746 hr
= IXMLDOMElement_insertBefore(elem3
, (IXMLDOMNode
*)elem4
, v
, &node
);
8747 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8748 ok(node
== (void*)elem4
, "got %p\n", node
);
8749 todo_wine
EXPECT_REF(elem4
, 3);
8750 todo_wine
EXPECT_REF(elem3
, 2);
8751 IXMLDOMNode_Release(node
);
8755 hr
= IXMLDOMElement_insertBefore(elem3
, (IXMLDOMNode
*)elem5
, v
, &node
);
8756 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8757 ok(node
== (void*)elem5
, "got %p\n", node
);
8758 todo_wine
EXPECT_REF(elem4
, 2);
8759 todo_wine
EXPECT_REF(elem5
, 3);
8760 IXMLDOMNode_Release(node
);
8762 IXMLDOMDocument_Release(doc2
);
8764 IXMLDOMElement_Release(elem1
);
8765 IXMLDOMElement_Release(elem2
);
8766 IXMLDOMElement_Release(elem3
);
8767 IXMLDOMElement_Release(elem4
);
8768 IXMLDOMElement_Release(elem5
);
8770 /* elements with same default namespace */
8772 V_I4(&v
) = NODE_ELEMENT
;
8774 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem1"), _bstr_("http://winehq.org/default"), (IXMLDOMNode
**)&elem1
);
8775 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8776 ok(elem1
!= NULL
, "got %p\n", elem1
);
8779 V_I4(&v
) = NODE_ELEMENT
;
8781 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem2"), _bstr_("http://winehq.org/default"), (IXMLDOMNode
**)&elem2
);
8782 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8783 ok(elem2
!= NULL
, "got %p\n", elem2
);
8785 /* check contents so far */
8787 hr
= IXMLDOMElement_get_xml(elem1
, &p
);
8788 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8789 ok(!lstrcmpW(p
, _bstr_("<elem1 xmlns=\"http://winehq.org/default\"/>")), "got %s\n", wine_dbgstr_w(p
));
8793 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
8794 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8795 ok(!lstrcmpW(p
, _bstr_("<elem2 xmlns=\"http://winehq.org/default\"/>")), "got %s\n", wine_dbgstr_w(p
));
8799 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, NULL
);
8800 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8802 /* get_xml depends on context, for top node it omits child namespace attribute,
8803 but at child level it's still returned */
8805 hr
= IXMLDOMElement_get_xml(elem1
, &p
);
8806 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8807 todo_wine
ok(!lstrcmpW(p
, _bstr_("<elem1 xmlns=\"http://winehq.org/default\"><elem2/></elem1>")),
8808 "got %s\n", wine_dbgstr_w(p
));
8812 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
8813 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8814 ok(!lstrcmpW(p
, _bstr_("<elem2 xmlns=\"http://winehq.org/default\"/>")), "got %s\n", wine_dbgstr_w(p
));
8817 IXMLDOMElement_Release(elem1
);
8818 IXMLDOMElement_Release(elem2
);
8820 /* child without default namespace added to node with default namespace */
8822 V_I4(&v
) = NODE_ELEMENT
;
8824 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem1"), _bstr_("http://winehq.org/default"), (IXMLDOMNode
**)&elem1
);
8825 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8826 ok(elem1
!= NULL
, "got %p\n", elem1
);
8829 V_I4(&v
) = NODE_ELEMENT
;
8831 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem2"), NULL
, (IXMLDOMNode
**)&elem2
);
8832 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8833 ok(elem2
!= NULL
, "got %p\n", elem2
);
8835 EXPECT_REF(elem2
, 1);
8837 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, NULL
);
8838 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8839 EXPECT_REF(elem2
, 1);
8842 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
8843 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8844 ok(!lstrcmpW(p
, _bstr_("<elem2/>")), "got %s\n", wine_dbgstr_w(p
));
8847 hr
= IXMLDOMElement_removeChild(elem1
, (IXMLDOMNode
*)elem2
, NULL
);
8848 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8851 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
8852 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8853 ok(!lstrcmpW(p
, _bstr_("<elem2/>")), "got %s\n", wine_dbgstr_w(p
));
8856 IXMLDOMElement_Release(elem1
);
8857 IXMLDOMElement_Release(elem2
);
8858 IXMLDOMDocument_Release(doc
);
8861 static void test_appendChild(void)
8863 IXMLDOMDocument
*doc
, *doc2
;
8864 IXMLDOMElement
*elem
, *elem2
;
8867 doc
= create_document(&IID_IXMLDOMDocument
);
8868 doc2
= create_document(&IID_IXMLDOMDocument
);
8870 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem
);
8871 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8873 hr
= IXMLDOMDocument_createElement(doc2
, _bstr_("elem2"), &elem2
);
8874 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8877 todo_wine
EXPECT_REF(elem
, 2);
8878 EXPECT_REF(doc2
, 1);
8879 todo_wine
EXPECT_REF(elem2
, 2);
8880 EXPECT_NO_CHILDREN(doc
);
8881 EXPECT_NO_CHILDREN(doc2
);
8883 hr
= IXMLDOMDocument_appendChild(doc2
, NULL
, NULL
);
8884 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8886 hr
= IXMLDOMElement_appendChild(elem
, NULL
, NULL
);
8887 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8889 /* append from another document */
8890 hr
= IXMLDOMDocument_appendChild(doc2
, (IXMLDOMNode
*)elem
, NULL
);
8891 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8894 todo_wine
EXPECT_REF(elem
, 2);
8895 EXPECT_REF(doc2
, 1);
8896 todo_wine
EXPECT_REF(elem2
, 2);
8897 EXPECT_NO_CHILDREN(doc
);
8898 EXPECT_CHILDREN(doc2
);
8900 IXMLDOMElement_Release(elem
);
8901 IXMLDOMElement_Release(elem2
);
8902 IXMLDOMDocument_Release(doc
);
8903 IXMLDOMDocument_Release(doc2
);
8906 static void test_get_doctype(void)
8908 static const WCHAR emailW
[] = {'e','m','a','i','l',0};
8909 IXMLDOMDocumentType
*doctype
;
8910 IXMLDOMDocument
*doc
;
8915 doc
= create_document(&IID_IXMLDOMDocument
);
8917 hr
= IXMLDOMDocument_get_doctype(doc
, NULL
);
8918 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8920 doctype
= (void*)0xdeadbeef;
8921 hr
= IXMLDOMDocument_get_doctype(doc
, &doctype
);
8922 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8923 ok(doctype
== NULL
, "got %p\n", doctype
);
8925 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szEmailXML
), &b
);
8926 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
8929 hr
= IXMLDOMDocument_get_doctype(doc
, &doctype
);
8930 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8931 ok(doctype
!= NULL
, "got %p\n", doctype
);
8933 hr
= IXMLDOMDocumentType_get_name(doctype
, NULL
);
8934 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8936 hr
= IXMLDOMDocumentType_get_name(doctype
, &s
);
8937 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8938 ok(!lstrcmpW(emailW
, s
), "got name %s\n", wine_dbgstr_w(s
));
8941 hr
= IXMLDOMDocumentType_get_nodeName(doctype
, &s
);
8942 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8943 ok(!lstrcmpW(emailW
, s
), "got name %s\n", wine_dbgstr_w(s
));
8946 IXMLDOMDocumentType_Release(doctype
);
8947 IXMLDOMDocument_Release(doc
);
8950 static void test_get_tagName(void)
8952 IXMLDOMDocument
*doc
;
8953 IXMLDOMElement
*elem
, *elem2
;
8957 doc
= create_document(&IID_IXMLDOMDocument
);
8959 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("element"), &elem
);
8960 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8962 hr
= IXMLDOMElement_get_tagName(elem
, NULL
);
8963 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8966 hr
= IXMLDOMElement_get_tagName(elem
, &str
);
8967 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8968 ok(!lstrcmpW(str
, _bstr_("element")), "got %s\n", wine_dbgstr_w(str
));
8971 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("s:element"), &elem2
);
8972 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8975 hr
= IXMLDOMElement_get_tagName(elem2
, &str
);
8976 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8977 ok(!lstrcmpW(str
, _bstr_("s:element")), "got %s\n", wine_dbgstr_w(str
));
8980 IXMLDOMElement_Release(elem
);
8981 IXMLDOMElement_Release(elem2
);
8982 IXMLDOMDocument_Release(doc
);
8993 static const node_type_t get_datatype
[] = {
8994 { NODE_ELEMENT
, "element", VT_NULL
, S_FALSE
},
8995 { NODE_ATTRIBUTE
, "attr", VT_NULL
, S_FALSE
},
8996 { NODE_TEXT
, "text", VT_NULL
, S_FALSE
},
8997 { NODE_CDATA_SECTION
, "cdata", VT_NULL
, S_FALSE
},
8998 { NODE_ENTITY_REFERENCE
, "entityref", VT_NULL
, S_FALSE
},
8999 { NODE_PROCESSING_INSTRUCTION
, "pi", VT_NULL
, S_FALSE
},
9000 { NODE_COMMENT
, "comment", VT_NULL
, S_FALSE
},
9001 { NODE_DOCUMENT_FRAGMENT
, "docfrag", VT_NULL
, S_FALSE
},
9005 static void test_get_dataType(void)
9007 const node_type_t
*entry
= get_datatype
;
9008 IXMLDOMDocument
*doc
;
9010 doc
= create_document(&IID_IXMLDOMDocument
);
9014 IXMLDOMNode
*node
= NULL
;
9019 V_I4(&var
) = entry
->type
;
9020 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_(entry
->name
), NULL
, &node
);
9021 ok(hr
== S_OK
, "failed to create node, type %d\n", entry
->type
);
9023 hr
= IXMLDOMNode_get_dataType(node
, NULL
);
9024 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9027 hr
= IXMLDOMNode_get_dataType(node
, &type
);
9028 ok(hr
== entry
->hr
, "got 0x%08x, expected 0x%08x. node type %d\n",
9029 hr
, entry
->hr
, entry
->type
);
9030 ok(V_VT(&type
) == entry
->vt
, "got %d, expected %d. node type %d\n",
9031 V_VT(&type
), entry
->vt
, entry
->type
);
9032 VariantClear(&type
);
9034 IXMLDOMNode_Release(node
);
9039 IXMLDOMDocument_Release(doc
);
9043 typedef struct _get_node_typestring_t
{
9046 } get_node_typestring_t
;
9048 static const get_node_typestring_t get_node_typestring
[] = {
9049 { NODE_ELEMENT
, "element" },
9050 { NODE_ATTRIBUTE
, "attribute" },
9051 { NODE_TEXT
, "text" },
9052 { NODE_CDATA_SECTION
, "cdatasection" },
9053 { NODE_ENTITY_REFERENCE
, "entityreference" },
9054 { NODE_PROCESSING_INSTRUCTION
, "processinginstruction" },
9055 { NODE_COMMENT
, "comment" },
9056 { NODE_DOCUMENT_FRAGMENT
, "documentfragment" },
9060 static void test_get_nodeTypeString(void)
9062 const get_node_typestring_t
*entry
= get_node_typestring
;
9063 IXMLDOMDocument
*doc
;
9067 doc
= create_document(&IID_IXMLDOMDocument
);
9069 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
9070 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9071 ok(!lstrcmpW(str
, _bstr_("document")), "got string %s\n", wine_dbgstr_w(str
));
9076 IXMLDOMNode
*node
= NULL
;
9080 V_I4(&var
) = entry
->type
;
9081 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("node"), NULL
, &node
);
9082 ok(hr
== S_OK
, "failed to create node, type %d\n", entry
->type
);
9084 hr
= IXMLDOMNode_get_nodeTypeString(node
, NULL
);
9085 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9087 hr
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
9088 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9089 ok(!lstrcmpW(str
, _bstr_(entry
->string
)), "got string %s, expected %s. node type %d\n",
9090 wine_dbgstr_w(str
), entry
->string
, entry
->type
);
9092 IXMLDOMNode_Release(node
);
9097 IXMLDOMDocument_Release(doc
);
9101 typedef struct _get_attributes_t
{
9106 static const get_attributes_t get_attributes
[] = {
9107 { NODE_ATTRIBUTE
, S_FALSE
},
9108 { NODE_TEXT
, S_FALSE
},
9109 { NODE_CDATA_SECTION
, S_FALSE
},
9110 { NODE_ENTITY_REFERENCE
, S_FALSE
},
9111 { NODE_PROCESSING_INSTRUCTION
, S_FALSE
},
9112 { NODE_COMMENT
, S_FALSE
},
9113 { NODE_DOCUMENT_FRAGMENT
, S_FALSE
},
9117 static void test_get_attributes(void)
9119 const get_attributes_t
*entry
= get_attributes
;
9120 IXMLDOMNamedNodeMap
*map
;
9121 IXMLDOMDocument
*doc
;
9122 IXMLDOMNode
*node
, *node2
;
9128 doc
= create_document(&IID_IXMLDOMDocument
);
9130 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
);
9131 ok(hr
== S_OK
, "got %08x\n", hr
);
9133 hr
= IXMLDOMDocument_get_attributes(doc
, NULL
);
9134 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
9136 map
= (void*)0xdeadbeef;
9137 hr
= IXMLDOMDocument_get_attributes(doc
, &map
);
9138 ok(hr
== S_FALSE
, "got %08x\n", hr
);
9139 ok(map
== NULL
, "got %p\n", map
);
9141 /* first child is <?xml ?> */
9142 hr
= IXMLDOMDocument_get_firstChild(doc
, &node
);
9143 ok(hr
== S_OK
, "got %08x\n", hr
);
9145 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9146 ok(hr
== S_OK
, "got %08x\n", hr
);
9148 node2
= (void*)0xdeadbeef;
9149 hr
= IXMLDOMNamedNodeMap_getNamedItem(map
, _bstr_("attr"), &node2
);
9150 ok(hr
== S_FALSE
, "got %08x\n", hr
);
9151 ok(node2
== NULL
, "got %p\n", node2
);
9154 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9155 EXPECT_HR(hr
, S_OK
);
9156 todo_wine
ok(length
== 1, "got %d\n", length
);
9158 if (hr
== S_OK
&& length
== 1)
9160 IXMLDOMAttribute
*attr
;
9165 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node2
);
9166 EXPECT_HR(hr
, S_OK
);
9167 ok(node
!= NULL
, "got %p\n", node2
);
9169 hr
= IXMLDOMNode_get_nodeName(node2
, &str
);
9170 EXPECT_HR(hr
, S_OK
);
9171 ok(!lstrcmpW(str
, _bstr_("version")), "got %s\n", wine_dbgstr_w(str
));
9175 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9176 EXPECT_HR(hr
, S_OK
);
9177 ok(length
== 1, "got %d\n", length
);
9180 hr
= IXMLDOMNode_get_nodeType(node2
, &type
);
9181 EXPECT_HR(hr
, S_OK
);
9182 ok(type
== NODE_ATTRIBUTE
, "got %d\n", type
);
9184 hr
= IXMLDOMNode_get_xml(node
, &str
);
9185 EXPECT_HR(hr
, S_OK
);
9186 ok(!lstrcmpW(str
, _bstr_("<?xml version=\"1.0\"?>")), "got %s\n", wine_dbgstr_w(str
));
9189 hr
= IXMLDOMNode_get_text(node
, &str
);
9190 EXPECT_HR(hr
, S_OK
);
9191 ok(!lstrcmpW(str
, _bstr_("version=\"1.0\"")), "got %s\n", wine_dbgstr_w(str
));
9194 hr
= IXMLDOMNamedNodeMap_removeNamedItem(map
, _bstr_("version"), NULL
);
9195 EXPECT_HR(hr
, S_OK
);
9198 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9199 EXPECT_HR(hr
, S_OK
);
9200 ok(length
== 0, "got %d\n", length
);
9202 hr
= IXMLDOMNode_get_xml(node
, &str
);
9203 EXPECT_HR(hr
, S_OK
);
9204 ok(!lstrcmpW(str
, _bstr_("<?xml version=\"1.0\"?>")), "got %s\n", wine_dbgstr_w(str
));
9207 hr
= IXMLDOMNode_get_text(node
, &str
);
9208 EXPECT_HR(hr
, S_OK
);
9209 ok(!lstrcmpW(str
, _bstr_("")), "got %s\n", wine_dbgstr_w(str
));
9212 IXMLDOMNamedNodeMap_Release(map
);
9214 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9215 ok(hr
== S_OK
, "got %08x\n", hr
);
9218 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9219 EXPECT_HR(hr
, S_OK
);
9220 ok(length
== 0, "got %d\n", length
);
9222 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("encoding"), &attr
);
9223 EXPECT_HR(hr
, S_OK
);
9226 V_BSTR(&v
) = _bstr_("UTF-8");
9227 hr
= IXMLDOMAttribute_put_nodeValue(attr
, v
);
9228 EXPECT_HR(hr
, S_OK
);
9230 EXPECT_REF(attr
, 2);
9231 hr
= IXMLDOMNamedNodeMap_setNamedItem(map
, (IXMLDOMNode
*)attr
, NULL
);
9232 EXPECT_HR(hr
, S_OK
);
9233 EXPECT_REF(attr
, 2);
9235 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9236 ok(hr
== S_OK
, "got %08x\n", hr
);
9239 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9240 EXPECT_HR(hr
, S_OK
);
9241 ok(length
== 1, "got %d\n", length
);
9243 hr
= IXMLDOMNode_get_xml(node
, &str
);
9244 EXPECT_HR(hr
, S_OK
);
9245 ok(!lstrcmpW(str
, _bstr_("<?xml version=\"1.0\"?>")), "got %s\n", wine_dbgstr_w(str
));
9248 hr
= IXMLDOMNode_get_text(node
, &str
);
9249 EXPECT_HR(hr
, S_OK
);
9250 ok(!lstrcmpW(str
, _bstr_("encoding=\"UTF-8\"")), "got %s\n", wine_dbgstr_w(str
));
9253 IXMLDOMNamedNodeMap_Release(map
);
9254 IXMLDOMNode_Release(node2
);
9257 IXMLDOMNode_Release(node
);
9259 /* last child is element */
9261 hr
= IXMLDOMDocument_get_lastChild(doc
, &node
);
9262 ok(hr
== S_OK
, "got %08x\n", hr
);
9265 EXPECT_REF(node
, 1);
9266 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9267 ok(hr
== S_OK
, "got %08x\n", hr
);
9268 EXPECT_REF(node
, 1);
9272 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node2
);
9273 ok(hr
== S_OK
, "got %08x\n", hr
);
9274 EXPECT_REF(node
, 1);
9275 EXPECT_REF(node2
, 1);
9278 IXMLDOMNode_Release(node2
);
9280 /* release node before map release, map still works */
9281 IXMLDOMNode_Release(node
);
9284 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9285 ok(hr
== S_OK
, "got %08x\n", hr
);
9286 ok(length
== 1, "got %d\n", length
);
9289 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node2
);
9290 ok(hr
== S_OK
, "got %08x\n", hr
);
9291 EXPECT_REF(node2
, 1);
9292 IXMLDOMNode_Release(node2
);
9294 IXMLDOMNamedNodeMap_Release(map
);
9303 V_I4(&var
) = entry
->type
;
9304 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("node"), NULL
, &node
);
9305 ok(hr
== S_OK
, "failed to create node, type %d\n", entry
->type
);
9307 hr
= IXMLDOMNode_get_attributes(node
, NULL
);
9308 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9310 map
= (void*)0xdeadbeef;
9311 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9312 ok(hr
== entry
->hr
, "got 0x%08x, expected 0x%08x. node type %d\n",
9313 hr
, entry
->hr
, entry
->type
);
9314 ok(map
== NULL
, "got %p\n", map
);
9316 IXMLDOMNode_Release(node
);
9321 IXMLDOMDocument_Release(doc
);
9325 static void test_selection(void)
9327 IXMLDOMSelection
*selection
, *selection2
;
9328 IEnumVARIANT
*enum1
, *enum2
, *enum3
;
9329 IXMLDOMNodeList
*list
;
9330 IUnknown
*unk1
, *unk2
;
9331 IXMLDOMDocument
*doc
;
9332 IDispatchEx
*dispex
;
9343 doc
= create_document(&IID_IXMLDOMDocument
);
9345 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
);
9346 EXPECT_HR(hr
, S_OK
);
9348 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
);
9349 EXPECT_HR(hr
, S_OK
);
9351 hr
= IXMLDOMNodeList_QueryInterface(list
, &IID_IXMLDOMSelection
, (void**)&selection
);
9352 EXPECT_HR(hr
, S_OK
);
9353 IXMLDOMSelection_Release(selection
);
9355 /* collection disp id */
9356 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IDispatchEx
, (void**)&dispex
);
9357 EXPECT_HR(hr
, S_OK
);
9359 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
9360 EXPECT_HR(hr
, S_OK
);
9361 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got %d\n", did
);
9363 hr
= IXMLDOMSelection_get_length(selection
, &len
);
9364 EXPECT_HR(hr
, S_OK
);
9365 ok(len
== 1, "got %d\n", len
);
9366 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("10"), 0, &did
);
9367 EXPECT_HR(hr
, S_OK
);
9368 ok(did
== DISPID_DOM_COLLECTION_BASE
+10, "got %d\n", did
);
9369 IDispatchEx_Release(dispex
);
9371 /* IEnumVARIANT tests */
9373 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IEnumVARIANT
, (void**)&enum1
);
9374 EXPECT_HR(hr
, S_OK
);
9375 ok(enum1
!= NULL
, "got %p\n", enum1
);
9376 EXPECT_REF(enum1
, 2);
9378 EXPECT_REF(selection
, 1);
9379 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IUnknown
, (void**)&unk1
);
9380 EXPECT_HR(hr
, S_OK
);
9381 EXPECT_REF(selection
, 2);
9382 EXPECT_REF(enum1
, 2);
9384 /* enumerator and selection object return same IUnknown* */
9385 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IUnknown
, (void**)&unk2
);
9386 EXPECT_HR(hr
, S_OK
);
9387 EXPECT_REF(selection
, 3);
9388 EXPECT_REF(enum1
, 2);
9389 ok(unk2
== unk1
, "got %p, %p\n", unk1
, unk2
);
9390 IUnknown_Release(unk2
);
9392 EXPECT_REF(selection
, 2);
9393 IEnumVARIANT_AddRef(enum1
);
9394 EXPECT_REF(selection
, 2);
9395 IEnumVARIANT_Release(enum1
);
9398 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IEnumVARIANT
, (void**)&enum3
);
9399 EXPECT_HR(hr
, S_OK
);
9400 ok(enum3
!= NULL
, "got %p\n", enum3
);
9401 ok(enum1
== enum3
, "got %p and %p\n", enum1
, enum3
);
9402 EXPECT_REF(enum1
, 3);
9403 IEnumVARIANT_Release(enum3
);
9405 EXPECT_REF(selection
, 2);
9406 EXPECT_REF(enum1
, 2);
9409 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum2
);
9410 EXPECT_HR(hr
, S_OK
);
9411 ok(enum2
!= NULL
, "got %p\n", enum2
);
9413 EXPECT_REF(selection
, 3);
9414 EXPECT_REF(enum1
, 2);
9415 EXPECT_REF(enum2
, 1);
9417 ok(enum1
!= enum2
, "got %p, %p\n", enum1
, enum2
);
9419 hr
= IEnumVARIANT_QueryInterface(enum2
, &IID_IUnknown
, (void**)&unk2
);
9420 EXPECT_HR(hr
, S_OK
);
9421 EXPECT_REF(selection
, 3);
9422 EXPECT_REF(enum2
, 2);
9423 ok(unk2
!= unk1
, "got %p, %p\n", unk1
, unk2
);
9424 IUnknown_Release(unk2
);
9425 IUnknown_Release(unk1
);
9428 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IXMLDOMSelection
, (void**)&selection2
);
9429 EXPECT_HR(hr
, S_OK
);
9430 ok(selection2
== selection
, "got %p and %p\n", selection
, selection2
);
9431 EXPECT_REF(selection
, 3);
9432 EXPECT_REF(enum1
, 2);
9434 IXMLDOMSelection_Release(selection2
);
9436 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IDispatch
, (void**)&disp
);
9437 EXPECT_HR(hr
, S_OK
);
9438 EXPECT_REF(selection
, 3);
9439 IDispatch_Release(disp
);
9441 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IEnumVARIANT
, (void**)&enum3
);
9442 EXPECT_HR(hr
, S_OK
);
9443 ok(enum3
== enum1
, "got %p and %p\n", enum3
, enum1
);
9444 EXPECT_REF(selection
, 2);
9445 EXPECT_REF(enum1
, 3);
9447 IEnumVARIANT_Release(enum1
);
9448 IEnumVARIANT_Release(enum2
);
9449 IEnumVARIANT_Release(enum3
);
9452 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum1
);
9453 EXPECT_HR(hr
, S_OK
);
9454 ok(enum1
!= NULL
, "got %p\n", enum1
);
9455 EXPECT_REF(enum1
, 1);
9456 EXPECT_REF(selection
, 2);
9459 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum2
);
9460 EXPECT_HR(hr
, S_OK
);
9461 ok(enum2
!= NULL
, "got %p\n", enum2
);
9462 EXPECT_REF(enum2
, 1);
9463 EXPECT_REF(selection
, 3);
9465 ok(enum1
!= enum2
, "got %p, %p\n", enum1
, enum2
);
9467 IEnumVARIANT_AddRef(enum1
);
9468 EXPECT_REF(selection
, 3);
9469 EXPECT_REF(enum1
, 2);
9470 EXPECT_REF(enum2
, 1);
9471 IEnumVARIANT_Release(enum1
);
9473 IEnumVARIANT_Release(enum1
);
9474 IEnumVARIANT_Release(enum2
);
9476 EXPECT_REF(selection
, 1);
9478 IXMLDOMNodeList_Release(list
);
9480 hr
= IXMLDOMDocument_get_childNodes(doc
, &list
);
9481 EXPECT_HR(hr
, S_OK
);
9483 hr
= IXMLDOMNodeList_QueryInterface(list
, &IID_IXMLDOMSelection
, (void**)&selection
);
9484 EXPECT_HR(hr
, E_NOINTERFACE
);
9486 IXMLDOMNodeList_Release(list
);
9488 /* test if IEnumVARIANT touches selection context */
9489 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(xpath_simple_list
), &b
);
9490 EXPECT_HR(hr
, S_OK
);
9492 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root/*"), &list
);
9493 EXPECT_HR(hr
, S_OK
);
9495 hr
= IXMLDOMNodeList_QueryInterface(list
, &IID_IXMLDOMSelection
, (void**)&selection
);
9496 EXPECT_HR(hr
, S_OK
);
9499 hr
= IXMLDOMSelection_get_length(selection
, &len
);
9500 EXPECT_HR(hr
, S_OK
);
9501 ok(len
== 4, "got %d\n", len
);
9504 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum1
);
9505 EXPECT_HR(hr
, S_OK
);
9507 /* no-op if zero count */
9509 hr
= IEnumVARIANT_Next(enum1
, 0, &v
, NULL
);
9510 EXPECT_HR(hr
, S_OK
);
9511 ok(V_VT(&v
) == VT_I2
, "got var type %d\n", V_VT(&v
));
9513 /* positive count, null array pointer */
9514 hr
= IEnumVARIANT_Next(enum1
, 1, NULL
, NULL
);
9515 EXPECT_HR(hr
, E_INVALIDARG
);
9518 hr
= IEnumVARIANT_Next(enum1
, 1, NULL
, &ret
);
9519 EXPECT_HR(hr
, E_INVALIDARG
);
9520 ok(ret
== 0, "got %d\n", ret
);
9523 hr
= IEnumVARIANT_Next(enum1
, 1, &v
, NULL
);
9524 EXPECT_HR(hr
, S_OK
);
9525 ok(V_VT(&v
) == VT_DISPATCH
, "got var type %d\n", V_VT(&v
));
9527 hr
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IXMLDOMNode
, (void**)&node
);
9528 EXPECT_HR(hr
, S_OK
);
9529 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
9530 EXPECT_HR(hr
, S_OK
);
9531 ok(!lstrcmpW(name
, _bstr_("a")), "got node name %s\n", wine_dbgstr_w(name
));
9532 SysFreeString(name
);
9533 IXMLDOMNode_Release(node
);
9536 /* list cursor is updated */
9537 hr
= IXMLDOMSelection_nextNode(selection
, &node
);
9538 EXPECT_HR(hr
, S_OK
);
9539 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
9540 EXPECT_HR(hr
, S_OK
);
9541 ok(!lstrcmpW(name
, _bstr_("c")), "got node name %s\n", wine_dbgstr_w(name
));
9542 IXMLDOMNode_Release(node
);
9543 SysFreeString(name
);
9546 hr
= IEnumVARIANT_Next(enum1
, 1, &v
, NULL
);
9547 EXPECT_HR(hr
, S_OK
);
9548 ok(V_VT(&v
) == VT_DISPATCH
, "got var type %d\n", V_VT(&v
));
9549 hr
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IXMLDOMNode
, (void**)&node
);
9550 EXPECT_HR(hr
, S_OK
);
9551 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
9552 EXPECT_HR(hr
, S_OK
);
9553 ok(!lstrcmpW(name
, _bstr_("b")), "got node name %s\n", wine_dbgstr_w(name
));
9554 SysFreeString(name
);
9555 IXMLDOMNode_Release(node
);
9557 IEnumVARIANT_Release(enum1
);
9559 hr
= IXMLDOMSelection_nextNode(selection
, &node
);
9560 EXPECT_HR(hr
, S_OK
);
9561 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
9562 EXPECT_HR(hr
, S_OK
);
9563 ok(!lstrcmpW(name
, _bstr_("d")), "got node name %s\n", wine_dbgstr_w(name
));
9564 IXMLDOMNode_Release(node
);
9565 SysFreeString(name
);
9567 IXMLDOMSelection_Release(selection
);
9568 IXMLDOMNodeList_Release(list
);
9569 IXMLDOMDocument_Release(doc
);
9574 static void write_to_file(const char *name
, const char *data
)
9580 hfile
= CreateFileA(name
, GENERIC_WRITE
|GENERIC_READ
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
9581 ok(hfile
!= INVALID_HANDLE_VALUE
, "failed to create test file: %s\n", name
);
9583 ret
= WriteFile(hfile
, data
, strlen(data
), &written
, NULL
);
9584 ok(ret
, "WriteFile failed: %s, %d\n", name
, GetLastError());
9589 static void test_load(void)
9591 IXMLDOMDocument
*doc
, *doc2
;
9592 IXMLDOMNodeList
*list
;
9593 IXMLDOMElement
*elem
;
9597 BSTR path
, bstr1
, bstr2
;
9600 /* prepare a file */
9601 write_to_file("test.xml", win1252xml
);
9603 doc
= create_document(&IID_IXMLDOMDocument
);
9605 /* null pointer as input */
9606 V_VT(&src
) = VT_UNKNOWN
;
9607 V_UNKNOWN(&src
) = NULL
;
9608 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9609 EXPECT_HR(hr
, E_INVALIDARG
);
9610 ok(b
== VARIANT_FALSE
, "got %d\n", b
);
9612 path
= _bstr_("test.xml");
9614 /* load from path: VT_BSTR */
9615 V_VT(&src
) = VT_BSTR
;
9616 V_BSTR(&src
) = path
;
9617 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9618 EXPECT_HR(hr
, S_OK
);
9619 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
9622 hr
= IXMLDOMDocument_get_url(doc
, &bstr1
);
9623 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9624 SysFreeString(bstr1
);
9626 /* load from a path: VT_BSTR|VT_BYREF */
9627 V_VT(&src
) = VT_BSTR
| VT_BYREF
;
9628 V_BSTRREF(&src
) = &path
;
9629 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9630 EXPECT_HR(hr
, S_OK
);
9631 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
9634 hr
= IXMLDOMDocument_get_url(doc
, &bstr1
);
9635 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9637 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
9638 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9640 /* create another instance for the same document, check url */
9641 hr
= IXMLDOMElement_get_ownerDocument(elem
, &doc2
);
9642 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9644 hr
= IXMLDOMDocument_get_url(doc
, &bstr2
);
9645 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9646 ok(!lstrcmpW(bstr1
, bstr2
), "got %s\n", wine_dbgstr_w(bstr2
));
9648 IXMLDOMDocument_Release(doc2
);
9649 IXMLDOMElement_Release(elem
);
9651 SysFreeString(bstr1
);
9652 SysFreeString(bstr2
);
9654 /* load from a path: VT_BSTR|VT_BYREF, null ptr */
9655 V_VT(&src
) = VT_BSTR
| VT_BYREF
;
9656 V_BSTRREF(&src
) = NULL
;
9657 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9658 EXPECT_HR(hr
, E_INVALIDARG
);
9659 ok(b
== VARIANT_FALSE
, "got %d\n", b
);
9662 hr
= IXMLDOMDocument_get_url(doc
, &bstr1
);
9663 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9664 SysFreeString(bstr1
);
9666 DeleteFileA("test.xml");
9668 /* load from existing path, no xml content */
9669 write_to_file("test.xml", nocontent
);
9671 V_VT(&src
) = VT_BSTR
;
9672 V_BSTR(&src
) = path
;
9674 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9675 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
9676 ok(b
== VARIANT_FALSE
, "got %d\n", b
);
9679 hr
= IXMLDOMDocument_get_url(doc
, &bstr1
);
9680 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
9681 ok(bstr1
== NULL
, "got %p\n", bstr1
);
9683 DeleteFileA("test.xml");
9684 IXMLDOMDocument_Release(doc
);
9686 doc
= create_document(&IID_IXMLDOMDocument
);
9688 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
);
9689 EXPECT_HR(hr
, S_OK
);
9690 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
9692 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("//*"), &list
);
9693 EXPECT_HR(hr
, S_OK
);
9694 bstr1
= _bstr_(list_to_string(list
));
9696 hr
= IXMLDOMNodeList_reset(list
);
9697 EXPECT_HR(hr
, S_OK
);
9699 IXMLDOMDocument_Release(doc
);
9701 doc
= create_document(&IID_IXMLDOMDocument
);
9704 V_ARRAY(&src
) = SafeArrayCreateVector(VT_UI1
, 0, lstrlenA(szExampleXML
));
9705 V_VT(&src
) = VT_ARRAY
|VT_UI1
;
9706 ok(V_ARRAY(&src
) != NULL
, "SafeArrayCreateVector() returned NULL\n");
9708 hr
= SafeArrayAccessData(V_ARRAY(&src
), &ptr
);
9709 EXPECT_HR(hr
, S_OK
);
9710 ok(ptr
!= NULL
, "SafeArrayAccessData() returned NULL\n");
9712 memcpy(ptr
, szExampleXML
, lstrlenA(szExampleXML
));
9713 hr
= SafeArrayUnlock(V_ARRAY(&src
));
9714 EXPECT_HR(hr
, S_OK
);
9716 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9717 EXPECT_HR(hr
, S_OK
);
9718 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
9720 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("//*"), &list
);
9721 EXPECT_HR(hr
, S_OK
);
9722 bstr2
= _bstr_(list_to_string(list
));
9724 hr
= IXMLDOMNodeList_reset(list
);
9725 EXPECT_HR(hr
, S_OK
);
9727 ok(lstrcmpW(bstr1
, bstr2
) == 0, "strings not equal: %s : %s\n",
9728 wine_dbgstr_w(bstr1
), wine_dbgstr_w(bstr2
));
9730 IXMLDOMDocument_Release(doc
);
9731 IXMLDOMNodeList_Release(list
);
9734 /* UTF-16 isn't accepted */
9735 doc
= create_document(&IID_IXMLDOMDocument
);
9737 V_ARRAY(&src
) = SafeArrayCreateVector(VT_UI1
, 0, lstrlenW(szComplete1
) * sizeof(WCHAR
));
9738 V_VT(&src
) = VT_ARRAY
|VT_UI1
;
9739 ok(V_ARRAY(&src
) != NULL
, "SafeArrayCreateVector() returned NULL\n");
9741 hr
= SafeArrayAccessData(V_ARRAY(&src
), &ptr
);
9742 EXPECT_HR(hr
, S_OK
);
9743 ok(ptr
!= NULL
, "SafeArrayAccessData() returned NULL\n");
9745 memcpy(ptr
, szComplete1
, lstrlenW(szComplete1
) * sizeof(WCHAR
));
9746 hr
= SafeArrayUnlock(V_ARRAY(&src
));
9747 EXPECT_HR(hr
, S_OK
);
9749 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9750 todo_wine
EXPECT_HR(hr
, S_FALSE
);
9751 todo_wine
ok(b
== VARIANT_FALSE
, "got %d\n", b
);
9755 /* it doesn't like it as a VT_ARRAY|VT_UI2 either */
9756 V_ARRAY(&src
) = SafeArrayCreateVector(VT_UI2
, 0, lstrlenW(szComplete1
));
9757 V_VT(&src
) = VT_ARRAY
|VT_UI2
;
9758 ok(V_ARRAY(&src
) != NULL
, "SafeArrayCreateVector() returned NULL\n");
9760 hr
= SafeArrayAccessData(V_ARRAY(&src
), &ptr
);
9761 EXPECT_HR(hr
, S_OK
);
9762 ok(ptr
!= NULL
, "SafeArrayAccessData() returned NULL\n");
9764 memcpy(ptr
, szComplete1
, lstrlenW(szComplete1
) * sizeof(WCHAR
));
9765 hr
= SafeArrayUnlock(V_ARRAY(&src
));
9766 EXPECT_HR(hr
, S_OK
);
9768 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
9769 todo_wine
EXPECT_HR(hr
, E_INVALIDARG
);
9770 ok(b
== VARIANT_FALSE
, "got %d\n", b
);
9773 IXMLDOMDocument_Release(doc
);
9778 static void test_domobj_dispex(IUnknown
*obj
)
9780 static const WCHAR testW
[] = {'t','e','s','t','p','r','o','p',0};
9781 DISPID dispid
= DISPID_XMLDOM_NODELIST_RESET
;
9782 IDispatchEx
*dispex
;
9789 hr
= IUnknown_QueryInterface(obj
, &IID_IDispatchEx
, (void**)&dispex
);
9790 EXPECT_HR(hr
, S_OK
);
9791 if (FAILED(hr
)) return;
9794 hr
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
9795 EXPECT_HR(hr
, S_OK
);
9796 ok(ticnt
== 1, "ticnt=%u\n", ticnt
);
9798 name
= SysAllocString(szstar
);
9799 hr
= IDispatchEx_DeleteMemberByName(dispex
, name
, fdexNameCaseSensitive
);
9800 EXPECT_HR(hr
, E_NOTIMPL
);
9801 SysFreeString(name
);
9803 hr
= IDispatchEx_DeleteMemberByDispID(dispex
, dispid
);
9804 EXPECT_HR(hr
, E_NOTIMPL
);
9807 hr
= IDispatchEx_GetMemberProperties(dispex
, dispid
, grfdexPropCanAll
, &props
);
9808 EXPECT_HR(hr
, E_NOTIMPL
);
9809 ok(props
== 0, "expected 0 got %d\n", props
);
9811 hr
= IDispatchEx_GetMemberName(dispex
, dispid
, &name
);
9812 EXPECT_HR(hr
, E_NOTIMPL
);
9813 if (SUCCEEDED(hr
)) SysFreeString(name
);
9815 hr
= IDispatchEx_GetNextDispID(dispex
, fdexEnumDefault
, DISPID_XMLDOM_NODELIST_RESET
, &dispid
);
9816 EXPECT_HR(hr
, E_NOTIMPL
);
9818 unk
= (IUnknown
*)0xdeadbeef;
9819 hr
= IDispatchEx_GetNameSpaceParent(dispex
, &unk
);
9820 EXPECT_HR(hr
, E_NOTIMPL
);
9821 ok(unk
== (IUnknown
*)0xdeadbeef, "got %p\n", unk
);
9823 name
= SysAllocString(testW
);
9824 hr
= IDispatchEx_GetDispID(dispex
, name
, fdexNameEnsure
, &dispid
);
9825 ok(hr
== DISP_E_UNKNOWNNAME
, "got 0x%08x\n", hr
);
9826 SysFreeString(name
);
9828 IDispatchEx_Release(dispex
);
9831 static void test_mxnamespacemanager(void)
9833 static const char xmluriA
[] = "http://www.w3.org/XML/1998/namespace";
9834 IMXNamespacePrefixes
*prefixes
;
9835 IVBMXNamespaceManager
*mgr2
;
9836 IMXNamespaceManager
*nsmgr
;
9837 IUnknown
*unk1
, *unk2
;
9844 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
9845 &IID_IMXNamespaceManager
, (void**)&nsmgr
);
9846 EXPECT_HR(hr
, S_OK
);
9848 /* IMXNamespaceManager inherits from IUnknown */
9849 hr
= IMXNamespaceManager_QueryInterface(nsmgr
, &IID_IDispatch
, (void**)&disp
);
9850 EXPECT_HR(hr
, S_OK
);
9851 IDispatch_Release(disp
);
9853 hr
= IMXNamespaceManager_QueryInterface(nsmgr
, &IID_IVBMXNamespaceManager
, (void**)&mgr2
);
9854 EXPECT_HR(hr
, S_OK
);
9856 EXPECT_REF(nsmgr
, 2);
9857 EXPECT_REF(mgr2
, 2);
9859 hr
= IVBMXNamespaceManager_getDeclaredPrefixes(mgr2
, &prefixes
);
9861 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9864 IDispatchEx
*dispex
;
9866 DISPPARAMS dispparams
;
9868 ok(prefixes
!= NULL
, "got %p\n", prefixes
);
9869 EXPECT_REF(nsmgr
, 2);
9870 EXPECT_REF(mgr2
, 2);
9871 EXPECT_REF(prefixes
, 1);
9873 IVBMXNamespaceManager_QueryInterface(mgr2
, &IID_IUnknown
, (void**)&unk1
);
9874 IMXNamespacePrefixes_QueryInterface(prefixes
, &IID_IUnknown
, (void**)&unk2
);
9876 EXPECT_REF(mgr2
, 3);
9877 EXPECT_REF(prefixes
, 2);
9879 IUnknown_Release(unk1
);
9880 IUnknown_Release(unk2
);
9882 hr
= IMXNamespacePrefixes_QueryInterface(prefixes
, &IID_IDispatchEx
, (void**)&dispex
);
9883 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9887 dispparams
.cArgs
= 1;
9888 dispparams
.cNamedArgs
= 0;
9889 dispparams
.rgdispidNamedArgs
= NULL
;
9890 dispparams
.rgvarg
= &arg
;
9892 V_VT(&ret
) = VT_EMPTY
;
9893 V_DISPATCH(&ret
) = (void*)0x1;
9894 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
9895 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9896 ok(V_VT(&ret
) == VT_BSTR
, "got %d\n", V_VT(&ret
));
9897 ok(V_BSTR(&ret
) != NULL
, "got %p\n", V_BSTR(&ret
));
9900 IDispatchEx_Release(dispex
);
9901 IMXNamespacePrefixes_Release(prefixes
);
9903 IVBMXNamespaceManager_Release(mgr2
);
9905 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, NULL
);
9906 EXPECT_HR(hr
, S_OK
);
9908 /* prefix already added */
9909 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri"));
9910 EXPECT_HR(hr
, S_FALSE
);
9912 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns0"), NULL
);
9913 EXPECT_HR(hr
, E_INVALIDARG
);
9915 /* "xml" and "xmlns" are not allowed here */
9916 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("xml"), _bstr_("uri1"));
9917 EXPECT_HR(hr
, E_INVALIDARG
);
9919 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("xmlns"), _bstr_("uri1"));
9920 EXPECT_HR(hr
, E_INVALIDARG
);
9922 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, -1, NULL
, NULL
);
9923 EXPECT_HR(hr
, E_FAIL
);
9925 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, NULL
, NULL
);
9926 EXPECT_HR(hr
, E_POINTER
);
9929 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, NULL
, &len
);
9930 EXPECT_HR(hr
, S_OK
);
9931 ok(len
== 3, "got %d\n", len
);
9935 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
9936 EXPECT_HR(hr
, E_XML_BUFFERTOOSMALL
);
9937 ok(len
== -1, "got %d\n", len
);
9938 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
9942 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
9943 EXPECT_HR(hr
, S_OK
);
9944 ok(len
== 3, "got %d\n", len
);
9945 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW
));
9948 hr
= IMXNamespaceManager_getURI(nsmgr
, NULL
, NULL
, NULL
, NULL
);
9949 EXPECT_HR(hr
, E_INVALIDARG
);
9952 hr
= IMXNamespaceManager_getURI(nsmgr
, NULL
, NULL
, NULL
, &len
);
9953 EXPECT_HR(hr
, E_INVALIDARG
);
9954 ok(len
== -1, "got %d\n", len
);
9956 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, NULL
, NULL
);
9957 EXPECT_HR(hr
, E_POINTER
);
9960 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, NULL
, &len
);
9961 EXPECT_HR(hr
, S_OK
);
9962 /* length of "xml" uri is constant */
9963 ok(len
== strlen(xmluriA
), "got %d\n", len
);
9966 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, buffW
, &len
);
9967 EXPECT_HR(hr
, S_OK
);
9968 ok(len
== strlen(xmluriA
), "got %d\n", len
);
9969 ok(!lstrcmpW(buffW
, _bstr_(xmluriA
)), "got prefix %s\n", wine_dbgstr_w(buffW
));
9971 len
= strlen(xmluriA
)-1;
9973 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, buffW
, &len
);
9974 EXPECT_HR(hr
, E_XML_BUFFERTOOSMALL
);
9975 ok(len
== strlen(xmluriA
)-1, "got %d\n", len
);
9976 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
9978 /* prefix xml1 not defined */
9980 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml1"), NULL
, NULL
, &len
);
9981 EXPECT_HR(hr
, S_FALSE
);
9982 ok(len
== 0, "got %d\n", len
);
9986 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml1"), NULL
, buffW
, &len
);
9987 EXPECT_HR(hr
, S_FALSE
);
9988 ok(buffW
[0] == 0, "got %x\n", buffW
[0]);
9989 ok(len
== 0, "got %d\n", len
);
9991 /* IDispatchEx tests */
9992 hr
= IMXNamespaceManager_QueryInterface(nsmgr
, &IID_IUnknown
, (void**)&unk
);
9993 EXPECT_HR(hr
, S_OK
);
9994 test_domobj_dispex(unk
);
9995 IUnknown_Release(unk
);
9997 IMXNamespaceManager_Release(nsmgr
);
10000 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
10001 &IID_IMXNamespaceManager
, (void**)&nsmgr
);
10002 EXPECT_HR(hr
, S_OK
);
10004 hr
= IMXNamespaceManager_getPrefix(nsmgr
, NULL
, 0, NULL
, NULL
);
10005 EXPECT_HR(hr
, E_INVALIDARG
);
10008 hr
= IMXNamespaceManager_getPrefix(nsmgr
, NULL
, 0, NULL
, &len
);
10009 EXPECT_HR(hr
, E_INVALIDARG
);
10010 ok(len
== -1, "got %d\n", len
);
10014 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns0 uri"), 0, buffW
, &len
);
10015 EXPECT_HR(hr
, E_FAIL
);
10016 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10017 ok(len
== 100, "got %d\n", len
);
10021 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns0 uri"), 0, buffW
, &len
);
10022 EXPECT_HR(hr
, E_FAIL
);
10023 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10024 ok(len
== 0, "got %d\n", len
);
10026 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns1"), _bstr_("ns1 uri"));
10027 EXPECT_HR(hr
, S_OK
);
10031 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 0, buffW
, &len
);
10032 EXPECT_HR(hr
, S_OK
);
10033 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got %s\n", wine_dbgstr_w(buffW
));
10034 ok(len
== 3, "got %d\n", len
);
10038 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("http://www.w3.org/XML/1998/namespace"), 0, buffW
, &len
);
10039 EXPECT_HR(hr
, S_OK
);
10040 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got %s\n", wine_dbgstr_w(buffW
));
10041 ok(len
== 3, "got %d\n", len
);
10043 /* with null buffer it's possible to get required length */
10045 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("http://www.w3.org/XML/1998/namespace"), 0, NULL
, &len
);
10046 EXPECT_HR(hr
, S_OK
);
10047 ok(len
== 3, "got %d\n", len
);
10050 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("http://www.w3.org/XML/1998/namespace"), 0, NULL
, &len
);
10051 EXPECT_HR(hr
, S_OK
);
10052 ok(len
== 3, "got %d\n", len
);
10056 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 1, buffW
, &len
);
10057 EXPECT_HR(hr
, E_FAIL
);
10058 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10059 ok(len
== 100, "got %d\n", len
);
10063 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 2, buffW
, &len
);
10064 EXPECT_HR(hr
, E_FAIL
);
10065 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10066 ok(len
== 100, "got %d\n", len
);
10070 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_(""), 0, buffW
, &len
);
10071 EXPECT_HR(hr
, E_INVALIDARG
);
10072 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10073 ok(len
== 100, "got %d\n", len
);
10077 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_(""), 1, buffW
, &len
);
10078 EXPECT_HR(hr
, E_INVALIDARG
);
10079 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10080 ok(len
== 100, "got %d\n", len
);
10084 hr
= IMXNamespaceManager_getPrefix(nsmgr
, NULL
, 0, buffW
, &len
);
10085 EXPECT_HR(hr
, E_INVALIDARG
);
10086 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10087 ok(len
== 100, "got %d\n", len
);
10091 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns0 uri"), 1, buffW
, &len
);
10092 EXPECT_HR(hr
, E_FAIL
);
10093 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10094 ok(len
== 100, "got %d\n", len
);
10098 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_(""), 1, buffW
, &len
);
10099 EXPECT_HR(hr
, E_INVALIDARG
);
10100 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10101 ok(len
== 100, "got %d\n", len
);
10103 /* declare another one, indices are shifted */
10104 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns2"), _bstr_("ns2 uri"));
10105 EXPECT_HR(hr
, S_OK
);
10109 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 0, buffW
, &len
);
10110 EXPECT_HR(hr
, S_OK
);
10111 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got %s\n", wine_dbgstr_w(buffW
));
10112 ok(len
== 3, "got %d\n", len
);
10116 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns2 uri"), 0, buffW
, &len
);
10117 EXPECT_HR(hr
, S_OK
);
10118 ok(!lstrcmpW(buffW
, _bstr_("ns2")), "got %s\n", wine_dbgstr_w(buffW
));
10119 ok(len
== 3, "got %d\n", len
);
10123 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns2 uri"), 1, buffW
, &len
);
10124 EXPECT_HR(hr
, E_FAIL
);
10125 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10126 ok(len
== 100, "got %d\n", len
);
10130 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_(""), 1, buffW
, &len
);
10131 EXPECT_HR(hr
, E_INVALIDARG
);
10132 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10133 ok(len
== 100, "got %d\n", len
);
10135 IMXNamespaceManager_Release(nsmgr
);
10137 /* push/pop tests */
10138 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
10139 &IID_IMXNamespaceManager
, (void**)&nsmgr
);
10140 EXPECT_HR(hr
, S_OK
);
10142 /* pop with empty stack */
10143 hr
= IMXNamespaceManager_popContext(nsmgr
);
10144 EXPECT_HR(hr
, E_FAIL
);
10146 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns1"), _bstr_("ns1 uri"));
10147 EXPECT_HR(hr
, S_OK
);
10151 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 0, buffW
, &len
);
10152 EXPECT_HR(hr
, S_OK
);
10153 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got %s\n", wine_dbgstr_w(buffW
));
10154 ok(len
== 3, "got %d\n", len
);
10156 hr
= IMXNamespaceManager_pushContext(nsmgr
);
10157 EXPECT_HR(hr
, S_OK
);
10161 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 0, buffW
, &len
);
10162 EXPECT_HR(hr
, S_OK
);
10163 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got %s\n", wine_dbgstr_w(buffW
));
10164 ok(len
== 3, "got %d\n", len
);
10166 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns2"), _bstr_("ns2 uri"));
10167 EXPECT_HR(hr
, S_OK
);
10171 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns2 uri"), 0, buffW
, &len
);
10172 EXPECT_HR(hr
, S_OK
);
10173 ok(!lstrcmpW(buffW
, _bstr_("ns2")), "got %s\n", wine_dbgstr_w(buffW
));
10174 ok(len
== 3, "got %d\n", len
);
10176 hr
= IMXNamespaceManager_pushContext(nsmgr
);
10177 EXPECT_HR(hr
, S_OK
);
10178 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns3"), _bstr_("ns3 uri"));
10179 EXPECT_HR(hr
, S_OK
);
10183 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns2 uri"), 0, buffW
, &len
);
10184 EXPECT_HR(hr
, S_OK
);
10185 ok(!lstrcmpW(buffW
, _bstr_("ns2")), "got %s\n", wine_dbgstr_w(buffW
));
10186 ok(len
== 3, "got %d\n", len
);
10190 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 0, buffW
, &len
);
10191 EXPECT_HR(hr
, S_OK
);
10192 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got %s\n", wine_dbgstr_w(buffW
));
10193 ok(len
== 3, "got %d\n", len
);
10195 hr
= IMXNamespaceManager_popContext(nsmgr
);
10196 EXPECT_HR(hr
, S_OK
);
10198 hr
= IMXNamespaceManager_popContext(nsmgr
);
10199 EXPECT_HR(hr
, S_OK
);
10203 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns2 uri"), 0, buffW
, &len
);
10204 EXPECT_HR(hr
, E_FAIL
);
10205 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10206 ok(len
== 100, "got %d\n", len
);
10210 hr
= IMXNamespaceManager_getPrefix(nsmgr
, _bstr_("ns1 uri"), 0, buffW
, &len
);
10211 EXPECT_HR(hr
, S_OK
);
10212 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got %s\n", wine_dbgstr_w(buffW
));
10213 ok(len
== 3, "got %d\n", len
);
10215 IMXNamespaceManager_Release(nsmgr
);
10220 static void test_mxnamespacemanager_override(void)
10222 IMXNamespaceManager
*nsmgr
;
10228 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
10229 &IID_IMXNamespaceManager
, (void**)&nsmgr
);
10230 EXPECT_HR(hr
, S_OK
);
10232 len
= sizeof(buffW
)/sizeof(WCHAR
);
10234 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
10235 EXPECT_HR(hr
, S_OK
);
10236 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10238 len
= sizeof(buffW
)/sizeof(WCHAR
);
10240 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 1, buffW
, &len
);
10241 EXPECT_HR(hr
, E_FAIL
);
10243 hr
= IMXNamespaceManager_getAllowOverride(nsmgr
, NULL
);
10244 EXPECT_HR(hr
, E_POINTER
);
10247 hr
= IMXNamespaceManager_getAllowOverride(nsmgr
, &b
);
10248 EXPECT_HR(hr
, S_OK
);
10249 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10251 hr
= IMXNamespaceManager_putAllowOverride(nsmgr
, VARIANT_FALSE
);
10252 EXPECT_HR(hr
, S_OK
);
10254 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri"));
10255 EXPECT_HR(hr
, S_OK
);
10257 len
= sizeof(buffW
)/sizeof(WCHAR
);
10259 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_(""), NULL
, buffW
, &len
);
10260 EXPECT_HR(hr
, S_OK
);
10261 ok(!lstrcmpW(buffW
, _bstr_("ns0 uri")), "got uri %s\n", wine_dbgstr_w(buffW
));
10263 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns0"), _bstr_("ns0 uri"));
10264 EXPECT_HR(hr
, S_OK
);
10266 len
= sizeof(buffW
)/sizeof(WCHAR
);
10268 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
10269 EXPECT_HR(hr
, S_OK
);
10270 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10272 len
= sizeof(buffW
)/sizeof(WCHAR
);
10274 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 1, buffW
, &len
);
10275 EXPECT_HR(hr
, S_OK
);
10276 ok(!lstrcmpW(buffW
, _bstr_("ns0")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10278 len
= sizeof(buffW
)/sizeof(WCHAR
);
10280 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 2, buffW
, &len
);
10281 EXPECT_HR(hr
, S_OK
);
10282 ok(!lstrcmpW(buffW
, _bstr_("")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10284 /* new prefix placed at index 1 always */
10285 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns1"), _bstr_("ns1 uri"));
10286 EXPECT_HR(hr
, S_OK
);
10288 len
= sizeof(buffW
)/sizeof(WCHAR
);
10290 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 1, buffW
, &len
);
10291 EXPECT_HR(hr
, S_OK
);
10292 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10294 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_(""), NULL
);
10295 todo_wine
EXPECT_HR(hr
, E_FAIL
);
10297 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, NULL
);
10298 EXPECT_HR(hr
, E_FAIL
);
10300 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri"));
10301 EXPECT_HR(hr
, E_FAIL
);
10303 hr
= IMXNamespaceManager_putAllowOverride(nsmgr
, VARIANT_TRUE
);
10304 EXPECT_HR(hr
, S_OK
);
10306 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri override"));
10307 EXPECT_HR(hr
, S_FALSE
);
10309 len
= sizeof(buffW
)/sizeof(WCHAR
);
10311 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_(""), NULL
, buffW
, &len
);
10312 EXPECT_HR(hr
, S_OK
);
10313 ok(!lstrcmpW(buffW
, _bstr_("ns0 uri override")), "got uri %s\n", wine_dbgstr_w(buffW
));
10315 len
= sizeof(buffW
)/sizeof(WCHAR
);
10317 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 3, buffW
, &len
);
10318 EXPECT_HR(hr
, S_OK
);
10319 ok(!lstrcmpW(buffW
, _bstr_("")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10321 IMXNamespaceManager_Release(nsmgr
);
10326 static const DOMNodeType nodetypes_test
[] =
10331 NODE_CDATA_SECTION
,
10332 NODE_ENTITY_REFERENCE
,
10333 NODE_PROCESSING_INSTRUCTION
,
10335 NODE_DOCUMENT_FRAGMENT
,
10339 static void test_dispex(void)
10341 const DOMNodeType
*type
= nodetypes_test
;
10342 IXMLDOMImplementation
*impl
;
10343 IXMLDOMNodeList
*node_list
;
10344 IXMLDOMParseError
*error
;
10345 IXMLDOMNamedNodeMap
*map
;
10346 IXSLProcessor
*processor
;
10347 IXSLTemplate
*template;
10348 IXMLDOMDocument
*doc
;
10349 IXMLHTTPRequest
*req
;
10350 IXMLDOMElement
*elem
;
10351 IDispatchEx
*dispex
;
10352 DISPPARAMS dispparams
;
10360 doc
= create_document(&IID_IXMLDOMDocument
);
10362 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
10363 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10364 test_domobj_dispex(unk
);
10365 IUnknown_Release(unk
);
10367 for(; *type
!= NODE_INVALID
; type
++)
10375 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("name"), NULL
, &node
);
10376 ok(hr
== S_OK
, "failed to create node type %d\n", *type
);
10378 IXMLDOMNode_QueryInterface(node
, &IID_IUnknown
, (void**)&unk
);
10380 test_domobj_dispex(unk
);
10381 IUnknown_Release(unk
);
10382 IXMLDOMNode_Release(node
);
10385 /* IXMLDOMNodeList */
10386 hr
= IXMLDOMDocument_getElementsByTagName(doc
, _bstr_("*"), &node_list
);
10387 EXPECT_HR(hr
, S_OK
);
10388 IXMLDOMNodeList_QueryInterface(node_list
, &IID_IUnknown
, (void**)&unk
);
10389 test_domobj_dispex(unk
);
10390 IUnknown_Release(unk
);
10391 IXMLDOMNodeList_Release(node_list
);
10393 /* IXMLDOMNodeList for children list */
10394 hr
= IXMLDOMDocument_get_childNodes(doc
, &node_list
);
10395 EXPECT_HR(hr
, S_OK
);
10396 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IUnknown
, (void**)&unk
);
10397 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10398 test_domobj_dispex(unk
);
10399 IUnknown_Release(unk
);
10401 /* collection dispex test, empty collection */
10402 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatchEx
, (void**)&dispex
);
10403 EXPECT_HR(hr
, S_OK
);
10405 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
10406 EXPECT_HR(hr
, S_OK
);
10407 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got 0x%08x\n", did
);
10408 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("1"), 0, &did
);
10409 EXPECT_HR(hr
, S_OK
);
10410 ok(did
== DISPID_DOM_COLLECTION_BASE
+1, "got 0x%08x\n", did
);
10411 IDispatchEx_Release(dispex
);
10414 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("item"), 0, &did
);
10415 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10416 ok(did
== DISPID_VALUE
, "got %d\n", did
);
10418 V_VT(&arg
) = VT_I4
;
10420 dispparams
.cArgs
= 0;
10421 dispparams
.cNamedArgs
= 0;
10422 dispparams
.rgdispidNamedArgs
= NULL
;
10423 dispparams
.rgvarg
= &arg
;
10425 V_VT(&ret
) = VT_EMPTY
;
10426 V_DISPATCH(&ret
) = (void*)0x1;
10427 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10428 ok(hr
== DISP_E_BADPARAMCOUNT
, "got 0x%08x\n", hr
);
10429 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10431 ok(broken(V_DISPATCH(&ret
) == (void*)0x1) || (V_DISPATCH(&ret
) == NULL
), "got %p\n", V_DISPATCH(&ret
));
10433 V_VT(&arg
) = VT_I4
;
10435 dispparams
.cArgs
= 2;
10436 dispparams
.cNamedArgs
= 0;
10437 dispparams
.rgdispidNamedArgs
= NULL
;
10438 dispparams
.rgvarg
= &arg
;
10440 V_VT(&ret
) = VT_EMPTY
;
10441 V_DISPATCH(&ret
) = (void*)0x1;
10442 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10443 ok(hr
== DISP_E_BADPARAMCOUNT
, "got 0x%08x\n", hr
);
10444 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10446 ok(broken(V_DISPATCH(&ret
) == (void*)0x1) || (V_DISPATCH(&ret
) == NULL
), "got %p\n", V_DISPATCH(&ret
));
10448 V_VT(&arg
) = VT_I4
;
10450 dispparams
.cArgs
= 1;
10451 dispparams
.cNamedArgs
= 0;
10452 dispparams
.rgdispidNamedArgs
= NULL
;
10453 dispparams
.rgvarg
= &arg
;
10455 V_VT(&ret
) = VT_EMPTY
;
10456 V_DISPATCH(&ret
) = (void*)0x1;
10457 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10458 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10459 ok(V_VT(&ret
) == VT_DISPATCH
, "got %d\n", V_VT(&ret
));
10460 ok(V_DISPATCH(&ret
) == NULL
, "got %p\n", V_DISPATCH(&ret
));
10462 V_VT(&ret
) = VT_EMPTY
;
10463 V_DISPATCH(&ret
) = (void*)0x1;
10464 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dispparams
, &ret
, NULL
, NULL
);
10465 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10466 ok(V_VT(&ret
) == VT_DISPATCH
, "got %d\n", V_VT(&ret
));
10467 ok(V_DISPATCH(&ret
) == NULL
, "got %p\n", V_DISPATCH(&ret
));
10469 V_VT(&ret
) = VT_EMPTY
;
10470 V_DISPATCH(&ret
) = (void*)0x1;
10471 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
|DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10472 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10473 ok(V_VT(&ret
) == VT_DISPATCH
, "got %d\n", V_VT(&ret
));
10474 ok(V_DISPATCH(&ret
) == NULL
, "got %p\n", V_DISPATCH(&ret
));
10476 dispparams
.cArgs
= 0;
10477 dispparams
.cNamedArgs
= 0;
10478 dispparams
.rgdispidNamedArgs
= NULL
;
10479 dispparams
.rgvarg
= NULL
;
10481 V_VT(&ret
) = VT_EMPTY
;
10483 hr
= IDispatchEx_Invoke(dispex
, DISPID_DOM_NODELIST_LENGTH
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dispparams
, &ret
, NULL
, NULL
);
10484 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10485 ok(V_VT(&ret
) == VT_I4
, "got %d\n", V_VT(&ret
));
10486 ok(V_I4(&ret
) == 0, "got %d\n", V_I4(&ret
));
10488 dispparams
.cArgs
= 0;
10489 dispparams
.cNamedArgs
= 0;
10490 dispparams
.rgdispidNamedArgs
= NULL
;
10491 dispparams
.rgvarg
= NULL
;
10493 V_VT(&ret
) = VT_EMPTY
;
10495 hr
= IDispatchEx_Invoke(dispex
, DISPID_DOM_NODELIST_LENGTH
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10496 ok(hr
== DISP_E_MEMBERNOTFOUND
, "got 0x%08x\n", hr
);
10497 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10499 ok(broken(V_I4(&ret
) == 1) || (V_I4(&ret
) == 0), "got %d\n", V_I4(&ret
));
10501 IXMLDOMNodeList_Release(node_list
);
10503 /* IXMLDOMParseError */
10504 hr
= IXMLDOMDocument_get_parseError(doc
, &error
);
10505 EXPECT_HR(hr
, S_OK
);
10506 IXMLDOMParseError_QueryInterface(error
, &IID_IUnknown
, (void**)&unk
);
10507 test_domobj_dispex(unk
);
10509 hr
= IXMLDOMParseError_QueryInterface(error
, &IID_IDispatchEx
, (void**)&dispex
);
10510 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10512 V_VT(&arg
) = VT_I4
;
10514 dispparams
.cArgs
= 1;
10515 dispparams
.cNamedArgs
= 0;
10516 dispparams
.rgdispidNamedArgs
= NULL
;
10517 dispparams
.rgvarg
= &arg
;
10519 V_VT(&ret
) = VT_EMPTY
;
10520 V_DISPATCH(&ret
) = (void*)0x1;
10521 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10522 ok(hr
== DISP_E_MEMBERNOTFOUND
, "got 0x%08x\n", hr
);
10523 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10525 ok(broken(V_DISPATCH(&ret
) == (void*)0x1) || (V_DISPATCH(&ret
) == NULL
), "got %p\n", V_DISPATCH(&ret
));
10527 IDispatchEx_Release(dispex
);
10529 IUnknown_Release(unk
);
10530 IXMLDOMParseError_Release(error
);
10532 /* IXMLDOMNamedNodeMap */
10533 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(xpath_simple_list
), &b
);
10534 EXPECT_HR(hr
, S_OK
);
10536 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root/a"), &node_list
);
10537 EXPECT_HR(hr
, S_OK
);
10538 hr
= IXMLDOMNodeList_get_item(node_list
, 0, &node
);
10539 EXPECT_HR(hr
, S_OK
);
10540 IXMLDOMNodeList_Release(node_list
);
10542 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
10543 EXPECT_HR(hr
, S_OK
);
10544 IXMLDOMNode_Release(node
);
10545 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
10546 EXPECT_HR(hr
, S_OK
);
10547 IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IUnknown
, (void**)&unk
);
10548 test_domobj_dispex(unk
);
10549 IUnknown_Release(unk
);
10550 /* collection dispex test */
10551 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IDispatchEx
, (void**)&dispex
);
10552 EXPECT_HR(hr
, S_OK
);
10554 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
10555 EXPECT_HR(hr
, S_OK
);
10556 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got 0x%08x\n", did
);
10557 IDispatchEx_Release(dispex
);
10558 IXMLDOMNamedNodeMap_Release(map
);
10560 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root/b"), &node_list
);
10561 EXPECT_HR(hr
, S_OK
);
10562 hr
= IXMLDOMNodeList_get_item(node_list
, 0, &node
);
10563 EXPECT_HR(hr
, S_OK
);
10564 IXMLDOMNodeList_Release(node_list
);
10565 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
10566 EXPECT_HR(hr
, S_OK
);
10567 IXMLDOMNode_Release(node
);
10568 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
10569 EXPECT_HR(hr
, S_OK
);
10570 /* collection dispex test, empty collection */
10571 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IDispatchEx
, (void**)&dispex
);
10572 EXPECT_HR(hr
, S_OK
);
10574 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
10575 EXPECT_HR(hr
, S_OK
);
10576 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got 0x%08x\n", did
);
10577 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("1"), 0, &did
);
10578 EXPECT_HR(hr
, S_OK
);
10579 ok(did
== DISPID_DOM_COLLECTION_BASE
+1, "got 0x%08x\n", did
);
10580 IXMLDOMNamedNodeMap_Release(map
);
10583 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("item"), 0, &did
);
10584 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10585 ok(did
== DISPID_VALUE
, "got %d\n", did
);
10587 V_VT(&arg
) = VT_I4
;
10589 dispparams
.cArgs
= 0;
10590 dispparams
.cNamedArgs
= 0;
10591 dispparams
.rgdispidNamedArgs
= NULL
;
10592 dispparams
.rgvarg
= &arg
;
10594 V_VT(&ret
) = VT_EMPTY
;
10595 V_DISPATCH(&ret
) = (void*)0x1;
10596 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10598 ok(hr
== DISP_E_BADPARAMCOUNT
, "got 0x%08x\n", hr
);
10599 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10601 ok(broken(V_DISPATCH(&ret
) == (void*)0x1) || (V_DISPATCH(&ret
) == NULL
), "got %p\n", V_DISPATCH(&ret
));
10603 V_VT(&arg
) = VT_I4
;
10605 dispparams
.cArgs
= 2;
10606 dispparams
.cNamedArgs
= 0;
10607 dispparams
.rgdispidNamedArgs
= NULL
;
10608 dispparams
.rgvarg
= &arg
;
10610 V_VT(&ret
) = VT_EMPTY
;
10611 V_DISPATCH(&ret
) = (void*)0x1;
10612 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10614 ok(hr
== DISP_E_BADPARAMCOUNT
, "got 0x%08x\n", hr
);
10615 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10617 ok(broken(V_DISPATCH(&ret
) == (void*)0x1) || (V_DISPATCH(&ret
) == NULL
), "got %p\n", V_DISPATCH(&ret
));
10619 V_VT(&arg
) = VT_I4
;
10621 dispparams
.cArgs
= 1;
10622 dispparams
.cNamedArgs
= 0;
10623 dispparams
.rgdispidNamedArgs
= NULL
;
10624 dispparams
.rgvarg
= &arg
;
10626 V_VT(&ret
) = VT_EMPTY
;
10627 V_DISPATCH(&ret
) = (void*)0x1;
10628 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10630 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10631 ok(V_VT(&ret
) == VT_DISPATCH
, "got %d\n", V_VT(&ret
));
10632 ok(V_DISPATCH(&ret
) == NULL
, "got %p\n", V_DISPATCH(&ret
));
10634 V_VT(&ret
) = VT_EMPTY
;
10635 V_DISPATCH(&ret
) = (void*)0x1;
10636 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dispparams
, &ret
, NULL
, NULL
);
10637 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10638 ok(V_VT(&ret
) == VT_DISPATCH
, "got %d\n", V_VT(&ret
));
10639 ok(V_DISPATCH(&ret
) == NULL
, "got %p\n", V_DISPATCH(&ret
));
10641 V_VT(&ret
) = VT_EMPTY
;
10642 V_DISPATCH(&ret
) = (void*)0x1;
10643 hr
= IDispatchEx_Invoke(dispex
, DISPID_VALUE
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
|DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10644 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10645 ok(V_VT(&ret
) == VT_DISPATCH
, "got %d\n", V_VT(&ret
));
10646 ok(V_DISPATCH(&ret
) == NULL
, "got %p\n", V_DISPATCH(&ret
));
10648 dispparams
.cArgs
= 0;
10649 dispparams
.cNamedArgs
= 0;
10650 dispparams
.rgdispidNamedArgs
= NULL
;
10651 dispparams
.rgvarg
= NULL
;
10653 V_VT(&ret
) = VT_EMPTY
;
10655 hr
= IDispatchEx_Invoke(dispex
, DISPID_DOM_NODELIST_LENGTH
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dispparams
, &ret
, NULL
, NULL
);
10656 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10657 ok(V_VT(&ret
) == VT_I4
, "got %d\n", V_VT(&ret
));
10658 ok(V_I4(&ret
) == 0, "got %d\n", V_I4(&ret
));
10660 dispparams
.cArgs
= 0;
10661 dispparams
.cNamedArgs
= 0;
10662 dispparams
.rgdispidNamedArgs
= NULL
;
10663 dispparams
.rgvarg
= NULL
;
10665 V_VT(&ret
) = VT_EMPTY
;
10667 hr
= IDispatchEx_Invoke(dispex
, DISPID_DOM_NODELIST_LENGTH
, &IID_NULL
, 0, DISPATCH_METHOD
, &dispparams
, &ret
, NULL
, NULL
);
10668 ok(hr
== DISP_E_MEMBERNOTFOUND
, "got 0x%08x\n", hr
);
10670 ok(V_VT(&ret
) == VT_EMPTY
, "got %d\n", V_VT(&ret
));
10671 ok(broken(V_I4(&ret
) == 1) || (V_I4(&ret
) == 0), "got %d\n", V_I4(&ret
));
10673 IDispatchEx_Release(dispex
);
10674 IXMLDOMElement_Release(elem
);
10676 /* IXMLDOMImplementation */
10677 hr
= IXMLDOMDocument_get_implementation(doc
, &impl
);
10678 EXPECT_HR(hr
, S_OK
);
10680 hr
= IXMLDOMImplementation_QueryInterface(impl
, &IID_IDispatchEx
, (void**)&dispex
);
10681 EXPECT_HR(hr
, S_OK
);
10682 IDispatchEx_Release(dispex
);
10683 IXMLDOMImplementation_Release(impl
);
10685 IXMLDOMDocument_Release(doc
);
10687 /* IXMLHTTPRequest */
10688 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
10689 &IID_IXMLHttpRequest
, (void**)&req
);
10692 hr
= IXMLHTTPRequest_QueryInterface(req
, &IID_IDispatchEx
, (void**)&dispex
);
10693 EXPECT_HR(hr
, E_NOINTERFACE
);
10694 IXMLHTTPRequest_Release(req
);
10698 template = create_xsltemplate(&IID_IXSLTemplate
);
10699 hr
= IXSLTemplate_QueryInterface(template, &IID_IDispatchEx
, (void**)&dispex
);
10700 EXPECT_HR(hr
, S_OK
);
10701 hr
= IDispatchEx_QueryInterface(dispex
, &IID_IUnknown
, (void**)&unk
);
10702 EXPECT_HR(hr
, S_OK
);
10703 test_domobj_dispex(unk
);
10704 IUnknown_Release(unk
);
10705 IDispatchEx_Release(dispex
);
10707 /* IXSLProcessor */
10708 hr
= CoCreateInstance(&CLSID_FreeThreadedDOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
10709 EXPECT_HR(hr
, S_OK
);
10711 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformSSXML
), &b
);
10712 EXPECT_HR(hr
, S_OK
);
10713 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10715 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
10716 EXPECT_HR(hr
, S_OK
);
10717 IXMLDOMDocument_Release(doc
);
10719 hr
= IXSLTemplate_createProcessor(template, &processor
);
10720 EXPECT_HR(hr
, S_OK
);
10721 hr
= IXSLProcessor_QueryInterface(processor
, &IID_IDispatchEx
, (void**)&dispex
);
10722 EXPECT_HR(hr
, S_OK
);
10723 hr
= IDispatchEx_QueryInterface(dispex
, &IID_IUnknown
, (void**)&unk
);
10724 EXPECT_HR(hr
, S_OK
);
10725 test_domobj_dispex(unk
);
10726 IUnknown_Release(unk
);
10727 IDispatchEx_Release(dispex
);
10729 IXSLProcessor_Release(processor
);
10730 IXSLTemplate_Release(template);
10732 if (is_clsid_supported(&CLSID_DOMDocument60
, &IID_IXMLDOMDocument
))
10734 doc
= create_document_version(60, &IID_IXMLDOMDocument
);
10735 test_domobj_dispex((IUnknown
*)doc
);
10736 IXMLDOMDocument_Release(doc
);
10742 static void test_parseerror(void)
10744 IXMLDOMParseError2
*error2
;
10745 IXMLDOMParseError
*error
;
10746 IXMLDOMDocument
*doc
;
10749 doc
= create_document(&IID_IXMLDOMDocument
);
10751 hr
= IXMLDOMDocument_get_parseError(doc
, &error
);
10752 EXPECT_HR(hr
, S_OK
);
10754 hr
= IXMLDOMParseError_get_line(error
, NULL
);
10755 EXPECT_HR(hr
, E_INVALIDARG
);
10757 hr
= IXMLDOMParseError_get_srcText(error
, NULL
);
10758 EXPECT_HR(hr
, E_INVALIDARG
);
10760 hr
= IXMLDOMParseError_get_linepos(error
, NULL
);
10761 EXPECT_HR(hr
, E_INVALIDARG
);
10763 IXMLDOMParseError_Release(error
);
10764 IXMLDOMDocument_Release(doc
);
10766 if (!is_clsid_supported(&CLSID_DOMDocument60
, &IID_IXMLDOMDocument
)) return;
10767 doc
= create_document_version(60, &IID_IXMLDOMDocument
);
10769 hr
= IXMLDOMDocument_get_parseError(doc
, &error
);
10770 EXPECT_HR(hr
, S_OK
);
10771 hr
= IXMLDOMParseError_QueryInterface(error
, &IID_IXMLDOMParseError2
, (void**)&error2
);
10772 EXPECT_HR(hr
, S_OK
);
10773 IXMLDOMParseError2_Release(error2
);
10774 IXMLDOMParseError_Release(error
);
10775 IXMLDOMDocument_Release(doc
);
10778 static void test_getAttributeNode(void)
10780 IXMLDOMAttribute
*attr
;
10781 IXMLDOMDocument
*doc
;
10782 IXMLDOMElement
*elem
;
10787 doc
= create_document(&IID_IXMLDOMDocument
);
10789 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &v
);
10790 EXPECT_HR(hr
, S_OK
);
10792 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
10793 EXPECT_HR(hr
, S_OK
);
10795 str
= SysAllocString(nonexistent_fileW
);
10796 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, NULL
);
10797 EXPECT_HR(hr
, E_FAIL
);
10799 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
10800 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, &attr
);
10801 EXPECT_HR(hr
, E_FAIL
);
10802 ok(attr
== NULL
, "got %p\n", attr
);
10803 SysFreeString(str
);
10805 str
= SysAllocString(nonexistent_attrW
);
10806 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, NULL
);
10807 EXPECT_HR(hr
, S_FALSE
);
10809 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
10810 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, &attr
);
10811 EXPECT_HR(hr
, S_FALSE
);
10812 ok(attr
== NULL
, "got %p\n", attr
);
10813 SysFreeString(str
);
10815 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("foo:b"), &attr
);
10816 EXPECT_HR(hr
, S_OK
);
10817 IXMLDOMAttribute_Release(attr
);
10819 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("b"), &attr
);
10820 EXPECT_HR(hr
, S_FALSE
);
10822 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("a"), &attr
);
10823 EXPECT_HR(hr
, S_OK
);
10824 IXMLDOMAttribute_Release(attr
);
10826 IXMLDOMElement_Release(elem
);
10827 IXMLDOMDocument_Release(doc
);
10837 static const supporterror_t supporterror_test
[] = {
10838 { NODE_ELEMENT
, "element", { &IID_IXMLDOMNode
, &IID_IXMLDOMElement
} },
10839 { NODE_ATTRIBUTE
, "attribute", { &IID_IXMLDOMNode
, &IID_IXMLDOMAttribute
} },
10840 { NODE_CDATA_SECTION
, "cdata", { &IID_IXMLDOMNode
, &IID_IXMLDOMCDATASection
} },
10841 { NODE_ENTITY_REFERENCE
, "entityref", { &IID_IXMLDOMNode
, &IID_IXMLDOMEntityReference
} },
10842 { NODE_PROCESSING_INSTRUCTION
, "pi", { &IID_IXMLDOMNode
, &IID_IXMLDOMProcessingInstruction
} },
10843 { NODE_COMMENT
, "comment", { &IID_IXMLDOMNode
, &IID_IXMLDOMComment
} },
10844 { NODE_DOCUMENT_FRAGMENT
, "fragment", { &IID_IXMLDOMNode
, &IID_IXMLDOMDocumentFragment
} },
10848 static void test_supporterrorinfo(void)
10850 static REFIID iids
[5] = { &IID_IXMLDOMNode
, &IID_IXMLDOMDocument
,
10851 &IID_IXMLDOMDocument2
, &IID_IXMLDOMDocument3
};
10852 const supporterror_t
*ptr
= supporterror_test
;
10853 ISupportErrorInfo
*errorinfo
, *info2
;
10854 IXMLDOMSchemaCollection
*schemacache
;
10855 IXMLDOMNamedNodeMap
*map
, *map2
;
10856 IXMLDOMDocument
*doc
;
10857 IXMLDOMElement
*elem
;
10864 if (!is_clsid_supported(&CLSID_DOMDocument60
, &IID_IXMLDOMDocument3
)) return;
10865 doc
= create_document_version(60, &IID_IXMLDOMDocument3
);
10867 EXPECT_REF(doc
, 1);
10868 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10869 EXPECT_HR(hr
, S_OK
);
10870 EXPECT_REF(doc
, 1);
10871 ISupportErrorInfo_AddRef(errorinfo
);
10872 EXPECT_REF(errorinfo
, 2);
10873 EXPECT_REF(doc
, 1);
10874 ISupportErrorInfo_Release(errorinfo
);
10876 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_ISupportErrorInfo
, (void**)&info2
);
10877 EXPECT_HR(hr
, S_OK
);
10878 ok(errorinfo
!= info2
, "got %p, %p\n", info2
, errorinfo
);
10880 /* error interface can't be queried back for DOM interface */
10881 hr
= ISupportErrorInfo_QueryInterface(info2
, &IID_IXMLDOMDocument
, &dummy
);
10882 EXPECT_HR(hr
, E_NOINTERFACE
);
10883 hr
= ISupportErrorInfo_QueryInterface(info2
, &IID_IXMLDOMNode
, &dummy
);
10884 EXPECT_HR(hr
, E_NOINTERFACE
);
10886 ISupportErrorInfo_Release(info2
);
10891 hr
= IXMLDOMDocument_QueryInterface(doc
, *iid
, (void**)&unk
);
10892 EXPECT_HR(hr
, S_OK
);
10895 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, *iid
);
10896 ok(hr
== S_OK
, "got 0x%08x for %s\n", hr
, wine_dbgstr_guid(*iid
));
10897 IUnknown_Release(unk
);
10903 ISupportErrorInfo_Release(errorinfo
);
10905 while (ptr
->type
!= NODE_INVALID
)
10910 V_VT(&type
) = VT_I1
;
10911 V_I1(&type
) = ptr
->type
;
10913 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_(ptr
->name
), NULL
, &node
);
10914 ok(hr
== S_OK
, "%d: got 0x%08x\n", ptr
->type
, hr
);
10916 EXPECT_REF(node
, 1);
10917 hr
= IXMLDOMNode_QueryInterface(node
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10918 ok(hr
== S_OK
, "%d: got 0x%08x\n", ptr
->type
, hr
);
10919 EXPECT_REF(node
, 1);
10921 hr
= ISupportErrorInfo_QueryInterface(errorinfo
, &IID_IXMLDOMNode
, &dummy
);
10922 ok(hr
== E_NOINTERFACE
, "%d: got 0x%08x\n", ptr
->type
, hr
);
10928 hr
= IXMLDOMNode_QueryInterface(node
, *iid
, (void**)&unk
);
10931 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, *iid
);
10932 ok(hr
== S_OK
, "%d: got 0x%08x for %s\n", ptr
->type
, hr
, wine_dbgstr_guid(*iid
));
10933 IUnknown_Release(unk
);
10939 ISupportErrorInfo_Release(errorinfo
);
10940 IXMLDOMNode_Release(node
);
10944 /* IXMLDOMNamedNodeMap */
10946 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
);
10947 EXPECT_HR(hr
, S_OK
);
10948 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10950 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
10951 EXPECT_HR(hr
, S_OK
);
10953 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
10954 EXPECT_HR(hr
, S_OK
);
10956 EXPECT_REF(map
, 1);
10957 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10958 EXPECT_HR(hr
, S_OK
);
10959 EXPECT_REF(map
, 2);
10961 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, &IID_IXMLDOMNamedNodeMap
);
10962 EXPECT_HR(hr
, S_OK
);
10964 hr
= ISupportErrorInfo_QueryInterface(errorinfo
, &IID_IXMLDOMNamedNodeMap
, (void**)&map2
);
10965 EXPECT_HR(hr
, S_OK
);
10966 ok(map
== map2
, "got %p\n", map2
);
10967 IXMLDOMNamedNodeMap_Release(map2
);
10969 EXPECT_REF(errorinfo
, 2);
10970 hr
= ISupportErrorInfo_QueryInterface(errorinfo
, &IID_IUnknown
, (void**)&unk
);
10971 EXPECT_HR(hr
, S_OK
);
10972 EXPECT_REF(errorinfo
, 3);
10973 EXPECT_REF(map
, 3);
10974 IUnknown_Release(unk
);
10976 ISupportErrorInfo_Release(errorinfo
);
10977 IXMLDOMNamedNodeMap_Release(map
);
10978 IXMLDOMElement_Release(elem
);
10980 IXMLDOMDocument_Release(doc
);
10982 /* IXMLDOMSchemaCollection */
10983 hr
= CoCreateInstance(&CLSID_XMLSchemaCache
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMSchemaCollection
, (void**)&schemacache
);
10984 ok(hr
== S_OK
, "failed to create schema collection, 0x%08x\n", hr
);
10986 hr
= IXMLDOMSchemaCollection_QueryInterface(schemacache
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10987 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10989 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, &IID_IXMLDOMSchemaCollection
);
10990 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
10992 ISupportErrorInfo_Release(errorinfo
);
10993 IXMLDOMSchemaCollection_Release(schemacache
);
11001 const char *put_content
;
11007 static const node_value_t nodevalue_test
[] = {
11008 { NODE_ELEMENT
, "element", "", E_FAIL
, VT_NULL
, S_FALSE
},
11009 { NODE_ATTRIBUTE
, "attr", "value", S_OK
, VT_BSTR
, S_OK
},
11010 { NODE_TEXT
, "text", "textdata", S_OK
, VT_BSTR
, S_OK
},
11011 { NODE_CDATA_SECTION
, "cdata", "cdata data", S_OK
, VT_BSTR
, S_OK
},
11012 { NODE_ENTITY_REFERENCE
, "entityref", "ref", E_FAIL
, VT_NULL
, S_FALSE
},
11013 { NODE_PROCESSING_INSTRUCTION
, "pi", "instr", S_OK
, VT_BSTR
, S_OK
},
11014 { NODE_COMMENT
, "comment", "comment data", S_OK
, VT_BSTR
, S_OK
},
11015 { NODE_DOCUMENT_FRAGMENT
, "docfrag", "", E_FAIL
, VT_NULL
, S_FALSE
},
11019 static void test_nodeValue(void)
11021 const node_value_t
*ptr
= nodevalue_test
;
11022 IXMLDOMDocument
*doc
;
11025 doc
= create_document(&IID_IXMLDOMDocument
);
11027 while (ptr
->type
!= NODE_INVALID
)
11033 V_I2(&v
) = ptr
->type
;
11035 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_(ptr
->name
), NULL
, &node
);
11036 ok(hr
== S_OK
, "failed to create node type %d\n", ptr
->type
);
11038 hr
= IXMLDOMNode_get_nodeValue(node
, NULL
);
11039 ok(hr
== E_INVALIDARG
, "%d: got 0x%08x\n", ptr
->type
, hr
);
11041 V_VT(&v
) = VT_BSTR
;
11042 V_BSTR(&v
) = _bstr_(ptr
->put_content
);
11043 hr
= IXMLDOMNode_put_nodeValue(node
, v
);
11044 ok(hr
== ptr
->put_hr
, "%d: got 0x%08x\n", ptr
->type
, hr
);
11046 V_VT(&v
) = VT_EMPTY
;
11047 hr
= IXMLDOMNode_get_nodeValue(node
, &v
);
11048 ok(hr
== ptr
->get_hr
, "%d: got 0x%08x, expected 0x%08x\n", ptr
->type
, hr
, ptr
->get_hr
);
11049 ok(V_VT(&v
) == ptr
->get_vt
, "%d: got %d, expected %d\n", ptr
->type
, V_VT(&v
), ptr
->get_vt
);
11051 ok(!lstrcmpW(V_BSTR(&v
), _bstr_(ptr
->put_content
)), "%d: got %s\n", ptr
->type
,
11052 wine_dbgstr_w(V_BSTR(&v
)));
11055 IXMLDOMNode_Release(node
);
11060 IXMLDOMDocument_Release(doc
);
11063 static void test_xmlns_attribute(void)
11066 IXMLDOMDocument
*doc
;
11067 IXMLDOMElement
*root
;
11068 IXMLDOMAttribute
*pAttribute
;
11069 IXMLDOMElement
*elem
;
11073 doc
= create_document(&IID_IXMLDOMDocument
);
11075 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &root
);
11076 EXPECT_HR(hr
, S_OK
);
11078 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)root
, NULL
);
11079 EXPECT_HR(hr
, S_OK
);
11081 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("xmlns:dt"), &pAttribute
);
11082 ok( hr
== S_OK
, "returns %08x\n", hr
);
11084 V_VT(&v
) = VT_BSTR
;
11085 V_BSTR(&v
) = _bstr_("urn:schemas-microsoft-com:datatypes");
11086 hr
= IXMLDOMAttribute_put_nodeValue(pAttribute
, v
);
11087 ok(hr
== S_OK
, "ret %08x\n", hr
);
11089 hr
= IXMLDOMElement_setAttributeNode(root
, pAttribute
, NULL
);
11090 ok(hr
== S_OK
, "ret %08x\n", hr
);
11092 hr
= IXMLDOMNode_put_dataType((IXMLDOMNode
*)root
, _bstr_("bin.base64"));
11093 ok(hr
== S_OK
, "ret %08x\n", hr
);
11095 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
11096 EXPECT_HR(hr
, S_OK
);
11099 hr
= IXMLDOMElement_get_xml(elem
, &str
);
11100 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
11101 todo_wine
ok( lstrcmpW(str
, _bstr_("<Testing xmlns:dt=\"urn:schemas-microsoft-com:datatypes\" dt:dt=\"bin.base64\"/>")) == 0,
11102 "got %s\n", wine_dbgstr_w(str
));
11103 SysFreeString(str
);
11105 IXMLDOMElement_Release(elem
);
11106 IXMLDOMAttribute_Release( pAttribute
);
11108 IXMLDOMDocument_Release(doc
);
11113 static const char namespacesA
[] =
11114 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"
11115 " <ns1:elem1 xmlns:ns1=\"http://blah.org\" b='1' >"
11116 " <ns2:elem2 xmlns:ns2=\"http://blah.org\"/>"
11119 " <elem5 xmlns=\"http://blahblah.org\"/>"
11120 " <ns1:elem6>true</ns1:elem6>"
11123 static const char xsd_schema1_uri
[] = "x-schema:test1.xsd";
11124 static const char xsd_schema1_xml
[] =
11125 "<?xml version='1.0'?>"
11126 "<schema xmlns='http://www.w3.org/2001/XMLSchema'"
11127 " targetNamespace='x-schema:test1.xsd'>"
11128 " <element name='root'>"
11130 " <sequence maxOccurs='unbounded'>"
11137 static void test_get_namespaces(void)
11139 IXMLDOMSchemaCollection
*collection
, *collection2
;
11140 IXMLDOMDocument2
*doc
, *doc2
;
11141 IEnumVARIANT
*enumv
, *enum2
;
11142 IUnknown
*unk1
, *unk2
;
11150 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument2
)) return;
11151 doc
= create_document(&IID_IXMLDOMDocument2
);
11154 hr
= IXMLDOMDocument2_get_namespaces(doc
, NULL
);
11155 EXPECT_HR(hr
, E_POINTER
);
11157 /* no document loaded */
11158 collection
= (void*)0xdeadbeef;
11159 hr
= IXMLDOMDocument2_get_namespaces(doc
, &collection
);
11160 EXPECT_HR(hr
, S_OK
);
11163 IXMLDOMDocument2_Release(doc
);
11166 EXPECT_REF(collection
, 2);
11168 collection2
= (void*)0xdeadbeef;
11169 hr
= IXMLDOMDocument2_get_namespaces(doc
, &collection2
);
11170 EXPECT_HR(hr
, S_OK
);
11171 ok(collection
== collection2
, "got %p\n", collection2
);
11172 EXPECT_REF(collection
, 3);
11173 IXMLDOMSchemaCollection_Release(collection
);
11176 hr
= IXMLDOMSchemaCollection_get_length(collection
, &len
);
11177 EXPECT_HR(hr
, S_OK
);
11178 ok(len
== 0, "got %d\n", len
);
11179 IXMLDOMSchemaCollection_Release(collection
);
11181 /* now with document */
11182 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(namespacesA
), &b
);
11183 EXPECT_HR(hr
, S_OK
);
11185 hr
= IXMLDOMDocument2_get_namespaces(doc
, &collection
);
11186 EXPECT_HR(hr
, S_OK
);
11189 hr
= IXMLDOMSchemaCollection_get_length(collection
, &len
);
11190 EXPECT_HR(hr
, S_OK
);
11191 ok(len
== 2, "got %d\n", len
);
11193 /* try to lookup some uris */
11194 node
= (void*)0xdeadbeef;
11195 hr
= IXMLDOMSchemaCollection_get(collection
, _bstr_("http://blah.org"), &node
);
11196 EXPECT_HR(hr
, S_OK
);
11197 ok(node
== NULL
, "got %p\n", node
);
11199 node
= (void*)0xdeadbeef;
11200 hr
= IXMLDOMSchemaCollection_get(collection
, _bstr_("http://blah1.org"), &node
);
11201 EXPECT_HR(hr
, S_OK
);
11202 ok(node
== NULL
, "got %p\n", node
);
11204 /* load schema and try to add it */
11205 doc2
= create_document(&IID_IXMLDOMDocument2
);
11206 hr
= IXMLDOMDocument2_loadXML(doc2
, _bstr_(xsd_schema1_xml
), &b
);
11207 EXPECT_HR(hr
, S_OK
);
11209 V_VT(&v
) = VT_DISPATCH
;
11210 V_DISPATCH(&v
) = (IDispatch
*)doc2
;
11211 hr
= IXMLDOMSchemaCollection_add(collection
, _bstr_(xsd_schema1_uri
), v
);
11212 EXPECT_HR(hr
, E_FAIL
);
11214 hr
= IXMLDOMSchemaCollection_get_namespaceURI(collection
, 0, &s
);
11215 EXPECT_HR(hr
, S_OK
);
11216 ok(!lstrcmpW(s
, _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(s
));
11219 hr
= IXMLDOMSchemaCollection_get_namespaceURI(collection
, 1, &s
);
11220 EXPECT_HR(hr
, S_OK
);
11221 ok(!lstrcmpW(s
, _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(s
));
11224 s
= (void*)0xdeadbeef;
11225 hr
= IXMLDOMSchemaCollection_get_namespaceURI(collection
, 2, &s
);
11226 EXPECT_HR(hr
, E_FAIL
);
11227 ok(s
== (void*)0xdeadbeef, "got %p\n", s
);
11230 enumv
= (void*)0xdeadbeef;
11231 EXPECT_REF(collection
, 2);
11232 hr
= IXMLDOMSchemaCollection_get__newEnum(collection
, (IUnknown
**)&enumv
);
11233 EXPECT_HR(hr
, S_OK
);
11234 EXPECT_REF(collection
, 3);
11235 ok(enumv
!= NULL
, "got %p\n", enumv
);
11237 hr
= IXMLDOMSchemaCollection_QueryInterface(collection
, &IID_IUnknown
, (void**)&unk1
);
11238 EXPECT_HR(hr
, S_OK
);
11239 hr
= IEnumVARIANT_QueryInterface(enumv
, &IID_IUnknown
, (void**)&unk2
);
11240 EXPECT_HR(hr
, S_OK
);
11241 ok(unk1
!= unk2
, "got %p, %p\n", unk1
, unk2
);
11242 IUnknown_Release(unk1
);
11243 IUnknown_Release(unk2
);
11245 hr
= IXMLDOMSchemaCollection_QueryInterface(collection
, &IID_IEnumVARIANT
, (void**)&enum2
);
11246 EXPECT_HR(hr
, E_NOINTERFACE
);
11248 V_VT(&v
) = VT_EMPTY
;
11249 hr
= IEnumVARIANT_Next(enumv
, 1, &v
, NULL
);
11250 EXPECT_HR(hr
, S_OK
);
11251 ok(V_VT(&v
) == VT_BSTR
, "got %d\n", V_VT(&v
));
11252 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
11255 V_VT(&v
) = VT_EMPTY
;
11256 hr
= IEnumVARIANT_Next(enumv
, 1, &v
, NULL
);
11257 EXPECT_HR(hr
, S_OK
);
11258 ok(V_VT(&v
) == VT_BSTR
, "got %d\n", V_VT(&v
));
11259 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
11262 V_VT(&v
) = VT_NULL
;
11263 hr
= IEnumVARIANT_Next(enumv
, 1, &v
, NULL
);
11264 EXPECT_HR(hr
, S_FALSE
);
11265 ok(V_VT(&v
) == VT_EMPTY
, "got %d\n", V_VT(&v
));
11267 IEnumVARIANT_Release(enumv
);
11268 IXMLDOMSchemaCollection_Release(collection
);
11270 IXMLDOMDocument2_Release(doc
);
11272 /* now with CLSID_DOMDocument60 */
11273 if (!is_clsid_supported(&CLSID_DOMDocument60
, &IID_IXMLDOMDocument2
)) return;
11274 doc
= create_document_version(60, &IID_IXMLDOMDocument2
);
11277 hr
= IXMLDOMDocument2_get_namespaces(doc
, NULL
);
11278 EXPECT_HR(hr
, E_POINTER
);
11280 /* no document loaded */
11281 collection
= (void*)0xdeadbeef;
11282 hr
= IXMLDOMDocument2_get_namespaces(doc
, &collection
);
11283 EXPECT_HR(hr
, S_OK
);
11286 IXMLDOMDocument2_Release(doc
);
11289 EXPECT_REF(collection
, 2);
11291 collection2
= (void*)0xdeadbeef;
11292 hr
= IXMLDOMDocument2_get_namespaces(doc
, &collection2
);
11293 EXPECT_HR(hr
, S_OK
);
11294 ok(collection
== collection2
, "got %p\n", collection2
);
11295 EXPECT_REF(collection
, 3);
11296 IXMLDOMSchemaCollection_Release(collection
);
11299 hr
= IXMLDOMSchemaCollection_get_length(collection
, &len
);
11300 EXPECT_HR(hr
, S_OK
);
11301 ok(len
== 0, "got %d\n", len
);
11302 IXMLDOMSchemaCollection_Release(collection
);
11304 /* now with document */
11305 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(namespacesA
), &b
);
11306 EXPECT_HR(hr
, S_OK
);
11308 hr
= IXMLDOMDocument2_get_namespaces(doc
, &collection
);
11309 EXPECT_HR(hr
, S_OK
);
11312 hr
= IXMLDOMSchemaCollection_get_length(collection
, &len
);
11313 EXPECT_HR(hr
, S_OK
);
11314 ok(len
== 2, "got %d\n", len
);
11316 /* try to lookup some uris */
11317 node
= (void*)0xdeadbeef;
11318 hr
= IXMLDOMSchemaCollection_get(collection
, _bstr_("http://blah.org"), &node
);
11319 EXPECT_HR(hr
, E_NOTIMPL
);
11320 ok(broken(node
== (void*)0xdeadbeef) || (node
== NULL
), "got %p\n", node
);
11322 /* load schema and try to add it */
11323 doc2
= create_document(&IID_IXMLDOMDocument2
);
11324 hr
= IXMLDOMDocument2_loadXML(doc2
, _bstr_(xsd_schema1_xml
), &b
);
11325 EXPECT_HR(hr
, S_OK
);
11327 V_VT(&v
) = VT_DISPATCH
;
11328 V_DISPATCH(&v
) = (IDispatch
*)doc2
;
11329 hr
= IXMLDOMSchemaCollection_add(collection
, _bstr_(xsd_schema1_uri
), v
);
11330 EXPECT_HR(hr
, E_FAIL
);
11331 IXMLDOMDocument2_Release(doc2
);
11333 hr
= IXMLDOMSchemaCollection_get_namespaceURI(collection
, 0, &s
);
11334 EXPECT_HR(hr
, S_OK
);
11335 ok(!lstrcmpW(s
, _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(s
));
11338 hr
= IXMLDOMSchemaCollection_get_namespaceURI(collection
, 1, &s
);
11339 EXPECT_HR(hr
, S_OK
);
11340 ok(!lstrcmpW(s
, _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(s
));
11343 s
= (void*)0xdeadbeef;
11344 hr
= IXMLDOMSchemaCollection_get_namespaceURI(collection
, 2, &s
);
11345 EXPECT_HR(hr
, E_FAIL
);
11346 ok(broken(s
== (void*)0xdeadbeef) || (s
== NULL
), "got %p\n", s
);
11349 enumv
= (void*)0xdeadbeef;
11350 hr
= IXMLDOMSchemaCollection_get__newEnum(collection
, (IUnknown
**)&enumv
);
11351 EXPECT_HR(hr
, S_OK
);
11352 ok(enumv
!= NULL
, "got %p\n", enumv
);
11354 V_VT(&v
) = VT_EMPTY
;
11355 hr
= IEnumVARIANT_Next(enumv
, 1, &v
, NULL
);
11356 EXPECT_HR(hr
, S_OK
);
11357 ok(V_VT(&v
) == VT_BSTR
, "got %d\n", V_VT(&v
));
11358 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("http://blah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
11361 V_VT(&v
) = VT_EMPTY
;
11362 hr
= IEnumVARIANT_Next(enumv
, 1, &v
, NULL
);
11363 EXPECT_HR(hr
, S_OK
);
11364 ok(V_VT(&v
) == VT_BSTR
, "got %d\n", V_VT(&v
));
11365 ok(!lstrcmpW(V_BSTR(&v
), _bstr_("http://blahblah.org")), "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
11368 V_VT(&v
) = VT_NULL
;
11369 hr
= IEnumVARIANT_Next(enumv
, 1, &v
, NULL
);
11370 EXPECT_HR(hr
, S_FALSE
);
11371 ok(V_VT(&v
) == VT_EMPTY
, "got %d\n", V_VT(&v
));
11373 IEnumVARIANT_Release(enumv
);
11374 IXMLDOMSchemaCollection_Release(collection
);
11375 IXMLDOMDocument2_Release(doc
);
11379 static DOMNodeType put_data_types
[] = {
11381 NODE_CDATA_SECTION
,
11382 NODE_PROCESSING_INSTRUCTION
,
11387 static void test_put_data(void)
11389 static const WCHAR test_data
[] = {'t','e','s','t',' ','n','o','d','e',' ','d','a','t','a',0};
11390 WCHAR buff
[100], *data
;
11391 IXMLDOMDocument
*doc
;
11399 doc
= create_document(&IID_IXMLDOMDocument
);
11401 memcpy(&buff
[2], test_data
, sizeof(test_data
));
11402 /* just a big length */
11403 *(DWORD
*)buff
= 0xf0f0;
11406 type
= put_data_types
;
11407 while (*type
!= NODE_INVALID
)
11412 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("name"), NULL
, &node
);
11413 EXPECT_HR(hr
, S_OK
);
11415 /* put_data() is interface-specific */
11420 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
11421 EXPECT_HR(hr
, S_OK
);
11422 hr
= IXMLDOMText_put_data(text
, data
);
11423 EXPECT_HR(hr
, S_OK
);
11425 hr
= IXMLDOMText_get_data(text
, &get_data
);
11426 EXPECT_HR(hr
, S_OK
);
11428 IXMLDOMText_Release(text
);
11431 case NODE_CDATA_SECTION
:
11433 IXMLDOMCDATASection
*cdata
;
11435 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
11436 EXPECT_HR(hr
, S_OK
);
11437 hr
= IXMLDOMCDATASection_put_data(cdata
, data
);
11438 EXPECT_HR(hr
, S_OK
);
11440 hr
= IXMLDOMCDATASection_get_data(cdata
, &get_data
);
11441 EXPECT_HR(hr
, S_OK
);
11443 IXMLDOMCDATASection_Release(cdata
);
11446 case NODE_PROCESSING_INSTRUCTION
:
11448 IXMLDOMProcessingInstruction
*pi
;
11450 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMProcessingInstruction
, (void**)&pi
);
11451 EXPECT_HR(hr
, S_OK
);
11452 hr
= IXMLDOMProcessingInstruction_put_data(pi
, data
);
11453 EXPECT_HR(hr
, S_OK
);
11455 hr
= IXMLDOMProcessingInstruction_get_data(pi
, &get_data
);
11456 EXPECT_HR(hr
, S_OK
);
11458 IXMLDOMProcessingInstruction_Release(pi
);
11463 IXMLDOMComment
*comment
;
11465 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
11466 EXPECT_HR(hr
, S_OK
);
11467 hr
= IXMLDOMComment_put_data(comment
, data
);
11468 EXPECT_HR(hr
, S_OK
);
11470 hr
= IXMLDOMComment_get_data(comment
, &get_data
);
11471 EXPECT_HR(hr
, S_OK
);
11473 IXMLDOMComment_Release(comment
);
11481 ok(!lstrcmpW(data
, get_data
), "%d: got wrong data %s, expected %s\n", *type
, wine_dbgstr_w(get_data
),
11482 wine_dbgstr_w(data
));
11483 SysFreeString(get_data
);
11485 IXMLDOMNode_Release(node
);
11489 /* \r\n sequence is never escaped */
11491 V_I2(&v
) = NODE_TEXT
;
11493 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("name"), NULL
, &node
);
11494 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11496 IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
11498 hr
= IXMLDOMText_put_data(text
, _bstr_("\r\n"));
11499 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11501 hr
= IXMLDOMText_get_data(text
, &get_data
);
11502 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11504 ok(!lstrcmpW(get_data
, _bstr_("\n")), "got %s\n", wine_dbgstr_w(get_data
));
11505 SysFreeString(get_data
);
11507 hr
= IXMLDOMText_get_xml(text
, &get_data
);
11508 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11509 ok(!lstrcmpW(get_data
, _bstr_("\r\n")), "got %s\n", wine_dbgstr_w(get_data
));
11510 SysFreeString(get_data
);
11512 IXMLDOMText_Release(text
);
11513 IXMLDOMNode_Release(node
);
11515 IXMLDOMDocument_Release(doc
);
11519 static void test_putref_schemas(void)
11521 IXMLDOMSchemaCollection
*cache
;
11522 IXMLDOMDocument2
*doc
;
11526 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument2
)) return;
11527 if (!is_clsid_supported(&CLSID_XMLSchemaCache
, &IID_IXMLDOMSchemaCollection
)) return;
11529 doc
= create_document(&IID_IXMLDOMDocument2
);
11530 cache
= create_cache(&IID_IXMLDOMSchemaCollection
);
11532 /* set to NULL iface when no schema is set */
11533 V_VT(&schema
) = VT_DISPATCH
;
11534 V_DISPATCH(&schema
) = NULL
;
11535 hr
= IXMLDOMDocument2_putref_schemas(doc
, schema
);
11536 EXPECT_HR(hr
, S_OK
);
11538 V_VT(&schema
) = VT_UNKNOWN
;
11539 V_UNKNOWN(&schema
) = NULL
;
11540 hr
= IXMLDOMDocument2_putref_schemas(doc
, schema
);
11541 EXPECT_HR(hr
, S_OK
);
11543 /* set as VT_DISPATCH, reset with it */
11544 V_VT(&schema
) = VT_DISPATCH
;
11545 V_DISPATCH(&schema
) = (IDispatch
*)cache
;
11546 hr
= IXMLDOMDocument2_putref_schemas(doc
, schema
);
11547 EXPECT_HR(hr
, S_OK
);
11549 V_DISPATCH(&schema
) = NULL
;
11550 hr
= IXMLDOMDocument2_get_schemas(doc
, &schema
);
11551 EXPECT_HR(hr
, S_OK
);
11552 ok(V_DISPATCH(&schema
) == (IDispatch
*)cache
, "got %p\n", V_DISPATCH(&schema
));
11554 V_VT(&schema
) = VT_DISPATCH
;
11555 V_DISPATCH(&schema
) = NULL
;
11556 hr
= IXMLDOMDocument2_putref_schemas(doc
, schema
);
11557 EXPECT_HR(hr
, S_OK
);
11559 V_DISPATCH(&schema
) = (IDispatch
*)0xdeadbeef;
11560 V_VT(&schema
) = VT_I2
;
11561 hr
= IXMLDOMDocument2_get_schemas(doc
, &schema
);
11562 EXPECT_HR(hr
, S_FALSE
);
11563 ok(V_DISPATCH(&schema
) == NULL
, "got %p\n", V_DISPATCH(&schema
));
11564 ok(V_VT(&schema
) == VT_NULL
, "got %d\n", V_VT(&schema
));
11566 /* set as VT_UNKNOWN, reset with it */
11567 V_VT(&schema
) = VT_UNKNOWN
;
11568 V_UNKNOWN(&schema
) = (IUnknown
*)cache
;
11569 hr
= IXMLDOMDocument2_putref_schemas(doc
, schema
);
11570 EXPECT_HR(hr
, S_OK
);
11572 V_DISPATCH(&schema
) = NULL
;
11573 hr
= IXMLDOMDocument2_get_schemas(doc
, &schema
);
11574 EXPECT_HR(hr
, S_OK
);
11575 ok(V_DISPATCH(&schema
) == (IDispatch
*)cache
, "got %p\n", V_DISPATCH(&schema
));
11577 V_VT(&schema
) = VT_UNKNOWN
;
11578 V_UNKNOWN(&schema
) = NULL
;
11579 hr
= IXMLDOMDocument2_putref_schemas(doc
, schema
);
11580 EXPECT_HR(hr
, S_OK
);
11582 V_DISPATCH(&schema
) = (IDispatch
*)0xdeadbeef;
11583 V_VT(&schema
) = VT_I2
;
11584 hr
= IXMLDOMDocument2_get_schemas(doc
, &schema
);
11585 EXPECT_HR(hr
, S_FALSE
);
11586 ok(V_DISPATCH(&schema
) == NULL
, "got %p\n", V_DISPATCH(&schema
));
11587 ok(V_VT(&schema
) == VT_NULL
, "got %d\n", V_VT(&schema
));
11589 IXMLDOMSchemaCollection_Release(cache
);
11590 IXMLDOMDocument2_Release(doc
);
11593 static void test_namedmap_newenum(void)
11595 IEnumVARIANT
*enum1
, *enum2
, *enum3
;
11596 IXMLDOMNamedNodeMap
*map
;
11597 IUnknown
*unk1
, *unk2
;
11598 IXMLDOMDocument
*doc
;
11599 IXMLDOMElement
*elem
;
11606 doc
= create_document(&IID_IXMLDOMDocument
);
11608 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(attributes_map
), &b
);
11609 EXPECT_HR(hr
, S_OK
);
11611 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
11612 EXPECT_HR(hr
, S_OK
);
11614 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
11615 EXPECT_HR(hr
, S_OK
);
11616 IXMLDOMElement_Release(elem
);
11619 EXPECT_REF(map
, 1);
11620 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IEnumVARIANT
, (void**)&enum1
);
11621 EXPECT_HR(hr
, S_OK
);
11622 ok(enum1
!= NULL
, "got %p\n", enum1
);
11623 EXPECT_REF(map
, 1);
11624 EXPECT_REF(enum1
, 2);
11627 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IEnumVARIANT
, (void**)&enum2
);
11628 EXPECT_HR(hr
, S_OK
);
11629 ok(enum2
== enum1
, "got %p\n", enum2
);
11631 IEnumVARIANT_Release(enum2
);
11633 EXPECT_REF(map
, 1);
11634 hr
= IXMLDOMNamedNodeMap__newEnum(map
, (IUnknown
**)&enum2
);
11635 EXPECT_HR(hr
, S_OK
);
11636 EXPECT_REF(map
, 2);
11637 EXPECT_REF(enum2
, 1);
11638 ok(enum2
!= enum1
, "got %p, %p\n", enum2
, enum1
);
11640 IEnumVARIANT_Release(enum1
);
11642 /* enumerator created with _newEnum() doesn't share IUnknown* with main object */
11643 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IUnknown
, (void**)&unk1
);
11644 EXPECT_HR(hr
, S_OK
);
11645 hr
= IEnumVARIANT_QueryInterface(enum2
, &IID_IUnknown
, (void**)&unk2
);
11646 EXPECT_HR(hr
, S_OK
);
11647 EXPECT_REF(map
, 3);
11648 EXPECT_REF(enum2
, 2);
11649 ok(unk1
!= unk2
, "got %p, %p\n", unk1
, unk2
);
11650 IUnknown_Release(unk1
);
11651 IUnknown_Release(unk2
);
11653 hr
= IXMLDOMNamedNodeMap__newEnum(map
, (IUnknown
**)&enum3
);
11654 EXPECT_HR(hr
, S_OK
);
11655 ok(enum2
!= enum3
, "got %p, %p\n", enum2
, enum3
);
11656 IEnumVARIANT_Release(enum3
);
11658 /* iteration tests */
11659 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node
);
11660 EXPECT_HR(hr
, S_OK
);
11661 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
11662 EXPECT_HR(hr
, S_OK
);
11663 ok(!lstrcmpW(str
, _bstr_("attr1")), "got %s\n", wine_dbgstr_w(str
));
11664 SysFreeString(str
);
11665 IXMLDOMNode_Release(node
);
11667 hr
= IXMLDOMNamedNodeMap_nextNode(map
, &node
);
11668 EXPECT_HR(hr
, S_OK
);
11669 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
11670 EXPECT_HR(hr
, S_OK
);
11671 ok(!lstrcmpW(str
, _bstr_("attr1")), "got %s\n", wine_dbgstr_w(str
));
11672 SysFreeString(str
);
11673 IXMLDOMNode_Release(node
);
11675 V_VT(&v
) = VT_EMPTY
;
11676 hr
= IEnumVARIANT_Next(enum2
, 1, &v
, NULL
);
11677 EXPECT_HR(hr
, S_OK
);
11678 ok(V_VT(&v
) == VT_DISPATCH
, "got var type %d\n", V_VT(&v
));
11679 hr
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IXMLDOMNode
, (void**)&node
);
11680 EXPECT_HR(hr
, S_OK
);
11681 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
11682 EXPECT_HR(hr
, S_OK
);
11683 ok(!lstrcmpW(str
, _bstr_("attr1")), "got node name %s\n", wine_dbgstr_w(str
));
11684 SysFreeString(str
);
11685 IXMLDOMNode_Release(node
);
11688 hr
= IXMLDOMNamedNodeMap_nextNode(map
, &node
);
11689 EXPECT_HR(hr
, S_OK
);
11690 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
11691 EXPECT_HR(hr
, S_OK
);
11692 ok(!lstrcmpW(str
, _bstr_("attr2")), "got %s\n", wine_dbgstr_w(str
));
11693 SysFreeString(str
);
11694 IXMLDOMNode_Release(node
);
11696 IEnumVARIANT_Release(enum2
);
11697 IXMLDOMNamedNodeMap_Release(map
);
11698 IXMLDOMDocument_Release(doc
);
11701 static const char xsltext_xsl
[] =
11702 "<?xml version=\"1.0\"?>"
11703 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
11704 "<xsl:output method=\"html\" encoding=\"us-ascii\"/>"
11705 "<xsl:template match=\"/\">"
11707 " <xsl:when test=\"testkey\">"
11708 " <xsl:text>testdata</xsl:text>"
11712 "</xsl:stylesheet>";
11714 static const char omitxmldecl_xsl
[] =
11715 "<?xml version=\"1.0\"?>"
11716 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
11717 "<xsl:output method=\"xml\" omit-xml-declaration=\"yes\"/>"
11718 "<xsl:template match=\"/\">"
11719 " <xsl:for-each select=\"/a/item\">"
11720 " <xsl:element name=\"node\">"
11721 " <xsl:value-of select=\"@name\"/>"
11725 "</xsl:stylesheet>";
11727 static const char omitxmldecl_doc
[] =
11728 "<?xml version=\"1.0\"?>"
11730 " <item name=\"item1\"/>"
11731 " <item name=\"item2\"/>"
11734 static void test_xsltext(void)
11736 IXMLDOMDocument
*doc
, *doc2
;
11741 doc
= create_document(&IID_IXMLDOMDocument
);
11742 doc2
= create_document(&IID_IXMLDOMDocument
);
11744 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(xsltext_xsl
), &b
);
11745 EXPECT_HR(hr
, S_OK
);
11747 hr
= IXMLDOMDocument_loadXML(doc2
, _bstr_("<testkey/>"), &b
);
11748 EXPECT_HR(hr
, S_OK
);
11750 hr
= IXMLDOMDocument_transformNode(doc2
, (IXMLDOMNode
*)doc
, &ret
);
11751 EXPECT_HR(hr
, S_OK
);
11752 ok(!lstrcmpW(ret
, _bstr_("testdata")), "transform result %s\n", wine_dbgstr_w(ret
));
11753 SysFreeString(ret
);
11755 /* omit-xml-declaration */
11756 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(omitxmldecl_xsl
), &b
);
11757 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11758 hr
= IXMLDOMDocument_loadXML(doc2
, _bstr_(omitxmldecl_doc
), &b
);
11759 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11761 hr
= IXMLDOMDocument_transformNode(doc2
, (IXMLDOMNode
*)doc
, &ret
);
11762 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11763 ok(!lstrcmpW(ret
, _bstr_("<node>item1</node><node>item2</node>")), "transform result %s\n", wine_dbgstr_w(ret
));
11764 SysFreeString(ret
);
11766 IXMLDOMDocument_Release(doc2
);
11767 IXMLDOMDocument_Release(doc
);
11771 struct attrtest_t
{
11774 const char *prefix
;
11778 static struct attrtest_t attrtests
[] = {
11779 { "xmlns", "http://www.w3.org/2000/xmlns/", "xmlns", "xmlns" },
11780 { "xmlns", "nondefaulturi", "xmlns", "xmlns" },
11781 { "c", "http://www.w3.org/2000/xmlns/", NULL
, "http://www.w3.org/2000/xmlns/" },
11782 { "c", "nsref1", NULL
, "nsref1" },
11783 { "ns:c", "nsref1", "ns", "nsref1" },
11784 { "xmlns:c", "http://www.w3.org/2000/xmlns/", "xmlns", "" },
11785 { "xmlns:c", "nondefaulturi", "xmlns", "" },
11789 static void test_create_attribute(void)
11791 struct attrtest_t
*ptr
= attrtests
;
11792 IXMLDOMElement
*el
;
11793 IXMLDOMDocument
*doc
;
11794 IXMLDOMNode
*node
, *node2
;
11800 doc
= create_document(&IID_IXMLDOMDocument
);
11804 V_VT(&var
) = VT_I1
;
11805 V_I1(&var
) = NODE_ATTRIBUTE
;
11806 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_(ptr
->name
), _bstr_(ptr
->uri
), &node
);
11807 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11810 hr
= IXMLDOMNode_get_prefix(node
, &str
);
11813 ok(hr
== S_OK
, "%d: got 0x%08x\n", i
, hr
);
11814 ok(!lstrcmpW(str
, _bstr_(ptr
->prefix
)), "%d: got prefix %s, expected %s\n", i
, wine_dbgstr_w(str
), ptr
->prefix
);
11818 ok(hr
== S_FALSE
, "%d: got 0x%08x\n", i
, hr
);
11819 ok(str
== NULL
, "%d: got prefix %s\n", i
, wine_dbgstr_w(str
));
11821 SysFreeString(str
);
11824 hr
= IXMLDOMNode_get_namespaceURI(node
, &str
);
11825 ok(hr
== S_OK
, "%d: got 0x%08x\n", i
, hr
);
11826 ok(!lstrcmpW(str
, _bstr_(ptr
->href
)), "%d: got uri %s, expected %s\n", i
, wine_dbgstr_w(str
), ptr
->href
);
11827 SysFreeString(str
);
11829 IXMLDOMNode_Release(node
);
11836 V_VT(&var
) = VT_I1
;
11837 V_I1(&var
) = NODE_ELEMENT
;
11838 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("e"), NULL
, &node2
);
11839 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11841 hr
= IXMLDOMNode_QueryInterface(node2
, &IID_IXMLDOMElement
, (void**)&el
);
11842 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11843 IXMLDOMNode_Release(node2
);
11845 V_VT(&var
) = VT_I1
;
11846 V_I1(&var
) = NODE_ATTRIBUTE
;
11847 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("xmlns:a"), _bstr_("http://www.w3.org/2000/xmlns/"), &node
);
11848 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11850 hr
= IXMLDOMElement_setAttributeNode(el
, (IXMLDOMAttribute
*)node
, NULL
);
11851 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11853 /* for some reason default namespace uri is not reported */
11854 hr
= IXMLDOMNode_get_namespaceURI(node
, &str
);
11855 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
11856 ok(!lstrcmpW(str
, _bstr_("")), "got uri %s\n", wine_dbgstr_w(str
));
11857 SysFreeString(str
);
11859 IXMLDOMNode_Release(node
);
11860 IXMLDOMElement_Release(el
);
11861 IXMLDOMDocument_Release(doc
);
11865 static void test_url(void)
11867 IXMLDOMDocument
*doc
;
11871 doc
= create_document(&IID_IXMLDOMDocument
);
11873 hr
= IXMLDOMDocument_get_url(doc
, NULL
);
11874 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
11877 hr
= IXMLDOMDocument_get_url(doc
, &s
);
11878 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
11879 ok(s
== NULL
, "got %s\n", wine_dbgstr_w(s
));
11881 IXMLDOMDocument_Release(doc
);
11888 hr
= CoInitialize( NULL
);
11889 ok( hr
== S_OK
, "failed to init com\n");
11890 if (hr
!= S_OK
) return;
11892 get_class_support_data(domdoc_support_data
);
11893 if (!is_clsid_supported(&CLSID_DOMDocument2
, &IID_IXMLDOMDocument
))
11895 win_skip("DOMDocument2 is not supported. Skipping all tests.\n");
11901 test_persiststreaminit();
11905 test_getElementsByTagName();
11907 test_get_childNodes();
11908 test_get_firstChild();
11909 test_get_lastChild();
11910 test_removeChild();
11911 test_replaceChild();
11912 test_removeNamedItem();
11913 test_IXMLDOMDocument2();
11920 test_testTransforms();
11921 test_namespaces_basic();
11922 test_namespaces_change();
11923 test_FormattingXML();
11924 test_nodeTypedValue();
11925 test_TransformWithLoadingLocalFile();
11926 test_put_nodeValue();
11927 test_IObjectSafety();
11929 test_getQualifiedItem();
11930 test_removeQualifiedItem();
11931 test_get_ownerDocument();
11932 test_setAttributeNode();
11933 test_put_dataType();
11935 test_create_attribute();
11937 test_default_properties();
11938 test_selectSingleNode();
11940 test_createProcessingInstruction();
11941 test_put_nodeTypedValue();
11943 test_insertBefore();
11944 test_appendChild();
11945 test_get_doctype();
11946 test_get_tagName();
11947 test_get_dataType();
11948 test_get_nodeTypeString();
11949 test_get_attributes();
11954 test_getAttributeNode();
11955 test_supporterrorinfo();
11957 test_get_namespaces();
11959 test_putref_schemas();
11960 test_namedmap_newenum();
11961 test_xmlns_attribute();
11964 test_xsltemplate();
11967 if (is_clsid_supported(&CLSID_MXNamespaceManager40
, &IID_IMXNamespaceManager
))
11969 test_mxnamespacemanager();
11970 test_mxnamespacemanager_override();