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 #define DEFINE_EXPECT(func) \
61 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
63 #define SET_EXPECT(func) \
64 expect_ ## func = TRUE
66 #define CHECK_EXPECT2(func) \
68 ok(expect_ ##func, "unexpected call " #func "\n"); \
69 called_ ## func = TRUE; \
72 #define CHECK_CALLED(func) \
74 ok(called_ ## func, "expected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
79 DEFINE_EXPECT(site_qi_IServiceProvider
);
80 DEFINE_EXPECT(site_qi_IXMLDOMDocument
);
81 DEFINE_EXPECT(site_qi_IOleClientSite
);
83 DEFINE_EXPECT(sp_queryservice_SID_SBindHost
);
84 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
85 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
86 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
87 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
89 DEFINE_EXPECT(htmldoc2_get_all
);
90 DEFINE_EXPECT(htmldoc2_get_url
);
91 DEFINE_EXPECT(collection_get_length
);
93 static const char *debugstr_guid(REFIID riid
)
100 sprintf(buf
, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
101 riid
->Data1
, riid
->Data2
, riid
->Data3
, riid
->Data4
[0],
102 riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3], riid
->Data4
[4],
103 riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7]);
108 static int g_unexpectedcall
, g_expectedcall
;
110 static BSTR
alloc_str_from_narrow(const char *str
)
112 int len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
113 BSTR ret
= SysAllocStringLen(NULL
, len
- 1); /* NUL character added automatically */
114 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
-1);
118 static BSTR alloced_bstrs
[256];
119 static int alloced_bstrs_count
;
121 static BSTR
_bstr_(const char *str
)
126 assert(alloced_bstrs_count
< sizeof(alloced_bstrs
)/sizeof(alloced_bstrs
[0]));
127 alloced_bstrs
[alloced_bstrs_count
] = alloc_str_from_narrow(str
);
128 return alloced_bstrs
[alloced_bstrs_count
++];
131 static void free_bstrs(void)
134 for (i
= 0; i
< alloced_bstrs_count
; i
++)
135 SysFreeString(alloced_bstrs
[i
]);
136 alloced_bstrs_count
= 0;
139 static BSTR
a2bstr(const char *str
)
147 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
148 ret
= SysAllocStringLen(NULL
, len
);
149 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
155 /* test IHTMLElementCollection */
156 static HRESULT WINAPI
htmlecoll_QueryInterface(IHTMLElementCollection
*iface
, REFIID riid
, void **ppvObject
)
158 ok(0, "unexpected call\n");
160 return E_NOINTERFACE
;
163 static ULONG WINAPI
htmlecoll_AddRef(IHTMLElementCollection
*iface
)
168 static ULONG WINAPI
htmlecoll_Release(IHTMLElementCollection
*iface
)
173 static HRESULT WINAPI
htmlecoll_GetTypeInfoCount(IHTMLElementCollection
*iface
, UINT
*pctinfo
)
175 ok(0, "unexpected call\n");
179 static HRESULT WINAPI
htmlecoll_GetTypeInfo(IHTMLElementCollection
*iface
, UINT iTInfo
,
180 LCID lcid
, ITypeInfo
**ppTInfo
)
182 ok(0, "unexpected call\n");
186 static HRESULT WINAPI
htmlecoll_GetIDsOfNames(IHTMLElementCollection
*iface
, REFIID riid
,
187 LPOLESTR
*rgszNames
, UINT cNames
,
188 LCID lcid
, DISPID
*rgDispId
)
190 ok(0, "unexpected call\n");
194 static HRESULT WINAPI
htmlecoll_Invoke(IHTMLElementCollection
*iface
, DISPID dispIdMember
,
195 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
196 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
198 ok(0, "unexpected call\n");
202 static HRESULT WINAPI
htmlecoll_toString(IHTMLElementCollection
*iface
, BSTR
*String
)
204 ok(0, "unexpected call\n");
208 static HRESULT WINAPI
htmlecoll_put_length(IHTMLElementCollection
*iface
, LONG v
)
210 ok(0, "unexpected call\n");
214 static HRESULT WINAPI
htmlecoll_get_length(IHTMLElementCollection
*iface
, LONG
*v
)
216 CHECK_EXPECT2(collection_get_length
);
220 static HRESULT WINAPI
htmlecoll_get__newEnum(IHTMLElementCollection
*iface
, IUnknown
**p
)
222 ok(0, "unexpected call\n");
226 static HRESULT WINAPI
htmlecoll_item(IHTMLElementCollection
*iface
, VARIANT name
, VARIANT index
, IDispatch
**pdisp
)
228 ok(0, "unexpected call\n");
232 static HRESULT WINAPI
htmlecoll_tags(IHTMLElementCollection
*iface
, VARIANT tagName
, IDispatch
**pdisp
)
234 ok(0, "unexpected call\n");
238 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl
= {
239 htmlecoll_QueryInterface
,
242 htmlecoll_GetTypeInfoCount
,
243 htmlecoll_GetTypeInfo
,
244 htmlecoll_GetIDsOfNames
,
247 htmlecoll_put_length
,
248 htmlecoll_get_length
,
249 htmlecoll_get__newEnum
,
254 static IHTMLElementCollection htmlecoll
= { &TestHTMLECollectionVtbl
};
256 /* test IHTMLDocument2 */
257 static HRESULT WINAPI
htmldoc2_QueryInterface(IHTMLDocument2
*iface
, REFIID riid
, void **ppvObject
)
261 return E_NOINTERFACE
;
264 static ULONG WINAPI
htmldoc2_AddRef(IHTMLDocument2
*iface
)
269 static ULONG WINAPI
htmldoc2_Release(IHTMLDocument2
*iface
)
274 static HRESULT WINAPI
htmldoc2_GetTypeInfoCount(IHTMLDocument2
*iface
, UINT
*pctinfo
)
276 ok(0, "unexpected call\n");
280 static HRESULT WINAPI
htmldoc2_GetTypeInfo(IHTMLDocument2
*iface
, UINT iTInfo
,
281 LCID lcid
, ITypeInfo
**ppTInfo
)
283 ok(0, "unexpected call\n");
287 static HRESULT WINAPI
htmldoc2_GetIDsOfNames(IHTMLDocument2
*iface
, REFIID riid
,
288 LPOLESTR
*rgszNames
, UINT cNames
,
289 LCID lcid
, DISPID
*rgDispId
)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI
htmldoc2_Invoke(IHTMLDocument2
*iface
, DISPID dispIdMember
,
296 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
297 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
299 ok(0, "unexpected call\n");
303 static HRESULT WINAPI
htmldoc2_get_Script(IHTMLDocument2
*iface
, IDispatch
**p
)
305 ok(0, "unexpected call\n");
309 static HRESULT WINAPI
htmldoc2_get_all(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
311 CHECK_EXPECT2(htmldoc2_get_all
);
316 static HRESULT WINAPI
htmldoc2_get_body(IHTMLDocument2
*iface
, IHTMLElement
**p
)
318 ok(0, "unexpected call\n");
322 static HRESULT WINAPI
htmldoc2_get_activeElement(IHTMLDocument2
*iface
, IHTMLElement
**p
)
324 ok(0, "unexpected call\n");
328 static HRESULT WINAPI
htmldoc2_get_images(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
330 ok(0, "unexpected call\n");
334 static HRESULT WINAPI
htmldoc2_get_applets(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
336 ok(0, "unexpected call\n");
340 static HRESULT WINAPI
htmldoc2_get_links(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
342 ok(0, "unexpected call\n");
346 static HRESULT WINAPI
htmldoc2_get_forms(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
348 ok(0, "unexpected call\n");
352 static HRESULT WINAPI
htmldoc2_get_anchors(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
354 ok(0, "unexpected call\n");
358 static HRESULT WINAPI
htmldoc2_put_title(IHTMLDocument2
*iface
, BSTR v
)
360 ok(0, "unexpected call\n");
364 static HRESULT WINAPI
htmldoc2_get_title(IHTMLDocument2
*iface
, BSTR
*p
)
366 ok(0, "unexpected call\n");
370 static HRESULT WINAPI
htmldoc2_get_scripts(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
372 ok(0, "unexpected call\n");
376 static HRESULT WINAPI
htmldoc2_put_designMode(IHTMLDocument2
*iface
, BSTR v
)
378 ok(0, "unexpected call\n");
382 static HRESULT WINAPI
htmldoc2_get_designMode(IHTMLDocument2
*iface
, BSTR
*p
)
384 ok(0, "unexpected call\n");
388 static HRESULT WINAPI
htmldoc2_get_selection(IHTMLDocument2
*iface
, IHTMLSelectionObject
**p
)
390 ok(0, "unexpected call\n");
394 static HRESULT WINAPI
htmldoc2_get_readyState(IHTMLDocument2
*iface
, BSTR
*p
)
396 ok(0, "unexpected call\n");
400 static HRESULT WINAPI
htmldoc2_get_frames(IHTMLDocument2
*iface
, IHTMLFramesCollection2
**p
)
402 ok(0, "unexpected call\n");
406 static HRESULT WINAPI
htmldoc2_get_embeds(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
408 ok(0, "unexpected call\n");
412 static HRESULT WINAPI
htmldoc2_get_plugins(IHTMLDocument2
*iface
, IHTMLElementCollection
**p
)
414 ok(0, "unexpected call\n");
418 static HRESULT WINAPI
htmldoc2_put_alinkColor(IHTMLDocument2
*iface
, VARIANT v
)
420 ok(0, "unexpected call\n");
424 static HRESULT WINAPI
htmldoc2_get_alinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
426 ok(0, "unexpected call\n");
430 static HRESULT WINAPI
htmldoc2_put_bgColor(IHTMLDocument2
*iface
, VARIANT v
)
432 ok(0, "unexpected call\n");
436 static HRESULT WINAPI
htmldoc2_get_bgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
438 ok(0, "unexpected call\n");
442 static HRESULT WINAPI
htmldoc2_put_fgColor(IHTMLDocument2
*iface
, VARIANT v
)
444 ok(0, "unexpected call\n");
448 static HRESULT WINAPI
htmldoc2_get_fgColor(IHTMLDocument2
*iface
, VARIANT
*p
)
450 ok(0, "unexpected call\n");
454 static HRESULT WINAPI
htmldoc2_put_linkColor(IHTMLDocument2
*iface
, VARIANT v
)
456 ok(0, "unexpected call\n");
460 static HRESULT WINAPI
htmldoc2_get_linkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
462 ok(0, "unexpected call\n");
466 static HRESULT WINAPI
htmldoc2_put_vlinkColor(IHTMLDocument2
*iface
, VARIANT v
)
468 ok(0, "unexpected call\n");
472 static HRESULT WINAPI
htmldoc2_get_vlinkColor(IHTMLDocument2
*iface
, VARIANT
*p
)
474 ok(0, "unexpected call\n");
478 static HRESULT WINAPI
htmldoc2_get_referrer(IHTMLDocument2
*iface
, BSTR
*p
)
480 ok(0, "unexpected call\n");
484 static HRESULT WINAPI
htmldoc2_get_location(IHTMLDocument2
*iface
, IHTMLLocation
**p
)
486 ok(0, "unexpected call\n");
490 static HRESULT WINAPI
htmldoc2_get_lastModified(IHTMLDocument2
*iface
, BSTR
*p
)
492 ok(0, "unexpected call\n");
496 static HRESULT WINAPI
htmldoc2_put_URL(IHTMLDocument2
*iface
, BSTR v
)
498 ok(0, "unexpected call\n");
502 static HRESULT WINAPI
htmldoc2_get_URL(IHTMLDocument2
*iface
, BSTR
*p
)
504 CHECK_EXPECT2(htmldoc2_get_url
);
505 *p
= a2bstr("http://test.winehq.org/");
509 static HRESULT WINAPI
htmldoc2_put_domain(IHTMLDocument2
*iface
, BSTR v
)
511 ok(0, "unexpected call\n");
515 static HRESULT WINAPI
htmldoc2_get_domain(IHTMLDocument2
*iface
, BSTR
*p
)
517 ok(0, "unexpected call\n");
521 static HRESULT WINAPI
htmldoc2_put_cookie(IHTMLDocument2
*iface
, BSTR v
)
523 ok(0, "unexpected call\n");
527 static HRESULT WINAPI
htmldoc2_get_cookie(IHTMLDocument2
*iface
, BSTR
*p
)
529 ok(0, "unexpected call\n");
533 static HRESULT WINAPI
htmldoc2_put_expando(IHTMLDocument2
*iface
, VARIANT_BOOL v
)
535 ok(0, "unexpected call\n");
539 static HRESULT WINAPI
htmldoc2_get_expando(IHTMLDocument2
*iface
, VARIANT_BOOL
*p
)
541 ok(0, "unexpected call\n");
545 static HRESULT WINAPI
htmldoc2_put_charset(IHTMLDocument2
*iface
, BSTR v
)
547 ok(0, "unexpected call\n");
551 static HRESULT WINAPI
htmldoc2_get_charset(IHTMLDocument2
*iface
, BSTR
*p
)
553 ok(0, "unexpected call\n");
557 static HRESULT WINAPI
htmldoc2_put_defaultCharset(IHTMLDocument2
*iface
, BSTR v
)
559 ok(0, "unexpected call\n");
563 static HRESULT WINAPI
htmldoc2_get_defaultCharset(IHTMLDocument2
*iface
, BSTR
*p
)
565 ok(0, "unexpected call\n");
569 static HRESULT WINAPI
htmldoc2_get_mimeType(IHTMLDocument2
*iface
, BSTR
*p
)
571 ok(0, "unexpected call\n");
575 static HRESULT WINAPI
htmldoc2_get_fileSize(IHTMLDocument2
*iface
, BSTR
*p
)
577 ok(0, "unexpected call\n");
581 static HRESULT WINAPI
htmldoc2_get_fileCreatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
583 ok(0, "unexpected call\n");
587 static HRESULT WINAPI
htmldoc2_get_fileModifiedDate(IHTMLDocument2
*iface
, BSTR
*p
)
589 ok(0, "unexpected call\n");
593 static HRESULT WINAPI
htmldoc2_get_fileUpdatedDate(IHTMLDocument2
*iface
, BSTR
*p
)
595 ok(0, "unexpected call\n");
599 static HRESULT WINAPI
htmldoc2_get_security(IHTMLDocument2
*iface
, BSTR
*p
)
601 ok(0, "unexpected call\n");
605 static HRESULT WINAPI
htmldoc2_get_protocol(IHTMLDocument2
*iface
, BSTR
*p
)
607 ok(0, "unexpected call\n");
611 static HRESULT WINAPI
htmldoc2_get_nameProp(IHTMLDocument2
*iface
, BSTR
*p
)
613 ok(0, "unexpected call\n");
617 static HRESULT WINAPI
htmldoc2_write(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
619 ok(0, "unexpected call\n");
623 static HRESULT WINAPI
htmldoc2_writeln(IHTMLDocument2
*iface
, SAFEARRAY
*psarray
)
625 ok(0, "unexpected call\n");
629 static HRESULT WINAPI
htmldoc2_open(IHTMLDocument2
*iface
, BSTR url
, VARIANT name
,
630 VARIANT features
, VARIANT replace
, IDispatch
**pomWindowResult
)
632 ok(0, "unexpected call\n");
636 static HRESULT WINAPI
htmldoc2_close(IHTMLDocument2
*iface
)
638 ok(0, "unexpected call\n");
642 static HRESULT WINAPI
htmldoc2_clear(IHTMLDocument2
*iface
)
644 ok(0, "unexpected call\n");
648 static HRESULT WINAPI
htmldoc2_queryCommandSupported(IHTMLDocument2
*iface
, BSTR cmdID
,
651 ok(0, "unexpected call\n");
655 static HRESULT WINAPI
htmldoc2_queryCommandEnabled(IHTMLDocument2
*iface
, BSTR cmdID
,
658 ok(0, "unexpected call\n");
662 static HRESULT WINAPI
htmldoc2_queryCommandState(IHTMLDocument2
*iface
, BSTR cmdID
,
665 ok(0, "unexpected call\n");
669 static HRESULT WINAPI
htmldoc2_queryCommandIndeterm(IHTMLDocument2
*iface
, BSTR cmdID
,
672 ok(0, "unexpected call\n");
676 static HRESULT WINAPI
htmldoc2_queryCommandText(IHTMLDocument2
*iface
, BSTR cmdID
,
679 ok(0, "unexpected call\n");
683 static HRESULT WINAPI
htmldoc2_queryCommandValue(IHTMLDocument2
*iface
, BSTR cmdID
,
686 ok(0, "unexpected call\n");
690 static HRESULT WINAPI
htmldoc2_execCommand(IHTMLDocument2
*iface
, BSTR cmdID
,
691 VARIANT_BOOL showUI
, VARIANT value
, VARIANT_BOOL
*pfRet
)
693 ok(0, "unexpected call\n");
697 static HRESULT WINAPI
htmldoc2_execCommandShowHelp(IHTMLDocument2
*iface
, BSTR cmdID
,
700 ok(0, "unexpected call\n");
704 static HRESULT WINAPI
htmldoc2_createElement(IHTMLDocument2
*iface
, BSTR eTag
,
705 IHTMLElement
**newElem
)
707 ok(0, "unexpected call\n");
711 static HRESULT WINAPI
htmldoc2_put_onhelp(IHTMLDocument2
*iface
, VARIANT v
)
713 ok(0, "unexpected call\n");
717 static HRESULT WINAPI
htmldoc2_get_onhelp(IHTMLDocument2
*iface
, VARIANT
*p
)
719 ok(0, "unexpected call\n");
723 static HRESULT WINAPI
htmldoc2_put_onclick(IHTMLDocument2
*iface
, VARIANT v
)
725 ok(0, "unexpected call\n");
729 static HRESULT WINAPI
htmldoc2_get_onclick(IHTMLDocument2
*iface
, VARIANT
*p
)
731 ok(0, "unexpected call\n");
735 static HRESULT WINAPI
htmldoc2_put_ondblclick(IHTMLDocument2
*iface
, VARIANT v
)
737 ok(0, "unexpected call\n");
741 static HRESULT WINAPI
htmldoc2_get_ondblclick(IHTMLDocument2
*iface
, VARIANT
*p
)
743 ok(0, "unexpected call\n");
747 static HRESULT WINAPI
htmldoc2_put_onkeyup(IHTMLDocument2
*iface
, VARIANT v
)
749 ok(0, "unexpected call\n");
753 static HRESULT WINAPI
htmldoc2_get_onkeyup(IHTMLDocument2
*iface
, VARIANT
*p
)
755 ok(0, "unexpected call\n");
759 static HRESULT WINAPI
htmldoc2_put_onkeydown(IHTMLDocument2
*iface
, VARIANT v
)
761 ok(0, "unexpected call\n");
765 static HRESULT WINAPI
htmldoc2_get_onkeydown(IHTMLDocument2
*iface
, VARIANT
*p
)
767 ok(0, "unexpected call\n");
771 static HRESULT WINAPI
htmldoc2_put_onkeypress(IHTMLDocument2
*iface
, VARIANT v
)
773 ok(0, "unexpected call\n");
777 static HRESULT WINAPI
htmldoc2_get_onkeypress(IHTMLDocument2
*iface
, VARIANT
*p
)
779 ok(0, "unexpected call\n");
783 static HRESULT WINAPI
htmldoc2_put_onmouseup(IHTMLDocument2
*iface
, VARIANT v
)
785 ok(0, "unexpected call\n");
789 static HRESULT WINAPI
htmldoc2_get_onmouseup(IHTMLDocument2
*iface
, VARIANT
*p
)
791 ok(0, "unexpected call\n");
795 static HRESULT WINAPI
htmldoc2_put_onmousedown(IHTMLDocument2
*iface
, VARIANT v
)
797 ok(0, "unexpected call\n");
801 static HRESULT WINAPI
htmldoc2_get_onmousedown(IHTMLDocument2
*iface
, VARIANT
*p
)
803 ok(0, "unexpected call\n");
807 static HRESULT WINAPI
htmldoc2_put_onmousemove(IHTMLDocument2
*iface
, VARIANT v
)
809 ok(0, "unexpected call\n");
813 static HRESULT WINAPI
htmldoc2_get_onmousemove(IHTMLDocument2
*iface
, VARIANT
*p
)
815 ok(0, "unexpected call\n");
819 static HRESULT WINAPI
htmldoc2_put_onmouseout(IHTMLDocument2
*iface
, VARIANT v
)
821 ok(0, "unexpected call\n");
825 static HRESULT WINAPI
htmldoc2_get_onmouseout(IHTMLDocument2
*iface
, VARIANT
*p
)
827 ok(0, "unexpected call\n");
831 static HRESULT WINAPI
htmldoc2_put_onmouseover(IHTMLDocument2
*iface
, VARIANT v
)
833 ok(0, "unexpected call\n");
837 static HRESULT WINAPI
htmldoc2_get_onmouseover(IHTMLDocument2
*iface
, VARIANT
*p
)
839 ok(0, "unexpected call\n");
843 static HRESULT WINAPI
htmldoc2_put_onreadystatechange(IHTMLDocument2
*iface
, VARIANT v
)
845 ok(0, "unexpected call\n");
849 static HRESULT WINAPI
htmldoc2_get_onreadystatechange(IHTMLDocument2
*iface
, VARIANT
*p
)
851 ok(0, "unexpected call\n");
855 static HRESULT WINAPI
htmldoc2_put_onafterupdate(IHTMLDocument2
*iface
, VARIANT v
)
857 ok(0, "unexpected call\n");
861 static HRESULT WINAPI
htmldoc2_get_onafterupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
863 ok(0, "unexpected call\n");
867 static HRESULT WINAPI
htmldoc2_put_onrowexit(IHTMLDocument2
*iface
, VARIANT v
)
869 ok(0, "unexpected call\n");
873 static HRESULT WINAPI
htmldoc2_get_onrowexit(IHTMLDocument2
*iface
, VARIANT
*p
)
875 ok(0, "unexpected call\n");
879 static HRESULT WINAPI
htmldoc2_put_onrowenter(IHTMLDocument2
*iface
, VARIANT v
)
881 ok(0, "unexpected call\n");
885 static HRESULT WINAPI
htmldoc2_get_onrowenter(IHTMLDocument2
*iface
, VARIANT
*p
)
887 ok(0, "unexpected call\n");
891 static HRESULT WINAPI
htmldoc2_put_ondragstart(IHTMLDocument2
*iface
, VARIANT v
)
893 ok(0, "unexpected call\n");
897 static HRESULT WINAPI
htmldoc2_get_ondragstart(IHTMLDocument2
*iface
, VARIANT
*p
)
899 ok(0, "unexpected call\n");
903 static HRESULT WINAPI
htmldoc2_put_onselectstart(IHTMLDocument2
*iface
, VARIANT v
)
905 ok(0, "unexpected call\n");
909 static HRESULT WINAPI
htmldoc2_get_onselectstart(IHTMLDocument2
*iface
, VARIANT
*p
)
911 ok(0, "unexpected call\n");
915 static HRESULT WINAPI
htmldoc2_elementFromPoint(IHTMLDocument2
*iface
, LONG x
, LONG y
,
916 IHTMLElement
**elementHit
)
918 ok(0, "unexpected call\n");
922 static HRESULT WINAPI
htmldoc2_get_parentWindow(IHTMLDocument2
*iface
, IHTMLWindow2
**p
)
924 ok(0, "unexpected call\n");
928 static HRESULT WINAPI
htmldoc2_get_styleSheets(IHTMLDocument2
*iface
,
929 IHTMLStyleSheetsCollection
**p
)
931 ok(0, "unexpected call\n");
935 static HRESULT WINAPI
htmldoc2_put_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT v
)
937 ok(0, "unexpected call\n");
941 static HRESULT WINAPI
htmldoc2_get_onbeforeupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
943 ok(0, "unexpected call\n");
947 static HRESULT WINAPI
htmldoc2_put_onerrorupdate(IHTMLDocument2
*iface
, VARIANT v
)
949 ok(0, "unexpected call\n");
953 static HRESULT WINAPI
htmldoc2_get_onerrorupdate(IHTMLDocument2
*iface
, VARIANT
*p
)
955 ok(0, "unexpected call\n");
959 static HRESULT WINAPI
htmldoc2_toString(IHTMLDocument2
*iface
, BSTR
*String
)
961 ok(0, "unexpected call\n");
965 static HRESULT WINAPI
htmldoc2_createStyleSheet(IHTMLDocument2
*iface
, BSTR bstrHref
,
966 LONG lIndex
, IHTMLStyleSheet
**ppnewStyleSheet
)
968 ok(0, "unexpected call\n");
972 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl
= {
973 htmldoc2_QueryInterface
,
976 htmldoc2_GetTypeInfoCount
,
977 htmldoc2_GetTypeInfo
,
978 htmldoc2_GetIDsOfNames
,
983 htmldoc2_get_activeElement
,
985 htmldoc2_get_applets
,
988 htmldoc2_get_anchors
,
991 htmldoc2_get_scripts
,
992 htmldoc2_put_designMode
,
993 htmldoc2_get_designMode
,
994 htmldoc2_get_selection
,
995 htmldoc2_get_readyState
,
998 htmldoc2_get_plugins
,
999 htmldoc2_put_alinkColor
,
1000 htmldoc2_get_alinkColor
,
1001 htmldoc2_put_bgColor
,
1002 htmldoc2_get_bgColor
,
1003 htmldoc2_put_fgColor
,
1004 htmldoc2_get_fgColor
,
1005 htmldoc2_put_linkColor
,
1006 htmldoc2_get_linkColor
,
1007 htmldoc2_put_vlinkColor
,
1008 htmldoc2_get_vlinkColor
,
1009 htmldoc2_get_referrer
,
1010 htmldoc2_get_location
,
1011 htmldoc2_get_lastModified
,
1014 htmldoc2_put_domain
,
1015 htmldoc2_get_domain
,
1016 htmldoc2_put_cookie
,
1017 htmldoc2_get_cookie
,
1018 htmldoc2_put_expando
,
1019 htmldoc2_get_expando
,
1020 htmldoc2_put_charset
,
1021 htmldoc2_get_charset
,
1022 htmldoc2_put_defaultCharset
,
1023 htmldoc2_get_defaultCharset
,
1024 htmldoc2_get_mimeType
,
1025 htmldoc2_get_fileSize
,
1026 htmldoc2_get_fileCreatedDate
,
1027 htmldoc2_get_fileModifiedDate
,
1028 htmldoc2_get_fileUpdatedDate
,
1029 htmldoc2_get_security
,
1030 htmldoc2_get_protocol
,
1031 htmldoc2_get_nameProp
,
1037 htmldoc2_queryCommandSupported
,
1038 htmldoc2_queryCommandEnabled
,
1039 htmldoc2_queryCommandState
,
1040 htmldoc2_queryCommandIndeterm
,
1041 htmldoc2_queryCommandText
,
1042 htmldoc2_queryCommandValue
,
1043 htmldoc2_execCommand
,
1044 htmldoc2_execCommandShowHelp
,
1045 htmldoc2_createElement
,
1046 htmldoc2_put_onhelp
,
1047 htmldoc2_get_onhelp
,
1048 htmldoc2_put_onclick
,
1049 htmldoc2_get_onclick
,
1050 htmldoc2_put_ondblclick
,
1051 htmldoc2_get_ondblclick
,
1052 htmldoc2_put_onkeyup
,
1053 htmldoc2_get_onkeyup
,
1054 htmldoc2_put_onkeydown
,
1055 htmldoc2_get_onkeydown
,
1056 htmldoc2_put_onkeypress
,
1057 htmldoc2_get_onkeypress
,
1058 htmldoc2_put_onmouseup
,
1059 htmldoc2_get_onmouseup
,
1060 htmldoc2_put_onmousedown
,
1061 htmldoc2_get_onmousedown
,
1062 htmldoc2_put_onmousemove
,
1063 htmldoc2_get_onmousemove
,
1064 htmldoc2_put_onmouseout
,
1065 htmldoc2_get_onmouseout
,
1066 htmldoc2_put_onmouseover
,
1067 htmldoc2_get_onmouseover
,
1068 htmldoc2_put_onreadystatechange
,
1069 htmldoc2_get_onreadystatechange
,
1070 htmldoc2_put_onafterupdate
,
1071 htmldoc2_get_onafterupdate
,
1072 htmldoc2_put_onrowexit
,
1073 htmldoc2_get_onrowexit
,
1074 htmldoc2_put_onrowenter
,
1075 htmldoc2_get_onrowenter
,
1076 htmldoc2_put_ondragstart
,
1077 htmldoc2_get_ondragstart
,
1078 htmldoc2_put_onselectstart
,
1079 htmldoc2_get_onselectstart
,
1080 htmldoc2_elementFromPoint
,
1081 htmldoc2_get_parentWindow
,
1082 htmldoc2_get_styleSheets
,
1083 htmldoc2_put_onbeforeupdate
,
1084 htmldoc2_get_onbeforeupdate
,
1085 htmldoc2_put_onerrorupdate
,
1086 htmldoc2_get_onerrorupdate
,
1088 htmldoc2_createStyleSheet
1091 static IHTMLDocument2 htmldoc2
= { &TestHTMLDocumentVtbl
};
1093 static HRESULT WINAPI
sp_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppvObject
)
1097 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
1098 IsEqualGUID(riid
, &IID_IServiceProvider
))
1101 IServiceProvider_AddRef(iface
);
1105 ok(0, "unexpected query interface: %s\n", debugstr_guid(riid
));
1107 return E_NOINTERFACE
;
1110 static ULONG WINAPI
sp_AddRef(IServiceProvider
*iface
)
1115 static ULONG WINAPI
sp_Release(IServiceProvider
*iface
)
1120 static HRESULT WINAPI
sp_QueryService(IServiceProvider
*iface
, REFGUID service
, REFIID riid
, void **obj
)
1124 if (IsEqualGUID(service
, &SID_SBindHost
) &&
1125 IsEqualGUID(riid
, &IID_IBindHost
))
1127 CHECK_EXPECT2(sp_queryservice_SID_SBindHost
);
1129 else if (IsEqualGUID(service
, &SID_SContainerDispatch
) &&
1130 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1132 CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1134 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1135 IsEqualGUID(riid
, &IID_IHTMLDocument2
))
1137 CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2
);
1141 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1142 IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1144 CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc
);
1146 else if (IsEqualGUID(service
, &SID_SInternetHostSecurityManager
) &&
1147 IsEqualGUID(riid
, &IID_IInternetHostSecurityManager
))
1149 CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr
);
1151 else if (IsEqualGUID(service
, &SID_UnknownSID
) &&
1152 IsEqualGUID(riid
, &IID_IStream
))
1154 /* FIXME: unidentified service id */
1157 ok(0, "unexpected request: sid %s, riid %s\n", debugstr_guid(service
), debugstr_guid(riid
));
1162 static const IServiceProviderVtbl testprovVtbl
=
1170 static IServiceProvider testprov
= { &testprovVtbl
};
1172 static HRESULT WINAPI
site_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppvObject
)
1176 if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1177 CHECK_EXPECT2(site_qi_IServiceProvider
);
1179 if (IsEqualGUID(riid
, &IID_IXMLDOMDocument
))
1180 CHECK_EXPECT2(site_qi_IXMLDOMDocument
);
1182 if (IsEqualGUID(riid
, &IID_IOleClientSite
))
1183 CHECK_EXPECT2(site_qi_IOleClientSite
);
1185 if (IsEqualGUID(riid
, &IID_IUnknown
))
1187 else if (IsEqualGUID(riid
, &IID_IServiceProvider
))
1188 *ppvObject
= &testprov
;
1190 if (*ppvObject
) IUnknown_AddRef(iface
);
1192 return *ppvObject
? S_OK
: E_NOINTERFACE
;
1195 static ULONG WINAPI
site_AddRef(IUnknown
*iface
)
1200 static ULONG WINAPI
site_Release(IUnknown
*iface
)
1205 static const IUnknownVtbl testsiteVtbl
=
1207 site_QueryInterface
,
1212 static IUnknown testsite
= { &testsiteVtbl
};
1216 IDispatch IDispatch_iface
;
1220 static IXMLHttpRequest
*httpreq
;
1222 static inline dispevent
*impl_from_IDispatch( IDispatch
*iface
)
1224 return CONTAINING_RECORD(iface
, dispevent
, IDispatch_iface
);
1227 static HRESULT WINAPI
dispevent_QueryInterface(IDispatch
*iface
, REFIID riid
, void **ppvObject
)
1231 if ( IsEqualGUID( riid
, &IID_IDispatch
) ||
1232 IsEqualGUID( riid
, &IID_IUnknown
) )
1237 return E_NOINTERFACE
;
1239 IDispatch_AddRef( iface
);
1244 static ULONG WINAPI
dispevent_AddRef(IDispatch
*iface
)
1246 dispevent
*This
= impl_from_IDispatch( iface
);
1247 return InterlockedIncrement( &This
->ref
);
1250 static ULONG WINAPI
dispevent_Release(IDispatch
*iface
)
1252 dispevent
*This
= impl_from_IDispatch( iface
);
1253 ULONG ref
= InterlockedDecrement( &This
->ref
);
1256 HeapFree(GetProcessHeap(), 0, This
);
1261 static HRESULT WINAPI
dispevent_GetTypeInfoCount(IDispatch
*iface
, UINT
*pctinfo
)
1268 static HRESULT WINAPI
dispevent_GetTypeInfo(IDispatch
*iface
, UINT iTInfo
,
1269 LCID lcid
, ITypeInfo
**ppTInfo
)
1275 static HRESULT WINAPI
dispevent_GetIDsOfNames(IDispatch
*iface
, REFIID riid
,
1276 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1282 static HRESULT WINAPI
dispevent_Invoke(IDispatch
*iface
, DISPID member
, REFIID riid
,
1283 LCID lcid
, WORD flags
, DISPPARAMS
*params
, VARIANT
*result
,
1284 EXCEPINFO
*excepInfo
, UINT
*argErr
)
1289 ok(member
== 0, "expected 0 member, got %d\n", member
);
1290 ok(lcid
== LOCALE_SYSTEM_DEFAULT
, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid
);
1291 ok(flags
== DISPATCH_METHOD
, "expected DISPATCH_METHOD, got %d\n", flags
);
1293 ok(params
->cArgs
== 0, "got %d\n", params
->cArgs
);
1294 ok(params
->cNamedArgs
== 0, "got %d\n", params
->cNamedArgs
);
1295 ok(params
->rgvarg
== NULL
, "got %p\n", params
->rgvarg
);
1296 ok(params
->rgdispidNamedArgs
== NULL
, "got %p\n", params
->rgdispidNamedArgs
);
1298 ok(result
== NULL
, "got %p\n", result
);
1299 ok(excepInfo
== NULL
, "got %p\n", excepInfo
);
1300 ok(argErr
== NULL
, "got %p\n", argErr
);
1304 state
= READYSTATE_UNINITIALIZED
;
1305 hr
= IXMLHttpRequest_get_readyState(httpreq
, &state
);
1306 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1307 if (state
== READYSTATE_COMPLETE
)
1311 hr
= IXMLHttpRequest_get_responseText(httpreq
, &text
);
1312 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1313 ok(*text
!= 0, "got %s\n", wine_dbgstr_w(text
));
1314 SysFreeString(text
);
1320 static const IDispatchVtbl dispeventVtbl
=
1322 dispevent_QueryInterface
,
1325 dispevent_GetTypeInfoCount
,
1326 dispevent_GetTypeInfo
,
1327 dispevent_GetIDsOfNames
,
1331 static IDispatch
* create_dispevent(void)
1333 dispevent
*event
= HeapAlloc(GetProcessHeap(), 0, sizeof(*event
));
1335 event
->IDispatch_iface
.lpVtbl
= &dispeventVtbl
;
1338 return &event
->IDispatch_iface
;
1341 static IXMLHttpRequest
*create_xhr(void)
1343 IXMLHttpRequest
*ret
;
1346 hr
= CoCreateInstance(&CLSID_XMLHTTPRequest
, NULL
, CLSCTX_INPROC_SERVER
,
1347 &IID_IXMLHttpRequest
, (void**)&ret
);
1349 return SUCCEEDED(hr
) ? ret
: NULL
;
1352 static void set_safety_opt(IUnknown
*unk
, DWORD mask
, DWORD opts
)
1354 IObjectSafety
*obj_safety
;
1357 hr
= IUnknown_QueryInterface(unk
, &IID_IObjectSafety
, (void**)&obj_safety
);
1358 ok(hr
== S_OK
, "Could not get IObjectSafety iface: %08x\n", hr
);
1360 hr
= IObjectSafety_SetInterfaceSafetyOptions(obj_safety
, &IID_IDispatch
, mask
, mask
&opts
);
1361 ok(hr
== S_OK
, "SetInterfaceSafetyOptions failed: %08x\n", hr
);
1363 IObjectSafety_Release(obj_safety
);
1366 static void set_xhr_site(IXMLHttpRequest
*xhr
)
1368 IObjectWithSite
*obj_site
;
1371 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1372 ok(hr
== S_OK
, "Could not get IObjectWithSite iface: %08x\n", hr
);
1374 SET_EXPECT(site_qi_IServiceProvider
);
1375 SET_EXPECT(sp_queryservice_SID_SBindHost
);
1376 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1377 SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2
);
1378 SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc
);
1379 SET_EXPECT(sp_queryservice_SID_secmgr_secmgr
);
1381 /* calls to IHTMLDocument2 */
1382 SET_EXPECT(htmldoc2_get_all
);
1383 SET_EXPECT(collection_get_length
);
1384 SET_EXPECT(htmldoc2_get_url
);
1386 SET_EXPECT(site_qi_IXMLDOMDocument
);
1387 SET_EXPECT(site_qi_IOleClientSite
);
1389 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1390 EXPECT_HR(hr
, S_OK
);
1392 CHECK_CALLED(site_qi_IServiceProvider
);
1394 CHECK_CALLED(sp_queryservice_SID_SBindHost
);
1395 CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1397 CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2
);
1398 CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc
);
1399 /* this one isn't very reliable
1400 CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
1402 CHECK_CALLED(htmldoc2_get_all
);
1403 CHECK_CALLED(collection_get_length
);
1404 CHECK_CALLED(htmldoc2_get_url
);
1406 CHECK_CALLED(site_qi_IXMLDOMDocument
);
1407 CHECK_CALLED(site_qi_IOleClientSite
);
1410 IObjectWithSite_Release(obj_site
);
1413 #define test_open(a,b,c,d) _test_open(__LINE__,a,b,c,d)
1414 static void _test_open(unsigned line
, IXMLHttpRequest
*xhr
, const char *method
, const char *url
, HRESULT exhres
)
1416 VARIANT empty
, vfalse
;
1419 V_VT(&empty
) = VT_EMPTY
;
1420 V_VT(&vfalse
) = VT_BOOL
;
1421 V_BOOL(&vfalse
) = VARIANT_FALSE
;
1423 hr
= IXMLHttpRequest_open(xhr
, _bstr_(method
), _bstr_(url
), vfalse
, empty
, empty
);
1424 ok_(__FILE__
,line
)(hr
== exhres
, "open(%s %s) failed: %08x, expected %08x\n", method
, url
, hr
, exhres
);
1427 static void test_XMLHTTP(void)
1429 static const char bodyA
[] = "mode=Test";
1430 static const char urlA
[] = "http://crossover.codeweavers.com/posttest.php";
1431 static const char xmltestA
[] = "http://crossover.codeweavers.com/xmltest.xml";
1432 static const WCHAR wszExpectedResponse
[] = {'F','A','I','L','E','D',0};
1433 static const CHAR xmltestbodyA
[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
1435 IXMLHttpRequest
*xhr
;
1436 IObjectWithSite
*obj_site
, *obj_site2
;
1437 BSTR bstrResponse
, str
, str1
;
1438 VARIANT varbody
, varbody_ref
;
1440 LONG state
, status
, bound
;
1448 VariantInit(&dummy
);
1449 V_VT(&dummy
) = VT_ERROR
;
1450 V_ERROR(&dummy
) = DISP_E_MEMBERNOTFOUND
;
1452 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, NULL
);
1453 EXPECT_HR(hr
, S_OK
);
1455 hr
= IXMLHttpRequest_abort(xhr
);
1456 EXPECT_HR(hr
, S_OK
);
1458 V_VT(&varbody
) = VT_I2
;
1460 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1461 EXPECT_HR(hr
, E_PENDING
);
1462 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1463 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
1465 V_VT(&varbody
) = VT_I2
;
1467 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1468 EXPECT_HR(hr
, E_PENDING
);
1469 ok(V_VT(&varbody
) == VT_EMPTY
, "got type %d\n", V_VT(&varbody
));
1470 ok(V_I2(&varbody
) == 1, "got %d\n", V_I2(&varbody
));
1472 /* send before open */
1473 hr
= IXMLHttpRequest_send(xhr
, dummy
);
1474 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1476 /* initial status code */
1477 hr
= IXMLHttpRequest_get_status(xhr
, NULL
);
1478 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1480 status
= 0xdeadbeef;
1481 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1482 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1483 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1485 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1486 ok(hr
== E_FAIL
, "got 0x%08x\n", hr
);
1488 /* invalid parameters */
1489 test_open(xhr
, NULL
, NULL
, E_INVALIDARG
);
1490 test_open(xhr
, "POST", NULL
, E_INVALIDARG
);
1491 test_open(xhr
, NULL
, urlA
, E_INVALIDARG
);
1493 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, NULL
);
1494 EXPECT_HR(hr
, E_INVALIDARG
);
1496 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), NULL
);
1497 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1499 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1500 EXPECT_HR(hr
, E_INVALIDARG
);
1502 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1503 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1505 hr
= IXMLHttpRequest_get_readyState(xhr
, NULL
);
1506 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1509 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1510 EXPECT_HR(hr
, S_OK
);
1511 ok(state
== READYSTATE_UNINITIALIZED
, "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1514 event
= create_dispevent();
1516 EXPECT_REF(event
, 1);
1517 hr
= IXMLHttpRequest_put_onreadystatechange(xhr
, event
);
1518 EXPECT_HR(hr
, S_OK
);
1519 EXPECT_REF(event
, 2);
1521 g_unexpectedcall
= g_expectedcall
= 0;
1523 test_open(xhr
, "POST", urlA
, S_OK
);
1525 ok(g_unexpectedcall
== 0, "unexpected disp event call\n");
1526 ok(g_expectedcall
== 1 || broken(g_expectedcall
== 0) /* win2k */, "no expected disp event call\n");
1528 /* status code after ::open() */
1529 status
= 0xdeadbeef;
1530 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1531 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1532 ok(status
== READYSTATE_UNINITIALIZED
|| broken(status
== 0xdeadbeef) /* <win8 */, "got %d\n", status
);
1535 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1536 EXPECT_HR(hr
, S_OK
);
1537 ok(state
== READYSTATE_LOADING
, "got %d, expected READYSTATE_LOADING\n", state
);
1539 hr
= IXMLHttpRequest_abort(xhr
);
1540 EXPECT_HR(hr
, S_OK
);
1543 hr
= IXMLHttpRequest_get_readyState(xhr
, &state
);
1544 EXPECT_HR(hr
, S_OK
);
1545 ok(state
== READYSTATE_UNINITIALIZED
|| broken(state
== READYSTATE_LOADING
) /* win2k */,
1546 "got %d, expected READYSTATE_UNINITIALIZED\n", state
);
1548 test_open(xhr
, "POST", urlA
, S_OK
);
1550 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_("header1"), _bstr_("value1"));
1551 EXPECT_HR(hr
, S_OK
);
1553 hr
= IXMLHttpRequest_setRequestHeader(xhr
, NULL
, _bstr_("value1"));
1554 EXPECT_HR(hr
, E_INVALIDARG
);
1556 hr
= IXMLHttpRequest_setRequestHeader(xhr
, _bstr_(""), _bstr_("value1"));
1557 EXPECT_HR(hr
, E_INVALIDARG
);
1559 V_VT(&varbody
) = VT_BSTR
;
1560 V_BSTR(&varbody
) = _bstr_(bodyA
);
1562 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1563 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1565 skip("No connection could be made with crossover.codeweavers.com\n");
1566 IXMLHttpRequest_Release(xhr
);
1569 EXPECT_HR(hr
, S_OK
);
1571 /* response headers */
1572 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, NULL
);
1573 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1574 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str
);
1575 EXPECT_HR(hr
, S_OK
);
1576 /* status line is stripped already */
1577 ok(memcmp(str
, _bstr_("HTTP"), 4*sizeof(WCHAR
)), "got response headers %s\n", wine_dbgstr_w(str
));
1578 ok(*str
, "got empty headers\n");
1579 hr
= IXMLHttpRequest_getAllResponseHeaders(xhr
, &str1
);
1580 EXPECT_HR(hr
, S_OK
);
1581 ok(str1
!= str
, "got %p\n", str1
);
1582 SysFreeString(str1
);
1585 hr
= IXMLHttpRequest_getResponseHeader(xhr
, NULL
, NULL
);
1586 EXPECT_HR(hr
, E_INVALIDARG
);
1587 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), NULL
);
1588 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1589 hr
= IXMLHttpRequest_getResponseHeader(xhr
, _bstr_("Date"), &str
);
1590 EXPECT_HR(hr
, S_OK
);
1591 ok(*str
!= ' ', "got leading space in header %s\n", wine_dbgstr_w(str
));
1594 /* status code after ::send() */
1595 status
= 0xdeadbeef;
1596 hr
= IXMLHttpRequest_get_status(xhr
, &status
);
1597 EXPECT_HR(hr
, S_OK
);
1598 ok(status
== 200, "got %d\n", status
);
1600 hr
= IXMLHttpRequest_get_statusText(xhr
, NULL
);
1601 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1603 hr
= IXMLHttpRequest_get_statusText(xhr
, &str
);
1604 EXPECT_HR(hr
, S_OK
);
1605 ok(!lstrcmpW(str
, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str
));
1608 /* another ::send() after completed request */
1609 V_VT(&varbody
) = VT_BSTR
;
1610 V_BSTR(&varbody
) = _bstr_(bodyA
);
1612 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1613 ok(hr
== E_FAIL
|| broken(hr
== E_UNEXPECTED
) /* win2k */, "got 0x%08x\n", hr
);
1615 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1616 EXPECT_HR(hr
, S_OK
);
1617 /* the server currently returns "FAILED" because the Content-Type header is
1618 * not what the server expects */
1621 ok(!memcmp(bstrResponse
, wszExpectedResponse
, sizeof(wszExpectedResponse
)),
1622 "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse
), wine_dbgstr_w(bstrResponse
));
1623 SysFreeString(bstrResponse
);
1626 /* POST: VT_VARIANT|VT_BYREF body */
1627 test_open(xhr
, "POST", urlA
, S_OK
);
1629 V_VT(&varbody_ref
) = VT_VARIANT
|VT_BYREF
;
1630 V_VARIANTREF(&varbody_ref
) = &varbody
;
1631 hr
= IXMLHttpRequest_send(xhr
, varbody_ref
);
1632 EXPECT_HR(hr
, S_OK
);
1635 test_open(xhr
, "GET", xmltestA
, S_OK
);
1637 V_VT(&varbody
) = VT_EMPTY
;
1639 hr
= IXMLHttpRequest_send(xhr
, varbody
);
1640 if (hr
== INET_E_RESOURCE_NOT_FOUND
)
1642 skip("No connection could be made with crossover.codeweavers.com\n");
1643 IXMLHttpRequest_Release(xhr
);
1646 EXPECT_HR(hr
, S_OK
);
1648 hr
= IXMLHttpRequest_get_responseText(xhr
, NULL
);
1649 ok(hr
== E_POINTER
|| broken(hr
== E_INVALIDARG
) /* <win8 */, "got 0x%08x\n", hr
);
1651 hr
= IXMLHttpRequest_get_responseText(xhr
, &bstrResponse
);
1652 EXPECT_HR(hr
, S_OK
);
1653 ok(!memcmp(bstrResponse
, _bstr_(xmltestbodyA
), sizeof(xmltestbodyA
)*sizeof(WCHAR
)),
1654 "expected %s, got %s\n", xmltestbodyA
, wine_dbgstr_w(bstrResponse
));
1655 SysFreeString(bstrResponse
);
1657 hr
= IXMLHttpRequest_get_responseBody(xhr
, NULL
);
1658 EXPECT_HR(hr
, E_INVALIDARG
);
1660 V_VT(&varbody
) = VT_EMPTY
;
1661 hr
= IXMLHttpRequest_get_responseBody(xhr
, &varbody
);
1662 EXPECT_HR(hr
, S_OK
);
1663 ok(V_VT(&varbody
) == (VT_ARRAY
|VT_UI1
), "got type %d, expected %d\n", V_VT(&varbody
), VT_ARRAY
|VT_UI1
);
1664 ok(SafeArrayGetDim(V_ARRAY(&varbody
)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody
)));
1667 hr
= SafeArrayGetLBound(V_ARRAY(&varbody
), 1, &bound
);
1668 EXPECT_HR(hr
, S_OK
);
1669 ok(bound
== 0, "got %d, expected zero bound\n", bound
);
1671 hr
= SafeArrayAccessData(V_ARRAY(&varbody
), &ptr
);
1672 EXPECT_HR(hr
, S_OK
);
1673 ok(memcmp(ptr
, xmltestbodyA
, sizeof(xmltestbodyA
)-1) == 0, "got wrong body data\n");
1674 SafeArrayUnaccessData(V_ARRAY(&varbody
));
1676 VariantClear(&varbody
);
1678 /* get_responseStream */
1679 hr
= IXMLHttpRequest_get_responseStream(xhr
, NULL
);
1680 EXPECT_HR(hr
, E_INVALIDARG
);
1682 V_VT(&varbody
) = VT_EMPTY
;
1683 hr
= IXMLHttpRequest_get_responseStream(xhr
, &varbody
);
1684 ok(V_VT(&varbody
) == VT_UNKNOWN
, "got type %d\n", V_VT(&varbody
));
1685 EXPECT_HR(hr
, S_OK
);
1686 EXPECT_REF(V_UNKNOWN(&varbody
), 1);
1689 hr
= GetHGlobalFromStream((IStream
*)V_UNKNOWN(&varbody
), &g
);
1690 EXPECT_HR(hr
, S_OK
);
1691 ok(g
!= NULL
, "got %p\n", g
);
1693 IDispatch_Release(event
);
1695 /* interaction with object site */
1696 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site
);
1697 EXPECT_HR(hr
, S_OK
);
1699 hr
= IObjectWithSite_SetSite(obj_site
, NULL
);
1700 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1702 hr
= IXMLHttpRequest_QueryInterface(xhr
, &IID_IObjectWithSite
, (void**)&obj_site2
);
1703 EXPECT_HR(hr
, S_OK
);
1704 ok(obj_site
== obj_site2
|| broken(obj_site
!= obj_site2
), "got new instance\n");
1705 IObjectWithSite_Release(obj_site2
);
1709 /* try to set site another time */
1710 SET_EXPECT(site_qi_IServiceProvider
);
1711 SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2
);
1713 hr
= IObjectWithSite_SetSite(obj_site
, &testsite
);
1714 EXPECT_HR(hr
, S_OK
);
1716 IObjectWithSite_Release(obj_site
);
1717 IXMLHttpRequest_Release(xhr
);
1721 static void test_safe_httpreq(void)
1723 IXMLHttpRequest
*xhr
;
1727 set_safety_opt((IUnknown
*)xhr
, INTERFACESAFE_FOR_UNTRUSTED_DATA
, -1);
1730 /* different scheme */
1731 test_open(xhr
, "GET", "https://test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1733 /* different host */
1734 test_open(xhr
, "GET", "http://tests.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1735 test_open(xhr
, "GET", "http://www.test.winehq.org/tests/hello.html", E_ACCESSDENIED
);
1737 IXMLHttpRequest_Release(xhr
);
1742 IXMLHttpRequest
*xhr
;
1746 if((xhr
= create_xhr())) {
1747 IXMLHttpRequest_Release(xhr
);
1750 test_safe_httpreq();
1752 win_skip("IXMLHTTPRequest is not available\n");