1 /*
2  * XML test
3  *
4  * Copyright 2010-2012 Nikolay Sivov for CodeWeavers
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #include "precomp.h"
22 
23 #define EXPECT_HR(hr,hr_exp) \
24     ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
25 
26 #define EXPECT_REF(node,ref) _expect_ref((IUnknown*)node, ref, __LINE__)
27 static void _expect_ref(IUnknown* obj, ULONG ref, int line)
28 {
29     ULONG rc;
30     IUnknown_AddRef(obj);
31     rc = IUnknown_Release(obj);
32     ok_(__FILE__, line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
33 }
34 
35 DEFINE_GUID(SID_SContainerDispatch, 0xb722be00, 0x4e68, 0x101b, 0xa2, 0xbc, 0x00, 0xaa, 0x00, 0x40, 0x47, 0x70);
36 DEFINE_GUID(SID_UnknownSID, 0x75dd09cb, 0x6c40, 0x11d5, 0x85, 0x43, 0x00, 0xc0, 0x4f, 0xa0, 0xfb, 0xa3);
37 
38 static BOOL g_enablecallchecks;
39 
40 #define DEFINE_EXPECT(func) \
41     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
42 
43 #define SET_EXPECT(func) \
44     expect_ ## func = TRUE
45 
46 #define CHECK_EXPECT2(func) \
47     do { \
48         if (g_enablecallchecks) \
49             ok(expect_ ##func, "unexpected call " #func "\n"); \
50         called_ ## func = TRUE; \
51     }while(0)
52 
53 #define CHECK_CALLED(func) \
54     do { \
55         ok(called_ ## func, "expected " #func "\n"); \
56         expect_ ## func = called_ ## func = FALSE; \
57     }while(0)
58 
59 /* object site */
60 DEFINE_EXPECT(site_qi_IServiceProvider);
61 DEFINE_EXPECT(site_qi_IXMLDOMDocument);
62 DEFINE_EXPECT(site_qi_IOleClientSite);
63 
64 DEFINE_EXPECT(sp_queryservice_SID_SBindHost);
65 DEFINE_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
66 DEFINE_EXPECT(sp_queryservice_SID_secmgr_htmldoc2);
67 DEFINE_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc);
68 DEFINE_EXPECT(sp_queryservice_SID_secmgr_secmgr);
69 
70 DEFINE_EXPECT(htmldoc2_get_all);
71 DEFINE_EXPECT(htmldoc2_get_url);
72 DEFINE_EXPECT(collection_get_length);
73 
74 static int g_unexpectedcall, g_expectedcall;
75 
76 static BSTR alloc_str_from_narrow(const char *str)
77 {
78     int len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
79     BSTR ret = SysAllocStringLen(NULL, len - 1);  /* NUL character added automatically */
80     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len-1);
81     return ret;
82 }
83 
84 static BSTR alloced_bstrs[256];
85 static int alloced_bstrs_count;
86 
87 static BSTR _bstr_(const char *str)
88 {
89     if(!str)
90         return NULL;
91 
92     assert(alloced_bstrs_count < sizeof(alloced_bstrs)/sizeof(alloced_bstrs[0]));
93     alloced_bstrs[alloced_bstrs_count] = alloc_str_from_narrow(str);
94     return alloced_bstrs[alloced_bstrs_count++];
95 }
96 
97 static void free_bstrs(void)
98 {
99     int i;
100     for (i = 0; i < alloced_bstrs_count; i++)
101         SysFreeString(alloced_bstrs[i]);
102     alloced_bstrs_count = 0;
103 }
104 
105 static BSTR a2bstr(const char *str)
106 {
107     BSTR ret;
108     int len;
109 
110     if(!str)
111         return NULL;
112 
113     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
114     ret = SysAllocStringLen(NULL, len);
115     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
116 
117     return ret;
118 }
119 
120 
121 /* test IHTMLElementCollection */
122 static HRESULT WINAPI htmlecoll_QueryInterface(IHTMLElementCollection *iface, REFIID riid, void **ppvObject)
123 {
124     ok(0, "unexpected call\n");
125     *ppvObject = NULL;
126     return E_NOINTERFACE;
127 }
128 
129 static ULONG WINAPI htmlecoll_AddRef(IHTMLElementCollection *iface)
130 {
131     return 2;
132 }
133 
134 static ULONG WINAPI htmlecoll_Release(IHTMLElementCollection *iface)
135 {
136     return 1;
137 }
138 
139 static HRESULT WINAPI htmlecoll_GetTypeInfoCount(IHTMLElementCollection *iface, UINT *pctinfo)
140 {
141     ok(0, "unexpected call\n");
142     return E_NOTIMPL;
143 }
144 
145 static HRESULT WINAPI htmlecoll_GetTypeInfo(IHTMLElementCollection *iface, UINT iTInfo,
146                                                 LCID lcid, ITypeInfo **ppTInfo)
147 {
148     ok(0, "unexpected call\n");
149     return E_NOTIMPL;
150 }
151 
152 static HRESULT WINAPI htmlecoll_GetIDsOfNames(IHTMLElementCollection *iface, REFIID riid,
153                                                 LPOLESTR *rgszNames, UINT cNames,
154                                                 LCID lcid, DISPID *rgDispId)
155 {
156     ok(0, "unexpected call\n");
157     return E_NOTIMPL;
158 }
159 
160 static HRESULT WINAPI htmlecoll_Invoke(IHTMLElementCollection *iface, DISPID dispIdMember,
161                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
162                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
163 {
164     ok(0, "unexpected call\n");
165     return E_NOTIMPL;
166 }
167 
168 static HRESULT WINAPI htmlecoll_toString(IHTMLElementCollection *iface, BSTR *String)
169 {
170     ok(0, "unexpected call\n");
171     return E_NOTIMPL;
172 }
173 
174 static HRESULT WINAPI htmlecoll_put_length(IHTMLElementCollection *iface, LONG v)
175 {
176     ok(0, "unexpected call\n");
177     return E_NOTIMPL;
178 }
179 
180 static HRESULT WINAPI htmlecoll_get_length(IHTMLElementCollection *iface, LONG *v)
181 {
182     CHECK_EXPECT2(collection_get_length);
183     return E_NOTIMPL;
184 }
185 
186 static HRESULT WINAPI htmlecoll_get__newEnum(IHTMLElementCollection *iface, IUnknown **p)
187 {
188     ok(0, "unexpected call\n");
189     return E_NOTIMPL;
190 }
191 
192 static HRESULT WINAPI htmlecoll_item(IHTMLElementCollection *iface, VARIANT name, VARIANT index, IDispatch **pdisp)
193 {
194     ok(0, "unexpected call\n");
195     return E_NOTIMPL;
196 }
197 
198 static HRESULT WINAPI htmlecoll_tags(IHTMLElementCollection *iface, VARIANT tagName, IDispatch **pdisp)
199 {
200     ok(0, "unexpected call\n");
201     return E_NOTIMPL;
202 }
203 
204 static const IHTMLElementCollectionVtbl TestHTMLECollectionVtbl = {
205     htmlecoll_QueryInterface,
206     htmlecoll_AddRef,
207     htmlecoll_Release,
208     htmlecoll_GetTypeInfoCount,
209     htmlecoll_GetTypeInfo,
210     htmlecoll_GetIDsOfNames,
211     htmlecoll_Invoke,
212     htmlecoll_toString,
213     htmlecoll_put_length,
214     htmlecoll_get_length,
215     htmlecoll_get__newEnum,
216     htmlecoll_item,
217     htmlecoll_tags
218 };
219 
220 static IHTMLElementCollection htmlecoll = { &TestHTMLECollectionVtbl };
221 
222 /* test IHTMLDocument2 */
223 static HRESULT WINAPI htmldoc2_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
224 {
225    trace("\n");
226    *ppvObject = NULL;
227    return E_NOINTERFACE;
228 }
229 
230 static ULONG WINAPI htmldoc2_AddRef(IHTMLDocument2 *iface)
231 {
232     return 2;
233 }
234 
235 static ULONG WINAPI htmldoc2_Release(IHTMLDocument2 *iface)
236 {
237     return 1;
238 }
239 
240 static HRESULT WINAPI htmldoc2_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
241 {
242     ok(0, "unexpected call\n");
243     return E_NOTIMPL;
244 }
245 
246 static HRESULT WINAPI htmldoc2_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
247                                                 LCID lcid, ITypeInfo **ppTInfo)
248 {
249     ok(0, "unexpected call\n");
250     return E_NOTIMPL;
251 }
252 
253 static HRESULT WINAPI htmldoc2_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
254                                                 LPOLESTR *rgszNames, UINT cNames,
255                                                 LCID lcid, DISPID *rgDispId)
256 {
257     ok(0, "unexpected call\n");
258     return E_NOTIMPL;
259 }
260 
261 static HRESULT WINAPI htmldoc2_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
262                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
263                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
264 {
265     ok(0, "unexpected call\n");
266     return E_NOTIMPL;
267 }
268 
269 static HRESULT WINAPI htmldoc2_get_Script(IHTMLDocument2 *iface, IDispatch **p)
270 {
271     ok(0, "unexpected call\n");
272     return E_NOTIMPL;
273 }
274 
275 static HRESULT WINAPI htmldoc2_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
276 {
277     CHECK_EXPECT2(htmldoc2_get_all);
278     *p = &htmlecoll;
279     return S_OK;
280 }
281 
282 static HRESULT WINAPI htmldoc2_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
283 {
284     ok(0, "unexpected call\n");
285     return E_NOTIMPL;
286 }
287 
288 static HRESULT WINAPI htmldoc2_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
289 {
290     ok(0, "unexpected call\n");
291     return E_NOTIMPL;
292 }
293 
294 static HRESULT WINAPI htmldoc2_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
295 {
296     ok(0, "unexpected call\n");
297     return E_NOTIMPL;
298 }
299 
300 static HRESULT WINAPI htmldoc2_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
301 {
302     ok(0, "unexpected call\n");
303     return E_NOTIMPL;
304 }
305 
306 static HRESULT WINAPI htmldoc2_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
307 {
308     ok(0, "unexpected call\n");
309     return E_NOTIMPL;
310 }
311 
312 static HRESULT WINAPI htmldoc2_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
313 {
314     ok(0, "unexpected call\n");
315     return E_NOTIMPL;
316 }
317 
318 static HRESULT WINAPI htmldoc2_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
319 {
320     ok(0, "unexpected call\n");
321     return E_NOTIMPL;
322 }
323 
324 static HRESULT WINAPI htmldoc2_put_title(IHTMLDocument2 *iface, BSTR v)
325 {
326     ok(0, "unexpected call\n");
327     return E_NOTIMPL;
328 }
329 
330 static HRESULT WINAPI htmldoc2_get_title(IHTMLDocument2 *iface, BSTR *p)
331 {
332     ok(0, "unexpected call\n");
333     return E_NOTIMPL;
334 }
335 
336 static HRESULT WINAPI htmldoc2_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
337 {
338     ok(0, "unexpected call\n");
339     return E_NOTIMPL;
340 }
341 
342 static HRESULT WINAPI htmldoc2_put_designMode(IHTMLDocument2 *iface, BSTR v)
343 {
344     ok(0, "unexpected call\n");
345     return E_NOTIMPL;
346 }
347 
348 static HRESULT WINAPI htmldoc2_get_designMode(IHTMLDocument2 *iface, BSTR *p)
349 {
350     ok(0, "unexpected call\n");
351     return E_NOTIMPL;
352 }
353 
354 static HRESULT WINAPI htmldoc2_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
355 {
356     ok(0, "unexpected call\n");
357     return E_NOTIMPL;
358 }
359 
360 static HRESULT WINAPI htmldoc2_get_readyState(IHTMLDocument2 *iface, BSTR *p)
361 {
362     ok(0, "unexpected call\n");
363     return E_NOTIMPL;
364 }
365 
366 static HRESULT WINAPI htmldoc2_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
367 {
368     ok(0, "unexpected call\n");
369     return E_NOTIMPL;
370 }
371 
372 static HRESULT WINAPI htmldoc2_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
373 {
374     ok(0, "unexpected call\n");
375     return E_NOTIMPL;
376 }
377 
378 static HRESULT WINAPI htmldoc2_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
379 {
380     ok(0, "unexpected call\n");
381     return E_NOTIMPL;
382 }
383 
384 static HRESULT WINAPI htmldoc2_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
385 {
386     ok(0, "unexpected call\n");
387     return E_NOTIMPL;
388 }
389 
390 static HRESULT WINAPI htmldoc2_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
391 {
392     ok(0, "unexpected call\n");
393     return E_NOTIMPL;
394 }
395 
396 static HRESULT WINAPI htmldoc2_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
397 {
398     ok(0, "unexpected call\n");
399     return E_NOTIMPL;
400 }
401 
402 static HRESULT WINAPI htmldoc2_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
403 {
404     ok(0, "unexpected call\n");
405     return E_NOTIMPL;
406 }
407 
408 static HRESULT WINAPI htmldoc2_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
409 {
410     ok(0, "unexpected call\n");
411     return E_NOTIMPL;
412 }
413 
414 static HRESULT WINAPI htmldoc2_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
415 {
416     ok(0, "unexpected call\n");
417     return E_NOTIMPL;
418 }
419 
420 static HRESULT WINAPI htmldoc2_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
421 {
422     ok(0, "unexpected call\n");
423     return E_NOTIMPL;
424 }
425 
426 static HRESULT WINAPI htmldoc2_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
427 {
428     ok(0, "unexpected call\n");
429     return E_NOTIMPL;
430 }
431 
432 static HRESULT WINAPI htmldoc2_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
433 {
434     ok(0, "unexpected call\n");
435     return E_NOTIMPL;
436 }
437 
438 static HRESULT WINAPI htmldoc2_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
439 {
440     ok(0, "unexpected call\n");
441     return E_NOTIMPL;
442 }
443 
444 static HRESULT WINAPI htmldoc2_get_referrer(IHTMLDocument2 *iface, BSTR *p)
445 {
446     ok(0, "unexpected call\n");
447     return E_NOTIMPL;
448 }
449 
450 static HRESULT WINAPI htmldoc2_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
451 {
452     ok(0, "unexpected call\n");
453     return E_NOTIMPL;
454 }
455 
456 static HRESULT WINAPI htmldoc2_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
457 {
458     ok(0, "unexpected call\n");
459     return E_NOTIMPL;
460 }
461 
462 static HRESULT WINAPI htmldoc2_put_URL(IHTMLDocument2 *iface, BSTR v)
463 {
464     ok(0, "unexpected call\n");
465     return E_NOTIMPL;
466 }
467 
468 static HRESULT WINAPI htmldoc2_get_URL(IHTMLDocument2 *iface, BSTR *p)
469 {
470     CHECK_EXPECT2(htmldoc2_get_url);
471     *p = a2bstr("http://test.winehq.org/");
472     return S_OK;
473 }
474 
475 static HRESULT WINAPI htmldoc2_put_domain(IHTMLDocument2 *iface, BSTR v)
476 {
477     ok(0, "unexpected call\n");
478     return E_NOTIMPL;
479 }
480 
481 static HRESULT WINAPI htmldoc2_get_domain(IHTMLDocument2 *iface, BSTR *p)
482 {
483     ok(0, "unexpected call\n");
484     return E_NOTIMPL;
485 }
486 
487 static HRESULT WINAPI htmldoc2_put_cookie(IHTMLDocument2 *iface, BSTR v)
488 {
489     ok(0, "unexpected call\n");
490     return E_NOTIMPL;
491 }
492 
493 static HRESULT WINAPI htmldoc2_get_cookie(IHTMLDocument2 *iface, BSTR *p)
494 {
495     ok(0, "unexpected call\n");
496     return E_NOTIMPL;
497 }
498 
499 static HRESULT WINAPI htmldoc2_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
500 {
501     ok(0, "unexpected call\n");
502     return E_NOTIMPL;
503 }
504 
505 static HRESULT WINAPI htmldoc2_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
506 {
507     ok(0, "unexpected call\n");
508     return E_NOTIMPL;
509 }
510 
511 static HRESULT WINAPI htmldoc2_put_charset(IHTMLDocument2 *iface, BSTR v)
512 {
513     ok(0, "unexpected call\n");
514     return E_NOTIMPL;
515 }
516 
517 static HRESULT WINAPI htmldoc2_get_charset(IHTMLDocument2 *iface, BSTR *p)
518 {
519     ok(0, "unexpected call\n");
520     return E_NOTIMPL;
521 }
522 
523 static HRESULT WINAPI htmldoc2_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
524 {
525     ok(0, "unexpected call\n");
526     return E_NOTIMPL;
527 }
528 
529 static HRESULT WINAPI htmldoc2_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
530 {
531     ok(0, "unexpected call\n");
532     return E_NOTIMPL;
533 }
534 
535 static HRESULT WINAPI htmldoc2_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
536 {
537     ok(0, "unexpected call\n");
538     return E_NOTIMPL;
539 }
540 
541 static HRESULT WINAPI htmldoc2_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
542 {
543     ok(0, "unexpected call\n");
544     return E_NOTIMPL;
545 }
546 
547 static HRESULT WINAPI htmldoc2_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
548 {
549     ok(0, "unexpected call\n");
550     return E_NOTIMPL;
551 }
552 
553 static HRESULT WINAPI htmldoc2_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
554 {
555     ok(0, "unexpected call\n");
556     return E_NOTIMPL;
557 }
558 
559 static HRESULT WINAPI htmldoc2_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
560 {
561     ok(0, "unexpected call\n");
562     return E_NOTIMPL;
563 }
564 
565 static HRESULT WINAPI htmldoc2_get_security(IHTMLDocument2 *iface, BSTR *p)
566 {
567     ok(0, "unexpected call\n");
568     return E_NOTIMPL;
569 }
570 
571 static HRESULT WINAPI htmldoc2_get_protocol(IHTMLDocument2 *iface, BSTR *p)
572 {
573     ok(0, "unexpected call\n");
574     return E_NOTIMPL;
575 }
576 
577 static HRESULT WINAPI htmldoc2_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
578 {
579     ok(0, "unexpected call\n");
580     return E_NOTIMPL;
581 }
582 
583 static HRESULT WINAPI htmldoc2_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
584 {
585     ok(0, "unexpected call\n");
586     return E_NOTIMPL;
587 }
588 
589 static HRESULT WINAPI htmldoc2_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
590 {
591     ok(0, "unexpected call\n");
592     return E_NOTIMPL;
593 }
594 
595 static HRESULT WINAPI htmldoc2_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
596                         VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
597 {
598     ok(0, "unexpected call\n");
599     return E_NOTIMPL;
600 }
601 
602 static HRESULT WINAPI htmldoc2_close(IHTMLDocument2 *iface)
603 {
604     ok(0, "unexpected call\n");
605     return E_NOTIMPL;
606 }
607 
608 static HRESULT WINAPI htmldoc2_clear(IHTMLDocument2 *iface)
609 {
610     ok(0, "unexpected call\n");
611     return E_NOTIMPL;
612 }
613 
614 static HRESULT WINAPI htmldoc2_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
615                                                         VARIANT_BOOL *pfRet)
616 {
617     ok(0, "unexpected call\n");
618     return E_NOTIMPL;
619 }
620 
621 static HRESULT WINAPI htmldoc2_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
622                                                         VARIANT_BOOL *pfRet)
623 {
624     ok(0, "unexpected call\n");
625     return E_NOTIMPL;
626 }
627 
628 static HRESULT WINAPI htmldoc2_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
629                                                         VARIANT_BOOL *pfRet)
630 {
631     ok(0, "unexpected call\n");
632     return E_NOTIMPL;
633 }
634 
635 static HRESULT WINAPI htmldoc2_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
636                                                         VARIANT_BOOL *pfRet)
637 {
638     ok(0, "unexpected call\n");
639     return E_NOTIMPL;
640 }
641 
642 static HRESULT WINAPI htmldoc2_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
643                                                         BSTR *pfRet)
644 {
645     ok(0, "unexpected call\n");
646     return E_NOTIMPL;
647 }
648 
649 static HRESULT WINAPI htmldoc2_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
650                                                         VARIANT *pfRet)
651 {
652     ok(0, "unexpected call\n");
653     return E_NOTIMPL;
654 }
655 
656 static HRESULT WINAPI htmldoc2_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
657                                 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
658 {
659     ok(0, "unexpected call\n");
660     return E_NOTIMPL;
661 }
662 
663 static HRESULT WINAPI htmldoc2_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
664                                                         VARIANT_BOOL *pfRet)
665 {
666     ok(0, "unexpected call\n");
667     return E_NOTIMPL;
668 }
669 
670 static HRESULT WINAPI htmldoc2_createElement(IHTMLDocument2 *iface, BSTR eTag,
671                                                  IHTMLElement **newElem)
672 {
673     ok(0, "unexpected call\n");
674     return E_NOTIMPL;
675 }
676 
677 static HRESULT WINAPI htmldoc2_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
678 {
679     ok(0, "unexpected call\n");
680     return E_NOTIMPL;
681 }
682 
683 static HRESULT WINAPI htmldoc2_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
684 {
685     ok(0, "unexpected call\n");
686     return E_NOTIMPL;
687 }
688 
689 static HRESULT WINAPI htmldoc2_put_onclick(IHTMLDocument2 *iface, VARIANT v)
690 {
691     ok(0, "unexpected call\n");
692     return E_NOTIMPL;
693 }
694 
695 static HRESULT WINAPI htmldoc2_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
696 {
697     ok(0, "unexpected call\n");
698     return E_NOTIMPL;
699 }
700 
701 static HRESULT WINAPI htmldoc2_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
702 {
703     ok(0, "unexpected call\n");
704     return E_NOTIMPL;
705 }
706 
707 static HRESULT WINAPI htmldoc2_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
708 {
709     ok(0, "unexpected call\n");
710     return E_NOTIMPL;
711 }
712 
713 static HRESULT WINAPI htmldoc2_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
714 {
715     ok(0, "unexpected call\n");
716     return E_NOTIMPL;
717 }
718 
719 static HRESULT WINAPI htmldoc2_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
720 {
721     ok(0, "unexpected call\n");
722     return E_NOTIMPL;
723 }
724 
725 static HRESULT WINAPI htmldoc2_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
726 {
727     ok(0, "unexpected call\n");
728     return E_NOTIMPL;
729 }
730 
731 static HRESULT WINAPI htmldoc2_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
732 {
733     ok(0, "unexpected call\n");
734     return E_NOTIMPL;
735 }
736 
737 static HRESULT WINAPI htmldoc2_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
738 {
739     ok(0, "unexpected call\n");
740     return E_NOTIMPL;
741 }
742 
743 static HRESULT WINAPI htmldoc2_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
744 {
745     ok(0, "unexpected call\n");
746     return E_NOTIMPL;
747 }
748 
749 static HRESULT WINAPI htmldoc2_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
750 {
751     ok(0, "unexpected call\n");
752     return E_NOTIMPL;
753 }
754 
755 static HRESULT WINAPI htmldoc2_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
756 {
757     ok(0, "unexpected call\n");
758     return E_NOTIMPL;
759 }
760 
761 static HRESULT WINAPI htmldoc2_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
762 {
763     ok(0, "unexpected call\n");
764     return E_NOTIMPL;
765 }
766 
767 static HRESULT WINAPI htmldoc2_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
768 {
769     ok(0, "unexpected call\n");
770     return E_NOTIMPL;
771 }
772 
773 static HRESULT WINAPI htmldoc2_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
774 {
775     ok(0, "unexpected call\n");
776     return E_NOTIMPL;
777 }
778 
779 static HRESULT WINAPI htmldoc2_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
780 {
781     ok(0, "unexpected call\n");
782     return E_NOTIMPL;
783 }
784 
785 static HRESULT WINAPI htmldoc2_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
786 {
787     ok(0, "unexpected call\n");
788     return E_NOTIMPL;
789 }
790 
791 static HRESULT WINAPI htmldoc2_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
792 {
793     ok(0, "unexpected call\n");
794     return E_NOTIMPL;
795 }
796 
797 static HRESULT WINAPI htmldoc2_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
798 {
799     ok(0, "unexpected call\n");
800     return E_NOTIMPL;
801 }
802 
803 static HRESULT WINAPI htmldoc2_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
804 {
805     ok(0, "unexpected call\n");
806     return E_NOTIMPL;
807 }
808 
809 static HRESULT WINAPI htmldoc2_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
810 {
811     ok(0, "unexpected call\n");
812     return E_NOTIMPL;
813 }
814 
815 static HRESULT WINAPI htmldoc2_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
816 {
817     ok(0, "unexpected call\n");
818     return E_NOTIMPL;
819 }
820 
821 static HRESULT WINAPI htmldoc2_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
822 {
823     ok(0, "unexpected call\n");
824     return E_NOTIMPL;
825 }
826 
827 static HRESULT WINAPI htmldoc2_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
828 {
829     ok(0, "unexpected call\n");
830     return E_NOTIMPL;
831 }
832 
833 static HRESULT WINAPI htmldoc2_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
834 {
835     ok(0, "unexpected call\n");
836     return E_NOTIMPL;
837 }
838 
839 static HRESULT WINAPI htmldoc2_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
840 {
841     ok(0, "unexpected call\n");
842     return E_NOTIMPL;
843 }
844 
845 static HRESULT WINAPI htmldoc2_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
846 {
847     ok(0, "unexpected call\n");
848     return E_NOTIMPL;
849 }
850 
851 static HRESULT WINAPI htmldoc2_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
852 {
853     ok(0, "unexpected call\n");
854     return E_NOTIMPL;
855 }
856 
857 static HRESULT WINAPI htmldoc2_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
858 {
859     ok(0, "unexpected call\n");
860     return E_NOTIMPL;
861 }
862 
863 static HRESULT WINAPI htmldoc2_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
864 {
865     ok(0, "unexpected call\n");
866     return E_NOTIMPL;
867 }
868 
869 static HRESULT WINAPI htmldoc2_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
870 {
871     ok(0, "unexpected call\n");
872     return E_NOTIMPL;
873 }
874 
875 static HRESULT WINAPI htmldoc2_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
876 {
877     ok(0, "unexpected call\n");
878     return E_NOTIMPL;
879 }
880 
881 static HRESULT WINAPI htmldoc2_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
882                                                         IHTMLElement **elementHit)
883 {
884     ok(0, "unexpected call\n");
885     return E_NOTIMPL;
886 }
887 
888 static HRESULT WINAPI htmldoc2_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
889 {
890     ok(0, "unexpected call\n");
891     return E_NOTIMPL;
892 }
893 
894 static HRESULT WINAPI htmldoc2_get_styleSheets(IHTMLDocument2 *iface,
895                                                    IHTMLStyleSheetsCollection **p)
896 {
897     ok(0, "unexpected call\n");
898     return E_NOTIMPL;
899 }
900 
901 static HRESULT WINAPI htmldoc2_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
902 {
903     ok(0, "unexpected call\n");
904     return E_NOTIMPL;
905 }
906 
907 static HRESULT WINAPI htmldoc2_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
908 {
909     ok(0, "unexpected call\n");
910     return E_NOTIMPL;
911 }
912 
913 static HRESULT WINAPI htmldoc2_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
914 {
915     ok(0, "unexpected call\n");
916     return E_NOTIMPL;
917 }
918 
919 static HRESULT WINAPI htmldoc2_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
920 {
921     ok(0, "unexpected call\n");
922     return E_NOTIMPL;
923 }
924 
925 static HRESULT WINAPI htmldoc2_toString(IHTMLDocument2 *iface, BSTR *String)
926 {
927     ok(0, "unexpected call\n");
928     return E_NOTIMPL;
929 }
930 
931 static HRESULT WINAPI htmldoc2_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
932                                             LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
933 {
934     ok(0, "unexpected call\n");
935     return E_NOTIMPL;
936 }
937 
938 static const IHTMLDocument2Vtbl TestHTMLDocumentVtbl = {
939     htmldoc2_QueryInterface,
940     htmldoc2_AddRef,
941     htmldoc2_Release,
942     htmldoc2_GetTypeInfoCount,
943     htmldoc2_GetTypeInfo,
944     htmldoc2_GetIDsOfNames,
945     htmldoc2_Invoke,
946     htmldoc2_get_Script,
947     htmldoc2_get_all,
948     htmldoc2_get_body,
949     htmldoc2_get_activeElement,
950     htmldoc2_get_images,
951     htmldoc2_get_applets,
952     htmldoc2_get_links,
953     htmldoc2_get_forms,
954     htmldoc2_get_anchors,
955     htmldoc2_put_title,
956     htmldoc2_get_title,
957     htmldoc2_get_scripts,
958     htmldoc2_put_designMode,
959     htmldoc2_get_designMode,
960     htmldoc2_get_selection,
961     htmldoc2_get_readyState,
962     htmldoc2_get_frames,
963     htmldoc2_get_embeds,
964     htmldoc2_get_plugins,
965     htmldoc2_put_alinkColor,
966     htmldoc2_get_alinkColor,
967     htmldoc2_put_bgColor,
968     htmldoc2_get_bgColor,
969     htmldoc2_put_fgColor,
970     htmldoc2_get_fgColor,
971     htmldoc2_put_linkColor,
972     htmldoc2_get_linkColor,
973     htmldoc2_put_vlinkColor,
974     htmldoc2_get_vlinkColor,
975     htmldoc2_get_referrer,
976     htmldoc2_get_location,
977     htmldoc2_get_lastModified,
978     htmldoc2_put_URL,
979     htmldoc2_get_URL,
980     htmldoc2_put_domain,
981     htmldoc2_get_domain,
982     htmldoc2_put_cookie,
983     htmldoc2_get_cookie,
984     htmldoc2_put_expando,
985     htmldoc2_get_expando,
986     htmldoc2_put_charset,
987     htmldoc2_get_charset,
988     htmldoc2_put_defaultCharset,
989     htmldoc2_get_defaultCharset,
990     htmldoc2_get_mimeType,
991     htmldoc2_get_fileSize,
992     htmldoc2_get_fileCreatedDate,
993     htmldoc2_get_fileModifiedDate,
994     htmldoc2_get_fileUpdatedDate,
995     htmldoc2_get_security,
996     htmldoc2_get_protocol,
997     htmldoc2_get_nameProp,
998     htmldoc2_write,
999     htmldoc2_writeln,
1000     htmldoc2_open,
1001     htmldoc2_close,
1002     htmldoc2_clear,
1003     htmldoc2_queryCommandSupported,
1004     htmldoc2_queryCommandEnabled,
1005     htmldoc2_queryCommandState,
1006     htmldoc2_queryCommandIndeterm,
1007     htmldoc2_queryCommandText,
1008     htmldoc2_queryCommandValue,
1009     htmldoc2_execCommand,
1010     htmldoc2_execCommandShowHelp,
1011     htmldoc2_createElement,
1012     htmldoc2_put_onhelp,
1013     htmldoc2_get_onhelp,
1014     htmldoc2_put_onclick,
1015     htmldoc2_get_onclick,
1016     htmldoc2_put_ondblclick,
1017     htmldoc2_get_ondblclick,
1018     htmldoc2_put_onkeyup,
1019     htmldoc2_get_onkeyup,
1020     htmldoc2_put_onkeydown,
1021     htmldoc2_get_onkeydown,
1022     htmldoc2_put_onkeypress,
1023     htmldoc2_get_onkeypress,
1024     htmldoc2_put_onmouseup,
1025     htmldoc2_get_onmouseup,
1026     htmldoc2_put_onmousedown,
1027     htmldoc2_get_onmousedown,
1028     htmldoc2_put_onmousemove,
1029     htmldoc2_get_onmousemove,
1030     htmldoc2_put_onmouseout,
1031     htmldoc2_get_onmouseout,
1032     htmldoc2_put_onmouseover,
1033     htmldoc2_get_onmouseover,
1034     htmldoc2_put_onreadystatechange,
1035     htmldoc2_get_onreadystatechange,
1036     htmldoc2_put_onafterupdate,
1037     htmldoc2_get_onafterupdate,
1038     htmldoc2_put_onrowexit,
1039     htmldoc2_get_onrowexit,
1040     htmldoc2_put_onrowenter,
1041     htmldoc2_get_onrowenter,
1042     htmldoc2_put_ondragstart,
1043     htmldoc2_get_ondragstart,
1044     htmldoc2_put_onselectstart,
1045     htmldoc2_get_onselectstart,
1046     htmldoc2_elementFromPoint,
1047     htmldoc2_get_parentWindow,
1048     htmldoc2_get_styleSheets,
1049     htmldoc2_put_onbeforeupdate,
1050     htmldoc2_get_onbeforeupdate,
1051     htmldoc2_put_onerrorupdate,
1052     htmldoc2_get_onerrorupdate,
1053     htmldoc2_toString,
1054     htmldoc2_createStyleSheet
1055 };
1056 
1057 static IHTMLDocument2 htmldoc2 = { &TestHTMLDocumentVtbl };
1058 
1059 static HRESULT WINAPI sp_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppvObject)
1060 {
1061     *ppvObject = NULL;
1062 
1063     if (IsEqualGUID(riid, &IID_IUnknown) ||
1064         IsEqualGUID(riid, &IID_IServiceProvider))
1065     {
1066         *ppvObject = iface;
1067         IServiceProvider_AddRef(iface);
1068         return S_OK;
1069     }
1070 
1071     ok(0, "unexpected query interface: %s\n", wine_dbgstr_guid(riid));
1072 
1073     return E_NOINTERFACE;
1074 }
1075 
1076 static ULONG WINAPI sp_AddRef(IServiceProvider *iface)
1077 {
1078     return 2;
1079 }
1080 
1081 static ULONG WINAPI sp_Release(IServiceProvider *iface)
1082 {
1083     return 1;
1084 }
1085 
1086 static HRESULT WINAPI sp_QueryService(IServiceProvider *iface, REFGUID service, REFIID riid, void **obj)
1087 {
1088     *obj = NULL;
1089 
1090     if (IsEqualGUID(service, &SID_SBindHost) &&
1091         IsEqualGUID(riid, &IID_IBindHost))
1092     {
1093         CHECK_EXPECT2(sp_queryservice_SID_SBindHost);
1094     }
1095     else if (IsEqualGUID(service, &SID_SContainerDispatch) &&
1096              IsEqualGUID(riid, &IID_IHTMLDocument2))
1097     {
1098         CHECK_EXPECT2(sp_queryservice_SID_SContainerDispatch_htmldoc2);
1099     }
1100     else if (IsEqualGUID(service, &SID_SInternetHostSecurityManager) &&
1101              IsEqualGUID(riid, &IID_IHTMLDocument2))
1102     {
1103         CHECK_EXPECT2(sp_queryservice_SID_secmgr_htmldoc2);
1104         *obj = &htmldoc2;
1105         return S_OK;
1106     }
1107     else if (IsEqualGUID(service, &SID_SInternetHostSecurityManager) &&
1108              IsEqualGUID(riid, &IID_IXMLDOMDocument))
1109     {
1110         CHECK_EXPECT2(sp_queryservice_SID_secmgr_xmldomdoc);
1111     }
1112     else if (IsEqualGUID(service, &SID_SInternetHostSecurityManager) &&
1113              IsEqualGUID(riid, &IID_IInternetHostSecurityManager))
1114     {
1115         CHECK_EXPECT2(sp_queryservice_SID_secmgr_secmgr);
1116     }
1117     else if (IsEqualGUID(service, &SID_UnknownSID) &&
1118              IsEqualGUID(riid, &IID_IStream))
1119     {
1120         /* FIXME: unidentified service id */
1121     }
1122     else if ((IsEqualGUID(service, &IID_IInternetProtocol) && IsEqualGUID(riid, &IID_IInternetProtocol)) ||
1123              (IsEqualGUID(service, &IID_IHttpNegotiate2) && IsEqualGUID(riid, &IID_IHttpNegotiate2)) ||
1124              (IsEqualGUID(service, &IID_IGetBindHandle) && IsEqualGUID(riid, &IID_IGetBindHandle)) ||
1125              (IsEqualGUID(service, &IID_IBindStatusCallback) && IsEqualGUID(riid, &IID_IBindStatusCallback)) ||
1126              (IsEqualGUID(service, &IID_IWindowForBindingUI) && IsEqualGUID(riid, &IID_IWindowForBindingUI)))
1127     {
1128     }
1129     else
1130         ok(0, "unexpected request: sid %s, riid %s\n", wine_dbgstr_guid(service), wine_dbgstr_guid(riid));
1131 
1132     return E_NOTIMPL;
1133 }
1134 
1135 static const IServiceProviderVtbl testprovVtbl =
1136 {
1137     sp_QueryInterface,
1138     sp_AddRef,
1139     sp_Release,
1140     sp_QueryService
1141 };
1142 
1143 static IServiceProvider testprov = { &testprovVtbl };
1144 
1145 static HRESULT WINAPI site_QueryInterface(IUnknown *iface, REFIID riid, void **ppvObject)
1146 {
1147     *ppvObject = NULL;
1148 
1149     if (IsEqualGUID(riid, &IID_IServiceProvider))
1150         CHECK_EXPECT2(site_qi_IServiceProvider);
1151 
1152     if (IsEqualGUID(riid, &IID_IXMLDOMDocument))
1153         CHECK_EXPECT2(site_qi_IXMLDOMDocument);
1154 
1155     if (IsEqualGUID(riid, &IID_IOleClientSite))
1156         CHECK_EXPECT2(site_qi_IOleClientSite);
1157 
1158     if (IsEqualGUID(riid, &IID_IUnknown))
1159          *ppvObject = iface;
1160     else if (IsEqualGUID(riid, &IID_IServiceProvider))
1161          *ppvObject = &testprov;
1162 
1163     if (*ppvObject) IUnknown_AddRef(iface);
1164 
1165     return *ppvObject ? S_OK : E_NOINTERFACE;
1166 }
1167 
1168 static ULONG WINAPI site_AddRef(IUnknown *iface)
1169 {
1170     return 2;
1171 }
1172 
1173 static ULONG WINAPI site_Release(IUnknown *iface)
1174 {
1175     return 1;
1176 }
1177 
1178 static const IUnknownVtbl testsiteVtbl =
1179 {
1180     site_QueryInterface,
1181     site_AddRef,
1182     site_Release
1183 };
1184 
1185 static IUnknown testsite = { &testsiteVtbl };
1186 
1187 typedef struct
1188 {
1189     IDispatch IDispatch_iface;
1190     LONG ref;
1191 } dispevent;
1192 
1193 static IXMLHttpRequest *httpreq;
1194 
1195 static inline dispevent *impl_from_IDispatch( IDispatch *iface )
1196 {
1197     return CONTAINING_RECORD(iface, dispevent, IDispatch_iface);
1198 }
1199 
1200 static HRESULT WINAPI dispevent_QueryInterface(IDispatch *iface, REFIID riid, void **ppvObject)
1201 {
1202     *ppvObject = NULL;
1203 
1204     if ( IsEqualGUID( riid, &IID_IDispatch) ||
1205          IsEqualGUID( riid, &IID_IUnknown) )
1206     {
1207         *ppvObject = iface;
1208     }
1209     else
1210         return E_NOINTERFACE;
1211 
1212     IDispatch_AddRef( iface );
1213 
1214     return S_OK;
1215 }
1216 
1217 static ULONG WINAPI dispevent_AddRef(IDispatch *iface)
1218 {
1219     dispevent *This = impl_from_IDispatch( iface );
1220     return InterlockedIncrement( &This->ref );
1221 }
1222 
1223 static ULONG WINAPI dispevent_Release(IDispatch *iface)
1224 {
1225     dispevent *This = impl_from_IDispatch( iface );
1226     ULONG ref = InterlockedDecrement( &This->ref );
1227 
1228     if (ref == 0)
1229         HeapFree(GetProcessHeap(), 0, This);
1230 
1231     return ref;
1232 }
1233 
1234 static HRESULT WINAPI dispevent_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
1235 {
1236     g_unexpectedcall++;
1237     *pctinfo = 0;
1238     return S_OK;
1239 }
1240 
1241 static HRESULT WINAPI dispevent_GetTypeInfo(IDispatch *iface, UINT iTInfo,
1242         LCID lcid, ITypeInfo **ppTInfo)
1243 {
1244     g_unexpectedcall++;
1245     return S_OK;
1246 }
1247 
1248 static HRESULT WINAPI dispevent_GetIDsOfNames(IDispatch *iface, REFIID riid,
1249         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1250 {
1251     g_unexpectedcall++;
1252     return S_OK;
1253 }
1254 
1255 static HRESULT WINAPI dispevent_Invoke(IDispatch *iface, DISPID member, REFIID riid,
1256         LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result,
1257         EXCEPINFO *excepInfo, UINT *argErr)
1258 {
1259     LONG state;
1260     HRESULT hr;
1261 
1262     ok(member == 0, "expected 0 member, got %d\n", member);
1263     ok(lcid == LOCALE_SYSTEM_DEFAULT, "expected LOCALE_SYSTEM_DEFAULT, got lcid %x\n", lcid);
1264     ok(flags == DISPATCH_METHOD, "expected DISPATCH_METHOD, got %d\n", flags);
1265 
1266     ok(params->cArgs == 0, "got %d\n", params->cArgs);
1267     ok(params->cNamedArgs == 0, "got %d\n", params->cNamedArgs);
1268     ok(params->rgvarg == NULL, "got %p\n", params->rgvarg);
1269     ok(params->rgdispidNamedArgs == NULL, "got %p\n", params->rgdispidNamedArgs);
1270 
1271     ok(result == NULL, "got %p\n", result);
1272     ok(excepInfo == NULL, "got %p\n", excepInfo);
1273     ok(argErr == NULL, "got %p\n", argErr);
1274 
1275     g_expectedcall++;
1276 
1277     state = READYSTATE_UNINITIALIZED;
1278     hr = IXMLHttpRequest_get_readyState(httpreq, &state);
1279     ok(hr == S_OK, "got 0x%08x\n", hr);
1280     if (state == READYSTATE_COMPLETE)
1281     {
1282         BSTR text = NULL;
1283 
1284         hr = IXMLHttpRequest_get_responseText(httpreq, &text);
1285         ok(hr == S_OK, "got 0x%08x\n", hr);
1286         ok(*text != 0, "got %s\n", wine_dbgstr_w(text));
1287         SysFreeString(text);
1288     }
1289 
1290     return E_FAIL;
1291 }
1292 
1293 static const IDispatchVtbl dispeventVtbl =
1294 {
1295     dispevent_QueryInterface,
1296     dispevent_AddRef,
1297     dispevent_Release,
1298     dispevent_GetTypeInfoCount,
1299     dispevent_GetTypeInfo,
1300     dispevent_GetIDsOfNames,
1301     dispevent_Invoke
1302 };
1303 
1304 static IDispatch* create_dispevent(void)
1305 {
1306     dispevent *event = HeapAlloc(GetProcessHeap(), 0, sizeof(*event));
1307 
1308     event->IDispatch_iface.lpVtbl = &dispeventVtbl;
1309     event->ref = 1;
1310 
1311     return &event->IDispatch_iface;
1312 }
1313 
1314 static IXMLHttpRequest *create_xhr(void)
1315 {
1316     IXMLHttpRequest *ret;
1317     HRESULT hr;
1318 
1319     hr = CoCreateInstance(&CLSID_XMLHTTPRequest, NULL, CLSCTX_INPROC_SERVER,
1320         &IID_IXMLHttpRequest, (void**)&ret);
1321 
1322     return SUCCEEDED(hr) ? ret : NULL;
1323 }
1324 
1325 static void set_safety_opt(IUnknown *unk, DWORD mask, DWORD opts)
1326 {
1327     IObjectSafety *obj_safety;
1328     HRESULT hr;
1329 
1330     hr = IUnknown_QueryInterface(unk, &IID_IObjectSafety, (void**)&obj_safety);
1331     ok(hr == S_OK, "Could not get IObjectSafety iface: %08x\n", hr);
1332 
1333     hr = IObjectSafety_SetInterfaceSafetyOptions(obj_safety, &IID_IDispatch, mask, mask&opts);
1334     ok(hr == S_OK, "SetInterfaceSafetyOptions failed: %08x\n", hr);
1335 
1336     IObjectSafety_Release(obj_safety);
1337 }
1338 
1339 static void set_xhr_site(IXMLHttpRequest *xhr)
1340 {
1341     IObjectWithSite *obj_site;
1342     HRESULT hr;
1343 
1344     hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site);
1345     ok(hr == S_OK, "Could not get IObjectWithSite iface: %08x\n", hr);
1346 
1347     g_enablecallchecks = TRUE;
1348 
1349     SET_EXPECT(site_qi_IServiceProvider);
1350     SET_EXPECT(sp_queryservice_SID_SBindHost);
1351     SET_EXPECT(sp_queryservice_SID_SContainerDispatch_htmldoc2);
1352     SET_EXPECT(sp_queryservice_SID_secmgr_htmldoc2);
1353     SET_EXPECT(sp_queryservice_SID_secmgr_xmldomdoc);
1354     SET_EXPECT(sp_queryservice_SID_secmgr_secmgr);
1355 
1356     /* calls to IHTMLDocument2 */
1357     SET_EXPECT(htmldoc2_get_all);
1358     SET_EXPECT(collection_get_length);
1359     SET_EXPECT(htmldoc2_get_url);
1360 
1361     SET_EXPECT(site_qi_IXMLDOMDocument);
1362     SET_EXPECT(site_qi_IOleClientSite);
1363 
1364     hr = IObjectWithSite_SetSite(obj_site, &testsite);
1365     EXPECT_HR(hr, S_OK);
1366 
1367     CHECK_CALLED(site_qi_IServiceProvider);
1368 todo_wine
1369     CHECK_CALLED(sp_queryservice_SID_SBindHost);
1370     CHECK_CALLED(sp_queryservice_SID_SContainerDispatch_htmldoc2);
1371     CHECK_CALLED(sp_queryservice_SID_secmgr_htmldoc2);
1372 todo_wine
1373     CHECK_CALLED(sp_queryservice_SID_secmgr_xmldomdoc);
1374     /* this one isn't very reliable
1375     CHECK_CALLED(sp_queryservice_SID_secmgr_secmgr); */
1376 todo_wine {
1377     CHECK_CALLED(htmldoc2_get_all);
1378     CHECK_CALLED(collection_get_length);
1379 }
1380     CHECK_CALLED(htmldoc2_get_url);
1381 
1382 todo_wine {
1383     CHECK_CALLED(site_qi_IXMLDOMDocument);
1384     CHECK_CALLED(site_qi_IOleClientSite);
1385 }
1386 
1387     g_enablecallchecks = FALSE;
1388 
1389     IObjectWithSite_Release(obj_site);
1390 }
1391 
1392 #define test_open(a,b,c,d) _test_open(__LINE__,a,b,c,d)
1393 static void _test_open(unsigned line, IXMLHttpRequest *xhr, const char *method, const char *url, HRESULT exhres)
1394 {
1395     VARIANT empty, vfalse;
1396     HRESULT hr;
1397 
1398     V_VT(&empty) = VT_EMPTY;
1399     V_VT(&vfalse) = VT_BOOL;
1400     V_BOOL(&vfalse) = VARIANT_FALSE;
1401 
1402     hr = IXMLHttpRequest_open(xhr, _bstr_(method), _bstr_(url), vfalse, empty, empty);
1403     ok_(__FILE__,line)(hr == exhres, "open(%s %s) failed: %08x, expected %08x\n", method, url, hr, exhres);
1404 }
1405 
1406 static void test_XMLHTTP(void)
1407 {
1408     static const char bodyA[] = "mode=Test";
1409     static const char urlA[] = "http://test.winehq.org/tests/post.php";
1410     static const char xmltestA[] = "http://test.winehq.org/tests/xmltest.xml";
1411     static const char referertesturl[] = "http://test.winehq.org/tests/referer.php";
1412     static const WCHAR wszExpectedResponse[] = {'F','A','I','L','E','D',0};
1413     static const CHAR xmltestbodyA[] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<a>TEST</a>\n";
1414     static const WCHAR norefererW[] = {'n','o',' ','r','e','f','e','r','e','r',' ','s','e','t',0};
1415 
1416     IXMLHttpRequest *xhr;
1417     IObjectWithSite *obj_site, *obj_site2;
1418     BSTR bstrResponse, str, str1;
1419     VARIANT varbody;
1420     VARIANT dummy;
1421     LONG state, status, bound;
1422     IDispatch *event;
1423     void *ptr;
1424     HRESULT hr;
1425     HGLOBAL g;
1426 
1427     xhr = create_xhr();
1428 
1429     VariantInit(&dummy);
1430     V_VT(&dummy) = VT_ERROR;
1431     V_ERROR(&dummy) = DISP_E_MEMBERNOTFOUND;
1432 
1433     hr = IXMLHttpRequest_put_onreadystatechange(xhr, NULL);
1434     EXPECT_HR(hr, S_OK);
1435 
1436     hr = IXMLHttpRequest_abort(xhr);
1437     EXPECT_HR(hr, S_OK);
1438 
1439     V_VT(&varbody) = VT_I2;
1440     V_I2(&varbody) = 1;
1441     hr = IXMLHttpRequest_get_responseBody(xhr, &varbody);
1442     EXPECT_HR(hr, E_PENDING);
1443     ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody));
1444 
1445     V_VT(&varbody) = VT_I2;
1446     V_I2(&varbody) = 1;
1447     hr = IXMLHttpRequest_get_responseStream(xhr, &varbody);
1448     EXPECT_HR(hr, E_PENDING);
1449     ok(V_VT(&varbody) == VT_EMPTY, "got type %d\n", V_VT(&varbody));
1450 
1451     /* send before open */
1452     hr = IXMLHttpRequest_send(xhr, dummy);
1453     ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
1454 
1455     /* initial status code */
1456     hr = IXMLHttpRequest_get_status(xhr, NULL);
1457     ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr);
1458 
1459     status = 0xdeadbeef;
1460     hr = IXMLHttpRequest_get_status(xhr, &status);
1461     ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
1462     ok(status == READYSTATE_UNINITIALIZED || broken(status == 0xdeadbeef) /* <win8 */, "got %d\n", status);
1463 
1464     hr = IXMLHttpRequest_get_statusText(xhr, &str);
1465     ok(hr == E_FAIL, "got 0x%08x\n", hr);
1466 
1467     /* invalid parameters */
1468     test_open(xhr, NULL, NULL, E_INVALIDARG);
1469     test_open(xhr, "POST", NULL, E_INVALIDARG);
1470     test_open(xhr, NULL, urlA, E_INVALIDARG);
1471 
1472     hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, NULL);
1473     EXPECT_HR(hr, E_INVALIDARG);
1474 
1475     hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), NULL);
1476     ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
1477 
1478     hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, _bstr_("value1"));
1479     EXPECT_HR(hr, E_INVALIDARG);
1480 
1481     hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), _bstr_("value1"));
1482     ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
1483 
1484     hr = IXMLHttpRequest_get_readyState(xhr, NULL);
1485     ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr);
1486 
1487     state = -1;
1488     hr = IXMLHttpRequest_get_readyState(xhr, &state);
1489     EXPECT_HR(hr, S_OK);
1490     ok(state == READYSTATE_UNINITIALIZED, "got %d, expected READYSTATE_UNINITIALIZED\n", state);
1491 
1492     httpreq = xhr;
1493     event = create_dispevent();
1494 
1495     EXPECT_REF(event, 1);
1496     hr = IXMLHttpRequest_put_onreadystatechange(xhr, event);
1497     EXPECT_HR(hr, S_OK);
1498     EXPECT_REF(event, 2);
1499 
1500     g_unexpectedcall = g_expectedcall = 0;
1501 
1502     test_open(xhr, "POST", urlA, S_OK);
1503 
1504     ok(g_unexpectedcall == 0, "unexpected disp event call\n");
1505     ok(g_expectedcall == 1 || broken(g_expectedcall == 0) /* win2k */, "no expected disp event call\n");
1506 
1507     /* status code after ::open() */
1508     status = 0xdeadbeef;
1509     hr = IXMLHttpRequest_get_status(xhr, &status);
1510     ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
1511     ok(status == READYSTATE_UNINITIALIZED || broken(status == 0xdeadbeef) /* <win8 */, "got %d\n", status);
1512 
1513     state = -1;
1514     hr = IXMLHttpRequest_get_readyState(xhr, &state);
1515     EXPECT_HR(hr, S_OK);
1516     ok(state == READYSTATE_LOADING, "got %d, expected READYSTATE_LOADING\n", state);
1517 
1518     hr = IXMLHttpRequest_abort(xhr);
1519     EXPECT_HR(hr, S_OK);
1520 
1521     state = -1;
1522     hr = IXMLHttpRequest_get_readyState(xhr, &state);
1523     EXPECT_HR(hr, S_OK);
1524     ok(state == READYSTATE_UNINITIALIZED || broken(state == READYSTATE_LOADING) /* win2k */,
1525         "got %d, expected READYSTATE_UNINITIALIZED\n", state);
1526 
1527     test_open(xhr, "POST", urlA, S_OK);
1528 
1529     hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_("header1"), _bstr_("value1"));
1530     EXPECT_HR(hr, S_OK);
1531 
1532     hr = IXMLHttpRequest_setRequestHeader(xhr, NULL, _bstr_("value1"));
1533     EXPECT_HR(hr, E_INVALIDARG);
1534 
1535     hr = IXMLHttpRequest_setRequestHeader(xhr, _bstr_(""), _bstr_("value1"));
1536     EXPECT_HR(hr, E_INVALIDARG);
1537 
1538     V_VT(&varbody) = VT_BSTR;
1539     V_BSTR(&varbody) = _bstr_(bodyA);
1540 
1541     hr = IXMLHttpRequest_send(xhr, varbody);
1542     if (hr == INET_E_RESOURCE_NOT_FOUND)
1543     {
1544         skip("No connection could be made with test.winehq.org\n");
1545         IXMLHttpRequest_Release(xhr);
1546         return;
1547     }
1548     EXPECT_HR(hr, S_OK);
1549 
1550     /* response headers */
1551     hr = IXMLHttpRequest_getAllResponseHeaders(xhr, NULL);
1552     ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr);
1553     hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str);
1554     EXPECT_HR(hr, S_OK);
1555     /* status line is stripped already */
1556     ok(memcmp(str, _bstr_("HTTP"), 4*sizeof(WCHAR)), "got response headers %s\n", wine_dbgstr_w(str));
1557     ok(*str, "got empty headers\n");
1558     hr = IXMLHttpRequest_getAllResponseHeaders(xhr, &str1);
1559     EXPECT_HR(hr, S_OK);
1560     ok(str1 != str, "got %p\n", str1);
1561     SysFreeString(str1);
1562     SysFreeString(str);
1563 
1564     hr = IXMLHttpRequest_getResponseHeader(xhr, NULL, NULL);
1565     EXPECT_HR(hr, E_INVALIDARG);
1566     hr = IXMLHttpRequest_getResponseHeader(xhr, _bstr_("Date"), NULL);
1567     ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr);
1568     hr = IXMLHttpRequest_getResponseHeader(xhr, _bstr_("Date"), &str);
1569     EXPECT_HR(hr, S_OK);
1570     ok(*str != ' ', "got leading space in header %s\n", wine_dbgstr_w(str));
1571     SysFreeString(str);
1572 
1573     /* status code after ::send() */
1574     status = 0xdeadbeef;
1575     hr = IXMLHttpRequest_get_status(xhr, &status);
1576     EXPECT_HR(hr, S_OK);
1577     ok(status == 200, "got %d\n", status);
1578 
1579     hr = IXMLHttpRequest_get_statusText(xhr, NULL);
1580     ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr);
1581 
1582     hr = IXMLHttpRequest_get_statusText(xhr, &str);
1583     EXPECT_HR(hr, S_OK);
1584     ok(!lstrcmpW(str, _bstr_("OK")), "got status %s\n", wine_dbgstr_w(str));
1585     SysFreeString(str);
1586 
1587     /* another ::send() after completed request */
1588     V_VT(&varbody) = VT_BSTR;
1589     V_BSTR(&varbody) = _bstr_(bodyA);
1590 
1591     hr = IXMLHttpRequest_send(xhr, varbody);
1592     ok(hr == E_FAIL || broken(hr == E_UNEXPECTED) /* win2k */, "got 0x%08x\n", hr);
1593 
1594     hr = IXMLHttpRequest_get_responseText(xhr, &bstrResponse);
1595     EXPECT_HR(hr, S_OK);
1596     /* the server currently returns "FAILED" because the Content-Type header is
1597      * not what the server expects */
1598     if(hr == S_OK)
1599     {
1600         ok(!memcmp(bstrResponse, wszExpectedResponse, sizeof(wszExpectedResponse)),
1601             "expected %s, got %s\n", wine_dbgstr_w(wszExpectedResponse), wine_dbgstr_w(bstrResponse));
1602         SysFreeString(bstrResponse);
1603     }
1604 
1605     /* POST: VT_VARIANT body */
1606     /* VT_VARIANT|VT_BYREF fails on Windows 10 */
1607     test_open(xhr, "POST", urlA, S_OK);
1608 
1609     hr = IXMLHttpRequest_send(xhr, varbody);
1610     EXPECT_HR(hr, S_OK);
1611 
1612     /* GET request */
1613     test_open(xhr, "GET", xmltestA, S_OK);
1614 
1615     V_VT(&varbody) = VT_EMPTY;
1616 
1617     hr = IXMLHttpRequest_send(xhr, varbody);
1618     if (hr == INET_E_RESOURCE_NOT_FOUND)
1619     {
1620         skip("No connection could be made with test.winehq.org\n");
1621         IXMLHttpRequest_Release(xhr);
1622         return;
1623     }
1624     EXPECT_HR(hr, S_OK);
1625 
1626     hr = IXMLHttpRequest_get_responseText(xhr, NULL);
1627     ok(hr == E_POINTER || broken(hr == E_INVALIDARG) /* <win8 */, "got 0x%08x\n", hr);
1628 
1629     hr = IXMLHttpRequest_get_responseText(xhr, &bstrResponse);
1630     EXPECT_HR(hr, S_OK);
1631     ok(!memcmp(bstrResponse, _bstr_(xmltestbodyA), sizeof(xmltestbodyA)*sizeof(WCHAR)),
1632         "expected %s, got %s\n", xmltestbodyA, wine_dbgstr_w(bstrResponse));
1633     SysFreeString(bstrResponse);
1634 
1635     hr = IXMLHttpRequest_get_responseBody(xhr, NULL);
1636     EXPECT_HR(hr, E_INVALIDARG);
1637 
1638     V_VT(&varbody) = VT_EMPTY;
1639     hr = IXMLHttpRequest_get_responseBody(xhr, &varbody);
1640     EXPECT_HR(hr, S_OK);
1641     ok(V_VT(&varbody) == (VT_ARRAY|VT_UI1), "got type %d, expected %d\n", V_VT(&varbody), VT_ARRAY|VT_UI1);
1642     ok(SafeArrayGetDim(V_ARRAY(&varbody)) == 1, "got %d, expected one dimension\n", SafeArrayGetDim(V_ARRAY(&varbody)));
1643 
1644     bound = -1;
1645     hr = SafeArrayGetLBound(V_ARRAY(&varbody), 1, &bound);
1646     EXPECT_HR(hr, S_OK);
1647     ok(bound == 0, "got %d, expected zero bound\n", bound);
1648 
1649     hr = SafeArrayAccessData(V_ARRAY(&varbody), &ptr);
1650     EXPECT_HR(hr, S_OK);
1651     ok(memcmp(ptr, xmltestbodyA, sizeof(xmltestbodyA)-1) == 0, "got wrong body data\n");
1652     SafeArrayUnaccessData(V_ARRAY(&varbody));
1653 
1654     VariantClear(&varbody);
1655 
1656     /* get_responseStream */
1657     hr = IXMLHttpRequest_get_responseStream(xhr, NULL);
1658     EXPECT_HR(hr, E_INVALIDARG);
1659 
1660     V_VT(&varbody) = VT_EMPTY;
1661     hr = IXMLHttpRequest_get_responseStream(xhr, &varbody);
1662     ok(V_VT(&varbody) == VT_UNKNOWN, "got type %d\n", V_VT(&varbody));
1663     EXPECT_HR(hr, S_OK);
1664     EXPECT_REF(V_UNKNOWN(&varbody), 1);
1665 
1666     g = NULL;
1667     hr = GetHGlobalFromStream((IStream*)V_UNKNOWN(&varbody), &g);
1668     EXPECT_HR(hr, S_OK);
1669     ok(g != NULL, "got %p\n", g);
1670     VariantClear(&varbody);
1671 
1672     IDispatch_Release(event);
1673 
1674     /* test if referrer header is sent */
1675     test_open(xhr, "GET", referertesturl, S_OK);
1676 
1677     V_VT(&varbody) = VT_EMPTY;
1678     hr = IXMLHttpRequest_send(xhr, varbody);
1679     ok(hr == S_OK, "got 0x%08x\n", hr);
1680     hr = IXMLHttpRequest_get_responseText(xhr, &str);
1681     ok(hr == S_OK, "got 0x%08x\n", hr);
1682     ok(!lstrcmpW(str, norefererW), "got response text %s\n", wine_dbgstr_w(str));
1683     SysFreeString(str);
1684 
1685     /* interaction with object site */
1686     hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site);
1687     EXPECT_HR(hr, S_OK);
1688 
1689     hr = IObjectWithSite_SetSite(obj_site, NULL);
1690     ok(hr == S_OK, "got 0x%08x\n", hr);
1691 
1692     hr = IXMLHttpRequest_QueryInterface(xhr, &IID_IObjectWithSite, (void**)&obj_site2);
1693     EXPECT_HR(hr, S_OK);
1694     ok(obj_site == obj_site2 || broken(obj_site != obj_site2), "got new instance\n");
1695     IObjectWithSite_Release(obj_site2);
1696 
1697     set_xhr_site(xhr);
1698 
1699     test_open(xhr, "GET", "tests/referer.php", S_OK);
1700     str1 = a2bstr("http://test.winehq.org/");
1701 
1702     V_VT(&varbody) = VT_EMPTY;
1703     hr = IXMLHttpRequest_send(xhr, varbody);
1704     ok(hr == S_OK, "got 0x%08x\n", hr);
1705 
1706     hr = IXMLHttpRequest_get_responseText(xhr, &str);
1707     ok(hr == S_OK, "got 0x%08x\n", hr);
1708     ok(!lstrcmpW(str, str1), "got response text %s, expected %s\n", wine_dbgstr_w(str), wine_dbgstr_w(str1));
1709     SysFreeString(str);
1710     SysFreeString(str1);
1711 
1712     /* try to set site another time */
1713     hr = IObjectWithSite_SetSite(obj_site, &testsite);
1714     EXPECT_HR(hr, S_OK);
1715 
1716     IObjectWithSite_Release(obj_site);
1717     IXMLHttpRequest_Release(xhr);
1718     free_bstrs();
1719 }
1720 
1721 static void test_safe_httpreq(void)
1722 {
1723     IXMLHttpRequest *xhr;
1724 
1725     xhr = create_xhr();
1726 
1727     set_safety_opt((IUnknown*)xhr, INTERFACESAFE_FOR_UNTRUSTED_DATA, -1);
1728     set_xhr_site(xhr);
1729 
1730     /* different scheme */
1731     test_open(xhr, "GET", "https://test.winehq.org/tests/hello.html", E_ACCESSDENIED);
1732 
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);
1736 
1737     IXMLHttpRequest_Release(xhr);
1738     free_bstrs();
1739 }
1740 
1741 START_TEST(httpreq)
1742 {
1743     IXMLHttpRequest *xhr;
1744 
1745     CoInitialize(NULL);
1746 
1747     if((xhr = create_xhr())) {
1748         IXMLHttpRequest_Release(xhr);
1749 
1750         test_XMLHTTP();
1751         test_safe_httpreq();
1752     }else {
1753         win_skip("IXMLHTTPRequest is not available\n");
1754     }
1755 
1756     CoUninitialize();
1757 }
1758