4 * Copyright 2010-2012 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "msxml2did.h"
38 #include "wine/heap.h"
39 #include "wine/test.h"
41 #define EXPECT_HR(hr,hr_exp) \
42 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
44 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__)
45 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
49 rc
= IUnknown_Release(obj
);
50 ok_(__FILE__
, line
)(rc
== ref
, "expected refcount %d, got %d\n", ref
, rc
);
53 static const char xmltestA
[] = "http://test.winehq.org/tests/xmltest.xml";
54 static const CHAR xmltestbodyA
[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
56 DEFINE_GUID(SID_SContainerDispatch
, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
57 DEFINE_GUID(SID_UnknownSID
, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
59 static BOOL g_enablecallchecks
;
61 #define DEFINE_EXPECT(func) \
62 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
64 #define SET_EXPECT(func) \
65 expect_ ## func = TRUE
67 #define CHECK_EXPECT2(func) \
69 if (g_enablecallchecks) \
70 ok(expect_ ##func, "unexpected call " #func "\n"); \
71 called_ ## func = TRUE; \
74 #define CHECK_CALLED(func) \
76 ok(called_ ## func, "expected " #func "\n"); \
77 expect_ ## func = called_ ## func = FALSE; \
81 DEFINE_EXPECT(site_qi_IServiceProvider
);
82 DEFINE_EXPECT(site_qi_IXMLDOMDocument
);
83 DEFINE_EXPECT(site_qi_IOleClientSite
);
85 DEFINE_EXPECT(sp_queryservice_SID_SBindHost
);
86 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
87 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
88 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
89 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
91 DEFINE_EXPECT(htmldoc2_get_all
);
92 DEFINE_EXPECT(htmldoc2_get_url
);
93 DEFINE_EXPECT(collection_get_length
);
95 static int g_unexpectedcall
, g_expectedcall
;
97 static int strcmp_wa(const WCHAR
*strw
, const char *stra
)
100 MultiByteToWideChar(CP_ACP
, 0, stra
, -1, buf
, ARRAY_SIZE(buf
));
101 return lstrcmpW(strw
, buf
);
104 static BSTR
alloc_str_from_narrow(const char *str
)
106 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
107 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
108 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
-1);
112 static BSTR alloced_bstrs
[256];
113 static int alloced_bstrs_count
;
115 static BSTR
_bstr_(const char *str
)
120 assert(alloced_bstrs_count
< ARRAY_SIZE(alloced_bstrs
));
121 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
122 return alloced_bstrs
[alloced_bstrs_count
++];
125 static void free_bstrs(void)
128 for (i
= 0; i
< alloced_bstrs_count
; i
++)
129 SysFreeString(alloced_bstrs
[i
]);
130 alloced_bstrs_count
= 0;
133 static BSTR
a2bstr(const char *str
)
141 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
142 ret
= SysAllocStringLen(NULL
, len
);
143 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
149 /* test IHTMLElementCollection */
150 static HRESULT WINAPI
htmlecoll_QueryInterface(IHTMLElementCollection
*iface
, REFIID riid
, void **ppvObject
)
152 ok(0, "unexpected call\n");
154 return E_NOINTERFACE
;
157 static ULONG WINAPI
htmlecoll_AddRef(IHTMLElementCollection
*iface
)
162 static ULONG WINAPI
htmlecoll_Release(IHTMLElementCollection
*iface
)
167 static HRESULT WINAPI
htmlecoll_GetTypeInfoCount(IHTMLElementCollection
*iface
, UINT
*pctinfo
)
169 ok(0, "unexpected call\n");
173 static HRESULT WINAPI
htmlecoll_GetTypeInfo(IHTMLElementCollection
*iface
, UINT iTInfo
,
174 LCID lcid
, ITypeInfo
**ppTInfo
)
176 ok(0, "unexpected call\n");
180 static HRESULT WINAPI
htmlecoll_GetIDsOfNames(IHTMLElementCollection
*iface
, REFIID riid
,
181 LPOLESTR
*rgszNames
, UINT cNames
,
182 LCID lcid
, DISPID
*rgDispId
)
184 ok(0, "unexpected call\n");
188 static HRESULT WINAPI
htmlecoll_Invoke(IHTMLElementCollection
*iface
, DISPID dispIdMember
,
189 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
190 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
192 ok(0, "unexpected call\n");
196 static HRESULT WINAPI
htmlecoll_toString(IHTMLElementCollection
*iface
, BSTR
*String
)
198 ok(0, "unexpected call\n");
202 static HRESULT WINAPI
htmlecoll_put_length(IHTMLElementCollection
*iface
, LONG v
)
204 ok(0, "unexpected call\n");
208 static HRESULT WINAPI
htmlecoll_get_length(IHTMLElementCollection
*iface
, LONG
*v
)
210 CHECK_EXPECT2(collection_get_length
);
214 static HRESULT WINAPI
htmlecoll_get__newEnum(IHTMLElementCollection
*iface
, IUnknown
**p
)
216 ok(0, "unexpected call\n");
220 static HRESULT WINAPI
htmlecoll_item(IHTMLElementCollection
*iface
, VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
222 ok(0, "unexpected call\n");
226 static HRESULT WINAPI
htmlecoll_tags(IHTMLElementCollection
*iface
, VARIANT tagName
, IDispatch
**pdisp
)
228 ok(0, "unexpected call\n");
232 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl
= {
233 htmlecoll_QueryInterface
,
236 htmlecoll_GetTypeInfoCount
,
237 htmlecoll_GetTypeInfo
,
238 htmlecoll_GetIDsOfNames
,
241 htmlecoll_put_length
,
242 htmlecoll_get_length
,
243 htmlecoll_get__newEnum
,
248 static IHTMLElementCollection htmlecoll
= { &TestHTMLECollectionVtbl
};
250 /* test IHTMLDocument2 */
251 static HRESULT WINAPI
htmldoc2_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppvObject
)
255 return E_NOINTERFACE
;
258 static ULONG WINAPI
htmldoc2_AddRef(IHTMLDocument2
*iface
)
263 static ULONG WINAPI
htmldoc2_Release(IHTMLDocument2
*iface
)
268 static HRESULT WINAPI
htmldoc2_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
270 ok(0, "unexpected call\n");
274 static HRESULT WINAPI
htmldoc2_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
275 LCID lcid
, ITypeInfo
**ppTInfo
)
277 ok(0, "unexpected call\n");
281 static HRESULT WINAPI
htmldoc2_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
282 LPOLESTR
*rgszNames
, UINT cNames
,
283 LCID lcid
, DISPID
*rgDispId
)
285 ok(0, "unexpected call\n");
289 static HRESULT WINAPI
htmldoc2_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
290 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
291 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
293 ok(0, "unexpected call\n");
297 static HRESULT WINAPI
htmldoc2_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
299 ok(0, "unexpected call\n");
303 static HRESULT WINAPI
htmldoc2_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
305 CHECK_EXPECT2(htmldoc2_get_all
);
310 static HRESULT WINAPI
htmldoc2_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
312 ok(0, "unexpected call\n");
316 static HRESULT WINAPI
htmldoc2_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
318 ok(0, "unexpected call\n");
322 static HRESULT WINAPI
htmldoc2_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
324 ok(0, "unexpected call\n");
328 static HRESULT WINAPI
htmldoc2_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
330 ok(0, "unexpected call\n");
334 static HRESULT WINAPI
htmldoc2_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
336 ok(0, "unexpected call\n");
340 static HRESULT WINAPI
htmldoc2_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
342 ok(0, "unexpected call\n");
346 static HRESULT WINAPI
htmldoc2_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
348 ok(0, "unexpected call\n");
352 static HRESULT WINAPI
htmldoc2_put_title(IHTMLDocument2
*iface
, BSTR v
)
354 ok(0, "unexpected call\n");
358 static HRESULT WINAPI
htmldoc2_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
360 ok(0, "unexpected call\n");
364 static HRESULT WINAPI
htmldoc2_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
366 ok(0, "unexpected call\n");
370 static HRESULT WINAPI
htmldoc2_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
372 ok(0, "unexpected call\n");
376 static HRESULT WINAPI
htmldoc2_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
378 ok(0, "unexpected call\n");
382 static HRESULT WINAPI
htmldoc2_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
384 ok(0, "unexpected call\n");
388 static HRESULT WINAPI
htmldoc2_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
390 ok(0, "unexpected call\n");
394 static HRESULT WINAPI
htmldoc2_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
396 ok(0, "unexpected call\n");
400 static HRESULT WINAPI
htmldoc2_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
402 ok(0, "unexpected call\n");
406 static HRESULT WINAPI
htmldoc2_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
408 ok(0, "unexpected call\n");
412 static HRESULT WINAPI
htmldoc2_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
414 ok(0, "unexpected call\n");
418 static HRESULT WINAPI
htmldoc2_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
420 ok(0, "unexpected call\n");
424 static HRESULT WINAPI
htmldoc2_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
426 ok(0, "unexpected call\n");
430 static HRESULT WINAPI
htmldoc2_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
432 ok(0, "unexpected call\n");
436 static HRESULT WINAPI
htmldoc2_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
438 ok(0, "unexpected call\n");
442 static HRESULT WINAPI
htmldoc2_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
444 ok(0, "unexpected call\n");
448 static HRESULT WINAPI
htmldoc2_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
450 ok(0, "unexpected call\n");
454 static HRESULT WINAPI
htmldoc2_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
456 ok(0, "unexpected call\n");
460 static HRESULT WINAPI
htmldoc2_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
462 ok(0, "unexpected call\n");
466 static HRESULT WINAPI
htmldoc2_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
468 ok(0, "unexpected call\n");
472 static HRESULT WINAPI
htmldoc2_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
474 ok(0, "unexpected call\n");
478 static HRESULT WINAPI
htmldoc2_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
480 ok(0, "unexpected call\n");
484 static HRESULT WINAPI
htmldoc2_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
486 ok(0, "unexpected call\n");
490 static HRESULT WINAPI
htmldoc2_put_URL(IHTMLDocument2
*iface
, BSTR v
)
492 ok(0, "unexpected call\n");
496 static HRESULT WINAPI
htmldoc2_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
498 CHECK_EXPECT2(htmldoc2_get_url
);
499 *p
= a2bstr("http://test.winehq.org/");
503 static HRESULT WINAPI
htmldoc2_put_domain(IHTMLDocument2
*iface
, BSTR v
)
505 ok(0, "unexpected call\n");
509 static HRESULT WINAPI
htmldoc2_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
511 ok(0, "unexpected call\n");
515 static HRESULT WINAPI
htmldoc2_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
517 ok(0, "unexpected call\n");
521 static HRESULT WINAPI
htmldoc2_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
523 ok(0, "unexpected call\n");
527 static HRESULT WINAPI
htmldoc2_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
529 ok(0, "unexpected call\n");
533 static HRESULT WINAPI
htmldoc2_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
535 ok(0, "unexpected call\n");
539 static HRESULT WINAPI
htmldoc2_put_charset(IHTMLDocument2
*iface
, BSTR v
)
541 ok(0, "unexpected call\n");
545 static HRESULT WINAPI
htmldoc2_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
547 ok(0, "unexpected call\n");
551 static HRESULT WINAPI
htmldoc2_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
553 ok(0, "unexpected call\n");
557 static HRESULT WINAPI
htmldoc2_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
559 ok(0, "unexpected call\n");
563 static HRESULT WINAPI
htmldoc2_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
565 ok(0, "unexpected call\n");
569 static HRESULT WINAPI
htmldoc2_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
571 ok(0, "unexpected call\n");
575 static HRESULT WINAPI
htmldoc2_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
577 ok(0, "unexpected call\n");
581 static HRESULT WINAPI
htmldoc2_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
583 ok(0, "unexpected call\n");
587 static HRESULT WINAPI
htmldoc2_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
589 ok(0, "unexpected call\n");
593 static HRESULT WINAPI
htmldoc2_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
595 ok(0, "unexpected call\n");
599 static HRESULT WINAPI
htmldoc2_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
601 ok(0, "unexpected call\n");
605 static HRESULT WINAPI
htmldoc2_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
607 ok(0, "unexpected call\n");
611 static HRESULT WINAPI
htmldoc2_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
613 ok(0, "unexpected call\n");
617 static HRESULT WINAPI
htmldoc2_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
619 ok(0, "unexpected call\n");
623 static HRESULT WINAPI
htmldoc2_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
624 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
626 ok(0, "unexpected call\n");
630 static HRESULT WINAPI
htmldoc2_close(IHTMLDocument2
*iface
)
632 ok(0, "unexpected call\n");
636 static HRESULT WINAPI
htmldoc2_clear(IHTMLDocument2
*iface
)
638 ok(0, "unexpected call\n");
642 static HRESULT WINAPI
htmldoc2_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
645 ok(0, "unexpected call\n");
649 static HRESULT WINAPI
htmldoc2_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
652 ok(0, "unexpected call\n");
656 static HRESULT WINAPI
htmldoc2_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
659 ok(0, "unexpected call\n");
663 static HRESULT WINAPI
htmldoc2_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
666 ok(0, "unexpected call\n");
670 static HRESULT WINAPI
htmldoc2_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
673 ok(0, "unexpected call\n");
677 static HRESULT WINAPI
htmldoc2_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
680 ok(0, "unexpected call\n");
684 static HRESULT WINAPI
htmldoc2_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
685 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
687 ok(0, "unexpected call\n");
691 static HRESULT WINAPI
htmldoc2_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
694 ok(0, "unexpected call\n");
698 static HRESULT WINAPI
htmldoc2_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
699 IHTMLElement
**newElem
)
701 ok(0, "unexpected call\n");
705 static HRESULT WINAPI
htmldoc2_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
707 ok(0, "unexpected call\n");
711 static HRESULT WINAPI
htmldoc2_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
713 ok(0, "unexpected call\n");
717 static HRESULT WINAPI
htmldoc2_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
719 ok(0, "unexpected call\n");
723 static HRESULT WINAPI
htmldoc2_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
725 ok(0, "unexpected call\n");
729 static HRESULT WINAPI
htmldoc2_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
731 ok(0, "unexpected call\n");
735 static HRESULT WINAPI
htmldoc2_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
737 ok(0, "unexpected call\n");
741 static HRESULT WINAPI
htmldoc2_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
743 ok(0, "unexpected call\n");
747 static HRESULT WINAPI
htmldoc2_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
749 ok(0, "unexpected call\n");
753 static HRESULT WINAPI
htmldoc2_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
755 ok(0, "unexpected call\n");
759 static HRESULT WINAPI
htmldoc2_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
761 ok(0, "unexpected call\n");
765 static HRESULT WINAPI
htmldoc2_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
767 ok(0, "unexpected call\n");
771 static HRESULT WINAPI
htmldoc2_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
773 ok(0, "unexpected call\n");
777 static HRESULT WINAPI
htmldoc2_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
779 ok(0, "unexpected call\n");
783 static HRESULT WINAPI
htmldoc2_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
785 ok(0, "unexpected call\n");
789 static HRESULT WINAPI
htmldoc2_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
791 ok(0, "unexpected call\n");
795 static HRESULT WINAPI
htmldoc2_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
797 ok(0, "unexpected call\n");
801 static HRESULT WINAPI
htmldoc2_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
803 ok(0, "unexpected call\n");
807 static HRESULT WINAPI
htmldoc2_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
809 ok(0, "unexpected call\n");
813 static HRESULT WINAPI
htmldoc2_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
815 ok(0, "unexpected call\n");
819 static HRESULT WINAPI
htmldoc2_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
821 ok(0, "unexpected call\n");
825 static HRESULT WINAPI
htmldoc2_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
827 ok(0, "unexpected call\n");
831 static HRESULT WINAPI
htmldoc2_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
833 ok(0, "unexpected call\n");
837 static HRESULT WINAPI
htmldoc2_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
839 ok(0, "unexpected call\n");
843 static HRESULT WINAPI
htmldoc2_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
845 ok(0, "unexpected call\n");
849 static HRESULT WINAPI
htmldoc2_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
851 ok(0, "unexpected call\n");
855 static HRESULT WINAPI
htmldoc2_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
857 ok(0, "unexpected call\n");
861 static HRESULT WINAPI
htmldoc2_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
863 ok(0, "unexpected call\n");
867 static HRESULT WINAPI
htmldoc2_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
869 ok(0, "unexpected call\n");
873 static HRESULT WINAPI
htmldoc2_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
875 ok(0, "unexpected call\n");
879 static HRESULT WINAPI
htmldoc2_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
881 ok(0, "unexpected call\n");
885 static HRESULT WINAPI
htmldoc2_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
887 ok(0, "unexpected call\n");
891 static HRESULT WINAPI
htmldoc2_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
893 ok(0, "unexpected call\n");
897 static HRESULT WINAPI
htmldoc2_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
899 ok(0, "unexpected call\n");
903 static HRESULT WINAPI
htmldoc2_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
905 ok(0, "unexpected call\n");
909 static HRESULT WINAPI
htmldoc2_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
910 IHTMLElement
**elementHit
)
912 ok(0, "unexpected call\n");
916 static HRESULT WINAPI
htmldoc2_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
918 ok(0, "unexpected call\n");
922 static HRESULT WINAPI
htmldoc2_get_styleSheets(IHTMLDocument2
*iface
,
923 IHTMLStyleSheetsCollection
**p
)
925 ok(0, "unexpected call\n");
929 static HRESULT WINAPI
htmldoc2_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
931 ok(0, "unexpected call\n");
935 static HRESULT WINAPI
htmldoc2_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
937 ok(0, "unexpected call\n");
941 static HRESULT WINAPI
htmldoc2_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
943 ok(0, "unexpected call\n");
947 static HRESULT WINAPI
htmldoc2_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
949 ok(0, "unexpected call\n");
953 static HRESULT WINAPI
htmldoc2_toString(IHTMLDocument2
*iface
, BSTR
*String
)
955 ok(0, "unexpected call\n");
959 static HRESULT WINAPI
htmldoc2_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
960 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
962 ok(0, "unexpected call\n");
966 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl
= {
967 htmldoc2_QueryInterface
,
970 htmldoc2_GetTypeInfoCount
,
971 htmldoc2_GetTypeInfo
,
972 htmldoc2_GetIDsOfNames
,
977 htmldoc2_get_activeElement
,
979 htmldoc2_get_applets
,
982 htmldoc2_get_anchors
,
985 htmldoc2_get_scripts
,
986 htmldoc2_put_designMode
,
987 htmldoc2_get_designMode
,
988 htmldoc2_get_selection
,
989 htmldoc2_get_readyState
,
992 htmldoc2_get_plugins
,
993 htmldoc2_put_alinkColor
,
994 htmldoc2_get_alinkColor
,
995 htmldoc2_put_bgColor
,
996 htmldoc2_get_bgColor
,
997 htmldoc2_put_fgColor
,
998 htmldoc2_get_fgColor
,
999 htmldoc2_put_linkColor
,
1000 htmldoc2_get_linkColor
,
1001 htmldoc2_put_vlinkColor
,
1002 htmldoc2_get_vlinkColor
,
1003 htmldoc2_get_referrer
,
1004 htmldoc2_get_location
,
1005 htmldoc2_get_lastModified
,
1008 htmldoc2_put_domain
,
1009 htmldoc2_get_domain
,
1010 htmldoc2_put_cookie
,
1011 htmldoc2_get_cookie
,
1012 htmldoc2_put_expando
,
1013 htmldoc2_get_expando
,
1014 htmldoc2_put_charset
,
1015 htmldoc2_get_charset
,
1016 htmldoc2_put_defaultCharset
,
1017 htmldoc2_get_defaultCharset
,
1018 htmldoc2_get_mimeType
,
1019 htmldoc2_get_fileSize
,
1020 htmldoc2_get_fileCreatedDate
,
1021 htmldoc2_get_fileModifiedDate
,
1022 htmldoc2_get_fileUpdatedDate
,
1023 htmldoc2_get_security
,
1024 htmldoc2_get_protocol
,
1025 htmldoc2_get_nameProp
,
1031 htmldoc2_queryCommandSupported
,
1032 htmldoc2_queryCommandEnabled
,
1033 htmldoc2_queryCommandState
,
1034 htmldoc2_queryCommandIndeterm
,
1035 htmldoc2_queryCommandText
,
1036 htmldoc2_queryCommandValue
,
1037 htmldoc2_execCommand
,
1038 htmldoc2_execCommandShowHelp
,
1039 htmldoc2_createElement
,
1040 htmldoc2_put_onhelp
,
1041 htmldoc2_get_onhelp
,
1042 htmldoc2_put_onclick
,
1043 htmldoc2_get_onclick
,
1044 htmldoc2_put_ondblclick
,
1045 htmldoc2_get_ondblclick
,
1046 htmldoc2_put_onkeyup
,
1047 htmldoc2_get_onkeyup
,
1048 htmldoc2_put_onkeydown
,
1049 htmldoc2_get_onkeydown
,
1050 htmldoc2_put_onkeypress
,
1051 htmldoc2_get_onkeypress
,
1052 htmldoc2_put_onmouseup
,
1053 htmldoc2_get_onmouseup
,
1054 htmldoc2_put_onmousedown
,
1055 htmldoc2_get_onmousedown
,
1056 htmldoc2_put_onmousemove
,
1057 htmldoc2_get_onmousemove
,
1058 htmldoc2_put_onmouseout
,
1059 htmldoc2_get_onmouseout
,
1060 htmldoc2_put_onmouseover
,
1061 htmldoc2_get_onmouseover
,
1062 htmldoc2_put_onreadystatechange
,
1063 htmldoc2_get_onreadystatechange
,
1064 htmldoc2_put_onafterupdate
,
1065 htmldoc2_get_onafterupdate
,
1066 htmldoc2_put_onrowexit
,
1067 htmldoc2_get_onrowexit
,
1068 htmldoc2_put_onrowenter
,
1069 htmldoc2_get_onrowenter
,
1070 htmldoc2_put_ondragstart
,
1071 htmldoc2_get_ondragstart
,
1072 htmldoc2_put_onselectstart
,
1073 htmldoc2_get_onselectstart
,
1074 htmldoc2_elementFromPoint
,
1075 htmldoc2_get_parentWindow
,
1076 htmldoc2_get_styleSheets
,
1077 htmldoc2_put_onbeforeupdate
,
1078 htmldoc2_get_onbeforeupdate
,
1079 htmldoc2_put_onerrorupdate
,
1080 htmldoc2_get_onerrorupdate
,
1082 htmldoc2_createStyleSheet
1085 static IHTMLDocument2 htmldoc2
= { &TestHTMLDocumentVtbl
};
1087 static HRESULT WINAPI
sp_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppvObject
)
1091 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1092 IsEqualGUID(riid
, &IID_IServiceProvider
))
1095 IServiceProvider_AddRef(iface
);
1099 ok(0, "unexpected query interface: %s\n", wine_dbgstr_guid(riid
));
1101 return E_NOINTERFACE
;
1104 static ULONG WINAPI
sp_AddRef(IServiceProvider
*iface
)
1109 static ULONG WINAPI
sp_Release(IServiceProvider
*iface
)
1114 static HRESULT WINAPI
sp_QueryService(IServiceProvider
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1118 if (IsEqualGUID(service
, &SID_SBindHost
) &&
1119 IsEqualGUID(riid
, &IID_IBindHost
))
1121 CHECK_EXPECT2(sp_queryservice_SID_SBindHost
);
1123 else if (IsEqualGUID(service
, &SID_SContainerDispatch
) &&
1124 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1126 CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1128 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1129 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1131 CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2
);
1135 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1136 IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1138 CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc
);
1140 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1141 IsEqualGUID(riid
, &IID_IInternetHostSecurityManager
))
1143 CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr
);
1145 else if (IsEqualGUID(service
, &SID_UnknownSID
) &&
1146 IsEqualGUID(riid
, &IID_IStream
))
1148 /* FIXME: unidentified service id */
1150 else if ((IsEqualGUID(service
, &IID_IInternetProtocol
) && IsEqualGUID(riid
, &IID_IInternetProtocol
)) ||
1151 (IsEqualGUID(service
, &IID_IHttpNegotiate2
) && IsEqualGUID(riid
, &IID_IHttpNegotiate2
)) ||
1152 (IsEqualGUID(service
, &IID_IGetBindHandle
) && IsEqualGUID(riid
, &IID_IGetBindHandle
)) ||
1153 (IsEqualGUID(service
, &IID_IBindStatusCallback
) && IsEqualGUID(riid
, &IID_IBindStatusCallback
)) ||
1154 (IsEqualGUID(service
, &IID_IWindowForBindingUI
) && IsEqualGUID(riid
, &IID_IWindowForBindingUI
)))
1158 ok(0, "unexpected request: sid %s, riid %s\n", wine_dbgstr_guid(service
), wine_dbgstr_guid(riid
));
1163 static const IServiceProviderVtbl testprovVtbl
=
1171 static IServiceProvider testprov
= { &testprovVtbl
};
1173 static HRESULT WINAPI
site_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
1177 if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1178 CHECK_EXPECT2(site_qi_IServiceProvider
);
1180 if (IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1181 CHECK_EXPECT2(site_qi_IXMLDOMDocument
);
1183 if (IsEqualGUID(riid
, &IID_IOleClientSite
))
1184 CHECK_EXPECT2(site_qi_IOleClientSite
);
1186 if (IsEqualGUID(riid
, &IID_IUnknown
))
1188 else if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1189 *ppvObject
= &testprov
;
1191 if (*ppvObject
) IUnknown_AddRef(iface
);
1193 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1196 static ULONG WINAPI
site_AddRef(IUnknown
*iface
)
1201 static ULONG WINAPI
site_Release(IUnknown
*iface
)
1206 static const IUnknownVtbl testsiteVtbl
=
1208 site_QueryInterface
,
1213 static IUnknown testsite
= { &testsiteVtbl
};
1217 IDispatch IDispatch_iface
;
1221 static IXMLHttpRequest
*httpreq
;
1223 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
1225 return CONTAINING_RECORD(iface
, dispevent
, IDispatch_iface
);
1228 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
1232 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
1233 IsEqualGUID( riid
, &IID_IUnknown
) )
1238 return E_NOINTERFACE
;
1240 IDispatch_AddRef( iface
);
1245 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
1247 dispevent
*This
= impl_from_IDispatch( iface
);
1248 return InterlockedIncrement( &This
->ref
);
1251 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
1253 dispevent
*This
= impl_from_IDispatch( iface
);
1254 ULONG ref
= InterlockedDecrement( &This
->ref
);
1262 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1269 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1270 LCID lcid
, ITypeInfo
**ppTInfo
)
1276 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1277 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1283 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
1284 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
1285 EXCEPINFO
*excepInfo
, UINT
*argErr
)
1290 ok(member
== 0, "expected 0 member, got %d\n", member
);
1291 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
1292 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
1294 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
1295 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
1296 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
1297 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
1299 ok(result
== NULL
, "got %p\n", result
);
1300 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
1301 ok(argErr
== NULL
, "got %p\n", argErr
);
1305 state
= READYSTATE_UNINITIALIZED
;
1306 hr
= IXMLHttpRequest_get_readyState(httpreq
, &state
);
1307 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1308 if (state
== READYSTATE_COMPLETE
)
1312 hr
= IXMLHttpRequest_get_responseText(httpreq
, &text
);
1313 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1314 ok(*text
!= 0, "got %s\n", wine_dbgstr_w(text
));
1315 SysFreeString(text
);
1321 static const IDispatchVtbl dispeventVtbl
=
1323 dispevent_QueryInterface
,
1326 dispevent_GetTypeInfoCount
,
1327 dispevent_GetTypeInfo
,
1328 dispevent_GetIDsOfNames
,
1332 static IDispatch
* create_dispevent(void)
1334 dispevent
*event
= heap_alloc(sizeof(*event
));
1336 event
->IDispatch_iface
.lpVtbl
= &dispeventVtbl
;
1339 return &event
->IDispatch_iface
;
1342 static IXMLHttpRequest
*create_xhr(void)
1344 IXMLHttpRequest
*ret
;
1347 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
1348 &IID_IXMLHttpRequest
, (void**)&ret
);
1350 return SUCCEEDED(hr
) ? ret
: NULL
;
1353 static IServerXMLHTTPRequest
*create_server_xhr(void)
1355 IServerXMLHTTPRequest
*ret
;
1358 hr
= CoCreateInstance(&CLSID_ServerXMLHTTP30
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IServerXMLHTTPRequest
, (void **)&ret
);
1360 return SUCCEEDED(hr
) ? ret
: NULL
;
1363 static void set_safety_opt(IUnknown
*unk
, DWORD mask
, DWORD opts
)
1365 IObjectSafety
*obj_safety
;
1368 hr
= IUnknown_QueryInterface(unk
, &IID_IObjectSafety
, (void**)&obj_safety
);
1369 ok(hr
== S_OK
, "Could not get IObjectSafety iface: %08x\n", hr
);
1371 hr
= IObjectSafety_SetInterfaceSafetyOptions(obj_safety
, &IID_IDispatch
, mask
, mask
&opts
);
1372 ok(hr
== S_OK
, "SetInterfaceSafetyOptions failed: %08x\n", hr
);
1374 IObjectSafety_Release(obj_safety
);
1377 static void set_xhr_site(IXMLHttpRequest
*xhr
)
1379 IObjectWithSite
*obj_site
;
1382 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1383 ok(hr
== S_OK
, "Could not get IObjectWithSite iface: %08x\n", hr
);
1385 g_enablecallchecks
= TRUE
;
1387 SET_EXPECT(site_qi_IServiceProvider
);
1388 SET_EXPECT(sp_queryservice_SID_SBindHost
);
1389 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1390 SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
1391 SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
1392 SET_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
1394 /* calls to IHTMLDocument2 */
1395 SET_EXPECT(htmldoc2_get_all
);
1396 SET_EXPECT(collection_get_length
);
1397 SET_EXPECT(htmldoc2_get_url
);
1399 SET_EXPECT(site_qi_IXMLDOMDocument
);
1400 SET_EXPECT(site_qi_IOleClientSite
);
1402 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1403 EXPECT_HR(hr
, S_OK
);
1405 CHECK_CALLED(site_qi_IServiceProvider
);
1407 CHECK_CALLED(sp_queryservice_SID_SBindHost
);
1408 CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1409 CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2
);
1411 CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc
);
1412 /* this one isn't very reliable
1413 CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
1415 CHECK_CALLED(htmldoc2_get_all
);
1416 CHECK_CALLED(collection_get_length
);
1418 CHECK_CALLED(htmldoc2_get_url
);
1421 CHECK_CALLED(site_qi_IXMLDOMDocument
);
1422 CHECK_CALLED(site_qi_IOleClientSite
);
1425 g_enablecallchecks
= FALSE
;
1427 IObjectWithSite_Release(obj_site
);
1430 #define test_open(a,b,c,d) _test_open(__LINE__,a,b,c,d)
1431 static void _test_open(unsigned line
, IXMLHttpRequest
*xhr
, const char *method
, const char *url
, HRESULT exhres
)
1433 VARIANT empty
, vfalse
;
1436 V_VT(&empty
) = VT_EMPTY
;
1437 V_VT(&vfalse
) = VT_BOOL
;
1438 V_BOOL(&vfalse
) = VARIANT_FALSE
;
1440 hr
= IXMLHttpRequest_open(xhr
, _bstr_(method
), _bstr_(url
), vfalse
, empty
, empty
);
1441 ok_(__FILE__
,line
)(hr
== exhres
, "open(%s %s) failed: %08x, expected %08x\n", method
, url
, hr
, exhres
);
1444 #define test_server_open(a,b,c,d) _test_server_open(__LINE__,a,b,c,d)
1445 static void _test_server_open(unsigned line
, IServerXMLHTTPRequest
*xhr
, const char *method
, const char *url
, HRESULT exhres
)
1447 VARIANT empty
, vfalse
;
1450 V_VT(&empty
) = VT_EMPTY
;
1451 V_VT(&vfalse
) = VT_BOOL
;
1452 V_BOOL(&vfalse
) = VARIANT_FALSE
;
1454 hr
= IServerXMLHTTPRequest_open(xhr
, _bstr_(method
), _bstr_(url
), vfalse
, empty
, empty
);
1455 ok_(__FILE__
,line
)(hr
== exhres
, "open(%s %s) failed: %08x, expected %08x\n", method
, url
, hr
, exhres
);
1458 static void test_XMLHTTP(void)
1460 static const char bodyA
[] = "mode=Test";
1461 static const char urlA
[] = "http://test.winehq.org/tests/post.php";
1462 static const char referertesturl
[] = "http://test.winehq.org/tests/referer.php";
1463 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
1464 static const WCHAR norefererW
[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0};
1466 IXMLHttpRequest
*xhr
;
1467 IObjectWithSite
*obj_site
, *obj_site2
;
1468 BSTR bstrResponse
, str
, str1
;
1471 LONG state
, status
, bound
;
1479 VariantInit(&dummy
);
1480 V_VT(&dummy
) = VT_ERROR
;
1481 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
1483 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, NULL
);
1484 EXPECT_HR(hr
, S_OK
);
1486 hr
= IXMLHttpRequest_abort(xhr
);
1487 EXPECT_HR(hr
, S_OK
);
1489 V_VT(&varbody
) = VT_I2
;
1491 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1492 EXPECT_HR(hr
, E_PENDING
);
1493 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1495 V_VT(&varbody
) = VT_I2
;
1497 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1498 EXPECT_HR(hr
, E_PENDING
);
1499 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1501 /* send before open */
1502 hr
= IXMLHttpRequest_send(xhr
, dummy
);
1503 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1505 /* initial status code */
1506 hr
= IXMLHttpRequest_get_status(xhr
, NULL
);
1507 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1509 status
= 0xdeadbeef;
1510 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1511 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1512 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1514 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1515 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
1517 /* invalid parameters */
1518 test_open(xhr
, NULL
, NULL
, E_INVALIDARG
);
1519 test_open(xhr
, "POST", NULL
, E_INVALIDARG
);
1520 test_open(xhr
, NULL
, urlA
, E_INVALIDARG
);
1522 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, NULL
);
1523 EXPECT_HR(hr
, E_INVALIDARG
);
1525 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), NULL
);
1526 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1528 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1529 EXPECT_HR(hr
, E_INVALIDARG
);
1531 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1532 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1534 hr
= IXMLHttpRequest_get_readyState(xhr
, NULL
);
1535 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1538 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1539 EXPECT_HR(hr
, S_OK
);
1540 ok(state
== READYSTATE_UNINITIALIZED
, "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1543 event
= create_dispevent();
1545 EXPECT_REF(event
, 1);
1546 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, event
);
1547 EXPECT_HR(hr
, S_OK
);
1548 EXPECT_REF(event
, 2);
1550 g_unexpectedcall
= g_expectedcall
= 0;
1552 test_open(xhr
, "POST", urlA
, S_OK
);
1554 ok(g_unexpectedcall
== 0, "unexpected disp event call\n");
1555 ok(g_expectedcall
== 1 || broken(g_expectedcall
== 0) /* win2k */, "no expected disp event call\n");
1557 /* status code after ::open() */
1558 status
= 0xdeadbeef;
1559 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1560 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1561 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1564 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1565 EXPECT_HR(hr
, S_OK
);
1566 ok(state
== READYSTATE_LOADING
, "got %d, expected READYSTATE_LOADING\n", state
);
1568 hr
= IXMLHttpRequest_abort(xhr
);
1569 EXPECT_HR(hr
, S_OK
);
1572 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1573 EXPECT_HR(hr
, S_OK
);
1574 ok(state
== READYSTATE_UNINITIALIZED
|| broken(state
== READYSTATE_LOADING
) /* win2k */,
1575 "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1577 test_open(xhr
, "POST", urlA
, S_OK
);
1579 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1580 EXPECT_HR(hr
, S_OK
);
1582 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1583 EXPECT_HR(hr
, E_INVALIDARG
);
1585 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_(""), _bstr_("value1"));
1586 EXPECT_HR(hr
, E_INVALIDARG
);
1588 V_VT(&varbody
) = VT_BSTR
;
1589 V_BSTR(&varbody
) = _bstr_(bodyA
);
1591 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1592 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1594 skip("No connection could be made with test.winehq.org\n");
1595 IXMLHttpRequest_Release(xhr
);
1598 EXPECT_HR(hr
, S_OK
);
1600 /* response headers */
1601 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, NULL
);
1602 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1603 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str
);
1604 EXPECT_HR(hr
, S_OK
);
1605 /* status line is stripped already */
1606 ok(memcmp(str
, _bstr_("HTTP"), 4*sizeof(WCHAR
)), "got response headers %s\n", wine_dbgstr_w(str
));
1607 ok(*str
, "got empty headers\n");
1608 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str1
);
1609 EXPECT_HR(hr
, S_OK
);
1610 ok(str1
!= str
, "got %p\n", str1
);
1611 SysFreeString(str1
);
1614 hr
= IXMLHttpRequest_getResponseHeader(xhr
, NULL
, NULL
);
1615 EXPECT_HR(hr
, E_INVALIDARG
);
1616 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), NULL
);
1617 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1618 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), &str
);
1619 EXPECT_HR(hr
, S_OK
);
1620 ok(*str
!= ' ', "got leading space in header %s\n", wine_dbgstr_w(str
));
1623 /* status code after ::send() */
1624 status
= 0xdeadbeef;
1625 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1626 EXPECT_HR(hr
, S_OK
);
1627 ok(status
== 200, "got %d\n", status
);
1629 hr
= IXMLHttpRequest_get_statusText(xhr
, NULL
);
1630 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1632 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1633 EXPECT_HR(hr
, S_OK
);
1634 ok(!lstrcmpW(str
, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str
));
1637 /* another ::send() after completed request */
1638 V_VT(&varbody
) = VT_BSTR
;
1639 V_BSTR(&varbody
) = _bstr_(bodyA
);
1641 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1642 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1644 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1645 EXPECT_HR(hr
, S_OK
);
1646 /* the server currently returns "FAILED" because the Content-Type header is
1647 * not what the server expects */
1650 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)),
1651 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse
), wine_dbgstr_w(bstrResponse
));
1652 SysFreeString(bstrResponse
);
1655 /* POST: VT_VARIANT body */
1656 /* VT_VARIANT|VT_BYREF fails on Windows 10 */
1657 test_open(xhr
, "POST", urlA
, S_OK
);
1659 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1660 EXPECT_HR(hr
, S_OK
);
1663 test_open(xhr
, "GET", xmltestA
, S_OK
);
1665 V_VT(&varbody
) = VT_EMPTY
;
1667 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1668 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1670 skip("No connection could be made with test.winehq.org\n");
1671 IXMLHttpRequest_Release(xhr
);
1674 EXPECT_HR(hr
, S_OK
);
1676 hr
= IXMLHttpRequest_get_responseText(xhr
, NULL
);
1677 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1679 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1680 EXPECT_HR(hr
, S_OK
);
1681 ok(!memcmp(bstrResponse
, _bstr_(xmltestbodyA
), sizeof(xmltestbodyA
)*sizeof(WCHAR
)),
1682 "expected %s, got %s\n", xmltestbodyA
, wine_dbgstr_w(bstrResponse
));
1683 SysFreeString(bstrResponse
);
1685 hr
= IXMLHttpRequest_get_responseBody(xhr
, NULL
);
1686 EXPECT_HR(hr
, E_INVALIDARG
);
1688 V_VT(&varbody
) = VT_EMPTY
;
1689 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1690 EXPECT_HR(hr
, S_OK
);
1691 ok(V_VT(&varbody
) == (VT_ARRAY
|VT_UI1
), "got type %d, expected %d\n", V_VT(&varbody
), VT_ARRAY
|VT_UI1
);
1692 ok(SafeArrayGetDim(V_ARRAY(&varbody
)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody
)));
1695 hr
= SafeArrayGetLBound(V_ARRAY(&varbody
), 1, &bound
);
1696 EXPECT_HR(hr
, S_OK
);
1697 ok(bound
== 0, "got %d, expected zero bound\n", bound
);
1699 hr
= SafeArrayAccessData(V_ARRAY(&varbody
), &ptr
);
1700 EXPECT_HR(hr
, S_OK
);
1701 ok(memcmp(ptr
, xmltestbodyA
, sizeof(xmltestbodyA
)-1) == 0, "got wrong body data\n");
1702 SafeArrayUnaccessData(V_ARRAY(&varbody
));
1704 VariantClear(&varbody
);
1706 /* get_responseStream */
1707 hr
= IXMLHttpRequest_get_responseStream(xhr
, NULL
);
1708 EXPECT_HR(hr
, E_INVALIDARG
);
1710 V_VT(&varbody
) = VT_EMPTY
;
1711 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1712 ok(V_VT(&varbody
) == VT_UNKNOWN
, "got type %d\n", V_VT(&varbody
));
1713 EXPECT_HR(hr
, S_OK
);
1714 EXPECT_REF(V_UNKNOWN(&varbody
), 1);
1717 hr
= GetHGlobalFromStream((IStream
*)V_UNKNOWN(&varbody
), &g
);
1718 EXPECT_HR(hr
, S_OK
);
1719 ok(g
!= NULL
, "got %p\n", g
);
1720 VariantClear(&varbody
);
1722 IDispatch_Release(event
);
1724 /* test if referrer header is sent */
1725 test_open(xhr
, "GET", referertesturl
, S_OK
);
1727 V_VT(&varbody
) = VT_EMPTY
;
1728 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1729 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1730 hr
= IXMLHttpRequest_get_responseText(xhr
, &str
);
1731 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1732 ok(!lstrcmpW(str
, norefererW
), "got response text %s\n", wine_dbgstr_w(str
));
1735 /* interaction with object site */
1736 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1737 EXPECT_HR(hr
, S_OK
);
1739 hr
= IObjectWithSite_SetSite(obj_site
, NULL
);
1740 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1742 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site2
);
1743 EXPECT_HR(hr
, S_OK
);
1744 ok(obj_site
== obj_site2
|| broken(obj_site
!= obj_site2
), "got new instance\n");
1745 IObjectWithSite_Release(obj_site2
);
1749 test_open(xhr
, "GET", "tests/referer.php", S_OK
);
1750 str1
= a2bstr("http://test.winehq.org/");
1752 V_VT(&varbody
) = VT_EMPTY
;
1753 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1754 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1756 hr
= IXMLHttpRequest_get_responseText(xhr
, &str
);
1757 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1758 ok(!lstrcmpW(str
, str1
), "got response text %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(str1
));
1760 SysFreeString(str1
);
1762 /* try to set site another time */
1763 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1764 EXPECT_HR(hr
, S_OK
);
1766 IObjectWithSite_Release(obj_site
);
1769 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, NULL
);
1770 ok(hr
== S_OK
, "Failed to reset state change handler, hr %#x.\n", hr
);
1772 test_open(xhr
, "HEAD", xmltestA
, S_OK
);
1774 V_VT(&varbody
) = VT_EMPTY
;
1775 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1776 ok(hr
== S_OK
, "Failed to send HEAD request, hr %#x.\n", hr
);
1779 hr
= IXMLHttpRequest_get_responseText(xhr
, &str
);
1780 ok(hr
== S_OK
, "Failed to get response text, hr %#x.\n", hr
);
1781 ok(!*str
, "Unexpected text %s.\n", wine_dbgstr_w(str
));
1784 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str
);
1785 ok(hr
== S_OK
, "Failed to get response headers, hr %#x.\n", hr
);
1786 ok(str
&& *str
, "Expected response headers.\n");
1789 IXMLHttpRequest_Release(xhr
);
1794 test_open(xhr
, "GET", "http://invalid.host.test.winehq.org/test/path", S_OK
);
1796 V_VT(&varbody
) = VT_EMPTY
;
1797 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1799 ok(hr
== INET_E_RESOURCE_NOT_FOUND
, "send to invalid host returned %#x.\n", hr
);
1801 IXMLHttpRequest_Release(xhr
);
1805 static void test_server_xhr(void)
1807 IServerXMLHTTPRequest
*xhr
;
1813 xhr
= create_server_xhr();
1815 test_server_open(xhr
, "GET", xmltestA
, S_OK
);
1817 V_VT(&body
) = VT_EMPTY
;
1819 hr
= IServerXMLHTTPRequest_send(xhr
, body
);
1820 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1822 skip("No connection could be made with test.winehq.org\n");
1823 IServerXMLHTTPRequest_Release(xhr
);
1826 ok(hr
== S_OK
, "send failed: %08x\n", hr
);
1828 hr
= IServerXMLHTTPRequest_get_responseText(xhr
, &response
);
1829 ok(hr
== S_OK
, "get_responseText failed: %08x\n", hr
);
1830 ok(!strcmp_wa(response
, xmltestbodyA
), "got %s\n", wine_dbgstr_w(response
));
1831 SysFreeString(response
);
1833 IServerXMLHTTPRequest_Release(xhr
);
1836 xhr
= create_server_xhr();
1838 test_server_open(xhr
, "GET", "http://invalid.host.test.winehq.org/test/path", S_OK
);
1840 V_VT(&body
) = VT_EMPTY
;
1841 hr
= IServerXMLHTTPRequest_send(xhr
, body
);
1843 ok(hr
== WININET_E_NAME_NOT_RESOLVED
, "send to invalid host returned %#x.\n", hr
);
1845 IServerXMLHTTPRequest_Release(xhr
);
1849 static void test_safe_httpreq(void)
1851 IXMLHttpRequest
*xhr
;
1855 set_safety_opt((IUnknown
*)xhr
, INTERFACESAFE_FOR_UNTRUSTED_DATA
, -1);
1858 /* different scheme */
1859 test_open(xhr
, "GET", "https://test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1861 /* different host */
1862 test_open(xhr
, "GET", "http://tests.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1863 test_open(xhr
, "GET", "http://www.test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1865 IXMLHttpRequest_Release(xhr
);
1869 static void test_supporterrorinfo(void)
1872 IXMLHttpRequest
*xhr
;
1873 IServerXMLHTTPRequest
*server_xhr
;
1874 ISupportErrorInfo
*errorinfo
, *errorinfo2
;
1879 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_ISupportErrorInfo
, (void **)&errorinfo
);
1880 ok(hr
== S_OK
, "Failed to get ISupportErrorInfo, hr %#x.\n", hr
);
1883 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_ISupportErrorInfo
, (void **)&errorinfo2
);
1884 ok(hr
== S_OK
, "Failed to get ISupportErrorInfo, hr %#x.\n", hr
);
1885 ok(errorinfo
== errorinfo2
, "Unexpected error info instance.\n");
1888 ISupportErrorInfo_Release(errorinfo2
);
1889 ISupportErrorInfo_Release(errorinfo
);
1891 IXMLHttpRequest_Release(xhr
);
1894 server_xhr
= create_server_xhr();
1896 EXPECT_REF(server_xhr
, 1);
1897 hr
= IServerXMLHTTPRequest_QueryInterface(server_xhr
, &IID_ISupportErrorInfo
, (void **)&errorinfo
);
1898 ok(hr
== S_OK
, "Failed to get ISupportErrorInfo, hr %#x.\n", hr
);
1899 EXPECT_REF(server_xhr
, 2);
1901 hr
= IServerXMLHTTPRequest_QueryInterface(server_xhr
, &IID_ISupportErrorInfo
, (void **)&errorinfo2
);
1902 ok(hr
== S_OK
, "Failed to get ISupportErrorInfo, hr %#x.\n", hr
);
1903 ok(errorinfo
== errorinfo2
, "Unexpected error info instance.\n");
1904 EXPECT_REF(server_xhr
, 3);
1906 ISupportErrorInfo_Release(errorinfo2
);
1907 ISupportErrorInfo_Release(errorinfo
);
1909 IServerXMLHTTPRequest_Release(server_xhr
);
1914 IXMLHttpRequest
*xhr
;
1918 if (!(xhr
= create_xhr()))
1920 win_skip("IXMLHTTPRequest is not available\n");
1925 IXMLHttpRequest_Release(xhr
);
1929 test_safe_httpreq();
1930 test_supporterrorinfo();