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
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
31 //#include "windows.h"
33 #include <wine/test.h>
39 //#include "msxml2did.h"
46 #define EXPECT_HR(hr,hr_exp) \
47 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
49 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__)
50 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
52 ULONG rc
= IUnknown_AddRef(obj
);
53 IUnknown_Release(obj
);
54 ok_(__FILE__
,line
)(rc
-1 == ref
, "expected refcount %d, got %d\n", ref
, rc
-1);
57 DEFINE_GUID(SID_SContainerDispatch
, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
58 DEFINE_GUID(SID_UnknownSID
, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
60 static BOOL g_enablecallchecks
;
62 #define DEFINE_EXPECT(func) \
63 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
65 #define SET_EXPECT(func) \
66 expect_ ## func = TRUE
68 #define CHECK_EXPECT2(func) \
70 if (g_enablecallchecks) \
71 ok(expect_ ##func, "unexpected call " #func "\n"); \
72 called_ ## func = TRUE; \
75 #define CHECK_CALLED(func) \
77 ok(called_ ## func, "expected " #func "\n"); \
78 expect_ ## func = called_ ## func = FALSE; \
82 DEFINE_EXPECT(site_qi_IServiceProvider
);
83 DEFINE_EXPECT(site_qi_IXMLDOMDocument
);
84 DEFINE_EXPECT(site_qi_IOleClientSite
);
86 DEFINE_EXPECT(sp_queryservice_SID_SBindHost
);
87 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
88 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
89 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
90 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
92 DEFINE_EXPECT(htmldoc2_get_all
);
93 DEFINE_EXPECT(htmldoc2_get_url
);
94 DEFINE_EXPECT(collection_get_length
);
96 static int g_unexpectedcall
, g_expectedcall
;
98 static BSTR
alloc_str_from_narrow(const char *str
)
100 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
101 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
102 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
-1);
106 static BSTR alloced_bstrs
[256];
107 static int alloced_bstrs_count
;
109 static BSTR
_bstr_(const char *str
)
114 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
115 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
116 return alloced_bstrs
[alloced_bstrs_count
++];
119 static void free_bstrs(void)
122 for (i
= 0; i
< alloced_bstrs_count
; i
++)
123 SysFreeString(alloced_bstrs
[i
]);
124 alloced_bstrs_count
= 0;
127 static BSTR
a2bstr(const char *str
)
135 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
136 ret
= SysAllocStringLen(NULL
, len
);
137 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
143 /* test IHTMLElementCollection */
144 static HRESULT WINAPI
htmlecoll_QueryInterface(IHTMLElementCollection
*iface
, REFIID riid
, void **ppvObject
)
146 ok(0, "unexpected call\n");
148 return E_NOINTERFACE
;
151 static ULONG WINAPI
htmlecoll_AddRef(IHTMLElementCollection
*iface
)
156 static ULONG WINAPI
htmlecoll_Release(IHTMLElementCollection
*iface
)
161 static HRESULT WINAPI
htmlecoll_GetTypeInfoCount(IHTMLElementCollection
*iface
, UINT
*pctinfo
)
163 ok(0, "unexpected call\n");
167 static HRESULT WINAPI
htmlecoll_GetTypeInfo(IHTMLElementCollection
*iface
, UINT iTInfo
,
168 LCID lcid
, ITypeInfo
**ppTInfo
)
170 ok(0, "unexpected call\n");
174 static HRESULT WINAPI
htmlecoll_GetIDsOfNames(IHTMLElementCollection
*iface
, REFIID riid
,
175 LPOLESTR
*rgszNames
, UINT cNames
,
176 LCID lcid
, DISPID
*rgDispId
)
178 ok(0, "unexpected call\n");
182 static HRESULT WINAPI
htmlecoll_Invoke(IHTMLElementCollection
*iface
, DISPID dispIdMember
,
183 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
184 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
186 ok(0, "unexpected call\n");
190 static HRESULT WINAPI
htmlecoll_toString(IHTMLElementCollection
*iface
, BSTR
*String
)
192 ok(0, "unexpected call\n");
196 static HRESULT WINAPI
htmlecoll_put_length(IHTMLElementCollection
*iface
, LONG v
)
198 ok(0, "unexpected call\n");
202 static HRESULT WINAPI
htmlecoll_get_length(IHTMLElementCollection
*iface
, LONG
*v
)
204 CHECK_EXPECT2(collection_get_length
);
208 static HRESULT WINAPI
htmlecoll_get__newEnum(IHTMLElementCollection
*iface
, IUnknown
**p
)
210 ok(0, "unexpected call\n");
214 static HRESULT WINAPI
htmlecoll_item(IHTMLElementCollection
*iface
, VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
216 ok(0, "unexpected call\n");
220 static HRESULT WINAPI
htmlecoll_tags(IHTMLElementCollection
*iface
, VARIANT tagName
, IDispatch
**pdisp
)
222 ok(0, "unexpected call\n");
226 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl
= {
227 htmlecoll_QueryInterface
,
230 htmlecoll_GetTypeInfoCount
,
231 htmlecoll_GetTypeInfo
,
232 htmlecoll_GetIDsOfNames
,
235 htmlecoll_put_length
,
236 htmlecoll_get_length
,
237 htmlecoll_get__newEnum
,
242 static IHTMLElementCollection htmlecoll
= { &TestHTMLECollectionVtbl
};
244 /* test IHTMLDocument2 */
245 static HRESULT WINAPI
htmldoc2_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppvObject
)
249 return E_NOINTERFACE
;
252 static ULONG WINAPI
htmldoc2_AddRef(IHTMLDocument2
*iface
)
257 static ULONG WINAPI
htmldoc2_Release(IHTMLDocument2
*iface
)
262 static HRESULT WINAPI
htmldoc2_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
264 ok(0, "unexpected call\n");
268 static HRESULT WINAPI
htmldoc2_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
269 LCID lcid
, ITypeInfo
**ppTInfo
)
271 ok(0, "unexpected call\n");
275 static HRESULT WINAPI
htmldoc2_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
276 LPOLESTR
*rgszNames
, UINT cNames
,
277 LCID lcid
, DISPID
*rgDispId
)
279 ok(0, "unexpected call\n");
283 static HRESULT WINAPI
htmldoc2_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
284 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
285 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
287 ok(0, "unexpected call\n");
291 static HRESULT WINAPI
htmldoc2_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
293 ok(0, "unexpected call\n");
297 static HRESULT WINAPI
htmldoc2_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
299 CHECK_EXPECT2(htmldoc2_get_all
);
304 static HRESULT WINAPI
htmldoc2_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
306 ok(0, "unexpected call\n");
310 static HRESULT WINAPI
htmldoc2_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
312 ok(0, "unexpected call\n");
316 static HRESULT WINAPI
htmldoc2_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
318 ok(0, "unexpected call\n");
322 static HRESULT WINAPI
htmldoc2_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
324 ok(0, "unexpected call\n");
328 static HRESULT WINAPI
htmldoc2_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
330 ok(0, "unexpected call\n");
334 static HRESULT WINAPI
htmldoc2_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
336 ok(0, "unexpected call\n");
340 static HRESULT WINAPI
htmldoc2_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
342 ok(0, "unexpected call\n");
346 static HRESULT WINAPI
htmldoc2_put_title(IHTMLDocument2
*iface
, BSTR v
)
348 ok(0, "unexpected call\n");
352 static HRESULT WINAPI
htmldoc2_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
354 ok(0, "unexpected call\n");
358 static HRESULT WINAPI
htmldoc2_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
360 ok(0, "unexpected call\n");
364 static HRESULT WINAPI
htmldoc2_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
366 ok(0, "unexpected call\n");
370 static HRESULT WINAPI
htmldoc2_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
372 ok(0, "unexpected call\n");
376 static HRESULT WINAPI
htmldoc2_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
378 ok(0, "unexpected call\n");
382 static HRESULT WINAPI
htmldoc2_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
384 ok(0, "unexpected call\n");
388 static HRESULT WINAPI
htmldoc2_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
390 ok(0, "unexpected call\n");
394 static HRESULT WINAPI
htmldoc2_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
396 ok(0, "unexpected call\n");
400 static HRESULT WINAPI
htmldoc2_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
402 ok(0, "unexpected call\n");
406 static HRESULT WINAPI
htmldoc2_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
408 ok(0, "unexpected call\n");
412 static HRESULT WINAPI
htmldoc2_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
414 ok(0, "unexpected call\n");
418 static HRESULT WINAPI
htmldoc2_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
420 ok(0, "unexpected call\n");
424 static HRESULT WINAPI
htmldoc2_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
426 ok(0, "unexpected call\n");
430 static HRESULT WINAPI
htmldoc2_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
432 ok(0, "unexpected call\n");
436 static HRESULT WINAPI
htmldoc2_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
438 ok(0, "unexpected call\n");
442 static HRESULT WINAPI
htmldoc2_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
444 ok(0, "unexpected call\n");
448 static HRESULT WINAPI
htmldoc2_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
450 ok(0, "unexpected call\n");
454 static HRESULT WINAPI
htmldoc2_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
456 ok(0, "unexpected call\n");
460 static HRESULT WINAPI
htmldoc2_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
462 ok(0, "unexpected call\n");
466 static HRESULT WINAPI
htmldoc2_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
468 ok(0, "unexpected call\n");
472 static HRESULT WINAPI
htmldoc2_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
474 ok(0, "unexpected call\n");
478 static HRESULT WINAPI
htmldoc2_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
480 ok(0, "unexpected call\n");
484 static HRESULT WINAPI
htmldoc2_put_URL(IHTMLDocument2
*iface
, BSTR v
)
486 ok(0, "unexpected call\n");
490 static HRESULT WINAPI
htmldoc2_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
492 CHECK_EXPECT2(htmldoc2_get_url
);
493 *p
= a2bstr("http://test.winehq.org/");
497 static HRESULT WINAPI
htmldoc2_put_domain(IHTMLDocument2
*iface
, BSTR v
)
499 ok(0, "unexpected call\n");
503 static HRESULT WINAPI
htmldoc2_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
505 ok(0, "unexpected call\n");
509 static HRESULT WINAPI
htmldoc2_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
511 ok(0, "unexpected call\n");
515 static HRESULT WINAPI
htmldoc2_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
517 ok(0, "unexpected call\n");
521 static HRESULT WINAPI
htmldoc2_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
523 ok(0, "unexpected call\n");
527 static HRESULT WINAPI
htmldoc2_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
529 ok(0, "unexpected call\n");
533 static HRESULT WINAPI
htmldoc2_put_charset(IHTMLDocument2
*iface
, BSTR v
)
535 ok(0, "unexpected call\n");
539 static HRESULT WINAPI
htmldoc2_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
541 ok(0, "unexpected call\n");
545 static HRESULT WINAPI
htmldoc2_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
547 ok(0, "unexpected call\n");
551 static HRESULT WINAPI
htmldoc2_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
553 ok(0, "unexpected call\n");
557 static HRESULT WINAPI
htmldoc2_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
559 ok(0, "unexpected call\n");
563 static HRESULT WINAPI
htmldoc2_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
565 ok(0, "unexpected call\n");
569 static HRESULT WINAPI
htmldoc2_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
571 ok(0, "unexpected call\n");
575 static HRESULT WINAPI
htmldoc2_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
577 ok(0, "unexpected call\n");
581 static HRESULT WINAPI
htmldoc2_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
583 ok(0, "unexpected call\n");
587 static HRESULT WINAPI
htmldoc2_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
589 ok(0, "unexpected call\n");
593 static HRESULT WINAPI
htmldoc2_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
595 ok(0, "unexpected call\n");
599 static HRESULT WINAPI
htmldoc2_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
601 ok(0, "unexpected call\n");
605 static HRESULT WINAPI
htmldoc2_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
607 ok(0, "unexpected call\n");
611 static HRESULT WINAPI
htmldoc2_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
613 ok(0, "unexpected call\n");
617 static HRESULT WINAPI
htmldoc2_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
618 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
620 ok(0, "unexpected call\n");
624 static HRESULT WINAPI
htmldoc2_close(IHTMLDocument2
*iface
)
626 ok(0, "unexpected call\n");
630 static HRESULT WINAPI
htmldoc2_clear(IHTMLDocument2
*iface
)
632 ok(0, "unexpected call\n");
636 static HRESULT WINAPI
htmldoc2_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
639 ok(0, "unexpected call\n");
643 static HRESULT WINAPI
htmldoc2_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
646 ok(0, "unexpected call\n");
650 static HRESULT WINAPI
htmldoc2_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
653 ok(0, "unexpected call\n");
657 static HRESULT WINAPI
htmldoc2_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
660 ok(0, "unexpected call\n");
664 static HRESULT WINAPI
htmldoc2_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
667 ok(0, "unexpected call\n");
671 static HRESULT WINAPI
htmldoc2_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
674 ok(0, "unexpected call\n");
678 static HRESULT WINAPI
htmldoc2_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
679 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
681 ok(0, "unexpected call\n");
685 static HRESULT WINAPI
htmldoc2_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
688 ok(0, "unexpected call\n");
692 static HRESULT WINAPI
htmldoc2_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
693 IHTMLElement
**newElem
)
695 ok(0, "unexpected call\n");
699 static HRESULT WINAPI
htmldoc2_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
701 ok(0, "unexpected call\n");
705 static HRESULT WINAPI
htmldoc2_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
707 ok(0, "unexpected call\n");
711 static HRESULT WINAPI
htmldoc2_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
713 ok(0, "unexpected call\n");
717 static HRESULT WINAPI
htmldoc2_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
719 ok(0, "unexpected call\n");
723 static HRESULT WINAPI
htmldoc2_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
725 ok(0, "unexpected call\n");
729 static HRESULT WINAPI
htmldoc2_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
731 ok(0, "unexpected call\n");
735 static HRESULT WINAPI
htmldoc2_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
737 ok(0, "unexpected call\n");
741 static HRESULT WINAPI
htmldoc2_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
743 ok(0, "unexpected call\n");
747 static HRESULT WINAPI
htmldoc2_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
749 ok(0, "unexpected call\n");
753 static HRESULT WINAPI
htmldoc2_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
755 ok(0, "unexpected call\n");
759 static HRESULT WINAPI
htmldoc2_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
761 ok(0, "unexpected call\n");
765 static HRESULT WINAPI
htmldoc2_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
767 ok(0, "unexpected call\n");
771 static HRESULT WINAPI
htmldoc2_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
773 ok(0, "unexpected call\n");
777 static HRESULT WINAPI
htmldoc2_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
779 ok(0, "unexpected call\n");
783 static HRESULT WINAPI
htmldoc2_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
785 ok(0, "unexpected call\n");
789 static HRESULT WINAPI
htmldoc2_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
791 ok(0, "unexpected call\n");
795 static HRESULT WINAPI
htmldoc2_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
797 ok(0, "unexpected call\n");
801 static HRESULT WINAPI
htmldoc2_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
803 ok(0, "unexpected call\n");
807 static HRESULT WINAPI
htmldoc2_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
809 ok(0, "unexpected call\n");
813 static HRESULT WINAPI
htmldoc2_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
815 ok(0, "unexpected call\n");
819 static HRESULT WINAPI
htmldoc2_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
821 ok(0, "unexpected call\n");
825 static HRESULT WINAPI
htmldoc2_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
827 ok(0, "unexpected call\n");
831 static HRESULT WINAPI
htmldoc2_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
833 ok(0, "unexpected call\n");
837 static HRESULT WINAPI
htmldoc2_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
839 ok(0, "unexpected call\n");
843 static HRESULT WINAPI
htmldoc2_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
845 ok(0, "unexpected call\n");
849 static HRESULT WINAPI
htmldoc2_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
851 ok(0, "unexpected call\n");
855 static HRESULT WINAPI
htmldoc2_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
857 ok(0, "unexpected call\n");
861 static HRESULT WINAPI
htmldoc2_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
863 ok(0, "unexpected call\n");
867 static HRESULT WINAPI
htmldoc2_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
869 ok(0, "unexpected call\n");
873 static HRESULT WINAPI
htmldoc2_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
875 ok(0, "unexpected call\n");
879 static HRESULT WINAPI
htmldoc2_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
881 ok(0, "unexpected call\n");
885 static HRESULT WINAPI
htmldoc2_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
887 ok(0, "unexpected call\n");
891 static HRESULT WINAPI
htmldoc2_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
893 ok(0, "unexpected call\n");
897 static HRESULT WINAPI
htmldoc2_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
899 ok(0, "unexpected call\n");
903 static HRESULT WINAPI
htmldoc2_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
904 IHTMLElement
**elementHit
)
906 ok(0, "unexpected call\n");
910 static HRESULT WINAPI
htmldoc2_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
912 ok(0, "unexpected call\n");
916 static HRESULT WINAPI
htmldoc2_get_styleSheets(IHTMLDocument2
*iface
,
917 IHTMLStyleSheetsCollection
**p
)
919 ok(0, "unexpected call\n");
923 static HRESULT WINAPI
htmldoc2_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
925 ok(0, "unexpected call\n");
929 static HRESULT WINAPI
htmldoc2_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
931 ok(0, "unexpected call\n");
935 static HRESULT WINAPI
htmldoc2_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
937 ok(0, "unexpected call\n");
941 static HRESULT WINAPI
htmldoc2_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
943 ok(0, "unexpected call\n");
947 static HRESULT WINAPI
htmldoc2_toString(IHTMLDocument2
*iface
, BSTR
*String
)
949 ok(0, "unexpected call\n");
953 static HRESULT WINAPI
htmldoc2_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
954 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
956 ok(0, "unexpected call\n");
960 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl
= {
961 htmldoc2_QueryInterface
,
964 htmldoc2_GetTypeInfoCount
,
965 htmldoc2_GetTypeInfo
,
966 htmldoc2_GetIDsOfNames
,
971 htmldoc2_get_activeElement
,
973 htmldoc2_get_applets
,
976 htmldoc2_get_anchors
,
979 htmldoc2_get_scripts
,
980 htmldoc2_put_designMode
,
981 htmldoc2_get_designMode
,
982 htmldoc2_get_selection
,
983 htmldoc2_get_readyState
,
986 htmldoc2_get_plugins
,
987 htmldoc2_put_alinkColor
,
988 htmldoc2_get_alinkColor
,
989 htmldoc2_put_bgColor
,
990 htmldoc2_get_bgColor
,
991 htmldoc2_put_fgColor
,
992 htmldoc2_get_fgColor
,
993 htmldoc2_put_linkColor
,
994 htmldoc2_get_linkColor
,
995 htmldoc2_put_vlinkColor
,
996 htmldoc2_get_vlinkColor
,
997 htmldoc2_get_referrer
,
998 htmldoc2_get_location
,
999 htmldoc2_get_lastModified
,
1002 htmldoc2_put_domain
,
1003 htmldoc2_get_domain
,
1004 htmldoc2_put_cookie
,
1005 htmldoc2_get_cookie
,
1006 htmldoc2_put_expando
,
1007 htmldoc2_get_expando
,
1008 htmldoc2_put_charset
,
1009 htmldoc2_get_charset
,
1010 htmldoc2_put_defaultCharset
,
1011 htmldoc2_get_defaultCharset
,
1012 htmldoc2_get_mimeType
,
1013 htmldoc2_get_fileSize
,
1014 htmldoc2_get_fileCreatedDate
,
1015 htmldoc2_get_fileModifiedDate
,
1016 htmldoc2_get_fileUpdatedDate
,
1017 htmldoc2_get_security
,
1018 htmldoc2_get_protocol
,
1019 htmldoc2_get_nameProp
,
1025 htmldoc2_queryCommandSupported
,
1026 htmldoc2_queryCommandEnabled
,
1027 htmldoc2_queryCommandState
,
1028 htmldoc2_queryCommandIndeterm
,
1029 htmldoc2_queryCommandText
,
1030 htmldoc2_queryCommandValue
,
1031 htmldoc2_execCommand
,
1032 htmldoc2_execCommandShowHelp
,
1033 htmldoc2_createElement
,
1034 htmldoc2_put_onhelp
,
1035 htmldoc2_get_onhelp
,
1036 htmldoc2_put_onclick
,
1037 htmldoc2_get_onclick
,
1038 htmldoc2_put_ondblclick
,
1039 htmldoc2_get_ondblclick
,
1040 htmldoc2_put_onkeyup
,
1041 htmldoc2_get_onkeyup
,
1042 htmldoc2_put_onkeydown
,
1043 htmldoc2_get_onkeydown
,
1044 htmldoc2_put_onkeypress
,
1045 htmldoc2_get_onkeypress
,
1046 htmldoc2_put_onmouseup
,
1047 htmldoc2_get_onmouseup
,
1048 htmldoc2_put_onmousedown
,
1049 htmldoc2_get_onmousedown
,
1050 htmldoc2_put_onmousemove
,
1051 htmldoc2_get_onmousemove
,
1052 htmldoc2_put_onmouseout
,
1053 htmldoc2_get_onmouseout
,
1054 htmldoc2_put_onmouseover
,
1055 htmldoc2_get_onmouseover
,
1056 htmldoc2_put_onreadystatechange
,
1057 htmldoc2_get_onreadystatechange
,
1058 htmldoc2_put_onafterupdate
,
1059 htmldoc2_get_onafterupdate
,
1060 htmldoc2_put_onrowexit
,
1061 htmldoc2_get_onrowexit
,
1062 htmldoc2_put_onrowenter
,
1063 htmldoc2_get_onrowenter
,
1064 htmldoc2_put_ondragstart
,
1065 htmldoc2_get_ondragstart
,
1066 htmldoc2_put_onselectstart
,
1067 htmldoc2_get_onselectstart
,
1068 htmldoc2_elementFromPoint
,
1069 htmldoc2_get_parentWindow
,
1070 htmldoc2_get_styleSheets
,
1071 htmldoc2_put_onbeforeupdate
,
1072 htmldoc2_get_onbeforeupdate
,
1073 htmldoc2_put_onerrorupdate
,
1074 htmldoc2_get_onerrorupdate
,
1076 htmldoc2_createStyleSheet
1079 static IHTMLDocument2 htmldoc2
= { &TestHTMLDocumentVtbl
};
1081 static HRESULT WINAPI
sp_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppvObject
)
1085 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1086 IsEqualGUID(riid
, &IID_IServiceProvider
))
1089 IServiceProvider_AddRef(iface
);
1093 ok(0, "unexpected query interface: %s\n", wine_dbgstr_guid(riid
));
1095 return E_NOINTERFACE
;
1098 static ULONG WINAPI
sp_AddRef(IServiceProvider
*iface
)
1103 static ULONG WINAPI
sp_Release(IServiceProvider
*iface
)
1108 static HRESULT WINAPI
sp_QueryService(IServiceProvider
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1112 if (IsEqualGUID(service
, &SID_SBindHost
) &&
1113 IsEqualGUID(riid
, &IID_IBindHost
))
1115 CHECK_EXPECT2(sp_queryservice_SID_SBindHost
);
1117 else if (IsEqualGUID(service
, &SID_SContainerDispatch
) &&
1118 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1120 CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1122 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1123 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1125 CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2
);
1129 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1130 IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1132 CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc
);
1134 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1135 IsEqualGUID(riid
, &IID_IInternetHostSecurityManager
))
1137 CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr
);
1139 else if (IsEqualGUID(service
, &SID_UnknownSID
) &&
1140 IsEqualGUID(riid
, &IID_IStream
))
1142 /* FIXME: unidentified service id */
1144 else if ((IsEqualGUID(service
, &IID_IInternetProtocol
) && IsEqualGUID(riid
, &IID_IInternetProtocol
)) ||
1145 (IsEqualGUID(service
, &IID_IHttpNegotiate2
) && IsEqualGUID(riid
, &IID_IHttpNegotiate2
)) ||
1146 (IsEqualGUID(service
, &IID_IGetBindHandle
) && IsEqualGUID(riid
, &IID_IGetBindHandle
)) ||
1147 (IsEqualGUID(service
, &IID_IBindStatusCallback
) && IsEqualGUID(riid
, &IID_IBindStatusCallback
)) ||
1148 (IsEqualGUID(service
, &IID_IWindowForBindingUI
) && IsEqualGUID(riid
, &IID_IWindowForBindingUI
)))
1152 ok(0, "unexpected request: sid %s, riid %s\n", wine_dbgstr_guid(service
), wine_dbgstr_guid(riid
));
1157 static const IServiceProviderVtbl testprovVtbl
=
1165 static IServiceProvider testprov
= { &testprovVtbl
};
1167 static HRESULT WINAPI
site_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
1171 if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1172 CHECK_EXPECT2(site_qi_IServiceProvider
);
1174 if (IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1175 CHECK_EXPECT2(site_qi_IXMLDOMDocument
);
1177 if (IsEqualGUID(riid
, &IID_IOleClientSite
))
1178 CHECK_EXPECT2(site_qi_IOleClientSite
);
1180 if (IsEqualGUID(riid
, &IID_IUnknown
))
1182 else if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1183 *ppvObject
= &testprov
;
1185 if (*ppvObject
) IUnknown_AddRef(iface
);
1187 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1190 static ULONG WINAPI
site_AddRef(IUnknown
*iface
)
1195 static ULONG WINAPI
site_Release(IUnknown
*iface
)
1200 static const IUnknownVtbl testsiteVtbl
=
1202 site_QueryInterface
,
1207 static IUnknown testsite
= { &testsiteVtbl
};
1211 IDispatch IDispatch_iface
;
1215 static IXMLHttpRequest
*httpreq
;
1217 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
1219 return CONTAINING_RECORD(iface
, dispevent
, IDispatch_iface
);
1222 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
1226 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
1227 IsEqualGUID( riid
, &IID_IUnknown
) )
1232 return E_NOINTERFACE
;
1234 IDispatch_AddRef( iface
);
1239 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
1241 dispevent
*This
= impl_from_IDispatch( iface
);
1242 return InterlockedIncrement( &This
->ref
);
1245 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
1247 dispevent
*This
= impl_from_IDispatch( iface
);
1248 ULONG ref
= InterlockedDecrement( &This
->ref
);
1251 HeapFree(GetProcessHeap(), 0, This
);
1256 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1263 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1264 LCID lcid
, ITypeInfo
**ppTInfo
)
1270 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1271 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1277 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
1278 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
1279 EXCEPINFO
*excepInfo
, UINT
*argErr
)
1284 ok(member
== 0, "expected 0 member, got %d\n", member
);
1285 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
1286 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
1288 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
1289 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
1290 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
1291 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
1293 ok(result
== NULL
, "got %p\n", result
);
1294 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
1295 ok(argErr
== NULL
, "got %p\n", argErr
);
1299 state
= READYSTATE_UNINITIALIZED
;
1300 hr
= IXMLHttpRequest_get_readyState(httpreq
, &state
);
1301 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1302 if (state
== READYSTATE_COMPLETE
)
1306 hr
= IXMLHttpRequest_get_responseText(httpreq
, &text
);
1307 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1308 ok(*text
!= 0, "got %s\n", wine_dbgstr_w(text
));
1309 SysFreeString(text
);
1315 static const IDispatchVtbl dispeventVtbl
=
1317 dispevent_QueryInterface
,
1320 dispevent_GetTypeInfoCount
,
1321 dispevent_GetTypeInfo
,
1322 dispevent_GetIDsOfNames
,
1326 static IDispatch
* create_dispevent(void)
1328 dispevent
*event
= HeapAlloc(GetProcessHeap(), 0, sizeof(*event
));
1330 event
->IDispatch_iface
.lpVtbl
= &dispeventVtbl
;
1333 return &event
->IDispatch_iface
;
1336 static IXMLHttpRequest
*create_xhr(void)
1338 IXMLHttpRequest
*ret
;
1341 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
1342 &IID_IXMLHttpRequest
, (void**)&ret
);
1344 return SUCCEEDED(hr
) ? ret
: NULL
;
1347 static void set_safety_opt(IUnknown
*unk
, DWORD mask
, DWORD opts
)
1349 IObjectSafety
*obj_safety
;
1352 hr
= IUnknown_QueryInterface(unk
, &IID_IObjectSafety
, (void**)&obj_safety
);
1353 ok(hr
== S_OK
, "Could not get IObjectSafety iface: %08x\n", hr
);
1355 hr
= IObjectSafety_SetInterfaceSafetyOptions(obj_safety
, &IID_IDispatch
, mask
, mask
&opts
);
1356 ok(hr
== S_OK
, "SetInterfaceSafetyOptions failed: %08x\n", hr
);
1358 IObjectSafety_Release(obj_safety
);
1361 static void set_xhr_site(IXMLHttpRequest
*xhr
)
1363 IObjectWithSite
*obj_site
;
1366 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1367 ok(hr
== S_OK
, "Could not get IObjectWithSite iface: %08x\n", hr
);
1369 g_enablecallchecks
= TRUE
;
1371 SET_EXPECT(site_qi_IServiceProvider
);
1372 SET_EXPECT(sp_queryservice_SID_SBindHost
);
1373 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1374 SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
1375 SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
1376 SET_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
1378 /* calls to IHTMLDocument2 */
1379 SET_EXPECT(htmldoc2_get_all
);
1380 SET_EXPECT(collection_get_length
);
1381 SET_EXPECT(htmldoc2_get_url
);
1383 SET_EXPECT(site_qi_IXMLDOMDocument
);
1384 SET_EXPECT(site_qi_IOleClientSite
);
1386 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1387 EXPECT_HR(hr
, S_OK
);
1389 CHECK_CALLED(site_qi_IServiceProvider
);
1391 CHECK_CALLED(sp_queryservice_SID_SBindHost
);
1392 CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1393 CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2
);
1395 CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc
);
1396 /* this one isn't very reliable
1397 CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
1399 CHECK_CALLED(htmldoc2_get_all
);
1400 CHECK_CALLED(collection_get_length
);
1402 CHECK_CALLED(htmldoc2_get_url
);
1405 CHECK_CALLED(site_qi_IXMLDOMDocument
);
1406 CHECK_CALLED(site_qi_IOleClientSite
);
1409 g_enablecallchecks
= FALSE
;
1411 IObjectWithSite_Release(obj_site
);
1414 #define test_open(a,b,c,d) _test_open(__LINE__,a,b,c,d)
1415 static void _test_open(unsigned line
, IXMLHttpRequest
*xhr
, const char *method
, const char *url
, HRESULT exhres
)
1417 VARIANT empty
, vfalse
;
1420 V_VT(&empty
) = VT_EMPTY
;
1421 V_VT(&vfalse
) = VT_BOOL
;
1422 V_BOOL(&vfalse
) = VARIANT_FALSE
;
1424 hr
= IXMLHttpRequest_open(xhr
, _bstr_(method
), _bstr_(url
), vfalse
, empty
, empty
);
1425 ok_(__FILE__
,line
)(hr
== exhres
, "open(%s %s) failed: %08x, expected %08x\n", method
, url
, hr
, exhres
);
1428 static void test_XMLHTTP(void)
1430 static const char bodyA
[] = "mode=Test";
1431 static const char urlA
[] = "http://test.winehq.org/tests/post.php";
1432 static const char xmltestA
[] = "http://test.winehq.org/tests/xmltest.xml";
1433 static const char referertesturl
[] = "http://test.winehq.org/tests/referer.php";
1434 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
1435 static const CHAR xmltestbodyA
[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
1436 static const WCHAR norefererW
[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0};
1438 IXMLHttpRequest
*xhr
;
1439 IObjectWithSite
*obj_site
, *obj_site2
;
1440 BSTR bstrResponse
, str
, str1
;
1441 VARIANT varbody
, varbody_ref
;
1443 LONG state
, status
, bound
;
1451 VariantInit(&dummy
);
1452 V_VT(&dummy
) = VT_ERROR
;
1453 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
1455 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, NULL
);
1456 EXPECT_HR(hr
, S_OK
);
1458 hr
= IXMLHttpRequest_abort(xhr
);
1459 EXPECT_HR(hr
, S_OK
);
1461 V_VT(&varbody
) = VT_I2
;
1463 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1464 EXPECT_HR(hr
, E_PENDING
);
1465 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1466 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
1468 V_VT(&varbody
) = VT_I2
;
1470 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1471 EXPECT_HR(hr
, E_PENDING
);
1472 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1473 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
1475 /* send before open */
1476 hr
= IXMLHttpRequest_send(xhr
, dummy
);
1477 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1479 /* initial status code */
1480 hr
= IXMLHttpRequest_get_status(xhr
, NULL
);
1481 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1483 status
= 0xdeadbeef;
1484 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1485 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1486 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1488 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1489 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
1491 /* invalid parameters */
1492 test_open(xhr
, NULL
, NULL
, E_INVALIDARG
);
1493 test_open(xhr
, "POST", NULL
, E_INVALIDARG
);
1494 test_open(xhr
, NULL
, urlA
, E_INVALIDARG
);
1496 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, NULL
);
1497 EXPECT_HR(hr
, E_INVALIDARG
);
1499 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), NULL
);
1500 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1502 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1503 EXPECT_HR(hr
, E_INVALIDARG
);
1505 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1506 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1508 hr
= IXMLHttpRequest_get_readyState(xhr
, NULL
);
1509 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1512 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1513 EXPECT_HR(hr
, S_OK
);
1514 ok(state
== READYSTATE_UNINITIALIZED
, "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1517 event
= create_dispevent();
1519 EXPECT_REF(event
, 1);
1520 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, event
);
1521 EXPECT_HR(hr
, S_OK
);
1522 EXPECT_REF(event
, 2);
1524 g_unexpectedcall
= g_expectedcall
= 0;
1526 test_open(xhr
, "POST", urlA
, S_OK
);
1528 ok(g_unexpectedcall
== 0, "unexpected disp event call\n");
1529 ok(g_expectedcall
== 1 || broken(g_expectedcall
== 0) /* win2k */, "no expected disp event call\n");
1531 /* status code after ::open() */
1532 status
= 0xdeadbeef;
1533 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1534 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1535 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1538 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1539 EXPECT_HR(hr
, S_OK
);
1540 ok(state
== READYSTATE_LOADING
, "got %d, expected READYSTATE_LOADING\n", state
);
1542 hr
= IXMLHttpRequest_abort(xhr
);
1543 EXPECT_HR(hr
, S_OK
);
1546 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1547 EXPECT_HR(hr
, S_OK
);
1548 ok(state
== READYSTATE_UNINITIALIZED
|| broken(state
== READYSTATE_LOADING
) /* win2k */,
1549 "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1551 test_open(xhr
, "POST", urlA
, S_OK
);
1553 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1554 EXPECT_HR(hr
, S_OK
);
1556 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1557 EXPECT_HR(hr
, E_INVALIDARG
);
1559 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_(""), _bstr_("value1"));
1560 EXPECT_HR(hr
, E_INVALIDARG
);
1562 V_VT(&varbody
) = VT_BSTR
;
1563 V_BSTR(&varbody
) = _bstr_(bodyA
);
1565 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1566 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1568 skip("No connection could be made with test.winehq.org\n");
1569 IXMLHttpRequest_Release(xhr
);
1572 EXPECT_HR(hr
, S_OK
);
1574 /* response headers */
1575 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, NULL
);
1576 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1577 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str
);
1578 EXPECT_HR(hr
, S_OK
);
1579 /* status line is stripped already */
1580 ok(memcmp(str
, _bstr_("HTTP"), 4*sizeof(WCHAR
)), "got response headers %s\n", wine_dbgstr_w(str
));
1581 ok(*str
, "got empty headers\n");
1582 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str1
);
1583 EXPECT_HR(hr
, S_OK
);
1584 ok(str1
!= str
, "got %p\n", str1
);
1585 SysFreeString(str1
);
1588 hr
= IXMLHttpRequest_getResponseHeader(xhr
, NULL
, NULL
);
1589 EXPECT_HR(hr
, E_INVALIDARG
);
1590 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), NULL
);
1591 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1592 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), &str
);
1593 EXPECT_HR(hr
, S_OK
);
1594 ok(*str
!= ' ', "got leading space in header %s\n", wine_dbgstr_w(str
));
1597 /* status code after ::send() */
1598 status
= 0xdeadbeef;
1599 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1600 EXPECT_HR(hr
, S_OK
);
1601 ok(status
== 200, "got %d\n", status
);
1603 hr
= IXMLHttpRequest_get_statusText(xhr
, NULL
);
1604 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1606 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1607 EXPECT_HR(hr
, S_OK
);
1608 ok(!lstrcmpW(str
, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str
));
1611 /* another ::send() after completed request */
1612 V_VT(&varbody
) = VT_BSTR
;
1613 V_BSTR(&varbody
) = _bstr_(bodyA
);
1615 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1616 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1618 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1619 EXPECT_HR(hr
, S_OK
);
1620 /* the server currently returns "FAILED" because the Content-Type header is
1621 * not what the server expects */
1624 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)),
1625 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse
), wine_dbgstr_w(bstrResponse
));
1626 SysFreeString(bstrResponse
);
1629 /* POST: VT_VARIANT|VT_BYREF body */
1630 test_open(xhr
, "POST", urlA
, S_OK
);
1632 V_VT(&varbody_ref
) = VT_VARIANT
|VT_BYREF
;
1633 V_VARIANTREF(&varbody_ref
) = &varbody
;
1634 hr
= IXMLHttpRequest_send(xhr
, varbody_ref
);
1635 EXPECT_HR(hr
, S_OK
);
1638 test_open(xhr
, "GET", xmltestA
, S_OK
);
1640 V_VT(&varbody
) = VT_EMPTY
;
1642 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1643 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1645 skip("No connection could be made with test.winehq.org\n");
1646 IXMLHttpRequest_Release(xhr
);
1649 EXPECT_HR(hr
, S_OK
);
1651 hr
= IXMLHttpRequest_get_responseText(xhr
, NULL
);
1652 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1654 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1655 EXPECT_HR(hr
, S_OK
);
1656 ok(!memcmp(bstrResponse
, _bstr_(xmltestbodyA
), sizeof(xmltestbodyA
)*sizeof(WCHAR
)),
1657 "expected %s, got %s\n", xmltestbodyA
, wine_dbgstr_w(bstrResponse
));
1658 SysFreeString(bstrResponse
);
1660 hr
= IXMLHttpRequest_get_responseBody(xhr
, NULL
);
1661 EXPECT_HR(hr
, E_INVALIDARG
);
1663 V_VT(&varbody
) = VT_EMPTY
;
1664 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1665 EXPECT_HR(hr
, S_OK
);
1666 ok(V_VT(&varbody
) == (VT_ARRAY
|VT_UI1
), "got type %d, expected %d\n", V_VT(&varbody
), VT_ARRAY
|VT_UI1
);
1667 ok(SafeArrayGetDim(V_ARRAY(&varbody
)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody
)));
1670 hr
= SafeArrayGetLBound(V_ARRAY(&varbody
), 1, &bound
);
1671 EXPECT_HR(hr
, S_OK
);
1672 ok(bound
== 0, "got %d, expected zero bound\n", bound
);
1674 hr
= SafeArrayAccessData(V_ARRAY(&varbody
), &ptr
);
1675 EXPECT_HR(hr
, S_OK
);
1676 ok(memcmp(ptr
, xmltestbodyA
, sizeof(xmltestbodyA
)-1) == 0, "got wrong body data\n");
1677 SafeArrayUnaccessData(V_ARRAY(&varbody
));
1679 VariantClear(&varbody
);
1681 /* get_responseStream */
1682 hr
= IXMLHttpRequest_get_responseStream(xhr
, NULL
);
1683 EXPECT_HR(hr
, E_INVALIDARG
);
1685 V_VT(&varbody
) = VT_EMPTY
;
1686 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1687 ok(V_VT(&varbody
) == VT_UNKNOWN
, "got type %d\n", V_VT(&varbody
));
1688 EXPECT_HR(hr
, S_OK
);
1689 EXPECT_REF(V_UNKNOWN(&varbody
), 1);
1692 hr
= GetHGlobalFromStream((IStream
*)V_UNKNOWN(&varbody
), &g
);
1693 EXPECT_HR(hr
, S_OK
);
1694 ok(g
!= NULL
, "got %p\n", g
);
1696 IDispatch_Release(event
);
1698 /* test if referrer header is sent */
1699 test_open(xhr
, "GET", referertesturl
, S_OK
);
1701 V_VT(&varbody
) = VT_EMPTY
;
1702 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1703 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1704 hr
= IXMLHttpRequest_get_responseText(xhr
, &str
);
1705 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1706 ok(!lstrcmpW(str
, norefererW
), "got response text %s\n", wine_dbgstr_w(str
));
1709 /* interaction with object site */
1710 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1711 EXPECT_HR(hr
, S_OK
);
1713 hr
= IObjectWithSite_SetSite(obj_site
, NULL
);
1714 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1716 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site2
);
1717 EXPECT_HR(hr
, S_OK
);
1718 ok(obj_site
== obj_site2
|| broken(obj_site
!= obj_site2
), "got new instance\n");
1719 IObjectWithSite_Release(obj_site2
);
1723 test_open(xhr
, "GET", "tests/referer.php", S_OK
);
1724 str1
= a2bstr("http://test.winehq.org/");
1726 V_VT(&varbody
) = VT_EMPTY
;
1727 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1728 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
, str1
), "got response text %s, expected %s\n", wine_dbgstr_w(str
), wine_dbgstr_w(str1
));
1734 SysFreeString(str1
);
1736 /* try to set site another time */
1737 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1738 EXPECT_HR(hr
, S_OK
);
1740 IObjectWithSite_Release(obj_site
);
1741 IXMLHttpRequest_Release(xhr
);
1745 static void test_safe_httpreq(void)
1747 IXMLHttpRequest
*xhr
;
1751 set_safety_opt((IUnknown
*)xhr
, INTERFACESAFE_FOR_UNTRUSTED_DATA
, -1);
1754 /* different scheme */
1755 test_open(xhr
, "GET", "https://test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1757 /* different host */
1758 test_open(xhr
, "GET", "http://tests.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1759 test_open(xhr
, "GET", "http://www.test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1761 IXMLHttpRequest_Release(xhr
);
1766 IXMLHttpRequest
*xhr
;
1770 if((xhr
= create_xhr())) {
1771 IXMLHttpRequest_Release(xhr
);
1774 test_safe_httpreq();
1776 win_skip("IXMLHTTPRequest is not available\n");