53646d1ddbf626dce5e96c9672df1aacc51d65f1
[reactos.git] / rostests / winetests / urlmon / url.c
1 /*
2 * UrlMon URL tests
3 *
4 * Copyright 2004 Kevin Koltzau
5 * Copyright 2004-2007 Jacek Caban for CodeWeavers
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define CONST_VTABLE
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "initguid.h"
32 #include "urlmon.h"
33 #include "wininet.h"
34 #include "mshtml.h"
35
36 #include "wine/test.h"
37
38 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
39 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
40 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
41
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
44
45 #define SET_EXPECT(func) \
46 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
47
48 #define CHECK_EXPECT2(func) \
49 do { \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 called_ ## func = TRUE; \
52 }while(0)
53
54 #define CHECK_EXPECT(func) \
55 do { \
56 CHECK_EXPECT2(func); \
57 expect_ ## func = FALSE; \
58 }while(0)
59
60 #define CHECK_CALLED(func) \
61 do { \
62 ok(called_ ## func, "expected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
64 }while(0)
65
66 #define CHECK_NOT_CALLED(func) \
67 do { \
68 ok(!called_ ## func, "unexpected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
70 }while(0)
71
72 #define CHECK_CALLED_BROKEN(func) \
73 do { \
74 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
76 }while(0)
77
78 #define CLEAR_CALLED(func) \
79 expect_ ## func = called_ ## func = FALSE
80
81 DEFINE_EXPECT(QueryInterface_IServiceProvider);
82 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
83 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
84 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
85 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
86 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
87 DEFINE_EXPECT(QueryInterface_IAuthenticate);
88 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
89 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI);
90 DEFINE_EXPECT(QueryService_IAuthenticate);
91 DEFINE_EXPECT(QueryService_IInternetProtocol);
92 DEFINE_EXPECT(QueryService_IInternetBindInfo);
93 DEFINE_EXPECT(QueryService_IWindowForBindingUI);
94 DEFINE_EXPECT(BeginningTransaction);
95 DEFINE_EXPECT(OnResponse);
96 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
97 DEFINE_EXPECT(GetRootSecurityId);
98 DEFINE_EXPECT(GetBindInfo);
99 DEFINE_EXPECT(GetBindInfoEx);
100 DEFINE_EXPECT(OnStartBinding);
101 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
102 DEFINE_EXPECT(OnProgress_CONNECTING);
103 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
104 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
105 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
106 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
107 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
108 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
109 DEFINE_EXPECT(OnStopBinding);
110 DEFINE_EXPECT(OnDataAvailable);
111 DEFINE_EXPECT(OnObjectAvailable);
112 DEFINE_EXPECT(Obj_OnStartBinding);
113 DEFINE_EXPECT(Obj_OnStopBinding);
114 DEFINE_EXPECT(Obj_GetBindInfo);
115 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
116 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
117 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
118 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
119 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
120 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
121 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
122 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
123 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
124 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
125 DEFINE_EXPECT(Start);
126 DEFINE_EXPECT(Read);
127 DEFINE_EXPECT(LockRequest);
128 DEFINE_EXPECT(Terminate);
129 DEFINE_EXPECT(UnlockRequest);
130 DEFINE_EXPECT(Continue);
131 DEFINE_EXPECT(CreateInstance);
132 DEFINE_EXPECT(Load);
133 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
134 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
135 DEFINE_EXPECT(SetPriority);
136
137 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
138 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
139
140 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
141 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
142 static const WCHAR SHORT_RESPONSE_URL[] =
143 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
144 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
145 'p','o','s','t','t','e','s','t','.','p','h','p',0};
146 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
147 static WCHAR INDEX_HTML[MAX_PATH];
148 static const WCHAR ITS_URL[] =
149 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
150 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
151 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
152 static const WCHAR https_urlW[] =
153 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
154 '/','t','e','s','t','.','h','t','m','l',0};
155 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
156 '/','p','u','b','/','o','t','h','e','r','/',
157 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
158
159
160 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
161
162 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
163
164 static const WCHAR wszWineHQSite[] =
165 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
166 static const WCHAR wszWineHQIP[] =
167 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
168 static const CHAR wszIndexHtmlA[] = "index.html";
169 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
170 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
171 static const CHAR dwl_htmlA[] = "dwl.html";
172 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
173 static const WCHAR emptyW[] = {0};
174
175 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
176 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
177 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed;
178 static CHAR mime_type[512];
179 static IInternetProtocolSink *protocol_sink = NULL;
180 static IBinding *current_binding;
181 static HANDLE complete_event, complete_event2;
182 static HRESULT binding_hres;
183 static BOOL have_IHttpNegotiate2, use_bscex;
184
185 static LPCWSTR urls[] = {
186 WINE_ABOUT_URL,
187 ABOUT_BLANK,
188 INDEX_HTML,
189 ITS_URL,
190 MK_URL,
191 https_urlW,
192 ftp_urlW
193 };
194
195 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
196
197 static enum {
198 HTTP_TEST,
199 ABOUT_TEST,
200 FILE_TEST,
201 ITS_TEST,
202 MK_TEST,
203 HTTPS_TEST,
204 FTP_TEST
205 } test_protocol;
206
207 static enum {
208 BEFORE_DOWNLOAD,
209 DOWNLOADING,
210 END_DOWNLOAD
211 } download_state;
212
213 static const char *debugstr_guid(REFIID riid)
214 {
215 static char buf[50];
216
217 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
218 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
219 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
220 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
221
222 return buf;
223 }
224
225 static BOOL is_urlmon_protocol(int prot)
226 {
227 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
228 }
229
230 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
231 {
232 HRESULT hr;
233 IMoniker *mon1 = NULL;
234 IMoniker *mon2 = NULL;
235
236 hr = CreateURLMoniker(NULL, url1, &mon1);
237 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
238 if(SUCCEEDED(hr)) {
239 hr = CreateURLMoniker(mon1, url2, &mon2);
240 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
241 }
242 if(mon1) IMoniker_Release(mon1);
243 if(mon2) IMoniker_Release(mon2);
244 }
245
246 static void test_create(void)
247 {
248 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
249 }
250
251 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
252 {
253 ok(0, "unexpected call\n");
254 return E_NOINTERFACE;
255 }
256
257 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
258 {
259 return 2;
260 }
261
262 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
263 {
264 return 1;
265 }
266
267 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
268 {
269 CHECK_EXPECT(SetPriority);
270 ok(!nPriority, "nPriority = %d\n", nPriority);
271 return S_OK;
272 }
273
274 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
275 {
276 ok(0, "unexpected call\n");
277 return S_OK;
278 }
279
280 static const IInternetPriorityVtbl InternetPriorityVtbl = {
281 Priority_QueryInterface,
282 Priority_AddRef,
283 Priority_Release,
284 Priority_SetPriority,
285 Priority_GetPriority
286 };
287
288 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
289
290 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
291 {
292 *ppv = NULL;
293
294 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
295 *ppv = iface;
296 return S_OK;
297 }
298
299 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
300 if(!is_urlmon_protocol(test_protocol))
301 return E_NOINTERFACE;
302
303 *ppv = &InternetPriority;
304 return S_OK;
305 }
306
307 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
308 return E_NOINTERFACE; /* TODO */
309
310 ok(0, "unexpected call %s\n", debugstr_guid(riid));
311 return E_NOINTERFACE;
312 }
313
314 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
315 {
316 return 2;
317 }
318
319 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
320 {
321 return 1;
322 }
323
324 static void test_switch_fail(void)
325 {
326 IInternetProtocolSink *binding_sink;
327 PROTOCOLDATA protocoldata;
328 HRESULT hres;
329
330 static BOOL tested_switch_fail;
331
332 if(tested_switch_fail)
333 return;
334
335 tested_switch_fail = TRUE;
336
337 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
338 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
339 if(SUCCEEDED(hres)) {
340 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
341 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
342 IInternetProtocolSink_Release(binding_sink);
343 }
344 }
345
346 static DWORD WINAPI thread_proc(PVOID arg)
347 {
348 PROTOCOLDATA protocoldata;
349 HRESULT hres;
350
351 if(bind_to_object)
352 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
353 else
354 SET_EXPECT(OnProgress_FINDINGRESOURCE);
355 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
356 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
357 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
358 WaitForSingleObject(complete_event, INFINITE);
359 if(bind_to_object)
360 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
361 else
362 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
363
364 if(bind_to_object)
365 SET_EXPECT(Obj_OnProgress_CONNECTING);
366 else
367 SET_EXPECT(OnProgress_CONNECTING);
368 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
369 BINDSTATUS_CONNECTING, wszWineHQIP);
370 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
371 WaitForSingleObject(complete_event, INFINITE);
372 if(bind_to_object)
373 CHECK_CALLED(Obj_OnProgress_CONNECTING);
374 else
375 CHECK_CALLED(OnProgress_CONNECTING);
376
377 if(bind_to_object)
378 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
379 else
380 SET_EXPECT(OnProgress_SENDINGREQUEST);
381 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
382 BINDSTATUS_SENDINGREQUEST, NULL);
383 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
384 WaitForSingleObject(complete_event, INFINITE);
385 if(bind_to_object)
386 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
387 else
388 CHECK_CALLED(OnProgress_SENDINGREQUEST);
389
390 test_switch_fail();
391
392 SET_EXPECT(Continue);
393 prot_state = 1;
394 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
395 ok(hres == S_OK, "Switch failed: %08x\n", hres);
396 WaitForSingleObject(complete_event, INFINITE);
397
398 CHECK_CALLED(Continue);
399 CHECK_CALLED(Read);
400 if(bind_to_object) {
401 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
402 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
403 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
404 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
405 CHECK_CALLED(CreateInstance);
406 CHECK_CALLED(PutProperty_MIMETYPEPROP);
407 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
408 CHECK_CALLED(Load);
409 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
410 CHECK_CALLED(OnObjectAvailable);
411 CHECK_CALLED(Obj_OnStopBinding);
412 }else {
413 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
414 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
415 CHECK_CALLED(LockRequest);
416 CHECK_CALLED(OnDataAvailable);
417 }
418
419 SET_EXPECT(Continue);
420 prot_state = 2;
421 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
422 ok(hres == S_OK, "Switch failed: %08x\n", hres);
423 WaitForSingleObject(complete_event, INFINITE);
424 CHECK_CALLED(Continue);
425 CHECK_CALLED(Read);
426 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
427 CHECK_CALLED(OnDataAvailable);
428
429 SET_EXPECT(Continue);
430 prot_state = 2;
431 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
432 ok(hres == S_OK, "Switch failed: %08x\n", hres);
433 WaitForSingleObject(complete_event, INFINITE);
434 CHECK_CALLED(Continue);
435 CHECK_CALLED(Read);
436 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
437 CHECK_CALLED(OnDataAvailable);
438
439 SET_EXPECT(Continue);
440 prot_state = 3;
441 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
442 ok(hres == S_OK, "Switch failed: %08x\n", hres);
443 WaitForSingleObject(complete_event, INFINITE);
444 CHECK_CALLED(Continue);
445 CHECK_CALLED(Read);
446 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
447 CHECK_CALLED(OnDataAvailable);
448 CHECK_CALLED(OnStopBinding);
449
450 SET_EXPECT(Read);
451
452 SetEvent(complete_event2);
453 return 0;
454 }
455
456 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
457 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
458 DWORD grfPI, HANDLE_PTR dwReserved)
459 {
460 BINDINFO bindinfo;
461 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
462 HRESULT hres;
463
464 static const STGMEDIUM stgmed_zero = {0};
465 static const SECURITY_ATTRIBUTES sa_zero = {0};
466
467 CHECK_EXPECT(Start);
468
469 read = 0;
470
471 if(!filedwl_api) /* FIXME */
472 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", wine_dbgstr_w(szUrl));
473 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
474 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
475 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
476 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
477
478 if(!filedwl_api && binding_hres != S_OK) {
479 SET_EXPECT(OnStopBinding);
480 SET_EXPECT(Terminate);
481 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
482 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
483 CHECK_CALLED(OnStopBinding);
484 CHECK_CALLED(Terminate);
485
486 return S_OK;
487 }
488
489 memset(&bindinfo, 0, sizeof(bindinfo));
490 bindinfo.cbSize = sizeof(bindinfo);
491 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
492 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
493
494 if(filedwl_api) {
495 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
496 }else if(tymed == TYMED_ISTREAM && is_urlmon_protocol(test_protocol)) {
497 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
498 |BINDF_FROMURLMON),
499 "bindf=%08x\n", bindf);
500 }else {
501 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
502 |BINDF_FROMURLMON|BINDF_NEEDFILE),
503 "bindf=%08x\n", bindf);
504 }
505
506 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
507 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
508 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
509 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
510 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
511 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
512 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
513 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
514 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
515 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
516 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
517 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
518 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
519 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
520
521 switch(test_protocol) {
522 case MK_TEST:
523 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
524 BINDSTATUS_DIRECTBIND, NULL);
525 ok(hres == S_OK,
526 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
527
528 case FILE_TEST:
529 case ITS_TEST:
530 if(bind_to_object)
531 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
532 else
533 SET_EXPECT(OnProgress_SENDINGREQUEST);
534 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
535 BINDSTATUS_SENDINGREQUEST, emptyW);
536 ok(hres == S_OK,
537 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
538 if(bind_to_object)
539 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
540 else
541 CHECK_CALLED(OnProgress_SENDINGREQUEST);
542 default:
543 break;
544 }
545
546 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
547 IServiceProvider *service_provider;
548 IHttpNegotiate *http_negotiate;
549 IHttpNegotiate2 *http_negotiate2;
550 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
551 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
552 BYTE sec_id[100];
553 DWORD fetched = 256, size = 100;
554 DWORD tid;
555
556 static const WCHAR wszMimes[] = {'*','/','*',0};
557
558 SET_EXPECT(QueryInterface_IInternetBindInfo);
559 SET_EXPECT(QueryService_IInternetBindInfo);
560 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
561 &ua, 1, &fetched);
562 CLEAR_CALLED(QueryInterface_IInternetBindInfo); /* IE <8 */
563 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
564
565 ok(hres == E_NOINTERFACE,
566 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
567 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
568 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
569
570 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
571 accept_mimes, 256, &fetched);
572 ok(hres == S_OK,
573 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
574 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
575 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
576
577 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
578 NULL, 256, &fetched);
579 ok(hres == E_INVALIDARG,
580 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
581
582 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
583 accept_mimes, 256, NULL);
584 ok(hres == E_INVALIDARG,
585 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
586
587 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
588 (void**)&service_provider);
589 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
590
591 SET_EXPECT(QueryInterface_IHttpNegotiate);
592 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
593 &IID_IHttpNegotiate, (void**)&http_negotiate);
594 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
595 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
596
597 SET_EXPECT(BeginningTransaction);
598 SET_EXPECT(QueryInterface_IHttpNegotiate);
599 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
600 NULL, 0, &additional_headers);
601 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
602 CHECK_CALLED(BeginningTransaction);
603 IHttpNegotiate_Release(http_negotiate);
604 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
605 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
606
607 SET_EXPECT(QueryInterface_IHttpNegotiate2);
608 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
609 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
610 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
611 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
612
613 size = 512;
614 SET_EXPECT(QueryInterface_IHttpNegotiate2);
615 SET_EXPECT(GetRootSecurityId);
616 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
617 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
618 CHECK_CALLED(GetRootSecurityId);
619 IHttpNegotiate2_Release(http_negotiate2);
620 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
621 ok(size == 13, "size=%d\n", size);
622
623 IServiceProvider_Release(service_provider);
624
625 IInternetProtocolSink_AddRef(pOIProtSink);
626 protocol_sink = pOIProtSink;
627 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
628
629 return S_OK;
630 }
631
632 if(test_protocol == FILE_TEST) {
633 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
634 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
635 ok(hres == S_OK,
636 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
637
638 if(bind_to_object)
639 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
640 else
641 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
642 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
643 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
644 ok(hres == S_OK,
645 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
646 if(bind_to_object)
647 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
648 else
649 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
650 }else {
651 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
652 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
653 ok(hres == S_OK,
654 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
655 }
656
657 if(test_protocol == ABOUT_TEST)
658 bscf |= BSCF_DATAFULLYAVAILABLE;
659 if(test_protocol == ITS_TEST)
660 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
661
662 SET_EXPECT(Read);
663 if(bind_to_object) {
664 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
665 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
666 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
667 if(test_protocol == FILE_TEST)
668 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
669 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
670 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
671 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
672 SET_EXPECT(CreateInstance);
673 SET_EXPECT(PutProperty_MIMETYPEPROP);
674 SET_EXPECT(PutProperty_CLASSIDPROP);
675 SET_EXPECT(Load);
676 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
677 SET_EXPECT(OnObjectAvailable);
678 SET_EXPECT(Obj_OnStopBinding);
679 }else {
680 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
681 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
682 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
683 if(test_protocol == FILE_TEST)
684 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
685 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
686 SET_EXPECT(LockRequest);
687 if(!filedwl_api)
688 SET_EXPECT(OnDataAvailable);
689 SET_EXPECT(OnStopBinding);
690 }
691
692 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
693 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
694
695 CHECK_CALLED(Read);
696 if(bind_to_object) {
697 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
698 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
699 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
700 if(test_protocol == FILE_TEST)
701 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
702 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
703 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
704 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
705 CHECK_CALLED(CreateInstance);
706 CHECK_CALLED(PutProperty_MIMETYPEPROP);
707 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
708 CHECK_CALLED(Load);
709 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
710 CHECK_CALLED(OnObjectAvailable);
711 CHECK_CALLED(Obj_OnStopBinding);
712 }else {
713 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
714 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
715 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
716 if(test_protocol == FILE_TEST)
717 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
718 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
719 CHECK_CALLED(LockRequest);
720 if(!filedwl_api)
721 CHECK_CALLED(OnDataAvailable);
722 CHECK_CALLED(OnStopBinding);
723 }
724
725 if(test_protocol == ITS_TEST) {
726 SET_EXPECT(Read);
727 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
728 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
729 CHECK_CALLED(Read);
730 }
731
732 SET_EXPECT(Terminate);
733 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
734 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
735 CHECK_CALLED(Terminate);
736
737 return S_OK;
738 }
739
740 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
741 PROTOCOLDATA *pProtocolData)
742 {
743 DWORD bscf = 0;
744 HRESULT hres;
745
746 CHECK_EXPECT(Continue);
747
748 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
749
750 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
751 if(!pProtocolData)
752 return S_OK;
753
754 switch(prot_state) {
755 case 1: {
756 IServiceProvider *service_provider;
757 IHttpNegotiate *http_negotiate;
758 static WCHAR header[] = {'?',0};
759
760 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
761 (void**)&service_provider);
762 ok(hres == S_OK, "Could not get IServiceProvicder\n");
763
764 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
765 &IID_IHttpNegotiate, (void**)&http_negotiate);
766 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
767
768 SET_EXPECT(QueryInterface_IHttpNegotiate);
769 SET_EXPECT(OnResponse);
770 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
771 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
772 CHECK_CALLED(OnResponse);
773 IHttpNegotiate_Release(http_negotiate);
774 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
775
776 if(test_protocol == HTTPS_TEST) {
777 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
778 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
779 }
780
781 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
782 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
783 ok(hres == S_OK,
784 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
785
786 if(tymed == TYMED_FILE) {
787 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
788 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
789 ok(hres == S_OK,
790 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
791 }
792
793 bscf |= BSCF_FIRSTDATANOTIFICATION;
794 break;
795 }
796 case 2:
797 case 3:
798 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
799 break;
800 }
801
802 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
803 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
804
805 SET_EXPECT(Read);
806 switch(prot_state) {
807 case 1:
808 if(bind_to_object) {
809 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
810 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
811 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
812 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
813 SET_EXPECT(CreateInstance);
814 SET_EXPECT(PutProperty_MIMETYPEPROP);
815 SET_EXPECT(PutProperty_CLASSIDPROP);
816 SET_EXPECT(Load);
817 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
818 SET_EXPECT(OnObjectAvailable);
819 SET_EXPECT(Obj_OnStopBinding);
820 }else {
821 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
822 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
823 SET_EXPECT(LockRequest);
824 }
825 break;
826 case 2:
827 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
828 break;
829 case 3:
830 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
831 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
832 }
833 if(!bind_to_object || prot_state >= 2)
834 SET_EXPECT(OnDataAvailable);
835 if(prot_state == 3)
836 SET_EXPECT(OnStopBinding);
837
838 return S_OK;
839 }
840
841 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
842 DWORD dwOptions)
843 {
844 ok(0, "unexpected call\n");
845 return E_NOTIMPL;
846 }
847
848 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
849 {
850 CHECK_EXPECT(Terminate);
851
852 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
853
854 if(protocol_sink) {
855 IInternetProtocolSink_Release(protocol_sink);
856 protocol_sink = NULL;
857 }
858
859 return S_OK;
860 }
861
862 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
863 {
864 ok(0, "unexpected call\n");
865 return E_NOTIMPL;
866 }
867
868 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
869 {
870 ok(0, "unexpected call\n");
871 return E_NOTIMPL;
872 }
873
874 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
875 ULONG cb, ULONG *pcbRead)
876 {
877 static const char data[] = "<HTML></HTML>";
878
879 CHECK_EXPECT2(Read);
880
881 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
882 HRESULT hres;
883
884 static BOOL pending = TRUE;
885
886 pending = !pending;
887
888 switch(prot_state) {
889 case 1:
890 case 2:
891 if(pending) {
892 *pcbRead = 10;
893 memset(pv, '?', 10);
894 return E_PENDING;
895 }else {
896 memset(pv, '?', cb);
897 *pcbRead = cb;
898 read++;
899 return S_OK;
900 }
901 case 3:
902 prot_state++;
903
904 *pcbRead = 0;
905
906 hres = IInternetProtocolSink_ReportData(protocol_sink,
907 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
908 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
909
910 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
911 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
912
913 return S_FALSE;
914 case 4:
915 *pcbRead = 0;
916 return S_FALSE;
917 }
918 }
919
920 if(read) {
921 *pcbRead = 0;
922 return S_FALSE;
923 }
924
925 ok(pv != NULL, "pv == NULL\n");
926 ok(cb != 0, "cb == 0\n");
927 ok(pcbRead != NULL, "pcbRead == NULL\n");
928 if(pcbRead) {
929 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
930 read += *pcbRead = sizeof(data)-1;
931 }
932 if(pv)
933 memcpy(pv, data, sizeof(data));
934
935 return S_OK;
936 }
937
938 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
939 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
940 {
941 ok(0, "unexpected call\n");
942 return E_NOTIMPL;
943 }
944
945 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
946 {
947 CHECK_EXPECT(LockRequest);
948 return S_OK;
949 }
950
951 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
952 {
953 CHECK_EXPECT(UnlockRequest);
954 return S_OK;
955 }
956
957 static const IInternetProtocolVtbl ProtocolVtbl = {
958 Protocol_QueryInterface,
959 Protocol_AddRef,
960 Protocol_Release,
961 Protocol_Start,
962 Protocol_Continue,
963 Protocol_Abort,
964 Protocol_Terminate,
965 Protocol_Suspend,
966 Protocol_Resume,
967 Protocol_Read,
968 Protocol_Seek,
969 Protocol_LockRequest,
970 Protocol_UnlockRequest
971 };
972
973 static IInternetProtocol Protocol = { &ProtocolVtbl };
974
975 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
976 {
977 if(IsEqualGUID(&IID_IUnknown, riid)
978 || IsEqualGUID(&IID_IHttpNegotiate, riid)
979 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
980 *ppv = iface;
981 return S_OK;
982 }
983
984 ok(0, "unexpected call\n");
985 return E_NOINTERFACE;
986 }
987
988 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
989 {
990 return 2;
991 }
992
993 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
994 {
995 return 1;
996 }
997
998 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
999 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1000 {
1001 CHECK_EXPECT(BeginningTransaction);
1002
1003 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1004
1005 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
1006 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1007 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1008 if(pszAdditionalHeaders)
1009 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1010
1011 return S_OK;
1012 }
1013
1014 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1015 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1016 {
1017 CHECK_EXPECT(OnResponse);
1018
1019 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1020
1021 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1022 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1023 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1024 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1025 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1026 if(pszAdditionalRequestHeaders)
1027 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1028
1029 return S_OK;
1030 }
1031
1032 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1033 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1034 {
1035 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1036
1037 CHECK_EXPECT(GetRootSecurityId);
1038
1039 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1040
1041 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1042 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1043 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1044
1045 if(pbSecurityId == (void*)0xdeadbeef)
1046 return E_NOTIMPL;
1047
1048 if(pcbSecurityId) {
1049 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1050 *pcbSecurityId = sizeof(sec_id);
1051 }
1052
1053 if(pbSecurityId)
1054 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1055
1056 return E_FAIL;
1057 }
1058
1059 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1060 HttpNegotiate_QueryInterface,
1061 HttpNegotiate_AddRef,
1062 HttpNegotiate_Release,
1063 HttpNegotiate_BeginningTransaction,
1064 HttpNegotiate_OnResponse,
1065 HttpNegotiate_GetRootSecurityId
1066 };
1067
1068 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1069
1070 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1071 {
1072 ok(0, "unexpected call\n");
1073 return E_NOINTERFACE;
1074 }
1075
1076 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1077 {
1078 return 2;
1079 }
1080
1081 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1082 {
1083 return 1;
1084 }
1085
1086 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1087 REFGUID guidService, REFIID riid, void **ppv)
1088 {
1089 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1090 CHECK_EXPECT(QueryService_IAuthenticate);
1091 return E_NOTIMPL;
1092 }
1093
1094 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1095 CHECK_EXPECT2(QueryService_IInternetProtocol);
1096 return E_NOTIMPL;
1097 }
1098
1099 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1100 CHECK_EXPECT(QueryService_IInternetBindInfo);
1101 return E_NOTIMPL;
1102 }
1103
1104 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1105 CHECK_EXPECT(QueryService_IWindowForBindingUI);
1106 return E_NOTIMPL;
1107 }
1108
1109 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1110 return E_NOINTERFACE;
1111 }
1112
1113 static IServiceProviderVtbl ServiceProviderVtbl = {
1114 ServiceProvider_QueryInterface,
1115 ServiceProvider_AddRef,
1116 ServiceProvider_Release,
1117 ServiceProvider_QueryService
1118 };
1119
1120 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1121
1122 static IBindStatusCallbackEx objbsc;
1123
1124 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1125 {
1126 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1127
1128 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1129 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1130 if(emulate_protocol) {
1131 *ppv = &Protocol;
1132 return S_OK;
1133 }else {
1134 return E_NOINTERFACE;
1135 }
1136 }
1137 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1138 {
1139 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1140 *ppv = &ServiceProvider;
1141 return S_OK;
1142 }
1143 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1144 {
1145 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1146 *ppv = &HttpNegotiate;
1147 return S_OK;
1148 }
1149 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1150 {
1151 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1152 *ppv = &HttpNegotiate;
1153 return S_OK;
1154 }
1155 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1156 {
1157 CHECK_EXPECT(QueryInterface_IAuthenticate);
1158 return E_NOINTERFACE;
1159 }
1160 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1161 {
1162 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1163 *ppv = iface;
1164 return S_OK;
1165 }
1166 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1167 {
1168 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1169 return E_NOINTERFACE;
1170 }
1171 else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid))
1172 {
1173 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1174 if(!use_bscex)
1175 return E_NOINTERFACE;
1176 *ppv = iface;
1177 return S_OK;
1178 }
1179 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1180 {
1181 /* TODO */
1182 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1183 }
1184 else if(IsEqualGUID(&IID_IWindowForBindingUI, riid))
1185 {
1186 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1187 return E_NOINTERFACE;
1188 }
1189 else
1190 {
1191 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1192 }
1193
1194 return E_NOINTERFACE;
1195 }
1196
1197 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1198 {
1199 return 2;
1200 }
1201
1202 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1203 {
1204 return 1;
1205 }
1206
1207 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1208 IBinding *pib)
1209 {
1210 IWinInetHttpInfo *http_info;
1211 HRESULT hres;
1212 IMoniker *mon;
1213
1214 if(iface == &objbsc)
1215 CHECK_EXPECT(Obj_OnStartBinding);
1216 else
1217 CHECK_EXPECT(OnStartBinding);
1218
1219 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1220
1221 ok(pib != NULL, "pib should not be NULL\n");
1222 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1223
1224 if(pib == (void*)0xdeadbeef)
1225 return S_OK;
1226
1227 current_binding = pib;
1228
1229 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1230 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1231 if(SUCCEEDED(hres))
1232 IMoniker_Release(mon);
1233
1234 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1235 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1236
1237 return S_OK;
1238 }
1239
1240 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1241 {
1242 ok(0, "unexpected call\n");
1243 return E_NOTIMPL;
1244 }
1245
1246 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1247 {
1248 ok(0, "unexpected call\n");
1249 return E_NOTIMPL;
1250 }
1251
1252 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1253 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1254 {
1255 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1256
1257 switch(ulStatusCode) {
1258 case BINDSTATUS_FINDINGRESOURCE:
1259 if(iface == &objbsc)
1260 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1261 else if(test_protocol == FTP_TEST)
1262 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1263 else
1264 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1265 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1266 SetEvent(complete_event);
1267 break;
1268 case BINDSTATUS_CONNECTING:
1269 if(iface == &objbsc)
1270 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1271 else if(test_protocol == FTP_TEST)
1272 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1273 else
1274 CHECK_EXPECT(OnProgress_CONNECTING);
1275 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1276 SetEvent(complete_event);
1277 break;
1278 case BINDSTATUS_SENDINGREQUEST:
1279 if(iface == &objbsc)
1280 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1281 else if(test_protocol == FTP_TEST)
1282 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1283 else
1284 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1285 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1286 SetEvent(complete_event);
1287 break;
1288 case BINDSTATUS_MIMETYPEAVAILABLE:
1289 if(iface == &objbsc)
1290 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1291 else
1292 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1293 if(!bind_to_object)
1294 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1295 download_state);
1296 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1297 break;
1298 case BINDSTATUS_BEGINDOWNLOADDATA:
1299 if(iface == &objbsc)
1300 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1301 else
1302 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1303 ok(szStatusText != NULL, "szStatusText == NULL\n");
1304 if(szStatusText) {
1305 if(filedwl_api) {
1306 /* FIXME */
1307 }else {
1308 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1309 }
1310 }
1311 if(!bind_to_object)
1312 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1313 download_state);
1314 download_state = DOWNLOADING;
1315 break;
1316 case BINDSTATUS_DOWNLOADINGDATA:
1317 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1318 ok(iface != &objbsc, "unexpected call\n");
1319 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1320 download_state);
1321 break;
1322 case BINDSTATUS_ENDDOWNLOADDATA:
1323 if(iface == &objbsc)
1324 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1325 else
1326 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1327 ok(szStatusText != NULL, "szStatusText == NULL\n");
1328 if(szStatusText) {
1329 if(filedwl_api) {
1330 /* FIXME */
1331 }else {
1332 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1333 }
1334 }
1335 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1336 download_state);
1337 download_state = END_DOWNLOAD;
1338 break;
1339 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1340 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) {
1341 if(iface == &objbsc)
1342 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1343 else
1344 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1345 }else { /* FIXME */
1346 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1347 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1348 }
1349
1350 ok(szStatusText != NULL, "szStatusText == NULL\n");
1351 if(szStatusText && test_protocol == FILE_TEST)
1352 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1353 break;
1354 case BINDSTATUS_CLASSIDAVAILABLE:
1355 {
1356 CLSID clsid;
1357 HRESULT hr;
1358 if(iface != &objbsc)
1359 ok(0, "unexpected call\n");
1360 else if(1||emulate_protocol)
1361 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1362 else
1363 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1364 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1365 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1366 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1367 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1368 break;
1369 }
1370 case BINDSTATUS_BEGINSYNCOPERATION:
1371 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1372 if(iface != &objbsc)
1373 ok(0, "unexpected call\n");
1374 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1375 break;
1376 case BINDSTATUS_ENDSYNCOPERATION:
1377 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1378 if(iface != &objbsc)
1379 ok(0, "unexpected call\n");
1380 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1381 break;
1382 case BINDSTATUS_PROXYDETECTING:
1383 trace("BINDSTATUS_PROXYDETECTING\n");
1384 break;
1385 case BINDSTATUS_COOKIE_SENT:
1386 trace("BINDSTATUS_COOKIE_SENT\n");
1387 break;
1388 default:
1389 ok(0, "unexpected code %d\n", ulStatusCode);
1390 };
1391
1392 if(current_binding) {
1393 IWinInetHttpInfo *http_info;
1394 HRESULT hres;
1395
1396 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1397 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol))
1398 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1399 else
1400 ok(hres == E_NOINTERFACE,
1401 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1402 if(SUCCEEDED(hres))
1403 IWinInetHttpInfo_Release(http_info);
1404 }
1405
1406 return S_OK;
1407 }
1408
1409 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1410 {
1411 if(iface == &objbsc) {
1412 CHECK_EXPECT(Obj_OnStopBinding);
1413 stopped_obj_binding = TRUE;
1414 }else {
1415 CHECK_EXPECT(OnStopBinding);
1416 stopped_binding = TRUE;
1417 }
1418
1419 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1420
1421 /* ignore DNS failure */
1422 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1423 return S_OK;
1424
1425 if(filedwl_api)
1426 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1427 else
1428 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1429 ok(szError == NULL, "szError should be NULL\n");
1430
1431 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) && emulate_protocol) {
1432 SetEvent(complete_event);
1433 if(iface != &objbsc)
1434 WaitForSingleObject(complete_event2, INFINITE);
1435 }
1436
1437 return S_OK;
1438 }
1439
1440 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1441 {
1442 DWORD cbSize;
1443
1444 if(iface == &objbsc)
1445 CHECK_EXPECT(Obj_GetBindInfo);
1446 else
1447 CHECK_EXPECT(GetBindInfo);
1448
1449 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1450
1451 *grfBINDF = bindf;
1452 cbSize = pbindinfo->cbSize;
1453 memset(pbindinfo, 0, cbSize);
1454 pbindinfo->cbSize = cbSize;
1455
1456 return S_OK;
1457 }
1458
1459 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1460 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1461 {
1462 HRESULT hres;
1463 DWORD readed;
1464 BYTE buf[512];
1465 CHAR clipfmt[512];
1466
1467 if(iface == &objbsc)
1468 ok(0, "unexpected call\n");
1469
1470 CHECK_EXPECT2(OnDataAvailable);
1471
1472 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1473
1474 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1475 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1476 download_state);
1477 data_available = TRUE;
1478
1479 ok(pformatetc != NULL, "pformatetx == NULL\n");
1480 if(pformatetc) {
1481 if (mime_type[0]) {
1482 clipfmt[0] = 0;
1483 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1484 "GetClipboardFormatName failed, error %d\n", GetLastError());
1485 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1486 pformatetc->cfFormat, clipfmt, mime_type);
1487 } else {
1488 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1489 }
1490 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1491 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1492 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1493 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1494 }
1495
1496 ok(pstgmed != NULL, "stgmeg == NULL\n");
1497 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1498 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1499
1500 switch(pstgmed->tymed) {
1501 case TYMED_ISTREAM:
1502 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1503 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1504 ok(hres == STG_E_ACCESSDENIED,
1505 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1506
1507 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1508 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1509
1510 hres = IStream_Revert(U(*pstgmed).pstm);
1511 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1512 }
1513
1514 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1515 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1516 while(hres == S_OK);
1517 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1518 break;
1519
1520 case TYMED_FILE:
1521 if(test_protocol == FILE_TEST)
1522 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1523 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1524 else if(emulate_protocol)
1525 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1526 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1527 else
1528 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1529 }
1530
1531 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1532 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1533 SetEvent(complete_event);
1534
1535 return S_OK;
1536 }
1537
1538 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
1539 {
1540 CHECK_EXPECT(OnObjectAvailable);
1541
1542 if(iface != &objbsc)
1543 ok(0, "unexpected call\n");
1544
1545 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1546 ok(punk != NULL, "punk == NULL\n");
1547
1548 return S_OK;
1549 }
1550
1551 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
1552 DWORD *grfBINDF2, DWORD *pdwReserved)
1553 {
1554 CHECK_EXPECT(GetBindInfoEx);
1555
1556 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1557 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
1558 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1559 ok(pdwReserved != NULL, "dwReserved == NULL\n");
1560
1561 return S_OK;
1562 }
1563
1564 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
1565 statusclb_QueryInterface,
1566 statusclb_AddRef,
1567 statusclb_Release,
1568 statusclb_OnStartBinding,
1569 statusclb_GetPriority,
1570 statusclb_OnLowResource,
1571 statusclb_OnProgress,
1572 statusclb_OnStopBinding,
1573 statusclb_GetBindInfo,
1574 statusclb_OnDataAvailable,
1575 statusclb_OnObjectAvailable,
1576 statusclb_GetBindInfoEx
1577 };
1578
1579 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
1580 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
1581
1582 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1583 {
1584 *ppv = NULL;
1585 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1586 return E_NOINTERFACE;
1587 }
1588
1589 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1590 {
1591 return 2;
1592 }
1593
1594 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1595 {
1596 return 1;
1597 }
1598
1599 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1600 {
1601 switch(mkp) {
1602 case MIMETYPEPROP:
1603 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1604 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
1605 break;
1606 case CLASSIDPROP:
1607 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1608 break;
1609 default:
1610 break;
1611 }
1612
1613 return S_OK;
1614 }
1615
1616 static const IMonikerPropVtbl MonikerPropVtbl = {
1617 MonikerProp_QueryInterface,
1618 MonikerProp_AddRef,
1619 MonikerProp_Release,
1620 MonikerProp_PutProperty
1621 };
1622
1623 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1624
1625 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1626 {
1627 *ppv = NULL;
1628
1629 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1630 *ppv = iface;
1631 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1632 *ppv = &MonikerProp;
1633
1634 if(*ppv)
1635 return S_OK;
1636
1637 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1638 return E_NOINTERFACE;
1639 }
1640
1641 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1642 {
1643 return 2;
1644 }
1645
1646 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1647 {
1648 return 1;
1649 }
1650
1651 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1652 {
1653 ok(0, "unexpected call\n");
1654 return E_NOTIMPL;
1655 }
1656
1657 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1658 {
1659 ok(0, "unexpected call\n");
1660 return E_NOTIMPL;
1661 }
1662
1663 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1664 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1665 {
1666 IUnknown *unk;
1667 HRESULT hres;
1668
1669 static WCHAR cbinding_contextW[] =
1670 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1671
1672 CHECK_EXPECT(Load);
1673 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1674
1675 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1676 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1677 else
1678 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1679 ok(pimkName != NULL, "pimkName == NULL\n");
1680 ok(pibc != NULL, "pibc == NULL\n");
1681 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1682
1683 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1684 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1685 if(SUCCEEDED(hres)) {
1686 IBinding *binding;
1687
1688 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1689 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1690
1691 IBinding_Release(binding);
1692 IUnknown_Release(unk);
1693 }
1694
1695 SET_EXPECT(QueryInterface_IServiceProvider);
1696 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
1697 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1698 CHECK_CALLED(QueryInterface_IServiceProvider);
1699
1700 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1701 SET_EXPECT(GetBindInfo);
1702 SET_EXPECT(OnStartBinding);
1703 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1704 if(test_protocol == FILE_TEST)
1705 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1706 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1707 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1708 SET_EXPECT(LockRequest);
1709 SET_EXPECT(OnDataAvailable);
1710 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1711 SET_EXPECT(OnStopBinding);
1712
1713 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1714 ok(hres == S_OK, "Load failed: %08x\n", hres);
1715
1716 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
1717 CHECK_CALLED(GetBindInfo);
1718 CHECK_CALLED(OnStartBinding);
1719 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1720 if(test_protocol == FILE_TEST)
1721 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1722 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1723 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1724 CHECK_CALLED(LockRequest);
1725 CHECK_CALLED(OnDataAvailable);
1726 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1727 CHECK_CALLED(OnStopBinding);
1728
1729 if(unk)
1730 IUnknown_Release(unk);
1731
1732 return S_OK;
1733 }
1734
1735 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1736 {
1737 ok(0, "unexpected call\n");
1738 return E_NOTIMPL;
1739 }
1740
1741 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1742 {
1743 ok(0, "unexpected call\n");
1744 return E_NOTIMPL;
1745 }
1746
1747 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1748 {
1749 ok(0, "unexpected call\n");
1750 return E_NOTIMPL;
1751 }
1752
1753 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1754 PersistMoniker_QueryInterface,
1755 PersistMoniker_AddRef,
1756 PersistMoniker_Release,
1757 PersistMoniker_GetClassID,
1758 PersistMoniker_IsDirty,
1759 PersistMoniker_Load,
1760 PersistMoniker_Save,
1761 PersistMoniker_SaveCompleted,
1762 PersistMoniker_GetCurMoniker
1763 };
1764
1765 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1766
1767 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1768 {
1769 *ppv = NULL;
1770
1771 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1772 *ppv = iface;
1773 return S_OK;
1774 }
1775
1776 if(IsEqualGUID(&IID_IMarshal, riid))
1777 return E_NOINTERFACE;
1778 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1779 return E_NOINTERFACE;
1780
1781 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1782 return E_NOTIMPL;
1783 }
1784
1785 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1786 {
1787 return 2;
1788 }
1789
1790 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1791 {
1792 return 1;
1793 }
1794
1795 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1796 {
1797 CHECK_EXPECT(CreateInstance);
1798 ok(!outer, "outer = %p\n", outer);
1799 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1800 *ppv = &PersistMoniker;
1801 return S_OK;
1802 }
1803
1804 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1805 {
1806 ok(0, "unexpected call\n");
1807 return S_OK;
1808 }
1809
1810 static const IClassFactoryVtbl ClassFactoryVtbl = {
1811 ClassFactory_QueryInterface,
1812 ClassFactory_AddRef,
1813 ClassFactory_Release,
1814 ClassFactory_CreateInstance,
1815 ClassFactory_LockServer
1816 };
1817
1818 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1819
1820 static void test_CreateAsyncBindCtx(void)
1821 {
1822 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1823 IUnknown *unk;
1824 HRESULT hres;
1825 ULONG ref;
1826 BIND_OPTS bindopts;
1827
1828 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1829 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1830 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1831
1832 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1833 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1834
1835 SET_EXPECT(QueryInterface_IServiceProvider);
1836 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
1837 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1838 CHECK_CALLED(QueryInterface_IServiceProvider);
1839
1840 bindopts.cbStruct = sizeof(bindopts);
1841 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1842 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1843 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1844 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1845 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1846 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1847 bindopts.grfMode);
1848 ok(bindopts.dwTickCountDeadline == 0,
1849 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1850
1851 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1852 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1853 if(SUCCEEDED(hres))
1854 IUnknown_Release(unk);
1855
1856 ref = IBindCtx_Release(bctx);
1857 ok(ref == 0, "bctx should be destroyed here\n");
1858 }
1859
1860 static void test_CreateAsyncBindCtxEx(void)
1861 {
1862 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1863 IUnknown *unk;
1864 BIND_OPTS bindopts;
1865 HRESULT hres;
1866
1867 static WCHAR testW[] = {'t','e','s','t',0};
1868
1869 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1870 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1871
1872 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1873 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1874
1875 if(SUCCEEDED(hres)) {
1876 bindopts.cbStruct = sizeof(bindopts);
1877 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1878 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1879 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1880 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1881 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1882 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1883 bindopts.grfMode);
1884 ok(bindopts.dwTickCountDeadline == 0,
1885 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1886
1887 IBindCtx_Release(bctx);
1888 }
1889
1890 CreateBindCtx(0, &bctx_arg);
1891 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1892 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1893
1894 if(SUCCEEDED(hres)) {
1895 bindopts.cbStruct = sizeof(bindopts);
1896 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1897 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1898 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1899 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1900 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1901 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1902 bindopts.grfMode);
1903 ok(bindopts.dwTickCountDeadline == 0,
1904 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1905
1906 IBindCtx_Release(bctx);
1907 }
1908
1909 IBindCtx_Release(bctx_arg);
1910
1911 SET_EXPECT(QueryInterface_IServiceProvider);
1912 hres = CreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
1913 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1914 CHECK_CALLED(QueryInterface_IServiceProvider);
1915
1916 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1917 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1918 if(SUCCEEDED(hres))
1919 IUnknown_Release(unk);
1920
1921 IBindCtx_Release(bctx);
1922
1923 hres = CreateBindCtx(0, &bctx2);
1924 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1925
1926 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1927 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1928
1929 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1930 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1931
1932 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1933 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1934 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1935
1936 IBindCtx_Release(bctx);
1937 IBindCtx_Release(bctx2);
1938 }
1939
1940 static void test_GetBindInfoEx(IBindStatusCallback *holder)
1941 {
1942 IBindStatusCallbackEx *bscex;
1943 BINDINFO bindinfo = {sizeof(bindinfo)};
1944 DWORD bindf, bindf2, dw;
1945 HRESULT hres;
1946
1947 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
1948 if(FAILED(hres)) {
1949 win_skip("IBindStatusCallbackEx not supported\n");
1950 return;
1951 }
1952
1953 use_bscex = TRUE;
1954
1955 bindf = 0;
1956 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1957 SET_EXPECT(GetBindInfoEx);
1958 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
1959 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1960 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1961 CHECK_CALLED(GetBindInfoEx);
1962
1963 bindf = bindf2 = dw = 0;
1964 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1965 SET_EXPECT(GetBindInfoEx);
1966 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
1967 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1968 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1969 CHECK_CALLED(GetBindInfoEx);
1970
1971 use_bscex = FALSE;
1972
1973 bindf = bindf2 = dw = 0xdeadbeef;
1974 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1975 SET_EXPECT(GetBindInfo);
1976 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
1977 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1978 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1979 CHECK_CALLED(GetBindInfo);
1980 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
1981 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
1982
1983 IBindStatusCallbackEx_Release(bscex);
1984 }
1985
1986 static BOOL test_bscholder(IBindStatusCallback *holder)
1987 {
1988 IServiceProvider *serv_prov;
1989 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1990 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1991 IAuthenticate *authenticate, *authenticate_serv;
1992 IInternetProtocol *protocol;
1993 BINDINFO bindinfo = {sizeof(bindinfo)};
1994 BOOL ret = TRUE;
1995 LPWSTR wstr;
1996 DWORD dw;
1997 HRESULT hres;
1998
1999 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2000 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2001
2002 dw = 0xdeadbeef;
2003 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2004 SET_EXPECT(GetBindInfo);
2005 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2006 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2007 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2008 CHECK_CALLED(GetBindInfo);
2009
2010 test_GetBindInfoEx(holder);
2011
2012 SET_EXPECT(OnStartBinding);
2013 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2014 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2015 CHECK_CALLED(OnStartBinding);
2016
2017 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2018 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2019
2020 SET_EXPECT(QueryInterface_IHttpNegotiate);
2021 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2022 (void**)&http_negotiate_serv);
2023 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2024 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2025
2026 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2027
2028 wstr = (void*)0xdeadbeef;
2029 SET_EXPECT(QueryInterface_IHttpNegotiate);
2030 SET_EXPECT(BeginningTransaction);
2031 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
2032 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2033 CHECK_CALLED(BeginningTransaction);
2034 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2035 ok(wstr == NULL, "wstr = %p\n", wstr);
2036
2037 IHttpNegotiate_Release(http_negotiate_serv);
2038
2039 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2040 (void**)&http_negotiate_serv);
2041 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2042 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2043 IHttpNegotiate_Release(http_negotiate_serv);
2044
2045 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2046 if(SUCCEEDED(hres)) {
2047 have_IHttpNegotiate2 = TRUE;
2048
2049 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2050 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2051 (void**)&http_negotiate2_serv);
2052 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2053 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2054 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2055
2056 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2057 SET_EXPECT(GetRootSecurityId);
2058 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2059 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2060 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2061 CHECK_CALLED(GetRootSecurityId);
2062
2063 IHttpNegotiate_Release(http_negotiate2_serv);
2064 IHttpNegotiate_Release(http_negotiate2);
2065 }else {
2066 skip("Could not get IHttpNegotiate2\n");
2067 ret = FALSE;
2068 }
2069
2070 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2071 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2072 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2073 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2074
2075 SET_EXPECT(QueryInterface_IHttpNegotiate);
2076 SET_EXPECT(OnResponse);
2077 wstr = (void*)0xdeadbeef;
2078 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2079 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2080 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2081 CHECK_CALLED(OnResponse);
2082
2083 IHttpNegotiate_Release(http_negotiate);
2084
2085 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2086 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2087
2088 SET_EXPECT(QueryInterface_IAuthenticate);
2089 SET_EXPECT(QueryService_IAuthenticate);
2090 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2091 (void**)&authenticate_serv);
2092 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2093 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2094 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2095 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2096 IAuthenticate_Release(authenticate_serv);
2097
2098 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2099 (void**)&authenticate_serv);
2100 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2101 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2102
2103 IAuthenticate_Release(authenticate);
2104 IAuthenticate_Release(authenticate_serv);
2105
2106 SET_EXPECT(OnStopBinding);
2107 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2108 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2109 CHECK_CALLED(OnStopBinding);
2110
2111 SET_EXPECT(QueryInterface_IInternetProtocol);
2112 SET_EXPECT(QueryService_IInternetProtocol);
2113 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2114 (void**)&protocol);
2115 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2116 CHECK_CALLED(QueryInterface_IInternetProtocol);
2117 CHECK_CALLED(QueryService_IInternetProtocol);
2118
2119 IServiceProvider_Release(serv_prov);
2120 return ret;
2121 }
2122
2123 static BOOL test_RegisterBindStatusCallback(void)
2124 {
2125 IBindStatusCallback *prevbsc, *clb;
2126 IBindCtx *bindctx;
2127 BOOL ret = TRUE;
2128 IUnknown *unk;
2129 HRESULT hres;
2130
2131 hres = CreateBindCtx(0, &bindctx);
2132 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2133
2134 SET_EXPECT(QueryInterface_IServiceProvider);
2135
2136 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2137 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2138
2139 SET_EXPECT(QueryInterface_IBindStatusCallback);
2140 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2141 prevbsc = (void*)0xdeadbeef;
2142 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2143 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2144 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2145 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2146 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2147
2148 CHECK_CALLED(QueryInterface_IServiceProvider);
2149
2150 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2151 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2152
2153 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2154 IUnknown_Release(unk);
2155 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2156 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2157
2158 if(!test_bscholder(clb))
2159 ret = FALSE;
2160
2161 IBindStatusCallback_Release(clb);
2162
2163 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2164 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2165
2166 unk = (void*)0xdeadbeef;
2167 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2168 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2169 ok(unk == NULL, "unk != NULL\n");
2170
2171 if(unk)
2172 IUnknown_Release(unk);
2173
2174 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2175 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2176
2177 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2178 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2179
2180 hres = RevokeBindStatusCallback(bindctx, NULL);
2181 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2182
2183 IBindCtx_Release(bindctx);
2184 return ret;
2185 }
2186
2187 #define BINDTEST_EMULATE 1
2188 #define BINDTEST_TOOBJECT 2
2189 #define BINDTEST_FILEDWLAPI 4
2190
2191 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2192 {
2193 test_protocol = protocol;
2194 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2195 download_state = BEFORE_DOWNLOAD;
2196 stopped_binding = FALSE;
2197 stopped_obj_binding = FALSE;
2198 data_available = FALSE;
2199 mime_type[0] = 0;
2200 binding_hres = S_OK;
2201 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2202 tymed = t;
2203 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2204 }
2205
2206 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
2207 {
2208 IMoniker *mon;
2209 HRESULT hres;
2210 LPOLESTR display_name;
2211 IBindCtx *bctx;
2212 MSG msg;
2213 IBindStatusCallback *previousclb;
2214 IUnknown *unk = (IUnknown*)0x00ff00ff;
2215 IBinding *bind;
2216
2217 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
2218
2219 SET_EXPECT(QueryInterface_IServiceProvider);
2220 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2221 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2222 CHECK_CALLED(QueryInterface_IServiceProvider);
2223 if(FAILED(hres))
2224 return;
2225
2226 SET_EXPECT(QueryInterface_IServiceProvider);
2227 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2228 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2229 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2230 CHECK_CALLED(QueryInterface_IServiceProvider);
2231 if(previousclb)
2232 IBindStatusCallback_Release(previousclb);
2233
2234 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2235 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2236 if(FAILED(hres)) {
2237 IBindCtx_Release(bctx);
2238 return;
2239 }
2240
2241 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2242 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2243 if(SUCCEEDED(hres))
2244 IBinding_Release(bind);
2245
2246 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2247 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2248 ok(!lstrcmpW(display_name, urls[test_protocol]),
2249 "GetDisplayName got wrong name %s\n", wine_dbgstr_w(display_name));
2250 CoTaskMemFree(display_name);
2251
2252 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2253 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2254
2255 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2256 SET_EXPECT(GetBindInfo);
2257 SET_EXPECT(QueryInterface_IInternetProtocol);
2258 if(!emulate_protocol)
2259 SET_EXPECT(QueryService_IInternetProtocol);
2260 SET_EXPECT(OnStartBinding);
2261 if(emulate_protocol) {
2262 if(is_urlmon_protocol(test_protocol))
2263 SET_EXPECT(SetPriority);
2264 SET_EXPECT(Start);
2265 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2266 SET_EXPECT(Terminate);
2267 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2268 SET_EXPECT(UnlockRequest);
2269 }else {
2270 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2271 SET_EXPECT(QueryInterface_IInternetBindInfo);
2272 SET_EXPECT(QueryService_IInternetBindInfo);
2273 SET_EXPECT(QueryInterface_IHttpNegotiate);
2274 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2275 SET_EXPECT(QueryService_IWindowForBindingUI);
2276 SET_EXPECT(BeginningTransaction);
2277 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2278 SET_EXPECT(GetRootSecurityId);
2279 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2280 SET_EXPECT(OnProgress_CONNECTING);
2281 }
2282 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
2283 || test_protocol == FILE_TEST)
2284 SET_EXPECT(OnProgress_SENDINGREQUEST);
2285 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2286 SET_EXPECT(QueryInterface_IHttpNegotiate);
2287 SET_EXPECT(OnResponse);
2288 }
2289 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2290 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2291 if(test_protocol == FILE_TEST)
2292 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2293 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST)
2294 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2295 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2296 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2297 SET_EXPECT(OnDataAvailable);
2298 SET_EXPECT(OnStopBinding);
2299 }
2300
2301 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2302 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2303 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2304 {
2305 skip("Network unreachable, skipping tests\n");
2306 return;
2307 }
2308
2309 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2310 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2311 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2312 ok(unk == NULL, "istr should be NULL\n");
2313 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2314 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2315 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2316 ok(unk == NULL, "istr should be NULL\n");
2317 }else {
2318 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2319 ok(unk != NULL, "unk == NULL\n");
2320 }
2321 if(unk)
2322 IUnknown_Release(unk);
2323
2324 if(FAILED(hres))
2325 return;
2326
2327 while((bindf & BINDF_ASYNCHRONOUS) &&
2328 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2329 TranslateMessage(&msg);
2330 DispatchMessage(&msg);
2331 }
2332
2333 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2334 CHECK_CALLED(GetBindInfo);
2335 CHECK_CALLED(QueryInterface_IInternetProtocol);
2336 if(!emulate_protocol)
2337 CHECK_CALLED(QueryService_IInternetProtocol);
2338 CHECK_CALLED(OnStartBinding);
2339 if(emulate_protocol) {
2340 if(is_urlmon_protocol(test_protocol))
2341 CHECK_CALLED(SetPriority);
2342 CHECK_CALLED(Start);
2343 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2344 if(tymed == TYMED_FILE)
2345 CLEAR_CALLED(Read);
2346 CHECK_CALLED(Terminate);
2347 }
2348 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2349 CHECK_CALLED(UnlockRequest);
2350 }else {
2351 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2352 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2353 CLEAR_CALLED(QueryService_IInternetBindInfo);
2354 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2355 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2356 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2357 CHECK_CALLED(BeginningTransaction);
2358 if (have_IHttpNegotiate2)
2359 {
2360 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2361 CHECK_CALLED(GetRootSecurityId);
2362 }
2363 if(http_is_first || test_protocol == HTTPS_TEST) {
2364 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2365 CHECK_CALLED(OnProgress_CONNECTING);
2366 }else todo_wine {
2367 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2368 /* IE7 does call this */
2369 CLEAR_CALLED(OnProgress_CONNECTING);
2370 }
2371 }
2372 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2373 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2374 else if(test_protocol == FTP_TEST)
2375 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
2376 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2377 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2378 CHECK_CALLED(OnResponse);
2379 }
2380 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2381 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2382 if(test_protocol == FILE_TEST)
2383 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2384 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST)
2385 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2386 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2387 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2388 CHECK_CALLED(OnDataAvailable);
2389 CHECK_CALLED(OnStopBinding);
2390 }
2391
2392 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2393 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2394
2395 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2396 http_is_first = FALSE;
2397 }
2398
2399 static void test_BindToObject(int protocol, BOOL emul)
2400 {
2401 IMoniker *mon;
2402 HRESULT hres;
2403 LPOLESTR display_name;
2404 IBindCtx *bctx;
2405 DWORD regid;
2406 MSG msg;
2407 IUnknown *unk = (IUnknown*)0x00ff00ff;
2408 IBinding *bind;
2409
2410 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2411
2412 if(emul)
2413 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2414 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
2415
2416 SET_EXPECT(QueryInterface_IServiceProvider);
2417 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx);
2418 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2419 CHECK_CALLED(QueryInterface_IServiceProvider);
2420 if(FAILED(hres))
2421 return;
2422
2423 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2424 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2425 if(FAILED(hres)) {
2426 IBindCtx_Release(bctx);
2427 return;
2428 }
2429
2430 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2431 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2432 if(SUCCEEDED(hres))
2433 IBinding_Release(bind);
2434
2435 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2436 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2437 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2438
2439 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2440 SET_EXPECT(Obj_GetBindInfo);
2441 SET_EXPECT(QueryInterface_IInternetProtocol);
2442 if(!emulate_protocol)
2443 SET_EXPECT(QueryService_IInternetProtocol);
2444 SET_EXPECT(Obj_OnStartBinding);
2445 if(emulate_protocol) {
2446 if(is_urlmon_protocol(test_protocol))
2447 SET_EXPECT(SetPriority);
2448 SET_EXPECT(Start);
2449 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2450 SET_EXPECT(Terminate);
2451 if(test_protocol == FILE_TEST)
2452 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2453 SET_EXPECT(UnlockRequest);
2454 }else {
2455 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2456 SET_EXPECT(QueryInterface_IHttpNegotiate);
2457 SET_EXPECT(BeginningTransaction);
2458 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2459 SET_EXPECT(GetRootSecurityId);
2460 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2461 SET_EXPECT(Obj_OnProgress_CONNECTING);
2462 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2463 SET_EXPECT(QueryService_IWindowForBindingUI);
2464 }
2465 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2466 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2467 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2468 SET_EXPECT(QueryInterface_IHttpNegotiate);
2469 SET_EXPECT(OnResponse);
2470 }
2471 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2472 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2473 if(test_protocol == FILE_TEST)
2474 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2475 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2476 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2477 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2478 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2479 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2480 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2481 SET_EXPECT(OnObjectAvailable);
2482 SET_EXPECT(Obj_OnStopBinding);
2483 }
2484
2485 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2486
2487 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2488 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2489 {
2490 skip( "Network unreachable, skipping tests\n" );
2491 return;
2492 }
2493
2494 /* no point testing the calls if binding didn't even work */
2495 if (FAILED(hres)) return;
2496
2497 if(bindf & BINDF_ASYNCHRONOUS) {
2498 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2499 ok(unk == NULL, "istr should be NULL\n");
2500 }else {
2501 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2502 ok(unk != NULL, "unk == NULL\n");
2503 if(emul)
2504 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2505 }
2506 if(unk)
2507 IUnknown_Release(unk);
2508
2509 while((bindf & BINDF_ASYNCHRONOUS) &&
2510 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2511 TranslateMessage(&msg);
2512 DispatchMessage(&msg);
2513 }
2514
2515 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
2516 CHECK_CALLED(Obj_GetBindInfo);
2517 CHECK_CALLED(QueryInterface_IInternetProtocol);
2518 if(!emulate_protocol)
2519 CHECK_CALLED(QueryService_IInternetProtocol);
2520 CHECK_CALLED(Obj_OnStartBinding);
2521 if(emulate_protocol) {
2522 if(is_urlmon_protocol(test_protocol))
2523 CHECK_CALLED(SetPriority);
2524 CHECK_CALLED(Start);
2525 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2526 CHECK_CALLED(Terminate);
2527 if(test_protocol == FILE_TEST)
2528 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2529 CHECK_CALLED(UnlockRequest);
2530 }else {
2531 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2532 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2533 CHECK_CALLED(BeginningTransaction);
2534 if (have_IHttpNegotiate2)
2535 {
2536 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2537 CHECK_CALLED(GetRootSecurityId);
2538 }
2539 if(http_is_first) {
2540 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2541 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2542 }else todo_wine {
2543 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2544 /* IE7 does call this */
2545 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2546 }
2547 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2548 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2549 }
2550 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
2551 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2552 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2553 else
2554 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2555 }
2556 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2557 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2558 CHECK_CALLED(OnResponse);
2559 }
2560 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2561 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2562 if(test_protocol == FILE_TEST)
2563 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2564 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2565 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2566 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2567 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2568 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2569 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2570 CHECK_CALLED(OnObjectAvailable);
2571 CHECK_CALLED(Obj_OnStopBinding);
2572 }
2573
2574 if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL || !(bindf & BINDF_ASYNCHRONOUS)) {
2575 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2576 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2577 }else {
2578 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2579 IBindCtx_Release(bctx);
2580 }
2581
2582 if(emul)
2583 CoRevokeClassObject(regid);
2584
2585 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2586 http_is_first = FALSE;
2587 }
2588
2589 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2590 {
2591 BOOL res;
2592 HRESULT hres;
2593
2594 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2595
2596 SET_EXPECT(GetBindInfo);
2597 SET_EXPECT(QueryInterface_IInternetProtocol);
2598 if(!emulate_protocol) {
2599 SET_EXPECT(QueryInterface_IServiceProvider);
2600 SET_EXPECT(QueryService_IInternetProtocol);
2601 }
2602 SET_EXPECT(OnStartBinding);
2603 if(emulate_protocol) {
2604 if(is_urlmon_protocol(test_protocol))
2605 SET_EXPECT(SetPriority);
2606 SET_EXPECT(Start);
2607 SET_EXPECT(UnlockRequest);
2608 }else {
2609 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2610 SET_EXPECT(QueryInterface_IHttpNegotiate);
2611 SET_EXPECT(BeginningTransaction);
2612 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2613 SET_EXPECT(GetRootSecurityId);
2614 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2615 }
2616 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2617 SET_EXPECT(OnProgress_SENDINGREQUEST);
2618 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2619 SET_EXPECT(QueryInterface_IHttpNegotiate);
2620 SET_EXPECT(OnResponse);
2621 }
2622 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2623 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2624 if(test_protocol == FILE_TEST)
2625 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2626 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2627 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2628 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2629 SET_EXPECT(OnStopBinding);
2630 }
2631
2632 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol],
2633 dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
2634 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2635
2636 CHECK_CALLED(GetBindInfo);
2637 CHECK_CALLED(QueryInterface_IInternetProtocol);
2638 if(!emulate_protocol) {
2639 CHECK_CALLED(QueryInterface_IServiceProvider);
2640 CHECK_CALLED(QueryService_IInternetProtocol);
2641 }
2642 CHECK_CALLED(OnStartBinding);
2643 if(emulate_protocol) {
2644 if(is_urlmon_protocol(test_protocol))
2645 CHECK_CALLED(SetPriority);
2646 CHECK_CALLED(Start);
2647 CHECK_CALLED(UnlockRequest);
2648 }else {
2649 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2650 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2651 CHECK_CALLED(BeginningTransaction);
2652 if (have_IHttpNegotiate2)
2653 {
2654 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2655 CHECK_CALLED(GetRootSecurityId);
2656 }
2657 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2658 }
2659 if(test_protocol == FILE_TEST)
2660 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2661 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2662 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2663 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2664 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2665 CHECK_CALLED(OnResponse);
2666 }
2667 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2668 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2669 if(test_protocol == FILE_TEST)
2670 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2671 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2672 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2673 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2674 CHECK_CALLED(OnStopBinding);
2675 }
2676
2677 res = DeleteFileA(dwl_htmlA);
2678 ok(res, "DeleteFile failed: %u\n", GetLastError());
2679
2680 if(prot != FILE_TEST || emul)
2681 return;
2682
2683 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2684 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2685
2686 res = DeleteFileA(dwl_htmlA);
2687 ok(res, "DeleteFile failed: %u\n", GetLastError());
2688 }
2689
2690 static void set_file_url(char *path)
2691 {
2692 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2693 CHAR INDEX_HTMLA[MAX_PATH];
2694
2695 lstrcpyA(file_urlA, "file:///");
2696 lstrcatA(file_urlA, path);
2697 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2698
2699 lstrcpyA(INDEX_HTMLA, "file://");
2700 lstrcatA(INDEX_HTMLA, path);
2701 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2702 }
2703
2704 static void create_file(void)
2705 {
2706 HANDLE file;
2707 DWORD size;
2708 CHAR path[MAX_PATH];
2709
2710 static const char html_doc[] = "<HTML></HTML>";
2711
2712 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2713 FILE_ATTRIBUTE_NORMAL, NULL);
2714 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2715 if(file == INVALID_HANDLE_VALUE)
2716 return;
2717
2718 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2719 CloseHandle(file);
2720
2721 GetCurrentDirectoryA(MAX_PATH, path);
2722 lstrcatA(path, "\\");
2723 lstrcatA(path, wszIndexHtmlA);
2724 set_file_url(path);
2725 }
2726
2727 static void test_ReportResult(HRESULT exhres)
2728 {
2729 IMoniker *mon = NULL;
2730 IBindCtx *bctx = NULL;
2731 IUnknown *unk = (void*)0xdeadbeef;
2732 HRESULT hres;
2733
2734 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2735 binding_hres = exhres;
2736
2737 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2738 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2739
2740 SET_EXPECT(QueryInterface_IServiceProvider);
2741 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2742 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2743 CHECK_CALLED(QueryInterface_IServiceProvider);
2744
2745 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2746 SET_EXPECT(GetBindInfo);
2747 SET_EXPECT(QueryInterface_IInternetProtocol);
2748 SET_EXPECT(OnStartBinding);
2749 if(is_urlmon_protocol(test_protocol))
2750 SET_EXPECT(SetPriority);
2751 SET_EXPECT(Start);
2752
2753 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2754 if(SUCCEEDED(exhres))
2755 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2756 else
2757 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2758 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2759
2760 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2761 CHECK_CALLED(GetBindInfo);
2762 CHECK_CALLED(QueryInterface_IInternetProtocol);
2763 CHECK_CALLED(OnStartBinding);
2764 if(is_urlmon_protocol(test_protocol))
2765 CHECK_CALLED(SetPriority);
2766 CHECK_CALLED(Start);
2767
2768 ok(unk == NULL, "unk=%p\n", unk);
2769
2770 IBindCtx_Release(bctx);
2771 IMoniker_Release(mon);
2772 }
2773
2774 static void test_BindToStorage_fail(void)
2775 {
2776 IMoniker *mon = NULL;
2777 IBindCtx *bctx = NULL;
2778 IUnknown *unk;
2779 HRESULT hres;
2780
2781 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2782 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2783 if(FAILED(hres))
2784 return;
2785
2786 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2787 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2788
2789 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2790 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2791 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2792
2793 IBindCtx_Release(bctx);
2794
2795 IMoniker_Release(mon);
2796
2797 test_ReportResult(E_NOTIMPL);
2798 test_ReportResult(S_FALSE);
2799 }
2800
2801 static void test_StdURLMoniker(void)
2802 {
2803 IMoniker *mon, *async_mon;
2804 LPOLESTR display_name;
2805 HRESULT hres;
2806
2807 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2808 &IID_IMoniker, (void**)&mon);
2809 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
2810 if(FAILED(hres))
2811 return;
2812
2813 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
2814 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
2815 ok(mon == async_mon, "mon != async_mon\n");
2816 IMoniker_Release(async_mon);
2817
2818 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
2819 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
2820
2821 IMoniker_Release(mon);
2822 }
2823
2824 static void gecko_installer_workaround(BOOL disable)
2825 {
2826 HKEY hkey;
2827 DWORD res;
2828
2829 static BOOL has_url = FALSE;
2830 static char url[2048];
2831
2832 if(!disable && !has_url)
2833 return;
2834
2835 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2836 if(res != ERROR_SUCCESS)
2837 return;
2838
2839 if(disable) {
2840 DWORD type, size = sizeof(url);
2841
2842 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2843 if(res == ERROR_SUCCESS && type == REG_SZ)
2844 has_url = TRUE;
2845
2846 RegDeleteValue(hkey, "GeckoUrl");
2847 }else {
2848 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2849 }
2850
2851 RegCloseKey(hkey);
2852 }
2853
2854 START_TEST(url)
2855 {
2856 gecko_installer_workaround(TRUE);
2857
2858 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2859 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2860 thread_id = GetCurrentThreadId();
2861 create_file();
2862
2863 test_create();
2864
2865 trace("test CreateAsyncBindCtx...\n");
2866 test_CreateAsyncBindCtx();
2867
2868 trace("test CreateAsyncBindCtxEx...\n");
2869 test_CreateAsyncBindCtxEx();
2870
2871 trace("test RegisterBindStatusCallback...\n");
2872 if(test_RegisterBindStatusCallback()) {
2873 trace("test BindToStorage failures...\n");
2874 test_BindToStorage_fail();
2875
2876 trace("synchronous http test (COM not initialised)...\n");
2877 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2878
2879 CoInitialize(NULL);
2880
2881 trace("test StdURLMoniker...\n");
2882 test_StdURLMoniker();
2883
2884 trace("synchronous http test...\n");
2885 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2886
2887 trace("synchronous http test (to object)...\n");
2888 test_BindToObject(HTTP_TEST, FALSE);
2889
2890 trace("synchronous file test...\n");
2891 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2892
2893 trace("synchronous file test (to object)...\n");
2894 test_BindToObject(FILE_TEST, FALSE);
2895
2896 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2897
2898 trace("http test...\n");
2899 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2900
2901 trace("http test (to file)...\n");
2902 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2903
2904 trace("http test (to object)...\n");
2905 test_BindToObject(HTTP_TEST, FALSE);
2906
2907 trace("http test (short response)...\n");
2908 http_is_first = TRUE;
2909 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2910 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2911
2912 trace("http test (short response, to object)...\n");
2913 test_BindToObject(HTTP_TEST, FALSE);
2914
2915 trace("emulated http test...\n");
2916 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2917
2918 trace("emulated http test (to object)...\n");
2919 test_BindToObject(HTTP_TEST, TRUE);
2920
2921 trace("emulated http test (to file)...\n");
2922 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2923
2924 trace("asynchronous https test...\n");
2925 test_BindToStorage(HTTPS_TEST, FALSE, TYMED_ISTREAM);
2926
2927 trace("emulated https test...\n");
2928 test_BindToStorage(HTTPS_TEST, TRUE, TYMED_ISTREAM);
2929
2930 trace("about test...\n");
2931 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2932
2933 trace("about test (to file)...\n");
2934 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2935
2936 trace("about test (to object)...\n");
2937 test_BindToObject(ABOUT_TEST, FALSE);
2938
2939 trace("emulated about test...\n");
2940 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2941
2942 trace("emulated about test (to file)...\n");
2943 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2944
2945 trace("emulated about test (to object)...\n");
2946 test_BindToObject(ABOUT_TEST, TRUE);
2947
2948 trace("file test...\n");
2949 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2950
2951 trace("file test (to file)...\n");
2952 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2953
2954 trace("file test (to object)...\n");
2955 test_BindToObject(FILE_TEST, FALSE);
2956
2957 trace("emulated file test...\n");
2958 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2959
2960 trace("emulated file test (to file)...\n");
2961 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2962
2963 trace("emulated file test (to object)...\n");
2964 test_BindToObject(FILE_TEST, TRUE);
2965
2966 trace("emulated its test...\n");
2967 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2968
2969 trace("emulated its test (to file)...\n");
2970 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2971
2972 trace("emulated mk test...\n");
2973 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2974
2975 trace("test URLDownloadToFile for file protocol...\n");
2976 test_URLDownloadToFile(FILE_TEST, FALSE);
2977
2978 trace("test URLDownloadToFile for emulated file protocol...\n");
2979 test_URLDownloadToFile(FILE_TEST, TRUE);
2980
2981 trace("test URLDownloadToFile for http protocol...\n");
2982 test_URLDownloadToFile(HTTP_TEST, FALSE);
2983
2984 bindf |= BINDF_NOWRITECACHE;
2985
2986 trace("ftp test...\n");
2987 test_BindToStorage(FTP_TEST, FALSE, TYMED_ISTREAM);
2988
2989 trace("test failures...\n");
2990 test_BindToStorage_fail();
2991 }
2992
2993 DeleteFileA(wszIndexHtmlA);
2994 CloseHandle(complete_event);
2995 CloseHandle(complete_event2);
2996 CoUninitialize();
2997
2998 gecko_installer_workaround(FALSE);
2999 }