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/test.h"
40 #define EXPECT_HR(hr,hr_exp) \
41 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
43 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__)
44 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
46 ULONG rc
= IUnknown_AddRef(obj
);
47 IUnknown_Release(obj
);
48 ok_(__FILE__
,line
)(rc
-1 == ref
, "expected refcount %d, got %d\n", ref
, rc
-1);
51 DEFINE_GUID(SID_SContainerDispatch
, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
52 DEFINE_GUID(SID_UnknownSID
, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
54 static BOOL g_enablecallchecks
;
56 #define DEFINE_EXPECT(func) \
57 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
59 #define SET_EXPECT(func) \
60 expect_ ## func = TRUE
62 #define CHECK_EXPECT2(func) \
64 if (g_enablecallchecks) \
65 ok(expect_ ##func, "unexpected call " #func "\n"); \
66 called_ ## func = TRUE; \
69 #define CHECK_CALLED(func) \
71 ok(called_ ## func, "expected " #func "\n"); \
72 expect_ ## func = called_ ## func = FALSE; \
76 DEFINE_EXPECT(site_qi_IServiceProvider
);
77 DEFINE_EXPECT(site_qi_IXMLDOMDocument
);
78 DEFINE_EXPECT(site_qi_IOleClientSite
);
80 DEFINE_EXPECT(sp_queryservice_SID_SBindHost
);
81 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
82 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
83 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
84 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
86 DEFINE_EXPECT(htmldoc2_get_all
);
87 DEFINE_EXPECT(htmldoc2_get_url
);
88 DEFINE_EXPECT(collection_get_length
);
90 static int g_unexpectedcall
, g_expectedcall
;
92 static BSTR
alloc_str_from_narrow(const char *str
)
94 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
95 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
96 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
-1);
100 static BSTR alloced_bstrs
[256];
101 static int alloced_bstrs_count
;
103 static BSTR
_bstr_(const char *str
)
108 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
109 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
110 return alloced_bstrs
[alloced_bstrs_count
++];
113 static void free_bstrs(void)
116 for (i
= 0; i
< alloced_bstrs_count
; i
++)
117 SysFreeString(alloced_bstrs
[i
]);
118 alloced_bstrs_count
= 0;
121 static BSTR
a2bstr(const char *str
)
129 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
130 ret
= SysAllocStringLen(NULL
, len
);
131 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
137 /* test IHTMLElementCollection */
138 static HRESULT WINAPI
htmlecoll_QueryInterface(IHTMLElementCollection
*iface
, REFIID riid
, void **ppvObject
)
140 ok(0, "unexpected call\n");
142 return E_NOINTERFACE
;
145 static ULONG WINAPI
htmlecoll_AddRef(IHTMLElementCollection
*iface
)
150 static ULONG WINAPI
htmlecoll_Release(IHTMLElementCollection
*iface
)
155 static HRESULT WINAPI
htmlecoll_GetTypeInfoCount(IHTMLElementCollection
*iface
, UINT
*pctinfo
)
157 ok(0, "unexpected call\n");
161 static HRESULT WINAPI
htmlecoll_GetTypeInfo(IHTMLElementCollection
*iface
, UINT iTInfo
,
162 LCID lcid
, ITypeInfo
**ppTInfo
)
164 ok(0, "unexpected call\n");
168 static HRESULT WINAPI
htmlecoll_GetIDsOfNames(IHTMLElementCollection
*iface
, REFIID riid
,
169 LPOLESTR
*rgszNames
, UINT cNames
,
170 LCID lcid
, DISPID
*rgDispId
)
172 ok(0, "unexpected call\n");
176 static HRESULT WINAPI
htmlecoll_Invoke(IHTMLElementCollection
*iface
, DISPID dispIdMember
,
177 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
178 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
180 ok(0, "unexpected call\n");
184 static HRESULT WINAPI
htmlecoll_toString(IHTMLElementCollection
*iface
, BSTR
*String
)
186 ok(0, "unexpected call\n");
190 static HRESULT WINAPI
htmlecoll_put_length(IHTMLElementCollection
*iface
, LONG v
)
192 ok(0, "unexpected call\n");
196 static HRESULT WINAPI
htmlecoll_get_length(IHTMLElementCollection
*iface
, LONG
*v
)
198 CHECK_EXPECT2(collection_get_length
);
202 static HRESULT WINAPI
htmlecoll_get__newEnum(IHTMLElementCollection
*iface
, IUnknown
**p
)
204 ok(0, "unexpected call\n");
208 static HRESULT WINAPI
htmlecoll_item(IHTMLElementCollection
*iface
, VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
210 ok(0, "unexpected call\n");
214 static HRESULT WINAPI
htmlecoll_tags(IHTMLElementCollection
*iface
, VARIANT tagName
, IDispatch
**pdisp
)
216 ok(0, "unexpected call\n");
220 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl
= {
221 htmlecoll_QueryInterface
,
224 htmlecoll_GetTypeInfoCount
,
225 htmlecoll_GetTypeInfo
,
226 htmlecoll_GetIDsOfNames
,
229 htmlecoll_put_length
,
230 htmlecoll_get_length
,
231 htmlecoll_get__newEnum
,
236 static IHTMLElementCollection htmlecoll
= { &TestHTMLECollectionVtbl
};
238 /* test IHTMLDocument2 */
239 static HRESULT WINAPI
htmldoc2_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppvObject
)
243 return E_NOINTERFACE
;
246 static ULONG WINAPI
htmldoc2_AddRef(IHTMLDocument2
*iface
)
251 static ULONG WINAPI
htmldoc2_Release(IHTMLDocument2
*iface
)
256 static HRESULT WINAPI
htmldoc2_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
258 ok(0, "unexpected call\n");
262 static HRESULT WINAPI
htmldoc2_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
263 LCID lcid
, ITypeInfo
**ppTInfo
)
265 ok(0, "unexpected call\n");
269 static HRESULT WINAPI
htmldoc2_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
270 LPOLESTR
*rgszNames
, UINT cNames
,
271 LCID lcid
, DISPID
*rgDispId
)
273 ok(0, "unexpected call\n");
277 static HRESULT WINAPI
htmldoc2_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
278 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
279 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
281 ok(0, "unexpected call\n");
285 static HRESULT WINAPI
htmldoc2_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
287 ok(0, "unexpected call\n");
291 static HRESULT WINAPI
htmldoc2_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
293 CHECK_EXPECT2(htmldoc2_get_all
);
298 static HRESULT WINAPI
htmldoc2_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
300 ok(0, "unexpected call\n");
304 static HRESULT WINAPI
htmldoc2_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
306 ok(0, "unexpected call\n");
310 static HRESULT WINAPI
htmldoc2_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
312 ok(0, "unexpected call\n");
316 static HRESULT WINAPI
htmldoc2_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
318 ok(0, "unexpected call\n");
322 static HRESULT WINAPI
htmldoc2_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
324 ok(0, "unexpected call\n");
328 static HRESULT WINAPI
htmldoc2_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
330 ok(0, "unexpected call\n");
334 static HRESULT WINAPI
htmldoc2_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
336 ok(0, "unexpected call\n");
340 static HRESULT WINAPI
htmldoc2_put_title(IHTMLDocument2
*iface
, BSTR v
)
342 ok(0, "unexpected call\n");
346 static HRESULT WINAPI
htmldoc2_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
348 ok(0, "unexpected call\n");
352 static HRESULT WINAPI
htmldoc2_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
354 ok(0, "unexpected call\n");
358 static HRESULT WINAPI
htmldoc2_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
360 ok(0, "unexpected call\n");
364 static HRESULT WINAPI
htmldoc2_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
366 ok(0, "unexpected call\n");
370 static HRESULT WINAPI
htmldoc2_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
372 ok(0, "unexpected call\n");
376 static HRESULT WINAPI
htmldoc2_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
378 ok(0, "unexpected call\n");
382 static HRESULT WINAPI
htmldoc2_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
384 ok(0, "unexpected call\n");
388 static HRESULT WINAPI
htmldoc2_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
390 ok(0, "unexpected call\n");
394 static HRESULT WINAPI
htmldoc2_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
396 ok(0, "unexpected call\n");
400 static HRESULT WINAPI
htmldoc2_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
402 ok(0, "unexpected call\n");
406 static HRESULT WINAPI
htmldoc2_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
408 ok(0, "unexpected call\n");
412 static HRESULT WINAPI
htmldoc2_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
414 ok(0, "unexpected call\n");
418 static HRESULT WINAPI
htmldoc2_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
420 ok(0, "unexpected call\n");
424 static HRESULT WINAPI
htmldoc2_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
426 ok(0, "unexpected call\n");
430 static HRESULT WINAPI
htmldoc2_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
432 ok(0, "unexpected call\n");
436 static HRESULT WINAPI
htmldoc2_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
438 ok(0, "unexpected call\n");
442 static HRESULT WINAPI
htmldoc2_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
444 ok(0, "unexpected call\n");
448 static HRESULT WINAPI
htmldoc2_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
450 ok(0, "unexpected call\n");
454 static HRESULT WINAPI
htmldoc2_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
456 ok(0, "unexpected call\n");
460 static HRESULT WINAPI
htmldoc2_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
462 ok(0, "unexpected call\n");
466 static HRESULT WINAPI
htmldoc2_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
468 ok(0, "unexpected call\n");
472 static HRESULT WINAPI
htmldoc2_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
474 ok(0, "unexpected call\n");
478 static HRESULT WINAPI
htmldoc2_put_URL(IHTMLDocument2
*iface
, BSTR v
)
480 ok(0, "unexpected call\n");
484 static HRESULT WINAPI
htmldoc2_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
486 CHECK_EXPECT2(htmldoc2_get_url
);
487 *p
= a2bstr("http://test.winehq.org/");
491 static HRESULT WINAPI
htmldoc2_put_domain(IHTMLDocument2
*iface
, BSTR v
)
493 ok(0, "unexpected call\n");
497 static HRESULT WINAPI
htmldoc2_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
499 ok(0, "unexpected call\n");
503 static HRESULT WINAPI
htmldoc2_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
505 ok(0, "unexpected call\n");
509 static HRESULT WINAPI
htmldoc2_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
511 ok(0, "unexpected call\n");
515 static HRESULT WINAPI
htmldoc2_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
517 ok(0, "unexpected call\n");
521 static HRESULT WINAPI
htmldoc2_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
523 ok(0, "unexpected call\n");
527 static HRESULT WINAPI
htmldoc2_put_charset(IHTMLDocument2
*iface
, BSTR v
)
529 ok(0, "unexpected call\n");
533 static HRESULT WINAPI
htmldoc2_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
535 ok(0, "unexpected call\n");
539 static HRESULT WINAPI
htmldoc2_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
541 ok(0, "unexpected call\n");
545 static HRESULT WINAPI
htmldoc2_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
547 ok(0, "unexpected call\n");
551 static HRESULT WINAPI
htmldoc2_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
553 ok(0, "unexpected call\n");
557 static HRESULT WINAPI
htmldoc2_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
559 ok(0, "unexpected call\n");
563 static HRESULT WINAPI
htmldoc2_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
565 ok(0, "unexpected call\n");
569 static HRESULT WINAPI
htmldoc2_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
571 ok(0, "unexpected call\n");
575 static HRESULT WINAPI
htmldoc2_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
577 ok(0, "unexpected call\n");
581 static HRESULT WINAPI
htmldoc2_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
583 ok(0, "unexpected call\n");
587 static HRESULT WINAPI
htmldoc2_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
589 ok(0, "unexpected call\n");
593 static HRESULT WINAPI
htmldoc2_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
595 ok(0, "unexpected call\n");
599 static HRESULT WINAPI
htmldoc2_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
601 ok(0, "unexpected call\n");
605 static HRESULT WINAPI
htmldoc2_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
607 ok(0, "unexpected call\n");
611 static HRESULT WINAPI
htmldoc2_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
612 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
614 ok(0, "unexpected call\n");
618 static HRESULT WINAPI
htmldoc2_close(IHTMLDocument2
*iface
)
620 ok(0, "unexpected call\n");
624 static HRESULT WINAPI
htmldoc2_clear(IHTMLDocument2
*iface
)
626 ok(0, "unexpected call\n");
630 static HRESULT WINAPI
htmldoc2_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
633 ok(0, "unexpected call\n");
637 static HRESULT WINAPI
htmldoc2_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
640 ok(0, "unexpected call\n");
644 static HRESULT WINAPI
htmldoc2_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
647 ok(0, "unexpected call\n");
651 static HRESULT WINAPI
htmldoc2_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
654 ok(0, "unexpected call\n");
658 static HRESULT WINAPI
htmldoc2_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
661 ok(0, "unexpected call\n");
665 static HRESULT WINAPI
htmldoc2_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
668 ok(0, "unexpected call\n");
672 static HRESULT WINAPI
htmldoc2_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
673 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
675 ok(0, "unexpected call\n");
679 static HRESULT WINAPI
htmldoc2_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
682 ok(0, "unexpected call\n");
686 static HRESULT WINAPI
htmldoc2_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
687 IHTMLElement
**newElem
)
689 ok(0, "unexpected call\n");
693 static HRESULT WINAPI
htmldoc2_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
695 ok(0, "unexpected call\n");
699 static HRESULT WINAPI
htmldoc2_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
701 ok(0, "unexpected call\n");
705 static HRESULT WINAPI
htmldoc2_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
707 ok(0, "unexpected call\n");
711 static HRESULT WINAPI
htmldoc2_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
713 ok(0, "unexpected call\n");
717 static HRESULT WINAPI
htmldoc2_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
719 ok(0, "unexpected call\n");
723 static HRESULT WINAPI
htmldoc2_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
725 ok(0, "unexpected call\n");
729 static HRESULT WINAPI
htmldoc2_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
731 ok(0, "unexpected call\n");
735 static HRESULT WINAPI
htmldoc2_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
737 ok(0, "unexpected call\n");
741 static HRESULT WINAPI
htmldoc2_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
743 ok(0, "unexpected call\n");
747 static HRESULT WINAPI
htmldoc2_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
749 ok(0, "unexpected call\n");
753 static HRESULT WINAPI
htmldoc2_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
755 ok(0, "unexpected call\n");
759 static HRESULT WINAPI
htmldoc2_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
761 ok(0, "unexpected call\n");
765 static HRESULT WINAPI
htmldoc2_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
767 ok(0, "unexpected call\n");
771 static HRESULT WINAPI
htmldoc2_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
773 ok(0, "unexpected call\n");
777 static HRESULT WINAPI
htmldoc2_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
779 ok(0, "unexpected call\n");
783 static HRESULT WINAPI
htmldoc2_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
785 ok(0, "unexpected call\n");
789 static HRESULT WINAPI
htmldoc2_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
791 ok(0, "unexpected call\n");
795 static HRESULT WINAPI
htmldoc2_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
797 ok(0, "unexpected call\n");
801 static HRESULT WINAPI
htmldoc2_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
803 ok(0, "unexpected call\n");
807 static HRESULT WINAPI
htmldoc2_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
809 ok(0, "unexpected call\n");
813 static HRESULT WINAPI
htmldoc2_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
815 ok(0, "unexpected call\n");
819 static HRESULT WINAPI
htmldoc2_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
821 ok(0, "unexpected call\n");
825 static HRESULT WINAPI
htmldoc2_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
827 ok(0, "unexpected call\n");
831 static HRESULT WINAPI
htmldoc2_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
833 ok(0, "unexpected call\n");
837 static HRESULT WINAPI
htmldoc2_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
839 ok(0, "unexpected call\n");
843 static HRESULT WINAPI
htmldoc2_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
845 ok(0, "unexpected call\n");
849 static HRESULT WINAPI
htmldoc2_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
851 ok(0, "unexpected call\n");
855 static HRESULT WINAPI
htmldoc2_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
857 ok(0, "unexpected call\n");
861 static HRESULT WINAPI
htmldoc2_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
863 ok(0, "unexpected call\n");
867 static HRESULT WINAPI
htmldoc2_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
869 ok(0, "unexpected call\n");
873 static HRESULT WINAPI
htmldoc2_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
875 ok(0, "unexpected call\n");
879 static HRESULT WINAPI
htmldoc2_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
881 ok(0, "unexpected call\n");
885 static HRESULT WINAPI
htmldoc2_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
887 ok(0, "unexpected call\n");
891 static HRESULT WINAPI
htmldoc2_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
893 ok(0, "unexpected call\n");
897 static HRESULT WINAPI
htmldoc2_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
898 IHTMLElement
**elementHit
)
900 ok(0, "unexpected call\n");
904 static HRESULT WINAPI
htmldoc2_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
906 ok(0, "unexpected call\n");
910 static HRESULT WINAPI
htmldoc2_get_styleSheets(IHTMLDocument2
*iface
,
911 IHTMLStyleSheetsCollection
**p
)
913 ok(0, "unexpected call\n");
917 static HRESULT WINAPI
htmldoc2_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
919 ok(0, "unexpected call\n");
923 static HRESULT WINAPI
htmldoc2_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
925 ok(0, "unexpected call\n");
929 static HRESULT WINAPI
htmldoc2_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
931 ok(0, "unexpected call\n");
935 static HRESULT WINAPI
htmldoc2_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
937 ok(0, "unexpected call\n");
941 static HRESULT WINAPI
htmldoc2_toString(IHTMLDocument2
*iface
, BSTR
*String
)
943 ok(0, "unexpected call\n");
947 static HRESULT WINAPI
htmldoc2_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
948 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
950 ok(0, "unexpected call\n");
954 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl
= {
955 htmldoc2_QueryInterface
,
958 htmldoc2_GetTypeInfoCount
,
959 htmldoc2_GetTypeInfo
,
960 htmldoc2_GetIDsOfNames
,
965 htmldoc2_get_activeElement
,
967 htmldoc2_get_applets
,
970 htmldoc2_get_anchors
,
973 htmldoc2_get_scripts
,
974 htmldoc2_put_designMode
,
975 htmldoc2_get_designMode
,
976 htmldoc2_get_selection
,
977 htmldoc2_get_readyState
,
980 htmldoc2_get_plugins
,
981 htmldoc2_put_alinkColor
,
982 htmldoc2_get_alinkColor
,
983 htmldoc2_put_bgColor
,
984 htmldoc2_get_bgColor
,
985 htmldoc2_put_fgColor
,
986 htmldoc2_get_fgColor
,
987 htmldoc2_put_linkColor
,
988 htmldoc2_get_linkColor
,
989 htmldoc2_put_vlinkColor
,
990 htmldoc2_get_vlinkColor
,
991 htmldoc2_get_referrer
,
992 htmldoc2_get_location
,
993 htmldoc2_get_lastModified
,
1000 htmldoc2_put_expando
,
1001 htmldoc2_get_expando
,
1002 htmldoc2_put_charset
,
1003 htmldoc2_get_charset
,
1004 htmldoc2_put_defaultCharset
,
1005 htmldoc2_get_defaultCharset
,
1006 htmldoc2_get_mimeType
,
1007 htmldoc2_get_fileSize
,
1008 htmldoc2_get_fileCreatedDate
,
1009 htmldoc2_get_fileModifiedDate
,
1010 htmldoc2_get_fileUpdatedDate
,
1011 htmldoc2_get_security
,
1012 htmldoc2_get_protocol
,
1013 htmldoc2_get_nameProp
,
1019 htmldoc2_queryCommandSupported
,
1020 htmldoc2_queryCommandEnabled
,
1021 htmldoc2_queryCommandState
,
1022 htmldoc2_queryCommandIndeterm
,
1023 htmldoc2_queryCommandText
,
1024 htmldoc2_queryCommandValue
,
1025 htmldoc2_execCommand
,
1026 htmldoc2_execCommandShowHelp
,
1027 htmldoc2_createElement
,
1028 htmldoc2_put_onhelp
,
1029 htmldoc2_get_onhelp
,
1030 htmldoc2_put_onclick
,
1031 htmldoc2_get_onclick
,
1032 htmldoc2_put_ondblclick
,
1033 htmldoc2_get_ondblclick
,
1034 htmldoc2_put_onkeyup
,
1035 htmldoc2_get_onkeyup
,
1036 htmldoc2_put_onkeydown
,
1037 htmldoc2_get_onkeydown
,
1038 htmldoc2_put_onkeypress
,
1039 htmldoc2_get_onkeypress
,
1040 htmldoc2_put_onmouseup
,
1041 htmldoc2_get_onmouseup
,
1042 htmldoc2_put_onmousedown
,
1043 htmldoc2_get_onmousedown
,
1044 htmldoc2_put_onmousemove
,
1045 htmldoc2_get_onmousemove
,
1046 htmldoc2_put_onmouseout
,
1047 htmldoc2_get_onmouseout
,
1048 htmldoc2_put_onmouseover
,
1049 htmldoc2_get_onmouseover
,
1050 htmldoc2_put_onreadystatechange
,
1051 htmldoc2_get_onreadystatechange
,
1052 htmldoc2_put_onafterupdate
,
1053 htmldoc2_get_onafterupdate
,
1054 htmldoc2_put_onrowexit
,
1055 htmldoc2_get_onrowexit
,
1056 htmldoc2_put_onrowenter
,
1057 htmldoc2_get_onrowenter
,
1058 htmldoc2_put_ondragstart
,
1059 htmldoc2_get_ondragstart
,
1060 htmldoc2_put_onselectstart
,
1061 htmldoc2_get_onselectstart
,
1062 htmldoc2_elementFromPoint
,
1063 htmldoc2_get_parentWindow
,
1064 htmldoc2_get_styleSheets
,
1065 htmldoc2_put_onbeforeupdate
,
1066 htmldoc2_get_onbeforeupdate
,
1067 htmldoc2_put_onerrorupdate
,
1068 htmldoc2_get_onerrorupdate
,
1070 htmldoc2_createStyleSheet
1073 static IHTMLDocument2 htmldoc2
= { &TestHTMLDocumentVtbl
};
1075 static HRESULT WINAPI
sp_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppvObject
)
1079 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1080 IsEqualGUID(riid
, &IID_IServiceProvider
))
1083 IServiceProvider_AddRef(iface
);
1087 ok(0, "unexpected query interface: %s\n", wine_dbgstr_guid(riid
));
1089 return E_NOINTERFACE
;
1092 static ULONG WINAPI
sp_AddRef(IServiceProvider
*iface
)
1097 static ULONG WINAPI
sp_Release(IServiceProvider
*iface
)
1102 static HRESULT WINAPI
sp_QueryService(IServiceProvider
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1106 if (IsEqualGUID(service
, &SID_SBindHost
) &&
1107 IsEqualGUID(riid
, &IID_IBindHost
))
1109 CHECK_EXPECT2(sp_queryservice_SID_SBindHost
);
1111 else if (IsEqualGUID(service
, &SID_SContainerDispatch
) &&
1112 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1114 CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1116 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1117 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1119 CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2
);
1123 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1124 IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1126 CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc
);
1128 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1129 IsEqualGUID(riid
, &IID_IInternetHostSecurityManager
))
1131 CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr
);
1133 else if (IsEqualGUID(service
, &SID_UnknownSID
) &&
1134 IsEqualGUID(riid
, &IID_IStream
))
1136 /* FIXME: unidentified service id */
1138 else if ((IsEqualGUID(service
, &IID_IInternetProtocol
) && IsEqualGUID(riid
, &IID_IInternetProtocol
)) ||
1139 (IsEqualGUID(service
, &IID_IHttpNegotiate2
) && IsEqualGUID(riid
, &IID_IHttpNegotiate2
)) ||
1140 (IsEqualGUID(service
, &IID_IGetBindHandle
) && IsEqualGUID(riid
, &IID_IGetBindHandle
)) ||
1141 (IsEqualGUID(service
, &IID_IBindStatusCallback
) && IsEqualGUID(riid
, &IID_IBindStatusCallback
)) ||
1142 (IsEqualGUID(service
, &IID_IWindowForBindingUI
) && IsEqualGUID(riid
, &IID_IWindowForBindingUI
)))
1146 ok(0, "unexpected request: sid %s, riid %s\n", wine_dbgstr_guid(service
), wine_dbgstr_guid(riid
));
1151 static const IServiceProviderVtbl testprovVtbl
=
1159 static IServiceProvider testprov
= { &testprovVtbl
};
1161 static HRESULT WINAPI
site_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
1165 if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1166 CHECK_EXPECT2(site_qi_IServiceProvider
);
1168 if (IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1169 CHECK_EXPECT2(site_qi_IXMLDOMDocument
);
1171 if (IsEqualGUID(riid
, &IID_IOleClientSite
))
1172 CHECK_EXPECT2(site_qi_IOleClientSite
);
1174 if (IsEqualGUID(riid
, &IID_IUnknown
))
1176 else if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1177 *ppvObject
= &testprov
;
1179 if (*ppvObject
) IUnknown_AddRef(iface
);
1181 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1184 static ULONG WINAPI
site_AddRef(IUnknown
*iface
)
1189 static ULONG WINAPI
site_Release(IUnknown
*iface
)
1194 static const IUnknownVtbl testsiteVtbl
=
1196 site_QueryInterface
,
1201 static IUnknown testsite
= { &testsiteVtbl
};
1205 IDispatch IDispatch_iface
;
1209 static IXMLHttpRequest
*httpreq
;
1211 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
1213 return CONTAINING_RECORD(iface
, dispevent
, IDispatch_iface
);
1216 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
1220 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
1221 IsEqualGUID( riid
, &IID_IUnknown
) )
1226 return E_NOINTERFACE
;
1228 IDispatch_AddRef( iface
);
1233 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
1235 dispevent
*This
= impl_from_IDispatch( iface
);
1236 return InterlockedIncrement( &This
->ref
);
1239 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
1241 dispevent
*This
= impl_from_IDispatch( iface
);
1242 ULONG ref
= InterlockedDecrement( &This
->ref
);
1245 HeapFree(GetProcessHeap(), 0, This
);
1250 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1257 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1258 LCID lcid
, ITypeInfo
**ppTInfo
)
1264 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1265 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1271 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
1272 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
1273 EXCEPINFO
*excepInfo
, UINT
*argErr
)
1278 ok(member
== 0, "expected 0 member, got %d\n", member
);
1279 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
1280 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
1282 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
1283 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
1284 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
1285 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
1287 ok(result
== NULL
, "got %p\n", result
);
1288 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
1289 ok(argErr
== NULL
, "got %p\n", argErr
);
1293 state
= READYSTATE_UNINITIALIZED
;
1294 hr
= IXMLHttpRequest_get_readyState(httpreq
, &state
);
1295 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1296 if (state
== READYSTATE_COMPLETE
)
1300 hr
= IXMLHttpRequest_get_responseText(httpreq
, &text
);
1301 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1302 ok(*text
!= 0, "got %s\n", wine_dbgstr_w(text
));
1303 SysFreeString(text
);
1309 static const IDispatchVtbl dispeventVtbl
=
1311 dispevent_QueryInterface
,
1314 dispevent_GetTypeInfoCount
,
1315 dispevent_GetTypeInfo
,
1316 dispevent_GetIDsOfNames
,
1320 static IDispatch
* create_dispevent(void)
1322 dispevent
*event
= HeapAlloc(GetProcessHeap(), 0, sizeof(*event
));
1324 event
->IDispatch_iface
.lpVtbl
= &dispeventVtbl
;
1327 return &event
->IDispatch_iface
;
1330 static IXMLHttpRequest
*create_xhr(void)
1332 IXMLHttpRequest
*ret
;
1335 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
1336 &IID_IXMLHttpRequest
, (void**)&ret
);
1338 return SUCCEEDED(hr
) ? ret
: NULL
;
1341 static void set_safety_opt(IUnknown
*unk
, DWORD mask
, DWORD opts
)
1343 IObjectSafety
*obj_safety
;
1346 hr
= IUnknown_QueryInterface(unk
, &IID_IObjectSafety
, (void**)&obj_safety
);
1347 ok(hr
== S_OK
, "Could not get IObjectSafety iface: %08x\n", hr
);
1349 hr
= IObjectSafety_SetInterfaceSafetyOptions(obj_safety
, &IID_IDispatch
, mask
, mask
&opts
);
1350 ok(hr
== S_OK
, "SetInterfaceSafetyOptions failed: %08x\n", hr
);
1352 IObjectSafety_Release(obj_safety
);
1355 static void set_xhr_site(IXMLHttpRequest
*xhr
)
1357 IObjectWithSite
*obj_site
;
1360 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1361 ok(hr
== S_OK
, "Could not get IObjectWithSite iface: %08x\n", hr
);
1363 g_enablecallchecks
= TRUE
;
1365 SET_EXPECT(site_qi_IServiceProvider
);
1366 SET_EXPECT(sp_queryservice_SID_SBindHost
);
1367 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1368 SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
1369 SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
1370 SET_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
1372 /* calls to IHTMLDocument2 */
1373 SET_EXPECT(htmldoc2_get_all
);
1374 SET_EXPECT(collection_get_length
);
1375 SET_EXPECT(htmldoc2_get_url
);
1377 SET_EXPECT(site_qi_IXMLDOMDocument
);
1378 SET_EXPECT(site_qi_IOleClientSite
);
1380 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1381 EXPECT_HR(hr
, S_OK
);
1383 CHECK_CALLED(site_qi_IServiceProvider
);
1385 CHECK_CALLED(sp_queryservice_SID_SBindHost
);
1386 CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1387 CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2
);
1389 CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc
);
1390 /* this one isn't very reliable
1391 CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
1393 CHECK_CALLED(htmldoc2_get_all
);
1394 CHECK_CALLED(collection_get_length
);
1396 CHECK_CALLED(htmldoc2_get_url
);
1399 CHECK_CALLED(site_qi_IXMLDOMDocument
);
1400 CHECK_CALLED(site_qi_IOleClientSite
);
1403 g_enablecallchecks
= FALSE
;
1405 IObjectWithSite_Release(obj_site
);
1408 #define test_open(a,b,c,d) _test_open(__LINE__,a,b,c,d)
1409 static void _test_open(unsigned line
, IXMLHttpRequest
*xhr
, const char *method
, const char *url
, HRESULT exhres
)
1411 VARIANT empty
, vfalse
;
1414 V_VT(&empty
) = VT_EMPTY
;
1415 V_VT(&vfalse
) = VT_BOOL
;
1416 V_BOOL(&vfalse
) = VARIANT_FALSE
;
1418 hr
= IXMLHttpRequest_open(xhr
, _bstr_(method
), _bstr_(url
), vfalse
, empty
, empty
);
1419 ok_(__FILE__
,line
)(hr
== exhres
, "open(%s %s) failed: %08x, expected %08x\n", method
, url
, hr
, exhres
);
1422 static void test_XMLHTTP(void)
1424 static const char bodyA
[] = "mode=Test";
1425 static const char urlA
[] = "http://crossover.codeweavers.com/posttest.php";
1426 static const char xmltestA
[] = "http://crossover.codeweavers.com/xmltest.xml";
1427 static const char referertesturl
[] = "http://test.winehq.org/tests/referer.php";
1428 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
1429 static const CHAR xmltestbodyA
[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
1430 static const WCHAR norefererW
[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0};
1432 IXMLHttpRequest
*xhr
;
1433 IObjectWithSite
*obj_site
, *obj_site2
;
1434 BSTR bstrResponse
, str
, str1
;
1435 VARIANT varbody
, varbody_ref
;
1437 LONG state
, status
, bound
;
1445 VariantInit(&dummy
);
1446 V_VT(&dummy
) = VT_ERROR
;
1447 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
1449 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, NULL
);
1450 EXPECT_HR(hr
, S_OK
);
1452 hr
= IXMLHttpRequest_abort(xhr
);
1453 EXPECT_HR(hr
, S_OK
);
1455 V_VT(&varbody
) = VT_I2
;
1457 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1458 EXPECT_HR(hr
, E_PENDING
);
1459 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1460 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
1462 V_VT(&varbody
) = VT_I2
;
1464 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1465 EXPECT_HR(hr
, E_PENDING
);
1466 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1467 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
1469 /* send before open */
1470 hr
= IXMLHttpRequest_send(xhr
, dummy
);
1471 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1473 /* initial status code */
1474 hr
= IXMLHttpRequest_get_status(xhr
, NULL
);
1475 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1477 status
= 0xdeadbeef;
1478 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1479 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1480 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1482 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1483 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
1485 /* invalid parameters */
1486 test_open(xhr
, NULL
, NULL
, E_INVALIDARG
);
1487 test_open(xhr
, "POST", NULL
, E_INVALIDARG
);
1488 test_open(xhr
, NULL
, urlA
, E_INVALIDARG
);
1490 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, NULL
);
1491 EXPECT_HR(hr
, E_INVALIDARG
);
1493 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), NULL
);
1494 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1496 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1497 EXPECT_HR(hr
, E_INVALIDARG
);
1499 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1500 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1502 hr
= IXMLHttpRequest_get_readyState(xhr
, NULL
);
1503 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1506 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1507 EXPECT_HR(hr
, S_OK
);
1508 ok(state
== READYSTATE_UNINITIALIZED
, "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1511 event
= create_dispevent();
1513 EXPECT_REF(event
, 1);
1514 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, event
);
1515 EXPECT_HR(hr
, S_OK
);
1516 EXPECT_REF(event
, 2);
1518 g_unexpectedcall
= g_expectedcall
= 0;
1520 test_open(xhr
, "POST", urlA
, S_OK
);
1522 ok(g_unexpectedcall
== 0, "unexpected disp event call\n");
1523 ok(g_expectedcall
== 1 || broken(g_expectedcall
== 0) /* win2k */, "no expected disp event call\n");
1525 /* status code after ::open() */
1526 status
= 0xdeadbeef;
1527 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1528 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1529 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1532 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1533 EXPECT_HR(hr
, S_OK
);
1534 ok(state
== READYSTATE_LOADING
, "got %d, expected READYSTATE_LOADING\n", state
);
1536 hr
= IXMLHttpRequest_abort(xhr
);
1537 EXPECT_HR(hr
, S_OK
);
1540 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1541 EXPECT_HR(hr
, S_OK
);
1542 ok(state
== READYSTATE_UNINITIALIZED
|| broken(state
== READYSTATE_LOADING
) /* win2k */,
1543 "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1545 test_open(xhr
, "POST", urlA
, S_OK
);
1547 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1548 EXPECT_HR(hr
, S_OK
);
1550 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1551 EXPECT_HR(hr
, E_INVALIDARG
);
1553 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_(""), _bstr_("value1"));
1554 EXPECT_HR(hr
, E_INVALIDARG
);
1556 V_VT(&varbody
) = VT_BSTR
;
1557 V_BSTR(&varbody
) = _bstr_(bodyA
);
1559 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1560 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1562 skip("No connection could be made with crossover.codeweavers.com\n");
1563 IXMLHttpRequest_Release(xhr
);
1566 EXPECT_HR(hr
, S_OK
);
1568 /* response headers */
1569 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, NULL
);
1570 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1571 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str
);
1572 EXPECT_HR(hr
, S_OK
);
1573 /* status line is stripped already */
1574 ok(memcmp(str
, _bstr_("HTTP"), 4*sizeof(WCHAR
)), "got response headers %s\n", wine_dbgstr_w(str
));
1575 ok(*str
, "got empty headers\n");
1576 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str1
);
1577 EXPECT_HR(hr
, S_OK
);
1578 ok(str1
!= str
, "got %p\n", str1
);
1579 SysFreeString(str1
);
1582 hr
= IXMLHttpRequest_getResponseHeader(xhr
, NULL
, NULL
);
1583 EXPECT_HR(hr
, E_INVALIDARG
);
1584 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), NULL
);
1585 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1586 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), &str
);
1587 EXPECT_HR(hr
, S_OK
);
1588 ok(*str
!= ' ', "got leading space in header %s\n", wine_dbgstr_w(str
));
1591 /* status code after ::send() */
1592 status
= 0xdeadbeef;
1593 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1594 EXPECT_HR(hr
, S_OK
);
1595 ok(status
== 200, "got %d\n", status
);
1597 hr
= IXMLHttpRequest_get_statusText(xhr
, NULL
);
1598 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1600 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1601 EXPECT_HR(hr
, S_OK
);
1602 ok(!lstrcmpW(str
, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str
));
1605 /* another ::send() after completed request */
1606 V_VT(&varbody
) = VT_BSTR
;
1607 V_BSTR(&varbody
) = _bstr_(bodyA
);
1609 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1610 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1612 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1613 EXPECT_HR(hr
, S_OK
);
1614 /* the server currently returns "FAILED" because the Content-Type header is
1615 * not what the server expects */
1618 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)),
1619 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse
), wine_dbgstr_w(bstrResponse
));
1620 SysFreeString(bstrResponse
);
1623 /* POST: VT_VARIANT|VT_BYREF body */
1624 test_open(xhr
, "POST", urlA
, S_OK
);
1626 V_VT(&varbody_ref
) = VT_VARIANT
|VT_BYREF
;
1627 V_VARIANTREF(&varbody_ref
) = &varbody
;
1628 hr
= IXMLHttpRequest_send(xhr
, varbody_ref
);
1629 EXPECT_HR(hr
, S_OK
);
1632 test_open(xhr
, "GET", xmltestA
, S_OK
);
1634 V_VT(&varbody
) = VT_EMPTY
;
1636 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1637 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1639 skip("No connection could be made with crossover.codeweavers.com\n");
1640 IXMLHttpRequest_Release(xhr
);
1643 EXPECT_HR(hr
, S_OK
);
1645 hr
= IXMLHttpRequest_get_responseText(xhr
, NULL
);
1646 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1648 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1649 EXPECT_HR(hr
, S_OK
);
1650 ok(!memcmp(bstrResponse
, _bstr_(xmltestbodyA
), sizeof(xmltestbodyA
)*sizeof(WCHAR
)),
1651 "expected %s, got %s\n", xmltestbodyA
, wine_dbgstr_w(bstrResponse
));
1652 SysFreeString(bstrResponse
);
1654 hr
= IXMLHttpRequest_get_responseBody(xhr
, NULL
);
1655 EXPECT_HR(hr
, E_INVALIDARG
);
1657 V_VT(&varbody
) = VT_EMPTY
;
1658 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1659 EXPECT_HR(hr
, S_OK
);
1660 ok(V_VT(&varbody
) == (VT_ARRAY
|VT_UI1
), "got type %d, expected %d\n", V_VT(&varbody
), VT_ARRAY
|VT_UI1
);
1661 ok(SafeArrayGetDim(V_ARRAY(&varbody
)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody
)));
1664 hr
= SafeArrayGetLBound(V_ARRAY(&varbody
), 1, &bound
);
1665 EXPECT_HR(hr
, S_OK
);
1666 ok(bound
== 0, "got %d, expected zero bound\n", bound
);
1668 hr
= SafeArrayAccessData(V_ARRAY(&varbody
), &ptr
);
1669 EXPECT_HR(hr
, S_OK
);
1670 ok(memcmp(ptr
, xmltestbodyA
, sizeof(xmltestbodyA
)-1) == 0, "got wrong body data\n");
1671 SafeArrayUnaccessData(V_ARRAY(&varbody
));
1673 VariantClear(&varbody
);
1675 /* get_responseStream */
1676 hr
= IXMLHttpRequest_get_responseStream(xhr
, NULL
);
1677 EXPECT_HR(hr
, E_INVALIDARG
);
1679 V_VT(&varbody
) = VT_EMPTY
;
1680 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1681 ok(V_VT(&varbody
) == VT_UNKNOWN
, "got type %d\n", V_VT(&varbody
));
1682 EXPECT_HR(hr
, S_OK
);
1683 EXPECT_REF(V_UNKNOWN(&varbody
), 1);
1686 hr
= GetHGlobalFromStream((IStream
*)V_UNKNOWN(&varbody
), &g
);
1687 EXPECT_HR(hr
, S_OK
);
1688 ok(g
!= NULL
, "got %p\n", g
);
1690 IDispatch_Release(event
);
1692 /* test if referrer header is sent */
1693 test_open(xhr
, "GET", referertesturl
, S_OK
);
1695 V_VT(&varbody
) = VT_EMPTY
;
1696 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1697 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1698 hr
= IXMLHttpRequest_get_responseText(xhr
, &str
);
1699 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1700 ok(!lstrcmpW(str
, norefererW
), "got response text %s\n", wine_dbgstr_w(str
));
1703 /* interaction with object site */
1704 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1705 EXPECT_HR(hr
, S_OK
);
1707 hr
= IObjectWithSite_SetSite(obj_site
, NULL
);
1708 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1710 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site2
);
1711 EXPECT_HR(hr
, S_OK
);
1712 ok(obj_site
== obj_site2
|| broken(obj_site
!= obj_site2
), "got new instance\n");
1713 IObjectWithSite_Release(obj_site2
);
1717 test_open(xhr
, "GET", "tests/referer.php", S_OK
);
1718 str1
= a2bstr("http://test.winehq.org/");
1720 V_VT(&varbody
) = VT_EMPTY
;
1721 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1722 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1724 hr
= IXMLHttpRequest_get_responseText(xhr
, &str
);
1725 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1726 ok(!lstrcmpW(str
, str1
), "got response text %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(str1
));
1728 SysFreeString(str1
);
1730 /* try to set site another time */
1731 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1732 EXPECT_HR(hr
, S_OK
);
1734 IObjectWithSite_Release(obj_site
);
1735 IXMLHttpRequest_Release(xhr
);
1739 static void test_safe_httpreq(void)
1741 IXMLHttpRequest
*xhr
;
1745 set_safety_opt((IUnknown
*)xhr
, INTERFACESAFE_FOR_UNTRUSTED_DATA
, -1);
1748 /* different scheme */
1749 test_open(xhr
, "GET", "https://test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1751 /* different host */
1752 test_open(xhr
, "GET", "http://tests.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1753 test_open(xhr
, "GET", "http://www.test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1755 IXMLHttpRequest_Release(xhr
);
1760 IXMLHttpRequest
*xhr
;
1764 if((xhr
= create_xhr())) {
1765 IXMLHttpRequest_Release(xhr
);
1768 test_safe_httpreq();
1770 win_skip("IXMLHTTPRequest is not available\n");