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-2012 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
34 #include "msxml2did.h"
42 #include "wine/test.h"
44 /* undef the #define in msxml2 so that we can access all versions */
45 #undef CLSID_DOMDocument
47 DEFINE_GUID(SID_SContainerDispatch
, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
48 DEFINE_GUID(SID_UnknownSID
, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
49 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
51 #define DEFINE_EXPECT(func) \
52 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
54 #define SET_EXPECT(func) \
55 expect_ ## func = TRUE
57 #define CHECK_EXPECT2(func) \
59 ok(expect_ ##func, "unexpected call " #func "\n"); \
60 called_ ## func = TRUE; \
63 #define CHECK_CALLED(func) \
65 ok(called_ ## func, "expected " #func "\n"); \
66 expect_ ## func = called_ ## func = FALSE; \
69 static const char *debugstr_guid(REFIID riid
)
76 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
77 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
78 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
79 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
84 static int g_unexpectedcall
, g_expectedcall
;
88 IDispatch IDispatch_iface
;
92 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
94 return CONTAINING_RECORD(iface
, dispevent
, IDispatch_iface
);
97 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
101 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
102 IsEqualGUID( riid
, &IID_IUnknown
) )
107 return E_NOINTERFACE
;
109 IDispatch_AddRef( iface
);
114 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
116 dispevent
*This
= impl_from_IDispatch( iface
);
117 return InterlockedIncrement( &This
->ref
);
120 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
122 dispevent
*This
= impl_from_IDispatch( iface
);
123 ULONG ref
= InterlockedDecrement( &This
->ref
);
126 HeapFree(GetProcessHeap(), 0, This
);
131 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
138 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
139 LCID lcid
, ITypeInfo
**ppTInfo
)
145 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
146 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
152 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
153 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
154 EXCEPINFO
*excepInfo
, UINT
*argErr
)
156 ok(member
== 0, "expected 0 member, got %d\n", member
);
157 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
158 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
160 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
161 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
162 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
163 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
165 ok(result
== NULL
, "got %p\n", result
);
166 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
167 ok(argErr
== NULL
, "got %p\n", argErr
);
173 static const IDispatchVtbl dispeventVtbl
=
175 dispevent_QueryInterface
,
178 dispevent_GetTypeInfoCount
,
179 dispevent_GetTypeInfo
,
180 dispevent_GetIDsOfNames
,
184 static IDispatch
* create_dispevent(void)
186 dispevent
*event
= HeapAlloc(GetProcessHeap(), 0, sizeof(*event
));
188 event
->IDispatch_iface
.lpVtbl
= &dispeventVtbl
;
191 return (IDispatch
*)&event
->IDispatch_iface
;
195 DEFINE_EXPECT(site_qi_IServiceProvider
);
196 DEFINE_EXPECT(site_qi_IXMLDOMDocument
);
197 DEFINE_EXPECT(site_qi_IOleClientSite
);
199 DEFINE_EXPECT(sp_queryservice_SID_SBindHost
);
200 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
201 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
202 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
203 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
205 DEFINE_EXPECT(htmldoc2_get_all
);
206 DEFINE_EXPECT(htmldoc2_get_url
);
207 DEFINE_EXPECT(collection_get_length
);
211 IServiceProvider IServiceProvider_iface
;
216 static HRESULT WINAPI
site_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
220 if (IsEqualGUID(riid
, &IID_IServiceProvider
))
221 CHECK_EXPECT2(site_qi_IServiceProvider
);
223 if (IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
224 CHECK_EXPECT2(site_qi_IXMLDOMDocument
);
226 if (IsEqualGUID(riid
, &IID_IOleClientSite
))
227 CHECK_EXPECT2(site_qi_IOleClientSite
);
229 if (IsEqualGUID(riid
, &IID_IUnknown
))
231 else if (IsEqualGUID(riid
, &IID_IServiceProvider
))
232 *ppvObject
= &testprov
.IServiceProvider_iface
;
234 if (*ppvObject
) IUnknown_AddRef(iface
);
236 return *ppvObject
? S_OK
: E_NOINTERFACE
;
239 static ULONG WINAPI
site_AddRef(IUnknown
*iface
)
244 static ULONG WINAPI
site_Release(IUnknown
*iface
)
249 static const IUnknownVtbl testsiteVtbl
=
258 IUnknown IUnknown_iface
;
261 static testsite_t testsite
= { { &testsiteVtbl
} };
263 /* test IHTMLElementCollection */
264 static HRESULT WINAPI
htmlecoll_QueryInterface(IHTMLElementCollection
*iface
, REFIID riid
, void **ppvObject
)
266 ok(0, "unexpected call\n");
268 return E_NOINTERFACE
;
271 static ULONG WINAPI
htmlecoll_AddRef(IHTMLElementCollection
*iface
)
276 static ULONG WINAPI
htmlecoll_Release(IHTMLElementCollection
*iface
)
281 static HRESULT WINAPI
htmlecoll_GetTypeInfoCount(IHTMLElementCollection
*iface
, UINT
*pctinfo
)
283 ok(0, "unexpected call\n");
287 static HRESULT WINAPI
htmlecoll_GetTypeInfo(IHTMLElementCollection
*iface
, UINT iTInfo
,
288 LCID lcid
, ITypeInfo
**ppTInfo
)
290 ok(0, "unexpected call\n");
294 static HRESULT WINAPI
htmlecoll_GetIDsOfNames(IHTMLElementCollection
*iface
, REFIID riid
,
295 LPOLESTR
*rgszNames
, UINT cNames
,
296 LCID lcid
, DISPID
*rgDispId
)
298 ok(0, "unexpected call\n");
302 static HRESULT WINAPI
htmlecoll_Invoke(IHTMLElementCollection
*iface
, DISPID dispIdMember
,
303 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
304 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
306 ok(0, "unexpected call\n");
310 static HRESULT WINAPI
htmlecoll_toString(IHTMLElementCollection
*iface
, BSTR
*String
)
312 ok(0, "unexpected call\n");
316 static HRESULT WINAPI
htmlecoll_put_length(IHTMLElementCollection
*iface
, LONG v
)
318 ok(0, "unexpected call\n");
322 static HRESULT WINAPI
htmlecoll_get_length(IHTMLElementCollection
*iface
, LONG
*v
)
324 CHECK_EXPECT2(collection_get_length
);
328 static HRESULT WINAPI
htmlecoll_get__newEnum(IHTMLElementCollection
*iface
, IUnknown
**p
)
330 ok(0, "unexpected call\n");
334 static HRESULT WINAPI
htmlecoll_item(IHTMLElementCollection
*iface
, VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
336 ok(0, "unexpected call\n");
340 static HRESULT WINAPI
htmlecoll_tags(IHTMLElementCollection
*iface
, VARIANT tagName
, IDispatch
**pdisp
)
342 ok(0, "unexpected call\n");
346 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl
= {
347 htmlecoll_QueryInterface
,
350 htmlecoll_GetTypeInfoCount
,
351 htmlecoll_GetTypeInfo
,
352 htmlecoll_GetIDsOfNames
,
356 htmlecoll_put_length
,
357 htmlecoll_get_length
,
358 htmlecoll_get__newEnum
,
365 IHTMLElementCollection IHTMLElementCollection_iface
;
368 static testhtmlecoll_t htmlecoll
= { { &TestHTMLECollectionVtbl
} };
370 /* test IHTMLDocument2 */
371 static HRESULT WINAPI
htmldoc2_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppvObject
)
375 return E_NOINTERFACE
;
378 static ULONG WINAPI
htmldoc2_AddRef(IHTMLDocument2
*iface
)
383 static ULONG WINAPI
htmldoc2_Release(IHTMLDocument2
*iface
)
388 static HRESULT WINAPI
htmldoc2_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
390 ok(0, "unexpected call\n");
394 static HRESULT WINAPI
htmldoc2_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
395 LCID lcid
, ITypeInfo
**ppTInfo
)
397 ok(0, "unexpected call\n");
401 static HRESULT WINAPI
htmldoc2_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
402 LPOLESTR
*rgszNames
, UINT cNames
,
403 LCID lcid
, DISPID
*rgDispId
)
405 ok(0, "unexpected call\n");
409 static HRESULT WINAPI
htmldoc2_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
410 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
411 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
413 ok(0, "unexpected call\n");
417 static HRESULT WINAPI
htmldoc2_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
419 ok(0, "unexpected call\n");
423 static HRESULT WINAPI
htmldoc2_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
425 CHECK_EXPECT2(htmldoc2_get_all
);
426 *p
= &htmlecoll
.IHTMLElementCollection_iface
;
430 static HRESULT WINAPI
htmldoc2_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
432 ok(0, "unexpected call\n");
436 static HRESULT WINAPI
htmldoc2_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
438 ok(0, "unexpected call\n");
442 static HRESULT WINAPI
htmldoc2_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
444 ok(0, "unexpected call\n");
448 static HRESULT WINAPI
htmldoc2_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
450 ok(0, "unexpected call\n");
454 static HRESULT WINAPI
htmldoc2_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
456 ok(0, "unexpected call\n");
460 static HRESULT WINAPI
htmldoc2_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
462 ok(0, "unexpected call\n");
466 static HRESULT WINAPI
htmldoc2_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
468 ok(0, "unexpected call\n");
472 static HRESULT WINAPI
htmldoc2_put_title(IHTMLDocument2
*iface
, BSTR v
)
474 ok(0, "unexpected call\n");
478 static HRESULT WINAPI
htmldoc2_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
480 ok(0, "unexpected call\n");
484 static HRESULT WINAPI
htmldoc2_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
486 ok(0, "unexpected call\n");
490 static HRESULT WINAPI
htmldoc2_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
492 ok(0, "unexpected call\n");
496 static HRESULT WINAPI
htmldoc2_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
498 ok(0, "unexpected call\n");
502 static HRESULT WINAPI
htmldoc2_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
504 ok(0, "unexpected call\n");
508 static HRESULT WINAPI
htmldoc2_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
510 ok(0, "unexpected call\n");
514 static HRESULT WINAPI
htmldoc2_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
516 ok(0, "unexpected call\n");
520 static HRESULT WINAPI
htmldoc2_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
522 ok(0, "unexpected call\n");
526 static HRESULT WINAPI
htmldoc2_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
528 ok(0, "unexpected call\n");
532 static HRESULT WINAPI
htmldoc2_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
534 ok(0, "unexpected call\n");
538 static HRESULT WINAPI
htmldoc2_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
540 ok(0, "unexpected call\n");
544 static HRESULT WINAPI
htmldoc2_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
546 ok(0, "unexpected call\n");
550 static HRESULT WINAPI
htmldoc2_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
552 ok(0, "unexpected call\n");
556 static HRESULT WINAPI
htmldoc2_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
558 ok(0, "unexpected call\n");
562 static HRESULT WINAPI
htmldoc2_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
564 ok(0, "unexpected call\n");
568 static HRESULT WINAPI
htmldoc2_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
570 ok(0, "unexpected call\n");
574 static HRESULT WINAPI
htmldoc2_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
576 ok(0, "unexpected call\n");
580 static HRESULT WINAPI
htmldoc2_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
582 ok(0, "unexpected call\n");
586 static HRESULT WINAPI
htmldoc2_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
588 ok(0, "unexpected call\n");
592 static HRESULT WINAPI
htmldoc2_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
594 ok(0, "unexpected call\n");
598 static HRESULT WINAPI
htmldoc2_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
600 ok(0, "unexpected call\n");
604 static HRESULT WINAPI
htmldoc2_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
606 ok(0, "unexpected call\n");
610 static HRESULT WINAPI
htmldoc2_put_URL(IHTMLDocument2
*iface
, BSTR v
)
612 ok(0, "unexpected call\n");
616 static HRESULT WINAPI
htmldoc2_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
618 CHECK_EXPECT2(htmldoc2_get_url
);
619 *p
= SysAllocString(NULL
);
623 static HRESULT WINAPI
htmldoc2_put_domain(IHTMLDocument2
*iface
, BSTR v
)
625 ok(0, "unexpected call\n");
629 static HRESULT WINAPI
htmldoc2_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
631 ok(0, "unexpected call\n");
635 static HRESULT WINAPI
htmldoc2_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
637 ok(0, "unexpected call\n");
641 static HRESULT WINAPI
htmldoc2_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
643 ok(0, "unexpected call\n");
647 static HRESULT WINAPI
htmldoc2_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
649 ok(0, "unexpected call\n");
653 static HRESULT WINAPI
htmldoc2_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
655 ok(0, "unexpected call\n");
659 static HRESULT WINAPI
htmldoc2_put_charset(IHTMLDocument2
*iface
, BSTR v
)
661 ok(0, "unexpected call\n");
665 static HRESULT WINAPI
htmldoc2_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
667 ok(0, "unexpected call\n");
671 static HRESULT WINAPI
htmldoc2_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
673 ok(0, "unexpected call\n");
677 static HRESULT WINAPI
htmldoc2_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
679 ok(0, "unexpected call\n");
683 static HRESULT WINAPI
htmldoc2_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
685 ok(0, "unexpected call\n");
689 static HRESULT WINAPI
htmldoc2_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
691 ok(0, "unexpected call\n");
695 static HRESULT WINAPI
htmldoc2_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
697 ok(0, "unexpected call\n");
701 static HRESULT WINAPI
htmldoc2_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
703 ok(0, "unexpected call\n");
707 static HRESULT WINAPI
htmldoc2_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
709 ok(0, "unexpected call\n");
713 static HRESULT WINAPI
htmldoc2_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
715 ok(0, "unexpected call\n");
719 static HRESULT WINAPI
htmldoc2_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
721 ok(0, "unexpected call\n");
725 static HRESULT WINAPI
htmldoc2_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
727 ok(0, "unexpected call\n");
731 static HRESULT WINAPI
htmldoc2_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
733 ok(0, "unexpected call\n");
737 static HRESULT WINAPI
htmldoc2_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
739 ok(0, "unexpected call\n");
743 static HRESULT WINAPI
htmldoc2_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
744 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
746 ok(0, "unexpected call\n");
750 static HRESULT WINAPI
htmldoc2_close(IHTMLDocument2
*iface
)
752 ok(0, "unexpected call\n");
756 static HRESULT WINAPI
htmldoc2_clear(IHTMLDocument2
*iface
)
758 ok(0, "unexpected call\n");
762 static HRESULT WINAPI
htmldoc2_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
765 ok(0, "unexpected call\n");
769 static HRESULT WINAPI
htmldoc2_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
772 ok(0, "unexpected call\n");
776 static HRESULT WINAPI
htmldoc2_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
779 ok(0, "unexpected call\n");
783 static HRESULT WINAPI
htmldoc2_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
786 ok(0, "unexpected call\n");
790 static HRESULT WINAPI
htmldoc2_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
793 ok(0, "unexpected call\n");
797 static HRESULT WINAPI
htmldoc2_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
800 ok(0, "unexpected call\n");
804 static HRESULT WINAPI
htmldoc2_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
805 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
807 ok(0, "unexpected call\n");
811 static HRESULT WINAPI
htmldoc2_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
814 ok(0, "unexpected call\n");
818 static HRESULT WINAPI
htmldoc2_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
819 IHTMLElement
**newElem
)
821 ok(0, "unexpected call\n");
825 static HRESULT WINAPI
htmldoc2_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
827 ok(0, "unexpected call\n");
831 static HRESULT WINAPI
htmldoc2_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
833 ok(0, "unexpected call\n");
837 static HRESULT WINAPI
htmldoc2_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
839 ok(0, "unexpected call\n");
843 static HRESULT WINAPI
htmldoc2_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
845 ok(0, "unexpected call\n");
849 static HRESULT WINAPI
htmldoc2_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
851 ok(0, "unexpected call\n");
855 static HRESULT WINAPI
htmldoc2_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
857 ok(0, "unexpected call\n");
861 static HRESULT WINAPI
htmldoc2_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
863 ok(0, "unexpected call\n");
867 static HRESULT WINAPI
htmldoc2_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
869 ok(0, "unexpected call\n");
873 static HRESULT WINAPI
htmldoc2_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
875 ok(0, "unexpected call\n");
879 static HRESULT WINAPI
htmldoc2_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
881 ok(0, "unexpected call\n");
885 static HRESULT WINAPI
htmldoc2_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
887 ok(0, "unexpected call\n");
891 static HRESULT WINAPI
htmldoc2_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
893 ok(0, "unexpected call\n");
897 static HRESULT WINAPI
htmldoc2_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
899 ok(0, "unexpected call\n");
903 static HRESULT WINAPI
htmldoc2_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
905 ok(0, "unexpected call\n");
909 static HRESULT WINAPI
htmldoc2_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
911 ok(0, "unexpected call\n");
915 static HRESULT WINAPI
htmldoc2_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
917 ok(0, "unexpected call\n");
921 static HRESULT WINAPI
htmldoc2_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
923 ok(0, "unexpected call\n");
927 static HRESULT WINAPI
htmldoc2_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
929 ok(0, "unexpected call\n");
933 static HRESULT WINAPI
htmldoc2_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
935 ok(0, "unexpected call\n");
939 static HRESULT WINAPI
htmldoc2_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
941 ok(0, "unexpected call\n");
945 static HRESULT WINAPI
htmldoc2_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
947 ok(0, "unexpected call\n");
951 static HRESULT WINAPI
htmldoc2_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
953 ok(0, "unexpected call\n");
957 static HRESULT WINAPI
htmldoc2_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
959 ok(0, "unexpected call\n");
963 static HRESULT WINAPI
htmldoc2_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
965 ok(0, "unexpected call\n");
969 static HRESULT WINAPI
htmldoc2_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
971 ok(0, "unexpected call\n");
975 static HRESULT WINAPI
htmldoc2_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
977 ok(0, "unexpected call\n");
981 static HRESULT WINAPI
htmldoc2_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
983 ok(0, "unexpected call\n");
987 static HRESULT WINAPI
htmldoc2_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
989 ok(0, "unexpected call\n");
993 static HRESULT WINAPI
htmldoc2_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
995 ok(0, "unexpected call\n");
999 static HRESULT WINAPI
htmldoc2_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
1001 ok(0, "unexpected call\n");
1005 static HRESULT WINAPI
htmldoc2_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
1007 ok(0, "unexpected call\n");
1011 static HRESULT WINAPI
htmldoc2_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1013 ok(0, "unexpected call\n");
1017 static HRESULT WINAPI
htmldoc2_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
1019 ok(0, "unexpected call\n");
1023 static HRESULT WINAPI
htmldoc2_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
1025 ok(0, "unexpected call\n");
1029 static HRESULT WINAPI
htmldoc2_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
1030 IHTMLElement
**elementHit
)
1032 ok(0, "unexpected call\n");
1036 static HRESULT WINAPI
htmldoc2_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
1038 ok(0, "unexpected call\n");
1042 static HRESULT WINAPI
htmldoc2_get_styleSheets(IHTMLDocument2
*iface
,
1043 IHTMLStyleSheetsCollection
**p
)
1045 ok(0, "unexpected call\n");
1049 static HRESULT WINAPI
htmldoc2_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
1051 ok(0, "unexpected call\n");
1055 static HRESULT WINAPI
htmldoc2_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1057 ok(0, "unexpected call\n");
1061 static HRESULT WINAPI
htmldoc2_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
1063 ok(0, "unexpected call\n");
1067 static HRESULT WINAPI
htmldoc2_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
1069 ok(0, "unexpected call\n");
1073 static HRESULT WINAPI
htmldoc2_toString(IHTMLDocument2
*iface
, BSTR
*String
)
1075 ok(0, "unexpected call\n");
1079 static HRESULT WINAPI
htmldoc2_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
1080 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
1082 ok(0, "unexpected call\n");
1086 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl
= {
1087 htmldoc2_QueryInterface
,
1090 htmldoc2_GetTypeInfoCount
,
1091 htmldoc2_GetTypeInfo
,
1092 htmldoc2_GetIDsOfNames
,
1094 htmldoc2_get_Script
,
1097 htmldoc2_get_activeElement
,
1098 htmldoc2_get_images
,
1099 htmldoc2_get_applets
,
1102 htmldoc2_get_anchors
,
1105 htmldoc2_get_scripts
,
1106 htmldoc2_put_designMode
,
1107 htmldoc2_get_designMode
,
1108 htmldoc2_get_selection
,
1109 htmldoc2_get_readyState
,
1110 htmldoc2_get_frames
,
1111 htmldoc2_get_embeds
,
1112 htmldoc2_get_plugins
,
1113 htmldoc2_put_alinkColor
,
1114 htmldoc2_get_alinkColor
,
1115 htmldoc2_put_bgColor
,
1116 htmldoc2_get_bgColor
,
1117 htmldoc2_put_fgColor
,
1118 htmldoc2_get_fgColor
,
1119 htmldoc2_put_linkColor
,
1120 htmldoc2_get_linkColor
,
1121 htmldoc2_put_vlinkColor
,
1122 htmldoc2_get_vlinkColor
,
1123 htmldoc2_get_referrer
,
1124 htmldoc2_get_location
,
1125 htmldoc2_get_lastModified
,
1128 htmldoc2_put_domain
,
1129 htmldoc2_get_domain
,
1130 htmldoc2_put_cookie
,
1131 htmldoc2_get_cookie
,
1132 htmldoc2_put_expando
,
1133 htmldoc2_get_expando
,
1134 htmldoc2_put_charset
,
1135 htmldoc2_get_charset
,
1136 htmldoc2_put_defaultCharset
,
1137 htmldoc2_get_defaultCharset
,
1138 htmldoc2_get_mimeType
,
1139 htmldoc2_get_fileSize
,
1140 htmldoc2_get_fileCreatedDate
,
1141 htmldoc2_get_fileModifiedDate
,
1142 htmldoc2_get_fileUpdatedDate
,
1143 htmldoc2_get_security
,
1144 htmldoc2_get_protocol
,
1145 htmldoc2_get_nameProp
,
1151 htmldoc2_queryCommandSupported
,
1152 htmldoc2_queryCommandEnabled
,
1153 htmldoc2_queryCommandState
,
1154 htmldoc2_queryCommandIndeterm
,
1155 htmldoc2_queryCommandText
,
1156 htmldoc2_queryCommandValue
,
1157 htmldoc2_execCommand
,
1158 htmldoc2_execCommandShowHelp
,
1159 htmldoc2_createElement
,
1160 htmldoc2_put_onhelp
,
1161 htmldoc2_get_onhelp
,
1162 htmldoc2_put_onclick
,
1163 htmldoc2_get_onclick
,
1164 htmldoc2_put_ondblclick
,
1165 htmldoc2_get_ondblclick
,
1166 htmldoc2_put_onkeyup
,
1167 htmldoc2_get_onkeyup
,
1168 htmldoc2_put_onkeydown
,
1169 htmldoc2_get_onkeydown
,
1170 htmldoc2_put_onkeypress
,
1171 htmldoc2_get_onkeypress
,
1172 htmldoc2_put_onmouseup
,
1173 htmldoc2_get_onmouseup
,
1174 htmldoc2_put_onmousedown
,
1175 htmldoc2_get_onmousedown
,
1176 htmldoc2_put_onmousemove
,
1177 htmldoc2_get_onmousemove
,
1178 htmldoc2_put_onmouseout
,
1179 htmldoc2_get_onmouseout
,
1180 htmldoc2_put_onmouseover
,
1181 htmldoc2_get_onmouseover
,
1182 htmldoc2_put_onreadystatechange
,
1183 htmldoc2_get_onreadystatechange
,
1184 htmldoc2_put_onafterupdate
,
1185 htmldoc2_get_onafterupdate
,
1186 htmldoc2_put_onrowexit
,
1187 htmldoc2_get_onrowexit
,
1188 htmldoc2_put_onrowenter
,
1189 htmldoc2_get_onrowenter
,
1190 htmldoc2_put_ondragstart
,
1191 htmldoc2_get_ondragstart
,
1192 htmldoc2_put_onselectstart
,
1193 htmldoc2_get_onselectstart
,
1194 htmldoc2_elementFromPoint
,
1195 htmldoc2_get_parentWindow
,
1196 htmldoc2_get_styleSheets
,
1197 htmldoc2_put_onbeforeupdate
,
1198 htmldoc2_get_onbeforeupdate
,
1199 htmldoc2_put_onerrorupdate
,
1200 htmldoc2_get_onerrorupdate
,
1202 htmldoc2_createStyleSheet
1207 IHTMLDocument2 IHTMLDocument2_iface
;
1210 static testhtmldoc2_t htmldoc2
= { { &TestHTMLDocumentVtbl
} };
1212 static HRESULT WINAPI
sp_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppvObject
)
1216 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1217 IsEqualGUID(riid
, &IID_IServiceProvider
))
1220 IServiceProvider_AddRef(iface
);
1224 ok(0, "unexpected query interface: %s\n", debugstr_guid(riid
));
1226 return E_NOINTERFACE
;
1229 static ULONG WINAPI
sp_AddRef(IServiceProvider
*iface
)
1234 static ULONG WINAPI
sp_Release(IServiceProvider
*iface
)
1239 static HRESULT WINAPI
sp_QueryService(IServiceProvider
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1243 if (IsEqualGUID(service
, &SID_SBindHost
) &&
1244 IsEqualGUID(riid
, &IID_IBindHost
))
1246 CHECK_EXPECT2(sp_queryservice_SID_SBindHost
);
1248 else if (IsEqualGUID(service
, &SID_SContainerDispatch
) &&
1249 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1251 CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1253 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1254 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1256 CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2
);
1257 *obj
= &htmldoc2
.IHTMLDocument2_iface
;
1260 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1261 IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1263 CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc
);
1265 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1266 IsEqualGUID(riid
, &IID_IInternetHostSecurityManager
))
1268 CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr
);
1270 else if (IsEqualGUID(service
, &SID_UnknownSID
) &&
1271 IsEqualGUID(riid
, &IID_IStream
))
1273 /* FIXME: unidentified service id */
1276 ok(0, "unexpected request: sid %s, riid %s\n", debugstr_guid(service
), debugstr_guid(riid
));
1281 static const IServiceProviderVtbl testprovVtbl
=
1289 testprov_t testprov
= { { &testprovVtbl
} };
1291 #define EXPECT_CHILDREN(node) _expect_children((IXMLDOMNode*)node, __LINE__)
1292 static void _expect_children(IXMLDOMNode
*node
, int line
)
1298 hr
= IXMLDOMNode_hasChildNodes(node
, &b
);
1299 ok_(__FILE__
,line
)(hr
== S_OK
, "hasChildNodes() failed, 0x%08x\n", hr
);
1300 ok_(__FILE__
,line
)(b
== VARIANT_TRUE
, "no children, %d\n", b
);
1303 #define EXPECT_NO_CHILDREN(node) _expect_no_children((IXMLDOMNode*)node, __LINE__)
1304 static void _expect_no_children(IXMLDOMNode
*node
, int line
)
1310 hr
= IXMLDOMNode_hasChildNodes(node
, &b
);
1311 ok_(__FILE__
,line
)(hr
== S_FALSE
, "hasChildNodes() failed, 0x%08x\n", hr
);
1312 ok_(__FILE__
,line
)(b
== VARIANT_FALSE
, "no children, %d\n", b
);
1315 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__)
1316 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
1318 ULONG rc
= IUnknown_AddRef(obj
);
1319 IUnknown_Release(obj
);
1320 ok_(__FILE__
,line
)(rc
-1 == ref
, "expected refcount %d, got %d\n", ref
, rc
-1);
1323 #define EXPECT_LIST_LEN(list,len) _expect_list_len(list, len, __LINE__)
1324 static void _expect_list_len(IXMLDOMNodeList
*list
, LONG len
, int line
)
1330 hr
= IXMLDOMNodeList_get_length(list
, &length
);
1331 ok_(__FILE__
,line
)(hr
== S_OK
, "got 0x%08x\n", hr
);
1332 ok_(__FILE__
,line
)(length
== len
, "got %d, expected %d\n", length
, len
);
1335 #define EXPECT_HR(hr,hr_exp) \
1336 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
1338 static const WCHAR szEmpty
[] = { 0 };
1339 static const WCHAR szIncomplete
[] = {
1340 '<','?','x','m','l',' ',
1341 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',0
1343 static const WCHAR szComplete1
[] = {
1344 '<','?','x','m','l',' ',
1345 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
1346 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
1348 static const WCHAR szComplete2
[] = {
1349 '<','?','x','m','l',' ',
1350 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
1351 '<','o','>','<','/','o','>','\n',0
1353 static const WCHAR szComplete3
[] = {
1354 '<','?','x','m','l',' ',
1355 'v','e','r','s','i','o','n','=','\'','1','.','0','\'','?','>','\n',
1356 '<','a','>','<','/','a','>','\n',0
1358 static const char complete4A
[] =
1359 "<?xml version=\'1.0\'?>\n"
1360 "<lc dl=\'str1\'>\n"
1361 "<bs vr=\'str2\' sz=\'1234\'>"
1364 "<pr id=\'str3\' vr=\'1.2.3\' pn=\'wine 20050804\'>\n"
1375 static const WCHAR szComplete5
[] = {
1376 '<','S',':','s','e','a','r','c','h',' ','x','m','l','n','s',':','D','=','"','D','A','V',':','"',' ',
1377 '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','"',
1378 ' ','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','"','>',
1379 '<','S',':','s','c','o','p','e','>',
1380 '<','S',':','d','e','e','p','>','/','<','/','S',':','d','e','e','p','>',
1381 '<','/','S',':','s','c','o','p','e','>',
1382 '<','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
1383 '<','C',':','t','e','x','t','o','r','p','r','o','p','e','r','t','y','/','>',
1384 'c','o','m','p','u','t','e','r',
1385 '<','/','S',':','c','o','n','t','e','n','t','f','r','e','e','t','e','x','t','>',
1386 '<','/','S',':','s','e','a','r','c','h','>',0
1389 static const WCHAR szComplete6
[] = {
1390 '<','?','x','m','l',' ','v','e','r','s','i','o','n','=','\'','1','.','0','\'',' ',
1391 'e','n','c','o','d','i','n','g','=','\'','W','i','n','d','o','w','s','-','1','2','5','2','\'','?','>','\n',
1392 '<','o','p','e','n','>','<','/','o','p','e','n','>','\n',0
1395 static const CHAR szNonUnicodeXML
[] =
1396 "<?xml version='1.0' encoding='Windows-1252'?>\n"
1399 static const char szExampleXML
[] =
1400 "<?xml version='1.0' encoding='utf-8'?>\n"
1401 "<root xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' a=\"attr a\" foo:b=\"attr b\" >\n"
1403 " <a>A1 field</a>\n"
1404 " <b>B1 field</b>\n"
1405 " <c>C1 field</c>\n"
1406 " <description xmlns:foo='http://www.winehq.org' xmlns:bar='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
1407 " <html xmlns='http://www.w3.org/1999/xhtml'>\n"
1408 " This is <strong>a</strong> <i>description</i>. <bar:x/>\n"
1410 " <html xml:space='preserve' xmlns='http://www.w3.org/1999/xhtml'>\n"
1411 " This is <strong>a</strong> <i>description</i> with preserved whitespace. <bar:x/>\n"
1417 " <a>A2 field</a>\n"
1418 " <b>B2 field</b>\n"
1419 " <c type=\"old\">C2 field</c>\n"
1422 " <elem xmlns='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'>\n"
1423 " <a>A3 field</a>\n"
1424 " <b>B3 field</b>\n"
1425 " <c>C3 field</c>\n"
1429 " <a>A4 field</a>\n"
1430 " <b>B4 field</b>\n"
1431 " <foo:c>C4 field</foo:c>\n"
1435 static const CHAR szNodeTypesXML
[] =
1436 "<?xml version='1.0'?>"
1437 "<!-- comment node 0 -->"
1438 "<root id='0' depth='0'>"
1439 " <!-- comment node 1 -->"
1441 " <x id='1' depth='1'>"
1442 " <?foo value='PI for x'?>"
1443 " <!-- comment node 2 -->"
1445 " <a id='3' depth='2'/>"
1446 " <b id='4' depth='2'/>"
1447 " <c id='5' depth='2'/>"
1449 " <y id='2' depth='1'>"
1450 " <?bar value='PI for y'?>"
1451 " <!-- comment node 3 -->"
1453 " <a id='6' depth='2'/>"
1454 " <b id='7' depth='2'/>"
1455 " <c id='8' depth='2'/>"
1459 static const CHAR szTransformXML
[] =
1460 "<?xml version=\"1.0\"?>\n"
1465 static const CHAR szTransformSSXML
[] =
1466 "<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">\n"
1467 " <xsl:output method=\"html\"/>\n"
1468 " <xsl:template match=\"/\">\n"
1469 " <xsl:apply-templates select=\"greeting\"/>\n"
1470 " </xsl:template>\n"
1471 " <xsl:template match=\"greeting\">\n"
1475 " <xsl:value-of select=\".\"/>\n"
1479 " </xsl:template>\n"
1480 "</xsl:stylesheet>";
1482 static const CHAR szTransformOutput
[] =
1485 "</h1></body></html>";
1487 static const CHAR szTypeValueXML
[] =
1488 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
1489 "<root xmlns:dt=\"urn:schemas-microsoft-com:datatypes\">\n"
1490 " <string>Wine</string>\n"
1491 " <string2 dt:dt=\"string\">String</string2>\n"
1492 " <number dt:dt=\"number\">12.44</number>\n"
1493 " <number2 dt:dt=\"NUMbEr\">-3.71e3</number2>\n"
1494 " <int dt:dt=\"int\">-13</int>\n"
1495 " <fixed dt:dt=\"fixed.14.4\">7322.9371</fixed>\n"
1496 " <bool dt:dt=\"boolean\">1</bool>\n"
1497 " <datetime dt:dt=\"datetime\">2009-11-18T03:21:33.12</datetime>\n"
1498 " <datetimetz dt:dt=\"datetime.tz\">2003-07-11T11:13:57+03:00</datetimetz>\n"
1499 " <date dt:dt=\"date\">3721-11-01</date>\n"
1500 " <time dt:dt=\"time\">13:57:12.31321</time>\n"
1501 " <timetz dt:dt=\"time.tz\">23:21:01.13+03:21</timetz>\n"
1502 " <i1 dt:dt=\"i1\">-13</i1>\n"
1503 " <i2 dt:dt=\"i2\">31915</i2>\n"
1504 " <i4 dt:dt=\"i4\">-312232</i4>\n"
1505 " <ui1 dt:dt=\"ui1\">123</ui1>\n"
1506 " <ui2 dt:dt=\"ui2\">48282</ui2>\n"
1507 " <ui4 dt:dt=\"ui4\">949281</ui4>\n"
1508 " <r4 dt:dt=\"r4\">213124.0</r4>\n"
1509 " <r8 dt:dt=\"r8\">0.412</r8>\n"
1510 " <float dt:dt=\"float\">41221.421</float>\n"
1511 " <uuid dt:dt=\"uuid\">333C7BC4-460F-11D0-BC04-0080C7055a83</uuid>\n"
1512 " <binhex dt:dt=\"bin.hex\">fffca012003c</binhex>\n"
1513 " <binbase64 dt:dt=\"bin.base64\">YmFzZTY0IHRlc3Q=</binbase64>\n"
1514 " <binbase64_1 dt:dt=\"bin.base64\">\nYmFzZTY0\nIHRlc3Q=\n</binbase64_1>\n"
1515 " <binbase64_2 dt:dt=\"bin.base64\">\nYmF\r\t z ZTY0\nIHRlc3Q=\n</binbase64_2>\n"
1518 static const CHAR szBasicTransformSSXMLPart1
[] =
1519 "<?xml version=\"1.0\"?>"
1520 "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >"
1521 "<xsl:output method=\"html\"/>\n"
1522 "<xsl:template match=\"/\">"
1523 "<HTML><BODY><TABLE>"
1524 " <xsl:apply-templates select='document(\"";
1526 static const CHAR szBasicTransformSSXMLPart2
[] =
1528 " <xsl:sort select=\"cost\"/><xsl:sort select=\"name\"/>"
1529 " </xsl:apply-templates>"
1530 "</TABLE></BODY></HTML>"
1532 "<xsl:template match=\"bottle\">"
1533 " <TR><xsl:apply-templates select=\"name\" /><xsl:apply-templates select=\"cost\" /></TR>"
1535 "<xsl:template match=\"name\">"
1536 " <TD><xsl:apply-templates /></TD>"
1538 "<xsl:template match=\"cost\">"
1539 " <TD><xsl:apply-templates /></TD>"
1541 "</xsl:stylesheet>";
1543 static const CHAR szBasicTransformXML
[] =
1544 "<?xml version=\"1.0\"?><bottle><wine><name>Wine</name><cost>$25.00</cost></wine></bottle>";
1546 static const CHAR szBasicTransformOutput
[] =
1547 "<HTML><BODY><TABLE><TD>Wine</TD><TD>$25.00</TD></TABLE></BODY></HTML>";
1549 #define SZ_EMAIL_DTD \
1550 "<!DOCTYPE email ["\
1551 " <!ELEMENT email (recipients,from,reply-to?,subject,body,attachment*)>"\
1552 " <!ATTLIST email attachments IDREFS #REQUIRED>"\
1553 " <!ATTLIST email sent (yes|no) \"no\">"\
1554 " <!ELEMENT recipients (to+,cc*)>"\
1555 " <!ELEMENT to (#PCDATA)>"\
1556 " <!ATTLIST to name CDATA #IMPLIED>"\
1557 " <!ELEMENT cc (#PCDATA)>"\
1558 " <!ATTLIST cc name CDATA #IMPLIED>"\
1559 " <!ELEMENT from (#PCDATA)>"\
1560 " <!ATTLIST from name CDATA #IMPLIED>"\
1561 " <!ELEMENT reply-to (#PCDATA)>"\
1562 " <!ATTLIST reply-to name CDATA #IMPLIED>"\
1563 " <!ELEMENT subject ANY>"\
1564 " <!ELEMENT body ANY>"\
1565 " <!ATTLIST body enc CDATA #FIXED \"UTF-8\">"\
1566 " <!ELEMENT attachment (#PCDATA)>"\
1567 " <!ATTLIST attachment id ID #REQUIRED>"\
1570 static const CHAR szEmailXML
[] =
1571 "<?xml version=\"1.0\"?>"
1573 "<email attachments=\"patch1\">"
1575 " <to>wine-patches@winehq.org</to>"
1577 " <from name=\"Anonymous\">user@localhost</from>"
1578 " <subject>msxml3/tests: DTD validation (try 87)</subject>"
1580 " It no longer causes spontaneous combustion..."
1582 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1585 static const CHAR szEmailXML_0D
[] =
1586 "<?xml version=\"1.0\"?>"
1588 "<email attachments=\"patch1\">"
1590 " <to>wine-patches@winehq.org</to>"
1592 " <from name=\"Anonymous\">user@localhost</from>"
1593 " <subject>msxml3/tests: DTD validation (try 88)</subject>"
1596 " XML_ELEMENT_UNDECLARED 0xC00CE00D"
1598 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1601 static const CHAR szEmailXML_0E
[] =
1602 "<?xml version=\"1.0\"?>"
1604 "<email attachments=\"patch1\">"
1606 " <to>wine-patches@winehq.org</to>"
1608 " <from name=\"Anonymous\">user@localhost</from>"
1609 " <subject>msxml3/tests: DTD validation (try 89)</subject>"
1611 " XML_ELEMENT_ID_NOT_FOUND 0xC00CE00E"
1613 " <attachment id=\"patch\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1616 static const CHAR szEmailXML_11
[] =
1617 "<?xml version=\"1.0\"?>"
1619 "<email attachments=\"patch1\">"
1622 " <from name=\"Anonymous\">user@localhost</from>"
1623 " <subject>msxml3/tests: DTD validation (try 90)</subject>"
1625 " XML_EMPTY_NOT_ALLOWED 0xC00CE011"
1627 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1630 static const CHAR szEmailXML_13
[] =
1631 "<?xml version=\"1.0\"?>"
1633 "<msg attachments=\"patch1\">"
1635 " <to>wine-patches@winehq.org</to>"
1637 " <from name=\"Anonymous\">user@localhost</from>"
1638 " <subject>msxml3/tests: DTD validation (try 91)</subject>"
1640 " XML_ROOT_NAME_MISMATCH 0xC00CE013"
1642 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1645 static const CHAR szEmailXML_14
[] =
1646 "<?xml version=\"1.0\"?>"
1648 "<email attachments=\"patch1\">"
1649 " <to>wine-patches@winehq.org</to>"
1650 " <from name=\"Anonymous\">user@localhost</from>"
1651 " <subject>msxml3/tests: DTD validation (try 92)</subject>"
1653 " XML_INVALID_CONTENT 0xC00CE014"
1655 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1658 static const CHAR szEmailXML_15
[] =
1659 "<?xml version=\"1.0\"?>"
1661 "<email attachments=\"patch1\" ip=\"127.0.0.1\">"
1663 " <to>wine-patches@winehq.org</to>"
1665 " <from name=\"Anonymous\">user@localhost</from>"
1666 " <subject>msxml3/tests: DTD validation (try 93)</subject>"
1668 " XML_ATTRIBUTE_NOT_DEFINED 0xC00CE015"
1670 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1673 static const CHAR szEmailXML_16
[] =
1674 "<?xml version=\"1.0\"?>"
1676 "<email attachments=\"patch1\">"
1678 " <to>wine-patches@winehq.org</to>"
1680 " <from name=\"Anonymous\">user@localhost</from>"
1681 " <subject>msxml3/tests: DTD validation (try 94)</subject>"
1682 " <body enc=\"ASCII\">"
1683 " XML_ATTRIBUTE_FIXED 0xC00CE016"
1685 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1688 static const CHAR szEmailXML_17
[] =
1689 "<?xml version=\"1.0\"?>"
1691 "<email attachments=\"patch1\" sent=\"true\">"
1693 " <to>wine-patches@winehq.org</to>"
1695 " <from name=\"Anonymous\">user@localhost</from>"
1696 " <subject>msxml3/tests: DTD validation (try 95)</subject>"
1698 " XML_ATTRIBUTE_VALUE 0xC00CE017"
1700 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1703 static const CHAR szEmailXML_18
[] =
1704 "<?xml version=\"1.0\"?>"
1706 "<email attachments=\"patch1\">"
1709 " <to>wine-patches@winehq.org</to>"
1711 " <from name=\"Anonymous\">user@localhost</from>"
1712 " <subject>msxml3/tests: DTD validation (try 96)</subject>"
1714 " XML_ILLEGAL_TEXT 0xC00CE018"
1716 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1719 static const CHAR szEmailXML_20
[] =
1720 "<?xml version=\"1.0\"?>"
1724 " <to>wine-patches@winehq.org</to>"
1726 " <from name=\"Anonymous\">user@localhost</from>"
1727 " <subject>msxml3/tests: DTD validation (try 97)</subject>"
1729 " XML_REQUIRED_ATTRIBUTE_MISSING 0xC00CE020"
1731 " <attachment id=\"patch1\">0001-msxml3-tests-DTD-validation.patch</attachment>"
1734 static const char xpath_simple_list
[] =
1735 "<?xml version=\"1.0\"?>"
1737 " <a attr1=\"1\" attr2=\"2\" />"
1743 static const char default_ns_doc
[] = {
1744 "<?xml version=\"1.0\"?>"
1745 "<a xmlns:ns=\"nshref\" xml:lang=\"ru\" ns:b=\"b attr\" xml:c=\"c attr\" "
1749 static const WCHAR nonexistent_fileW
[] = {
1750 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'x', 'm', 'l', 0
1752 static const WCHAR nonexistent_attrW
[] = {
1753 'n','o','n','E','x','i','s','i','t','i','n','g','A','t','t','r','i','b','u','t','e',0
1755 static const WCHAR szDocument
[] = {
1756 '#', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 0
1759 static const WCHAR szOpen
[] = { 'o','p','e','n',0 };
1760 static WCHAR szdl
[] = { 'd','l',0 };
1761 static const WCHAR szvr
[] = { 'v','r',0 };
1762 static const WCHAR szlc
[] = { 'l','c',0 };
1763 static WCHAR szbs
[] = { 'b','s',0 };
1764 static const WCHAR szstr1
[] = { 's','t','r','1',0 };
1765 static const WCHAR szstr2
[] = { 's','t','r','2',0 };
1766 static const WCHAR szstar
[] = { '*',0 };
1767 static const WCHAR szfn1_txt
[] = {'f','n','1','.','t','x','t',0};
1769 static WCHAR szComment
[] = {'A',' ','C','o','m','m','e','n','t',0 };
1770 static WCHAR szCommentXML
[] = {'<','!','-','-','A',' ','C','o','m','m','e','n','t','-','-','>',0 };
1771 static WCHAR szCommentNodeText
[] = {'#','c','o','m','m','e','n','t',0 };
1773 static WCHAR szElement
[] = {'E','l','e','T','e','s','t', 0 };
1774 static WCHAR szElementXML
[] = {'<','E','l','e','T','e','s','t','/','>',0 };
1775 static WCHAR szElementXML2
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','/','>',0 };
1776 static WCHAR szElementXML3
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
1777 'T','e','s','t','i','n','g','N','o','d','e','<','/','E','l','e','T','e','s','t','>',0 };
1778 static WCHAR szElementXML4
[] = {'<','E','l','e','T','e','s','t',' ','A','t','t','r','=','"','"','>',
1779 '&','a','m','p',';','x',' ',0x2103,'<','/','E','l','e','T','e','s','t','>',0 };
1781 static WCHAR szAttribute
[] = {'A','t','t','r',0 };
1782 static WCHAR szAttributeXML
[] = {'A','t','t','r','=','"','"',0 };
1784 static WCHAR szCData
[] = {'[','1',']','*','2','=','3',';',' ','&','g','e','e',' ','t','h','a','t','s',
1785 ' ','n','o','t',' ','r','i','g','h','t','!', 0};
1786 static WCHAR szCDataXML
[] = {'<','!','[','C','D','A','T','A','[','[','1',']','*','2','=','3',';',' ','&',
1787 'g','e','e',' ','t','h','a','t','s',' ','n','o','t',' ','r','i','g','h','t',
1789 static WCHAR szCDataNodeText
[] = {'#','c','d','a','t','a','-','s','e','c','t','i','o','n',0 };
1790 static WCHAR szDocFragmentText
[] = {'#','d','o','c','u','m','e','n','t','-','f','r','a','g','m','e','n','t',0 };
1792 static WCHAR szEntityRef
[] = {'e','n','t','i','t','y','r','e','f',0 };
1793 static WCHAR szEntityRefXML
[] = {'&','e','n','t','i','t','y','r','e','f',';',0 };
1794 static WCHAR szStrangeChars
[] = {'&','x',' ',0x2103, 0};
1796 #define expect_bstr_eq_and_free(bstr, expect) { \
1797 BSTR bstrExp = alloc_str_from_narrow(expect); \
1798 ok(lstrcmpW(bstr, bstrExp) == 0, "String differs\n"); \
1799 SysFreeString(bstr); \
1800 SysFreeString(bstrExp); \
1803 #define expect_eq(expr, value, type, format) { type ret = (expr); ok((value) == ret, #expr " expected " format " got " format "\n", value, ret); }
1805 #define ole_check(expr) { \
1807 ok(r == S_OK, #expr " returned %x\n", r); \
1810 #define ole_expect(expr, expect) { \
1812 ok(r == (expect), #expr " returned %x, expected %x\n", r, expect); \
1815 #define double_eq(x, y) ok((x)-(y)<=1e-14*(x) && (x)-(y)>=-1e-14*(x), "expected %.16g, got %.16g\n", x, y)
1817 static void* _create_object(const GUID
*clsid
, const char *name
, const IID
*iid
, int line
)
1822 hr
= CoCreateInstance(clsid
, NULL
, CLSCTX_INPROC_SERVER
, iid
, &obj
);
1824 win_skip_(__FILE__
,line
)("failed to create %s instance: 0x%08x\n", name
, hr
);
1829 #define _create(cls) cls, #cls
1831 #define create_document(iid) _create_object(&_create(CLSID_DOMDocument2), iid, __LINE__)
1832 #define create_document_version(v, iid) _create_object(&_create(CLSID_DOMDocument ## v), iid, __LINE__)
1833 #define create_cache(iid) _create_object(&_create(CLSID_XMLSchemaCache), iid, __LINE__)
1834 #define create_cache_version(v, iid) _create_object(&_create(CLSID_XMLSchemaCache ## v), iid, __LINE__)
1835 #define create_xsltemplate(iid) _create_object(&_create(CLSID_XSLTemplate), iid, __LINE__)
1837 static BSTR
alloc_str_from_narrow(const char *str
)
1839 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
1840 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
1841 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
1845 static BSTR alloced_bstrs
[256];
1846 static int alloced_bstrs_count
;
1848 static BSTR
_bstr_(const char *str
)
1850 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
1851 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
1852 return alloced_bstrs
[alloced_bstrs_count
++];
1855 static void free_bstrs(void)
1858 for (i
= 0; i
< alloced_bstrs_count
; i
++)
1859 SysFreeString(alloced_bstrs
[i
]);
1860 alloced_bstrs_count
= 0;
1863 static VARIANT
_variantbstr_(const char *str
)
1867 V_BSTR(&v
) = _bstr_(str
);
1871 static BOOL
compareIgnoreReturns(BSTR sLeft
, BSTR sRight
)
1875 while (*sLeft
== '\r' || *sLeft
== '\n') sLeft
++;
1876 while (*sRight
== '\r' || *sRight
== '\n') sRight
++;
1877 if (*sLeft
!= *sRight
) return FALSE
;
1878 if (!*sLeft
) return TRUE
;
1884 static void get_str_for_type(DOMNodeType type
, char *buf
)
1888 case NODE_ATTRIBUTE
:
1903 case NODE_PROCESSING_INSTRUCTION
:
1907 wsprintfA(buf
, "[%d]", type
);
1911 static int get_node_position(IXMLDOMNode
*node
)
1916 IXMLDOMNode_AddRef(node
);
1919 IXMLDOMNode
*new_node
;
1922 r
= IXMLDOMNode_get_previousSibling(node
, &new_node
);
1923 ok(SUCCEEDED(r
), "get_previousSibling failed\n");
1924 IXMLDOMNode_Release(node
);
1926 } while (r
== S_OK
);
1930 static void node_to_string(IXMLDOMNode
*node
, char *buf
)
1937 lstrcpyA(buf
, "(null)");
1941 IXMLDOMNode_AddRef(node
);
1944 IXMLDOMNode
*new_node
;
1946 ole_check(IXMLDOMNode_get_nodeType(node
, &type
));
1947 get_str_for_type(type
, buf
);
1950 if (type
== NODE_ATTRIBUTE
)
1953 ole_check(IXMLDOMNode_get_nodeName(node
, &bstr
));
1955 wsprintfA(buf
, "%ws", bstr
);
1958 SysFreeString(bstr
);
1960 r
= IXMLDOMNode_selectSingleNode(node
, _bstr_(".."), &new_node
);
1964 r
= IXMLDOMNode_get_parentNode(node
, &new_node
);
1965 wsprintf(buf
, "%d", get_node_position(node
));
1969 ok(SUCCEEDED(r
), "get_parentNode failed (%08x)\n", r
);
1970 IXMLDOMNode_Release(node
);
1979 static char *list_to_string(IXMLDOMNodeList
*list
)
1981 static char buf
[4096];
1988 lstrcpyA(buf
, "(null)");
1991 ole_check(IXMLDOMNodeList_get_length(list
, &len
));
1992 for (i
= 0; i
< len
; i
++)
1997 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
1998 node_to_string(node
, pos
);
2000 IXMLDOMNode_Release(node
);
2006 #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); }
2007 #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); }
2009 struct docload_ret_t
{
2014 struct leading_spaces_t
{
2017 struct docload_ret_t ret
[2]; /* 0 - ::load(), 1 - ::loadXML() */
2020 static const struct leading_spaces_t leading_spaces_classdata
[] = {
2021 { &CLSID_DOMDocument
, "CLSID_DOMDocument", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_TRUE
, S_OK
} }},
2022 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
2023 { &CLSID_DOMDocument26
, "CLSID_DOMDocument26", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_TRUE
, S_OK
} }},
2024 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
2025 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
2026 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", {{VARIANT_FALSE
, S_FALSE
}, {VARIANT_FALSE
, S_FALSE
} }},
2030 static const char* leading_spaces_xmldata
[] = {
2031 "\n<?xml version=\"1.0\" encoding=\"UTF-16\" ?><root/>",
2032 " <?xml version=\"1.0\"?><root/>",
2033 "\n<?xml version=\"1.0\"?><root/>",
2034 "\t<?xml version=\"1.0\"?><root/>",
2035 "\r\n<?xml version=\"1.0\"?><root/>",
2036 "\r<?xml version=\"1.0\"?><root/>",
2037 "\r\r\r\r\t\t \n\n <?xml version=\"1.0\"?><root/>",
2041 static void test_domdoc( void )
2044 IXMLDOMDocument
*doc
;
2045 IXMLDOMParseError
*error
;
2046 IXMLDOMElement
*element
= NULL
;
2048 IXMLDOMText
*nodetext
= NULL
;
2049 IXMLDOMComment
*node_comment
= NULL
;
2050 IXMLDOMAttribute
*node_attr
= NULL
;
2051 IXMLDOMNode
*nodeChild
= NULL
;
2052 IXMLDOMProcessingInstruction
*nodePI
= NULL
;
2053 const struct leading_spaces_t
*class_ptr
;
2054 const char **data_ptr
;
2063 /* Load document with leading spaces
2065 * Test all CLSIDs with all test data XML strings
2067 class_ptr
= leading_spaces_classdata
;
2069 while (class_ptr
->clsid
)
2074 hr
= CoCreateInstance(class_ptr
->clsid
, NULL
, CLSCTX_INPROC_SERVER
,
2075 &IID_IXMLDOMDocument
, (void**)&doc
);
2077 win_skip("%d: failed to create class instance for %s\n", index
, class_ptr
->name
);
2083 data_ptr
= leading_spaces_xmldata
;
2086 BSTR data
= _bstr_(*data_ptr
);
2089 V_VT(&var
) = VT_BSTR
;
2090 V_BSTR(&var
) = data
;
2091 hr
= IXMLDOMDocument_load(doc
, var
, &b
);
2092 EXPECT_HR(hr
, class_ptr
->ret
[0].hr
);
2093 ok(b
== class_ptr
->ret
[0].b
, "%d:%d, got %d, expected %d\n", index
, i
, b
, class_ptr
->ret
[0].b
);
2096 hr
= IXMLDOMDocument_loadXML(doc
, data
, &b
);
2097 EXPECT_HR(hr
, class_ptr
->ret
[1].hr
);
2098 ok(b
== class_ptr
->ret
[1].b
, "%d:%d, got %d, expected %d\n", index
, i
, b
, class_ptr
->ret
[1].b
);
2107 doc
= create_document(&IID_IXMLDOMDocument
);
2112 /* crashes on native */
2113 IXMLDOMDocument_loadXML( doc
, (BSTR
)0x1, NULL
);
2116 /* try some stupid things */
2117 hr
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
2118 EXPECT_HR(hr
, S_FALSE
);
2121 hr
= IXMLDOMDocument_loadXML( doc
, NULL
, &b
);
2122 EXPECT_HR(hr
, S_FALSE
);
2123 ok( b
== VARIANT_FALSE
, "failed to load XML string\n");
2125 /* try to load a document from a nonexistent file */
2127 str
= SysAllocString( nonexistent_fileW
);
2129 V_VT(&var
) = VT_BSTR
;
2132 r
= IXMLDOMDocument_load( doc
, var
, &b
);
2133 ok( r
== S_FALSE
, "loadXML succeeded\n");
2134 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
2135 SysFreeString( str
);
2137 /* try load an empty document */
2139 str
= SysAllocString( szEmpty
);
2140 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2141 ok( r
== S_FALSE
, "loadXML succeeded\n");
2142 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
2143 SysFreeString( str
);
2145 r
= IXMLDOMDocument_get_async( doc
, &b
);
2146 ok( r
== S_OK
, "get_async failed (%08x)\n", r
);
2147 ok( b
== VARIANT_TRUE
, "Wrong default value\n");
2149 /* check that there's no document element */
2151 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2152 ok( r
== S_FALSE
, "should be no document element\n");
2154 /* try finding a node */
2156 str
= SysAllocString( szstr1
);
2157 r
= IXMLDOMDocument_selectSingleNode( doc
, str
, &node
);
2158 ok( r
== S_FALSE
, "ret %08x\n", r
);
2159 SysFreeString( str
);
2162 str
= SysAllocString( szIncomplete
);
2163 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2164 ok( r
== S_FALSE
, "loadXML succeeded\n");
2165 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
2166 SysFreeString( str
);
2168 /* check that there's no document element */
2169 element
= (IXMLDOMElement
*)1;
2170 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2171 ok( r
== S_FALSE
, "should be no document element\n");
2172 ok( element
== NULL
, "Element should be NULL\n");
2174 /* test for BSTR handling, pass broken BSTR */
2175 memcpy(&buff
[2], szComplete1
, sizeof(szComplete1
));
2176 /* just a big length */
2177 *(DWORD
*)buff
= 0xf0f0;
2179 r
= IXMLDOMDocument_loadXML( doc
, &buff
[2], &b
);
2180 ok( r
== S_OK
, "loadXML failed\n");
2181 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2183 /* loadXML ignores the encoding attribute and always expects Unicode */
2185 str
= SysAllocString( szComplete6
);
2186 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2187 ok( r
== S_OK
, "loadXML failed\n");
2188 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2189 SysFreeString( str
);
2191 /* try a BSTR containing a Windows-1252 document */
2193 str
= SysAllocStringByteLen( szNonUnicodeXML
, sizeof(szNonUnicodeXML
) - 1 );
2194 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2195 ok( r
== S_FALSE
, "loadXML succeeded\n");
2196 ok( b
== VARIANT_FALSE
, "succeeded in loading XML string\n");
2197 SysFreeString( str
);
2199 /* try to load something valid */
2201 str
= SysAllocString( szComplete1
);
2202 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2203 ok( r
== S_OK
, "loadXML failed\n");
2204 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2205 SysFreeString( str
);
2207 /* check if nodename is correct */
2208 r
= IXMLDOMDocument_get_nodeName( doc
, NULL
);
2209 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
2211 str
= (BSTR
)0xdeadbeef;
2212 r
= IXMLDOMDocument_get_baseName( doc
, &str
);
2213 ok ( r
== S_FALSE
, "got 0x%08x\n", r
);
2214 ok (str
== NULL
, "got %p\n", str
);
2216 /* content doesn't matter here */
2218 r
= IXMLDOMDocument_get_nodeName( doc
, &str
);
2219 ok ( r
== S_OK
, "get_nodeName wrong code\n");
2220 ok ( str
!= NULL
, "str is null\n");
2221 ok( !lstrcmpW( str
, szDocument
), "incorrect nodeName\n");
2222 SysFreeString( str
);
2225 r
= IXMLDOMDocument_put_text( doc
, _bstr_("Should Fail") );
2226 ok( r
== E_FAIL
, "ret %08x\n", r
);
2228 /* check that there's a document element */
2230 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2231 ok( r
== S_OK
, "should be a document element\n");
2234 IObjectIdentity
*ident
;
2236 r
= IXMLDOMElement_QueryInterface( element
, &IID_IObjectIdentity
, (void**)&ident
);
2237 ok( r
== E_NOINTERFACE
, "ret %08x\n", r
);
2239 IXMLDOMElement_Release( element
);
2243 /* as soon as we call loadXML again, the document element will disappear */
2245 r
= IXMLDOMDocument_loadXML( doc
, NULL
, NULL
);
2246 ok( r
== S_FALSE
, "loadXML failed\n");
2247 ok( b
== 2, "variant modified\n");
2248 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2249 ok( r
== S_FALSE
, "should be no document element\n");
2251 /* try to load something else simple and valid */
2253 str
= SysAllocString( szComplete3
);
2254 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
2255 ok( r
== S_OK
, "loadXML failed\n");
2256 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2257 SysFreeString( str
);
2259 /* try something a little more complicated */
2261 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
2262 ok( r
== S_OK
, "loadXML failed\n");
2263 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2265 r
= IXMLDOMDocument_get_parseError( doc
, &error
);
2266 ok( r
== S_OK
, "returns %08x\n", r
);
2268 r
= IXMLDOMParseError_get_errorCode( error
, &code
);
2269 ok( r
== S_FALSE
, "returns %08x\n", r
);
2270 ok( code
== 0, "code %d\n", code
);
2271 IXMLDOMParseError_Release( error
);
2273 /* test createTextNode */
2274 r
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &nodetext
);
2275 ok( r
== S_OK
, "returns %08x\n", r
);
2276 IXMLDOMText_Release(nodetext
);
2278 str
= SysAllocString( szOpen
);
2279 r
= IXMLDOMDocument_createTextNode(doc
, str
, NULL
);
2280 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2281 r
= IXMLDOMDocument_createTextNode(doc
, str
, &nodetext
);
2282 ok( r
== S_OK
, "returns %08x\n", r
);
2283 SysFreeString( str
);
2286 r
= IXMLDOMText_QueryInterface(nodetext
, &IID_IXMLDOMElement
, (void**)&element
);
2287 ok(r
== E_NOINTERFACE
, "ret %08x\n", r
);
2289 /* Text Last Child Checks */
2290 r
= IXMLDOMText_get_lastChild(nodetext
, NULL
);
2291 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2293 nodeChild
= (IXMLDOMNode
*)0x1;
2294 r
= IXMLDOMText_get_lastChild(nodetext
, &nodeChild
);
2295 ok(r
== S_FALSE
, "ret %08x\n", r
);
2296 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
2298 /* test length property */
2299 r
= IXMLDOMText_get_length(nodetext
, NULL
);
2300 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2302 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
2303 ok(r
== S_OK
, "ret %08x\n", r
);
2304 ok(nLength
== 4, "expected 4 got %d\n", nLength
);
2306 /* put data Tests */
2307 r
= IXMLDOMText_put_data(nodetext
, _bstr_("This &is a ; test <>\\"));
2308 ok(r
== S_OK
, "ret %08x\n", r
);
2310 /* get data Tests */
2311 r
= IXMLDOMText_get_data(nodetext
, &str
);
2312 ok(r
== S_OK
, "ret %08x\n", r
);
2313 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect put_data string\n");
2316 /* Confirm XML text is good */
2317 r
= IXMLDOMText_get_xml(nodetext
, &str
);
2318 ok(r
== S_OK
, "ret %08x\n", r
);
2319 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2322 /* Confirm we get the put_data Text back */
2323 r
= IXMLDOMText_get_text(nodetext
, &str
);
2324 ok(r
== S_OK
, "ret %08x\n", r
);
2325 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
2328 /* test substringData */
2329 r
= IXMLDOMText_substringData(nodetext
, 0, 4, NULL
);
2330 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2332 /* test substringData - Invalid offset */
2333 str
= (BSTR
)&szElement
;
2334 r
= IXMLDOMText_substringData(nodetext
, -1, 4, &str
);
2335 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2336 ok( str
== NULL
, "incorrect string\n");
2338 /* test substringData - Invalid offset */
2339 str
= (BSTR
)&szElement
;
2340 r
= IXMLDOMText_substringData(nodetext
, 30, 0, &str
);
2341 ok(r
== S_FALSE
, "ret %08x\n", r
);
2342 ok( str
== NULL
, "incorrect string\n");
2344 /* test substringData - Invalid size */
2345 str
= (BSTR
)&szElement
;
2346 r
= IXMLDOMText_substringData(nodetext
, 0, -1, &str
);
2347 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2348 ok( str
== NULL
, "incorrect string\n");
2350 /* test substringData - Invalid size */
2351 str
= (BSTR
)&szElement
;
2352 r
= IXMLDOMText_substringData(nodetext
, 2, 0, &str
);
2353 ok(r
== S_FALSE
, "ret %08x\n", r
);
2354 ok( str
== NULL
, "incorrect string\n");
2356 /* test substringData - Start of string */
2357 r
= IXMLDOMText_substringData(nodetext
, 0, 4, &str
);
2358 ok(r
== S_OK
, "ret %08x\n", r
);
2359 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
2362 /* test substringData - Middle of string */
2363 r
= IXMLDOMText_substringData(nodetext
, 13, 4, &str
);
2364 ok(r
== S_OK
, "ret %08x\n", r
);
2365 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
2368 /* test substringData - End of string */
2369 r
= IXMLDOMText_substringData(nodetext
, 20, 4, &str
);
2370 ok(r
== S_OK
, "ret %08x\n", r
);
2371 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
2374 /* test appendData */
2375 r
= IXMLDOMText_appendData(nodetext
, NULL
);
2376 ok(r
== S_OK
, "ret %08x\n", r
);
2378 r
= IXMLDOMText_appendData(nodetext
, _bstr_(""));
2379 ok(r
== S_OK
, "ret %08x\n", r
);
2381 r
= IXMLDOMText_appendData(nodetext
, _bstr_("Append"));
2382 ok(r
== S_OK
, "ret %08x\n", r
);
2384 r
= IXMLDOMText_get_text(nodetext
, &str
);
2385 ok(r
== S_OK
, "ret %08x\n", r
);
2386 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2389 /* test insertData */
2390 str
= SysAllocStringLen(NULL
, 0);
2391 r
= IXMLDOMText_insertData(nodetext
, -1, str
);
2392 ok(r
== S_OK
, "ret %08x\n", r
);
2394 r
= IXMLDOMText_insertData(nodetext
, -1, NULL
);
2395 ok(r
== S_OK
, "ret %08x\n", r
);
2397 r
= IXMLDOMText_insertData(nodetext
, 1000, str
);
2398 ok(r
== S_OK
, "ret %08x\n", r
);
2400 r
= IXMLDOMText_insertData(nodetext
, 1000, NULL
);
2401 ok(r
== S_OK
, "ret %08x\n", r
);
2403 r
= IXMLDOMText_insertData(nodetext
, 0, NULL
);
2404 ok(r
== S_OK
, "ret %08x\n", r
);
2406 r
= IXMLDOMText_insertData(nodetext
, 0, str
);
2407 ok(r
== S_OK
, "ret %08x\n", r
);
2410 r
= IXMLDOMText_insertData(nodetext
, -1, _bstr_("Inserting"));
2411 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2413 r
= IXMLDOMText_insertData(nodetext
, 1000, _bstr_("Inserting"));
2414 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2416 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("Begin "));
2417 ok(r
== S_OK
, "ret %08x\n", r
);
2419 r
= IXMLDOMText_insertData(nodetext
, 17, _bstr_("Middle"));
2420 ok(r
== S_OK
, "ret %08x\n", r
);
2422 r
= IXMLDOMText_insertData(nodetext
, 39, _bstr_(" End"));
2423 ok(r
== S_OK
, "ret %08x\n", r
);
2425 r
= IXMLDOMText_get_text(nodetext
, &str
);
2426 ok(r
== S_OK
, "ret %08x\n", r
);
2427 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2431 /* invalid arguments */
2432 r
= IXMLDOMText_deleteData(nodetext
, -1, 1);
2433 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2435 r
= IXMLDOMText_deleteData(nodetext
, 0, 0);
2436 ok(r
== S_OK
, "ret %08x\n", r
);
2438 r
= IXMLDOMText_deleteData(nodetext
, 0, -1);
2439 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2441 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
2442 ok(r
== S_OK
, "ret %08x\n", r
);
2443 ok(nLength
== 43, "expected 43 got %d\n", nLength
);
2445 r
= IXMLDOMText_deleteData(nodetext
, nLength
, 1);
2446 ok(r
== S_OK
, "ret %08x\n", r
);
2448 r
= IXMLDOMText_deleteData(nodetext
, nLength
+1, 1);
2449 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2451 /* delete from start */
2452 r
= IXMLDOMText_deleteData(nodetext
, 0, 5);
2453 ok(r
== S_OK
, "ret %08x\n", r
);
2455 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
2456 ok(r
== S_OK
, "ret %08x\n", r
);
2457 ok(nLength
== 38, "expected 38 got %d\n", nLength
);
2459 r
= IXMLDOMText_get_text(nodetext
, &str
);
2460 ok(r
== S_OK
, "ret %08x\n", r
);
2461 ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2464 /* delete from end */
2465 r
= IXMLDOMText_deleteData(nodetext
, 35, 3);
2466 ok(r
== S_OK
, "ret %08x\n", r
);
2468 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
2469 ok(r
== S_OK
, "ret %08x\n", r
);
2470 ok(nLength
== 35, "expected 35 got %d\n", nLength
);
2472 r
= IXMLDOMText_get_text(nodetext
, &str
);
2473 ok(r
== S_OK
, "ret %08x\n", r
);
2474 ok( !lstrcmpW( str
, _bstr_("This &is a Middle; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2477 /* delete from inside */
2478 r
= IXMLDOMText_deleteData(nodetext
, 1, 33);
2479 ok(r
== S_OK
, "ret %08x\n", r
);
2481 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
2482 ok(r
== S_OK
, "ret %08x\n", r
);
2483 ok(nLength
== 2, "expected 2 got %d\n", nLength
);
2485 r
= IXMLDOMText_get_text(nodetext
, &str
);
2486 ok(r
== S_OK
, "ret %08x\n", r
);
2487 ok( !lstrcmpW( str
, _bstr_("") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2490 /* delete whole data ... */
2491 r
= IXMLDOMText_get_length(nodetext
, &nLength
);
2492 ok(r
== S_OK
, "ret %08x\n", r
);
2494 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
2495 ok(r
== S_OK
, "ret %08x\n", r
);
2496 /* ... and try again with empty string */
2497 r
= IXMLDOMText_deleteData(nodetext
, 0, nLength
);
2498 ok(r
== S_OK
, "ret %08x\n", r
);
2501 V_VT(&var
) = VT_BSTR
;
2502 V_BSTR(&var
) = SysAllocString(szstr1
);
2503 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
2504 ok(r
== S_OK
, "ret %08x\n", r
);
2507 r
= IXMLDOMText_get_text(nodetext
, &str
);
2508 ok(r
== S_OK
, "ret %08x\n", r
);
2509 ok( !lstrcmpW( str
, szstr1
), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2515 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
2516 ok(r
== S_OK
, "ret %08x\n", r
);
2519 r
= IXMLDOMText_get_text(nodetext
, &str
);
2520 ok(r
== S_OK
, "ret %08x\n", r
);
2521 ok( !lstrcmpW( str
, _bstr_("99") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2524 /* ::replaceData() */
2525 V_VT(&var
) = VT_BSTR
;
2526 V_BSTR(&var
) = SysAllocString(szstr1
);
2527 r
= IXMLDOMText_put_nodeValue(nodetext
, var
);
2528 ok(r
== S_OK
, "ret %08x\n", r
);
2531 r
= IXMLDOMText_replaceData(nodetext
, 6, 0, NULL
);
2532 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2533 r
= IXMLDOMText_get_text(nodetext
, &str
);
2534 ok(r
== S_OK
, "ret %08x\n", r
);
2535 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2538 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, NULL
);
2539 ok(r
== S_OK
, "ret %08x\n", r
);
2540 r
= IXMLDOMText_get_text(nodetext
, &str
);
2541 ok(r
== S_OK
, "ret %08x\n", r
);
2542 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2545 /* NULL pointer means delete */
2546 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, NULL
);
2547 ok(r
== S_OK
, "ret %08x\n", r
);
2548 r
= IXMLDOMText_get_text(nodetext
, &str
);
2549 ok(r
== S_OK
, "ret %08x\n", r
);
2550 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2553 /* empty string means delete */
2554 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_(""));
2555 ok(r
== S_OK
, "ret %08x\n", r
);
2556 r
= IXMLDOMText_get_text(nodetext
, &str
);
2557 ok(r
== S_OK
, "ret %08x\n", r
);
2558 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2561 /* zero count means insert */
2562 r
= IXMLDOMText_replaceData(nodetext
, 0, 0, _bstr_("a"));
2563 ok(r
== S_OK
, "ret %08x\n", r
);
2564 r
= IXMLDOMText_get_text(nodetext
, &str
);
2565 ok(r
== S_OK
, "ret %08x\n", r
);
2566 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2569 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, NULL
);
2570 ok(r
== S_OK
, "ret %08x\n", r
);
2572 r
= IXMLDOMText_insertData(nodetext
, 0, _bstr_("m"));
2573 ok(r
== S_OK
, "ret %08x\n", r
);
2574 r
= IXMLDOMText_get_text(nodetext
, &str
);
2575 ok(r
== S_OK
, "ret %08x\n", r
);
2576 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2579 /* nonempty string, count greater than its length */
2580 r
= IXMLDOMText_replaceData(nodetext
, 0, 2, _bstr_("a1.2"));
2581 ok(r
== S_OK
, "ret %08x\n", r
);
2582 r
= IXMLDOMText_get_text(nodetext
, &str
);
2583 ok(r
== S_OK
, "ret %08x\n", r
);
2584 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2587 /* nonempty string, count less than its length */
2588 r
= IXMLDOMText_replaceData(nodetext
, 0, 1, _bstr_("wine"));
2589 ok(r
== S_OK
, "ret %08x\n", r
);
2590 r
= IXMLDOMText_get_text(nodetext
, &str
);
2591 ok(r
== S_OK
, "ret %08x\n", r
);
2592 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
2595 IXMLDOMText_Release( nodetext
);
2598 /* test Create Comment */
2599 r
= IXMLDOMDocument_createComment(doc
, NULL
, NULL
);
2600 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2601 node_comment
= (IXMLDOMComment
*)0x1;
2604 r
= IXMLDOMDocument_createComment(doc
, _bstr_(""), &node_comment
);
2605 ok( r
== S_OK
, "returns %08x\n", r
);
2607 r
= IXMLDOMComment_get_data(node_comment
, &str
);
2608 ok( r
== S_OK
, "returns %08x\n", r
);
2609 ok( str
&& SysStringLen(str
) == 0, "expected empty string data\n");
2610 IXMLDOMComment_Release(node_comment
);
2613 r
= IXMLDOMDocument_createComment(doc
, NULL
, &node_comment
);
2614 ok( r
== S_OK
, "returns %08x\n", r
);
2616 r
= IXMLDOMComment_get_data(node_comment
, &str
);
2617 ok( r
== S_OK
, "returns %08x\n", r
);
2618 ok( str
&& (SysStringLen(str
) == 0), "expected empty string data\n");
2619 IXMLDOMComment_Release(node_comment
);
2622 str
= SysAllocString(szComment
);
2623 r
= IXMLDOMDocument_createComment(doc
, str
, &node_comment
);
2625 ok( r
== S_OK
, "returns %08x\n", r
);
2628 /* Last Child Checks */
2629 r
= IXMLDOMComment_get_lastChild(node_comment
, NULL
);
2630 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2632 nodeChild
= (IXMLDOMNode
*)0x1;
2633 r
= IXMLDOMComment_get_lastChild(node_comment
, &nodeChild
);
2634 ok(r
== S_FALSE
, "ret %08x\n", r
);
2635 ok(nodeChild
== NULL
, "pLastChild not NULL\n");
2638 str
= (BSTR
)0xdeadbeef;
2639 IXMLDOMComment_get_baseName(node_comment
, &str
);
2640 ok(r
== S_FALSE
, "ret %08x\n", r
);
2641 ok(str
== NULL
, "Expected NULL\n");
2643 IXMLDOMComment_Release( node_comment
);
2646 /* test Create Attribute */
2647 str
= SysAllocString(szAttribute
);
2648 r
= IXMLDOMDocument_createAttribute(doc
, NULL
, NULL
);
2649 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2650 r
= IXMLDOMDocument_createAttribute(doc
, str
, &node_attr
);
2651 ok( r
== S_OK
, "returns %08x\n", r
);
2652 IXMLDOMText_Release( node_attr
);
2655 /* test Processing Instruction */
2656 str
= SysAllocStringLen(NULL
, 0);
2657 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, NULL
);
2658 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
2659 r
= IXMLDOMDocument_createProcessingInstruction(doc
, NULL
, str
, &nodePI
);
2660 ok( r
== E_FAIL
, "returns %08x\n", r
);
2661 r
= IXMLDOMDocument_createProcessingInstruction(doc
, str
, str
, &nodePI
);
2662 ok( r
== E_FAIL
, "returns %08x\n", r
);
2665 r
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"), _bstr_("version=\"1.0\""), &nodePI
);
2666 ok( r
== S_OK
, "returns %08x\n", r
);
2669 /* Last Child Checks */
2670 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, NULL
);
2671 ok(r
== E_INVALIDARG
, "ret %08x\n", r
);
2673 nodeChild
= (IXMLDOMNode
*)0x1;
2674 r
= IXMLDOMProcessingInstruction_get_lastChild(nodePI
, &nodeChild
);
2675 ok(r
== S_FALSE
, "ret %08x\n", r
);
2676 ok(nodeChild
== NULL
, "nodeChild not NULL\n");
2679 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
2680 ok(r
== S_OK
, "ret %08x\n", r
);
2681 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
2686 r
= IXMLDOMProcessingInstruction_get_baseName(nodePI
, &str
);
2687 ok(r
== S_OK
, "ret %08x\n", r
);
2688 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
2692 r
= IXMLDOMProcessingInstruction_get_target(nodePI
, &str
);
2693 ok(r
== S_OK
, "ret %08x\n", r
);
2694 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect target string\n");
2698 r
= IXMLDOMProcessingInstruction_get_data(nodePI
, &str
);
2699 ok(r
== S_OK
, "ret %08x\n", r
);
2700 ok( !lstrcmpW( str
, _bstr_("version=\"1.0\"") ), "incorrect data string\n");
2704 r
= IXMLDOMProcessingInstruction_put_data(nodePI
, _bstr_("version=\"1.0\" encoding=\"UTF-8\""));
2705 ok(r
== E_FAIL
, "ret %08x\n", r
);
2708 V_VT(&var
) = VT_BSTR
;
2709 V_BSTR(&var
) = SysAllocString(szOpen
); /* Doesn't matter what the string is, cannot set an xml node. */
2710 r
= IXMLDOMProcessingInstruction_put_nodeValue(nodePI
, var
);
2711 ok(r
== E_FAIL
, "ret %08x\n", r
);
2714 /* test get nodeName */
2715 r
= IXMLDOMProcessingInstruction_get_nodeName(nodePI
, &str
);
2716 ok( !lstrcmpW( str
, _bstr_("xml") ), "incorrect nodeName string\n");
2717 ok(r
== S_OK
, "ret %08x\n", r
);
2720 IXMLDOMProcessingInstruction_Release(nodePI
);
2723 ref
= IXMLDOMDocument_Release( doc
);
2724 ok( ref
== 0, "got %d\n", ref
);
2729 static void test_persiststreaminit(void)
2731 IXMLDOMDocument
*doc
;
2732 IPersistStreamInit
*streaminit
;
2735 doc
= create_document(&IID_IXMLDOMDocument
);
2738 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IPersistStreamInit
, (void**)&streaminit
);
2739 ok( hr
== S_OK
, "failed with 0x%08x\n", hr
);
2741 hr
= IPersistStreamInit_InitNew(streaminit
);
2742 ok( hr
== S_OK
, "failed with 0x%08x\n", hr
);
2744 IXMLDOMDocument_Release(doc
);
2747 static void test_domnode( void )
2750 IXMLDOMDocument
*doc
, *owner
= NULL
;
2751 IXMLDOMElement
*element
= NULL
;
2752 IXMLDOMNamedNodeMap
*map
= NULL
;
2753 IXMLDOMNode
*node
= NULL
, *next
= NULL
;
2754 IXMLDOMNodeList
*list
= NULL
;
2755 IXMLDOMAttribute
*attr
= NULL
;
2756 DOMNodeType type
= NODE_INVALID
;
2762 doc
= create_document(&IID_IXMLDOMDocument
);
2766 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
2767 ok( r
== S_OK
, "loadXML failed\n");
2768 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
2770 EXPECT_CHILDREN(doc
);
2772 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
2773 ok( r
== S_OK
, "should be a document element\n");
2774 ok( element
!= NULL
, "should be an element\n");
2777 ok( V_VT(&var
) == VT_EMPTY
, "variant init failed\n");
2779 r
= IXMLDOMNode_get_nodeValue( doc
, NULL
);
2780 ok(r
== E_INVALIDARG
, "get_nodeValue ret %08x\n", r
);
2782 r
= IXMLDOMNode_get_nodeValue( doc
, &var
);
2783 ok( r
== S_FALSE
, "nextNode returned wrong code\n");
2784 ok( V_VT(&var
) == VT_NULL
, "variant wasn't empty\n");
2785 ok( V_BSTR(&var
) == NULL
, "variant value wasn't null\n");
2790 r
= IXMLDOMNode_get_ownerDocument( element
, &owner
);
2791 ok( r
== S_OK
, "get_ownerDocument return code\n");
2792 ok( owner
!= doc
, "get_ownerDocument return\n");
2793 IXMLDOMDocument_Release(owner
);
2795 type
= NODE_INVALID
;
2796 r
= IXMLDOMNode_get_nodeType( element
, &type
);
2797 ok( r
== S_OK
, "got %08x\n", r
);
2798 ok( type
== NODE_ELEMENT
, "node not an element\n");
2801 r
= IXMLDOMNode_get_baseName( element
, &str
);
2802 ok( r
== S_OK
, "get_baseName returned wrong code\n");
2803 ok( lstrcmpW(str
,szlc
) == 0, "basename was wrong\n");
2806 /* check if nodename is correct */
2807 r
= IXMLDOMElement_get_nodeName( element
, NULL
);
2808 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
2810 /* content doesn't matter here */
2812 r
= IXMLDOMElement_get_nodeName( element
, &str
);
2813 ok ( r
== S_OK
, "get_nodeName wrong code\n");
2814 ok ( str
!= NULL
, "str is null\n");
2815 ok( !lstrcmpW( str
, szlc
), "incorrect nodeName\n");
2816 SysFreeString( str
);
2818 str
= SysAllocString( nonexistent_fileW
);
2820 V_I4(&var
) = 0x1234;
2821 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
2822 ok( r
== E_FAIL
, "getAttribute ret %08x\n", r
);
2823 ok( V_VT(&var
) == VT_NULL
|| V_VT(&var
) == VT_EMPTY
, "vt = %x\n", V_VT(&var
));
2826 str
= SysAllocString( szdl
);
2828 V_I4(&var
) = 0x1234;
2829 r
= IXMLDOMElement_getAttribute( element
, str
, &var
);
2830 ok( r
== S_OK
, "getAttribute ret %08x\n", r
);
2831 ok( V_VT(&var
) == VT_BSTR
, "vt = %x\n", V_VT(&var
));
2832 ok( !lstrcmpW(V_BSTR(&var
), szstr1
), "wrong attr value\n");
2833 VariantClear( &var
);
2835 r
= IXMLDOMElement_getAttribute( element
, NULL
, &var
);
2836 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
2838 r
= IXMLDOMElement_getAttribute( element
, str
, NULL
);
2839 ok( r
== E_INVALIDARG
, "getAttribute ret %08x\n", r
);
2842 r
= IXMLDOMElement_getAttributeNode( element
, str
, &attr
);
2843 ok( r
== S_OK
, "GetAttributeNode ret %08x\n", r
);
2844 ok( attr
!= NULL
, "getAttributeNode returned NULL\n" );
2847 r
= IXMLDOMAttribute_get_parentNode( attr
, NULL
);
2848 ok( r
== E_INVALIDARG
, "Expected E_INVALIDARG, ret %08x\n", r
);
2850 /* attribute doesn't have a parent in msxml interpretation */
2851 node
= (IXMLDOMNode
*)0xdeadbeef;
2852 r
= IXMLDOMAttribute_get_parentNode( attr
, &node
);
2853 ok( r
== S_FALSE
, "Expected S_FALSE, ret %08x\n", r
);
2854 ok( node
== NULL
, "Expected NULL, got %p\n", node
);
2856 IXMLDOMAttribute_Release(attr
);
2859 SysFreeString( str
);
2861 r
= IXMLDOMElement_get_attributes( element
, &map
);
2862 ok( r
== S_OK
, "get_attributes returned wrong code\n");
2863 ok( map
!= NULL
, "should be attributes\n");
2865 EXPECT_CHILDREN(element
);
2868 ok( FALSE
, "no element\n");
2872 str
= SysAllocString( szdl
);
2873 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
2874 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2875 ok( node
!= NULL
, "should be attributes\n");
2876 IXMLDOMNode_Release(node
);
2877 SysFreeString( str
);
2879 str
= SysAllocString( szdl
);
2880 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, NULL
);
2881 ok( r
== E_INVALIDARG
, "getNamedItem should return E_INVALIDARG\n");
2882 SysFreeString( str
);
2884 /* something that isn't in complete4A */
2885 str
= SysAllocString( szOpen
);
2886 node
= (IXMLDOMNode
*) 1;
2887 r
= IXMLDOMNamedNodeMap_getNamedItem( map
, str
, &node
);
2888 ok( r
== S_FALSE
, "getNamedItem found a node that wasn't there\n");
2889 ok( node
== NULL
, "getNamedItem should have returned NULL\n");
2890 SysFreeString( str
);
2892 /* test indexed access of attributes */
2893 r
= IXMLDOMNamedNodeMap_get_length( map
, NULL
);
2894 ok ( r
== E_INVALIDARG
, "get_length should return E_INVALIDARG\n");
2896 r
= IXMLDOMNamedNodeMap_get_length( map
, &count
);
2897 ok ( r
== S_OK
, "get_length wrong code\n");
2898 ok ( count
== 1, "get_length != 1\n");
2901 r
= IXMLDOMNamedNodeMap_get_item( map
, -1, &node
);
2902 ok ( r
== S_FALSE
, "get_item (-1) wrong code\n");
2903 ok ( node
== NULL
, "there is no node\n");
2906 r
= IXMLDOMNamedNodeMap_get_item( map
, 1, &node
);
2907 ok ( r
== S_FALSE
, "get_item (1) wrong code\n");
2908 ok ( node
== NULL
, "there is no attribute\n");
2911 r
= IXMLDOMNamedNodeMap_get_item( map
, 0, &node
);
2912 ok ( r
== S_OK
, "get_item (0) wrong code\n");
2913 ok ( node
!= NULL
, "should be attribute\n");
2915 r
= IXMLDOMNode_get_nodeName( node
, NULL
);
2916 ok ( r
== E_INVALIDARG
, "get_nodeName (NULL) wrong code\n");
2918 /* content doesn't matter here */
2920 r
= IXMLDOMNode_get_nodeName( node
, &str
);
2921 ok ( r
== S_OK
, "get_nodeName wrong code\n");
2922 ok ( str
!= NULL
, "str is null\n");
2923 ok( !lstrcmpW( str
, szdl
), "incorrect node name\n");
2924 SysFreeString( str
);
2925 IXMLDOMNode_Release( node
);
2927 /* test sequential access of attributes */
2929 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2930 ok ( r
== S_OK
, "nextNode (first time) wrong code\n");
2931 ok ( node
!= NULL
, "nextNode, should be attribute\n");
2932 IXMLDOMNode_Release( node
);
2934 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2935 ok ( r
!= S_OK
, "nextNode (second time) wrong code\n");
2936 ok ( node
== NULL
, "nextNode, there is no attribute\n");
2938 r
= IXMLDOMNamedNodeMap_reset( map
);
2939 ok ( r
== S_OK
, "reset should return S_OK\n");
2941 r
= IXMLDOMNamedNodeMap_nextNode( map
, &node
);
2942 ok ( r
== S_OK
, "nextNode (third time) wrong code\n");
2943 ok ( node
!= NULL
, "nextNode, should be attribute\n");
2946 ok( FALSE
, "no map\n");
2950 type
= NODE_INVALID
;
2951 r
= IXMLDOMNode_get_nodeType( node
, &type
);
2952 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2953 ok( type
== NODE_ATTRIBUTE
, "node not an attribute\n");
2956 r
= IXMLDOMNode_get_baseName( node
, NULL
);
2957 ok( r
== E_INVALIDARG
, "get_baseName returned wrong code\n");
2960 r
= IXMLDOMNode_get_baseName( node
, &str
);
2961 ok( r
== S_OK
, "get_baseName returned wrong code\n");
2962 ok( lstrcmpW(str
,szdl
) == 0, "basename was wrong\n");
2963 SysFreeString( str
);
2965 r
= IXMLDOMNode_get_childNodes( node
, NULL
);
2966 ok( r
== E_INVALIDARG
, "get_childNodes returned wrong code\n");
2968 r
= IXMLDOMNode_get_childNodes( node
, &list
);
2969 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
2973 r
= IXMLDOMNodeList_nextNode( list
, &next
);
2974 ok( r
== S_OK
, "nextNode returned wrong code\n");
2977 ok( FALSE
, "no childlist\n");
2981 EXPECT_NO_CHILDREN(next
);
2983 type
= NODE_INVALID
;
2984 r
= IXMLDOMNode_get_nodeType( next
, &type
);
2985 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
2986 ok( type
== NODE_TEXT
, "node not text\n");
2989 r
= IXMLDOMNode_get_baseName( next
, &str
);
2990 ok( r
== S_FALSE
, "get_baseName returned wrong code\n");
2991 ok( str
== NULL
, "basename was wrong\n");
2995 ok( FALSE
, "no next\n");
2998 IXMLDOMNode_Release( next
);
3001 IXMLDOMNodeList_Release( list
);
3004 IXMLDOMNode_Release( node
);
3007 ok( FALSE
, "no node\n");
3011 IXMLDOMNamedNodeMap_Release( map
);
3013 /* now traverse the tree from the root element */
3016 r
= IXMLDOMNode_get_childNodes( element
, &list
);
3017 ok( r
== S_OK
, "get_childNodes returned wrong code\n");
3019 /* using get_item for child list doesn't advance the position */
3020 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
3021 expect_node(node
, "E2.E2.D1");
3022 IXMLDOMNode_Release(node
);
3023 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
3024 expect_node(node
, "E1.E2.D1");
3025 IXMLDOMNode_Release(node
);
3026 ole_check(IXMLDOMNodeList_reset(list
));
3028 IXMLDOMNodeList_AddRef(list
);
3029 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1");
3030 ole_check(IXMLDOMNodeList_reset(list
));
3032 node
= (void*)0xdeadbeef;
3033 str
= SysAllocString(szdl
);
3034 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
3036 ok( r
== S_FALSE
, "ret %08x\n", r
);
3037 ok( node
== NULL
, "node %p\n", node
);
3039 str
= SysAllocString(szbs
);
3040 r
= IXMLDOMNode_selectSingleNode( element
, str
, &node
);
3042 ok( r
== S_OK
, "ret %08x\n", r
);
3043 r
= IXMLDOMNode_Release( node
);
3044 ok( r
== 0, "ret %08x\n", r
);
3047 ok( FALSE
, "no element\n");
3051 r
= IXMLDOMNodeList_get_item(list
, 0, NULL
);
3052 ok(r
== E_INVALIDARG
, "Expected E_INVALIDARG got %08x\n", r
);
3054 r
= IXMLDOMNodeList_get_length(list
, NULL
);
3055 ok(r
== E_INVALIDARG
, "Expected E_INVALIDARG got %08x\n", r
);
3057 r
= IXMLDOMNodeList_get_length( list
, &count
);
3058 ok( r
== S_OK
, "get_length returns %08x\n", r
);
3059 ok( count
== 4, "get_length got %d\n", count
);
3061 r
= IXMLDOMNodeList_nextNode(list
, NULL
);
3062 ok(r
== E_INVALIDARG
, "Expected E_INVALIDARG got %08x\n", r
);
3064 r
= IXMLDOMNodeList_nextNode( list
, &node
);
3065 ok( r
== S_OK
, "nextNode returned wrong code\n");
3068 ok( FALSE
, "no list\n");
3072 type
= NODE_INVALID
;
3073 r
= IXMLDOMNode_get_nodeType( node
, &type
);
3074 ok( r
== S_OK
, "getNamedItem returned wrong code\n");
3075 ok( type
== NODE_ELEMENT
, "node not text\n");
3077 r
= IXMLDOMNode_hasChildNodes( node
, NULL
);
3078 ok( r
== E_INVALIDARG
, "hasChildNodes bad return\n");
3080 EXPECT_CHILDREN(node
);
3083 r
= IXMLDOMNode_get_baseName( node
, &str
);
3084 ok( r
== S_OK
, "get_baseName returned wrong code\n");
3085 ok( lstrcmpW(str
,szbs
) == 0, "basename was wrong\n");
3089 ok( FALSE
, "no node\n");
3092 IXMLDOMNode_Release( node
);
3094 IXMLDOMNodeList_Release( list
);
3096 IXMLDOMElement_Release( element
);
3099 str
= SysAllocString( szComplete5
);
3100 r
= IXMLDOMDocument_loadXML( doc
, str
, &b
);
3101 ok( r
== S_OK
, "loadXML failed\n");
3102 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3103 SysFreeString( str
);
3105 EXPECT_CHILDREN(doc
);
3107 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
3108 ok( r
== S_OK
, "should be a document element\n");
3109 ok( element
!= NULL
, "should be an element\n");
3113 static const WCHAR szSSearch
[] = {'S',':','s','e','a','r','c','h',0};
3116 /* check if the tag is correct */
3117 r
= IXMLDOMElement_get_tagName( element
, &tag
);
3118 ok( r
== S_OK
, "couldn't get tag name\n");
3119 ok( tag
!= NULL
, "tag was null\n");
3120 ok( !lstrcmpW( tag
, szSSearch
), "incorrect tag name\n");
3121 SysFreeString( tag
);
3125 IXMLDOMElement_Release( element
);
3126 ok(IXMLDOMDocument_Release( doc
) == 0, "document is not destroyed\n");
3136 static const refcount_test_t refcount_test
[] = {
3137 { NODE_ELEMENT
, &IID_IXMLDOMElement
},
3138 { NODE_ATTRIBUTE
, &IID_IXMLDOMAttribute
},
3139 { NODE_TEXT
, &IID_IXMLDOMText
},
3140 { NODE_CDATA_SECTION
, &IID_IXMLDOMCDATASection
},
3141 { NODE_ENTITY_REFERENCE
, &IID_IXMLDOMEntityReference
},
3142 { NODE_PROCESSING_INSTRUCTION
, &IID_IXMLDOMProcessingInstruction
},
3143 { NODE_COMMENT
, &IID_IXMLDOMComment
},
3144 { NODE_DOCUMENT_FRAGMENT
, &IID_IXMLDOMDocumentFragment
},
3145 { NODE_INVALID
, &IID_NULL
}
3148 static void test_refs(void)
3150 IXMLDOMImplementation
*impl
, *impl2
;
3151 IXMLDOMElement
*element
, *elem2
;
3152 IXMLDOMNodeList
*node_list
= NULL
;
3153 IXMLDOMNode
*node
, *node2
, *node3
;
3154 const refcount_test_t
*ptr
;
3155 IXMLDOMDocument
*doc
;
3156 IUnknown
*unk
, *unk2
;
3161 doc
= create_document(&IID_IXMLDOMDocument
);
3164 ptr
= refcount_test
;
3165 while (ptr
->type
!= NODE_INVALID
)
3167 IUnknown
*node_typed
, *node_typed2
;
3168 IDispatchEx
*dispex
, *dispex2
;
3169 IDispatch
*disp
, *disp2
;
3172 V_VT(&type
) = VT_I1
;
3173 V_I1(&type
) = ptr
->type
;
3176 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("name"), NULL
, &node
);
3177 EXPECT_HR(hr
, S_OK
);
3179 EXPECT_REF(node
, 1);
3181 /* try IDispatch and IUnknown from IXMLDOMNode */
3182 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IUnknown
, (void**)&unk
);
3183 EXPECT_HR(hr
, S_OK
);
3186 EXPECT_REF(node
, 1);
3187 ok(unk
!= (IUnknown
*)node
, "%d: got %p and %p\n", ptr
->type
, unk
, node
);
3190 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp
);
3191 EXPECT_HR(hr
, S_OK
);
3192 todo_wine
ok(unk
!= (IUnknown
*)disp
, "%d: got %p and %p\n", ptr
->type
, unk
, disp
);
3194 todo_wine
EXPECT_REF(disp
, 1);
3197 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatch
, (void**)&disp2
);
3198 EXPECT_HR(hr
, S_OK
);
3199 todo_wine
ok(disp
!= disp2
, "%d: got %p and %p\n", ptr
->type
, disp
, disp2
);
3201 todo_wine
EXPECT_REF(disp2
, 1);
3203 IDispatch_Release(disp
);
3204 IDispatch_Release(disp2
);
3206 /* get IXMLDOMNode from this IUnknown */
3208 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMNode
, (void**)&node2
);
3209 EXPECT_HR(hr
, S_OK
);
3210 todo_wine
ok(unk
!= (IUnknown
*)node2
, "%d: got %p and %p\n", ptr
->type
, unk
, node2
);
3212 todo_wine
EXPECT_REF(node2
, 1);
3215 hr
= IUnknown_QueryInterface(unk
, &IID_IXMLDOMNode
, (void**)&node3
);
3216 EXPECT_HR(hr
, S_OK
);
3217 todo_wine
ok(node2
!= node3
, "%d: got %p and %p\n", ptr
->type
, node2
, node3
);
3219 todo_wine
EXPECT_REF(node3
, 1);
3221 IXMLDOMNode_Release(node2
);
3222 IXMLDOMNode_Release(node3
);
3224 /* try IDispatchEx from IUnknown */
3226 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex
);
3227 EXPECT_HR(hr
, S_OK
);
3228 ok(unk
!= (IUnknown
*)dispex
, "%d: got %p and %p\n", ptr
->type
, unk
, dispex
);
3230 todo_wine
EXPECT_REF(dispex
, 1);
3233 hr
= IUnknown_QueryInterface(unk
, &IID_IDispatchEx
, (void**)&dispex2
);
3234 EXPECT_HR(hr
, S_OK
);
3235 todo_wine
ok(dispex
!= dispex2
, "%d: got %p and %p\n", ptr
->type
, dispex
, dispex2
);
3237 todo_wine
EXPECT_REF(dispex2
, 1);
3239 IDispatch_Release(dispex
);
3240 IDispatch_Release(dispex2
);
3242 /* try corresponding IXMLDOM* */
3244 hr
= IUnknown_QueryInterface(unk
, ptr
->iid
, (void**)&node_typed
);
3245 EXPECT_HR(hr
, S_OK
);
3247 hr
= IUnknown_QueryInterface(unk
, ptr
->iid
, (void**)&node_typed2
);
3248 EXPECT_HR(hr
, S_OK
);
3250 todo_wine
ok(node_typed
!= node_typed2
, "%d: got %p and %p\n", ptr
->type
, node_typed
, node_typed2
);
3251 IUnknown_Release(node_typed
);
3252 IUnknown_Release(node_typed2
);
3254 /* try invalid IXMLDOM* */
3255 hr
= IUnknown_QueryInterface(unk
, (ptr
+1)->iid
, (void**)&node_typed
);
3256 EXPECT_HR(hr
, E_NOINTERFACE
);
3258 IUnknown_Release(unk
);
3260 EXPECT_REF(node
, 1);
3261 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMNode
, (void**)&node2
);
3262 EXPECT_HR(hr
, S_OK
);
3263 EXPECT_REF(node
, 2);
3264 ok(node
== node2
, "%d: got %p and %p\n", ptr
->type
, node
, node2
);
3266 EXPECT_REF(node
, 2);
3267 hr
= IXMLDOMNode_QueryInterface(node
, ptr
->iid
, (void**)&node_typed
);
3268 EXPECT_HR(hr
, S_OK
);
3269 EXPECT_REF(node
, 3);
3271 EXPECT_REF(node_typed
, 2);
3272 ok((IUnknown
*)node
!= node_typed
, "%d: got %p and %p\n", ptr
->type
, node
, node_typed
);
3274 IUnknown_Release(node_typed
);
3276 IXMLDOMNode_Release(node2
);
3277 IXMLDOMNode_Release(node
);
3283 ref
= IXMLDOMDocument_Release(doc
);
3284 ok( ref
== 0, "ref %d\n", ref
);
3286 /* check IUnknown after releasing DOM iface */
3287 doc
= create_document(&IID_IXMLDOMDocument
);
3289 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
3290 EXPECT_HR(hr
, S_OK
);
3295 IXMLDOMDocument_Release(doc
);
3297 IUnknown_Release(unk
);
3299 doc
= create_document(&IID_IXMLDOMDocument
);
3303 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
3304 EXPECT_HR(hr
, S_OK
);
3309 IUnknown_Release(unk
);
3311 /* IXMLDOMImplementation */
3313 hr
= IXMLDOMDocument_get_implementation(doc
, &impl
);
3314 EXPECT_HR(hr
, S_OK
);
3316 EXPECT_REF(impl
, 1);
3317 hr
= IXMLDOMDocument_get_implementation(doc
, &impl2
);
3318 EXPECT_HR(hr
, S_OK
);
3320 EXPECT_REF(impl2
, 1);
3321 ok(impl
!= impl2
, "got %p, %p\n", impl
, impl2
);
3322 IXMLDOMImplementation_Release(impl
);
3323 IXMLDOMImplementation_Release(impl2
);
3325 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3326 EXPECT_HR(hr
, S_OK
);
3327 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3330 IXMLDOMDocument_AddRef( doc
);
3332 IXMLDOMDocument_AddRef( doc
);
3335 IXMLDOMDocument_Release( doc
);
3336 IXMLDOMDocument_Release( doc
);
3339 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
3340 EXPECT_HR(hr
, S_OK
);
3345 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
3346 EXPECT_HR(hr
, S_OK
);
3349 EXPECT_REF(element
, 2);
3351 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem2
);
3352 EXPECT_HR(hr
, S_OK
);
3356 EXPECT_REF(element
, 2);
3357 EXPECT_REF(elem2
, 2);
3359 IXMLDOMElement_AddRef(element
);
3360 todo_wine
EXPECT_REF(element
, 3);
3361 IXMLDOMElement_Release(element
);
3363 /* get IUnknown from a node doesn't touch node instance refcount */
3364 hr
= IXMLDOMElement_QueryInterface(element
, &IID_IUnknown
, (void**)&unk
);
3365 EXPECT_HR(hr
, S_OK
);
3366 EXPECT_REF(element
, 2);
3369 EXPECT_REF(elem2
, 2);
3371 hr
= IXMLDOMElement_QueryInterface(elem2
, &IID_IUnknown
, (void**)&unk2
);
3372 EXPECT_HR(hr
, S_OK
);
3375 EXPECT_REF(unk2
, 5);
3377 EXPECT_REF(element
, 2);
3378 EXPECT_REF(elem2
, 2);
3380 todo_wine
ok(unk
== unk2
, "got %p and %p\n", unk
, unk2
);
3382 IUnknown_Release(unk
);
3383 IUnknown_Release(unk2
);
3385 /* IUnknown refcount is not affected by node refcount */
3386 todo_wine
EXPECT_REF(unk2
, 3);
3387 IXMLDOMElement_AddRef(elem2
);
3388 todo_wine
EXPECT_REF(unk2
, 3);
3389 IXMLDOMElement_Release(elem2
);
3391 IXMLDOMElement_Release(elem2
);
3392 todo_wine
EXPECT_REF(unk2
, 2);
3394 hr
= IXMLDOMElement_get_childNodes( element
, &node_list
);
3395 EXPECT_HR(hr
, S_OK
);
3397 todo_wine
EXPECT_REF(element
, 2);
3398 EXPECT_REF(node_list
, 1);
3400 hr
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
3401 EXPECT_HR(hr
, S_OK
);
3402 EXPECT_REF(node_list
, 1);
3403 EXPECT_REF(node
, 1);
3405 hr
= IXMLDOMNodeList_get_item( node_list
, 0, &node2
);
3406 EXPECT_HR(hr
, S_OK
);
3407 EXPECT_REF(node_list
, 1);
3408 EXPECT_REF(node2
, 1);
3410 ref
= IXMLDOMNode_Release( node
);
3411 ok( ref
== 0, "ref %d\n", ref
);
3412 ref
= IXMLDOMNode_Release( node2
);
3413 ok( ref
== 0, "ref %d\n", ref
);
3415 ref
= IXMLDOMNodeList_Release( node_list
);
3416 ok( ref
== 0, "ref %d\n", ref
);
3418 ok( node
!= node2
, "node %p node2 %p\n", node
, node2
);
3420 ref
= IXMLDOMDocument_Release( doc
);
3421 todo_wine
ok( ref
== 0, "ref %d\n", ref
);
3423 todo_wine
EXPECT_REF(element
, 2);
3425 /* IUnknown must be unique however we obtain it */
3426 hr
= IXMLDOMElement_QueryInterface(element
, &IID_IUnknown
, (void**)&unk
);
3427 EXPECT_HR(hr
, S_OK
);
3428 EXPECT_REF(element
, 2);
3429 hr
= IXMLDOMElement_QueryInterface(element
, &IID_IXMLDOMNode
, (void**)&node
);
3430 EXPECT_HR(hr
, S_OK
);
3431 todo_wine
EXPECT_REF(element
, 2);
3432 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IUnknown
, (void**)&unk2
);
3433 EXPECT_HR(hr
, S_OK
);
3434 todo_wine
EXPECT_REF(element
, 2);
3435 ok(unk
== unk2
, "unk %p unk2 %p\n", unk
, unk2
);
3436 todo_wine
ok(element
!= (void*)node
, "node %p element %p\n", node
, element
);
3438 IUnknown_Release( unk2
);
3439 IUnknown_Release( unk
);
3440 IXMLDOMNode_Release( node
);
3441 todo_wine
EXPECT_REF(element
, 2);
3443 IXMLDOMElement_Release( element
);
3448 static void test_create(void)
3450 static const WCHAR szOne
[] = {'1',0};
3451 static const WCHAR szOneGarbage
[] = {'1','G','a','r','b','a','g','e',0};
3455 IXMLDOMDocument
*doc
;
3456 IXMLDOMElement
*element
;
3457 IXMLDOMComment
*comment
;
3459 IXMLDOMCDATASection
*cdata
;
3460 IXMLDOMNode
*root
, *node
, *child
;
3461 IXMLDOMNamedNodeMap
*attr_map
;
3466 doc
= create_document(&IID_IXMLDOMDocument
);
3471 /* types not supported for creation */
3473 V_I1(&var
) = NODE_DOCUMENT
;
3474 node
= (IXMLDOMNode
*)0x1;
3475 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3476 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3477 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3480 V_I1(&var
) = NODE_DOCUMENT_TYPE
;
3481 node
= (IXMLDOMNode
*)0x1;
3482 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3483 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3484 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3487 V_I1(&var
) = NODE_ENTITY
;
3488 node
= (IXMLDOMNode
*)0x1;
3489 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3490 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3491 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3494 V_I1(&var
) = NODE_NOTATION
;
3495 node
= (IXMLDOMNode
*)0x1;
3496 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3497 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3498 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3502 V_I1(&var
) = NODE_COMMENT
;
3504 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3505 ok( r
== S_OK
, "returns %08x\n", r
);
3506 ok( node
!= NULL
, "\n");
3508 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
3509 ok( r
== S_OK
, "returns %08x\n", r
);
3510 IXMLDOMNode_Release(node
);
3513 r
= IXMLDOMComment_get_data(comment
, &str
);
3514 ok( r
== S_OK
, "returns %08x\n", r
);
3515 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3516 IXMLDOMComment_Release(comment
);
3519 node
= (IXMLDOMNode
*)0x1;
3520 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3521 ok( r
== S_OK
, "returns %08x\n", r
);
3523 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
3524 ok( r
== S_OK
, "returns %08x\n", r
);
3525 IXMLDOMNode_Release(node
);
3528 r
= IXMLDOMComment_get_data(comment
, &str
);
3529 ok( r
== S_OK
, "returns %08x\n", r
);
3530 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3531 IXMLDOMComment_Release(comment
);
3534 node
= (IXMLDOMNode
*)0x1;
3535 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
3536 ok( r
== S_OK
, "returns %08x\n", r
);
3538 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMComment
, (void**)&comment
);
3539 ok( r
== S_OK
, "returns %08x\n", r
);
3540 IXMLDOMNode_Release(node
);
3543 r
= IXMLDOMComment_get_data(comment
, &str
);
3544 ok( r
== S_OK
, "returns %08x\n", r
);
3545 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3546 IXMLDOMComment_Release(comment
);
3551 V_I1(&var
) = NODE_TEXT
;
3553 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3554 ok( r
== S_OK
, "returns %08x\n", r
);
3555 ok( node
!= NULL
, "\n");
3557 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
3558 ok( r
== S_OK
, "returns %08x\n", r
);
3559 IXMLDOMNode_Release(node
);
3562 r
= IXMLDOMText_get_data(text
, &str
);
3563 ok( r
== S_OK
, "returns %08x\n", r
);
3564 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3565 IXMLDOMText_Release(text
);
3568 node
= (IXMLDOMNode
*)0x1;
3569 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3570 ok( r
== S_OK
, "returns %08x\n", r
);
3572 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
3573 ok( r
== S_OK
, "returns %08x\n", r
);
3574 IXMLDOMNode_Release(node
);
3577 r
= IXMLDOMText_get_data(text
, &str
);
3578 ok( r
== S_OK
, "returns %08x\n", r
);
3579 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3580 IXMLDOMText_Release(text
);
3583 node
= (IXMLDOMNode
*)0x1;
3584 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
3585 ok( r
== S_OK
, "returns %08x\n", r
);
3587 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMText
, (void**)&text
);
3588 ok( r
== S_OK
, "returns %08x\n", r
);
3589 IXMLDOMNode_Release(node
);
3592 r
= IXMLDOMText_get_data(text
, &str
);
3593 ok( r
== S_OK
, "returns %08x\n", r
);
3594 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3595 IXMLDOMText_Release(text
);
3598 /* NODE_CDATA_SECTION */
3600 V_I1(&var
) = NODE_CDATA_SECTION
;
3602 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3603 ok( r
== S_OK
, "returns %08x\n", r
);
3604 ok( node
!= NULL
, "\n");
3606 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
3607 ok( r
== S_OK
, "returns %08x\n", r
);
3608 IXMLDOMNode_Release(node
);
3611 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
3612 ok( r
== S_OK
, "returns %08x\n", r
);
3613 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3614 IXMLDOMCDATASection_Release(cdata
);
3617 node
= (IXMLDOMNode
*)0x1;
3618 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3619 ok( r
== S_OK
, "returns %08x\n", r
);
3621 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
3622 ok( r
== S_OK
, "returns %08x\n", r
);
3623 IXMLDOMNode_Release(node
);
3626 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
3627 ok( r
== S_OK
, "returns %08x\n", r
);
3628 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3629 IXMLDOMCDATASection_Release(cdata
);
3632 node
= (IXMLDOMNode
*)0x1;
3633 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("blah"), NULL
, &node
);
3634 ok( r
== S_OK
, "returns %08x\n", r
);
3636 r
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMCDATASection
, (void**)&cdata
);
3637 ok( r
== S_OK
, "returns %08x\n", r
);
3638 IXMLDOMNode_Release(node
);
3641 r
= IXMLDOMCDATASection_get_data(cdata
, &str
);
3642 ok( r
== S_OK
, "returns %08x\n", r
);
3643 ok( str
&& SysStringLen(str
) == 0, "expected empty comment, %p\n", str
);
3644 IXMLDOMCDATASection_Release(cdata
);
3647 /* NODE_ATTRIBUTE */
3649 V_I1(&var
) = NODE_ATTRIBUTE
;
3650 node
= (IXMLDOMNode
*)0x1;
3651 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3652 ok( r
== E_FAIL
, "returns %08x\n", r
);
3653 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3656 V_I1(&var
) = NODE_ATTRIBUTE
;
3657 node
= (IXMLDOMNode
*)0x1;
3658 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3659 ok( r
== E_FAIL
, "returns %08x\n", r
);
3660 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3663 V_I1(&var
) = NODE_ATTRIBUTE
;
3664 str
= SysAllocString( szlc
);
3665 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3666 ok( r
== S_OK
, "returns %08x\n", r
);
3667 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
3670 /* a name is required for attribute, try a BSTR with first null wchar */
3672 V_I1(&var
) = NODE_ATTRIBUTE
;
3673 str
= SysAllocString( szstr1
);
3675 node
= (IXMLDOMNode
*)0x1;
3676 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3677 ok( r
== E_FAIL
, "returns %08x\n", r
);
3678 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3681 /* NODE_PROCESSING_INSTRUCTION */
3683 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
3684 node
= (IXMLDOMNode
*)0x1;
3685 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3686 ok( r
== E_FAIL
, "returns %08x\n", r
);
3687 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3690 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
3691 node
= (IXMLDOMNode
*)0x1;
3692 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3693 ok( r
== E_FAIL
, "returns %08x\n", r
);
3694 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3697 V_I1(&var
) = NODE_PROCESSING_INSTRUCTION
;
3698 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_("pi"), NULL
, NULL
);
3699 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3701 /* NODE_ENTITY_REFERENCE */
3703 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
3704 node
= (IXMLDOMNode
*)0x1;
3705 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3706 ok( r
== E_FAIL
, "returns %08x\n", r
);
3707 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3710 V_I1(&var
) = NODE_ENTITY_REFERENCE
;
3711 node
= (IXMLDOMNode
*)0x1;
3712 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3713 ok( r
== E_FAIL
, "returns %08x\n", r
);
3714 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3718 V_I1(&var
) = NODE_ELEMENT
;
3719 node
= (IXMLDOMNode
*)0x1;
3720 r
= IXMLDOMDocument_createNode( doc
, var
, NULL
, NULL
, &node
);
3721 ok( r
== E_FAIL
, "returns %08x\n", r
);
3722 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3725 V_I1(&var
) = NODE_ELEMENT
;
3726 node
= (IXMLDOMNode
*)0x1;
3727 r
= IXMLDOMDocument_createNode( doc
, var
, _bstr_(""), NULL
, &node
);
3728 ok( r
== E_FAIL
, "returns %08x\n", r
);
3729 ok( node
== (void*)0x1, "expected same ptr, got %p\n", node
);
3732 V_I1(&var
) = NODE_ELEMENT
;
3733 str
= SysAllocString( szlc
);
3734 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3735 ok( r
== S_OK
, "returns %08x\n", r
);
3736 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
3739 V_I1(&var
) = NODE_ELEMENT
;
3740 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, NULL
);
3741 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3744 V_R4(&var
) = NODE_ELEMENT
;
3745 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3746 ok( r
== S_OK
, "returns %08x\n", r
);
3747 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
3749 V_VT(&var
) = VT_BSTR
;
3750 V_BSTR(&var
) = SysAllocString( szOne
);
3751 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3752 ok( r
== S_OK
, "returns %08x\n", r
);
3753 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
3756 V_VT(&var
) = VT_BSTR
;
3757 V_BSTR(&var
) = SysAllocString( szOneGarbage
);
3758 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3759 ok( r
== E_INVALIDARG
, "returns %08x\n", r
);
3760 if( SUCCEEDED(r
) ) IXMLDOMNode_Release( node
);
3764 V_I4(&var
) = NODE_ELEMENT
;
3765 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3766 ok( r
== S_OK
, "returns %08x\n", r
);
3769 r
= IXMLDOMDocument_appendChild( doc
, node
, &root
);
3770 ok( r
== S_OK
, "returns %08x\n", r
);
3771 ok( node
== root
, "%p %p\n", node
, root
);
3774 EXPECT_REF(node
, 2);
3776 ref
= IXMLDOMNode_Release( node
);
3777 ok(ref
== 1, "ref %d\n", ref
);
3778 SysFreeString( str
);
3781 V_I4(&var
) = NODE_ELEMENT
;
3782 str
= SysAllocString( szbs
);
3783 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3784 ok( r
== S_OK
, "returns %08x\n", r
);
3785 SysFreeString( str
);
3787 EXPECT_REF(node
, 1);
3789 r
= IXMLDOMNode_QueryInterface( node
, &IID_IUnknown
, (void**)&unk
);
3790 ok( r
== S_OK
, "returns %08x\n", r
);
3794 V_VT(&var
) = VT_EMPTY
;
3796 r
= IXMLDOMNode_insertBefore( root
, (IXMLDOMNode
*)unk
, var
, &child
);
3797 ok( r
== S_OK
, "returns %08x\n", r
);
3798 ok( unk
== (IUnknown
*)child
, "%p %p\n", unk
, child
);
3800 todo_wine
EXPECT_REF(unk
, 4);
3802 IXMLDOMNode_Release( child
);
3803 IUnknown_Release( unk
);
3805 V_VT(&var
) = VT_NULL
;
3806 V_DISPATCH(&var
) = (IDispatch
*)node
;
3807 r
= IXMLDOMNode_insertBefore( root
, node
, var
, &child
);
3808 ok( r
== S_OK
, "returns %08x\n", r
);
3809 ok( node
== child
, "%p %p\n", node
, child
);
3810 IXMLDOMNode_Release( child
);
3812 V_VT(&var
) = VT_NULL
;
3813 V_DISPATCH(&var
) = (IDispatch
*)node
;
3814 r
= IXMLDOMNode_insertBefore( root
, node
, var
, NULL
);
3815 ok( r
== S_OK
, "returns %08x\n", r
);
3816 IXMLDOMNode_Release( node
);
3818 r
= IXMLDOMNode_QueryInterface( root
, &IID_IXMLDOMElement
, (void**)&element
);
3819 ok( r
== S_OK
, "returns %08x\n", r
);
3821 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
3822 ok( r
== S_OK
, "returns %08x\n", r
);
3823 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
3824 ok( r
== S_OK
, "returns %08x\n", r
);
3825 ok( num
== 0, "num %d\n", num
);
3826 IXMLDOMNamedNodeMap_Release( attr_map
);
3828 V_VT(&var
) = VT_BSTR
;
3829 V_BSTR(&var
) = SysAllocString( szstr1
);
3830 name
= SysAllocString( szdl
);
3831 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
3832 ok( r
== S_OK
, "returns %08x\n", r
);
3833 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
3834 ok( r
== S_OK
, "returns %08x\n", r
);
3835 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
3836 ok( r
== S_OK
, "returns %08x\n", r
);
3837 ok( num
== 1, "num %d\n", num
);
3838 IXMLDOMNamedNodeMap_Release( attr_map
);
3841 V_VT(&var
) = VT_BSTR
;
3842 V_BSTR(&var
) = SysAllocString( szstr2
);
3843 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
3844 ok( r
== S_OK
, "returns %08x\n", r
);
3845 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
3846 ok( r
== S_OK
, "returns %08x\n", r
);
3847 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
3848 ok( r
== S_OK
, "returns %08x\n", r
);
3849 ok( num
== 1, "num %d\n", num
);
3850 IXMLDOMNamedNodeMap_Release( attr_map
);
3852 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
3853 ok( r
== S_OK
, "returns %08x\n", r
);
3854 ok( !lstrcmpW(V_BSTR(&var
), szstr2
), "wrong attr value\n");
3856 SysFreeString(name
);
3858 V_VT(&var
) = VT_BSTR
;
3859 V_BSTR(&var
) = SysAllocString( szstr1
);
3860 name
= SysAllocString( szlc
);
3861 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
3862 ok( r
== S_OK
, "returns %08x\n", r
);
3863 r
= IXMLDOMElement_get_attributes( element
, &attr_map
);
3864 ok( r
== S_OK
, "returns %08x\n", r
);
3865 r
= IXMLDOMNamedNodeMap_get_length( attr_map
, &num
);
3866 ok( r
== S_OK
, "returns %08x\n", r
);
3867 ok( num
== 2, "num %d\n", num
);
3868 IXMLDOMNamedNodeMap_Release( attr_map
);
3870 SysFreeString(name
);
3874 name
= SysAllocString( szbs
);
3875 r
= IXMLDOMElement_setAttribute( element
, name
, var
);
3876 ok( r
== S_OK
, "returns %08x\n", r
);
3878 r
= IXMLDOMElement_getAttribute( element
, name
, &var
);
3879 ok( r
== S_OK
, "returns %08x\n", r
);
3880 ok( V_VT(&var
) == VT_BSTR
, "variant type %x\n", V_VT(&var
));
3882 SysFreeString(name
);
3884 /* Create an Attribute */
3886 V_I4(&var
) = NODE_ATTRIBUTE
;
3887 str
= SysAllocString( szAttribute
);
3888 r
= IXMLDOMDocument_createNode( doc
, var
, str
, NULL
, &node
);
3889 ok( r
== S_OK
, "returns %08x\n", r
);
3890 ok( node
!= NULL
, "node was null\n");
3893 IXMLDOMElement_Release( element
);
3894 IXMLDOMNode_Release( root
);
3895 IXMLDOMDocument_Release( doc
);
3898 static void test_getElementsByTagName(void)
3900 IXMLDOMNodeList
*node_list
;
3901 IXMLDOMDocument
*doc
;
3902 IXMLDOMElement
*elem
;
3909 doc
= create_document(&IID_IXMLDOMDocument
);
3912 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
3913 ok( r
== S_OK
, "loadXML failed\n");
3914 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
3916 str
= SysAllocString( szstar
);
3918 /* null arguments cases */
3919 r
= IXMLDOMDocument_getElementsByTagName(doc
, NULL
, &node_list
);
3920 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3921 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, NULL
);
3922 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3924 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
3925 ok( r
== S_OK
, "ret %08x\n", r
);
3926 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3927 ok( r
== S_OK
, "ret %08x\n", r
);
3928 ok( len
== 6, "len %d\n", len
);
3930 IXMLDOMNodeList_Release( node_list
);
3931 SysFreeString( str
);
3933 /* broken query BSTR */
3934 memcpy(&buff
[2], szstar
, sizeof(szstar
));
3935 /* just a big length */
3936 *(DWORD
*)buff
= 0xf0f0;
3937 r
= IXMLDOMDocument_getElementsByTagName(doc
, &buff
[2], &node_list
);
3938 ok( r
== S_OK
, "ret %08x\n", r
);
3939 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3940 ok( r
== S_OK
, "ret %08x\n", r
);
3941 ok( len
== 6, "len %d\n", len
);
3942 IXMLDOMNodeList_Release( node_list
);
3944 str
= SysAllocString( szbs
);
3945 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
3946 ok( r
== S_OK
, "ret %08x\n", r
);
3947 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3948 ok( r
== S_OK
, "ret %08x\n", r
);
3949 ok( len
== 1, "len %d\n", len
);
3950 IXMLDOMNodeList_Release( node_list
);
3951 SysFreeString( str
);
3953 str
= SysAllocString( szdl
);
3954 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
3955 ok( r
== S_OK
, "ret %08x\n", r
);
3956 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3957 ok( r
== S_OK
, "ret %08x\n", r
);
3958 ok( len
== 0, "len %d\n", len
);
3959 IXMLDOMNodeList_Release( node_list
);
3960 SysFreeString( str
);
3962 str
= SysAllocString( szstr1
);
3963 r
= IXMLDOMDocument_getElementsByTagName(doc
, str
, &node_list
);
3964 ok( r
== S_OK
, "ret %08x\n", r
);
3965 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3966 ok( r
== S_OK
, "ret %08x\n", r
);
3967 ok( len
== 0, "len %d\n", len
);
3968 IXMLDOMNodeList_Release( node_list
);
3969 SysFreeString( str
);
3971 /* test for element */
3972 r
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
3973 ok( r
== S_OK
, "ret %08x\n", r
);
3975 str
= SysAllocString( szstar
);
3977 /* null arguments cases */
3978 r
= IXMLDOMElement_getElementsByTagName(elem
, NULL
, &node_list
);
3979 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3980 r
= IXMLDOMElement_getElementsByTagName(elem
, str
, NULL
);
3981 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
3983 r
= IXMLDOMElement_getElementsByTagName(elem
, str
, &node_list
);
3984 ok( r
== S_OK
, "ret %08x\n", r
);
3985 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3986 ok( r
== S_OK
, "ret %08x\n", r
);
3987 ok( len
== 5, "len %d\n", len
);
3988 expect_list_and_release(node_list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1 E4.E2.D1 E1.E4.E2.D1");
3989 SysFreeString( str
);
3991 /* broken query BSTR */
3992 memcpy(&buff
[2], szstar
, sizeof(szstar
));
3993 /* just a big length */
3994 *(DWORD
*)buff
= 0xf0f0;
3995 r
= IXMLDOMElement_getElementsByTagName(elem
, &buff
[2], &node_list
);
3996 ok( r
== S_OK
, "ret %08x\n", r
);
3997 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
3998 ok( r
== S_OK
, "ret %08x\n", r
);
3999 ok( len
== 5, "len %d\n", len
);
4000 IXMLDOMNodeList_Release( node_list
);
4002 IXMLDOMElement_Release(elem
);
4004 IXMLDOMDocument_Release( doc
);
4009 static void test_get_text(void)
4014 IXMLDOMDocument
*doc
;
4015 IXMLDOMNode
*node
, *node2
, *node3
;
4016 IXMLDOMNode
*nodeRoot
;
4017 IXMLDOMNodeList
*node_list
;
4018 IXMLDOMNamedNodeMap
*node_map
;
4021 doc
= create_document(&IID_IXMLDOMDocument
);
4024 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4025 ok( r
== S_OK
, "loadXML failed\n");
4026 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4028 str
= SysAllocString( szbs
);
4029 r
= IXMLDOMDocument_getElementsByTagName( doc
, str
, &node_list
);
4030 ok( r
== S_OK
, "ret %08x\n", r
);
4033 /* Test to get all child node text. */
4034 r
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&nodeRoot
);
4035 ok( r
== S_OK
, "ret %08x\n", r
);
4038 r
= IXMLDOMNode_get_text( nodeRoot
, &str
);
4039 ok( r
== S_OK
, "ret %08x\n", r
);
4040 ok( compareIgnoreReturns(str
, _bstr_("fn1.txt\n\n fn2.txt \n\nf1\n")), "wrong get_text: %s\n", wine_dbgstr_w(str
));
4043 IXMLDOMNode_Release(nodeRoot
);
4046 r
= IXMLDOMNodeList_get_length( node_list
, NULL
);
4047 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4049 r
= IXMLDOMNodeList_get_length( node_list
, &len
);
4050 ok( r
== S_OK
, "ret %08x\n", r
);
4051 ok( len
== 1, "expect 1 got %d\n", len
);
4053 r
= IXMLDOMNodeList_get_item( node_list
, 0, NULL
);
4054 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4056 r
= IXMLDOMNodeList_nextNode( node_list
, NULL
);
4057 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4059 r
= IXMLDOMNodeList_get_item( node_list
, 0, &node
);
4060 ok( r
== S_OK
, "ret %08x\n", r
);
4061 IXMLDOMNodeList_Release( node_list
);
4063 /* Invalid output parameter*/
4064 r
= IXMLDOMNode_get_text( node
, NULL
);
4065 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4067 r
= IXMLDOMNode_get_text( node
, &str
);
4068 ok( r
== S_OK
, "ret %08x\n", r
);
4069 ok( !memcmp(str
, szfn1_txt
, lstrlenW(szfn1_txt
) ), "wrong string\n" );
4072 r
= IXMLDOMNode_get_attributes( node
, &node_map
);
4073 ok( r
== S_OK
, "ret %08x\n", r
);
4075 str
= SysAllocString( szvr
);
4076 r
= IXMLDOMNamedNodeMap_getNamedItem( node_map
, str
, &node2
);
4077 ok( r
== S_OK
, "ret %08x\n", r
);
4080 r
= IXMLDOMNode_get_text( node2
, &str
);
4081 ok( r
== S_OK
, "ret %08x\n", r
);
4082 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
4085 r
= IXMLDOMNode_get_firstChild( node2
, &node3
);
4086 ok( r
== S_OK
, "ret %08x\n", r
);
4088 r
= IXMLDOMNode_get_text( node3
, &str
);
4089 ok( r
== S_OK
, "ret %08x\n", r
);
4090 ok( !memcmp(str
, szstr2
, sizeof(szstr2
)), "wrong string\n" );
4094 IXMLDOMNode_Release( node3
);
4095 IXMLDOMNode_Release( node2
);
4096 IXMLDOMNamedNodeMap_Release( node_map
);
4097 IXMLDOMNode_Release( node
);
4098 IXMLDOMDocument_Release( doc
);
4103 static void test_get_childNodes(void)
4107 IXMLDOMDocument
*doc
;
4108 IXMLDOMElement
*element
;
4109 IXMLDOMNode
*node
, *node2
;
4110 IXMLDOMNodeList
*node_list
, *node_list2
;
4114 doc
= create_document(&IID_IXMLDOMDocument
);
4117 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4118 EXPECT_HR(hr
, S_OK
);
4119 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4121 hr
= IXMLDOMDocument_get_documentElement( doc
, &element
);
4122 EXPECT_HR(hr
, S_OK
);
4124 hr
= IXMLDOMElement_get_childNodes( element
, &node_list
);
4125 EXPECT_HR(hr
, S_OK
);
4127 hr
= IXMLDOMNodeList_get_length( node_list
, &len
);
4128 EXPECT_HR(hr
, S_OK
);
4129 ok( len
== 4, "len %d\n", len
);
4131 hr
= IXMLDOMNodeList_get_item( node_list
, 2, &node
);
4132 EXPECT_HR(hr
, S_OK
);
4134 hr
= IXMLDOMNode_get_childNodes( node
, &node_list2
);
4135 EXPECT_HR(hr
, S_OK
);
4137 hr
= IXMLDOMNodeList_get_length( node_list2
, &len
);
4138 EXPECT_HR(hr
, S_OK
);
4139 ok( len
== 0, "len %d\n", len
);
4141 hr
= IXMLDOMNodeList_get_item( node_list2
, 0, &node2
);
4142 EXPECT_HR(hr
, S_FALSE
);
4144 IXMLDOMNodeList_Release( node_list2
);
4145 IXMLDOMNode_Release( node
);
4146 IXMLDOMNodeList_Release( node_list
);
4147 IXMLDOMElement_Release( element
);
4149 /* test for children of <?xml ..?> node */
4150 hr
= IXMLDOMDocument_get_firstChild(doc
, &node
);
4151 EXPECT_HR(hr
, S_OK
);
4154 hr
= IXMLDOMNode_get_nodeName(node
, &str
);
4155 EXPECT_HR(hr
, S_OK
);
4156 ok(!lstrcmpW(str
, _bstr_("xml")), "got %s\n", wine_dbgstr_w(str
));
4159 /* it returns empty but valid node list */
4160 node_list
= (void*)0xdeadbeef;
4161 hr
= IXMLDOMNode_get_childNodes(node
, &node_list
);
4162 EXPECT_HR(hr
, S_OK
);
4165 hr
= IXMLDOMNodeList_get_length(node_list
, &len
);
4166 EXPECT_HR(hr
, S_OK
);
4167 ok(len
== 0, "got %d\n", len
);
4169 IXMLDOMNodeList_Release( node_list
);
4170 IXMLDOMNode_Release(node
);
4172 IXMLDOMDocument_Release( doc
);
4176 static void test_get_firstChild(void)
4178 static WCHAR xmlW
[] = {'x','m','l',0};
4179 IXMLDOMDocument
*doc
;
4185 doc
= create_document(&IID_IXMLDOMDocument
);
4188 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4189 ok( r
== S_OK
, "loadXML failed\n");
4190 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4192 r
= IXMLDOMDocument_get_firstChild( doc
, &node
);
4193 ok( r
== S_OK
, "ret %08x\n", r
);
4195 r
= IXMLDOMNode_get_nodeName( node
, &str
);
4196 ok( r
== S_OK
, "ret %08x\n", r
);
4198 ok(!lstrcmpW(str
, xmlW
), "expected \"xml\" node name, got %s\n", wine_dbgstr_w(str
));
4201 IXMLDOMNode_Release( node
);
4202 IXMLDOMDocument_Release( doc
);
4207 static void test_get_lastChild(void)
4209 static WCHAR lcW
[] = {'l','c',0};
4210 static WCHAR foW
[] = {'f','o',0};
4211 IXMLDOMDocument
*doc
;
4212 IXMLDOMNode
*node
, *child
;
4217 doc
= create_document(&IID_IXMLDOMDocument
);
4220 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4221 ok( r
== S_OK
, "loadXML failed\n");
4222 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4224 r
= IXMLDOMDocument_get_lastChild( doc
, &node
);
4225 ok( r
== S_OK
, "ret %08x\n", r
);
4227 r
= IXMLDOMNode_get_nodeName( node
, &str
);
4228 ok( r
== S_OK
, "ret %08x\n", r
);
4230 ok(memcmp(str
, lcW
, sizeof(lcW
)) == 0, "expected \"lc\" node name\n");
4233 r
= IXMLDOMNode_get_lastChild( node
, &child
);
4234 ok( r
== S_OK
, "ret %08x\n", r
);
4236 r
= IXMLDOMNode_get_nodeName( child
, &str
);
4237 ok( r
== S_OK
, "ret %08x\n", r
);
4239 ok(memcmp(str
, foW
, sizeof(foW
)) == 0, "expected \"fo\" node name\n");
4242 IXMLDOMNode_Release( child
);
4243 IXMLDOMNode_Release( node
);
4244 IXMLDOMDocument_Release( doc
);
4249 static void test_removeChild(void)
4253 IXMLDOMDocument
*doc
;
4254 IXMLDOMElement
*element
, *lc_element
;
4255 IXMLDOMNode
*fo_node
, *ba_node
, *removed_node
, *temp_node
, *lc_node
;
4256 IXMLDOMNodeList
*root_list
, *fo_list
;
4258 doc
= create_document(&IID_IXMLDOMDocument
);
4261 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4262 ok( r
== S_OK
, "loadXML failed\n");
4263 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4265 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
4266 ok( r
== S_OK
, "ret %08x\n", r
);
4267 todo_wine
EXPECT_REF(element
, 2);
4269 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
4270 ok( r
== S_OK
, "ret %08x\n", r
);
4271 EXPECT_REF(root_list
, 1);
4273 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
4274 ok( r
== S_OK
, "ret %08x\n", r
);
4275 EXPECT_REF(fo_node
, 1);
4277 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
4278 ok( r
== S_OK
, "ret %08x\n", r
);
4279 EXPECT_REF(fo_list
, 1);
4281 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
4282 ok( r
== S_OK
, "ret %08x\n", r
);
4283 EXPECT_REF(ba_node
, 1);
4285 /* invalid parameter: NULL ptr */
4286 removed_node
= (void*)0xdeadbeef;
4287 r
= IXMLDOMElement_removeChild( element
, NULL
, &removed_node
);
4288 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4289 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
4291 /* ba_node is a descendant of element, but not a direct child. */
4292 removed_node
= (void*)0xdeadbeef;
4293 EXPECT_REF(ba_node
, 1);
4294 EXPECT_CHILDREN(fo_node
);
4295 r
= IXMLDOMElement_removeChild( element
, ba_node
, &removed_node
);
4296 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4297 ok( removed_node
== NULL
, "%p\n", removed_node
);
4298 EXPECT_REF(ba_node
, 1);
4299 EXPECT_CHILDREN(fo_node
);
4301 EXPECT_REF(ba_node
, 1);
4302 EXPECT_REF(fo_node
, 1);
4303 r
= IXMLDOMElement_removeChild( element
, fo_node
, &removed_node
);
4304 ok( r
== S_OK
, "ret %08x\n", r
);
4305 ok( fo_node
== removed_node
, "node %p node2 %p\n", fo_node
, removed_node
);
4306 EXPECT_REF(fo_node
, 2);
4307 EXPECT_REF(ba_node
, 1);
4309 /* try removing already removed child */
4310 temp_node
= (void*)0xdeadbeef;
4311 r
= IXMLDOMElement_removeChild( element
, fo_node
, &temp_node
);
4312 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4313 ok( temp_node
== NULL
, "%p\n", temp_node
);
4314 IXMLDOMNode_Release( fo_node
);
4316 /* the removed node has no parent anymore */
4317 r
= IXMLDOMNode_get_parentNode( removed_node
, &temp_node
);
4318 ok( r
== S_FALSE
, "ret %08x\n", r
);
4319 ok( temp_node
== NULL
, "%p\n", temp_node
);
4321 IXMLDOMNode_Release( removed_node
);
4322 IXMLDOMNode_Release( ba_node
);
4323 IXMLDOMNodeList_Release( fo_list
);
4325 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
4326 ok( r
== S_OK
, "ret %08x\n", r
);
4328 r
= IXMLDOMElement_QueryInterface( lc_node
, &IID_IXMLDOMElement
, (void**)&lc_element
);
4329 ok( r
== S_OK
, "ret %08x\n", r
);
4331 /* MS quirk: passing wrong interface pointer works, too */
4332 r
= IXMLDOMElement_removeChild( element
, (IXMLDOMNode
*)lc_element
, NULL
);
4333 ok( r
== S_OK
, "ret %08x\n", r
);
4334 IXMLDOMElement_Release( lc_element
);
4336 temp_node
= (void*)0xdeadbeef;
4337 r
= IXMLDOMNode_get_parentNode( lc_node
, &temp_node
);
4338 ok( r
== S_FALSE
, "ret %08x\n", r
);
4339 ok( temp_node
== NULL
, "%p\n", temp_node
);
4341 IXMLDOMNode_Release( lc_node
);
4342 IXMLDOMNodeList_Release( root_list
);
4343 IXMLDOMElement_Release( element
);
4344 IXMLDOMDocument_Release( doc
);
4349 static void test_replaceChild(void)
4353 IXMLDOMDocument
*doc
;
4354 IXMLDOMElement
*element
, *ba_element
;
4355 IXMLDOMNode
*fo_node
, *ba_node
, *lc_node
, *removed_node
, *temp_node
;
4356 IXMLDOMNodeList
*root_list
, *fo_list
;
4357 IUnknown
* unk1
, *unk2
;
4360 doc
= create_document(&IID_IXMLDOMDocument
);
4363 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4364 ok( r
== S_OK
, "loadXML failed\n");
4365 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4367 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
4368 ok( r
== S_OK
, "ret %08x\n", r
);
4370 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
4371 ok( r
== S_OK
, "ret %08x\n", r
);
4373 r
= IXMLDOMNodeList_get_item( root_list
, 0, &lc_node
);
4374 ok( r
== S_OK
, "ret %08x\n", r
);
4376 r
= IXMLDOMNodeList_get_item( root_list
, 3, &fo_node
);
4377 ok( r
== S_OK
, "ret %08x\n", r
);
4379 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
4380 ok( r
== S_OK
, "ret %08x\n", r
);
4382 r
= IXMLDOMNodeList_get_item( fo_list
, 0, &ba_node
);
4383 ok( r
== S_OK
, "ret %08x\n", r
);
4385 IXMLDOMNodeList_Release( fo_list
);
4387 /* invalid parameter: NULL ptr for element to remove */
4388 removed_node
= (void*)0xdeadbeef;
4389 r
= IXMLDOMElement_replaceChild( element
, ba_node
, NULL
, &removed_node
);
4390 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4391 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
4393 /* invalid parameter: NULL for replacement element. (Sic!) */
4394 removed_node
= (void*)0xdeadbeef;
4395 r
= IXMLDOMElement_replaceChild( element
, NULL
, fo_node
, &removed_node
);
4396 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4397 ok( removed_node
== (void*)0xdeadbeef, "%p\n", removed_node
);
4399 /* invalid parameter: OldNode is not a child */
4400 removed_node
= (void*)0xdeadbeef;
4401 r
= IXMLDOMElement_replaceChild( element
, lc_node
, ba_node
, &removed_node
);
4402 ok( r
== E_INVALIDARG
, "ret %08x\n", r
);
4403 ok( removed_node
== NULL
, "%p\n", removed_node
);
4404 IXMLDOMNode_Release( lc_node
);
4406 /* invalid parameter: would create loop */
4407 removed_node
= (void*)0xdeadbeef;
4408 r
= IXMLDOMNode_replaceChild( fo_node
, fo_node
, ba_node
, &removed_node
);
4409 ok( r
== E_FAIL
, "ret %08x\n", r
);
4410 ok( removed_node
== NULL
, "%p\n", removed_node
);
4412 r
= IXMLDOMElement_replaceChild( element
, ba_node
, fo_node
, NULL
);
4413 ok( r
== S_OK
, "ret %08x\n", r
);
4415 r
= IXMLDOMNodeList_get_item( root_list
, 3, &temp_node
);
4416 ok( r
== S_OK
, "ret %08x\n", r
);
4418 /* ba_node and temp_node refer to the same node, yet they
4419 are different interface pointers */
4420 ok( ba_node
!= temp_node
, "ba_node %p temp_node %p\n", ba_node
, temp_node
);
4421 r
= IXMLDOMNode_QueryInterface( temp_node
, &IID_IUnknown
, (void**)&unk1
);
4422 ok( r
== S_OK
, "ret %08x\n", r
);
4423 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IUnknown
, (void**)&unk2
);
4424 ok( r
== S_OK
, "ret %08x\n", r
);
4425 todo_wine
ok( unk1
== unk2
, "unk1 %p unk2 %p\n", unk1
, unk2
);
4427 IUnknown_Release( unk1
);
4428 IUnknown_Release( unk2
);
4430 /* ba_node should have been removed from below fo_node */
4431 r
= IXMLDOMNode_get_childNodes( fo_node
, &fo_list
);
4432 ok( r
== S_OK
, "ret %08x\n", r
);
4434 /* MS quirk: replaceChild also accepts elements instead of nodes */
4435 r
= IXMLDOMNode_QueryInterface( ba_node
, &IID_IXMLDOMElement
, (void**)&ba_element
);
4436 ok( r
== S_OK
, "ret %08x\n", r
);
4437 EXPECT_REF(ba_element
, 2);
4439 removed_node
= NULL
;
4440 r
= IXMLDOMElement_replaceChild( element
, ba_node
, (IXMLDOMNode
*)ba_element
, &removed_node
);
4441 ok( r
== S_OK
, "ret %08x\n", r
);
4442 ok( removed_node
!= NULL
, "got %p\n", removed_node
);
4443 EXPECT_REF(ba_element
, 3);
4444 IXMLDOMElement_Release( ba_element
);
4446 r
= IXMLDOMNodeList_get_length( fo_list
, &len
);
4447 ok( r
== S_OK
, "ret %08x\n", r
);
4448 ok( len
== 0, "len %d\n", len
);
4450 IXMLDOMNodeList_Release( fo_list
);
4452 IXMLDOMNode_Release(ba_node
);
4453 IXMLDOMNode_Release(fo_node
);
4454 IXMLDOMNode_Release(temp_node
);
4455 IXMLDOMNodeList_Release( root_list
);
4456 IXMLDOMElement_Release( element
);
4457 IXMLDOMDocument_Release( doc
);
4462 static void test_removeNamedItem(void)
4464 IXMLDOMDocument
*doc
;
4465 IXMLDOMElement
*element
;
4466 IXMLDOMNode
*pr_node
, *removed_node
, *removed_node2
;
4467 IXMLDOMNodeList
*root_list
;
4468 IXMLDOMNamedNodeMap
* pr_attrs
;
4474 doc
= create_document(&IID_IXMLDOMDocument
);
4477 r
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
4478 ok( r
== S_OK
, "loadXML failed\n");
4479 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
4481 r
= IXMLDOMDocument_get_documentElement( doc
, &element
);
4482 ok( r
== S_OK
, "ret %08x\n", r
);
4484 r
= IXMLDOMElement_get_childNodes( element
, &root_list
);
4485 ok( r
== S_OK
, "ret %08x\n", r
);
4487 r
= IXMLDOMNodeList_get_item( root_list
, 1, &pr_node
);
4488 ok( r
== S_OK
, "ret %08x\n", r
);
4490 r
= IXMLDOMNode_get_attributes( pr_node
, &pr_attrs
);
4491 ok( r
== S_OK
, "ret %08x\n", r
);
4493 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
4494 ok( r
== S_OK
, "ret %08x\n", r
);
4495 ok( len
== 3, "length %d\n", len
);
4497 removed_node
= (void*)0xdeadbeef;
4498 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, NULL
, &removed_node
);
4499 ok ( r
== E_INVALIDARG
, "ret %08x\n", r
);
4500 ok ( removed_node
== (void*)0xdeadbeef, "got %p\n", removed_node
);
4502 removed_node
= (void*)0xdeadbeef;
4503 str
= SysAllocString(szvr
);
4504 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node
);
4505 ok ( r
== S_OK
, "ret %08x\n", r
);
4507 removed_node2
= (void*)0xdeadbeef;
4508 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, &removed_node2
);
4509 ok ( r
== S_FALSE
, "ret %08x\n", r
);
4510 ok ( removed_node2
== NULL
, "got %p\n", removed_node2
);
4512 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
4513 ok( r
== S_OK
, "ret %08x\n", r
);
4514 ok( len
== 2, "length %d\n", len
);
4516 r
= IXMLDOMNamedNodeMap_setNamedItem( pr_attrs
, removed_node
, NULL
);
4517 ok ( r
== S_OK
, "ret %08x\n", r
);
4518 IXMLDOMNode_Release(removed_node
);
4520 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
4521 ok( r
== S_OK
, "ret %08x\n", r
);
4522 ok( len
== 3, "length %d\n", len
);
4524 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
4525 ok ( r
== S_OK
, "ret %08x\n", r
);
4527 r
= IXMLDOMNamedNodeMap_get_length( pr_attrs
, &len
);
4528 ok( r
== S_OK
, "ret %08x\n", r
);
4529 ok( len
== 2, "length %d\n", len
);
4531 r
= IXMLDOMNamedNodeMap_removeNamedItem( pr_attrs
, str
, NULL
);
4532 ok ( r
== S_FALSE
, "ret %08x\n", r
);
4536 IXMLDOMNamedNodeMap_Release( pr_attrs
);
4537 IXMLDOMNode_Release( pr_node
);
4538 IXMLDOMNodeList_Release( root_list
);
4539 IXMLDOMElement_Release( element
);
4540 IXMLDOMDocument_Release( doc
);
4545 #define test_IObjectSafety_set(p, r, r2, s, m, e, e2) _test_IObjectSafety_set(__LINE__,p, r, r2, s, m, e, e2)
4546 static void _test_IObjectSafety_set(unsigned line
, IObjectSafety
*safety
, HRESULT result
,
4547 HRESULT result2
, DWORD set
, DWORD mask
, DWORD expected
,
4550 DWORD enabled
, supported
;
4553 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
, set
, mask
);
4554 if (result
== result2
)
4555 ok_(__FILE__
,line
)(hr
== result
, "SetInterfaceSafetyOptions: expected %08x, returned %08x\n", result
, hr
);
4557 ok_(__FILE__
,line
)(broken(hr
== result
) || hr
== result2
,
4558 "SetInterfaceSafetyOptions: expected %08x, got %08x\n", result2
, hr
);
4560 supported
= enabled
= 0xCAFECAFE;
4561 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
4562 ok(hr
== S_OK
, "ret %08x\n", hr
);
4563 if (expected
== expected2
)
4564 ok_(__FILE__
,line
)(enabled
== expected
, "Expected %08x, got %08x\n", expected
, enabled
);
4566 ok_(__FILE__
,line
)(broken(enabled
== expected
) || enabled
== expected2
,
4567 "Expected %08x, got %08x\n", expected2
, enabled
);
4569 /* reset the safety options */
4571 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
4572 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
|INTERFACE_USES_SECURITY_MANAGER
,
4574 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4576 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
4577 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4578 ok_(__FILE__
,line
)(enabled
== 0, "Expected 0, got %08x\n", enabled
);
4581 #define test_IObjectSafety_common(s) _test_IObjectSafety_common(__LINE__,s)
4582 static void _test_IObjectSafety_common(unsigned line
, IObjectSafety
*safety
)
4584 DWORD enabled
= 0, supported
= 0;
4588 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, NULL
, &enabled
);
4589 ok_(__FILE__
,line
)(hr
== E_POINTER
, "ret %08x\n", hr
);
4590 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, NULL
);
4591 ok_(__FILE__
,line
)(hr
== E_POINTER
, "ret %08x\n", hr
);
4593 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
4594 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4595 ok_(__FILE__
,line
)(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
4596 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
4597 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
4598 "got %08x\n", supported
);
4599 ok_(__FILE__
,line
)(enabled
== 0, "Expected 0, got %08x\n", enabled
);
4601 /* set -- individual flags */
4603 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
4604 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
4605 INTERFACESAFE_FOR_UNTRUSTED_CALLER
, INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
4607 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
4608 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4609 INTERFACESAFE_FOR_UNTRUSTED_DATA
, INTERFACESAFE_FOR_UNTRUSTED_DATA
);
4611 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
4612 INTERFACE_USES_SECURITY_MANAGER
, INTERFACE_USES_SECURITY_MANAGER
,
4613 0, INTERFACE_USES_SECURITY_MANAGER
/* msxml3 SP8+ */);
4615 /* set INTERFACE_USES_DISPEX */
4617 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
4618 INTERFACE_USES_DISPEX
, INTERFACE_USES_DISPEX
,
4621 test_IObjectSafety_set(safety
, S_OK
, E_FAIL
/* msxml3 SP8+ */,
4622 INTERFACE_USES_DISPEX
, 0,
4625 test_IObjectSafety_set(safety
, S_OK
, S_OK
/* msxml3 SP8+ */,
4626 0, INTERFACE_USES_DISPEX
,
4629 /* set option masking */
4631 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
4632 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4633 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
4634 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
4635 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
4637 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
4638 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4639 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4640 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4641 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
4643 test_IObjectSafety_set(safety
, S_OK
, S_OK
,
4644 INTERFACESAFE_FOR_UNTRUSTED_CALLER
|INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4645 INTERFACE_USES_SECURITY_MANAGER
,
4649 /* set -- inheriting previous settings */
4651 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
4652 INTERFACESAFE_FOR_UNTRUSTED_CALLER
,
4653 INTERFACESAFE_FOR_UNTRUSTED_CALLER
);
4654 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4655 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
4656 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4657 ok_(__FILE__
,line
)(enabled
== INTERFACESAFE_FOR_UNTRUSTED_CALLER
, "Expected INTERFACESAFE_FOR_UNTRUSTED_CALLER got %08x\n", enabled
);
4658 ok_(__FILE__
,line
)(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
4659 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
4660 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
4661 "got %08x\n", supported
);
4663 hr
= IObjectSafety_SetInterfaceSafetyOptions(safety
, NULL
,
4664 INTERFACESAFE_FOR_UNTRUSTED_DATA
,
4665 INTERFACESAFE_FOR_UNTRUSTED_DATA
);
4666 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4667 hr
= IObjectSafety_GetInterfaceSafetyOptions(safety
, NULL
, &supported
, &enabled
);
4668 ok_(__FILE__
,line
)(hr
== S_OK
, "ret %08x\n", hr
);
4669 ok_(__FILE__
,line
)(broken(enabled
== INTERFACESAFE_FOR_UNTRUSTED_DATA
) ||
4670 enabled
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
),
4671 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA) got %08x\n", enabled
);
4672 ok_(__FILE__
,line
)(broken(supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
)) ||
4673 supported
== (INTERFACESAFE_FOR_UNTRUSTED_CALLER
| INTERFACESAFE_FOR_UNTRUSTED_DATA
| INTERFACE_USES_SECURITY_MANAGER
) /* msxml3 SP8+ */,
4674 "Expected (INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACE_USES_SECURITY_MANAGER), "
4675 "got %08x\n", supported
);
4678 static void test_XMLHTTP(void)
4680 static const char bodyA
[] = "mode=Test";
4681 static const char urlA
[] = "http://crossover.codeweavers.com/posttest.php";
4682 static const char xmltestA
[] = "http://crossover.codeweavers.com/xmltest.xml";
4683 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
4684 static const CHAR xmltestbodyA
[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
4686 IXMLHttpRequest
*xhr
;
4687 IObjectSafety
*safety
;
4688 IObjectWithSite
*obj_site
, *obj_site2
;
4689 BSTR bstrResponse
, str
, str1
;
4690 VARIANT varbody
, varbody_ref
;
4693 LONG state
, status
, bound
;
4699 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
4700 &IID_IXMLHttpRequest
, (void**)&xhr
);
4703 win_skip("IXMLHTTPRequest is not available (0x%08x)\n", hr
);
4707 VariantInit(&dummy
);
4708 V_VT(&dummy
) = VT_ERROR
;
4709 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
4710 VariantInit(&async
);
4711 V_VT(&async
) = VT_BOOL
;
4712 V_BOOL(&async
) = VARIANT_FALSE
;
4714 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, NULL
);
4715 EXPECT_HR(hr
, S_OK
);
4717 hr
= IXMLHttpRequest_abort(xhr
);
4718 EXPECT_HR(hr
, S_OK
);
4720 V_VT(&varbody
) = VT_I2
;
4722 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
4723 EXPECT_HR(hr
, E_PENDING
);
4724 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
4725 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
4727 V_VT(&varbody
) = VT_I2
;
4729 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
4730 EXPECT_HR(hr
, E_PENDING
);
4731 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
4732 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
4734 /* send before open */
4735 hr
= IXMLHttpRequest_send(xhr
, dummy
);
4736 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
4738 /* initial status code */
4739 hr
= IXMLHttpRequest_get_status(xhr
, NULL
);
4740 EXPECT_HR(hr
, E_INVALIDARG
);
4742 status
= 0xdeadbeef;
4743 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
4744 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
4745 ok(status
== 0xdeadbeef, "got %d\n", status
);
4747 /* invalid parameters */
4748 hr
= IXMLHttpRequest_open(xhr
, NULL
, NULL
, async
, dummy
, dummy
);
4749 EXPECT_HR(hr
, E_INVALIDARG
);
4751 hr
= IXMLHttpRequest_open(xhr
, _bstr_("POST"), NULL
, async
, dummy
, dummy
);
4752 EXPECT_HR(hr
, E_INVALIDARG
);
4754 hr
= IXMLHttpRequest_open(xhr
, NULL
, _bstr_(urlA
), async
, dummy
, dummy
);
4755 EXPECT_HR(hr
, E_INVALIDARG
);
4757 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, NULL
);
4758 EXPECT_HR(hr
, E_INVALIDARG
);
4760 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), NULL
);
4761 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
4763 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
4764 EXPECT_HR(hr
, E_INVALIDARG
);
4766 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
4767 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
4769 hr
= IXMLHttpRequest_get_readyState(xhr
, NULL
);
4770 EXPECT_HR(hr
, E_INVALIDARG
);
4773 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
4774 EXPECT_HR(hr
, S_OK
);
4775 ok(state
== READYSTATE_UNINITIALIZED
, "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
4777 event
= create_dispevent();
4779 EXPECT_REF(event
, 1);
4780 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, event
);
4781 EXPECT_HR(hr
, S_OK
);
4782 EXPECT_REF(event
, 2);
4784 g_unexpectedcall
= g_expectedcall
= 0;
4786 hr
= IXMLHttpRequest_open(xhr
, _bstr_("POST"), _bstr_(urlA
), async
, dummy
, dummy
);
4787 EXPECT_HR(hr
, S_OK
);
4789 ok(g_unexpectedcall
== 0, "unexpected disp event call\n");
4790 ok(g_expectedcall
== 1 || broken(g_expectedcall
== 0) /* win2k */, "no expected disp event call\n");
4792 /* status code after ::open() */
4793 status
= 0xdeadbeef;
4794 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
4795 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
4796 ok(status
== 0xdeadbeef, "got %d\n", status
);
4799 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
4800 EXPECT_HR(hr
, S_OK
);
4801 ok(state
== READYSTATE_LOADING
, "got %d, expected READYSTATE_LOADING\n", state
);
4803 hr
= IXMLHttpRequest_abort(xhr
);
4804 EXPECT_HR(hr
, S_OK
);
4807 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
4808 EXPECT_HR(hr
, S_OK
);
4809 ok(state
== READYSTATE_UNINITIALIZED
|| broken(state
== READYSTATE_LOADING
) /* win2k */,
4810 "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
4812 hr
= IXMLHttpRequest_open(xhr
, _bstr_("POST"), _bstr_(urlA
), async
, dummy
, dummy
);
4813 EXPECT_HR(hr
, S_OK
);
4815 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
4816 EXPECT_HR(hr
, S_OK
);
4818 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
4819 EXPECT_HR(hr
, E_INVALIDARG
);
4821 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_(""), _bstr_("value1"));
4822 EXPECT_HR(hr
, E_INVALIDARG
);
4824 V_VT(&varbody
) = VT_BSTR
;
4825 V_BSTR(&varbody
) = _bstr_(bodyA
);
4827 hr
= IXMLHttpRequest_send(xhr
, varbody
);
4828 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
4830 skip("No connection could be made with crossover.codeweavers.com\n");
4831 IXMLHttpRequest_Release(xhr
);
4834 EXPECT_HR(hr
, S_OK
);
4836 /* response headers */
4837 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, NULL
);
4838 EXPECT_HR(hr
, E_INVALIDARG
);
4839 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str
);
4840 EXPECT_HR(hr
, S_OK
);
4841 /* status line is stripped already */
4842 ok(memcmp(str
, _bstr_("HTTP"), 4*sizeof(WCHAR
)), "got response headers %s\n", wine_dbgstr_w(str
));
4843 ok(*str
, "got empty headers\n");
4844 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str1
);
4845 EXPECT_HR(hr
, S_OK
);
4846 ok(str1
!= str
, "got %p\n", str1
);
4847 SysFreeString(str1
);
4850 hr
= IXMLHttpRequest_getResponseHeader(xhr
, NULL
, NULL
);
4851 EXPECT_HR(hr
, E_INVALIDARG
);
4852 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), NULL
);
4853 EXPECT_HR(hr
, E_INVALIDARG
);
4854 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), &str
);
4855 EXPECT_HR(hr
, S_OK
);
4856 ok(*str
!= ' ', "got leading space in header %s\n", wine_dbgstr_w(str
));
4859 /* status code after ::send() */
4860 status
= 0xdeadbeef;
4861 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
4862 EXPECT_HR(hr
, S_OK
);
4863 ok(status
== 200, "got %d\n", status
);
4865 /* another ::send() after completed request */
4866 V_VT(&varbody
) = VT_BSTR
;
4867 V_BSTR(&varbody
) = _bstr_(bodyA
);
4869 hr
= IXMLHttpRequest_send(xhr
, varbody
);
4870 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
4872 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
4873 EXPECT_HR(hr
, S_OK
);
4874 /* the server currently returns "FAILED" because the Content-Type header is
4875 * not what the server expects */
4878 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)),
4879 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse
), wine_dbgstr_w(bstrResponse
));
4880 SysFreeString(bstrResponse
);
4883 /* POST: VT_VARIANT|VT_BYREF body */
4884 V_VT(&varbody_ref
) = VT_VARIANT
|VT_BYREF
;
4885 V_VARIANTREF(&varbody_ref
) = &varbody
;
4886 hr
= IXMLHttpRequest_open(xhr
, _bstr_("POST"), _bstr_(urlA
), async
, dummy
, dummy
);
4887 EXPECT_HR(hr
, S_OK
);
4888 hr
= IXMLHttpRequest_send(xhr
, varbody_ref
);
4889 EXPECT_HR(hr
, S_OK
);
4892 hr
= IXMLHttpRequest_open(xhr
, _bstr_("GET"), _bstr_(xmltestA
), async
, dummy
, dummy
);
4893 EXPECT_HR(hr
, S_OK
);
4895 V_VT(&varbody
) = VT_EMPTY
;
4897 hr
= IXMLHttpRequest_send(xhr
, varbody
);
4898 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
4900 skip("No connection could be made with crossover.codeweavers.com\n");
4901 IXMLHttpRequest_Release(xhr
);
4904 EXPECT_HR(hr
, S_OK
);
4906 hr
= IXMLHttpRequest_get_responseText(xhr
, NULL
);
4907 EXPECT_HR(hr
, E_INVALIDARG
);
4909 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
4910 EXPECT_HR(hr
, S_OK
);
4911 ok(!memcmp(bstrResponse
, _bstr_(xmltestbodyA
), sizeof(xmltestbodyA
)*sizeof(WCHAR
)),
4912 "expected %s, got %s\n", xmltestbodyA
, wine_dbgstr_w(bstrResponse
));
4913 SysFreeString(bstrResponse
);
4915 hr
= IXMLHttpRequest_get_responseBody(xhr
, NULL
);
4916 EXPECT_HR(hr
, E_INVALIDARG
);
4918 V_VT(&varbody
) = VT_EMPTY
;
4919 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
4920 EXPECT_HR(hr
, S_OK
);
4921 ok(V_VT(&varbody
) == (VT_ARRAY
|VT_UI1
), "got type %d, expected %d\n", V_VT(&varbody
), VT_ARRAY
|VT_UI1
);
4922 ok(SafeArrayGetDim(V_ARRAY(&varbody
)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody
)));
4925 hr
= SafeArrayGetLBound(V_ARRAY(&varbody
), 1, &bound
);
4926 EXPECT_HR(hr
, S_OK
);
4927 ok(bound
== 0, "got %d, expected zero bound\n", bound
);
4929 hr
= SafeArrayAccessData(V_ARRAY(&varbody
), &ptr
);
4930 EXPECT_HR(hr
, S_OK
);
4931 ok(memcmp(ptr
, xmltestbodyA
, sizeof(xmltestbodyA
)-1) == 0, "got wrong body data\n");
4932 SafeArrayUnaccessData(V_ARRAY(&varbody
));
4934 VariantClear(&varbody
);
4936 /* get_responseStream */
4937 hr
= IXMLHttpRequest_get_responseStream(xhr
, NULL
);
4938 EXPECT_HR(hr
, E_INVALIDARG
);
4940 V_VT(&varbody
) = VT_EMPTY
;
4941 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
4942 ok(V_VT(&varbody
) == VT_UNKNOWN
, "got type %d\n", V_VT(&varbody
));
4943 EXPECT_HR(hr
, S_OK
);
4944 EXPECT_REF(V_UNKNOWN(&varbody
), 1);
4947 hr
= GetHGlobalFromStream((IStream
*)V_UNKNOWN(&varbody
), &g
);
4948 EXPECT_HR(hr
, S_OK
);
4949 ok(g
!= NULL
, "got %p\n", g
);
4951 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectSafety
, (void**)&safety
);
4952 EXPECT_HR(hr
, S_OK
);
4955 test_IObjectSafety_common(safety
);
4956 IObjectSafety_Release(safety
);
4959 IDispatch_Release(event
);
4961 /* interaction with object site */
4963 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
4964 EXPECT_HR(hr
, S_OK
);
4967 EXPECT_REF(obj_site
, 1);
4970 IObjectWithSite_AddRef(obj_site
);
4972 EXPECT_REF(obj_site
, 2);
4975 IObjectWithSite_Release(obj_site
);
4977 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site2
);
4978 EXPECT_HR(hr
, S_OK
);
4981 EXPECT_REF(obj_site
, 1);
4982 EXPECT_REF(obj_site2
, 1);
4983 ok(obj_site
!= obj_site2
, "expected new instance\n");
4985 SET_EXPECT(site_qi_IServiceProvider
);
4986 SET_EXPECT(sp_queryservice_SID_SBindHost
);
4987 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
4988 SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
4989 SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
4990 SET_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
4992 /* calls to IHTMLDocument2 */
4993 SET_EXPECT(htmldoc2_get_all
);
4994 SET_EXPECT(collection_get_length
);
4995 SET_EXPECT(htmldoc2_get_url
);
4997 SET_EXPECT(site_qi_IXMLDOMDocument
);
4998 SET_EXPECT(site_qi_IOleClientSite
);
5000 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
.IUnknown_iface
);
5001 EXPECT_HR(hr
, S_OK
);
5004 CHECK_CALLED(site_qi_IServiceProvider
);
5006 CHECK_CALLED(sp_queryservice_SID_SBindHost
);
5007 CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
5008 CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2
);
5009 CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc
);
5010 /* this one isn't very reliable
5011 CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
5013 CHECK_CALLED(htmldoc2_get_all
);
5014 CHECK_CALLED(collection_get_length
);
5015 CHECK_CALLED(htmldoc2_get_url
);
5017 CHECK_CALLED(site_qi_IXMLDOMDocument
);
5018 CHECK_CALLED(site_qi_IOleClientSite
);
5020 IObjectWithSite_Release(obj_site
);
5022 todo_wine
EXPECT_REF(xhr
, 1);
5023 IXMLHttpRequest_Release(xhr
);
5025 /* still works after request is released */
5026 SET_EXPECT(site_qi_IServiceProvider
);
5028 hr
= IObjectWithSite_SetSite(obj_site2
, &testsite
.IUnknown_iface
);
5029 EXPECT_HR(hr
, S_OK
);
5030 IObjectWithSite_Release(obj_site2
);
5035 static void test_IXMLDOMDocument2(void)
5037 static const WCHAR emptyW
[] = {0};
5038 IXMLDOMDocument2
*doc2
, *dtddoc2
;
5039 IXMLDOMDocument
*doc
;
5040 IXMLDOMParseError
* err
;
5041 IDispatchEx
*dispex
;
5047 doc
= create_document(&IID_IXMLDOMDocument
);
5050 dtddoc2
= create_document(&IID_IXMLDOMDocument2
);
5053 IXMLDOMDocument_Release(doc
);
5057 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IXMLDOMDocument2
, (void**)&doc2
);
5058 ok( r
== S_OK
, "ret %08x\n", r
);
5059 ok( doc
== (IXMLDOMDocument
*)doc2
, "interfaces differ\n");
5061 ole_expect(IXMLDOMDocument2_get_readyState(doc2
, NULL
), E_INVALIDARG
);
5062 ole_check(IXMLDOMDocument2_get_readyState(doc2
, &res
));
5063 ok(res
== READYSTATE_COMPLETE
, "expected READYSTATE_COMPLETE (4), got %i\n", res
);
5066 ole_expect(IXMLDOMDocument2_validate(doc2
, NULL
), S_FALSE
);
5067 ole_expect(IXMLDOMDocument2_validate(doc2
, &err
), S_FALSE
);
5068 ok(err
!= NULL
, "expected a pointer\n");
5072 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5074 ok(res
== E_XML_NOTWF
, "got %08x\n", res
);
5075 IXMLDOMParseError_Release(err
);
5078 r
= IXMLDOMDocument_loadXML( doc2
, _bstr_(complete4A
), &b
);
5079 ok( r
== S_OK
, "loadXML failed\n");
5080 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5082 ole_check(IXMLDOMDocument2_get_readyState(doc
, &res
));
5083 ok(res
== READYSTATE_COMPLETE
, "expected READYSTATE_COMPLETE (4), got %i\n", res
);
5086 ole_expect(IXMLDOMDocument2_validate(doc2
, &err
), S_FALSE
);
5087 ok(err
!= NULL
, "expected a pointer\n");
5091 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5093 ok(res
== E_XML_NODTD
, "got %08x\n", res
);
5094 IXMLDOMParseError_Release(err
);
5097 r
= IXMLDOMDocument_QueryInterface( doc
, &IID_IDispatchEx
, (void**)&dispex
);
5098 ok( r
== S_OK
, "ret %08x\n", r
);
5101 IDispatchEx_Release(dispex
);
5104 /* we will check if the variant got cleared */
5105 IXMLDOMDocument2_AddRef(doc2
);
5106 EXPECT_REF(doc2
, 3); /* doc, doc2, AddRef*/
5108 V_VT(&var
) = VT_UNKNOWN
;
5109 V_UNKNOWN(&var
) = (IUnknown
*)doc2
;
5112 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("askldhfaklsdf"), &var
), E_FAIL
);
5113 expect_eq(V_VT(&var
), VT_UNKNOWN
, int, "%x");
5114 ole_expect(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), NULL
), E_INVALIDARG
);
5117 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
5118 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
5119 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
5122 /* the variant didn't get cleared*/
5123 expect_eq(IXMLDOMDocument2_Release(doc2
), 2, int, "%d");
5125 /* setProperty tests */
5126 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("askldhfaklsdf"), var
), E_FAIL
);
5127 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), var
), E_FAIL
);
5128 ole_expect(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("alskjdh faklsjd hfk")), E_FAIL
);
5129 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
5130 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
5131 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
5133 V_VT(&var
) = VT_BSTR
;
5134 V_BSTR(&var
) = SysAllocString(emptyW
);
5135 r
= IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionNamespaces"), var
);
5136 ok(r
== S_OK
, "got 0x%08x\n", r
);
5141 r
= IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionNamespaces"), var
);
5142 ok(r
== E_FAIL
, "got 0x%08x\n", r
);
5144 /* contrary to what MSDN claims you can switch back from XPath to XSLPattern */
5145 ole_check(IXMLDOMDocument2_getProperty(doc2
, _bstr_("SelectionLanguage"), &var
));
5146 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
5147 expect_bstr_eq_and_free(V_BSTR(&var
), "XSLPattern");
5149 IXMLDOMDocument2_Release( doc2
);
5150 IXMLDOMDocument_Release( doc
);
5152 /* DTD validation */
5153 ole_check(IXMLDOMDocument2_put_validateOnParse(dtddoc2
, VARIANT_FALSE
));
5154 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML
), &b
));
5155 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5157 ole_check(IXMLDOMDocument2_validate(dtddoc2
, &err
));
5158 ok(err
!= NULL
, "expected pointer\n");
5162 ole_expect(IXMLDOMParseError_get_errorCode(err
, &res
), S_FALSE
);
5163 ok(res
== 0, "got %08x\n", res
);
5164 IXMLDOMParseError_Release(err
);
5167 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_0D
), &b
));
5168 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5170 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5171 ok(err
!= NULL
, "expected pointer\n");
5175 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5176 /* XML_ELEMENT_UNDECLARED */
5177 todo_wine
ok(res
== 0xC00CE00D, "got %08x\n", res
);
5178 IXMLDOMParseError_Release(err
);
5181 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_0E
), &b
));
5182 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5184 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5185 ok(err
!= NULL
, "expected pointer\n");
5189 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5190 /* XML_ELEMENT_ID_NOT_FOUND */
5191 todo_wine
ok(res
== 0xC00CE00E, "got %08x\n", res
);
5192 IXMLDOMParseError_Release(err
);
5195 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_11
), &b
));
5196 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5198 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5199 ok(err
!= NULL
, "expected pointer\n");
5203 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5204 /* XML_EMPTY_NOT_ALLOWED */
5205 todo_wine
ok(res
== 0xC00CE011, "got %08x\n", res
);
5206 IXMLDOMParseError_Release(err
);
5209 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_13
), &b
));
5210 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5212 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5213 ok(err
!= NULL
, "expected pointer\n");
5217 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5218 /* XML_ROOT_NAME_MISMATCH */
5219 todo_wine
ok(res
== 0xC00CE013, "got %08x\n", res
);
5220 IXMLDOMParseError_Release(err
);
5223 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_14
), &b
));
5224 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5226 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5227 ok(err
!= NULL
, "expected pointer\n");
5231 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5232 /* XML_INVALID_CONTENT */
5233 todo_wine
ok(res
== 0xC00CE014, "got %08x\n", res
);
5234 IXMLDOMParseError_Release(err
);
5237 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_15
), &b
));
5238 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5240 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5241 ok(err
!= NULL
, "expected pointer\n");
5245 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5246 /* XML_ATTRIBUTE_NOT_DEFINED */
5247 todo_wine
ok(res
== 0xC00CE015, "got %08x\n", res
);
5248 IXMLDOMParseError_Release(err
);
5251 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_16
), &b
));
5252 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5254 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5255 ok(err
!= NULL
, "expected pointer\n");
5259 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5260 /* XML_ATTRIBUTE_FIXED */
5261 todo_wine
ok(res
== 0xC00CE016, "got %08x\n", res
);
5262 IXMLDOMParseError_Release(err
);
5265 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_17
), &b
));
5266 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5268 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5269 ok(err
!= NULL
, "expected pointer\n");
5273 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5274 /* XML_ATTRIBUTE_VALUE */
5275 todo_wine
ok(res
== 0xC00CE017, "got %08x\n", res
);
5276 IXMLDOMParseError_Release(err
);
5279 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_18
), &b
));
5280 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5282 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5283 ok(err
!= NULL
, "expected pointer\n");
5287 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5288 /* XML_ILLEGAL_TEXT */
5289 todo_wine
ok(res
== 0xC00CE018, "got %08x\n", res
);
5290 IXMLDOMParseError_Release(err
);
5293 ole_check(IXMLDOMDocument2_loadXML(dtddoc2
, _bstr_(szEmailXML_20
), &b
));
5294 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
5296 ole_expect(IXMLDOMDocument2_validate(dtddoc2
, &err
), S_FALSE
);
5297 ok(err
!= NULL
, "expected pointer\n");
5301 ole_check(IXMLDOMParseError_get_errorCode(err
, &res
));
5302 /* XML_REQUIRED_ATTRIBUTE_MISSING */
5303 todo_wine
ok(res
== 0xC00CE020, "got %08x\n", res
);
5304 IXMLDOMParseError_Release(err
);
5307 IXMLDOMDocument2_Release( dtddoc2
);
5311 #define helper_ole_check(expr) { \
5313 ok_(__FILE__, line)(r == S_OK, "=> %i: " #expr " returned %08x\n", __LINE__, r); \
5316 #define helper_expect_list_and_release(list, expstr) { \
5317 char *str = list_to_string(list); \
5318 ok_(__FILE__, line)(strcmp(str, expstr)==0, "=> %i: Invalid node list: %s, expected %s\n", __LINE__, str, expstr); \
5319 if (list) IXMLDOMNodeList_Release(list); \
5322 #define helper_expect_bstr_and_release(bstr, str) { \
5323 ok_(__FILE__, line)(lstrcmpW(bstr, _bstr_(str)) == 0, \
5324 "=> %i: got %s\n", __LINE__, wine_dbgstr_w(bstr)); \
5325 SysFreeString(bstr); \
5328 #define check_ws_ignored(doc, str) _check_ws_ignored(__LINE__, doc, str)
5329 static inline void _check_ws_ignored(int line
, IXMLDOMDocument2
* doc
, char const* str
)
5331 IXMLDOMNode
*node1
, *node2
;
5332 IXMLDOMNodeList
*list
;
5335 helper_ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//*[local-name()='html']"), &list
));
5336 helper_ole_check(IXMLDOMNodeList_get_item(list
, 0, &node1
));
5337 helper_ole_check(IXMLDOMNodeList_get_item(list
, 1, &node2
));
5338 helper_ole_check(IXMLDOMNodeList_reset(list
));
5339 helper_expect_list_and_release(list
, "E1.E4.E1.E2.D1 E2.E4.E1.E2.D1");
5341 helper_ole_check(IXMLDOMNode_get_childNodes(node1
, &list
));
5342 helper_expect_list_and_release(list
, "T1.E1.E4.E1.E2.D1 E2.E1.E4.E1.E2.D1 E3.E1.E4.E1.E2.D1 T4.E1.E4.E1.E2.D1 E5.E1.E4.E1.E2.D1");
5343 helper_ole_check(IXMLDOMNode_get_text(node1
, &bstr
));
5346 helper_expect_bstr_and_release(bstr
, str
);
5350 helper_expect_bstr_and_release(bstr
, "This is a description.");
5352 IXMLDOMNode_Release(node1
);
5354 helper_ole_check(IXMLDOMNode_get_childNodes(node2
, &list
));
5355 helper_expect_list_and_release(list
, "T1.E2.E4.E1.E2.D1 E2.E2.E4.E1.E2.D1 T3.E2.E4.E1.E2.D1 E4.E2.E4.E1.E2.D1 T5.E2.E4.E1.E2.D1 E6.E2.E4.E1.E2.D1 T7.E2.E4.E1.E2.D1");
5356 helper_ole_check(IXMLDOMNode_get_text(node2
, &bstr
));
5357 helper_expect_bstr_and_release(bstr
, "\n This is a description with preserved whitespace. \n ");
5358 IXMLDOMNode_Release(node2
);
5361 #define check_ws_preserved(doc, str) _check_ws_preserved(__LINE__, doc, str)
5362 static inline void _check_ws_preserved(int line
, IXMLDOMDocument2
* doc
, char const* str
)
5364 IXMLDOMNode
*node1
, *node2
;
5365 IXMLDOMNodeList
*list
;
5368 helper_ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//*[local-name()='html']"), &list
));
5369 helper_ole_check(IXMLDOMNodeList_get_item(list
, 0, &node1
));
5370 helper_ole_check(IXMLDOMNodeList_get_item(list
, 1, &node2
));
5371 helper_ole_check(IXMLDOMNodeList_reset(list
));
5372 helper_expect_list_and_release(list
, "E2.E8.E2.E2.D1 E4.E8.E2.E2.D1");
5374 helper_ole_check(IXMLDOMNode_get_childNodes(node1
, &list
));
5375 helper_expect_list_and_release(list
, "T1.E2.E8.E2.E2.D1 E2.E2.E8.E2.E2.D1 T3.E2.E8.E2.E2.D1 E4.E2.E8.E2.E2.D1 T5.E2.E8.E2.E2.D1 E6.E2.E8.E2.E2.D1 T7.E2.E8.E2.E2.D1");
5376 helper_ole_check(IXMLDOMNode_get_text(node1
, &bstr
));
5379 helper_expect_bstr_and_release(bstr
, str
);
5383 helper_expect_bstr_and_release(bstr
, "\n This is a description. \n ");
5385 IXMLDOMNode_Release(node1
);
5387 helper_ole_check(IXMLDOMNode_get_childNodes(node2
, &list
));
5388 helper_expect_list_and_release(list
, "T1.E4.E8.E2.E2.D1 E2.E4.E8.E2.E2.D1 T3.E4.E8.E2.E2.D1 E4.E4.E8.E2.E2.D1 T5.E4.E8.E2.E2.D1 E6.E4.E8.E2.E2.D1 T7.E4.E8.E2.E2.D1");
5389 helper_ole_check(IXMLDOMNode_get_text(node2
, &bstr
));
5390 helper_expect_bstr_and_release(bstr
, "\n This is a description with preserved whitespace. \n ");
5391 IXMLDOMNode_Release(node2
);
5394 static void test_whitespace(void)
5397 IXMLDOMDocument2
*doc1
, *doc2
, *doc3
, *doc4
;
5399 doc1
= create_document(&IID_IXMLDOMDocument2
);
5400 doc2
= create_document(&IID_IXMLDOMDocument2
);
5401 if (!doc1
|| !doc2
) return;
5403 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc2
, VARIANT_TRUE
));
5404 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc1
, &b
));
5405 ok(b
== VARIANT_FALSE
, "expected false\n");
5406 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc2
, &b
));
5407 ok(b
== VARIANT_TRUE
, "expected true\n");
5409 ole_check(IXMLDOMDocument2_loadXML(doc1
, _bstr_(szExampleXML
), &b
));
5410 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5411 ole_check(IXMLDOMDocument2_loadXML(doc2
, _bstr_(szExampleXML
), &b
));
5412 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5414 /* switch to XPath */
5415 ole_check(IXMLDOMDocument2_setProperty(doc1
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
5416 ole_check(IXMLDOMDocument2_setProperty(doc2
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
5418 check_ws_ignored(doc1
, NULL
);
5419 check_ws_preserved(doc2
, NULL
);
5421 /* new instances copy the property */
5422 ole_check(IXMLDOMDocument2_QueryInterface(doc1
, &IID_IXMLDOMDocument2
, (void**) &doc3
));
5423 ole_check(IXMLDOMDocument2_QueryInterface(doc2
, &IID_IXMLDOMDocument2
, (void**) &doc4
));
5425 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc3
, &b
));
5426 ok(b
== VARIANT_FALSE
, "expected false\n");
5427 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc4
, &b
));
5428 ok(b
== VARIANT_TRUE
, "expected true\n");
5430 check_ws_ignored(doc3
, NULL
);
5431 check_ws_preserved(doc4
, NULL
);
5433 /* setting after loading xml affects trimming of leading/trailing ws only */
5434 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc1
, VARIANT_TRUE
));
5435 ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc2
, VARIANT_FALSE
));
5437 /* the trailing "\n " isn't there, because it was ws-only node */
5438 check_ws_ignored(doc1
, "\n This is a description. ");
5439 check_ws_preserved(doc2
, "This is a description.");
5441 /* it takes effect on reload */
5442 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc1
, &b
));
5443 ok(b
== VARIANT_TRUE
, "expected true\n");
5444 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc2
, &b
));
5445 ok(b
== VARIANT_FALSE
, "expected false\n");
5447 ole_check(IXMLDOMDocument2_loadXML(doc1
, _bstr_(szExampleXML
), &b
));
5448 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5449 ole_check(IXMLDOMDocument2_loadXML(doc2
, _bstr_(szExampleXML
), &b
));
5450 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5452 check_ws_preserved(doc1
, NULL
);
5453 check_ws_ignored(doc2
, NULL
);
5455 /* other instances follow suit */
5456 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc3
, &b
));
5457 ok(b
== VARIANT_TRUE
, "expected true\n");
5458 ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc4
, &b
));
5459 ok(b
== VARIANT_FALSE
, "expected false\n");
5461 check_ws_preserved(doc3
, NULL
);
5462 check_ws_ignored(doc4
, NULL
);
5464 IXMLDOMDocument_Release(doc1
);
5465 IXMLDOMDocument_Release(doc2
);
5466 IXMLDOMDocument_Release(doc3
);
5467 IXMLDOMDocument_Release(doc4
);
5471 static void test_XPath(void)
5475 IXMLDOMDocument2
*doc
;
5476 IXMLDOMDocument
*doc2
;
5477 IXMLDOMNode
*rootNode
;
5478 IXMLDOMNode
*elem1Node
;
5480 IXMLDOMNodeList
*list
;
5481 IXMLDOMElement
*elem
;
5482 IXMLDOMAttribute
*attr
;
5486 doc
= create_document(&IID_IXMLDOMDocument2
);
5489 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
));
5490 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5492 /* switch to XPath */
5493 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
5495 /* some simple queries*/
5497 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
5498 EXPECT_HR(hr
, S_OK
);
5500 EXPECT_LIST_LEN(list
, 1);
5502 EXPECT_REF(list
, 1);
5503 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
5504 EXPECT_HR(hr
, S_OK
);
5505 EXPECT_REF(list
, 1);
5506 EXPECT_REF(rootNode
, 1);
5508 hr
= IXMLDOMNodeList_reset(list
);
5509 EXPECT_HR(hr
, S_OK
);
5510 expect_list_and_release(list
, "E2.D1");
5512 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//c"), &list
));
5513 expect_list_and_release(list
, "E3.E1.E2.D1 E3.E2.E2.D1");
5515 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("//c[@type]"), &list
));
5516 expect_list_and_release(list
, "E3.E2.E2.D1");
5518 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem"), &list
));
5519 /* using get_item for query results advances the position */
5520 ole_check(IXMLDOMNodeList_get_item(list
, 1, &node
));
5521 expect_node(node
, "E2.E2.D1");
5522 IXMLDOMNode_Release(node
);
5523 ole_check(IXMLDOMNodeList_nextNode(list
, &node
));
5524 expect_node(node
, "E4.E2.D1");
5525 IXMLDOMNode_Release(node
);
5526 ole_check(IXMLDOMNodeList_reset(list
));
5527 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E4.E2.D1");
5529 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("."), &list
));
5530 expect_list_and_release(list
, "E2.D1");
5532 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("elem[3]/preceding-sibling::*"), &list
));
5533 ole_check(IXMLDOMNodeList_get_item(list
, 0, &elem1Node
));
5534 ole_check(IXMLDOMNodeList_reset(list
));
5535 expect_list_and_release(list
, "E1.E2.D1 E2.E2.D1 E3.E2.D1");
5537 /* select an attribute */
5538 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//@type"), &list
));
5539 expect_list_and_release(list
, "A'type'.E3.E2.E2.D1");
5541 /* would evaluate to a number */
5542 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("count(*)"), &list
), E_FAIL
);
5543 /* would evaluate to a boolean */
5544 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("position()>0"), &list
), E_FAIL
);
5545 /* would evaluate to a string */
5546 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_("name()"), &list
), E_FAIL
);
5549 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_("c"), &list
));
5550 expect_list_and_release(list
, "");
5551 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("elem//c"), &list
));
5552 expect_list_and_release(list
, "");
5553 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("//elem[4]"), &list
));
5554 expect_list_and_release(list
, "");
5555 ole_check(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//elem[0]"), &list
));
5556 expect_list_and_release(list
, "");
5558 /* foo undeclared in document node */
5559 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
5560 /* undeclared in <root> node */
5561 ole_expect(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//foo:c"), &list
), E_FAIL
);
5562 /* undeclared in <elem> node */
5563 ole_expect(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//foo:c"), &list
), E_FAIL
);
5564 /* but this trick can be used */
5565 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//*[name()='foo:c']"), &list
));
5566 expect_list_and_release(list
, "E3.E4.E2.D1");
5568 /* it has to be declared in SelectionNamespaces */
5569 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
5570 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
5572 /* now the namespace can be used */
5573 ole_check(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//test:c"), &list
));
5574 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
5575 ole_check(IXMLDOMNode_selectNodes(rootNode
, _bstr_(".//test:c"), &list
));
5576 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
5577 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_("//test:c"), &list
));
5578 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
5579 ole_check(IXMLDOMNode_selectNodes(elem1Node
, _bstr_(".//test:x"), &list
));
5580 expect_list_and_release(list
, "E5.E1.E4.E1.E2.D1 E6.E2.E4.E1.E2.D1");
5582 /* SelectionNamespaces syntax error - the namespaces doesn't work anymore but the value is stored */
5583 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
5584 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###")), E_FAIL
);
5586 ole_expect(IXMLDOMDocument2_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
5589 ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
5590 expect_eq(V_VT(&var
), VT_BSTR
, int, "%x");
5591 if (V_VT(&var
) == VT_BSTR
)
5592 expect_bstr_eq_and_free(V_BSTR(&var
), "xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' xmlns:foo=###");
5594 /* extra attributes - same thing*/
5595 ole_expect(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"),
5596 _variantbstr_("xmlns:test='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29' param='test'")), E_FAIL
);
5597 ole_expect(IXMLDOMDocument_selectNodes(doc
, _bstr_("root//foo:c"), &list
), E_FAIL
);
5599 IXMLDOMNode_Release(rootNode
);
5600 IXMLDOMNode_Release(elem1Node
);
5602 /* alter document with already built list */
5603 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
5604 EXPECT_HR(hr
, S_OK
);
5605 EXPECT_LIST_LEN(list
, 1);
5607 hr
= IXMLDOMDocument2_get_lastChild(doc
, &rootNode
);
5608 EXPECT_HR(hr
, S_OK
);
5609 EXPECT_REF(rootNode
, 1);
5612 hr
= IXMLDOMDocument2_removeChild(doc
, rootNode
, NULL
);
5613 EXPECT_HR(hr
, S_OK
);
5614 IXMLDOMNode_Release(rootNode
);
5616 EXPECT_LIST_LEN(list
, 1);
5618 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
5619 EXPECT_HR(hr
, S_OK
);
5620 EXPECT_REF(rootNode
, 1);
5622 IXMLDOMNodeList_Release(list
);
5624 hr
= IXMLDOMNode_get_nodeName(rootNode
, &str
);
5625 EXPECT_HR(hr
, S_OK
);
5626 ok(!lstrcmpW(str
, _bstr_("root")), "got %s\n", wine_dbgstr_w(str
));
5628 IXMLDOMNode_Release(rootNode
);
5630 /* alter node from list and get it another time */
5631 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
5632 EXPECT_HR(hr
, S_OK
);
5633 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5635 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
5636 EXPECT_HR(hr
, S_OK
);
5637 EXPECT_LIST_LEN(list
, 1);
5639 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
5640 EXPECT_HR(hr
, S_OK
);
5642 hr
= IXMLDOMNode_QueryInterface(rootNode
, &IID_IXMLDOMElement
, (void**)&elem
);
5643 EXPECT_HR(hr
, S_OK
);
5647 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("attrtest"), var
);
5648 EXPECT_HR(hr
, S_OK
);
5649 IXMLDOMElement_Release(elem
);
5650 IXMLDOMNode_Release(rootNode
);
5652 /* now check attribute to be present */
5653 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
5654 EXPECT_HR(hr
, S_OK
);
5656 hr
= IXMLDOMNode_QueryInterface(rootNode
, &IID_IXMLDOMElement
, (void**)&elem
);
5657 EXPECT_HR(hr
, S_OK
);
5659 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attrtest"), &attr
);
5660 EXPECT_HR(hr
, S_OK
);
5661 IXMLDOMAttribute_Release(attr
);
5663 IXMLDOMElement_Release(elem
);
5664 IXMLDOMNode_Release(rootNode
);
5666 /* and now check for attribute in original document */
5667 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
5668 EXPECT_HR(hr
, S_OK
);
5670 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attrtest"), &attr
);
5671 EXPECT_HR(hr
, S_OK
);
5672 IXMLDOMAttribute_Release(attr
);
5674 IXMLDOMElement_Release(elem
);
5676 /* attach node from list to another document */
5677 doc2
= create_document(&IID_IXMLDOMDocument
);
5679 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
5680 EXPECT_HR(hr
, S_OK
);
5681 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5683 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("root"), &list
);
5684 EXPECT_HR(hr
, S_OK
);
5685 EXPECT_LIST_LEN(list
, 1);
5687 hr
= IXMLDOMNodeList_get_item(list
, 0, &rootNode
);
5688 EXPECT_HR(hr
, S_OK
);
5689 EXPECT_REF(rootNode
, 1);
5691 hr
= IXMLDOMDocument_appendChild(doc2
, rootNode
, NULL
);
5692 EXPECT_HR(hr
, S_OK
);
5693 EXPECT_REF(rootNode
, 1);
5694 EXPECT_REF(doc2
, 1);
5695 EXPECT_REF(list
, 1);
5697 EXPECT_LIST_LEN(list
, 1);
5699 IXMLDOMNode_Release(rootNode
);
5700 IXMLDOMNodeList_Release(list
);
5701 IXMLDOMDocument_Release(doc2
);
5703 IXMLDOMDocument2_Release(doc
);
5707 static void test_cloneNode(void )
5709 IXMLDOMDocument
*doc
, *doc2
;
5711 IXMLDOMNodeList
*pList
;
5712 IXMLDOMNamedNodeMap
*mapAttr
;
5713 LONG length
, length1
;
5714 LONG attr_cnt
, attr_cnt1
;
5716 IXMLDOMNode
*node_clone
;
5717 IXMLDOMNode
*node_first
;
5720 doc
= create_document(&IID_IXMLDOMDocument
);
5723 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
));
5724 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
5726 hr
= IXMLDOMNode_selectSingleNode(doc
, _bstr_("lc/pr"), &node
);
5727 ok( hr
== S_OK
, "ret %08x\n", hr
);
5728 ok( node
!= NULL
, "node %p\n", node
);
5730 /* Check invalid parameter */
5731 hr
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, NULL
);
5732 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5735 hr
= IXMLDOMNode_cloneNode(node
, VARIANT_TRUE
, &node_clone
);
5736 ok( hr
== S_OK
, "ret %08x\n", hr
);
5737 ok( node_clone
!= NULL
, "node %p\n", node
);
5739 hr
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
5740 ok( hr
== S_OK
, "ret %08x\n", hr
);
5741 hr
= IXMLDOMNode_get_ownerDocument(node_clone
, &doc2
);
5742 ok( hr
== S_OK
, "ret %08x\n", hr
);
5743 IXMLDOMDocument_Release(doc2
);
5744 IXMLDOMNode_Release(node_first
);
5746 hr
= IXMLDOMNode_get_childNodes(node
, &pList
);
5747 ok( hr
== S_OK
, "ret %08x\n", hr
);
5749 hr
= IXMLDOMNodeList_get_length(pList
, &length
);
5750 ok( hr
== S_OK
, "ret %08x\n", hr
);
5751 ok(length
== 1, "got %d\n", length
);
5752 IXMLDOMNodeList_Release(pList
);
5754 hr
= IXMLDOMNode_get_attributes(node
, &mapAttr
);
5755 ok( hr
== S_OK
, "ret %08x\n", hr
);
5757 hr
= IXMLDOMNamedNodeMap_get_length(mapAttr
, &attr_cnt
);
5758 ok( hr
== S_OK
, "ret %08x\n", hr
);
5759 ok(attr_cnt
== 3, "got %d\n", attr_cnt
);
5760 IXMLDOMNamedNodeMap_Release(mapAttr
);
5762 hr
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
5763 ok( hr
== S_OK
, "ret %08x\n", hr
);
5765 hr
= IXMLDOMNodeList_get_length(pList
, &length1
);
5766 ok(length1
== 1, "got %d\n", length1
);
5767 ok( hr
== S_OK
, "ret %08x\n", hr
);
5768 IXMLDOMNodeList_Release(pList
);
5770 hr
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
5771 ok( hr
== S_OK
, "ret %08x\n", hr
);
5773 hr
= IXMLDOMNamedNodeMap_get_length(mapAttr
, &attr_cnt1
);
5774 ok( hr
== S_OK
, "ret %08x\n", hr
);
5775 ok(attr_cnt1
== 3, "got %d\n", attr_cnt1
);
5776 IXMLDOMNamedNodeMap_Release(mapAttr
);
5778 ok(length
== length1
, "wrong Child count (%d, %d)\n", length
, length1
);
5779 ok(attr_cnt
== attr_cnt1
, "wrong Attribute count (%d, %d)\n", attr_cnt
, attr_cnt1
);
5780 IXMLDOMNode_Release(node_clone
);
5783 hr
= IXMLDOMNode_cloneNode(node
, VARIANT_FALSE
, &node_clone
);
5784 ok( hr
== S_OK
, "ret %08x\n", hr
);
5785 ok( node_clone
!= NULL
, "node %p\n", node
);
5787 hr
= IXMLDOMNode_get_firstChild(node_clone
, &node_first
);
5788 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5790 hr
= IXMLDOMNode_get_childNodes(node_clone
, &pList
);
5791 ok(hr
== S_OK
, "ret %08x\n", hr
);
5792 hr
= IXMLDOMNodeList_get_length(pList
, &length1
);
5793 ok(hr
== S_OK
, "ret %08x\n", hr
);
5794 ok( length1
== 0, "Length should be 0 (%d)\n", length1
);
5795 IXMLDOMNodeList_Release(pList
);
5797 hr
= IXMLDOMNode_get_attributes(node_clone
, &mapAttr
);
5798 ok(hr
== S_OK
, "ret %08x\n", hr
);
5799 hr
= IXMLDOMNamedNodeMap_get_length(mapAttr
, &attr_cnt1
);
5800 ok(hr
== S_OK
, "ret %08x\n", hr
);
5801 ok(attr_cnt1
== 3, "Attribute count should be 3 (%d)\n", attr_cnt1
);
5802 IXMLDOMNamedNodeMap_Release(mapAttr
);
5804 ok(length
!= length1
, "wrong Child count (%d, %d)\n", length
, length1
);
5805 ok(attr_cnt
== attr_cnt1
, "wrong Attribute count (%d, %d)\n", attr_cnt
, attr_cnt1
);
5806 IXMLDOMNode_Release(node_clone
);
5808 IXMLDOMNode_Release(node
);
5809 IXMLDOMDocument_Release(doc
);
5813 static void test_xmlTypes(void)
5815 IXMLDOMDocument
*doc
;
5816 IXMLDOMElement
*pRoot
;
5818 IXMLDOMComment
*pComment
;
5819 IXMLDOMElement
*pElement
;
5820 IXMLDOMAttribute
*pAttribute
;
5821 IXMLDOMNamedNodeMap
*pAttribs
;
5822 IXMLDOMCDATASection
*pCDataSec
;
5823 IXMLDOMImplementation
*pIXMLDOMImplementation
= NULL
;
5824 IXMLDOMDocumentFragment
*pDocFrag
= NULL
;
5825 IXMLDOMEntityReference
*pEntityRef
= NULL
;
5827 IXMLDOMNode
*pNextChild
;
5831 doc
= create_document(&IID_IXMLDOMDocument
);
5834 pNextChild
= (void*)0xdeadbeef;
5835 hr
= IXMLDOMDocument_get_nextSibling(doc
, NULL
);
5836 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5838 pNextChild
= (void*)0xdeadbeef;
5839 hr
= IXMLDOMDocument_get_nextSibling(doc
, &pNextChild
);
5840 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5841 ok(pNextChild
== NULL
, "pDocChild not NULL\n");
5843 /* test previous Sibling */
5844 hr
= IXMLDOMDocument_get_previousSibling(doc
, NULL
);
5845 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5847 pNextChild
= (void*)0xdeadbeef;
5848 hr
= IXMLDOMDocument_get_previousSibling(doc
, &pNextChild
);
5849 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5850 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
5852 /* test get_dataType */
5853 V_VT(&v
) = VT_EMPTY
;
5854 hr
= IXMLDOMDocument_get_dataType(doc
, &v
);
5855 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5856 ok( V_VT(&v
) == VT_NULL
, "incorrect dataType type\n");
5859 /* test implementation */
5860 hr
= IXMLDOMDocument_get_implementation(doc
, NULL
);
5861 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5863 hr
= IXMLDOMDocument_get_implementation(doc
, &pIXMLDOMImplementation
);
5864 ok(hr
== S_OK
, "ret %08x\n", hr
);
5867 VARIANT_BOOL hasFeature
= VARIANT_TRUE
;
5868 BSTR sEmpty
= SysAllocStringLen(NULL
, 0);
5870 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, NULL
, sEmpty
, &hasFeature
);
5871 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5873 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, NULL
);
5874 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5876 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
5877 ok(hr
== S_OK
, "ret %08x\n", hr
);
5878 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
5880 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, sEmpty
, sEmpty
, &hasFeature
);
5881 ok(hr
== S_OK
, "ret %08x\n", hr
);
5882 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned true\n");
5884 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), NULL
, &hasFeature
);
5885 ok(hr
== S_OK
, "ret %08x\n", hr
);
5886 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned false\n");
5888 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), sEmpty
, &hasFeature
);
5889 ok(hr
== S_OK
, "ret %08x\n", hr
);
5890 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
5892 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("DOM"), _bstr_("1.0"), &hasFeature
);
5893 ok(hr
== S_OK
, "ret %08x\n", hr
);
5894 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
5896 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("XML"), _bstr_("1.0"), &hasFeature
);
5897 ok(hr
== S_OK
, "ret %08x\n", hr
);
5898 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
5900 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("MS-DOM"), _bstr_("1.0"), &hasFeature
);
5901 ok(hr
== S_OK
, "ret %08x\n", hr
);
5902 ok(hasFeature
== VARIANT_TRUE
, "hasFeature returned true\n");
5904 hr
= IXMLDOMImplementation_hasFeature(pIXMLDOMImplementation
, _bstr_("SSS"), NULL
, &hasFeature
);
5905 ok(hr
== S_OK
, "ret %08x\n", hr
);
5906 ok(hasFeature
== VARIANT_FALSE
, "hasFeature returned false\n");
5908 SysFreeString(sEmpty
);
5909 IXMLDOMImplementation_Release(pIXMLDOMImplementation
);
5912 pRoot
= (IXMLDOMElement
*)0x1;
5913 hr
= IXMLDOMDocument_createElement(doc
, NULL
, &pRoot
);
5914 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5915 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
5917 pRoot
= (IXMLDOMElement
*)0x1;
5918 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(""), &pRoot
);
5919 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
5920 ok(pRoot
== (void*)0x1, "Expect same ptr, got %p\n", pRoot
);
5922 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &pRoot
);
5923 ok(hr
== S_OK
, "ret %08x\n", hr
);
5926 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)pRoot
, NULL
);
5927 ok(hr
== S_OK
, "ret %08x\n", hr
);
5931 str
= SysAllocString(szComment
);
5932 hr
= IXMLDOMDocument_createComment(doc
, str
, &pComment
);
5934 ok(hr
== S_OK
, "ret %08x\n", hr
);
5937 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pComment
, NULL
);
5938 ok(hr
== S_OK
, "ret %08x\n", hr
);
5940 hr
= IXMLDOMComment_get_nodeName(pComment
, &str
);
5941 ok(hr
== S_OK
, "ret %08x\n", hr
);
5942 ok( !lstrcmpW( str
, szCommentNodeText
), "incorrect comment node Name\n");
5945 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
5946 ok(hr
== S_OK
, "ret %08x\n", hr
);
5947 ok( !lstrcmpW( str
, szCommentXML
), "incorrect comment xml\n");
5950 /* put data Tests */
5951 hr
= IXMLDOMComment_put_data(pComment
, _bstr_("This &is a ; test <>\\"));
5952 ok(hr
== S_OK
, "ret %08x\n", hr
);
5954 /* get data Tests */
5955 hr
= IXMLDOMComment_get_data(pComment
, &str
);
5956 ok(hr
== S_OK
, "ret %08x\n", hr
);
5957 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect get_data string\n");
5960 /* Confirm XML text is good */
5961 hr
= IXMLDOMComment_get_xml(pComment
, &str
);
5962 ok(hr
== S_OK
, "ret %08x\n", hr
);
5963 ok( !lstrcmpW( str
, _bstr_("<!--This &is a ; test <>\\-->") ), "incorrect xml string\n");
5966 /* Confirm we get the put_data Text back */
5967 hr
= IXMLDOMComment_get_text(pComment
, &str
);
5968 ok(hr
== S_OK
, "ret %08x\n", hr
);
5969 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect xml string\n");
5972 /* test length property */
5973 hr
= IXMLDOMComment_get_length(pComment
, &len
);
5974 ok(hr
== S_OK
, "ret %08x\n", hr
);
5975 ok(len
== 21, "expected 21 got %d\n", len
);
5977 /* test substringData */
5978 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, NULL
);
5979 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5981 /* test substringData - Invalid offset */
5982 str
= (BSTR
)&szElement
;
5983 hr
= IXMLDOMComment_substringData(pComment
, -1, 4, &str
);
5984 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5985 ok( str
== NULL
, "incorrect string\n");
5987 /* test substringData - Invalid offset */
5988 str
= (BSTR
)&szElement
;
5989 hr
= IXMLDOMComment_substringData(pComment
, 30, 0, &str
);
5990 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
5991 ok( str
== NULL
, "incorrect string\n");
5993 /* test substringData - Invalid size */
5994 str
= (BSTR
)&szElement
;
5995 hr
= IXMLDOMComment_substringData(pComment
, 0, -1, &str
);
5996 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
5997 ok( str
== NULL
, "incorrect string\n");
5999 /* test substringData - Invalid size */
6000 str
= (BSTR
)&szElement
;
6001 hr
= IXMLDOMComment_substringData(pComment
, 2, 0, &str
);
6002 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6003 ok( str
== NULL
, "incorrect string\n");
6005 /* test substringData - Start of string */
6006 hr
= IXMLDOMComment_substringData(pComment
, 0, 4, &str
);
6007 ok(hr
== S_OK
, "ret %08x\n", hr
);
6008 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
6011 /* test substringData - Middle of string */
6012 hr
= IXMLDOMComment_substringData(pComment
, 13, 4, &str
);
6013 ok(hr
== S_OK
, "ret %08x\n", hr
);
6014 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
6017 /* test substringData - End of string */
6018 hr
= IXMLDOMComment_substringData(pComment
, 20, 4, &str
);
6019 ok(hr
== S_OK
, "ret %08x\n", hr
);
6020 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
6023 /* test appendData */
6024 hr
= IXMLDOMComment_appendData(pComment
, NULL
);
6025 ok(hr
== S_OK
, "ret %08x\n", hr
);
6027 hr
= IXMLDOMComment_appendData(pComment
, _bstr_(""));
6028 ok(hr
== S_OK
, "ret %08x\n", hr
);
6030 hr
= IXMLDOMComment_appendData(pComment
, _bstr_("Append"));
6031 ok(hr
== S_OK
, "ret %08x\n", hr
);
6033 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6034 ok(hr
== S_OK
, "ret %08x\n", hr
);
6035 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6038 /* test insertData */
6039 str
= SysAllocStringLen(NULL
, 0);
6040 hr
= IXMLDOMComment_insertData(pComment
, -1, str
);
6041 ok(hr
== S_OK
, "ret %08x\n", hr
);
6043 hr
= IXMLDOMComment_insertData(pComment
, -1, NULL
);
6044 ok(hr
== S_OK
, "ret %08x\n", hr
);
6046 hr
= IXMLDOMComment_insertData(pComment
, 1000, str
);
6047 ok(hr
== S_OK
, "ret %08x\n", hr
);
6049 hr
= IXMLDOMComment_insertData(pComment
, 1000, NULL
);
6050 ok(hr
== S_OK
, "ret %08x\n", hr
);
6052 hr
= IXMLDOMComment_insertData(pComment
, 0, NULL
);
6053 ok(hr
== S_OK
, "ret %08x\n", hr
);
6055 hr
= IXMLDOMComment_insertData(pComment
, 0, str
);
6056 ok(hr
== S_OK
, "ret %08x\n", hr
);
6059 hr
= IXMLDOMComment_insertData(pComment
, -1, _bstr_("Inserting"));
6060 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6062 hr
= IXMLDOMComment_insertData(pComment
, 1000, _bstr_("Inserting"));
6063 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6065 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("Begin "));
6066 ok(hr
== S_OK
, "ret %08x\n", hr
);
6068 hr
= IXMLDOMComment_insertData(pComment
, 17, _bstr_("Middle"));
6069 ok(hr
== S_OK
, "ret %08x\n", hr
);
6071 hr
= IXMLDOMComment_insertData(pComment
, 39, _bstr_(" End"));
6072 ok(hr
== S_OK
, "ret %08x\n", hr
);
6074 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6075 ok(hr
== S_OK
, "ret %08x\n", hr
);
6076 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6080 /* invalid arguments */
6081 hr
= IXMLDOMComment_deleteData(pComment
, -1, 1);
6082 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6084 hr
= IXMLDOMComment_deleteData(pComment
, 0, 0);
6085 ok(hr
== S_OK
, "ret %08x\n", hr
);
6087 hr
= IXMLDOMComment_deleteData(pComment
, 0, -1);
6088 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6090 hr
= IXMLDOMComment_get_length(pComment
, &len
);
6091 ok(hr
== S_OK
, "ret %08x\n", hr
);
6092 ok(len
== 43, "expected 43 got %d\n", len
);
6094 hr
= IXMLDOMComment_deleteData(pComment
, len
, 1);
6095 ok(hr
== S_OK
, "ret %08x\n", hr
);
6097 hr
= IXMLDOMComment_deleteData(pComment
, len
+1, 1);
6098 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6100 /* delete from start */
6101 hr
= IXMLDOMComment_deleteData(pComment
, 0, 5);
6102 ok(hr
== S_OK
, "ret %08x\n", hr
);
6104 hr
= IXMLDOMComment_get_length(pComment
, &len
);
6105 ok(hr
== S_OK
, "ret %08x\n", hr
);
6106 ok(len
== 38, "expected 38 got %d\n", len
);
6108 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6109 ok(hr
== S_OK
, "ret %08x\n", hr
);
6110 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6113 /* delete from end */
6114 hr
= IXMLDOMComment_deleteData(pComment
, 35, 3);
6115 ok(hr
== S_OK
, "ret %08x\n", hr
);
6117 hr
= IXMLDOMComment_get_length(pComment
, &len
);
6118 ok(hr
== S_OK
, "ret %08x\n", hr
);
6119 ok(len
== 35, "expected 35 got %d\n", len
);
6121 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6122 ok(hr
== S_OK
, "ret %08x\n", hr
);
6123 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6126 /* delete from inside */
6127 hr
= IXMLDOMComment_deleteData(pComment
, 1, 33);
6128 ok(hr
== S_OK
, "ret %08x\n", hr
);
6130 hr
= IXMLDOMComment_get_length(pComment
, &len
);
6131 ok(hr
== S_OK
, "ret %08x\n", hr
);
6132 ok(len
== 2, "expected 2 got %d\n", len
);
6134 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6135 ok(hr
== S_OK
, "ret %08x\n", hr
);
6136 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6139 /* delete whole data ... */
6140 hr
= IXMLDOMComment_get_length(pComment
, &len
);
6141 ok(hr
== S_OK
, "ret %08x\n", hr
);
6143 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
6144 ok(hr
== S_OK
, "ret %08x\n", hr
);
6145 /* ... and try again with empty string */
6146 hr
= IXMLDOMComment_deleteData(pComment
, 0, len
);
6147 ok(hr
== S_OK
, "ret %08x\n", hr
);
6149 /* ::replaceData() */
6151 V_BSTR(&v
) = SysAllocString(szstr1
);
6152 hr
= IXMLDOMComment_put_nodeValue(pComment
, v
);
6153 ok(hr
== S_OK
, "ret %08x\n", hr
);
6156 hr
= IXMLDOMComment_replaceData(pComment
, 6, 0, NULL
);
6157 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6158 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6159 ok(hr
== S_OK
, "ret %08x\n", hr
);
6160 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6163 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, NULL
);
6164 ok(hr
== S_OK
, "ret %08x\n", hr
);
6165 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6166 ok(hr
== S_OK
, "ret %08x\n", hr
);
6167 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6170 /* NULL pointer means delete */
6171 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, NULL
);
6172 ok(hr
== S_OK
, "ret %08x\n", hr
);
6173 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6174 ok(hr
== S_OK
, "ret %08x\n", hr
);
6175 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6178 /* empty string means delete */
6179 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_(""));
6180 ok(hr
== S_OK
, "ret %08x\n", hr
);
6181 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6182 ok(hr
== S_OK
, "ret %08x\n", hr
);
6183 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6186 /* zero count means insert */
6187 hr
= IXMLDOMComment_replaceData(pComment
, 0, 0, _bstr_("a"));
6188 ok(hr
== S_OK
, "ret %08x\n", hr
);
6189 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6190 ok(hr
== S_OK
, "ret %08x\n", hr
);
6191 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6194 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, NULL
);
6195 ok(hr
== S_OK
, "ret %08x\n", hr
);
6197 hr
= IXMLDOMComment_insertData(pComment
, 0, _bstr_("m"));
6198 ok(hr
== S_OK
, "ret %08x\n", hr
);
6199 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6200 ok(hr
== S_OK
, "ret %08x\n", hr
);
6201 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6204 /* nonempty string, count greater than its length */
6205 hr
= IXMLDOMComment_replaceData(pComment
, 0, 2, _bstr_("a1.2"));
6206 ok(hr
== S_OK
, "ret %08x\n", hr
);
6207 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6208 ok(hr
== S_OK
, "ret %08x\n", hr
);
6209 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6212 /* nonempty string, count less than its length */
6213 hr
= IXMLDOMComment_replaceData(pComment
, 0, 1, _bstr_("wine"));
6214 ok(hr
== S_OK
, "ret %08x\n", hr
);
6215 hr
= IXMLDOMComment_get_text(pComment
, &str
);
6216 ok(hr
== S_OK
, "ret %08x\n", hr
);
6217 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6220 IXMLDOMComment_Release(pComment
);
6224 str
= SysAllocString(szElement
);
6225 hr
= IXMLDOMDocument_createElement(doc
, str
, &pElement
);
6227 ok(hr
== S_OK
, "ret %08x\n", hr
);
6230 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pElement
, NULL
);
6231 ok(hr
== S_OK
, "ret %08x\n", hr
);
6233 hr
= IXMLDOMElement_get_nodeName(pElement
, &str
);
6234 ok(hr
== S_OK
, "ret %08x\n", hr
);
6235 ok( !lstrcmpW( str
, szElement
), "incorrect element node Name\n");
6238 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
6239 ok(hr
== S_OK
, "ret %08x\n", hr
);
6240 ok( !lstrcmpW( str
, szElementXML
), "incorrect element xml\n");
6244 pAttribute
= (IXMLDOMAttribute
*)0x1;
6245 hr
= IXMLDOMDocument_createAttribute(doc
, NULL
, &pAttribute
);
6246 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6247 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
6249 pAttribute
= (IXMLDOMAttribute
*)0x1;
6250 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_(""), &pAttribute
);
6251 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6252 ok(pAttribute
== (void*)0x1, "Expect same ptr, got %p\n", pAttribute
);
6254 str
= SysAllocString(szAttribute
);
6255 hr
= IXMLDOMDocument_createAttribute(doc
, str
, &pAttribute
);
6257 ok(hr
== S_OK
, "ret %08x\n", hr
);
6260 IXMLDOMNode
*pNewChild
= (IXMLDOMNode
*)0x1;
6262 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, NULL
);
6263 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6265 pNextChild
= (IXMLDOMNode
*)0x1;
6266 hr
= IXMLDOMAttribute_get_nextSibling(pAttribute
, &pNextChild
);
6267 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6268 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
6270 /* test Previous Sibling*/
6271 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, NULL
);
6272 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6274 pNextChild
= (IXMLDOMNode
*)0x1;
6275 hr
= IXMLDOMAttribute_get_previousSibling(pAttribute
, &pNextChild
);
6276 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6277 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
6279 hr
= IXMLDOMElement_appendChild(pElement
, (IXMLDOMNode
*)pAttribute
, &pNewChild
);
6280 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6281 ok(pNewChild
== NULL
, "pNewChild not NULL\n");
6283 hr
= IXMLDOMElement_get_attributes(pElement
, &pAttribs
);
6284 ok(hr
== S_OK
, "ret %08x\n", hr
);
6287 hr
= IXMLDOMNamedNodeMap_setNamedItem(pAttribs
, (IXMLDOMNode
*)pAttribute
, NULL
);
6288 ok(hr
== S_OK
, "ret %08x\n", hr
);
6290 IXMLDOMNamedNodeMap_Release(pAttribs
);
6293 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
6294 ok(hr
== S_OK
, "ret %08x\n", hr
);
6295 ok( !lstrcmpW( str
, szAttribute
), "incorrect attribute node Name\n");
6299 hr
= IXMLDOMAttribute_get_nodeName(pAttribute
, &str
);
6300 ok(hr
== S_OK
, "ret %08x\n", hr
);
6301 ok( !lstrcmpW( str
, szAttribute
), "incorrect nodeName string\n");
6304 /* test name property */
6305 hr
= IXMLDOMAttribute_get_name(pAttribute
, &str
);
6306 ok(hr
== S_OK
, "ret %08x\n", hr
);
6307 ok( !lstrcmpW( str
, szAttribute
), "incorrect name string\n");
6310 hr
= IXMLDOMAttribute_get_xml(pAttribute
, &str
);
6311 ok(hr
== S_OK
, "ret %08x\n", hr
);
6312 ok( !lstrcmpW( str
, szAttributeXML
), "incorrect attribute xml\n");
6315 IXMLDOMAttribute_Release(pAttribute
);
6317 /* Check Element again with the Add Attribute*/
6318 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
6319 ok(hr
== S_OK
, "ret %08x\n", hr
);
6320 ok( !lstrcmpW( str
, szElementXML2
), "incorrect element xml\n");
6324 hr
= IXMLDOMElement_put_text(pElement
, _bstr_("TestingNode"));
6325 ok(hr
== S_OK
, "ret %08x\n", hr
);
6327 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
6328 ok(hr
== S_OK
, "ret %08x\n", hr
);
6329 ok( !lstrcmpW( str
, szElementXML3
), "incorrect element xml\n");
6332 /* Test for reversible escaping */
6333 str
= SysAllocString( szStrangeChars
);
6334 hr
= IXMLDOMElement_put_text(pElement
, str
);
6335 ok(hr
== S_OK
, "ret %08x\n", hr
);
6336 SysFreeString( str
);
6338 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
6339 ok(hr
== S_OK
, "ret %08x\n", hr
);
6340 ok( !lstrcmpW( str
, szElementXML4
), "incorrect element xml\n");
6343 hr
= IXMLDOMElement_get_text(pElement
, &str
);
6344 ok(hr
== S_OK
, "ret %08x\n", hr
);
6345 ok( !lstrcmpW( str
, szStrangeChars
), "incorrect element text\n");
6348 IXMLDOMElement_Release(pElement
);
6352 str
= SysAllocString(szCData
);
6353 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, NULL
);
6354 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6356 hr
= IXMLDOMDocument_createCDATASection(doc
, str
, &pCDataSec
);
6358 ok(hr
== S_OK
, "ret %08x\n", hr
);
6361 IXMLDOMNode
*pNextChild
= (IXMLDOMNode
*)0x1;
6366 hr
= IXMLDOMCDATASection_QueryInterface(pCDataSec
, &IID_IXMLDOMElement
, (void**)&pElement
);
6367 ok(hr
== E_NOINTERFACE
, "ret %08x\n", hr
);
6369 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pCDataSec
, NULL
);
6370 ok(hr
== S_OK
, "ret %08x\n", hr
);
6372 hr
= IXMLDOMCDATASection_get_nodeName(pCDataSec
, &str
);
6373 ok(hr
== S_OK
, "ret %08x\n", hr
);
6374 ok( !lstrcmpW( str
, szCDataNodeText
), "incorrect cdata node Name\n");
6377 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
6378 ok(hr
== S_OK
, "ret %08x\n", hr
);
6379 ok( !lstrcmpW( str
, szCDataXML
), "incorrect cdata xml\n");
6382 /* test lastChild */
6383 pNextChild
= (IXMLDOMNode
*)0x1;
6384 hr
= IXMLDOMCDATASection_get_lastChild(pCDataSec
, &pNextChild
);
6385 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6386 ok(pNextChild
== NULL
, "pNextChild not NULL\n");
6388 /* put data Tests */
6389 hr
= IXMLDOMCDATASection_put_data(pCDataSec
, _bstr_("This &is a ; test <>\\"));
6390 ok(hr
== S_OK
, "ret %08x\n", hr
);
6392 /* Confirm XML text is good */
6393 hr
= IXMLDOMCDATASection_get_xml(pCDataSec
, &str
);
6394 ok(hr
== S_OK
, "ret %08x\n", hr
);
6395 ok( !lstrcmpW( str
, _bstr_("<![CDATA[This &is a ; test <>\\]]>") ), "incorrect xml string\n");
6398 /* Confirm we get the put_data Text back */
6399 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6400 ok(hr
== S_OK
, "ret %08x\n", hr
);
6401 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
6404 /* test length property */
6405 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
6406 ok(hr
== S_OK
, "ret %08x\n", hr
);
6407 ok(len
== 21, "expected 21 got %d\n", len
);
6410 hr
= IXMLDOMCDATASection_get_data(pCDataSec
, &str
);
6411 ok(hr
== S_OK
, "ret %08x\n", hr
);
6412 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\") ), "incorrect text string\n");
6415 /* test substringData */
6416 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, NULL
);
6417 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6419 /* test substringData - Invalid offset */
6420 str
= (BSTR
)&szElement
;
6421 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, -1, 4, &str
);
6422 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6423 ok( str
== NULL
, "incorrect string\n");
6425 /* test substringData - Invalid offset */
6426 str
= (BSTR
)&szElement
;
6427 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 30, 0, &str
);
6428 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6429 ok( str
== NULL
, "incorrect string\n");
6431 /* test substringData - Invalid size */
6432 str
= (BSTR
)&szElement
;
6433 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, -1, &str
);
6434 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6435 ok( str
== NULL
, "incorrect string\n");
6437 /* test substringData - Invalid size */
6438 str
= (BSTR
)&szElement
;
6439 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 2, 0, &str
);
6440 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6441 ok( str
== NULL
, "incorrect string\n");
6443 /* test substringData - Start of string */
6444 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 0, 4, &str
);
6445 ok(hr
== S_OK
, "ret %08x\n", hr
);
6446 ok( !lstrcmpW( str
, _bstr_("This") ), "incorrect substringData string\n");
6449 /* test substringData - Middle of string */
6450 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 13, 4, &str
);
6451 ok(hr
== S_OK
, "ret %08x\n", hr
);
6452 ok( !lstrcmpW( str
, _bstr_("test") ), "incorrect substringData string\n");
6455 /* test substringData - End of string */
6456 hr
= IXMLDOMCDATASection_substringData(pCDataSec
, 20, 4, &str
);
6457 ok(hr
== S_OK
, "ret %08x\n", hr
);
6458 ok( !lstrcmpW( str
, _bstr_("\\") ), "incorrect substringData string\n");
6461 /* test appendData */
6462 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, NULL
);
6463 ok(hr
== S_OK
, "ret %08x\n", hr
);
6465 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_(""));
6466 ok(hr
== S_OK
, "ret %08x\n", hr
);
6468 hr
= IXMLDOMCDATASection_appendData(pCDataSec
, _bstr_("Append"));
6469 ok(hr
== S_OK
, "ret %08x\n", hr
);
6471 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6472 ok(hr
== S_OK
, "ret %08x\n", hr
);
6473 ok( !lstrcmpW( str
, _bstr_("This &is a ; test <>\\Append") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6476 /* test insertData */
6477 str
= SysAllocStringLen(NULL
, 0);
6478 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, str
);
6479 ok(hr
== S_OK
, "ret %08x\n", hr
);
6481 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, NULL
);
6482 ok(hr
== S_OK
, "ret %08x\n", hr
);
6484 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, str
);
6485 ok(hr
== S_OK
, "ret %08x\n", hr
);
6487 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, NULL
);
6488 ok(hr
== S_OK
, "ret %08x\n", hr
);
6490 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, NULL
);
6491 ok(hr
== S_OK
, "ret %08x\n", hr
);
6493 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, str
);
6494 ok(hr
== S_OK
, "ret %08x\n", hr
);
6497 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, -1, _bstr_("Inserting"));
6498 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6500 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 1000, _bstr_("Inserting"));
6501 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6503 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("Begin "));
6504 ok(hr
== S_OK
, "ret %08x\n", hr
);
6506 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 17, _bstr_("Middle"));
6507 ok(hr
== S_OK
, "ret %08x\n", hr
);
6509 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 39, _bstr_(" End"));
6510 ok(hr
== S_OK
, "ret %08x\n", hr
);
6512 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6513 ok(hr
== S_OK
, "ret %08x\n", hr
);
6514 ok( !lstrcmpW( str
, _bstr_("Begin This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6518 /* invalid arguments */
6519 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, -1, 1);
6520 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6522 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 0);
6523 ok(hr
== S_OK
, "ret %08x\n", hr
);
6525 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, -1);
6526 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6528 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
6529 ok(hr
== S_OK
, "ret %08x\n", hr
);
6530 ok(len
== 43, "expected 43 got %d\n", len
);
6532 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
, 1);
6533 ok(hr
== S_OK
, "ret %08x\n", hr
);
6535 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, len
+1, 1);
6536 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6538 /* delete from start */
6539 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, 5);
6540 ok(hr
== S_OK
, "ret %08x\n", hr
);
6542 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
6543 ok(hr
== S_OK
, "ret %08x\n", hr
);
6544 ok(len
== 38, "expected 38 got %d\n", len
);
6546 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6547 ok(hr
== S_OK
, "ret %08x\n", hr
);
6548 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append End") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6551 /* delete from end */
6552 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 35, 3);
6553 ok(hr
== S_OK
, "ret %08x\n", hr
);
6555 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
6556 ok(hr
== S_OK
, "ret %08x\n", hr
);
6557 ok(len
== 35, "expected 35 got %d\n", len
);
6559 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6560 ok(hr
== S_OK
, "ret %08x\n", hr
);
6561 ok( !lstrcmpW( str
, _bstr_(" This &is a Middle; test <>\\Append ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6564 /* delete from inside */
6565 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 1, 33);
6566 ok(hr
== S_OK
, "ret %08x\n", hr
);
6568 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
6569 ok(hr
== S_OK
, "ret %08x\n", hr
);
6570 ok(len
== 2, "expected 2 got %d\n", len
);
6572 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6573 ok(hr
== S_OK
, "ret %08x\n", hr
);
6574 ok( !lstrcmpW( str
, _bstr_(" ") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6577 /* delete whole data ... */
6578 hr
= IXMLDOMCDATASection_get_length(pCDataSec
, &len
);
6579 ok(hr
== S_OK
, "ret %08x\n", hr
);
6581 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
6582 ok(hr
== S_OK
, "ret %08x\n", hr
);
6584 /* ... and try again with empty string */
6585 hr
= IXMLDOMCDATASection_deleteData(pCDataSec
, 0, len
);
6586 ok(hr
== S_OK
, "ret %08x\n", hr
);
6588 /* ::replaceData() */
6590 V_BSTR(&v
) = SysAllocString(szstr1
);
6591 hr
= IXMLDOMCDATASection_put_nodeValue(pCDataSec
, v
);
6592 ok(hr
== S_OK
, "ret %08x\n", hr
);
6595 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 6, 0, NULL
);
6596 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6597 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6598 ok(hr
== S_OK
, "ret %08x\n", hr
);
6599 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6602 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, NULL
);
6603 ok(hr
== S_OK
, "ret %08x\n", hr
);
6604 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6605 ok(hr
== S_OK
, "ret %08x\n", hr
);
6606 ok( !lstrcmpW( str
, _bstr_("str1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6609 /* NULL pointer means delete */
6610 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, NULL
);
6611 ok(hr
== S_OK
, "ret %08x\n", hr
);
6612 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6613 ok(hr
== S_OK
, "ret %08x\n", hr
);
6614 ok( !lstrcmpW( str
, _bstr_("tr1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6617 /* empty string means delete */
6618 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_(""));
6619 ok(hr
== S_OK
, "ret %08x\n", hr
);
6620 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6621 ok(hr
== S_OK
, "ret %08x\n", hr
);
6622 ok( !lstrcmpW( str
, _bstr_("r1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6625 /* zero count means insert */
6626 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 0, _bstr_("a"));
6627 ok(hr
== S_OK
, "ret %08x\n", hr
);
6628 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6629 ok(hr
== S_OK
, "ret %08x\n", hr
);
6630 ok( !lstrcmpW( str
, _bstr_("ar1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6633 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, NULL
);
6634 ok(hr
== S_OK
, "ret %08x\n", hr
);
6636 hr
= IXMLDOMCDATASection_insertData(pCDataSec
, 0, _bstr_("m"));
6637 ok(hr
== S_OK
, "ret %08x\n", hr
);
6638 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6639 ok(hr
== S_OK
, "ret %08x\n", hr
);
6640 ok( !lstrcmpW( str
, _bstr_("m1") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6643 /* nonempty string, count greater than its length */
6644 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 2, _bstr_("a1.2"));
6645 ok(hr
== S_OK
, "ret %08x\n", hr
);
6646 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6647 ok(hr
== S_OK
, "ret %08x\n", hr
);
6648 ok( !lstrcmpW( str
, _bstr_("a1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6651 /* nonempty string, count less than its length */
6652 hr
= IXMLDOMCDATASection_replaceData(pCDataSec
, 0, 1, _bstr_("wine"));
6653 ok(hr
== S_OK
, "ret %08x\n", hr
);
6654 hr
= IXMLDOMCDATASection_get_text(pCDataSec
, &str
);
6655 ok(hr
== S_OK
, "ret %08x\n", hr
);
6656 ok( !lstrcmpW( str
, _bstr_("wine1.2") ), "incorrect get_text string, got '%s'\n", wine_dbgstr_w(str
) );
6659 IXMLDOMCDATASection_Release(pCDataSec
);
6662 /* Document Fragments */
6663 hr
= IXMLDOMDocument_createDocumentFragment(doc
, NULL
);
6664 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6666 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &pDocFrag
);
6667 ok(hr
== S_OK
, "ret %08x\n", hr
);
6672 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, NULL
);
6673 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6675 node
= (IXMLDOMNode
*)0x1;
6676 hr
= IXMLDOMDocumentFragment_get_parentNode(pDocFrag
, &node
);
6677 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6678 ok(node
== NULL
, "expected NULL, got %p\n", node
);
6680 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pDocFrag
, NULL
);
6681 ok(hr
== S_OK
, "ret %08x\n", hr
);
6683 hr
= IXMLDOMDocumentFragment_get_nodeName(pDocFrag
, &str
);
6684 ok(hr
== S_OK
, "ret %08x\n", hr
);
6685 ok( !lstrcmpW( str
, szDocFragmentText
), "incorrect docfragment node Name\n");
6688 /* test next Sibling*/
6689 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, NULL
);
6690 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6692 node
= (IXMLDOMNode
*)0x1;
6693 hr
= IXMLDOMDocumentFragment_get_nextSibling(pDocFrag
, &node
);
6694 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6695 ok(node
== NULL
, "next sibling not NULL\n");
6697 /* test Previous Sibling*/
6698 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, NULL
);
6699 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6701 node
= (IXMLDOMNode
*)0x1;
6702 hr
= IXMLDOMDocumentFragment_get_previousSibling(pDocFrag
, &node
);
6703 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
6704 ok(node
== NULL
, "previous sibling not NULL\n");
6706 IXMLDOMDocumentFragment_Release(pDocFrag
);
6709 /* Entity References */
6710 hr
= IXMLDOMDocument_createEntityReference(doc
, NULL
, &pEntityRef
);
6711 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6712 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_(""), &pEntityRef
);
6713 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
6715 str
= SysAllocString(szEntityRef
);
6716 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, NULL
);
6717 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
6719 hr
= IXMLDOMDocument_createEntityReference(doc
, str
, &pEntityRef
);
6721 ok(hr
== S_OK
, "ret %08x\n", hr
);
6724 hr
= IXMLDOMElement_appendChild(pRoot
, (IXMLDOMNode
*)pEntityRef
, NULL
);
6725 ok(hr
== S_OK
, "ret %08x\n", hr
);
6728 hr
= IXMLDOMEntityReference_get_xml(pEntityRef
, &str
);
6729 ok(hr
== S_OK
, "ret %08x\n", hr
);
6730 ok( !lstrcmpW( str
, szEntityRefXML
), "incorrect xml string\n");
6733 IXMLDOMEntityReference_Release(pEntityRef
);
6736 IXMLDOMElement_Release( pRoot
);
6740 IXMLDOMDocument_Release(doc
);
6751 /* Type test for elements only. Name passed into put_dataType is case-insensitive.
6752 So many of the names have been changed to reflect this. */
6753 static put_datatype_t put_datatype_data
[] = {
6754 { "test_inval", "abcdefg", E_FAIL
},
6755 { "test_bool", "Boolean", S_OK
},
6756 { "test_string", "String", S_OK
},
6757 { "test_number", "number", S_OK
},
6758 { "test_int", "InT", S_OK
},
6759 { "test_fixed", "fixed.14.4", S_OK
},
6760 { "test_datetime", "DateTime", S_OK
},
6761 { "test_datetimetz", "DateTime.tz", S_OK
},
6762 { "test_date", "Date", S_OK
},
6763 { "test_time", "Time", S_OK
},
6764 { "test_timetz", "Time.tz", S_OK
},
6765 { "test_I1", "I1", S_OK
},
6766 { "test_I2", "I2", S_OK
},
6767 { "test_I4", "I4", S_OK
},
6768 { "test_UI1", "UI1", S_OK
},
6769 { "test_UI2", "UI2", S_OK
},
6770 { "test_UI4", "UI4", S_OK
},
6771 { "test_r4", "r4", S_OK
},
6772 { "test_r8", "r8", S_OK
},
6773 { "test_float", "float", S_OK
},
6774 { "test_uuid", "UuId", S_OK
},
6775 { "test_binhex", "bin.hex", S_OK
},
6776 { "test_binbase64", "bin.base64", S_OK
},
6780 static void test_nodeTypeTests( void )
6782 const put_datatype_t
*ptr
= put_datatype_data
;
6783 IXMLDOMElement
*root
, *element
;
6784 IXMLDOMDocument
*doc
;
6787 doc
= create_document(&IID_IXMLDOMDocument
);
6790 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), NULL
);
6791 EXPECT_HR(hr
, E_INVALIDARG
);
6793 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &root
);
6794 EXPECT_HR(hr
, S_OK
);
6796 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)root
, NULL
);
6797 EXPECT_HR(hr
, S_OK
);
6799 hr
= IXMLDOMElement_put_dataType(root
, NULL
);
6800 EXPECT_HR(hr
, E_INVALIDARG
);
6804 hr
= IXMLDOMDocument_createElement(doc
, _bstr_(ptr
->name
), &element
);
6805 EXPECT_HR(hr
, S_OK
);
6808 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)element
, NULL
);
6809 EXPECT_HR(hr
, S_OK
);
6811 hr
= IXMLDOMElement_put_dataType(element
, _bstr_(ptr
->type
));
6812 ok(hr
== ptr
->hr
, "failed for %s:%s, 0x%08x\n", ptr
->name
, ptr
->type
, ptr
->hr
);
6814 IXMLDOMElement_Release(element
);
6819 /* check changing types */
6820 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing_Change"), &element
);
6821 EXPECT_HR(hr
, S_OK
);
6823 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)element
, NULL
);
6824 EXPECT_HR(hr
, S_OK
);
6826 hr
= IXMLDOMElement_put_dataType(element
, _bstr_("DateTime.tz"));
6827 EXPECT_HR(hr
, S_OK
);
6829 hr
= IXMLDOMElement_put_dataType(element
, _bstr_("string"));
6830 EXPECT_HR(hr
, S_OK
);
6832 IXMLDOMElement_Release(element
);
6834 IXMLDOMElement_Release(root
);
6835 IXMLDOMDocument_Release(doc
);
6839 static void test_save(void)
6841 IXMLDOMDocument
*doc
, *doc2
;
6842 IXMLDOMElement
*root
;
6844 BSTR sOrig
, sNew
, filename
;
6850 doc
= create_document(&IID_IXMLDOMDocument
);
6853 doc2
= create_document(&IID_IXMLDOMDocument
);
6856 IXMLDOMDocument_Release(doc
);
6860 /* save to IXMLDOMDocument */
6861 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Testing"), &root
);
6862 EXPECT_HR(hr
, S_OK
);
6864 hr
= IXMLDOMDocument_appendChild(doc
, (IXMLDOMNode
*)root
, NULL
);
6865 EXPECT_HR(hr
, S_OK
);
6867 V_VT(&vDoc
) = VT_UNKNOWN
;
6868 V_UNKNOWN(&vDoc
) = (IUnknown
*)doc2
;
6870 hr
= IXMLDOMDocument_save(doc
, vDoc
);
6871 EXPECT_HR(hr
, S_OK
);
6873 hr
= IXMLDOMDocument_get_xml(doc
, &sOrig
);
6874 EXPECT_HR(hr
, S_OK
);
6876 hr
= IXMLDOMDocument_get_xml(doc2
, &sNew
);
6877 EXPECT_HR(hr
, S_OK
);
6879 ok( !lstrcmpW( sOrig
, sNew
), "New document is not the same as original\n");
6881 SysFreeString(sOrig
);
6882 SysFreeString(sNew
);
6884 IXMLDOMElement_Release(root
);
6885 IXMLDOMDocument_Release(doc2
);
6888 V_VT(&file
) = VT_BSTR
;
6889 V_BSTR(&file
) = _bstr_("test.xml");
6891 hr
= IXMLDOMDocument_save(doc
, file
);
6892 EXPECT_HR(hr
, S_OK
);
6894 hfile
= CreateFileA("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6895 ok(hfile
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
6896 if(hfile
== INVALID_HANDLE_VALUE
) return;
6898 ReadFile(hfile
, buffer
, sizeof(buffer
), &read
, NULL
);
6899 ok(read
!= 0, "could not read file\n");
6900 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
6903 DeleteFile("test.xml");
6905 /* save to path VT_BSTR | VT_BYREF */
6906 filename
= _bstr_("test.xml");
6907 V_VT(&file
) = VT_BSTR
| VT_BYREF
;
6908 V_BSTRREF(&file
) = &filename
;
6910 hr
= IXMLDOMDocument_save(doc
, file
);
6911 EXPECT_HR(hr
, S_OK
);
6913 IXMLDOMDocument_Release(doc
);
6915 hfile
= CreateFileA("test.xml", GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
6916 ok(hfile
!= INVALID_HANDLE_VALUE
, "Could not open file: %u\n", GetLastError());
6917 if(hfile
== INVALID_HANDLE_VALUE
) return;
6919 ReadFile(hfile
, buffer
, sizeof(buffer
), &read
, NULL
);
6920 ok(read
!= 0, "could not read file\n");
6921 ok(buffer
[0] != '<' || buffer
[1] != '?', "File contains processing instruction\n");
6924 DeleteFile("test.xml");
6928 static void test_testTransforms(void)
6930 IXMLDOMDocument
*doc
, *docSS
;
6936 doc
= create_document(&IID_IXMLDOMDocument
);
6939 docSS
= create_document(&IID_IXMLDOMDocument
);
6942 IXMLDOMDocument_Release(doc
);
6946 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformXML
), &bSucc
);
6947 ok(hr
== S_OK
, "ret %08x\n", hr
);
6949 hr
= IXMLDOMDocument_loadXML(docSS
, _bstr_(szTransformSSXML
), &bSucc
);
6950 ok(hr
== S_OK
, "ret %08x\n", hr
);
6952 hr
= IXMLDOMDocument_QueryInterface(docSS
, &IID_IXMLDOMNode
, (void**)&pNode
);
6953 ok(hr
== S_OK
, "ret %08x\n", hr
);
6958 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &bOut
);
6959 ok(hr
== S_OK
, "ret %08x\n", hr
);
6962 ok( compareIgnoreReturns( bOut
, _bstr_(szTransformOutput
)), "Stylesheet output not correct\n");
6963 SysFreeString(bOut
);
6966 IXMLDOMNode_Release(pNode
);
6969 IXMLDOMDocument_Release(docSS
);
6970 IXMLDOMDocument_Release(doc
);
6975 static void test_namespaces(void)
6977 static const CHAR namespaces_xmlA
[] =
6978 "<?xml version=\"1.0\"?>\n"
6979 "<XMI xmi.version=\"1.1\" xmlns:Model=\"http://omg.org/mof.Model/1.3\">"
6981 " <Model:Package name=\"WinePackage\" Model:name2=\"name2 attr\" />"
6985 IXMLDOMDocument
*doc
;
6986 IXMLDOMElement
*elem
;
6994 doc
= create_document(&IID_IXMLDOMDocument
);
6997 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(namespaces_xmlA
), &b
);
6998 EXPECT_HR(hr
, S_OK
);
6999 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
7001 str
= (BSTR
)0xdeadbeef;
7002 hr
= IXMLDOMDocument_get_namespaceURI(doc
, &str
);
7003 EXPECT_HR(hr
, S_FALSE
);
7004 ok(str
== NULL
, "got %p\n", str
);
7006 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("//XMI.content"), &node
);
7007 EXPECT_HR(hr
, S_OK
);
7010 IXMLDOMAttribute
*attr
;
7013 hr
= IXMLDOMNode_get_firstChild(node
, &node2
);
7014 EXPECT_HR(hr
, S_OK
);
7015 ok(node2
!= NULL
, "got %p\n", node2
);
7017 /* Test get_prefix */
7018 hr
= IXMLDOMNode_get_prefix(node2
, NULL
);
7019 EXPECT_HR(hr
, E_INVALIDARG
);
7020 /* NOTE: Need to test that arg2 gets cleared on Error. */
7022 hr
= IXMLDOMNode_get_prefix(node2
, &str
);
7023 EXPECT_HR(hr
, S_OK
);
7024 ok( !lstrcmpW( str
, _bstr_("Model")), "got %s\n", wine_dbgstr_w(str
));
7027 hr
= IXMLDOMNode_get_nodeName(node2
, &str
);
7028 EXPECT_HR(hr
, S_OK
);
7029 ok(!lstrcmpW( str
, _bstr_("Model:Package")), "got %s\n", wine_dbgstr_w(str
));
7032 /* Test get_namespaceURI */
7033 hr
= IXMLDOMNode_get_namespaceURI(node2
, NULL
);
7034 EXPECT_HR(hr
, E_INVALIDARG
);
7035 /* NOTE: Need to test that arg2 gets cleared on Error. */
7037 hr
= IXMLDOMNode_get_namespaceURI(node2
, &str
);
7038 EXPECT_HR(hr
, S_OK
);
7039 ok(!lstrcmpW( str
, _bstr_("http://omg.org/mof.Model/1.3")), "got %s\n", wine_dbgstr_w(str
));
7042 hr
= IXMLDOMNode_QueryInterface(node2
, &IID_IXMLDOMElement
, (void**)&elem
);
7043 EXPECT_HR(hr
, S_OK
);
7045 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("Model:name2"), &attr
);
7046 EXPECT_HR(hr
, S_OK
);
7048 hr
= IXMLDOMAttribute_get_nodeName(attr
, &str
);
7049 EXPECT_HR(hr
, S_OK
);
7050 ok(!lstrcmpW( str
, _bstr_("Model:name2")), "got %s\n", wine_dbgstr_w(str
));
7053 hr
= IXMLDOMAttribute_get_prefix(attr
, &str
);
7054 EXPECT_HR(hr
, S_OK
);
7055 ok(!lstrcmpW( str
, _bstr_("Model")), "got %s\n", wine_dbgstr_w(str
));
7058 IXMLDOMAttribute_Release(attr
);
7059 IXMLDOMElement_Release(elem
);
7061 IXMLDOMNode_Release(node2
);
7062 IXMLDOMNode_Release(node
);
7065 IXMLDOMDocument_Release(doc
);
7067 /* create on element and try to alter namespace after that */
7068 doc
= create_document(&IID_IXMLDOMDocument
);
7072 V_I2(&var
) = NODE_ELEMENT
;
7074 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("ns:elem"), _bstr_("ns/uri"), &node
);
7075 EXPECT_HR(hr
, S_OK
);
7077 hr
= IXMLDOMDocument_appendChild(doc
, node
, NULL
);
7078 EXPECT_HR(hr
, S_OK
);
7080 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
7081 EXPECT_HR(hr
, S_OK
);
7083 V_VT(&var
) = VT_BSTR
;
7084 V_BSTR(&var
) = _bstr_("ns/uri2");
7086 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("xmlns:ns"), var
);
7087 EXPECT_HR(hr
, E_INVALIDARG
);
7089 V_VT(&var
) = VT_BSTR
;
7090 V_BSTR(&var
) = _bstr_("ns/uri");
7092 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("xmlns:ns"), var
);
7093 EXPECT_HR(hr
, S_OK
);
7095 hr
= IXMLDOMElement_get_xml(elem
, &str
);
7096 EXPECT_HR(hr
, S_OK
);
7097 ok(!lstrcmpW(str
, _bstr_("<ns:elem xmlns:ns=\"ns/uri\"/>")), "got element %s\n", wine_dbgstr_w(str
));
7100 IXMLDOMElement_Release(elem
);
7101 IXMLDOMDocument_Release(doc
);
7103 /* create on element and try to alter namespace after that */
7104 doc
= create_document_version(60, &IID_IXMLDOMDocument
);
7108 V_I2(&var
) = NODE_ELEMENT
;
7110 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("ns:elem"), _bstr_("ns/uri"), &node
);
7111 EXPECT_HR(hr
, S_OK
);
7113 hr
= IXMLDOMDocument_appendChild(doc
, node
, NULL
);
7114 EXPECT_HR(hr
, S_OK
);
7116 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
7117 EXPECT_HR(hr
, S_OK
);
7119 /* try same prefix, different uri */
7120 V_VT(&var
) = VT_BSTR
;
7121 V_BSTR(&var
) = _bstr_("ns/uri2");
7123 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("xmlns:ns"), var
);
7124 EXPECT_HR(hr
, E_INVALIDARG
);
7126 /* try same prefix and uri */
7127 V_VT(&var
) = VT_BSTR
;
7128 V_BSTR(&var
) = _bstr_("ns/uri");
7130 hr
= IXMLDOMElement_setAttribute(elem
, _bstr_("xmlns:ns"), var
);
7131 EXPECT_HR(hr
, S_OK
);
7133 hr
= IXMLDOMElement_get_xml(elem
, &str
);
7134 EXPECT_HR(hr
, S_OK
);
7135 ok(!lstrcmpW(str
, _bstr_("<ns:elem xmlns:ns=\"ns/uri\"/>")), "got element %s\n", wine_dbgstr_w(str
));
7138 IXMLDOMElement_Release(elem
);
7139 IXMLDOMDocument_Release(doc
);
7144 static void test_FormattingXML(void)
7146 IXMLDOMDocument
*doc
;
7147 IXMLDOMElement
*pElement
;
7151 static const CHAR szLinefeedXML
[] = "<?xml version=\"1.0\"?>\n<Root>\n\t<Sub val=\"A\" />\n</Root>";
7152 static const CHAR szLinefeedRootXML
[] = "<Root>\r\n\t<Sub val=\"A\"/>\r\n</Root>";
7154 doc
= create_document(&IID_IXMLDOMDocument
);
7157 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szLinefeedXML
), &bSucc
);
7158 ok(hr
== S_OK
, "ret %08x\n", hr
);
7159 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
7161 if(bSucc
== VARIANT_TRUE
)
7163 hr
= IXMLDOMDocument_get_documentElement(doc
, &pElement
);
7164 ok(hr
== S_OK
, "ret %08x\n", hr
);
7167 hr
= IXMLDOMElement_get_xml(pElement
, &str
);
7168 ok(hr
== S_OK
, "ret %08x\n", hr
);
7169 ok( !lstrcmpW( str
, _bstr_(szLinefeedRootXML
) ), "incorrect element xml\n");
7172 IXMLDOMElement_Release(pElement
);
7176 IXMLDOMDocument_Release(doc
);
7181 typedef struct _nodetypedvalue_t
{
7184 const char *value
; /* value in string format */
7187 static const nodetypedvalue_t get_nodetypedvalue
[] = {
7188 { "root/string", VT_BSTR
, "Wine" },
7189 { "root/string2", VT_BSTR
, "String" },
7190 { "root/number", VT_BSTR
, "12.44" },
7191 { "root/number2", VT_BSTR
, "-3.71e3" },
7192 { "root/int", VT_I4
, "-13" },
7193 { "root/fixed", VT_CY
, "7322.9371" },
7194 { "root/bool", VT_BOOL
, "-1" },
7195 { "root/datetime", VT_DATE
, "40135.14" },
7196 { "root/datetimetz",VT_DATE
, "37813.59" },
7197 { "root/date", VT_DATE
, "665413" },
7198 { "root/time", VT_DATE
, "0.5813889" },
7199 { "root/timetz", VT_DATE
, "1.112512" },
7200 { "root/i1", VT_I1
, "-13" },
7201 { "root/i2", VT_I2
, "31915" },
7202 { "root/i4", VT_I4
, "-312232" },
7203 { "root/ui1", VT_UI1
, "123" },
7204 { "root/ui2", VT_UI2
, "48282" },
7205 { "root/ui4", VT_UI4
, "949281" },
7206 { "root/r4", VT_R4
, "213124" },
7207 { "root/r8", VT_R8
, "0.412" },
7208 { "root/float", VT_R8
, "41221.421" },
7209 { "root/uuid", VT_BSTR
, "333C7BC4-460F-11D0-BC04-0080C7055a83" },
7210 { "root/binbase64", VT_ARRAY
|VT_UI1
, "base64 test" },
7211 { "root/binbase64_1", VT_ARRAY
|VT_UI1
, "base64 test" },
7212 { "root/binbase64_2", VT_ARRAY
|VT_UI1
, "base64 test" },
7216 static void test_nodeTypedValue(void)
7218 const nodetypedvalue_t
*entry
= get_nodetypedvalue
;
7219 IXMLDOMDocumentType
*doctype
, *doctype2
;
7220 IXMLDOMProcessingInstruction
*pi
;
7221 IXMLDOMDocumentFragment
*frag
;
7222 IXMLDOMDocument
*doc
, *doc2
;
7223 IXMLDOMCDATASection
*cdata
;
7224 IXMLDOMComment
*comment
;
7230 doc
= create_document(&IID_IXMLDOMDocument
);
7234 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTypeValueXML
), &b
);
7235 ok(hr
== S_OK
, "ret %08x\n", hr
);
7236 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
7238 hr
= IXMLDOMDocument_get_nodeValue(doc
, NULL
);
7239 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7241 V_VT(&value
) = VT_BSTR
;
7242 V_BSTR(&value
) = NULL
;
7243 hr
= IXMLDOMDocument_get_nodeValue(doc
, &value
);
7244 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
7245 ok(V_VT(&value
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&value
));
7247 hr
= IXMLDOMDocument_get_nodeTypedValue(doc
, NULL
);
7248 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7250 V_VT(&value
) = VT_EMPTY
;
7251 hr
= IXMLDOMDocument_get_nodeTypedValue(doc
, &value
);
7252 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
7253 ok(V_VT(&value
) == VT_NULL
, "got %d\n", V_VT(&value
));
7255 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/string"), &node
);
7256 ok(hr
== S_OK
, "ret %08x\n", hr
);
7258 V_VT(&value
) = VT_BSTR
;
7259 V_BSTR(&value
) = NULL
;
7260 hr
= IXMLDOMNode_get_nodeValue(node
, &value
);
7261 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
7262 ok(V_VT(&value
) == VT_NULL
, "expect VT_NULL got %d\n", V_VT(&value
));
7264 hr
= IXMLDOMNode_get_nodeTypedValue(node
, NULL
);
7265 ok(hr
== E_INVALIDARG
, "ret %08x\n", hr
);
7267 IXMLDOMNode_Release(node
);
7269 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("root/binhex"), &node
);
7270 ok(hr
== S_OK
, "ret %08x\n", hr
);
7272 BYTE bytes
[] = {0xff,0xfc,0xa0,0x12,0x00,0x3c};
7274 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
7275 ok(hr
== S_OK
, "ret %08x\n", hr
);
7276 ok(V_VT(&value
) == (VT_ARRAY
|VT_UI1
), "incorrect type\n");
7277 ok(V_ARRAY(&value
)->rgsabound
[0].cElements
== 6, "incorrect array size\n");
7278 if(V_ARRAY(&value
)->rgsabound
[0].cElements
== 6)
7279 ok(!memcmp(bytes
, V_ARRAY(&value
)->pvData
, sizeof(bytes
)), "incorrect value\n");
7280 VariantClear(&value
);
7281 IXMLDOMNode_Release(node
);
7284 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("foo"), _bstr_("value"), &pi
);
7285 ok(hr
== S_OK
, "ret %08x\n", hr
);
7287 V_VT(&value
) = VT_NULL
;
7288 V_BSTR(&value
) = (void*)0xdeadbeef;
7289 hr
= IXMLDOMProcessingInstruction_get_nodeTypedValue(pi
, &value
);
7290 ok(hr
== S_OK
, "ret %08x\n", hr
);
7291 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
7292 ok(!lstrcmpW(V_BSTR(&value
), _bstr_("value")), "got wrong value\n");
7293 IXMLDOMProcessingInstruction_Release(pi
);
7294 VariantClear(&value
);
7297 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("[1]*2=3; &gee that's not right!"), &cdata
);
7298 ok(hr
== S_OK
, "ret %08x\n", hr
);
7300 V_VT(&value
) = VT_NULL
;
7301 V_BSTR(&value
) = (void*)0xdeadbeef;
7302 hr
= IXMLDOMCDATASection_get_nodeTypedValue(cdata
, &value
);
7303 ok(hr
== S_OK
, "ret %08x\n", hr
);
7304 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
7305 ok(!lstrcmpW(V_BSTR(&value
), _bstr_("[1]*2=3; &gee that's not right!")), "got wrong value\n");
7306 IXMLDOMCDATASection_Release(cdata
);
7307 VariantClear(&value
);
7310 hr
= IXMLDOMDocument_createComment(doc
, _bstr_("comment"), &comment
);
7311 ok(hr
== S_OK
, "ret %08x\n", hr
);
7313 V_VT(&value
) = VT_NULL
;
7314 V_BSTR(&value
) = (void*)0xdeadbeef;
7315 hr
= IXMLDOMComment_get_nodeTypedValue(comment
, &value
);
7316 ok(hr
== S_OK
, "ret %08x\n", hr
);
7317 ok(V_VT(&value
) == VT_BSTR
, "got %d\n", V_VT(&value
));
7318 ok(!lstrcmpW(V_BSTR(&value
), _bstr_("comment")), "got wrong value\n");
7319 IXMLDOMComment_Release(comment
);
7320 VariantClear(&value
);
7323 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &frag
);
7324 ok(hr
== S_OK
, "ret %08x\n", hr
);
7326 V_VT(&value
) = VT_EMPTY
;
7327 hr
= IXMLDOMDocumentFragment_get_nodeTypedValue(frag
, &value
);
7328 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
7329 ok(V_VT(&value
) == VT_NULL
, "got %d\n", V_VT(&value
));
7330 IXMLDOMDocumentFragment_Release(frag
);
7333 doc2
= create_document(&IID_IXMLDOMDocument
);
7336 hr
= IXMLDOMDocument_loadXML(doc2
, _bstr_(szEmailXML
), &b
);
7337 ok(hr
== S_OK
, "ret %08x\n", hr
);
7338 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
7340 EXPECT_REF(doc2
, 1);
7342 hr
= IXMLDOMDocument_get_doctype(doc2
, &doctype
);
7343 ok(hr
== S_OK
, "ret %08x\n", hr
);
7345 EXPECT_REF(doc2
, 1);
7346 todo_wine
EXPECT_REF(doctype
, 2);
7349 V_VT(&value
) = VT_EMPTY
;
7350 hr
= IXMLDOMDocumentType_get_nodeTypedValue(doctype
, &value
);
7351 ok(hr
== S_FALSE
, "ret %08x\n", hr
);
7352 ok(V_VT(&value
) == VT_NULL
, "got %d\n", V_VT(&value
));
7355 hr
= IXMLDOMDocument_get_doctype(doc2
, &doctype2
);
7356 ok(hr
== S_OK
, "ret %08x\n", hr
);
7357 ok(doctype
!= doctype2
, "got %p, was %p\n", doctype2
, doctype
);
7359 IXMLDOMDocumentType_Release(doctype2
);
7360 IXMLDOMDocumentType_Release(doctype
);
7362 IXMLDOMDocument_Release(doc2
);
7366 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_(entry
->name
), &node
);
7367 ok(hr
== S_OK
, "ret %08x\n", hr
);
7369 hr
= IXMLDOMNode_get_nodeTypedValue(node
, &value
);
7370 ok(hr
== S_OK
, "ret %08x\n", hr
);
7371 ok(V_VT(&value
) == entry
->type
, "incorrect type, expected %d, got %d\n", entry
->type
, V_VT(&value
));
7373 if (entry
->type
== (VT_ARRAY
|VT_UI1
))
7375 ok(V_ARRAY(&value
)->rgsabound
[0].cElements
== strlen(entry
->value
),
7376 "incorrect array size %d\n", V_ARRAY(&value
)->rgsabound
[0].cElements
);
7379 if (entry
->type
!= VT_BSTR
)
7381 if (entry
->type
== VT_DATE
||
7382 entry
->type
== VT_R8
||
7383 entry
->type
== VT_CY
)
7385 if (entry
->type
== VT_DATE
)
7387 hr
= VariantChangeType(&value
, &value
, 0, VT_R4
);
7388 ok(hr
== S_OK
, "ret %08x\n", hr
);
7390 hr
= VariantChangeTypeEx(&value
, &value
,
7391 MAKELCID(MAKELANGID(LANG_ENGLISH
, SUBLANG_DEFAULT
), SORT_DEFAULT
),
7392 VARIANT_NOUSEROVERRIDE
, VT_BSTR
);
7393 ok(hr
== S_OK
, "ret %08x\n", hr
);
7397 hr
= VariantChangeType(&value
, &value
, 0, VT_BSTR
);
7398 ok(hr
== S_OK
, "ret %08x\n", hr
);
7401 /* for byte array from VT_ARRAY|VT_UI1 it's not a WCHAR buffer */
7402 if (entry
->type
== (VT_ARRAY
|VT_UI1
))
7404 ok(!memcmp( V_BSTR(&value
), entry
->value
, strlen(entry
->value
)),
7405 "expected %s\n", entry
->value
);
7408 ok(lstrcmpW( V_BSTR(&value
), _bstr_(entry
->value
)) == 0,
7409 "expected %s, got %s\n", entry
->value
, wine_dbgstr_w(V_BSTR(&value
)));
7412 ok(lstrcmpW( V_BSTR(&value
), _bstr_(entry
->value
)) == 0,
7413 "expected %s, got %s\n", entry
->value
, wine_dbgstr_w(V_BSTR(&value
)));
7415 VariantClear( &value
);
7416 IXMLDOMNode_Release(node
);
7421 IXMLDOMDocument_Release(doc
);
7425 static void test_TransformWithLoadingLocalFile(void)
7427 IXMLDOMDocument
*doc
;
7428 IXMLDOMDocument
*xsl
;
7434 char lpPathBuffer
[MAX_PATH
];
7437 /* Create a Temp File. */
7438 GetTempPathA(MAX_PATH
, lpPathBuffer
);
7439 strcat(lpPathBuffer
, "customers.xml" );
7441 file
= CreateFileA(lpPathBuffer
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
7442 ok(file
!= INVALID_HANDLE_VALUE
, "Could not create file: %u\n", GetLastError());
7443 if(file
== INVALID_HANDLE_VALUE
)
7446 WriteFile(file
, szBasicTransformXML
, strlen(szBasicTransformXML
), &dwWritten
, NULL
);
7449 /* Correct path to not include a escape character. */
7450 for(i
=0; i
< strlen(lpPathBuffer
); i
++)
7452 if(lpPathBuffer
[i
] == '\\')
7453 lpPathBuffer
[i
] = '/';
7456 doc
= create_document(&IID_IXMLDOMDocument
);
7459 xsl
= create_document(&IID_IXMLDOMDocument
);
7462 IXMLDOMDocument2_Release(doc
);
7466 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTypeValueXML
), &bSucc
);
7467 ok(hr
== S_OK
, "ret %08x\n", hr
);
7468 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
7469 if(bSucc
== VARIANT_TRUE
)
7472 BSTR sPart1
= _bstr_(szBasicTransformSSXMLPart1
);
7473 BSTR sPart2
= _bstr_(szBasicTransformSSXMLPart2
);
7474 BSTR sFileName
= _bstr_(lpPathBuffer
);
7475 int nLegnth
= lstrlenW(sPart1
) + lstrlenW(sPart2
) + lstrlenW(sFileName
) + 1;
7477 sXSL
= SysAllocStringLen(NULL
, nLegnth
);
7478 lstrcpyW(sXSL
, sPart1
);
7479 lstrcatW(sXSL
, sFileName
);
7480 lstrcatW(sXSL
, sPart2
);
7482 hr
= IXMLDOMDocument_loadXML(xsl
, sXSL
, &bSucc
);
7483 ok(hr
== S_OK
, "ret %08x\n", hr
);
7484 ok(bSucc
== VARIANT_TRUE
, "Expected VARIANT_TRUE got VARIANT_FALSE\n");
7485 if(bSucc
== VARIANT_TRUE
)
7489 hr
= IXMLDOMDocument_QueryInterface(xsl
, &IID_IXMLDOMNode
, (void**)&pNode
);
7490 ok(hr
== S_OK
, "ret %08x\n", hr
);
7493 /* This will load the temp file via the XSL */
7494 hr
= IXMLDOMDocument_transformNode(doc
, pNode
, &sResult
);
7495 ok(hr
== S_OK
, "ret %08x\n", hr
);
7498 ok( compareIgnoreReturns( sResult
, _bstr_(szBasicTransformOutput
)), "Stylesheet output not correct\n");
7499 SysFreeString(sResult
);
7502 IXMLDOMNode_Release(pNode
);
7506 SysFreeString(sXSL
);
7509 IXMLDOMDocument_Release(doc
);
7510 IXMLDOMDocument_Release(xsl
);
7512 DeleteFile(lpPathBuffer
);
7516 static void test_put_nodeValue(void)
7518 static const WCHAR jeevesW
[] = {'J','e','e','v','e','s',' ','&',' ','W','o','o','s','t','e','r',0};
7519 IXMLDOMDocument
*doc
;
7521 IXMLDOMEntityReference
*entityref
;
7522 IXMLDOMAttribute
*attr
;
7527 doc
= create_document(&IID_IXMLDOMDocument
);
7530 /* test for unsupported types */
7532 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IXMLDOMNode
, (void**)&node
);
7533 ok(hr
== S_OK
, "ret %08x\n", hr
);
7534 V_VT(&data
) = VT_BSTR
;
7535 V_BSTR(&data
) = _bstr_("one two three");
7536 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
7537 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
7538 IXMLDOMNode_Release(node
);
7540 /* NODE_DOCUMENT_FRAGMENT */
7541 V_VT(&type
) = VT_I1
;
7542 V_I1(&type
) = NODE_DOCUMENT_FRAGMENT
;
7543 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
7544 ok(hr
== S_OK
, "ret %08x\n", hr
);
7545 V_VT(&data
) = VT_BSTR
;
7546 V_BSTR(&data
) = _bstr_("one two three");
7547 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
7548 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
7549 IXMLDOMNode_Release(node
);
7552 V_VT(&type
) = VT_I1
;
7553 V_I1(&type
) = NODE_ELEMENT
;
7554 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_("test"), NULL
, &node
);
7555 ok(hr
== S_OK
, "ret %08x\n", hr
);
7556 V_VT(&data
) = VT_BSTR
;
7557 V_BSTR(&data
) = _bstr_("one two three");
7558 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
7559 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
7560 IXMLDOMNode_Release(node
);
7562 /* NODE_ENTITY_REFERENCE */
7563 hr
= IXMLDOMDocument_createEntityReference(doc
, _bstr_("ref"), &entityref
);
7564 ok(hr
== S_OK
, "ret %08x\n", hr
);
7566 V_VT(&data
) = VT_BSTR
;
7567 V_BSTR(&data
) = _bstr_("one two three");
7568 hr
= IXMLDOMEntityReference_put_nodeValue(entityref
, data
);
7569 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
7571 hr
= IXMLDOMEntityReference_QueryInterface(entityref
, &IID_IXMLDOMNode
, (void**)&node
);
7572 ok(hr
== S_OK
, "ret %08x\n", hr
);
7573 V_VT(&data
) = VT_BSTR
;
7574 V_BSTR(&data
) = _bstr_("one two three");
7575 hr
= IXMLDOMNode_put_nodeValue(node
, data
);
7576 ok(hr
== E_FAIL
, "ret %08x\n", hr
);
7577 IXMLDOMNode_Release(node
);
7578 IXMLDOMEntityReference_Release(entityref
);
7580 /* supported types */
7581 hr
= IXMLDOMDocument_createTextNode(doc
, _bstr_(""), &text
);
7582 ok(hr
== S_OK
, "ret %08x\n", hr
);
7583 V_VT(&data
) = VT_BSTR
;
7584 V_BSTR(&data
) = _bstr_("Jeeves & Wooster");
7585 hr
= IXMLDOMText_put_nodeValue(text
, data
);
7586 ok(hr
== S_OK
, "ret %08x\n", hr
);
7587 IXMLDOMText_Release(text
);
7589 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
7590 ok(hr
== S_OK
, "ret %08x\n", hr
);
7591 V_VT(&data
) = VT_BSTR
;
7592 V_BSTR(&data
) = _bstr_("Jeeves & Wooster");
7593 hr
= IXMLDOMAttribute_put_nodeValue(attr
, data
);
7594 ok(hr
== S_OK
, "ret %08x\n", hr
);
7595 hr
= IXMLDOMAttribute_get_nodeValue(attr
, &data
);
7596 ok(hr
== S_OK
, "ret %08x\n", hr
);
7597 ok(memcmp(V_BSTR(&data
), jeevesW
, sizeof(jeevesW
)) == 0, "got %s\n",
7598 wine_dbgstr_w(V_BSTR(&data
)));
7599 VariantClear(&data
);
7600 IXMLDOMAttribute_Release(attr
);
7604 IXMLDOMDocument_Release(doc
);
7607 static void test_document_IObjectSafety(void)
7609 IXMLDOMDocument
*doc
;
7610 IObjectSafety
*safety
;
7613 doc
= create_document(&IID_IXMLDOMDocument
);
7616 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IObjectSafety
, (void**)&safety
);
7617 ok(hr
== S_OK
, "ret %08x\n", hr
);
7619 test_IObjectSafety_common(safety
);
7621 IObjectSafety_Release(safety
);
7623 IXMLDOMDocument_Release(doc
);
7626 typedef struct _property_test_t
{
7629 const char *property
;
7633 static const property_test_t properties_test_data
[] = {
7634 { &CLSID_DOMDocument
, "CLSID_DOMDocument" , "SelectionLanguage", "XSLPattern" },
7635 { &CLSID_DOMDocument2
, "CLSID_DOMDocument2" , "SelectionLanguage", "XSLPattern" },
7636 { &CLSID_DOMDocument30
, "CLSID_DOMDocument30", "SelectionLanguage", "XSLPattern" },
7637 { &CLSID_DOMDocument40
, "CLSID_DOMDocument40", "SelectionLanguage", "XPath" },
7638 { &CLSID_DOMDocument60
, "CLSID_DOMDocument60", "SelectionLanguage", "XPath" },
7642 static void test_default_properties(void)
7644 const property_test_t
*entry
= properties_test_data
;
7648 IXMLDOMDocument2
*doc
;
7652 hr
= CoCreateInstance(entry
->guid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument2
, (void**)&doc
);
7655 win_skip("can't create %s instance\n", entry
->clsid
);
7660 hr
= IXMLDOMDocument2_getProperty(doc
, _bstr_(entry
->property
), &var
);
7661 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7662 ok(lstrcmpW(V_BSTR(&var
), _bstr_(entry
->value
)) == 0, "expected %s, for %s\n",
7663 entry
->value
, entry
->clsid
);
7666 IXMLDOMDocument2_Release(doc
);
7675 } xslpattern_test_t
;
7677 static const xslpattern_test_t xslpattern_test
[] = {
7678 { "root//elem[0]", "E1.E2.D1" },
7679 { "root//elem[index()=1]", "E2.E2.D1" },
7680 { "root//elem[index() $eq$ 1]", "E2.E2.D1" },
7681 { "root//elem[end()]", "E4.E2.D1" },
7682 { "root//elem[$not$ end()]", "E1.E2.D1 E2.E2.D1 E3.E2.D1" },
7683 { "root//elem[index() != 0]", "E2.E2.D1 E3.E2.D1 E4.E2.D1" },
7684 { "root//elem[index() $ne$ 0]", "E2.E2.D1 E3.E2.D1 E4.E2.D1" },
7685 { "root//elem[index() < 2]", "E1.E2.D1 E2.E2.D1" },
7686 { "root//elem[index() $lt$ 2]", "E1.E2.D1 E2.E2.D1" },
7687 { "root//elem[index() <= 1]", "E1.E2.D1 E2.E2.D1" },
7688 { "root//elem[index() $le$ 1]", "E1.E2.D1 E2.E2.D1" },
7689 { "root//elem[index() > 1]", "E3.E2.D1 E4.E2.D1" },
7690 { "root//elem[index() $gt$ 1]", "E3.E2.D1 E4.E2.D1" },
7691 { "root//elem[index() >= 2]", "E3.E2.D1 E4.E2.D1" },
7692 { "root//elem[index() $ge$ 2]", "E3.E2.D1 E4.E2.D1" },
7693 { "root//elem[a $ieq$ 'a2 field']", "E2.E2.D1" },
7694 { "root//elem[a $ine$ 'a2 field']", "E1.E2.D1 E3.E2.D1 E4.E2.D1" },
7695 { "root//elem[a $ilt$ 'a3 field']", "E1.E2.D1 E2.E2.D1" },
7696 { "root//elem[a $ile$ 'a2 field']", "E1.E2.D1 E2.E2.D1" },
7697 { "root//elem[a $igt$ 'a2 field']", "E3.E2.D1 E4.E2.D1" },
7698 { "root//elem[a $ige$ 'a3 field']", "E3.E2.D1 E4.E2.D1" },
7699 { "root//elem[$any$ *='B2 field']", "E2.E2.D1" },
7700 { "root//elem[$all$ *!='B2 field']", "E1.E2.D1 E3.E2.D1 E4.E2.D1" },
7701 { "root//elem[index()=0 or end()]", "E1.E2.D1 E4.E2.D1" },
7702 { "root//elem[index()=0 $or$ end()]", "E1.E2.D1 E4.E2.D1" },
7703 { "root//elem[index()=0 || end()]", "E1.E2.D1 E4.E2.D1" },
7704 { "root//elem[index()>0 and $not$ end()]", "E2.E2.D1 E3.E2.D1" },
7705 { "root//elem[index()>0 $and$ $not$ end()]", "E2.E2.D1 E3.E2.D1" },
7706 { "root//elem[index()>0 && $not$ end()]", "E2.E2.D1 E3.E2.D1" },
7710 static const xslpattern_test_t xslpattern_test_no_ns
[] = {
7711 /* prefixes don't need to be registered, you may use them as they are in the doc */
7712 { "//bar:x", "E5.E1.E4.E1.E2.D1 E6.E2.E4.E1.E2.D1" },
7713 /* prefixes must be explicitly specified in the name */
7714 { "//foo:elem", "" },
7715 { "//foo:c", "E3.E4.E2.D1" },
7719 static const xslpattern_test_t xslpattern_test_func
[] = {
7720 { "attribute()", "" },
7721 { "attribute('depth')", "" },
7722 { "root/attribute('depth')", "A'depth'.E3.D1" },
7723 { "//x/attribute()", "A'id'.E3.E3.D1 A'depth'.E3.E3.D1" },
7724 { "//x//attribute(id)", NULL
},
7725 { "//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" },
7726 { "comment()", "C2.D1" },
7727 { "//comment()", "C2.D1 C1.E3.D1 C2.E3.E3.D1 C2.E4.E3.D1" },
7728 { "element()", "E3.D1" },
7729 { "root/y/element()", "E4.E4.E3.D1 E5.E4.E3.D1 E6.E4.E3.D1" },
7730 { "//element(a)", NULL
},
7731 { "//element('a')", "E4.E3.E3.D1 E4.E4.E3.D1" },
7732 { "node()", "P1.D1 C2.D1 E3.D1" },
7733 { "//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" },
7734 { "//x/node()[nodeType()=1]", "E4.E3.E3.D1 E5.E3.E3.D1 E6.E3.E3.D1" },
7735 { "//x/node()[nodeType()=3]", "T3.E3.E3.D1" },
7736 { "//x/node()[nodeType()=7]", "P1.E3.E3.D1" },
7737 { "//x/node()[nodeType()=8]", "C2.E3.E3.D1" },
7738 { "pi()", "P1.D1" },
7739 { "//y/pi()", "P1.E4.E3.D1" },
7740 { "root/textnode()", "T2.E3.D1" },
7741 { "root/element()/textnode()", "T3.E3.E3.D1 T3.E4.E3.D1" },
7745 static void test_XSLPattern(void)
7747 const xslpattern_test_t
*ptr
= xslpattern_test
;
7748 IXMLDOMDocument2
*doc
;
7749 IXMLDOMNodeList
*list
;
7754 doc
= create_document(&IID_IXMLDOMDocument2
);
7758 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
7759 EXPECT_HR(hr
, S_OK
);
7760 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7762 /* switch to XSLPattern */
7763 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern"));
7764 EXPECT_HR(hr
, S_OK
);
7766 /* XPath doesn't select elements with non-null default namespace with unqualified selectors, XSLPattern does */
7767 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("//elem/c"), &list
);
7768 EXPECT_HR(hr
, S_OK
);
7771 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7772 EXPECT_HR(hr
, S_OK
);
7773 /* should select <elem><c> and <elem xmlns='...'><c> but not <elem><foo:c> */
7774 ok(len
== 3, "expected 3 entries in list, got %d\n", len
);
7775 IXMLDOMNodeList_Release(list
);
7780 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_(ptr
->query
), &list
);
7781 ok(hr
== S_OK
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
7783 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7784 ok(len
!= 0, "query=%s, empty list\n", ptr
->query
);
7786 expect_list_and_release(list
, ptr
->list
);
7791 /* namespace handling */
7792 /* no registered namespaces */
7793 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_(""));
7794 EXPECT_HR(hr
, S_OK
);
7796 ptr
= xslpattern_test_no_ns
;
7800 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_(ptr
->query
), &list
);
7801 ok(hr
== S_OK
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
7806 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7807 EXPECT_HR(hr
, S_OK
);
7808 ok(len
!= 0, "query=%s, empty list\n", ptr
->query
);
7813 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7814 EXPECT_HR(hr
, S_OK
);
7815 ok(len
== 0, "query=%s, empty list\n", ptr
->query
);
7818 expect_list_and_release(list
, ptr
->list
);
7823 /* explicitly register prefix foo */
7824 ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:foo='urn:uuid:86B2F87F-ACB6-45cd-8B77-9BDB92A01A29'")));
7826 /* now we get the same behavior as XPath */
7827 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
);
7828 EXPECT_HR(hr
, S_OK
);
7830 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7831 EXPECT_HR(hr
, S_OK
);
7832 ok(len
!= 0, "expected filled list\n");
7834 expect_list_and_release(list
, "E3.E3.E2.D1 E3.E4.E2.D1");
7836 /* set prefix foo to some nonexistent namespace */
7837 hr
= IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:foo='urn:nonexistent-foo'"));
7838 EXPECT_HR(hr
, S_OK
);
7840 /* the registered prefix takes precedence */
7841 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_("//foo:c"), &list
);
7842 EXPECT_HR(hr
, S_OK
);
7844 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7845 EXPECT_HR(hr
, S_OK
);
7846 ok(len
== 0, "expected empty list\n");
7847 IXMLDOMNodeList_Release(list
);
7849 IXMLDOMDocument2_Release(doc
);
7851 doc
= create_document(&IID_IXMLDOMDocument2
);
7854 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szNodeTypesXML
), &b
);
7855 EXPECT_HR(hr
, S_OK
);
7856 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
7858 ptr
= xslpattern_test_func
;
7862 hr
= IXMLDOMDocument2_selectNodes(doc
, _bstr_(ptr
->query
), &list
);
7865 ok(hr
== S_OK
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
7867 hr
= IXMLDOMNodeList_get_length(list
, &len
);
7870 ok(len
!= 0, "query=%s, empty list\n", ptr
->query
);
7872 expect_list_and_release(list
, ptr
->list
);
7875 ok(len
== 0, "query=%s, filled list\n", ptr
->query
);
7878 ok(hr
== E_FAIL
, "query=%s, failed with 0x%08x\n", ptr
->query
, hr
);
7883 IXMLDOMDocument2_Release(doc
);
7887 static void test_splitText(void)
7889 IXMLDOMCDATASection
*cdata
;
7890 IXMLDOMElement
*root
;
7891 IXMLDOMDocument
*doc
;
7892 IXMLDOMText
*text
, *text2
;
7895 VARIANT_BOOL success
;
7899 doc
= create_document(&IID_IXMLDOMDocument
);
7902 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_("<root></root>"), &success
);
7903 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7905 hr
= IXMLDOMDocument_get_documentElement(doc
, &root
);
7906 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7908 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("beautiful plumage"), &cdata
);
7909 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7911 V_VT(&var
) = VT_EMPTY
;
7912 hr
= IXMLDOMElement_appendChild(root
, (IXMLDOMNode
*)cdata
, NULL
);
7913 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7916 hr
= IXMLDOMCDATASection_get_length(cdata
, &length
);
7917 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7918 ok(length
> 0, "got %d\n", length
);
7920 hr
= IXMLDOMCDATASection_splitText(cdata
, 0, NULL
);
7921 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7923 text
= (void*)0xdeadbeef;
7924 /* negative offset */
7925 hr
= IXMLDOMCDATASection_splitText(cdata
, -1, &text
);
7926 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7927 ok(text
== (void*)0xdeadbeef, "got %p\n", text
);
7929 text
= (void*)0xdeadbeef;
7930 /* offset outside data */
7931 hr
= IXMLDOMCDATASection_splitText(cdata
, length
+ 1, &text
);
7932 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7933 ok(text
== 0, "got %p\n", text
);
7935 text
= (void*)0xdeadbeef;
7936 /* offset outside data */
7937 hr
= IXMLDOMCDATASection_splitText(cdata
, length
, &text
);
7938 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7939 ok(text
== 0, "got %p\n", text
);
7941 /* no empty node created */
7942 node
= (void*)0xdeadbeef;
7943 hr
= IXMLDOMCDATASection_get_nextSibling(cdata
, &node
);
7944 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7945 ok(node
== 0, "got %p\n", text
);
7947 hr
= IXMLDOMCDATASection_splitText(cdata
, 10, &text
);
7948 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7951 hr
= IXMLDOMText_get_length(text
, &length
);
7952 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7953 ok(length
== 7, "got %d\n", length
);
7955 hr
= IXMLDOMCDATASection_get_nextSibling(cdata
, &node
);
7956 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7957 IXMLDOMNode_Release(node
);
7959 /* split new text node */
7960 hr
= IXMLDOMText_get_length(text
, &length
);
7961 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7963 node
= (void*)0xdeadbeef;
7964 hr
= IXMLDOMText_get_nextSibling(text
, &node
);
7965 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7966 ok(node
== 0, "got %p\n", text
);
7968 hr
= IXMLDOMText_splitText(text
, 0, NULL
);
7969 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7971 text2
= (void*)0xdeadbeef;
7972 /* negative offset */
7973 hr
= IXMLDOMText_splitText(text
, -1, &text2
);
7974 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7975 ok(text2
== (void*)0xdeadbeef, "got %p\n", text2
);
7977 text2
= (void*)0xdeadbeef;
7978 /* offset outside data */
7979 hr
= IXMLDOMText_splitText(text
, length
+ 1, &text2
);
7980 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
7981 ok(text2
== 0, "got %p\n", text2
);
7983 text2
= (void*)0xdeadbeef;
7984 /* offset outside data */
7985 hr
= IXMLDOMText_splitText(text
, length
, &text2
);
7986 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
7987 ok(text2
== 0, "got %p\n", text
);
7990 hr
= IXMLDOMText_splitText(text
, 4, &text2
);
7991 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7992 if (text2
) IXMLDOMText_Release(text2
);
7995 hr
= IXMLDOMText_get_nextSibling(text
, &node
);
7996 todo_wine
ok(hr
== S_OK
, "got 0x%08x\n", hr
);
7997 if (node
) IXMLDOMNode_Release(node
);
7999 IXMLDOMText_Release(text
);
8000 IXMLDOMElement_Release(root
);
8001 IXMLDOMCDATASection_Release(cdata
);
8011 /* default_ns_doc used */
8012 static const ns_item_t qualified_item_tests
[] = {
8013 { "xml:lang", NULL
, S_FALSE
},
8014 { "xml:lang", "http://www.w3.org/XML/1998/namespace", S_FALSE
},
8015 { "lang", "http://www.w3.org/XML/1998/namespace", S_OK
},
8016 { "ns:b", NULL
, S_FALSE
},
8017 { "ns:b", "nshref", S_FALSE
},
8018 { "b", "nshref", S_OK
},
8019 { "d", NULL
, S_OK
},
8023 static const ns_item_t named_item_tests
[] = {
8024 { "xml:lang", NULL
, S_OK
},
8025 { "lang", NULL
, S_FALSE
},
8026 { "ns:b", NULL
, S_OK
},
8027 { "b", NULL
, S_FALSE
},
8028 { "d", NULL
, S_OK
},
8032 static void test_getQualifiedItem(void)
8034 IXMLDOMNode
*pr_node
, *node
;
8035 IXMLDOMNodeList
*root_list
;
8036 IXMLDOMNamedNodeMap
*map
;
8037 IXMLDOMElement
*element
;
8038 const ns_item_t
* ptr
;
8039 IXMLDOMDocument
*doc
;
8044 doc
= create_document(&IID_IXMLDOMDocument
);
8047 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
8048 EXPECT_HR(hr
, S_OK
);
8049 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8051 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
8052 EXPECT_HR(hr
, S_OK
);
8054 hr
= IXMLDOMElement_get_childNodes(element
, &root_list
);
8055 EXPECT_HR(hr
, S_OK
);
8057 hr
= IXMLDOMNodeList_get_item(root_list
, 1, &pr_node
);
8058 EXPECT_HR(hr
, S_OK
);
8059 IXMLDOMNodeList_Release(root_list
);
8061 hr
= IXMLDOMNode_get_attributes(pr_node
, &map
);
8062 EXPECT_HR(hr
, S_OK
);
8063 IXMLDOMNode_Release(pr_node
);
8066 hr
= IXMLDOMNamedNodeMap_get_length(map
, &len
);
8067 EXPECT_HR(hr
, S_OK
);
8068 ok( len
== 3, "length %d\n", len
);
8070 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, NULL
, NULL
, NULL
);
8071 EXPECT_HR(hr
, E_INVALIDARG
);
8073 node
= (void*)0xdeadbeef;
8074 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, NULL
, NULL
, &node
);
8075 EXPECT_HR(hr
, E_INVALIDARG
);
8076 ok( node
== (void*)0xdeadbeef, "got %p\n", node
);
8078 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
8079 EXPECT_HR(hr
, E_INVALIDARG
);
8081 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_("id"), NULL
, &node
);
8082 EXPECT_HR(hr
, S_OK
);
8084 IXMLDOMNode_Release(node
);
8085 IXMLDOMNamedNodeMap_Release(map
);
8086 IXMLDOMElement_Release(element
);
8088 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(default_ns_doc
), &b
);
8089 EXPECT_HR(hr
, S_OK
);
8091 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("a"), &node
);
8092 EXPECT_HR(hr
, S_OK
);
8094 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&element
);
8095 EXPECT_HR(hr
, S_OK
);
8096 IXMLDOMNode_Release(node
);
8098 hr
= IXMLDOMElement_get_attributes(element
, &map
);
8099 EXPECT_HR(hr
, S_OK
);
8101 ptr
= qualified_item_tests
;
8104 node
= (void*)0xdeadbeef;
8105 hr
= IXMLDOMNamedNodeMap_getQualifiedItem(map
, _bstr_(ptr
->name
), _bstr_(ptr
->uri
), &node
);
8106 ok(hr
== ptr
->hr
, "%s, %s: got 0x%08x, expected 0x%08x\n", ptr
->name
, ptr
->uri
, hr
, ptr
->hr
);
8108 IXMLDOMNode_Release(node
);
8110 ok(node
== NULL
, "%s, %s: got %p\n", ptr
->name
, ptr
->uri
, node
);
8114 ptr
= named_item_tests
;
8117 node
= (void*)0xdeadbeef;
8118 hr
= IXMLDOMNamedNodeMap_getNamedItem(map
, _bstr_(ptr
->name
), &node
);
8119 ok(hr
== ptr
->hr
, "%s: got 0x%08x, expected 0x%08x\n", ptr
->name
, hr
, ptr
->hr
);
8121 IXMLDOMNode_Release(node
);
8123 ok(node
== NULL
, "%s: got %p\n", ptr
->name
, node
);
8127 IXMLDOMNamedNodeMap_Release(map
);
8129 IXMLDOMElement_Release(element
);
8130 IXMLDOMDocument_Release(doc
);
8134 static void test_removeQualifiedItem(void)
8136 IXMLDOMDocument
*doc
;
8137 IXMLDOMElement
*element
;
8138 IXMLDOMNode
*pr_node
, *node
;
8139 IXMLDOMNodeList
*root_list
;
8140 IXMLDOMNamedNodeMap
*map
;
8145 doc
= create_document(&IID_IXMLDOMDocument
);
8148 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
8149 ok( hr
== S_OK
, "loadXML failed\n");
8150 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8152 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
8153 ok( hr
== S_OK
, "ret %08x\n", hr
);
8155 hr
= IXMLDOMElement_get_childNodes(element
, &root_list
);
8156 ok( hr
== S_OK
, "ret %08x\n", hr
);
8158 hr
= IXMLDOMNodeList_get_item(root_list
, 1, &pr_node
);
8159 ok( hr
== S_OK
, "ret %08x\n", hr
);
8160 IXMLDOMNodeList_Release(root_list
);
8162 hr
= IXMLDOMNode_get_attributes(pr_node
, &map
);
8163 ok( hr
== S_OK
, "ret %08x\n", hr
);
8164 IXMLDOMNode_Release(pr_node
);
8166 hr
= IXMLDOMNamedNodeMap_get_length(map
, &len
);
8167 ok( hr
== S_OK
, "ret %08x\n", hr
);
8168 ok( len
== 3, "length %d\n", len
);
8170 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, NULL
, NULL
, NULL
);
8171 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
8173 node
= (void*)0xdeadbeef;
8174 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, NULL
, NULL
, &node
);
8175 ok( hr
== E_INVALIDARG
, "ret %08x\n", hr
);
8176 ok( node
== (void*)0xdeadbeef, "got %p\n", node
);
8178 /* out pointer is optional */
8179 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
8180 ok( hr
== S_OK
, "ret %08x\n", hr
);
8182 /* already removed */
8183 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("id"), NULL
, NULL
);
8184 ok( hr
== S_FALSE
, "ret %08x\n", hr
);
8186 hr
= IXMLDOMNamedNodeMap_removeQualifiedItem(map
, _bstr_("vr"), NULL
, &node
);
8187 ok( hr
== S_OK
, "ret %08x\n", hr
);
8188 IXMLDOMNode_Release(node
);
8190 IXMLDOMNamedNodeMap_Release( map
);
8191 IXMLDOMElement_Release( element
);
8192 IXMLDOMDocument_Release( doc
);
8196 #define check_default_props(doc) _check_default_props(__LINE__, doc)
8197 static inline void _check_default_props(int line
, IXMLDOMDocument2
* doc
)
8204 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionLanguage"), &var
));
8205 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("XSLPattern")) == 0, "expected XSLPattern\n");
8208 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
8209 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("")) == 0, "expected empty string\n");
8212 helper_ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc
, &b
));
8213 ok_(__FILE__
, line
)(b
== VARIANT_FALSE
, "expected FALSE\n");
8215 hr
= IXMLDOMDocument2_get_schemas(doc
, &var
);
8216 ok_(__FILE__
, line
)(hr
== S_FALSE
, "got %08x\n", hr
);
8220 #define check_set_props(doc) _check_set_props(__LINE__, doc)
8221 static inline void _check_set_props(int line
, IXMLDOMDocument2
* doc
)
8227 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionLanguage"), &var
));
8228 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("XPath")) == 0, "expected XPath\n");
8231 helper_ole_check(IXMLDOMDocument2_getProperty(doc
, _bstr_("SelectionNamespaces"), &var
));
8232 ok_(__FILE__
, line
)(lstrcmpW(V_BSTR(&var
), _bstr_("xmlns:wi=\'www.winehq.org\'")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&var
)));
8235 helper_ole_check(IXMLDOMDocument2_get_preserveWhiteSpace(doc
, &b
));
8236 ok_(__FILE__
, line
)(b
== VARIANT_TRUE
, "expected TRUE\n");
8238 helper_ole_check(IXMLDOMDocument2_get_schemas(doc
, &var
));
8239 ok_(__FILE__
, line
)(V_VT(&var
) != VT_NULL
, "expected pointer\n");
8243 #define set_props(doc, cache) _set_props(__LINE__, doc, cache)
8244 static inline void _set_props(int line
, IXMLDOMDocument2
* doc
, IXMLDOMSchemaCollection
* cache
)
8249 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XPath")));
8250 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("xmlns:wi=\'www.winehq.org\'")));
8251 helper_ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc
, VARIANT_TRUE
));
8252 V_VT(&var
) = VT_DISPATCH
;
8253 V_DISPATCH(&var
) = NULL
;
8254 helper_ole_check(IXMLDOMSchemaCollection_QueryInterface(cache
, &IID_IDispatch
, (void**)&V_DISPATCH(&var
)));
8255 ok_(__FILE__
, line
)(V_DISPATCH(&var
) != NULL
, "expected pointer\n");
8256 helper_ole_check(IXMLDOMDocument2_putref_schemas(doc
, var
));
8260 #define unset_props(doc) _unset_props(__LINE__, doc)
8261 static inline void _unset_props(int line
, IXMLDOMDocument2
* doc
)
8266 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionLanguage"), _variantbstr_("XSLPattern")));
8267 helper_ole_check(IXMLDOMDocument2_setProperty(doc
, _bstr_("SelectionNamespaces"), _variantbstr_("")));
8268 helper_ole_check(IXMLDOMDocument2_put_preserveWhiteSpace(doc
, VARIANT_FALSE
));
8269 V_VT(&var
) = VT_NULL
;
8270 helper_ole_check(IXMLDOMDocument2_putref_schemas(doc
, var
));
8274 static void test_get_ownerDocument(void)
8276 IXMLDOMDocument
*doc1
, *doc2
, *doc3
;
8277 IXMLDOMDocument2
*doc
, *doc_owner
;
8279 IXMLDOMSchemaCollection
*cache
;
8283 doc
= create_document(&IID_IXMLDOMDocument2
);
8284 cache
= create_cache(&IID_IXMLDOMSchemaCollection
);
8287 if (doc
) IXMLDOMDocument2_Release(doc
);
8288 if (cache
) IXMLDOMSchemaCollection_Release(cache
);
8294 ole_check(IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
));
8295 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
8297 check_default_props(doc
);
8299 /* set properties and check that new instances use them */
8300 set_props(doc
, cache
);
8301 check_set_props(doc
);
8303 ole_check(IXMLDOMDocument2_get_firstChild(doc
, &node
));
8304 ole_check(IXMLDOMNode_get_ownerDocument(node
, &doc1
));
8306 /* new interface keeps props */
8307 ole_check(IXMLDOMDocument_QueryInterface(doc1
, &IID_IXMLDOMDocument2
, (void**)&doc_owner
));
8308 ok( doc_owner
!= doc
, "got %p, doc %p\n", doc_owner
, doc
);
8309 check_set_props(doc_owner
);
8310 IXMLDOMDocument2_Release(doc_owner
);
8312 ole_check(IXMLDOMNode_get_ownerDocument(node
, &doc2
));
8313 IXMLDOMNode_Release(node
);
8315 ok(doc1
!= doc2
, "got %p, expected %p. original %p\n", doc2
, doc1
, doc
);
8318 ole_check(IXMLDOMDocument2_loadXML(doc
, _bstr_(complete4A
), &b
));
8319 ok(b
== VARIANT_TRUE
, "failed to load XML string\n");
8321 /* properties retained even after reload */
8322 check_set_props(doc
);
8324 ole_check(IXMLDOMDocument2_get_firstChild(doc
, &node
));
8325 ole_check(IXMLDOMNode_get_ownerDocument(node
, &doc3
));
8326 IXMLDOMNode_Release(node
);
8328 ole_check(IXMLDOMDocument_QueryInterface(doc3
, &IID_IXMLDOMDocument2
, (void**)&doc_owner
));
8329 ok(doc3
!= doc1
&& doc3
!= doc2
&& doc_owner
!= doc
, "got %p, (%p, %p, %p)\n", doc3
, doc
, doc1
, doc2
);
8330 check_set_props(doc_owner
);
8332 /* changing properties for one instance changes them for all */
8333 unset_props(doc_owner
);
8334 check_default_props(doc_owner
);
8335 check_default_props(doc
);
8337 IXMLDOMSchemaCollection_Release(cache
);
8338 IXMLDOMDocument_Release(doc1
);
8339 IXMLDOMDocument_Release(doc2
);
8340 IXMLDOMDocument_Release(doc3
);
8341 IXMLDOMDocument2_Release(doc
);
8342 IXMLDOMDocument2_Release(doc_owner
);
8346 static void test_setAttributeNode(void)
8348 IXMLDOMDocument
*doc
, *doc2
;
8349 IXMLDOMElement
*elem
, *elem2
;
8350 IXMLDOMAttribute
*attr
, *attr2
, *ret_attr
;
8357 doc
= create_document(&IID_IXMLDOMDocument
);
8360 hr
= IXMLDOMDocument2_loadXML( doc
, _bstr_(complete4A
), &b
);
8361 ok( hr
== S_OK
, "loadXML failed\n");
8362 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8364 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
8365 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8367 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem2
);
8368 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8369 ok( elem2
!= elem
, "got same instance\n");
8371 ret_attr
= (void*)0xdeadbeef;
8372 hr
= IXMLDOMElement_setAttributeNode(elem
, NULL
, &ret_attr
);
8373 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8374 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
8376 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
8377 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8379 ref1
= IXMLDOMElement_AddRef(elem
);
8380 IXMLDOMElement_Release(elem
);
8382 ret_attr
= (void*)0xdeadbeef;
8383 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
8384 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8385 ok( ret_attr
== NULL
, "got %p\n", ret_attr
);
8387 /* no reference added */
8388 ref2
= IXMLDOMElement_AddRef(elem
);
8389 IXMLDOMElement_Release(elem
);
8390 ok(ref2
== ref1
, "got %d, expected %d\n", ref2
, ref1
);
8392 EXPECT_CHILDREN(elem
);
8393 EXPECT_CHILDREN(elem2
);
8395 IXMLDOMElement_Release(elem2
);
8398 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("attr"), &attr2
);
8399 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8400 ok( attr2
!= attr
, "got same instance %p\n", attr2
);
8401 IXMLDOMAttribute_Release(attr2
);
8403 /* try to add it another time */
8404 ret_attr
= (void*)0xdeadbeef;
8405 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
8406 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8407 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
8409 IXMLDOMElement_Release(elem
);
8411 /* initially used element is released, attribute still 'has' a container */
8412 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
8413 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8414 ret_attr
= (void*)0xdeadbeef;
8415 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
8416 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8417 ok( ret_attr
== (void*)0xdeadbeef, "got %p\n", ret_attr
);
8418 IXMLDOMElement_Release(elem
);
8420 /* add attribute already attached to another document */
8421 doc2
= create_document(&IID_IXMLDOMDocument
);
8423 hr
= IXMLDOMDocument_loadXML( doc2
, _bstr_(complete4A
), &b
);
8424 ok( hr
== S_OK
, "loadXML failed\n");
8425 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8427 hr
= IXMLDOMDocument_get_documentElement(doc2
, &elem
);
8428 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8429 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, NULL
);
8430 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8431 IXMLDOMElement_Release(elem
);
8433 IXMLDOMAttribute_Release(attr
);
8435 /* create element, add attribute, see if it's copied or linked */
8436 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("test"), &elem
);
8437 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8440 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("attr"), &attr
);
8441 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8442 ok(attr
!= NULL
, "got %p\n", attr
);
8444 ref1
= IXMLDOMAttribute_AddRef(attr
);
8445 IXMLDOMAttribute_Release(attr
);
8448 V_BSTR(&v
) = _bstr_("attrvalue1");
8449 hr
= IXMLDOMAttribute_put_nodeValue(attr
, v
);
8450 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8453 hr
= IXMLDOMAttribute_get_xml(attr
, &str
);
8454 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8455 ok( lstrcmpW(str
, _bstr_("attr=\"attrvalue1\"")) == 0,
8456 "got %s\n", wine_dbgstr_w(str
));
8459 ret_attr
= (void*)0xdeadbeef;
8460 hr
= IXMLDOMElement_setAttributeNode(elem
, attr
, &ret_attr
);
8461 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8462 ok(ret_attr
== NULL
, "got %p\n", ret_attr
);
8464 /* attribute reference increased */
8465 ref2
= IXMLDOMAttribute_AddRef(attr
);
8466 IXMLDOMAttribute_Release(attr
);
8467 ok(ref1
== ref2
, "got %d, expected %d\n", ref2
, ref1
);
8469 hr
= IXMLDOMElement_get_xml(elem
, &str
);
8470 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8471 ok( lstrcmpW(str
, _bstr_("<test attr=\"attrvalue1\"/>")) == 0,
8472 "got %s\n", wine_dbgstr_w(str
));
8476 V_BSTR(&v
) = _bstr_("attrvalue2");
8477 hr
= IXMLDOMAttribute_put_nodeValue(attr
, v
);
8478 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8480 hr
= IXMLDOMElement_get_xml(elem
, &str
);
8481 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8482 todo_wine
ok( lstrcmpW(str
, _bstr_("<test attr=\"attrvalue2\"/>")) == 0,
8483 "got %s\n", wine_dbgstr_w(str
));
8486 IXMLDOMElement_Release(elem
);
8487 IXMLDOMAttribute_Release(attr
);
8488 IXMLDOMDocument_Release(doc2
);
8489 IXMLDOMDocument_Release(doc
);
8493 static void test_put_dataType(void)
8495 IXMLDOMCDATASection
*cdata
;
8496 IXMLDOMDocument
*doc
;
8500 doc
= create_document(&IID_IXMLDOMDocument
);
8503 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
8504 ok( hr
== S_OK
, "loadXML failed\n");
8505 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8507 hr
= IXMLDOMDocument_createCDATASection(doc
, _bstr_("test"), &cdata
);
8508 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8509 hr
= IXMLDOMCDATASection_put_dataType(cdata
, _bstr_("number"));
8510 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8511 hr
= IXMLDOMCDATASection_put_dataType(cdata
, _bstr_("string"));
8512 ok( hr
== E_FAIL
, "got 0x%08x\n", hr
);
8513 IXMLDOMCDATASection_Release(cdata
);
8515 IXMLDOMDocument_Release(doc
);
8519 static void test_createNode(void)
8521 IXMLDOMDocument
*doc
;
8522 IXMLDOMElement
*elem
;
8529 doc
= create_document(&IID_IXMLDOMDocument
);
8534 /* reference count tests */
8535 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem
);
8536 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8538 /* initial reference is 2 */
8540 EXPECT_REF(elem
, 2);
8541 ref
= IXMLDOMElement_Release(elem
);
8542 ok(ref
== 1, "got %d\n", ref
);
8543 /* it's released already, attempt to release now will crash it */
8546 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem
);
8547 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8548 todo_wine
EXPECT_REF(elem
, 2);
8549 IXMLDOMDocument_Release(doc
);
8550 todo_wine
EXPECT_REF(elem
, 2);
8551 IXMLDOMElement_Release(elem
);
8553 doc
= create_document(&IID_IXMLDOMDocument
);
8555 /* NODE_ELEMENT nodes */
8556 /* 1. specified namespace */
8558 V_I4(&v
) = NODE_ELEMENT
;
8560 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("ns1:test"), _bstr_("http://winehq.org"), &node
);
8561 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8563 hr
= IXMLDOMNode_get_prefix(node
, &prefix
);
8564 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8565 ok(lstrcmpW(prefix
, _bstr_("ns1")) == 0, "wrong prefix\n");
8566 SysFreeString(prefix
);
8567 IXMLDOMNode_Release(node
);
8569 /* 2. default namespace */
8570 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("test"), _bstr_("http://winehq.org/default"), &node
);
8571 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8572 prefix
= (void*)0xdeadbeef;
8573 hr
= IXMLDOMNode_get_prefix(node
, &prefix
);
8574 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8575 ok(prefix
== 0, "expected empty prefix, got %p\n", prefix
);
8577 hr
= IXMLDOMNode_get_xml(node
, &str
);
8578 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8579 ok( lstrcmpW(str
, _bstr_("<test xmlns=\"http://winehq.org/default\"/>")) == 0,
8580 "got %s\n", wine_dbgstr_w(str
));
8583 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
8584 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8586 V_VT(&var
) = VT_BSTR
;
8587 hr
= IXMLDOMElement_getAttribute(elem
, _bstr_("xmlns"), &var
);
8588 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8589 ok( V_VT(&var
) == VT_NULL
, "got %d\n", V_VT(&var
));
8592 hr
= IXMLDOMElement_get_namespaceURI(elem
, &str
);
8593 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8594 ok( lstrcmpW(str
, _bstr_("http://winehq.org/default")) == 0, "expected default namespace\n");
8597 IXMLDOMElement_Release(elem
);
8598 IXMLDOMNode_Release(node
);
8600 IXMLDOMDocument_Release(doc
);
8604 static const char get_prefix_doc
[] =
8605 "<?xml version=\"1.0\" ?>"
8606 "<a xmlns:ns1=\"ns1 href\" />";
8608 static void test_get_prefix(void)
8610 IXMLDOMDocumentFragment
*fragment
;
8611 IXMLDOMCDATASection
*cdata
;
8612 IXMLDOMElement
*element
;
8613 IXMLDOMComment
*comment
;
8614 IXMLDOMDocument
*doc
;
8619 doc
= create_document(&IID_IXMLDOMDocument
);
8622 /* nodes that can't support prefix */
8624 str
= (void*)0xdeadbeef;
8625 hr
= IXMLDOMDocument_get_prefix(doc
, &str
);
8626 EXPECT_HR(hr
, S_FALSE
);
8627 ok(str
== NULL
, "got %p\n", str
);
8629 hr
= IXMLDOMDocument_get_prefix(doc
, NULL
);
8630 EXPECT_HR(hr
, E_INVALIDARG
);
8633 hr
= IXMLDOMDocument_createCDATASection(doc
, NULL
, &cdata
);
8634 ok(hr
== S_OK
, "got %08x\n", hr
);
8636 str
= (void*)0xdeadbeef;
8637 hr
= IXMLDOMCDATASection_get_prefix(cdata
, &str
);
8638 ok(hr
== S_FALSE
, "got %08x\n", hr
);
8639 ok( str
== 0, "got %p\n", str
);
8641 hr
= IXMLDOMCDATASection_get_prefix(cdata
, NULL
);
8642 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
8643 IXMLDOMCDATASection_Release(cdata
);
8646 hr
= IXMLDOMDocument_createComment(doc
, NULL
, &comment
);
8647 ok(hr
== S_OK
, "got %08x\n", hr
);
8649 str
= (void*)0xdeadbeef;
8650 hr
= IXMLDOMComment_get_prefix(comment
, &str
);
8651 ok(hr
== S_FALSE
, "got %08x\n", hr
);
8652 ok( str
== 0, "got %p\n", str
);
8654 hr
= IXMLDOMComment_get_prefix(comment
, NULL
);
8655 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
8656 IXMLDOMComment_Release(comment
);
8659 hr
= IXMLDOMDocument_createDocumentFragment(doc
, &fragment
);
8660 ok(hr
== S_OK
, "got %08x\n", hr
);
8662 str
= (void*)0xdeadbeef;
8663 hr
= IXMLDOMDocumentFragment_get_prefix(fragment
, &str
);
8664 ok(hr
== S_FALSE
, "got %08x\n", hr
);
8665 ok( str
== 0, "got %p\n", str
);
8667 hr
= IXMLDOMDocumentFragment_get_prefix(fragment
, NULL
);
8668 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
8669 IXMLDOMDocumentFragment_Release(fragment
);
8672 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &element
);
8673 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8675 hr
= IXMLDOMElement_get_prefix(element
, NULL
);
8676 ok( hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8678 str
= (void*)0xdeadbeef;
8679 hr
= IXMLDOMElement_get_prefix(element
, &str
);
8680 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8681 ok( str
== 0, "got %p\n", str
);
8683 IXMLDOMElement_Release(element
);
8686 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("a:elem"), &element
);
8687 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8689 str
= (void*)0xdeadbeef;
8690 hr
= IXMLDOMElement_get_prefix(element
, &str
);
8691 ok( hr
== S_OK
, "got 0x%08x\n", hr
);
8692 ok( lstrcmpW(str
, _bstr_("a")) == 0, "expected prefix \"a\"\n");
8695 str
= (void*)0xdeadbeef;
8696 hr
= IXMLDOMElement_get_namespaceURI(element
, &str
);
8697 ok( hr
== S_FALSE
, "got 0x%08x\n", hr
);
8698 ok( str
== 0, "got %p\n", str
);
8700 IXMLDOMElement_Release(element
);
8702 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(get_prefix_doc
), &b
);
8703 EXPECT_HR(hr
, S_OK
);
8705 hr
= IXMLDOMDocument_get_documentElement(doc
, &element
);
8706 EXPECT_HR(hr
, S_OK
);
8708 str
= (void*)0xdeadbeef;
8709 hr
= IXMLDOMElement_get_prefix(element
, &str
);
8710 EXPECT_HR(hr
, S_FALSE
);
8711 ok(str
== NULL
, "got %p\n", str
);
8713 str
= (void*)0xdeadbeef;
8714 hr
= IXMLDOMElement_get_namespaceURI(element
, &str
);
8715 EXPECT_HR(hr
, S_FALSE
);
8716 ok(str
== NULL
, "got %s\n", wine_dbgstr_w(str
));
8718 IXMLDOMDocument_Release(doc
);
8722 static void test_selectSingleNode(void)
8724 IXMLDOMDocument
*doc
;
8725 IXMLDOMNodeList
*list
;
8731 doc
= create_document(&IID_IXMLDOMDocument
);
8734 hr
= IXMLDOMDocument_selectSingleNode(doc
, NULL
, NULL
);
8735 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8737 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, NULL
);
8738 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8740 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(complete4A
), &b
);
8741 ok( hr
== S_OK
, "loadXML failed\n");
8742 ok( b
== VARIANT_TRUE
, "failed to load XML string\n");
8744 hr
= IXMLDOMDocument_selectSingleNode(doc
, NULL
, NULL
);
8745 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8747 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, NULL
);
8748 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8750 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc"), NULL
);
8751 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8753 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("lc"), NULL
);
8754 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8756 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("lc"), &node
);
8757 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8758 IXMLDOMNode_Release(node
);
8760 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("lc"), &list
);
8761 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8762 IXMLDOMNodeList_Release(list
);
8764 list
= (void*)0xdeadbeef;
8765 hr
= IXMLDOMDocument_selectNodes(doc
, NULL
, &list
);
8766 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
8767 ok(list
== (void*)0xdeadbeef, "got %p\n", list
);
8769 node
= (void*)0xdeadbeef;
8770 hr
= IXMLDOMDocument_selectSingleNode(doc
, _bstr_("nonexistent"), &node
);
8771 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8772 ok(node
== 0, "got %p\n", node
);
8774 list
= (void*)0xdeadbeef;
8775 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("nonexistent"), &list
);
8776 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8778 hr
= IXMLDOMNodeList_get_length(list
, &len
);
8779 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8780 ok(len
== 0, "got %d\n", len
);
8781 IXMLDOMNodeList_Release(list
);
8783 IXMLDOMDocument_Release(doc
);
8787 static void test_events(void)
8789 IConnectionPointContainer
*conn
;
8790 IConnectionPoint
*point
;
8791 IXMLDOMDocument
*doc
;
8796 doc
= create_document(&IID_IXMLDOMDocument
);
8799 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_IConnectionPointContainer
, (void**)&conn
);
8800 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8802 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &IID_IDispatch
, &point
);
8803 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8804 IConnectionPoint_Release(point
);
8805 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &IID_IPropertyNotifySink
, &point
);
8806 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8807 IConnectionPoint_Release(point
);
8808 hr
= IConnectionPointContainer_FindConnectionPoint(conn
, &DIID_XMLDOMDocumentEvents
, &point
);
8809 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8810 IConnectionPoint_Release(point
);
8812 IConnectionPointContainer_Release(conn
);
8814 /* ready state callback */
8816 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8817 ok(hr
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hr
);
8819 event
= create_dispevent();
8820 V_VT(&v
) = VT_UNKNOWN
;
8821 V_UNKNOWN(&v
) = (IUnknown
*)event
;
8823 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8824 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8825 EXPECT_REF(event
, 2);
8827 V_VT(&v
) = VT_DISPATCH
;
8828 V_DISPATCH(&v
) = event
;
8830 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8831 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8832 EXPECT_REF(event
, 2);
8834 /* VT_NULL doesn't reset event handler */
8836 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8837 ok(hr
== DISP_E_TYPEMISMATCH
, "got 0x%08x\n", hr
);
8838 EXPECT_REF(event
, 2);
8840 V_VT(&v
) = VT_DISPATCH
;
8841 V_DISPATCH(&v
) = NULL
;
8843 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8844 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8845 EXPECT_REF(event
, 1);
8847 V_VT(&v
) = VT_UNKNOWN
;
8848 V_DISPATCH(&v
) = NULL
;
8849 hr
= IXMLDOMDocument_put_onreadystatechange(doc
, v
);
8850 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8852 IDispatch_Release(event
);
8854 IXMLDOMDocument_Release(doc
);
8857 static void test_createProcessingInstruction(void)
8859 static const WCHAR bodyW
[] = {'t','e','s','t',0};
8860 IXMLDOMProcessingInstruction
*pi
;
8861 IXMLDOMDocument
*doc
;
8865 doc
= create_document(&IID_IXMLDOMDocument
);
8868 /* test for BSTR handling, pass broken BSTR */
8869 memcpy(&buff
[2], bodyW
, sizeof(bodyW
));
8870 /* just a big length */
8871 *(DWORD
*)buff
= 0xf0f0;
8872 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("test"), &buff
[2], &pi
);
8873 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8875 IXMLDOMProcessingInstruction_Release(pi
);
8876 IXMLDOMDocument_Release(doc
);
8879 static void test_put_nodeTypedValue(void)
8881 IXMLDOMDocument
*doc
;
8882 IXMLDOMElement
*elem
;
8886 doc
= create_document(&IID_IXMLDOMDocument
);
8889 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("Element"), &elem
);
8890 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8892 V_VT(&type
) = VT_EMPTY
;
8893 hr
= IXMLDOMElement_get_dataType(elem
, &type
);
8894 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8895 ok(V_VT(&type
) == VT_NULL
, "got %d, expected VT_NULL\n", V_VT(&type
));
8897 /* set typed value for untyped node */
8898 V_VT(&type
) = VT_I1
;
8900 hr
= IXMLDOMElement_put_nodeTypedValue(elem
, type
);
8901 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8903 V_VT(&type
) = VT_EMPTY
;
8904 hr
= IXMLDOMElement_get_dataType(elem
, &type
);
8905 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
8906 ok(V_VT(&type
) == VT_NULL
, "got %d, expected VT_NULL\n", V_VT(&type
));
8908 /* no type info stored */
8909 V_VT(&type
) = VT_EMPTY
;
8910 hr
= IXMLDOMElement_get_nodeTypedValue(elem
, &type
);
8911 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8912 ok(V_VT(&type
) == VT_BSTR
, "got %d, expected VT_BSTR\n", V_VT(&type
));
8913 ok(memcmp(V_BSTR(&type
), _bstr_("1"), 2*sizeof(WCHAR
)) == 0,
8914 "got %s, expected \"1\"\n", wine_dbgstr_w(V_BSTR(&type
)));
8915 VariantClear(&type
);
8917 IXMLDOMElement_Release(elem
);
8918 IXMLDOMDocument_Release(doc
);
8922 static void test_get_xml(void)
8924 static const char xmlA
[] = "<?xml version=\"1.0\" encoding=\"UTF-16\"?>\r\n<a>test</a>\r\n";
8925 static const char fooA
[] = "<foo/>";
8926 IXMLDOMProcessingInstruction
*pi
;
8928 IXMLDOMElement
*elem
= NULL
;
8929 IXMLDOMDocument
*doc
;
8935 doc
= create_document(&IID_IXMLDOMDocument
);
8939 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_("<a>test</a>"), &b
);
8940 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8941 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
8943 hr
= IXMLDOMDocument_createProcessingInstruction(doc
, _bstr_("xml"),
8944 _bstr_("version=\"1.0\" encoding=\"UTF-16\""), &pi
);
8945 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8947 hr
= IXMLDOMDocument_get_firstChild(doc
, &first
);
8948 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8950 V_UNKNOWN(&v
) = (IUnknown
*)first
;
8951 V_VT(&v
) = VT_UNKNOWN
;
8953 hr
= IXMLDOMDocument_insertBefore(doc
, (IXMLDOMNode
*)pi
, v
, NULL
);
8954 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8956 IXMLDOMProcessingInstruction_Release(pi
);
8957 IXMLDOMNode_Release(first
);
8959 hr
= IXMLDOMDocument_get_xml(doc
, &xml
);
8960 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8962 ok(memcmp(xml
, _bstr_(xmlA
), sizeof(xmlA
)*sizeof(WCHAR
)) == 0,
8963 "got %s, expected %s\n", wine_dbgstr_w(xml
), xmlA
);
8966 IXMLDOMDocument_Release(doc
);
8968 doc
= create_document(&IID_IXMLDOMDocument
);
8970 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("foo"), &elem
);
8971 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8973 hr
= IXMLDOMDocument_putref_documentElement(doc
, elem
);
8974 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8976 hr
= IXMLDOMDocument_get_xml(doc
, &xml
);
8977 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
8979 ok(memcmp(xml
, _bstr_(fooA
), (sizeof(fooA
)-1)*sizeof(WCHAR
)) == 0,
8980 "got %s, expected %s\n", wine_dbgstr_w(xml
), fooA
);
8983 IXMLDOMElement_Release(elem
);
8984 IXMLDOMDocument_Release(doc
);
8989 static void test_xsltemplate(void)
8991 IXSLTemplate
*template;
8992 IXSLProcessor
*processor
;
8993 IXMLDOMDocument
*doc
, *doc2
;
9000 template = create_xsltemplate(&IID_IXSLTemplate
);
9001 if (!template) return;
9003 /* works as reset */
9004 hr
= IXSLTemplate_putref_stylesheet(template, NULL
);
9005 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9007 doc
= create_document(&IID_IXMLDOMDocument
);
9010 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_("<a>test</a>"), &b
);
9011 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9012 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
9014 /* putref with non-xsl document */
9015 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
9016 todo_wine
ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9019 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(szTransformSSXML
), &b
);
9020 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9021 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
9023 /* not a freethreaded document */
9024 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
9025 todo_wine
ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9027 IXMLDOMDocument_Release(doc
);
9029 hr
= CoCreateInstance(&CLSID_FreeThreadedDOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
9032 win_skip("failed to create free threaded document instance: 0x%08x\n", hr
);
9033 IXSLTemplate_Release(template);
9038 hr
= IXMLDOMDocument_loadXML( doc
, _bstr_(szTransformSSXML
), &b
);
9039 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9040 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
9042 /* freethreaded document */
9043 ref1
= IXMLDOMDocument_AddRef(doc
);
9044 IXMLDOMDocument_Release(doc
);
9045 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
9046 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9047 ref2
= IXMLDOMDocument_AddRef(doc
);
9048 IXMLDOMDocument_Release(doc
);
9049 ok(ref2
> ref1
, "got %d\n", ref2
);
9052 hr
= IXSLTemplate_createProcessor(template, NULL
);
9053 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9055 EXPECT_REF(template, 1);
9056 hr
= IXSLTemplate_createProcessor(template, &processor
);
9057 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9058 EXPECT_REF(template, 2);
9060 /* input no set yet */
9063 hr
= IXSLProcessor_get_input(processor
, &v
);
9065 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9066 ok(V_VT(&v
) == VT_EMPTY
, "got %d\n", V_VT(&v
));
9069 hr
= IXSLProcessor_get_output(processor
, NULL
);
9070 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9072 /* reset before it was set */
9073 V_VT(&v
) = VT_EMPTY
;
9074 hr
= IXSLProcessor_put_output(processor
, v
);
9075 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9077 CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
9078 EXPECT_REF(stream
, 1);
9080 V_VT(&v
) = VT_UNKNOWN
;
9081 V_UNKNOWN(&v
) = (IUnknown
*)stream
;
9082 hr
= IXSLProcessor_put_output(processor
, v
);
9083 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9085 /* it seems processor grabs 2 references */
9086 todo_wine
EXPECT_REF(stream
, 3);
9088 V_VT(&v
) = VT_EMPTY
;
9089 hr
= IXSLProcessor_get_output(processor
, &v
);
9090 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9091 ok(V_VT(&v
) == VT_UNKNOWN
, "got type %d\n", V_VT(&v
));
9092 ok(V_UNKNOWN(&v
) == (IUnknown
*)stream
, "got %p\n", V_UNKNOWN(&v
));
9094 todo_wine
EXPECT_REF(stream
, 4);
9097 hr
= IXSLProcessor_transform(processor
, NULL
);
9098 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9100 /* reset and check stream refcount */
9101 V_VT(&v
) = VT_EMPTY
;
9102 hr
= IXSLProcessor_put_output(processor
, v
);
9103 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9105 EXPECT_REF(stream
, 1);
9107 IStream_Release(stream
);
9109 /* no output interface set, check output */
9110 doc2
= create_document(&IID_IXMLDOMDocument
);
9113 hr
= IXMLDOMDocument_loadXML( doc2
, _bstr_("<a>test</a>"), &b
);
9114 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9115 ok( b
== VARIANT_TRUE
, "got %d\n", b
);
9117 V_VT(&v
) = VT_UNKNOWN
;
9118 V_UNKNOWN(&v
) = (IUnknown
*)doc2
;
9119 hr
= IXSLProcessor_put_input(processor
, v
);
9120 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9122 hr
= IXSLProcessor_transform(processor
, &b
);
9123 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9125 V_VT(&v
) = VT_EMPTY
;
9126 hr
= IXSLProcessor_get_output(processor
, &v
);
9127 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9128 ok(V_VT(&v
) == VT_BSTR
, "got type %d\n", V_VT(&v
));
9129 /* we currently output one '\n' instead of empty string */
9130 todo_wine
ok(lstrcmpW(V_BSTR(&v
), _bstr_("")) == 0, "got %s\n", wine_dbgstr_w(V_BSTR(&v
)));
9131 IXMLDOMDocument_Release(doc2
);
9134 IXSLProcessor_Release(processor
);
9136 /* drop reference */
9137 hr
= IXSLTemplate_putref_stylesheet(template, NULL
);
9138 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9139 ref2
= IXMLDOMDocument_AddRef(doc
);
9140 IXMLDOMDocument_Release(doc
);
9141 ok(ref2
== ref1
, "got %d\n", ref2
);
9143 IXMLDOMDocument_Release(doc
);
9144 IXSLTemplate_Release(template);
9148 static void test_insertBefore(void)
9150 IXMLDOMDocument
*doc
, *doc2
;
9151 IXMLDOMAttribute
*attr
;
9152 IXMLDOMElement
*elem1
, *elem2
, *elem3
, *elem4
, *elem5
;
9153 IXMLDOMNode
*node
, *newnode
;
9158 doc
= create_document(&IID_IXMLDOMDocument
);
9160 /* insertBefore behaviour for attribute node */
9162 V_I4(&v
) = NODE_ATTRIBUTE
;
9165 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("attr"), NULL
, (IXMLDOMNode
**)&attr
);
9166 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9167 ok(attr
!= NULL
, "got %p\n", attr
);
9169 /* attribute to attribute */
9171 V_I4(&v
) = NODE_ATTRIBUTE
;
9173 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("attr2"), NULL
, &newnode
);
9174 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9175 ok(newnode
!= NULL
, "got %p\n", newnode
);
9178 node
= (void*)0xdeadbeef;
9179 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
9180 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9181 ok(node
== NULL
, "got %p\n", node
);
9183 V_VT(&v
) = VT_UNKNOWN
;
9184 V_UNKNOWN(&v
) = (IUnknown
*)attr
;
9185 node
= (void*)0xdeadbeef;
9186 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
9187 todo_wine
ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9188 ok(node
== NULL
, "got %p\n", node
);
9189 IXMLDOMNode_Release(newnode
);
9191 /* cdata to attribute */
9193 V_I4(&v
) = NODE_CDATA_SECTION
;
9195 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
9196 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9197 ok(newnode
!= NULL
, "got %p\n", newnode
);
9200 node
= (void*)0xdeadbeef;
9201 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
9202 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9203 ok(node
== NULL
, "got %p\n", node
);
9204 IXMLDOMNode_Release(newnode
);
9206 /* comment to attribute */
9208 V_I4(&v
) = NODE_COMMENT
;
9210 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
9211 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9212 ok(newnode
!= NULL
, "got %p\n", newnode
);
9215 node
= (void*)0xdeadbeef;
9216 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
9217 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9218 ok(node
== NULL
, "got %p\n", node
);
9219 IXMLDOMNode_Release(newnode
);
9221 /* element to attribute */
9223 V_I4(&v
) = NODE_ELEMENT
;
9225 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
9226 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9227 ok(newnode
!= NULL
, "got %p\n", newnode
);
9230 node
= (void*)0xdeadbeef;
9231 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
9232 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9233 ok(node
== NULL
, "got %p\n", node
);
9234 IXMLDOMNode_Release(newnode
);
9236 /* pi to attribute */
9238 V_I4(&v
) = NODE_PROCESSING_INSTRUCTION
;
9240 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("cdata"), NULL
, &newnode
);
9241 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9242 ok(newnode
!= NULL
, "got %p\n", newnode
);
9245 node
= (void*)0xdeadbeef;
9246 hr
= IXMLDOMAttribute_insertBefore(attr
, newnode
, v
, &node
);
9247 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
9248 ok(node
== NULL
, "got %p\n", node
);
9249 IXMLDOMNode_Release(newnode
);
9250 IXMLDOMAttribute_Release(attr
);
9252 /* insertBefore for elements */
9253 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem1
);
9254 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9256 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem2"), &elem2
);
9257 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9259 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem3"), &elem3
);
9260 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9262 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem3"), &elem3
);
9263 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9265 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem4"), &elem4
);
9266 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9268 EXPECT_NO_CHILDREN(elem1
);
9269 EXPECT_NO_CHILDREN(elem2
);
9270 EXPECT_NO_CHILDREN(elem3
);
9272 todo_wine
EXPECT_REF(elem2
, 2);
9274 V_VT(&v
) = VT_DISPATCH
;
9275 V_DISPATCH(&v
) = NULL
;
9277 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem4
, v
, &node
);
9278 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9279 ok(node
== (void*)elem4
, "got %p\n", node
);
9281 EXPECT_CHILDREN(elem1
);
9282 hr
= IXMLDOMElement_removeChild(elem1
, (IXMLDOMNode
*)elem4
, NULL
);
9283 EXPECT_HR(hr
, S_OK
);
9284 IXMLDOMElement_Release(elem4
);
9286 EXPECT_NO_CHILDREN(elem1
);
9290 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, &node
);
9291 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9292 ok(node
== (void*)elem2
, "got %p\n", node
);
9294 EXPECT_CHILDREN(elem1
);
9295 todo_wine
EXPECT_REF(elem2
, 3);
9296 IXMLDOMNode_Release(node
);
9298 /* again for already linked node */
9301 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, &node
);
9302 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9303 ok(node
== (void*)elem2
, "got %p\n", node
);
9305 EXPECT_CHILDREN(elem1
);
9307 /* increments each time */
9308 todo_wine
EXPECT_REF(elem2
, 3);
9309 IXMLDOMNode_Release(node
);
9311 /* try to add to another element */
9313 node
= (void*)0xdeadbeef;
9314 hr
= IXMLDOMElement_insertBefore(elem3
, (IXMLDOMNode
*)elem2
, v
, &node
);
9315 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9316 ok(node
== (void*)elem2
, "got %p\n", node
);
9318 EXPECT_CHILDREN(elem3
);
9319 EXPECT_NO_CHILDREN(elem1
);
9321 IXMLDOMNode_Release(node
);
9323 /* cross document case - try to add as child to a node created with other doc */
9324 doc2
= create_document(&IID_IXMLDOMDocument
);
9326 hr
= IXMLDOMDocument_createElement(doc2
, _bstr_("elem4"), &elem4
);
9327 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9328 todo_wine
EXPECT_REF(elem4
, 2);
9330 /* same name, another instance */
9331 hr
= IXMLDOMDocument_createElement(doc2
, _bstr_("elem4"), &elem5
);
9332 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9333 todo_wine
EXPECT_REF(elem5
, 2);
9335 todo_wine
EXPECT_REF(elem3
, 2);
9338 hr
= IXMLDOMElement_insertBefore(elem3
, (IXMLDOMNode
*)elem4
, v
, &node
);
9339 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9340 ok(node
== (void*)elem4
, "got %p\n", node
);
9341 todo_wine
EXPECT_REF(elem4
, 3);
9342 todo_wine
EXPECT_REF(elem3
, 2);
9343 IXMLDOMNode_Release(node
);
9347 hr
= IXMLDOMElement_insertBefore(elem3
, (IXMLDOMNode
*)elem5
, v
, &node
);
9348 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9349 ok(node
== (void*)elem5
, "got %p\n", node
);
9350 todo_wine
EXPECT_REF(elem4
, 2);
9351 todo_wine
EXPECT_REF(elem5
, 3);
9352 IXMLDOMNode_Release(node
);
9354 IXMLDOMDocument_Release(doc2
);
9356 IXMLDOMElement_Release(elem1
);
9357 IXMLDOMElement_Release(elem2
);
9358 IXMLDOMElement_Release(elem3
);
9359 IXMLDOMElement_Release(elem4
);
9360 IXMLDOMElement_Release(elem5
);
9362 /* elements with same default namespace */
9364 V_I4(&v
) = NODE_ELEMENT
;
9366 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem1"), _bstr_("http://winehq.org/default"), (IXMLDOMNode
**)&elem1
);
9367 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9368 ok(elem1
!= NULL
, "got %p\n", elem1
);
9371 V_I4(&v
) = NODE_ELEMENT
;
9373 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem2"), _bstr_("http://winehq.org/default"), (IXMLDOMNode
**)&elem2
);
9374 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9375 ok(elem2
!= NULL
, "got %p\n", elem2
);
9377 /* check contents so far */
9379 hr
= IXMLDOMElement_get_xml(elem1
, &p
);
9380 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9381 ok(!lstrcmpW(p
, _bstr_("<elem1 xmlns=\"http://winehq.org/default\"/>")), "got %s\n", wine_dbgstr_w(p
));
9385 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
9386 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9387 ok(!lstrcmpW(p
, _bstr_("<elem2 xmlns=\"http://winehq.org/default\"/>")), "got %s\n", wine_dbgstr_w(p
));
9391 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, NULL
);
9392 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9394 /* get_xml depends on context, for top node it omits child namespace attribute,
9395 but at child level it's still returned */
9397 hr
= IXMLDOMElement_get_xml(elem1
, &p
);
9398 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9399 todo_wine
ok(!lstrcmpW(p
, _bstr_("<elem1 xmlns=\"http://winehq.org/default\"><elem2/></elem1>")),
9400 "got %s\n", wine_dbgstr_w(p
));
9404 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
9405 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9406 ok(!lstrcmpW(p
, _bstr_("<elem2 xmlns=\"http://winehq.org/default\"/>")), "got %s\n", wine_dbgstr_w(p
));
9409 IXMLDOMElement_Release(elem1
);
9410 IXMLDOMElement_Release(elem2
);
9412 /* child without default namespace added to node with default namespace */
9414 V_I4(&v
) = NODE_ELEMENT
;
9416 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem1"), _bstr_("http://winehq.org/default"), (IXMLDOMNode
**)&elem1
);
9417 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9418 ok(elem1
!= NULL
, "got %p\n", elem1
);
9421 V_I4(&v
) = NODE_ELEMENT
;
9423 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("elem2"), NULL
, (IXMLDOMNode
**)&elem2
);
9424 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9425 ok(elem2
!= NULL
, "got %p\n", elem2
);
9427 EXPECT_REF(elem2
, 1);
9429 hr
= IXMLDOMElement_insertBefore(elem1
, (IXMLDOMNode
*)elem2
, v
, NULL
);
9430 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9431 EXPECT_REF(elem2
, 1);
9434 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
9435 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9436 ok(!lstrcmpW(p
, _bstr_("<elem2/>")), "got %s\n", wine_dbgstr_w(p
));
9439 hr
= IXMLDOMElement_removeChild(elem1
, (IXMLDOMNode
*)elem2
, NULL
);
9440 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9443 hr
= IXMLDOMElement_get_xml(elem2
, &p
);
9444 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9445 ok(!lstrcmpW(p
, _bstr_("<elem2/>")), "got %s\n", wine_dbgstr_w(p
));
9448 IXMLDOMElement_Release(elem1
);
9449 IXMLDOMElement_Release(elem2
);
9450 IXMLDOMDocument_Release(doc
);
9453 static void test_appendChild(void)
9455 IXMLDOMDocument
*doc
, *doc2
;
9456 IXMLDOMElement
*elem
, *elem2
;
9459 doc
= create_document(&IID_IXMLDOMDocument
);
9460 doc2
= create_document(&IID_IXMLDOMDocument
);
9462 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("elem"), &elem
);
9463 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9465 hr
= IXMLDOMDocument_createElement(doc2
, _bstr_("elem2"), &elem2
);
9466 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9469 todo_wine
EXPECT_REF(elem
, 2);
9470 EXPECT_REF(doc2
, 1);
9471 todo_wine
EXPECT_REF(elem2
, 2);
9472 EXPECT_NO_CHILDREN(doc
);
9473 EXPECT_NO_CHILDREN(doc2
);
9475 /* append from another document */
9476 hr
= IXMLDOMDocument_appendChild(doc2
, (IXMLDOMNode
*)elem
, NULL
);
9477 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9480 todo_wine
EXPECT_REF(elem
, 2);
9481 EXPECT_REF(doc2
, 1);
9482 todo_wine
EXPECT_REF(elem2
, 2);
9483 EXPECT_NO_CHILDREN(doc
);
9484 EXPECT_CHILDREN(doc2
);
9486 IXMLDOMElement_Release(elem
);
9487 IXMLDOMElement_Release(elem2
);
9488 IXMLDOMDocument_Release(doc
);
9489 IXMLDOMDocument_Release(doc2
);
9492 static void test_get_doctype(void)
9494 IXMLDOMDocumentType
*doctype
;
9495 IXMLDOMDocument
*doc
;
9498 doc
= create_document(&IID_IXMLDOMDocument
);
9500 hr
= IXMLDOMDocument_get_doctype(doc
, NULL
);
9501 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9503 doctype
= (void*)0xdeadbeef;
9504 hr
= IXMLDOMDocument_get_doctype(doc
, &doctype
);
9505 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
9506 ok(doctype
== NULL
, "got %p\n", doctype
);
9508 IXMLDOMDocument_Release(doc
);
9511 static void test_get_tagName(void)
9513 IXMLDOMDocument
*doc
;
9514 IXMLDOMElement
*elem
, *elem2
;
9518 doc
= create_document(&IID_IXMLDOMDocument
);
9520 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("element"), &elem
);
9521 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9523 hr
= IXMLDOMElement_get_tagName(elem
, NULL
);
9524 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9527 hr
= IXMLDOMElement_get_tagName(elem
, &str
);
9528 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9529 ok(!lstrcmpW(str
, _bstr_("element")), "got %s\n", wine_dbgstr_w(str
));
9532 hr
= IXMLDOMDocument_createElement(doc
, _bstr_("s:element"), &elem2
);
9533 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9536 hr
= IXMLDOMElement_get_tagName(elem2
, &str
);
9537 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9538 ok(!lstrcmpW(str
, _bstr_("s:element")), "got %s\n", wine_dbgstr_w(str
));
9541 IXMLDOMDocument_Release(elem
);
9542 IXMLDOMDocument_Release(elem2
);
9543 IXMLDOMDocument_Release(doc
);
9554 static const node_type_t get_datatype
[] = {
9555 { NODE_ELEMENT
, "element", VT_NULL
, S_FALSE
},
9556 { NODE_ATTRIBUTE
, "attr", VT_NULL
, S_FALSE
},
9557 { NODE_TEXT
, "text", VT_NULL
, S_FALSE
},
9558 { NODE_CDATA_SECTION
, "cdata", VT_NULL
, S_FALSE
},
9559 { NODE_ENTITY_REFERENCE
, "entityref", VT_NULL
, S_FALSE
},
9560 { NODE_PROCESSING_INSTRUCTION
, "pi", VT_NULL
, S_FALSE
},
9561 { NODE_COMMENT
, "comment", VT_NULL
, S_FALSE
},
9562 { NODE_DOCUMENT_FRAGMENT
, "docfrag", VT_NULL
, S_FALSE
},
9566 static void test_get_dataType(void)
9568 const node_type_t
*entry
= get_datatype
;
9569 IXMLDOMDocument
*doc
;
9571 doc
= create_document(&IID_IXMLDOMDocument
);
9575 IXMLDOMNode
*node
= NULL
;
9580 V_I4(&var
) = entry
->type
;
9581 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_(entry
->name
), NULL
, &node
);
9582 ok(hr
== S_OK
, "failed to create node, type %d\n", entry
->type
);
9584 hr
= IXMLDOMNode_get_dataType(node
, NULL
);
9585 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9588 hr
= IXMLDOMNode_get_dataType(node
, &type
);
9589 ok(hr
== entry
->hr
, "got 0x%08x, expected 0x%08x. node type %d\n",
9590 hr
, entry
->hr
, entry
->type
);
9591 ok(V_VT(&type
) == entry
->vt
, "got %d, expected %d. node type %d\n",
9592 V_VT(&type
), entry
->vt
, entry
->type
);
9593 VariantClear(&type
);
9595 IXMLDOMNode_Release(node
);
9600 IXMLDOMDocument_Release(doc
);
9604 typedef struct _get_node_typestring_t
{
9607 } get_node_typestring_t
;
9609 static const get_node_typestring_t get_node_typestring
[] = {
9610 { NODE_ELEMENT
, "element" },
9611 { NODE_ATTRIBUTE
, "attribute" },
9612 { NODE_TEXT
, "text" },
9613 { NODE_CDATA_SECTION
, "cdatasection" },
9614 { NODE_ENTITY_REFERENCE
, "entityreference" },
9615 { NODE_PROCESSING_INSTRUCTION
, "processinginstruction" },
9616 { NODE_COMMENT
, "comment" },
9617 { NODE_DOCUMENT_FRAGMENT
, "documentfragment" },
9621 static void test_get_nodeTypeString(void)
9623 const get_node_typestring_t
*entry
= get_node_typestring
;
9624 IXMLDOMDocument
*doc
;
9628 doc
= create_document(&IID_IXMLDOMDocument
);
9630 hr
= IXMLDOMDocument_get_nodeTypeString(doc
, &str
);
9631 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9632 ok(!lstrcmpW(str
, _bstr_("document")), "got string %s\n", wine_dbgstr_w(str
));
9637 IXMLDOMNode
*node
= NULL
;
9641 V_I4(&var
) = entry
->type
;
9642 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("node"), NULL
, &node
);
9643 ok(hr
== S_OK
, "failed to create node, type %d\n", entry
->type
);
9645 hr
= IXMLDOMNode_get_nodeTypeString(node
, NULL
);
9646 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9648 hr
= IXMLDOMNode_get_nodeTypeString(node
, &str
);
9649 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
9650 ok(!lstrcmpW(str
, _bstr_(entry
->string
)), "got string %s, expected %s. node type %d\n",
9651 wine_dbgstr_w(str
), entry
->string
, entry
->type
);
9653 IXMLDOMNode_Release(node
);
9658 IXMLDOMDocument_Release(doc
);
9662 typedef struct _get_attributes_t
{
9667 static const get_attributes_t get_attributes
[] = {
9668 { NODE_ATTRIBUTE
, S_FALSE
},
9669 { NODE_TEXT
, S_FALSE
},
9670 { NODE_CDATA_SECTION
, S_FALSE
},
9671 { NODE_ENTITY_REFERENCE
, S_FALSE
},
9672 { NODE_PROCESSING_INSTRUCTION
, S_FALSE
},
9673 { NODE_COMMENT
, S_FALSE
},
9674 { NODE_DOCUMENT_FRAGMENT
, S_FALSE
},
9678 static void test_get_attributes(void)
9680 const get_attributes_t
*entry
= get_attributes
;
9681 IXMLDOMNamedNodeMap
*map
;
9682 IXMLDOMDocument
*doc
;
9683 IXMLDOMNode
*node
, *node2
;
9689 doc
= create_document(&IID_IXMLDOMDocument
);
9691 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
);
9692 ok(hr
== S_OK
, "got %08x\n", hr
);
9694 hr
= IXMLDOMDocument_get_attributes(doc
, NULL
);
9695 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
9697 map
= (void*)0xdeadbeef;
9698 hr
= IXMLDOMDocument_get_attributes(doc
, &map
);
9699 ok(hr
== S_FALSE
, "got %08x\n", hr
);
9700 ok(map
== NULL
, "got %p\n", map
);
9702 /* first child is <?xml ?> */
9703 hr
= IXMLDOMDocument_get_firstChild(doc
, &node
);
9704 ok(hr
== S_OK
, "got %08x\n", hr
);
9706 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9707 ok(hr
== S_OK
, "got %08x\n", hr
);
9710 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9711 EXPECT_HR(hr
, S_OK
);
9712 todo_wine
ok(length
== 1, "got %d\n", length
);
9714 if (hr
== S_OK
&& length
== 1)
9716 IXMLDOMAttribute
*attr
;
9721 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node2
);
9722 EXPECT_HR(hr
, S_OK
);
9723 ok(node
!= NULL
, "got %p\n", node2
);
9725 hr
= IXMLDOMNode_get_nodeName(node2
, &str
);
9726 EXPECT_HR(hr
, S_OK
);
9727 ok(!lstrcmpW(str
, _bstr_("version")), "got %s\n", wine_dbgstr_w(str
));
9731 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9732 EXPECT_HR(hr
, S_OK
);
9733 ok(length
== 1, "got %d\n", length
);
9736 hr
= IXMLDOMNode_get_nodeType(node2
, &type
);
9737 EXPECT_HR(hr
, S_OK
);
9738 ok(type
== NODE_ATTRIBUTE
, "got %d\n", type
);
9740 hr
= IXMLDOMNode_get_xml(node
, &str
);
9741 EXPECT_HR(hr
, S_OK
);
9742 ok(!lstrcmpW(str
, _bstr_("<?xml version=\"1.0\"?>")), "got %s\n", wine_dbgstr_w(str
));
9745 hr
= IXMLDOMNode_get_text(node
, &str
);
9746 EXPECT_HR(hr
, S_OK
);
9747 ok(!lstrcmpW(str
, _bstr_("version=\"1.0\"")), "got %s\n", wine_dbgstr_w(str
));
9750 hr
= IXMLDOMNamedNodeMap_removeNamedItem(map
, _bstr_("version"), NULL
);
9751 EXPECT_HR(hr
, S_OK
);
9754 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9755 EXPECT_HR(hr
, S_OK
);
9756 ok(length
== 0, "got %d\n", length
);
9758 hr
= IXMLDOMNode_get_xml(node
, &str
);
9759 EXPECT_HR(hr
, S_OK
);
9760 ok(!lstrcmpW(str
, _bstr_("<?xml version=\"1.0\"?>")), "got %s\n", wine_dbgstr_w(str
));
9763 hr
= IXMLDOMNode_get_text(node
, &str
);
9764 EXPECT_HR(hr
, S_OK
);
9765 ok(!lstrcmpW(str
, _bstr_("")), "got %s\n", wine_dbgstr_w(str
));
9768 IXMLDOMNamedNodeMap_Release(map
);
9770 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9771 ok(hr
== S_OK
, "got %08x\n", hr
);
9774 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9775 EXPECT_HR(hr
, S_OK
);
9776 ok(length
== 0, "got %d\n", length
);
9778 hr
= IXMLDOMDocument_createAttribute(doc
, _bstr_("encoding"), &attr
);
9779 EXPECT_HR(hr
, S_OK
);
9782 V_BSTR(&v
) = _bstr_("UTF-8");
9783 hr
= IXMLDOMAttribute_put_nodeValue(attr
, v
);
9784 EXPECT_HR(hr
, S_OK
);
9786 EXPECT_REF(attr
, 2);
9787 hr
= IXMLDOMNamedNodeMap_setNamedItem(map
, (IXMLDOMNode
*)attr
, NULL
);
9788 EXPECT_HR(hr
, S_OK
);
9789 EXPECT_REF(attr
, 2);
9791 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9792 ok(hr
== S_OK
, "got %08x\n", hr
);
9795 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9796 EXPECT_HR(hr
, S_OK
);
9797 ok(length
== 1, "got %d\n", length
);
9799 hr
= IXMLDOMNode_get_xml(node
, &str
);
9800 EXPECT_HR(hr
, S_OK
);
9801 ok(!lstrcmpW(str
, _bstr_("<?xml version=\"1.0\"?>")), "got %s\n", wine_dbgstr_w(str
));
9804 hr
= IXMLDOMNode_get_text(node
, &str
);
9805 EXPECT_HR(hr
, S_OK
);
9806 ok(!lstrcmpW(str
, _bstr_("encoding=\"UTF-8\"")), "got %s\n", wine_dbgstr_w(str
));
9809 IXMLDOMNamedNodeMap_Release(map
);
9810 IXMLDOMNode_Release(node2
);
9813 IXMLDOMNode_Release(node
);
9815 /* last child is element */
9817 hr
= IXMLDOMDocument_get_lastChild(doc
, &node
);
9818 ok(hr
== S_OK
, "got %08x\n", hr
);
9821 EXPECT_REF(node
, 1);
9822 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9823 ok(hr
== S_OK
, "got %08x\n", hr
);
9824 EXPECT_REF(node
, 1);
9828 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node2
);
9829 ok(hr
== S_OK
, "got %08x\n", hr
);
9830 EXPECT_REF(node
, 1);
9831 EXPECT_REF(node2
, 1);
9834 IXMLDOMNode_Release(node2
);
9836 /* release node before map release, map still works */
9837 IXMLDOMNode_Release(node
);
9840 hr
= IXMLDOMNamedNodeMap_get_length(map
, &length
);
9841 ok(hr
== S_OK
, "got %08x\n", hr
);
9842 ok(length
== 1, "got %d\n", length
);
9845 hr
= IXMLDOMNamedNodeMap_get_item(map
, 0, &node2
);
9846 ok(hr
== S_OK
, "got %08x\n", hr
);
9847 EXPECT_REF(node2
, 1);
9848 IXMLDOMNode_Release(node2
);
9850 IXMLDOMNamedNodeMap_Release(map
);
9859 V_I4(&var
) = entry
->type
;
9860 hr
= IXMLDOMDocument_createNode(doc
, var
, _bstr_("node"), NULL
, &node
);
9861 ok(hr
== S_OK
, "failed to create node, type %d\n", entry
->type
);
9863 hr
= IXMLDOMNode_get_attributes(node
, NULL
);
9864 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
9866 map
= (void*)0xdeadbeef;
9867 hr
= IXMLDOMNode_get_attributes(node
, &map
);
9868 ok(hr
== entry
->hr
, "got 0x%08x, expected 0x%08x. node type %d\n",
9869 hr
, entry
->hr
, entry
->type
);
9870 ok(map
== NULL
, "got %p\n", map
);
9872 IXMLDOMNode_Release(node
);
9877 IXMLDOMDocument_Release(doc
);
9881 static void test_selection(void)
9883 IXMLDOMSelection
*selection
, *selection2
;
9884 IEnumVARIANT
*enum1
, *enum2
, *enum3
;
9885 IXMLDOMNodeList
*list
;
9886 IXMLDOMDocument
*doc
;
9887 IDispatchEx
*dispex
;
9898 doc
= create_document(&IID_IXMLDOMDocument
);
9900 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(szExampleXML
), &b
);
9901 EXPECT_HR(hr
, S_OK
);
9903 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root"), &list
);
9904 EXPECT_HR(hr
, S_OK
);
9906 hr
= IXMLDOMNodeList_QueryInterface(list
, &IID_IXMLDOMSelection
, (void**)&selection
);
9907 EXPECT_HR(hr
, S_OK
);
9908 IXMLDOMSelection_Release(selection
);
9910 /* collection disp id */
9911 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IDispatchEx
, (void**)&dispex
);
9912 EXPECT_HR(hr
, S_OK
);
9914 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
9915 EXPECT_HR(hr
, S_OK
);
9916 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got %d\n", did
);
9918 hr
= IXMLDOMSelection_get_length(selection
, &len
);
9919 EXPECT_HR(hr
, S_OK
);
9920 ok(len
== 1, "got %d\n", len
);
9921 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("10"), 0, &did
);
9922 EXPECT_HR(hr
, S_OK
);
9923 ok(did
== DISPID_DOM_COLLECTION_BASE
+10, "got %d\n", did
);
9924 IDispatchEx_Release(dispex
);
9926 /* IEnumVARIANT tests */
9928 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IEnumVARIANT
, (void**)&enum1
);
9929 EXPECT_HR(hr
, S_OK
);
9930 ok(enum1
!= NULL
, "got %p\n", enum1
);
9931 EXPECT_REF(enum1
, 2);
9934 hr
= IXMLDOMSelection_QueryInterface(selection
, &IID_IEnumVARIANT
, (void**)&enum3
);
9935 EXPECT_HR(hr
, S_OK
);
9936 ok(enum3
!= NULL
, "got %p\n", enum3
);
9937 ok(enum1
== enum3
, "got %p and %p\n", enum1
, enum3
);
9938 EXPECT_REF(enum1
, 3);
9939 IEnumVARIANT_Release(enum3
);
9941 EXPECT_REF(selection
, 1);
9942 EXPECT_REF(enum1
, 2);
9945 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum2
);
9946 EXPECT_HR(hr
, S_OK
);
9947 ok(enum2
!= NULL
, "got %p\n", enum2
);
9949 EXPECT_REF(selection
, 2);
9950 EXPECT_REF(enum1
, 2);
9951 EXPECT_REF(enum2
, 1);
9953 ok(enum1
!= enum2
, "got %p, %p\n", enum1
, enum2
);
9956 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IXMLDOMSelection
, (void**)&selection2
);
9957 EXPECT_HR(hr
, S_OK
);
9958 ok(selection2
== selection
, "got %p and %p\n", selection
, selection2
);
9959 EXPECT_REF(selection
, 3);
9960 EXPECT_REF(enum1
, 2);
9962 IXMLDOMSelection_Release(selection2
);
9964 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IDispatch
, (void**)&disp
);
9965 EXPECT_HR(hr
, S_OK
);
9966 EXPECT_REF(selection
, 3);
9967 IDispatch_Release(disp
);
9969 hr
= IEnumVARIANT_QueryInterface(enum1
, &IID_IEnumVARIANT
, (void**)&enum3
);
9970 EXPECT_HR(hr
, S_OK
);
9971 ok(enum3
== enum1
, "got %p and %p\n", enum3
, enum1
);
9972 EXPECT_REF(selection
, 2);
9973 EXPECT_REF(enum1
, 3);
9975 IEnumVARIANT_Release(enum1
);
9976 IEnumVARIANT_Release(enum2
);
9979 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum1
);
9980 EXPECT_HR(hr
, S_OK
);
9981 ok(enum1
!= NULL
, "got %p\n", enum1
);
9982 EXPECT_REF(enum1
, 1);
9983 EXPECT_REF(selection
, 2);
9986 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum2
);
9987 EXPECT_HR(hr
, S_OK
);
9988 ok(enum2
!= NULL
, "got %p\n", enum2
);
9989 EXPECT_REF(enum2
, 1);
9990 EXPECT_REF(selection
, 3);
9992 ok(enum1
!= enum2
, "got %p, %p\n", enum1
, enum2
);
9994 IEnumVARIANT_AddRef(enum1
);
9995 EXPECT_REF(selection
, 3);
9996 EXPECT_REF(enum1
, 2);
9997 EXPECT_REF(enum2
, 1);
9998 IEnumVARIANT_Release(enum1
);
10000 IEnumVARIANT_Release(enum1
);
10001 IEnumVARIANT_Release(enum2
);
10003 EXPECT_REF(selection
, 1);
10005 IXMLDOMNodeList_Release(list
);
10007 hr
= IXMLDOMDocument_get_childNodes(doc
, &list
);
10008 EXPECT_HR(hr
, S_OK
);
10010 hr
= IXMLDOMNodeList_QueryInterface(list
, &IID_IXMLDOMSelection
, (void**)&selection
);
10011 EXPECT_HR(hr
, E_NOINTERFACE
);
10013 IXMLDOMNodeList_Release(list
);
10015 /* test if IEnumVARIANT touches selection context */
10016 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(xpath_simple_list
), &b
);
10017 EXPECT_HR(hr
, S_OK
);
10019 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root/*"), &list
);
10020 EXPECT_HR(hr
, S_OK
);
10022 hr
= IXMLDOMNodeList_QueryInterface(list
, &IID_IXMLDOMSelection
, (void**)&selection
);
10023 EXPECT_HR(hr
, S_OK
);
10026 hr
= IXMLDOMSelection_get_length(selection
, &len
);
10027 EXPECT_HR(hr
, S_OK
);
10028 ok(len
== 4, "got %d\n", len
);
10031 hr
= IXMLDOMSelection_get__newEnum(selection
, (IUnknown
**)&enum1
);
10032 EXPECT_HR(hr
, S_OK
);
10034 /* no-op if zero count */
10036 hr
= IEnumVARIANT_Next(enum1
, 0, &v
, NULL
);
10037 EXPECT_HR(hr
, S_OK
);
10038 ok(V_VT(&v
) == VT_I2
, "got var type %d\n", V_VT(&v
));
10040 /* positive count, null array pointer */
10041 hr
= IEnumVARIANT_Next(enum1
, 1, NULL
, NULL
);
10042 EXPECT_HR(hr
, E_INVALIDARG
);
10045 hr
= IEnumVARIANT_Next(enum1
, 1, NULL
, &ret
);
10046 EXPECT_HR(hr
, E_INVALIDARG
);
10047 ok(ret
== 0, "got %d\n", ret
);
10050 hr
= IEnumVARIANT_Next(enum1
, 1, &v
, NULL
);
10051 EXPECT_HR(hr
, S_OK
);
10052 ok(V_VT(&v
) == VT_DISPATCH
, "got var type %d\n", V_VT(&v
));
10054 hr
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IXMLDOMNode
, (void**)&node
);
10055 EXPECT_HR(hr
, S_OK
);
10056 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
10057 EXPECT_HR(hr
, S_OK
);
10058 ok(!lstrcmpW(name
, _bstr_("a")), "got node name %s\n", wine_dbgstr_w(name
));
10059 SysFreeString(name
);
10060 IXMLDOMNode_Release(node
);
10063 /* list cursor is updated */
10064 hr
= IXMLDOMSelection_nextNode(selection
, &node
);
10065 EXPECT_HR(hr
, S_OK
);
10066 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
10067 EXPECT_HR(hr
, S_OK
);
10068 ok(!lstrcmpW(name
, _bstr_("c")), "got node name %s\n", wine_dbgstr_w(name
));
10069 IXMLDOMNode_Release(node
);
10072 hr
= IEnumVARIANT_Next(enum1
, 1, &v
, NULL
);
10073 EXPECT_HR(hr
, S_OK
);
10074 ok(V_VT(&v
) == VT_DISPATCH
, "got var type %d\n", V_VT(&v
));
10075 hr
= IDispatch_QueryInterface(V_DISPATCH(&v
), &IID_IXMLDOMNode
, (void**)&node
);
10076 EXPECT_HR(hr
, S_OK
);
10077 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
10078 EXPECT_HR(hr
, S_OK
);
10079 ok(!lstrcmpW(name
, _bstr_("b")), "got node name %s\n", wine_dbgstr_w(name
));
10080 SysFreeString(name
);
10081 IXMLDOMNode_Release(node
);
10084 hr
= IXMLDOMSelection_nextNode(selection
, &node
);
10085 EXPECT_HR(hr
, S_OK
);
10086 hr
= IXMLDOMNode_get_nodeName(node
, &name
);
10087 EXPECT_HR(hr
, S_OK
);
10088 ok(!lstrcmpW(name
, _bstr_("d")), "got node name %s\n", wine_dbgstr_w(name
));
10089 IXMLDOMNode_Release(node
);
10091 IXMLDOMSelection_Release(selection
);
10092 IXMLDOMNodeList_Release(list
);
10093 IXMLDOMDocument_Release(doc
);
10098 static void test_load(void)
10100 IXMLDOMDocument
*doc
;
10101 IXMLDOMNodeList
*list
;
10107 BSTR path
, bstr1
, bstr2
;
10111 /* prepare a file */
10112 hfile
= CreateFileA("test.xml", GENERIC_WRITE
|GENERIC_READ
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
10113 ok(hfile
!= INVALID_HANDLE_VALUE
, "failed to create test file\n");
10114 if(hfile
== INVALID_HANDLE_VALUE
) return;
10116 ret
= WriteFile(hfile
, szNonUnicodeXML
, sizeof(szNonUnicodeXML
)-1, &written
, NULL
);
10117 ok(ret
, "WriteFile failed\n");
10119 CloseHandle(hfile
);
10121 doc
= create_document(&IID_IXMLDOMDocument
);
10123 path
= _bstr_("test.xml");
10125 /* load from path: VT_BSTR */
10126 V_VT(&src
) = VT_BSTR
;
10127 V_BSTR(&src
) = path
;
10128 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
10129 EXPECT_HR(hr
, S_OK
);
10130 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10132 /* load from a path: VT_BSTR|VT_BYREF */
10133 V_VT(&src
) = VT_BSTR
| VT_BYREF
;
10134 V_BSTRREF(&src
) = &path
;
10135 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
10136 EXPECT_HR(hr
, S_OK
);
10137 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10139 /* load from a path: VT_BSTR|VT_BYREF, null ptr */
10140 V_VT(&src
) = VT_BSTR
| VT_BYREF
;
10141 V_BSTRREF(&src
) = NULL
;
10142 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
10143 EXPECT_HR(hr
, E_INVALIDARG
);
10144 ok(b
== VARIANT_FALSE
, "got %d\n", b
);
10146 IXMLDOMDocument_Release(doc
);
10148 DeleteFileA("test.xml");
10150 doc
= create_document(&IID_IXMLDOMDocument
);
10152 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &b
);
10153 EXPECT_HR(hr
, S_OK
);
10154 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10156 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("//*"), &list
);
10157 EXPECT_HR(hr
, S_OK
);
10158 bstr1
= _bstr_(list_to_string(list
));
10160 hr
= IXMLDOMNodeList_reset(list
);
10161 EXPECT_HR(hr
, S_OK
);
10163 IXMLDOMDocument_Release(doc
);
10165 doc
= create_document(&IID_IXMLDOMDocument
);
10168 V_ARRAY(&src
) = SafeArrayCreateVector(VT_UI1
, 0, lstrlenA(szExampleXML
));
10169 V_VT(&src
) = VT_ARRAY
|VT_UI1
;
10170 ok(V_ARRAY(&src
) != NULL
, "SafeArrayCreateVector() returned NULL\n");
10172 hr
= SafeArrayAccessData(V_ARRAY(&src
), &ptr
);
10173 EXPECT_HR(hr
, S_OK
);
10174 ok(ptr
!= NULL
, "SafeArrayAccessData() returned NULL\n");
10176 memcpy(ptr
, szExampleXML
, lstrlenA(szExampleXML
));
10177 hr
= SafeArrayUnlock(V_ARRAY(&src
));
10178 EXPECT_HR(hr
, S_OK
);
10180 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
10181 EXPECT_HR(hr
, S_OK
);
10182 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10184 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("//*"), &list
);
10185 EXPECT_HR(hr
, S_OK
);
10186 bstr2
= _bstr_(list_to_string(list
));
10188 hr
= IXMLDOMNodeList_reset(list
);
10189 EXPECT_HR(hr
, S_OK
);
10191 ok(lstrcmpW(bstr1
, bstr2
) == 0, "strings not equal: %s : %s\n",
10192 wine_dbgstr_w(bstr1
), wine_dbgstr_w(bstr2
));
10194 IXMLDOMDocument_Release(doc
);
10195 IXMLDOMNodeList_Release(list
);
10196 VariantClear(&src
);
10198 /* UTF-16 isn't accepted */
10199 doc
= create_document(&IID_IXMLDOMDocument
);
10201 V_ARRAY(&src
) = SafeArrayCreateVector(VT_UI1
, 0, lstrlenW(szComplete1
) * sizeof(WCHAR
));
10202 V_VT(&src
) = VT_ARRAY
|VT_UI1
;
10203 ok(V_ARRAY(&src
) != NULL
, "SafeArrayCreateVector() returned NULL\n");
10205 hr
= SafeArrayAccessData(V_ARRAY(&src
), &ptr
);
10206 EXPECT_HR(hr
, S_OK
);
10207 ok(ptr
!= NULL
, "SafeArrayAccessData() returned NULL\n");
10209 memcpy(ptr
, szComplete1
, lstrlenW(szComplete1
) * sizeof(WCHAR
));
10210 hr
= SafeArrayUnlock(V_ARRAY(&src
));
10211 EXPECT_HR(hr
, S_OK
);
10213 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
10214 todo_wine
EXPECT_HR(hr
, S_FALSE
);
10215 todo_wine
ok(b
== VARIANT_FALSE
, "got %d\n", b
);
10217 VariantClear(&src
);
10219 /* it doesn't like it as a VT_ARRAY|VT_UI2 either */
10220 V_ARRAY(&src
) = SafeArrayCreateVector(VT_UI2
, 0, lstrlenW(szComplete1
));
10221 V_VT(&src
) = VT_ARRAY
|VT_UI2
;
10222 ok(V_ARRAY(&src
) != NULL
, "SafeArrayCreateVector() returned NULL\n");
10224 hr
= SafeArrayAccessData(V_ARRAY(&src
), &ptr
);
10225 EXPECT_HR(hr
, S_OK
);
10226 ok(ptr
!= NULL
, "SafeArrayAccessData() returned NULL\n");
10228 memcpy(ptr
, szComplete1
, lstrlenW(szComplete1
) * sizeof(WCHAR
));
10229 hr
= SafeArrayUnlock(V_ARRAY(&src
));
10230 EXPECT_HR(hr
, S_OK
);
10232 hr
= IXMLDOMDocument_load(doc
, src
, &b
);
10233 todo_wine
EXPECT_HR(hr
, E_INVALIDARG
);
10234 ok(b
== VARIANT_FALSE
, "got %d\n", b
);
10236 VariantClear(&src
);
10237 IXMLDOMDocument_Release(doc
);
10242 static void test_domobj_dispex(IUnknown
*obj
)
10244 DISPID dispid
= DISPID_XMLDOM_NODELIST_RESET
;
10245 IDispatchEx
*dispex
;
10252 hr
= IUnknown_QueryInterface(obj
, &IID_IDispatchEx
, (void**)&dispex
);
10253 EXPECT_HR(hr
, S_OK
);
10254 if (FAILED(hr
)) return;
10257 hr
= IDispatchEx_GetTypeInfoCount(dispex
, &ticnt
);
10258 EXPECT_HR(hr
, S_OK
);
10259 ok(ticnt
== 1, "ticnt=%u\n", ticnt
);
10261 name
= SysAllocString(szstar
);
10262 hr
= IDispatchEx_DeleteMemberByName(dispex
, name
, fdexNameCaseSensitive
);
10263 EXPECT_HR(hr
, E_NOTIMPL
);
10264 SysFreeString(name
);
10266 hr
= IDispatchEx_DeleteMemberByDispID(dispex
, dispid
);
10267 EXPECT_HR(hr
, E_NOTIMPL
);
10270 hr
= IDispatchEx_GetMemberProperties(dispex
, dispid
, grfdexPropCanAll
, &props
);
10271 EXPECT_HR(hr
, E_NOTIMPL
);
10272 ok(props
== 0, "expected 0 got %d\n", props
);
10274 hr
= IDispatchEx_GetMemberName(dispex
, dispid
, &name
);
10275 EXPECT_HR(hr
, E_NOTIMPL
);
10276 if (SUCCEEDED(hr
)) SysFreeString(name
);
10278 hr
= IDispatchEx_GetNextDispID(dispex
, fdexEnumDefault
, DISPID_XMLDOM_NODELIST_RESET
, &dispid
);
10279 EXPECT_HR(hr
, E_NOTIMPL
);
10281 hr
= IDispatchEx_GetNameSpaceParent(dispex
, &unk
);
10282 EXPECT_HR(hr
, E_NOTIMPL
);
10283 if (hr
== S_OK
&& unk
) IUnknown_Release(unk
);
10285 IDispatchEx_Release(dispex
);
10288 static void test_nsnamespacemanager(void)
10290 static const char xmluriA
[] = "http://www.w3.org/XML/1998/namespace";
10291 IVBMXNamespaceManager
*mgr2
;
10292 IMXNamespaceManager
*nsmgr
;
10299 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
10300 &IID_IMXNamespaceManager
, (void**)&nsmgr
);
10301 EXPECT_HR(hr
, S_OK
);
10303 /* IMXNamespaceManager inherits from IUnknown */
10304 hr
= IMXNamespaceManager_QueryInterface(nsmgr
, &IID_IDispatch
, (void**)&disp
);
10305 EXPECT_HR(hr
, S_OK
);
10306 IDispatch_Release(disp
);
10308 hr
= IMXNamespaceManager_QueryInterface(nsmgr
, &IID_IVBMXNamespaceManager
, (void**)&mgr2
);
10309 EXPECT_HR(hr
, S_OK
);
10310 IVBMXNamespaceManager_Release(mgr2
);
10312 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, NULL
);
10313 EXPECT_HR(hr
, S_OK
);
10315 /* prefix already added */
10316 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri"));
10317 EXPECT_HR(hr
, S_FALSE
);
10319 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns0"), NULL
);
10320 EXPECT_HR(hr
, E_INVALIDARG
);
10322 /* "xml" and "xmlns" are not allowed here */
10323 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("xml"), _bstr_("uri1"));
10324 EXPECT_HR(hr
, E_INVALIDARG
);
10326 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("xmlns"), _bstr_("uri1"));
10327 EXPECT_HR(hr
, E_INVALIDARG
);
10329 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, -1, NULL
, NULL
);
10330 EXPECT_HR(hr
, E_FAIL
);
10332 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, NULL
, NULL
);
10333 EXPECT_HR(hr
, E_POINTER
);
10336 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, NULL
, &len
);
10337 EXPECT_HR(hr
, S_OK
);
10338 ok(len
== 3, "got %d\n", len
);
10342 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
10343 EXPECT_HR(hr
, E_XML_BUFFERTOOSMALL
);
10344 ok(len
== -1, "got %d\n", len
);
10345 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10349 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
10350 EXPECT_HR(hr
, S_OK
);
10351 ok(len
== 3, "got %d\n", len
);
10352 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10355 hr
= IMXNamespaceManager_getURI(nsmgr
, NULL
, NULL
, NULL
, NULL
);
10356 EXPECT_HR(hr
, E_INVALIDARG
);
10359 hr
= IMXNamespaceManager_getURI(nsmgr
, NULL
, NULL
, NULL
, &len
);
10360 EXPECT_HR(hr
, E_INVALIDARG
);
10361 ok(len
== -1, "got %d\n", len
);
10363 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, NULL
, NULL
);
10364 EXPECT_HR(hr
, E_POINTER
);
10367 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, NULL
, &len
);
10368 EXPECT_HR(hr
, S_OK
);
10369 /* length of "xml" uri is constant */
10370 ok(len
== strlen(xmluriA
), "got %d\n", len
);
10373 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, buffW
, &len
);
10374 EXPECT_HR(hr
, S_OK
);
10375 ok(len
== strlen(xmluriA
), "got %d\n", len
);
10376 ok(!lstrcmpW(buffW
, _bstr_(xmluriA
)), "got prefix %s\n", wine_dbgstr_w(buffW
));
10378 len
= strlen(xmluriA
)-1;
10380 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml"), NULL
, buffW
, &len
);
10381 EXPECT_HR(hr
, E_XML_BUFFERTOOSMALL
);
10382 ok(len
== strlen(xmluriA
)-1, "got %d\n", len
);
10383 ok(buffW
[0] == 0x1, "got %x\n", buffW
[0]);
10385 /* prefix xml1 not defined */
10387 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml1"), NULL
, NULL
, &len
);
10388 EXPECT_HR(hr
, S_FALSE
);
10389 ok(len
== 0, "got %d\n", len
);
10393 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_("xml1"), NULL
, buffW
, &len
);
10394 EXPECT_HR(hr
, S_FALSE
);
10395 ok(buffW
[0] == 0, "got %x\n", buffW
[0]);
10396 ok(len
== 0, "got %d\n", len
);
10398 /* IDispatchEx tests */
10399 hr
= IMXNamespaceManager_QueryInterface(nsmgr
, &IID_IUnknown
, (void**)&unk
);
10400 EXPECT_HR(hr
, S_OK
);
10401 test_domobj_dispex(unk
);
10402 IUnknown_Release(unk
);
10404 IMXNamespaceManager_Release(nsmgr
);
10409 static void test_nsnamespacemanager_override(void)
10411 IMXNamespaceManager
*nsmgr
;
10417 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
10418 &IID_IMXNamespaceManager
, (void**)&nsmgr
);
10419 EXPECT_HR(hr
, S_OK
);
10421 len
= sizeof(buffW
)/sizeof(WCHAR
);
10423 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
10424 EXPECT_HR(hr
, S_OK
);
10425 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10427 len
= sizeof(buffW
)/sizeof(WCHAR
);
10429 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 1, buffW
, &len
);
10430 EXPECT_HR(hr
, E_FAIL
);
10432 hr
= IMXNamespaceManager_getAllowOverride(nsmgr
, NULL
);
10433 EXPECT_HR(hr
, E_POINTER
);
10436 hr
= IMXNamespaceManager_getAllowOverride(nsmgr
, &b
);
10437 EXPECT_HR(hr
, S_OK
);
10438 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10440 hr
= IMXNamespaceManager_putAllowOverride(nsmgr
, VARIANT_FALSE
);
10441 EXPECT_HR(hr
, S_OK
);
10443 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri"));
10444 EXPECT_HR(hr
, S_OK
);
10446 len
= sizeof(buffW
)/sizeof(WCHAR
);
10448 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_(""), NULL
, buffW
, &len
);
10449 EXPECT_HR(hr
, S_OK
);
10450 ok(!lstrcmpW(buffW
, _bstr_("ns0 uri")), "got uri %s\n", wine_dbgstr_w(buffW
));
10452 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns0"), _bstr_("ns0 uri"));
10453 EXPECT_HR(hr
, S_OK
);
10455 len
= sizeof(buffW
)/sizeof(WCHAR
);
10457 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 0, buffW
, &len
);
10458 EXPECT_HR(hr
, S_OK
);
10459 ok(!lstrcmpW(buffW
, _bstr_("xml")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10461 len
= sizeof(buffW
)/sizeof(WCHAR
);
10463 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 1, buffW
, &len
);
10464 EXPECT_HR(hr
, S_OK
);
10465 ok(!lstrcmpW(buffW
, _bstr_("ns0")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10467 len
= sizeof(buffW
)/sizeof(WCHAR
);
10469 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 2, buffW
, &len
);
10470 EXPECT_HR(hr
, S_OK
);
10471 ok(!lstrcmpW(buffW
, _bstr_("")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10473 /* new prefix placed at index 1 always */
10474 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_("ns1"), _bstr_("ns1 uri"));
10475 EXPECT_HR(hr
, S_OK
);
10477 len
= sizeof(buffW
)/sizeof(WCHAR
);
10479 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 1, buffW
, &len
);
10480 EXPECT_HR(hr
, S_OK
);
10481 ok(!lstrcmpW(buffW
, _bstr_("ns1")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10483 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, _bstr_(""), NULL
);
10484 todo_wine
EXPECT_HR(hr
, E_FAIL
);
10486 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, NULL
);
10487 EXPECT_HR(hr
, E_FAIL
);
10489 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri"));
10490 EXPECT_HR(hr
, E_FAIL
);
10492 hr
= IMXNamespaceManager_putAllowOverride(nsmgr
, VARIANT_TRUE
);
10493 EXPECT_HR(hr
, S_OK
);
10495 hr
= IMXNamespaceManager_declarePrefix(nsmgr
, NULL
, _bstr_("ns0 uri override"));
10496 EXPECT_HR(hr
, S_FALSE
);
10498 len
= sizeof(buffW
)/sizeof(WCHAR
);
10500 hr
= IMXNamespaceManager_getURI(nsmgr
, _bstr_(""), NULL
, buffW
, &len
);
10501 EXPECT_HR(hr
, S_OK
);
10502 ok(!lstrcmpW(buffW
, _bstr_("ns0 uri override")), "got uri %s\n", wine_dbgstr_w(buffW
));
10504 len
= sizeof(buffW
)/sizeof(WCHAR
);
10506 hr
= IMXNamespaceManager_getDeclaredPrefix(nsmgr
, 3, buffW
, &len
);
10507 EXPECT_HR(hr
, S_OK
);
10508 ok(!lstrcmpW(buffW
, _bstr_("")), "got prefix %s\n", wine_dbgstr_w(buffW
));
10510 IMXNamespaceManager_Release(nsmgr
);
10515 static const DOMNodeType nodetypes_test
[] =
10520 NODE_CDATA_SECTION
,
10521 NODE_ENTITY_REFERENCE
,
10522 NODE_PROCESSING_INSTRUCTION
,
10524 NODE_DOCUMENT_FRAGMENT
,
10528 static void test_dispex(void)
10530 const DOMNodeType
*type
= nodetypes_test
;
10531 IXMLDOMImplementation
*impl
;
10532 IXMLDOMNodeList
*node_list
;
10533 IXMLDOMParseError
*error
;
10534 IXMLDOMNamedNodeMap
*map
;
10535 IXSLProcessor
*processor
;
10536 IXSLTemplate
*template;
10537 IXMLDOMDocument
*doc
;
10538 IXMLHTTPRequest
*req
;
10539 IXMLDOMElement
*elem
;
10540 IDispatchEx
*dispex
;
10547 doc
= create_document(&IID_IXMLDOMDocument
);
10549 IXMLDOMDocument_QueryInterface(doc
, &IID_IUnknown
, (void**)&unk
);
10550 test_domobj_dispex(unk
);
10551 IUnknown_Release(unk
);
10553 for(; *type
!= NODE_INVALID
; type
++)
10561 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_("name"), NULL
, &node
);
10562 ok(hr
== S_OK
, "failed to create node type %d\n", *type
);
10564 IXMLDOMNode_QueryInterface(node
, &IID_IUnknown
, (void**)&unk
);
10566 test_domobj_dispex(unk
);
10567 IUnknown_Release(unk
);
10568 IXMLDOMNode_Release(node
);
10571 /* IXMLDOMNodeList */
10572 hr
= IXMLDOMDocument_getElementsByTagName(doc
, _bstr_("*"), &node_list
);
10573 EXPECT_HR(hr
, S_OK
);
10574 IXMLDOMNodeList_QueryInterface(node_list
, &IID_IUnknown
, (void**)&unk
);
10575 test_domobj_dispex(unk
);
10576 IUnknown_Release(unk
);
10577 IXMLDOMNodeList_Release(node_list
);
10579 /* IXMLDOMNodeList for children list */
10580 hr
= IXMLDOMDocument_get_childNodes(doc
, &node_list
);
10581 EXPECT_HR(hr
, S_OK
);
10582 IXMLDOMNodeList_QueryInterface(node_list
, &IID_IUnknown
, (void**)&unk
);
10583 test_domobj_dispex(unk
);
10584 IUnknown_Release(unk
);
10586 /* collection dispex test, empty collection */
10587 hr
= IXMLDOMNodeList_QueryInterface(node_list
, &IID_IDispatchEx
, (void**)&dispex
);
10588 EXPECT_HR(hr
, S_OK
);
10590 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
10591 EXPECT_HR(hr
, S_OK
);
10592 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got 0x%08x\n", did
);
10593 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("1"), 0, &did
);
10594 EXPECT_HR(hr
, S_OK
);
10595 ok(did
== DISPID_DOM_COLLECTION_BASE
+1, "got 0x%08x\n", did
);
10596 IDispatchEx_Release(dispex
);
10598 IXMLDOMNodeList_Release(node_list
);
10600 /* IXMLDOMParseError */
10601 hr
= IXMLDOMDocument_get_parseError(doc
, &error
);
10602 EXPECT_HR(hr
, S_OK
);
10603 IXMLDOMParseError_QueryInterface(error
, &IID_IUnknown
, (void**)&unk
);
10604 test_domobj_dispex(unk
);
10605 IUnknown_Release(unk
);
10606 IXMLDOMParseError_Release(error
);
10608 /* IXMLDOMNamedNodeMap */
10609 hr
= IXMLDOMDocument2_loadXML(doc
, _bstr_(xpath_simple_list
), &b
);
10610 EXPECT_HR(hr
, S_OK
);
10612 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root/a"), &node_list
);
10613 EXPECT_HR(hr
, S_OK
);
10614 hr
= IXMLDOMNodeList_get_item(node_list
, 0, &node
);
10615 EXPECT_HR(hr
, S_OK
);
10616 IXMLDOMNodeList_Release(node_list
);
10618 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
10619 EXPECT_HR(hr
, S_OK
);
10620 IXMLDOMNode_Release(node
);
10621 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
10622 EXPECT_HR(hr
, S_OK
);
10623 IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IUnknown
, (void**)&unk
);
10624 test_domobj_dispex(unk
);
10625 IUnknown_Release(unk
);
10626 /* collection dispex test */
10627 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IDispatchEx
, (void**)&dispex
);
10628 EXPECT_HR(hr
, S_OK
);
10630 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
10631 EXPECT_HR(hr
, S_OK
);
10632 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got 0x%08x\n", did
);
10633 IDispatchEx_Release(dispex
);
10635 hr
= IXMLDOMDocument_selectNodes(doc
, _bstr_("root/b"), &node_list
);
10636 EXPECT_HR(hr
, S_OK
);
10637 hr
= IXMLDOMNodeList_get_item(node_list
, 0, &node
);
10638 EXPECT_HR(hr
, S_OK
);
10639 IXMLDOMNodeList_Release(node_list
);
10640 hr
= IXMLDOMNode_QueryInterface(node
, &IID_IXMLDOMElement
, (void**)&elem
);
10641 EXPECT_HR(hr
, S_OK
);
10642 IXMLDOMNode_Release(node
);
10643 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
10644 EXPECT_HR(hr
, S_OK
);
10645 /* collection dispex test, empty collection */
10646 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_IDispatchEx
, (void**)&dispex
);
10647 EXPECT_HR(hr
, S_OK
);
10649 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("0"), 0, &did
);
10650 EXPECT_HR(hr
, S_OK
);
10651 ok(did
== DISPID_DOM_COLLECTION_BASE
, "got 0x%08x\n", did
);
10652 hr
= IDispatchEx_GetDispID(dispex
, _bstr_("1"), 0, &did
);
10653 EXPECT_HR(hr
, S_OK
);
10654 ok(did
== DISPID_DOM_COLLECTION_BASE
+1, "got 0x%08x\n", did
);
10655 IDispatchEx_Release(dispex
);
10657 IXMLDOMNamedNodeMap_Release(map
);
10658 IXMLDOMElement_Release(elem
);
10660 /* IXMLDOMImplementation */
10661 hr
= IXMLDOMDocument_get_implementation(doc
, &impl
);
10662 EXPECT_HR(hr
, S_OK
);
10664 hr
= IXMLDOMImplementation_QueryInterface(impl
, &IID_IDispatchEx
, (void**)&dispex
);
10665 EXPECT_HR(hr
, S_OK
);
10666 IDispatchEx_Release(dispex
);
10667 IXMLDOMImplementation_Release(impl
);
10669 IXMLDOMDocument_Release(doc
);
10671 /* IXMLHTTPRequest */
10672 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
10673 &IID_IXMLHttpRequest
, (void**)&req
);
10676 hr
= IXMLHTTPRequest_QueryInterface(req
, &IID_IDispatchEx
, (void**)&dispex
);
10677 EXPECT_HR(hr
, E_NOINTERFACE
);
10678 IXMLHTTPRequest_Release(req
);
10682 template = create_xsltemplate(&IID_IXSLTemplate
);
10683 hr
= IXSLTemplate_QueryInterface(template, &IID_IDispatchEx
, (void**)&dispex
);
10684 EXPECT_HR(hr
, S_OK
);
10685 hr
= IDispatchEx_QueryInterface(dispex
, &IID_IUnknown
, (void**)&unk
);
10686 EXPECT_HR(hr
, S_OK
);
10687 test_domobj_dispex(unk
);
10688 IUnknown_Release(unk
);
10689 IDispatchEx_Release(dispex
);
10691 /* IXSLProcessor */
10692 hr
= CoCreateInstance(&CLSID_FreeThreadedDOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
10693 EXPECT_HR(hr
, S_OK
);
10695 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szTransformSSXML
), &b
);
10696 EXPECT_HR(hr
, S_OK
);
10697 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10699 hr
= IXSLTemplate_putref_stylesheet(template, (IXMLDOMNode
*)doc
);
10700 EXPECT_HR(hr
, S_OK
);
10701 IXMLDOMDocument_Release(doc
);
10703 hr
= IXSLTemplate_createProcessor(template, &processor
);
10704 EXPECT_HR(hr
, S_OK
);
10705 hr
= IXSLProcessor_QueryInterface(processor
, &IID_IDispatchEx
, (void**)&dispex
);
10706 EXPECT_HR(hr
, S_OK
);
10707 hr
= IDispatchEx_QueryInterface(dispex
, &IID_IUnknown
, (void**)&unk
);
10708 EXPECT_HR(hr
, S_OK
);
10709 test_domobj_dispex(unk
);
10710 IUnknown_Release(unk
);
10711 IDispatchEx_Release(dispex
);
10713 IXSLProcessor_Release(processor
);
10714 IXSLTemplate_Release(template);
10719 static void test_parseerror(void)
10721 IXMLDOMParseError2
*error2
;
10722 IXMLDOMParseError
*error
;
10723 IXMLDOMDocument
*doc
;
10726 doc
= create_document(&IID_IXMLDOMDocument
);
10728 hr
= IXMLDOMDocument_get_parseError(doc
, &error
);
10729 EXPECT_HR(hr
, S_OK
);
10731 hr
= IXMLDOMParseError_get_line(error
, NULL
);
10732 EXPECT_HR(hr
, E_INVALIDARG
);
10734 hr
= IXMLDOMParseError_get_srcText(error
, NULL
);
10735 EXPECT_HR(hr
, E_INVALIDARG
);
10737 hr
= IXMLDOMParseError_get_linepos(error
, NULL
);
10738 EXPECT_HR(hr
, E_INVALIDARG
);
10740 IXMLDOMParseError_Release(error
);
10741 IXMLDOMDocument_Release(doc
);
10743 doc
= create_document_version(60, &IID_IXMLDOMDocument
);
10745 hr
= IXMLDOMDocument_get_parseError(doc
, &error
);
10746 EXPECT_HR(hr
, S_OK
);
10747 hr
= IXMLDOMParseError_QueryInterface(error
, &IID_IXMLDOMParseError2
, (void**)&error2
);
10748 EXPECT_HR(hr
, S_OK
);
10749 IXMLDOMParseError2_Release(error2
);
10750 IXMLDOMParseError_Release(error
);
10751 IXMLDOMDocument_Release(doc
);
10754 static void test_getAttributeNode(void)
10756 IXMLDOMAttribute
*attr
;
10757 IXMLDOMDocument
*doc
;
10758 IXMLDOMElement
*elem
;
10763 doc
= create_document(&IID_IXMLDOMDocument
);
10765 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(szExampleXML
), &v
);
10766 EXPECT_HR(hr
, S_OK
);
10768 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
10769 EXPECT_HR(hr
, S_OK
);
10771 str
= SysAllocString(nonexistent_fileW
);
10772 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, NULL
);
10773 EXPECT_HR(hr
, E_FAIL
);
10775 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
10776 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, &attr
);
10777 EXPECT_HR(hr
, E_FAIL
);
10778 ok(attr
== NULL
, "got %p\n", attr
);
10779 SysFreeString(str
);
10781 str
= SysAllocString(nonexistent_attrW
);
10782 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, NULL
);
10783 EXPECT_HR(hr
, S_FALSE
);
10785 attr
= (IXMLDOMAttribute
*)0xdeadbeef;
10786 hr
= IXMLDOMElement_getAttributeNode(elem
, str
, &attr
);
10787 EXPECT_HR(hr
, S_FALSE
);
10788 ok(attr
== NULL
, "got %p\n", attr
);
10789 SysFreeString(str
);
10791 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("foo:b"), &attr
);
10792 EXPECT_HR(hr
, S_OK
);
10793 IXMLDOMAttribute_Release(attr
);
10795 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("b"), &attr
);
10796 EXPECT_HR(hr
, S_FALSE
);
10798 hr
= IXMLDOMElement_getAttributeNode(elem
, _bstr_("a"), &attr
);
10799 EXPECT_HR(hr
, S_OK
);
10800 IXMLDOMAttribute_Release(attr
);
10802 IXMLDOMElement_Release(elem
);
10803 IXMLDOMDocument_Release(doc
);
10813 static const supporterror_t supporterror_test
[] = {
10814 { NODE_ELEMENT
, "element", { &IID_IXMLDOMNode
, &IID_IXMLDOMElement
} },
10815 { NODE_ATTRIBUTE
, "attribute", { &IID_IXMLDOMNode
, &IID_IXMLDOMAttribute
} },
10816 { NODE_CDATA_SECTION
, "cdata", { &IID_IXMLDOMNode
, &IID_IXMLDOMCDATASection
} },
10817 { NODE_ENTITY_REFERENCE
, "entityref", { &IID_IXMLDOMNode
, &IID_IXMLDOMEntityReference
} },
10818 { NODE_PROCESSING_INSTRUCTION
, "pi", { &IID_IXMLDOMNode
, &IID_IXMLDOMProcessingInstruction
} },
10819 { NODE_COMMENT
, "comment", { &IID_IXMLDOMNode
, &IID_IXMLDOMComment
} },
10820 { NODE_DOCUMENT_FRAGMENT
, "fragment", { &IID_IXMLDOMNode
, &IID_IXMLDOMDocumentFragment
} },
10824 static void test_supporterrorinfo(void)
10826 static REFIID iids
[5] = { &IID_IXMLDOMNode
, &IID_IXMLDOMDocument
,
10827 &IID_IXMLDOMDocument2
, &IID_IXMLDOMDocument3
};
10828 const supporterror_t
*ptr
= supporterror_test
;
10829 ISupportErrorInfo
*errorinfo
, *info2
;
10830 IXMLDOMNamedNodeMap
*map
, *map2
;
10831 IXMLDOMDocument
*doc
;
10832 IXMLDOMElement
*elem
;
10839 doc
= create_document_version(60, &IID_IXMLDOMDocument3
);
10842 EXPECT_REF(doc
, 1);
10843 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10844 EXPECT_HR(hr
, S_OK
);
10845 EXPECT_REF(doc
, 1);
10846 ISupportErrorInfo_AddRef(errorinfo
);
10847 EXPECT_REF(errorinfo
, 2);
10848 EXPECT_REF(doc
, 1);
10849 ISupportErrorInfo_Release(errorinfo
);
10851 hr
= IXMLDOMDocument_QueryInterface(doc
, &IID_ISupportErrorInfo
, (void**)&info2
);
10852 EXPECT_HR(hr
, S_OK
);
10853 ok(errorinfo
!= info2
, "got %p, %p\n", info2
, errorinfo
);
10855 /* error interface can't be queried back for DOM interface */
10856 hr
= ISupportErrorInfo_QueryInterface(info2
, &IID_IXMLDOMDocument
, &dummy
);
10857 EXPECT_HR(hr
, E_NOINTERFACE
);
10858 hr
= ISupportErrorInfo_QueryInterface(info2
, &IID_IXMLDOMNode
, &dummy
);
10859 EXPECT_HR(hr
, E_NOINTERFACE
);
10861 ISupportErrorInfo_Release(info2
);
10866 hr
= IXMLDOMDocument_QueryInterface(doc
, *iid
, (void**)&unk
);
10867 EXPECT_HR(hr
, S_OK
);
10870 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, *iid
);
10871 ok(hr
== S_OK
, "got 0x%08x for %s\n", hr
, debugstr_guid(*iid
));
10872 IUnknown_Release(unk
);
10878 ISupportErrorInfo_Release(errorinfo
);
10880 while (ptr
->type
!= NODE_INVALID
)
10885 V_VT(&type
) = VT_I1
;
10886 V_I1(&type
) = ptr
->type
;
10888 hr
= IXMLDOMDocument_createNode(doc
, type
, _bstr_(ptr
->name
), NULL
, &node
);
10889 ok(hr
== S_OK
, "%d: got 0x%08x\n", ptr
->type
, hr
);
10891 EXPECT_REF(node
, 1);
10892 hr
= IXMLDOMNode_QueryInterface(node
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10893 ok(hr
== S_OK
, "%d: got 0x%08x\n", ptr
->type
, hr
);
10894 EXPECT_REF(node
, 1);
10896 hr
= ISupportErrorInfo_QueryInterface(errorinfo
, &IID_IXMLDOMNode
, &dummy
);
10897 ok(hr
== E_NOINTERFACE
, "%d: got 0x%08x\n", ptr
->type
, hr
);
10903 hr
= IXMLDOMNode_QueryInterface(node
, *iid
, (void**)&unk
);
10906 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, *iid
);
10907 ok(hr
== S_OK
, "%d: got 0x%08x for %s\n", ptr
->type
, hr
, debugstr_guid(*iid
));
10908 IUnknown_Release(unk
);
10914 ISupportErrorInfo_Release(errorinfo
);
10915 IXMLDOMNode_Release(node
);
10919 /* IXMLDOMNamedNodeMap */
10921 hr
= IXMLDOMDocument_loadXML(doc
, _bstr_(complete4A
), &b
);
10922 EXPECT_HR(hr
, S_OK
);
10923 ok(b
== VARIANT_TRUE
, "got %d\n", b
);
10925 hr
= IXMLDOMDocument_get_documentElement(doc
, &elem
);
10926 EXPECT_HR(hr
, S_OK
);
10928 hr
= IXMLDOMElement_get_attributes(elem
, &map
);
10929 EXPECT_HR(hr
, S_OK
);
10931 EXPECT_REF(map
, 1);
10932 hr
= IXMLDOMNamedNodeMap_QueryInterface(map
, &IID_ISupportErrorInfo
, (void**)&errorinfo
);
10933 EXPECT_HR(hr
, S_OK
);
10934 EXPECT_REF(map
, 2);
10936 hr
= ISupportErrorInfo_InterfaceSupportsErrorInfo(errorinfo
, &IID_IXMLDOMNamedNodeMap
);
10937 EXPECT_HR(hr
, S_OK
);
10939 hr
= ISupportErrorInfo_QueryInterface(errorinfo
, &IID_IXMLDOMNamedNodeMap
, (void**)&map2
);
10940 EXPECT_HR(hr
, S_OK
);
10941 ok(map
== map2
, "got %p\n", map2
);
10942 IXMLDOMNamedNodeMap_Release(map2
);
10944 EXPECT_REF(errorinfo
, 2);
10945 hr
= ISupportErrorInfo_QueryInterface(errorinfo
, &IID_IUnknown
, (void**)&unk
);
10946 EXPECT_HR(hr
, S_OK
);
10947 EXPECT_REF(errorinfo
, 3);
10948 EXPECT_REF(map
, 3);
10949 IUnknown_Release(unk
);
10951 ISupportErrorInfo_Release(errorinfo
);
10952 IXMLDOMNamedNodeMap_Release(map
);
10953 IXMLDOMElement_Release(elem
);
10955 IXMLDOMDocument_Release(doc
);
10962 const char *put_content
;
10968 static const node_value_t nodevalue_test
[] = {
10969 { NODE_ELEMENT
, "element", "", E_FAIL
, VT_NULL
, S_FALSE
},
10970 { NODE_ATTRIBUTE
, "attr", "value", S_OK
, VT_BSTR
, S_OK
},
10971 { NODE_TEXT
, "text", "textdata", S_OK
, VT_BSTR
, S_OK
},
10972 { NODE_CDATA_SECTION
, "cdata", "cdata data", S_OK
, VT_BSTR
, S_OK
},
10973 { NODE_ENTITY_REFERENCE
, "entityref", "ref", E_FAIL
, VT_NULL
, S_FALSE
},
10974 { NODE_PROCESSING_INSTRUCTION
, "pi", "instr", S_OK
, VT_BSTR
, S_OK
},
10975 { NODE_COMMENT
, "comment", "comment data", S_OK
, VT_BSTR
, S_OK
},
10976 { NODE_DOCUMENT_FRAGMENT
, "docfrag", "", E_FAIL
, VT_NULL
, S_FALSE
},
10980 static void test_nodeValue(void)
10982 const node_value_t
*ptr
= nodevalue_test
;
10983 IXMLDOMDocument
*doc
;
10986 doc
= create_document(&IID_IXMLDOMDocument
);
10989 while (ptr
->type
!= NODE_INVALID
)
10995 V_I2(&v
) = ptr
->type
;
10997 hr
= IXMLDOMDocument_createNode(doc
, v
, _bstr_(ptr
->name
), NULL
, &node
);
10998 ok(hr
== S_OK
, "failed to create node type %d\n", ptr
->type
);
11000 hr
= IXMLDOMNode_get_nodeValue(node
, NULL
);
11001 ok(hr
== E_INVALIDARG
, "%d: got 0x%08x\n", ptr
->type
, hr
);
11003 V_VT(&v
) = VT_BSTR
;
11004 V_BSTR(&v
) = _bstr_(ptr
->put_content
);
11005 hr
= IXMLDOMNode_put_nodeValue(node
, v
);
11006 ok(hr
== ptr
->put_hr
, "%d: got 0x%08x\n", ptr
->type
, hr
);
11008 V_VT(&v
) = VT_EMPTY
;
11009 hr
= IXMLDOMNode_get_nodeValue(node
, &v
);
11010 ok(hr
== ptr
->get_hr
, "%d: got 0x%08x, expected 0x%08x\n", ptr
->type
, hr
, ptr
->get_hr
);
11011 ok(V_VT(&v
) == ptr
->get_vt
, "%d: got %d, expected %d\n", ptr
->type
, V_VT(&v
), ptr
->get_vt
);
11013 ok(!lstrcmpW(V_BSTR(&v
), _bstr_(ptr
->put_content
)), "%d: got %s\n", ptr
->type
,
11014 wine_dbgstr_w(V_BSTR(&v
)));
11017 IXMLDOMNode_Release(node
);
11022 IXMLDOMDocument_Release(doc
);
11027 IXMLDOMDocument
*doc
;
11031 hr
= CoInitialize( NULL
);
11032 ok( hr
== S_OK
, "failed to init com\n");
11033 if (hr
!= S_OK
) return;
11037 hr
= CoCreateInstance( &CLSID_DOMDocument
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IXMLDOMDocument
, (void**)&doc
);
11040 win_skip("IXMLDOMDocument is not available (0x%08x)\n", hr
);
11044 IXMLDOMDocument_Release(doc
);
11047 test_persiststreaminit();
11051 test_getElementsByTagName();
11053 test_get_childNodes();
11054 test_get_firstChild();
11055 test_get_lastChild();
11056 test_removeChild();
11057 test_replaceChild();
11058 test_removeNamedItem();
11059 test_IXMLDOMDocument2();
11065 test_nodeTypeTests();
11067 test_testTransforms();
11069 test_FormattingXML();
11070 test_nodeTypedValue();
11071 test_TransformWithLoadingLocalFile();
11072 test_put_nodeValue();
11073 test_document_IObjectSafety();
11075 test_getQualifiedItem();
11076 test_removeQualifiedItem();
11077 test_get_ownerDocument();
11078 test_setAttributeNode();
11079 test_put_dataType();
11082 test_default_properties();
11083 test_selectSingleNode();
11085 test_createProcessingInstruction();
11086 test_put_nodeTypedValue();
11088 test_insertBefore();
11089 test_appendChild();
11090 test_get_doctype();
11091 test_get_tagName();
11092 test_get_dataType();
11093 test_get_nodeTypeString();
11094 test_get_attributes();
11099 test_getAttributeNode();
11100 test_supporterrorinfo();
11103 test_xsltemplate();
11105 hr
= CoCreateInstance(&CLSID_MXNamespaceManager40
, NULL
, CLSCTX_INPROC_SERVER
,
11106 &IID_IMXNamespaceManager
, (void**)&unk
);
11109 test_nsnamespacemanager();
11110 test_nsnamespacemanager_override();
11112 IUnknown_Release(unk
);
11115 win_skip("MXNamespaceManager is not available\n");