[URLMON_WINETEST]
[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 static HRESULT (WINAPI *pCreateAsyncBindCtxEx)(IBindCtx *, DWORD,
39 IBindStatusCallback *, IEnumFORMATETC *, IBindCtx **, DWORD);
40 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
41
42 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
43 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
44 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
45
46 #define DEFINE_EXPECT(func) \
47 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
48
49 #define SET_EXPECT(func) \
50 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
51
52 #define CHECK_EXPECT2(func) \
53 do { \
54 ok(expect_ ##func, "unexpected call " #func "\n"); \
55 called_ ## func = TRUE; \
56 }while(0)
57
58 #define CHECK_EXPECT(func) \
59 do { \
60 CHECK_EXPECT2(func); \
61 expect_ ## func = FALSE; \
62 }while(0)
63
64 #define CHECK_CALLED(func) \
65 do { \
66 ok(called_ ## func, "expected " #func "\n"); \
67 expect_ ## func = called_ ## func = FALSE; \
68 }while(0)
69
70 #define CHECK_NOT_CALLED(func) \
71 do { \
72 ok(!called_ ## func, "unexpected " #func "\n"); \
73 expect_ ## func = called_ ## func = FALSE; \
74 }while(0)
75
76 #define CHECK_CALLED_BROKEN(func) \
77 do { \
78 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
79 expect_ ## func = called_ ## func = FALSE; \
80 }while(0)
81
82 #define CLEAR_CALLED(func) \
83 expect_ ## func = called_ ## func = FALSE
84
85 DEFINE_EXPECT(QueryInterface_IServiceProvider);
86 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
87 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
88 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
89 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
90 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
91 DEFINE_EXPECT(QueryInterface_IAuthenticate);
92 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
93 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI);
94 DEFINE_EXPECT(QueryInterface_IHttpSecurity);
95 DEFINE_EXPECT(QueryService_IAuthenticate);
96 DEFINE_EXPECT(QueryService_IInternetProtocol);
97 DEFINE_EXPECT(QueryService_IInternetBindInfo);
98 DEFINE_EXPECT(QueryService_IWindowForBindingUI);
99 DEFINE_EXPECT(QueryService_IHttpSecurity);
100 DEFINE_EXPECT(BeginningTransaction);
101 DEFINE_EXPECT(OnResponse);
102 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
103 DEFINE_EXPECT(GetRootSecurityId);
104 DEFINE_EXPECT(GetBindInfo);
105 DEFINE_EXPECT(GetBindInfoEx);
106 DEFINE_EXPECT(OnStartBinding);
107 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
108 DEFINE_EXPECT(OnProgress_CONNECTING);
109 DEFINE_EXPECT(OnProgress_REDIRECTING);
110 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
111 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
112 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
113 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
114 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
115 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
116 DEFINE_EXPECT(OnStopBinding);
117 DEFINE_EXPECT(OnDataAvailable);
118 DEFINE_EXPECT(OnObjectAvailable);
119 DEFINE_EXPECT(Obj_OnStartBinding);
120 DEFINE_EXPECT(Obj_OnStopBinding);
121 DEFINE_EXPECT(Obj_GetBindInfo);
122 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
123 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
124 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
125 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
126 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
127 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
128 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
129 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
130 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
131 DEFINE_EXPECT(Obj_OnProgress_REDIRECTING);
132 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
133 DEFINE_EXPECT(Start);
134 DEFINE_EXPECT(Read);
135 DEFINE_EXPECT(LockRequest);
136 DEFINE_EXPECT(Terminate);
137 DEFINE_EXPECT(UnlockRequest);
138 DEFINE_EXPECT(Continue);
139 DEFINE_EXPECT(Abort);
140 DEFINE_EXPECT(CreateInstance);
141 DEFINE_EXPECT(Load);
142 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
143 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
144 DEFINE_EXPECT(SetPriority);
145 DEFINE_EXPECT(GetWindow_IHttpSecurity);
146 DEFINE_EXPECT(GetWindow_IWindowForBindingUI);
147 DEFINE_EXPECT(OnSecurityProblem);
148
149 static const WCHAR winetest_data_urlW[] =
150 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
151 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
152
153 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','s','/','d','a','t','a','.','p','h','p','\0'};
154
155 static const WCHAR winetest_post_urlW[] =
156 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
157 't','e','s','t','s','/','p','o','s','t','.','p','h','p',0};
158 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
159 static WCHAR INDEX_HTML[MAX_PATH];
160 static const WCHAR ITS_URL[] =
161 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
162 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
163 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
164 static const WCHAR https_urlW[] =
165 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
166 '/','t','e','s','t','.','h','t','m','l',0};
167 static const WCHAR https_invalid_cn_urlW[] =
168 {'h','t','t','p','s',':','/','/','2','0','9','.','4','6','.','2','5','.','1','3','2',
169 '/','t','e','s','t','.','h','t','m','l',0};
170 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
171 '/','p','u','b','/','o','t','h','e','r','/',
172 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
173 static const WCHAR winetest_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
174
175
176 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
177
178 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
179
180 static const WCHAR wszWineHQSite[] =
181 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
182 static const WCHAR wszWineHQIP[] =
183 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
184 static const CHAR wszIndexHtmlA[] = "index.html";
185 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
186 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
187 static const CHAR dwl_htmlA[] = "dwl.html";
188 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
189 static const CHAR test_txtA[] = "test.txt";
190 static const WCHAR emptyW[] = {0};
191
192 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
193 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
194 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed, security_problem;
195 static CHAR mime_type[512];
196 static IInternetProtocolSink *protocol_sink = NULL;
197 static IBinding *current_binding;
198 static HANDLE complete_event, complete_event2;
199 static HRESULT binding_hres;
200 static HRESULT onsecurityproblem_hres;
201 static HRESULT abort_hres;
202 static BOOL have_IHttpNegotiate2, use_bscex, is_async_prot;
203 static BOOL test_redirect, use_cache_file, callback_read, no_callback, test_abort;
204 static WCHAR cache_file_name[MAX_PATH];
205 static BOOL only_check_prot_args = FALSE;
206 static BOOL invalid_cn_accepted = FALSE;
207 static BOOL abort_start = FALSE;
208 static BOOL abort_progress = FALSE;
209
210 static LPCWSTR urls[] = {
211 winetest_data_urlW,
212 ABOUT_BLANK,
213 INDEX_HTML,
214 ITS_URL,
215 MK_URL,
216 https_urlW,
217 ftp_urlW,
218 winetest_urlW
219 };
220
221 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
222
223 static enum {
224 HTTP_TEST,
225 ABOUT_TEST,
226 FILE_TEST,
227 ITS_TEST,
228 MK_TEST,
229 HTTPS_TEST,
230 FTP_TEST,
231 WINETEST_TEST
232 } test_protocol;
233
234 static enum {
235 BEFORE_DOWNLOAD,
236 DOWNLOADING,
237 END_DOWNLOAD
238 } download_state;
239
240 static const char *debugstr_guid(REFIID riid)
241 {
242 static char buf[50];
243
244 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
245 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
246 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
247 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
248
249 return buf;
250 }
251
252 static BOOL proxy_active(void)
253 {
254 HKEY internet_settings;
255 DWORD proxy_enable;
256 DWORD size;
257
258 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
259 0, KEY_QUERY_VALUE, &internet_settings) != ERROR_SUCCESS)
260 return FALSE;
261
262 size = sizeof(DWORD);
263 if (RegQueryValueExA(internet_settings, "ProxyEnable", NULL, NULL, (LPBYTE) &proxy_enable, &size) != ERROR_SUCCESS)
264 proxy_enable = 0;
265
266 RegCloseKey(internet_settings);
267
268 return proxy_enable != 0;
269 }
270
271 static BOOL is_urlmon_protocol(int prot)
272 {
273 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
274 }
275
276 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
277 {
278 HRESULT hr;
279 IMoniker *mon1 = NULL;
280 IMoniker *mon2 = NULL;
281
282 hr = CreateURLMoniker(NULL, NULL, NULL);
283 ok(hr == E_INVALIDARG,
284 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
285
286 mon1 = (IMoniker *)0xdeadbeef;
287 hr = CreateURLMoniker(NULL, NULL, &mon1);
288 ok(hr == E_INVALIDARG,
289 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
290 ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1);
291
292 hr = CreateURLMoniker(NULL, emptyW, NULL);
293 ok(hr == E_INVALIDARG,
294 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
295
296 hr = CreateURLMoniker(NULL, emptyW, &mon1);
297 ok(hr == S_OK ||
298 broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */
299 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr);
300 if(mon1) IMoniker_Release(mon1);
301
302 hr = CreateURLMoniker(NULL, url1, &mon1);
303 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
304 if(hr == S_OK) {
305 hr = CreateURLMoniker(mon1, url2, &mon2);
306 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
307 }
308 if(mon1) IMoniker_Release(mon1);
309 if(mon2) IMoniker_Release(mon2);
310 }
311
312 static void test_create(void)
313 {
314 static const WCHAR relativeW[] = {'a','/','b','.','t','x','t',0};
315 IStream *stream;
316 IMoniker *mon;
317 IBindCtx *bctx;
318 HRESULT hr;
319
320 test_CreateURLMoniker(winetest_data_urlW, TEST_PART_URL_1);
321
322 mon = (void*)0xdeadbeef;
323 hr = CreateURLMoniker(NULL, relativeW, &mon);
324 ok(hr == S_OK, "got 0x%08x\n", hr);
325
326 hr = CreateBindCtx(0, &bctx);
327
328 stream = (void*)0xdeadbeef;
329 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&stream);
330 todo_wine ok(hr == INET_E_UNKNOWN_PROTOCOL, "got 0x%08x\n", hr);
331 ok(stream == NULL, "got %p\n", stream);
332
333 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
334 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
335
336 stream = (void*)0xdeadbeef;
337 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
338 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
339 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
340 "got %p\n", stream);
341
342 IMoniker_Release(mon);
343
344 mon = (void*)0xdaedbeef;
345 hr = CreateURLMoniker(NULL, winetest_data_urlW, &mon);
346 ok(hr == S_OK, "got 0x%08x\n", hr);
347
348 stream = (void*)0xdeadbeef;
349 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
350 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
351 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
352 "got %p\n", stream);
353
354 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
355 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
356
357 IMoniker_Release(mon);
358 IBindCtx_Release(bctx);
359 }
360
361 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
362 {
363 ok(0, "unexpected call\n");
364 return E_NOINTERFACE;
365 }
366
367 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
368 {
369 return 2;
370 }
371
372 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
373 {
374 return 1;
375 }
376
377 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
378 {
379 CHECK_EXPECT(SetPriority);
380 ok(!nPriority, "nPriority = %d\n", nPriority);
381 return S_OK;
382 }
383
384 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
385 {
386 ok(0, "unexpected call\n");
387 return S_OK;
388 }
389
390 static const IInternetPriorityVtbl InternetPriorityVtbl = {
391 Priority_QueryInterface,
392 Priority_AddRef,
393 Priority_Release,
394 Priority_SetPriority,
395 Priority_GetPriority
396 };
397
398 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
399
400 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
401 {
402 *ppv = NULL;
403
404 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
405 *ppv = iface;
406 return S_OK;
407 }
408
409 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
410 if(!is_urlmon_protocol(test_protocol))
411 return E_NOINTERFACE;
412
413 *ppv = &InternetPriority;
414 return S_OK;
415 }
416
417 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
418 return E_NOINTERFACE; /* TODO */
419
420 ok(0, "unexpected call %s\n", debugstr_guid(riid));
421 return E_NOINTERFACE;
422 }
423
424 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
425 {
426 return 2;
427 }
428
429 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
430 {
431 return 1;
432 }
433
434 static void test_switch_fail(void)
435 {
436 IInternetProtocolSink *binding_sink;
437 PROTOCOLDATA protocoldata;
438 HRESULT hres;
439
440 static BOOL tested_switch_fail;
441
442 if(tested_switch_fail)
443 return;
444
445 tested_switch_fail = TRUE;
446
447 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
448 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
449 if(SUCCEEDED(hres)) {
450 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
451 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
452 IInternetProtocolSink_Release(binding_sink);
453 }
454 }
455
456 static DWORD WINAPI thread_proc(PVOID arg)
457 {
458 PROTOCOLDATA protocoldata;
459 HRESULT hres;
460
461 if(!no_callback) {
462 if(bind_to_object)
463 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
464 else
465 SET_EXPECT(OnProgress_FINDINGRESOURCE);
466 }
467 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
468 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
469 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
470 if(!no_callback) {
471 WaitForSingleObject(complete_event, INFINITE);
472 if(bind_to_object)
473 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
474 else
475 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
476 }
477
478 if(!no_callback) {
479 if(bind_to_object)
480 SET_EXPECT(Obj_OnProgress_CONNECTING);
481 else
482 SET_EXPECT(OnProgress_CONNECTING);
483 }
484 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
485 BINDSTATUS_CONNECTING, wszWineHQIP);
486 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
487 if(!no_callback) {
488 WaitForSingleObject(complete_event, INFINITE);
489 if(bind_to_object)
490 CHECK_CALLED(Obj_OnProgress_CONNECTING);
491 else
492 CHECK_CALLED(OnProgress_CONNECTING);
493 }
494
495 if(!no_callback) {
496 if(bind_to_object)
497 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
498 else
499 SET_EXPECT(OnProgress_SENDINGREQUEST);
500 }
501 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
502 BINDSTATUS_SENDINGREQUEST, NULL);
503 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
504 if(!no_callback) {
505 WaitForSingleObject(complete_event, INFINITE);
506 if(bind_to_object)
507 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
508 else
509 CHECK_CALLED(OnProgress_SENDINGREQUEST);
510 }
511
512 if(test_redirect) {
513 if(bind_to_object)
514 SET_EXPECT(Obj_OnProgress_REDIRECTING);
515 else
516 SET_EXPECT(OnProgress_REDIRECTING);
517 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_REDIRECTING, winetest_data_urlW);
518 ok(hres == S_OK, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres);
519 WaitForSingleObject(complete_event, INFINITE);
520 if(bind_to_object)
521 CHECK_CALLED(Obj_OnProgress_REDIRECTING);
522 else
523 CHECK_CALLED(OnProgress_REDIRECTING);
524 }
525
526 test_switch_fail();
527
528 SET_EXPECT(Continue);
529 prot_state = 1;
530 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
531 ok(hres == S_OK, "Switch failed: %08x\n", hres);
532 WaitForSingleObject(complete_event, INFINITE);
533
534 CHECK_CALLED(Continue);
535 CHECK_CALLED(Read);
536 if(bind_to_object) {
537 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
538 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
539 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
540 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
541 CHECK_CALLED(CreateInstance);
542 CHECK_CALLED(PutProperty_MIMETYPEPROP);
543 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
544 CHECK_CALLED(Load);
545 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
546 CHECK_CALLED(OnObjectAvailable);
547 CHECK_CALLED(Obj_OnStopBinding);
548 }else if(!no_callback) {
549 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
550 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
551 CHECK_CALLED(OnDataAvailable);
552 }else {
553 CHECK_CALLED(LockRequest);
554 }
555
556 SET_EXPECT(Continue);
557 prot_state = 2;
558 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
559 ok(hres == S_OK, "Switch failed: %08x\n", hres);
560 WaitForSingleObject(complete_event, INFINITE);
561 CHECK_CALLED(Continue);
562 if(test_abort) {
563 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
564 CHECK_CALLED(OnStopBinding);
565 SetEvent(complete_event2);
566 return 0;
567 }else {
568 CHECK_CALLED(Read);
569 if(!no_callback) {
570 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
571 CHECK_CALLED(OnDataAvailable);
572 }
573 }
574
575 SET_EXPECT(Continue);
576 prot_state = 2;
577 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
578 ok(hres == S_OK, "Switch failed: %08x\n", hres);
579 WaitForSingleObject(complete_event, INFINITE);
580 CHECK_CALLED(Continue);
581 CHECK_CALLED(Read);
582 if(!no_callback) {
583 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
584 CHECK_CALLED(OnDataAvailable);
585 }
586
587 SET_EXPECT(Continue);
588 prot_state = 3;
589 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
590 ok(hres == S_OK, "Switch failed: %08x\n", hres);
591 WaitForSingleObject(complete_event, INFINITE);
592 CHECK_CALLED(Continue);
593 CHECK_CALLED(Read);
594 if(!no_callback) {
595 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
596 CHECK_CALLED(OnDataAvailable);
597 CHECK_CALLED(OnStopBinding);
598 }
599
600 SET_EXPECT(Read);
601
602 SetEvent(complete_event2);
603 return 0;
604 }
605
606 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
607 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
608 DWORD grfPI, HANDLE_PTR dwReserved)
609 {
610 BINDINFO bindinfo;
611 DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
612 HRESULT hres;
613
614 static const STGMEDIUM stgmed_zero = {0};
615 static const SECURITY_ATTRIBUTES sa_zero = {0};
616
617 CHECK_EXPECT(Start);
618
619 read = 0;
620
621 if(!filedwl_api) /* FIXME */
622 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", wine_dbgstr_w(szUrl));
623 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
624 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
625 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
626 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
627
628 if(!filedwl_api && binding_hres != S_OK) {
629 SET_EXPECT(OnStopBinding);
630 SET_EXPECT(Terminate);
631 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
632 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
633 CHECK_CALLED(OnStopBinding);
634 CHECK_CALLED(Terminate);
635
636 return S_OK;
637 }
638
639 memset(&bindinfo, 0, sizeof(bindinfo));
640 bindinfo.cbSize = sizeof(bindinfo);
641 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
642 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
643
644 ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n");
645
646 if(filedwl_api || !is_urlmon_protocol(test_protocol) || tymed != TYMED_ISTREAM ||
647 !(bindf&BINDF_ASYNCSTORAGE) || !(bindf&BINDF_PULLDATA))
648 ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n");
649 else
650 ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n");
651
652 bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON);
653 if(filedwl_api || no_callback)
654 ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info);
655 else
656 ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n",
657 bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)));
658
659 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
660 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
661 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
662 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
663 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
664 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
665 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
666 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
667 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
668 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
669 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
670 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
671 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
672 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
673
674 if(only_check_prot_args)
675 return E_FAIL;
676
677 switch(test_protocol) {
678 case MK_TEST:
679 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
680 BINDSTATUS_DIRECTBIND, NULL);
681 ok(hres == S_OK,
682 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
683
684 case FILE_TEST:
685 case ITS_TEST:
686 if(bind_to_object)
687 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
688 else
689 SET_EXPECT(OnProgress_SENDINGREQUEST);
690 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
691 BINDSTATUS_SENDINGREQUEST, emptyW);
692 ok(hres == S_OK,
693 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
694 if(bind_to_object)
695 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
696 else
697 CHECK_CALLED(OnProgress_SENDINGREQUEST);
698 default:
699 break;
700 }
701
702 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
703 IServiceProvider *service_provider;
704 IHttpNegotiate *http_negotiate;
705 IHttpNegotiate2 *http_negotiate2;
706 IHttpSecurity *http_security;
707 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
708 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
709 BYTE sec_id[100];
710 DWORD fetched = 256, size = 100;
711 DWORD tid;
712
713 static const WCHAR wszMimes[] = {'*','/','*',0};
714
715 SET_EXPECT(QueryInterface_IInternetBindInfo);
716 SET_EXPECT(QueryService_IInternetBindInfo);
717 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
718 &ua, 1, &fetched);
719 CLEAR_CALLED(QueryInterface_IInternetBindInfo); /* IE <8 */
720 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
721
722 ok(hres == E_NOINTERFACE,
723 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
724 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
725 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
726
727 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
728 accept_mimes, 256, &fetched);
729 ok(hres == S_OK,
730 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
731 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
732 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
733 CoTaskMemFree(accept_mimes[0]);
734
735 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
736 NULL, 256, &fetched);
737 ok(hres == E_INVALIDARG,
738 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
739
740 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
741 accept_mimes, 256, NULL);
742 ok(hres == E_INVALIDARG,
743 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
744
745 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
746 (void**)&service_provider);
747 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
748
749 SET_EXPECT(QueryInterface_IHttpNegotiate);
750 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
751 &IID_IHttpNegotiate, (void**)&http_negotiate);
752 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
753 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
754
755 if(!no_callback) {
756 SET_EXPECT(BeginningTransaction);
757 SET_EXPECT(QueryInterface_IHttpNegotiate);
758 }
759 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
760 NULL, 0, &additional_headers);
761 if(!no_callback) {
762 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
763 CHECK_CALLED(BeginningTransaction);
764 }
765 IHttpNegotiate_Release(http_negotiate);
766 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
767 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
768
769 SET_EXPECT(QueryInterface_IHttpNegotiate2);
770 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
771 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
772 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
773 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
774
775 size = 512;
776 if(!no_callback) {
777 SET_EXPECT(QueryInterface_IHttpNegotiate2);
778 SET_EXPECT(GetRootSecurityId);
779 }
780 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
781 if(!no_callback) {
782 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
783 CHECK_CALLED(GetRootSecurityId);
784 }
785 IHttpNegotiate2_Release(http_negotiate2);
786 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
787 ok(size == no_callback ? 512 : 13, "size=%d\n", size);
788
789 if(!no_callback) {
790 SET_EXPECT(QueryService_IHttpSecurity);
791 SET_EXPECT(QueryInterface_IHttpSecurity);
792 }
793 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpSecurity,
794 &IID_IHttpSecurity, (void**)&http_security);
795 ok(hres == (no_callback ? E_NOINTERFACE : S_OK), "QueryService failed: 0x%08x\n", hres);
796 if(!no_callback) {
797 CHECK_CALLED(QueryService_IHttpSecurity);
798 CHECK_CALLED(QueryInterface_IHttpSecurity);
799 }
800
801 IServiceProvider_Release(service_provider);
802
803 IInternetProtocolSink_AddRef(pOIProtSink);
804 protocol_sink = pOIProtSink;
805 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
806
807 return S_OK;
808 }
809
810 if(test_protocol == FILE_TEST) {
811 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
812 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
813 ok(hres == S_OK,
814 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
815
816 if(bind_to_object)
817 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
818 else
819 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
820 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
821 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
822 ok(hres == S_OK,
823 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
824 if(bind_to_object)
825 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
826 else
827 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
828 }else {
829 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
830 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
831 ok(hres == S_OK,
832 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
833 }
834
835 if(test_protocol == ABOUT_TEST)
836 bscf |= BSCF_DATAFULLYAVAILABLE;
837 if(test_protocol == ITS_TEST)
838 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
839
840 SET_EXPECT(Read);
841 if(bind_to_object) {
842 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
843 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
844 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
845 if(test_protocol == FILE_TEST)
846 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
847 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
848 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
849 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
850 SET_EXPECT(CreateInstance);
851 SET_EXPECT(PutProperty_MIMETYPEPROP);
852 SET_EXPECT(PutProperty_CLASSIDPROP);
853 SET_EXPECT(Load);
854 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
855 SET_EXPECT(OnObjectAvailable);
856 SET_EXPECT(Obj_OnStopBinding);
857 }else {
858 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
859 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
860 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
861 if(test_protocol == FILE_TEST)
862 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
863 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
864 SET_EXPECT(LockRequest);
865 if(!filedwl_api)
866 SET_EXPECT(OnDataAvailable);
867 SET_EXPECT(OnStopBinding);
868 }
869
870 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
871 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
872
873 CHECK_CALLED(Read);
874 if(bind_to_object) {
875 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
876 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
877 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
878 if(test_protocol == FILE_TEST)
879 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
880 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
881 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
882 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
883 CHECK_CALLED(CreateInstance);
884 CHECK_CALLED(PutProperty_MIMETYPEPROP);
885 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
886 CHECK_CALLED(Load);
887 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
888 CHECK_CALLED(OnObjectAvailable);
889 CHECK_CALLED(Obj_OnStopBinding);
890 }else {
891 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
892 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
893 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
894 if(test_protocol == FILE_TEST)
895 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
896 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
897 CHECK_CALLED(LockRequest);
898 if(!filedwl_api)
899 CHECK_CALLED(OnDataAvailable);
900 CHECK_CALLED(OnStopBinding);
901 }
902
903 if(test_protocol == ITS_TEST) {
904 SET_EXPECT(Read);
905 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
906 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
907 CHECK_CALLED(Read);
908 }else if(!bind_to_object && test_protocol == ABOUT_TEST) {
909 SET_EXPECT(Read);
910 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
911 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
912 CHECK_CALLED(Read);
913 }
914
915 SET_EXPECT(Terminate);
916 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
917 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
918 CHECK_CALLED(Terminate);
919
920 return S_OK;
921 }
922
923 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
924 PROTOCOLDATA *pProtocolData)
925 {
926 DWORD bscf = 0;
927 HRESULT hres;
928
929 CHECK_EXPECT(Continue);
930
931 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
932
933 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
934 if(!pProtocolData)
935 return S_OK;
936
937 switch(prot_state) {
938 case 1: {
939 IServiceProvider *service_provider;
940 IHttpNegotiate *http_negotiate;
941 static WCHAR header[] = {'?',0};
942
943 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
944 (void**)&service_provider);
945 ok(hres == S_OK, "Could not get IServiceProvicder\n");
946
947 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
948 &IID_IHttpNegotiate, (void**)&http_negotiate);
949 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
950
951 if(!no_callback) {
952 SET_EXPECT(QueryInterface_IHttpNegotiate);
953 SET_EXPECT(OnResponse);
954 }
955 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
956 if(!no_callback) {
957 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
958 CHECK_CALLED(OnResponse);
959 }
960 IHttpNegotiate_Release(http_negotiate);
961 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
962
963 if(test_protocol == HTTPS_TEST || test_redirect) {
964 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
965 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
966 }
967
968 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
969 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
970 ok(hres == S_OK,
971 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
972
973 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
974 BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW);
975 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
976
977 bscf |= BSCF_FIRSTDATANOTIFICATION;
978 break;
979 }
980 case 2:
981 case 3:
982 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
983 break;
984 }
985
986 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
987 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
988
989 if(prot_state != 2 || !test_abort)
990 SET_EXPECT(Read);
991 switch(prot_state) {
992 case 1:
993 if(bind_to_object) {
994 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
995 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
996 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
997 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
998 SET_EXPECT(CreateInstance);
999 SET_EXPECT(PutProperty_MIMETYPEPROP);
1000 SET_EXPECT(PutProperty_CLASSIDPROP);
1001 SET_EXPECT(Load);
1002 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1003 SET_EXPECT(OnObjectAvailable);
1004 SET_EXPECT(Obj_OnStopBinding);
1005 }else if(!no_callback) {
1006 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1007 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1008 SET_EXPECT(LockRequest);
1009 }else {
1010 SET_EXPECT(LockRequest);
1011 }
1012 break;
1013 case 2:
1014 if(!no_callback)
1015 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1016 break;
1017 case 3:
1018 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1019 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1020 }
1021 if(!no_callback) {
1022 if((!bind_to_object || prot_state >= 2) && (!test_abort || prot_state != 2))
1023 SET_EXPECT(OnDataAvailable);
1024 if(prot_state == 3 || (test_abort && prot_state == 2))
1025 SET_EXPECT(OnStopBinding);
1026 }
1027 return S_OK;
1028 }
1029
1030 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
1031 DWORD dwOptions)
1032 {
1033 HRESULT hres;
1034
1035 CHECK_EXPECT(Abort);
1036
1037 ok(hrReason == E_ABORT, "hrReason = %08x\n", hrReason);
1038 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
1039
1040 hres = IInternetProtocolSink_ReportResult(protocol_sink, E_ABORT, ERROR_SUCCESS, NULL);
1041 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1042
1043 return S_OK;
1044 }
1045
1046 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
1047 {
1048 CHECK_EXPECT(Terminate);
1049
1050 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
1051
1052 if(protocol_sink) {
1053 IInternetProtocolSink_Release(protocol_sink);
1054 protocol_sink = NULL;
1055 }
1056
1057 if(no_callback)
1058 SetEvent(complete_event);
1059 return S_OK;
1060 }
1061
1062 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
1063 {
1064 ok(0, "unexpected call\n");
1065 return E_NOTIMPL;
1066 }
1067
1068 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
1069 {
1070 ok(0, "unexpected call\n");
1071 return E_NOTIMPL;
1072 }
1073
1074 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
1075 ULONG cb, ULONG *pcbRead)
1076 {
1077 static const char data[] = "<HTML></HTML>";
1078
1079 CHECK_EXPECT2(Read);
1080
1081 ok(pv != NULL, "pv == NULL\n");
1082 ok(cb != 0, "cb == 0\n");
1083 ok(pcbRead != NULL, "pcbRead == NULL\n");
1084
1085 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
1086 HRESULT hres;
1087
1088 static int pending = TRUE;
1089
1090 pending = !pending;
1091
1092 switch(prot_state) {
1093 case 1:
1094 case 2:
1095 if(pending) {
1096 *pcbRead = 10;
1097 memset(pv, '?', 10);
1098 if(prot_state == 2 && no_callback)
1099 SetEvent(complete_event);
1100 return E_PENDING;
1101 }else {
1102 memset(pv, '?', cb);
1103 *pcbRead = cb;
1104 read++;
1105 return S_OK;
1106 }
1107 case 3:
1108 prot_state++;
1109
1110 *pcbRead = 0;
1111
1112 hres = IInternetProtocolSink_ReportData(protocol_sink,
1113 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
1114 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1115
1116 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1117 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1118
1119 return S_FALSE;
1120 case 4:
1121 *pcbRead = 0;
1122 return S_FALSE;
1123 }
1124 }
1125
1126 if(read) {
1127 *pcbRead = 0;
1128 return S_FALSE;
1129 }
1130
1131 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
1132 read += *pcbRead = sizeof(data)-1;
1133 memcpy(pv, data, sizeof(data));
1134 return S_OK;
1135 }
1136
1137 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
1138 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1139 {
1140 ok(0, "unexpected call\n");
1141 return E_NOTIMPL;
1142 }
1143
1144 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
1145 {
1146 CHECK_EXPECT(LockRequest);
1147 if(no_callback)
1148 SetEvent(complete_event);
1149 return S_OK;
1150 }
1151
1152 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
1153 {
1154 CHECK_EXPECT(UnlockRequest);
1155 return S_OK;
1156 }
1157
1158 static const IInternetProtocolVtbl ProtocolVtbl = {
1159 Protocol_QueryInterface,
1160 Protocol_AddRef,
1161 Protocol_Release,
1162 Protocol_Start,
1163 Protocol_Continue,
1164 Protocol_Abort,
1165 Protocol_Terminate,
1166 Protocol_Suspend,
1167 Protocol_Resume,
1168 Protocol_Read,
1169 Protocol_Seek,
1170 Protocol_LockRequest,
1171 Protocol_UnlockRequest
1172 };
1173
1174 static IInternetProtocol Protocol = { &ProtocolVtbl };
1175
1176 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
1177 {
1178 if(IsEqualGUID(&IID_IUnknown, riid)
1179 || IsEqualGUID(&IID_IHttpNegotiate, riid)
1180 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1181 *ppv = iface;
1182 return S_OK;
1183 }
1184
1185 ok(0, "unexpected call\n");
1186 return E_NOINTERFACE;
1187 }
1188
1189 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
1190 {
1191 return 2;
1192 }
1193
1194 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
1195 {
1196 return 1;
1197 }
1198
1199 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
1200 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1201 {
1202 if(onsecurityproblem_hres == S_OK)
1203 CHECK_EXPECT2(BeginningTransaction);
1204 else
1205 CHECK_EXPECT(BeginningTransaction);
1206
1207 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1208
1209 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
1210 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1211 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1212 if(pszAdditionalHeaders)
1213 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1214
1215 return S_OK;
1216 }
1217
1218 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1219 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1220 {
1221 CHECK_EXPECT(OnResponse);
1222
1223 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1224
1225 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1226 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1227 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1228 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1229 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1230 if(pszAdditionalRequestHeaders)
1231 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1232
1233 return S_OK;
1234 }
1235
1236 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1237 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1238 {
1239 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1240
1241 CHECK_EXPECT(GetRootSecurityId);
1242
1243 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1244
1245 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1246 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1247 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1248
1249 if(pbSecurityId == (void*)0xdeadbeef)
1250 return E_NOTIMPL;
1251
1252 if(pcbSecurityId) {
1253 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1254 *pcbSecurityId = sizeof(sec_id);
1255 }
1256
1257 if(pbSecurityId)
1258 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1259
1260 return E_FAIL;
1261 }
1262
1263 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1264 HttpNegotiate_QueryInterface,
1265 HttpNegotiate_AddRef,
1266 HttpNegotiate_Release,
1267 HttpNegotiate_BeginningTransaction,
1268 HttpNegotiate_OnResponse,
1269 HttpNegotiate_GetRootSecurityId
1270 };
1271
1272 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1273
1274 static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv)
1275 {
1276 ok(0, "Unexpected call\n");
1277 *ppv = NULL;
1278 if(IsEqualGUID(&IID_IHttpSecurity, riid) ||
1279 IsEqualGUID(&IID_IWindowForBindingUI, riid) ||
1280 IsEqualGUID(&IID_IUnknown, riid))
1281 {
1282 *ppv = iface;
1283 return S_OK;
1284 }
1285
1286 ok(0, "Unexpected interface requested.\n");
1287
1288 return E_NOINTERFACE;
1289 }
1290
1291 static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface)
1292 {
1293 return 2;
1294 }
1295
1296 static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface)
1297 {
1298 return 1;
1299 }
1300
1301 static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity *iface, REFGUID rguidReason, HWND *phwnd)
1302 {
1303 if(IsEqualGUID(rguidReason, &IID_IHttpSecurity))
1304 CHECK_EXPECT(GetWindow_IHttpSecurity);
1305 else if(IsEqualGUID(rguidReason, &IID_IWindowForBindingUI))
1306 CHECK_EXPECT2(GetWindow_IWindowForBindingUI);
1307 else
1308 ok(0, "Unexpected rguidReason: %s\n", debugstr_guid(rguidReason));
1309
1310 *phwnd = NULL;
1311 return S_OK;
1312 }
1313
1314 static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem)
1315 {
1316 CHECK_EXPECT(OnSecurityProblem);
1317 if(!security_problem) {
1318 ok(dwProblem == ERROR_INTERNET_SEC_CERT_CN_INVALID ||
1319 broken(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) /* Some versions of IE6 */,
1320 "Got problem: %d\n", dwProblem);
1321 security_problem = dwProblem;
1322
1323 if(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS)
1324 binding_hres = INET_E_SECURITY_PROBLEM;
1325 }else
1326 ok(dwProblem == security_problem, "Got problem: %d\n", dwProblem);
1327
1328 return onsecurityproblem_hres;
1329 }
1330
1331 static const IHttpSecurityVtbl HttpSecurityVtbl = {
1332 HttpSecurity_QueryInterface,
1333 HttpSecurity_AddRef,
1334 HttpSecurity_Release,
1335 HttpSecurity_GetWindow,
1336 HttpSecurity_OnSecurityProblem
1337 };
1338
1339 static IHttpSecurity HttpSecurity = { &HttpSecurityVtbl };
1340
1341 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1342 {
1343 ok(0, "unexpected call\n");
1344 return E_NOINTERFACE;
1345 }
1346
1347 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1348 {
1349 return 2;
1350 }
1351
1352 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1353 {
1354 return 1;
1355 }
1356
1357 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1358 REFGUID guidService, REFIID riid, void **ppv)
1359 {
1360 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1361 CHECK_EXPECT(QueryService_IAuthenticate);
1362 return E_NOTIMPL;
1363 }
1364
1365 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1366 CHECK_EXPECT2(QueryService_IInternetProtocol);
1367 return E_NOTIMPL;
1368 }
1369
1370 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1371 CHECK_EXPECT(QueryService_IInternetBindInfo);
1372 return E_NOTIMPL;
1373 }
1374
1375 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1376 CHECK_EXPECT2(QueryService_IWindowForBindingUI);
1377 *ppv = &HttpSecurity;
1378 return S_OK;
1379 }
1380
1381 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
1382 CHECK_EXPECT(QueryService_IHttpSecurity);
1383 *ppv = &HttpSecurity;
1384 return S_OK;
1385 }
1386
1387 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1388 return E_NOINTERFACE;
1389 }
1390
1391 static IServiceProviderVtbl ServiceProviderVtbl = {
1392 ServiceProvider_QueryInterface,
1393 ServiceProvider_AddRef,
1394 ServiceProvider_Release,
1395 ServiceProvider_QueryService
1396 };
1397
1398 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1399
1400 static IBindStatusCallbackEx objbsc;
1401
1402 static void test_WinInetHttpInfo(IWinInetHttpInfo *http_info, DWORD progress)
1403 {
1404 DWORD status, size;
1405 HRESULT hres, expect;
1406
1407 /* QueryInfo changes it's behavior during this request */
1408 if(progress == BINDSTATUS_SENDINGREQUEST)
1409 return;
1410
1411 if(test_protocol==FTP_TEST && download_state==BEFORE_DOWNLOAD
1412 && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1413 expect = E_FAIL;
1414 else if(test_protocol == FTP_TEST)
1415 expect = S_FALSE;
1416 else
1417 expect = S_OK;
1418
1419 size = sizeof(DWORD);
1420 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
1421 &status, &size, NULL, NULL);
1422 ok(hres == expect, "hres = %x, expected %x\n", hres, expect);
1423 if(hres == S_OK) {
1424 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1425 ok(status == 0, "status = %d\n", status);
1426 else
1427 ok(status == HTTP_STATUS_OK, "status = %d\n", status);
1428 ok(size == sizeof(DWORD), "size = %d\n", size);
1429 }
1430
1431 size = sizeof(DWORD);
1432 hres = IWinInetHttpInfo_QueryOption(http_info, INTERNET_OPTION_HANDLE_TYPE, &status, &size);
1433 if(test_protocol == FTP_TEST) {
1434 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1435 ok(hres == E_FAIL, "hres = %x\n", hres);
1436 else
1437 ok(hres == S_OK, "hres = %x\n", hres);
1438
1439 if(hres == S_OK)
1440 ok(status == INTERNET_HANDLE_TYPE_FTP_FILE, "status = %d\n", status);
1441 } else {
1442 ok(hres == S_OK, "hres = %x\n", hres);
1443 ok(status == INTERNET_HANDLE_TYPE_HTTP_REQUEST, "status = %d\n", status);
1444 }
1445 }
1446
1447 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1448 {
1449 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1450
1451 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1452 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1453 if(emulate_protocol) {
1454 *ppv = &Protocol;
1455 return S_OK;
1456 }else {
1457 return E_NOINTERFACE;
1458 }
1459 }
1460 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1461 {
1462 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1463 *ppv = &ServiceProvider;
1464 return S_OK;
1465 }
1466 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1467 {
1468 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1469 *ppv = &HttpNegotiate;
1470 return S_OK;
1471 }
1472 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1473 {
1474 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1475 *ppv = &HttpNegotiate;
1476 return S_OK;
1477 }
1478 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1479 {
1480 CHECK_EXPECT(QueryInterface_IAuthenticate);
1481 return E_NOINTERFACE;
1482 }
1483 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1484 {
1485 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1486 *ppv = iface;
1487 return S_OK;
1488 }
1489 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1490 {
1491 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1492 return E_NOINTERFACE;
1493 }
1494 else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid))
1495 {
1496 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1497 if(!use_bscex)
1498 return E_NOINTERFACE;
1499 *ppv = iface;
1500 return S_OK;
1501 }
1502 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1503 {
1504 /* TODO */
1505 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1506 }
1507 else if(IsEqualGUID(&IID_IWindowForBindingUI, riid))
1508 {
1509 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1510 return E_NOINTERFACE;
1511 }
1512 else if(IsEqualGUID(&IID_IHttpSecurity, riid))
1513 {
1514 CHECK_EXPECT2(QueryInterface_IHttpSecurity);
1515 return E_NOINTERFACE;
1516 }
1517 else
1518 {
1519 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1520 }
1521
1522 return E_NOINTERFACE;
1523 }
1524
1525 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1526 {
1527 return 2;
1528 }
1529
1530 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1531 {
1532 return 1;
1533 }
1534
1535 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1536 IBinding *pib)
1537 {
1538 IWinInetHttpInfo *http_info;
1539 HRESULT hres;
1540 IMoniker *mon;
1541
1542 if(iface == &objbsc)
1543 CHECK_EXPECT(Obj_OnStartBinding);
1544 else
1545 CHECK_EXPECT(OnStartBinding);
1546
1547 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1548
1549 ok(pib != NULL, "pib should not be NULL\n");
1550 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1551
1552 if(pib == (void*)0xdeadbeef)
1553 return S_OK;
1554
1555 current_binding = pib;
1556
1557 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1558 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1559 if(SUCCEEDED(hres))
1560 IMoniker_Release(mon);
1561
1562 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1563 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1564
1565 if(abort_start) {
1566 binding_hres = abort_hres;
1567 return abort_hres;
1568 }
1569
1570 return S_OK;
1571 }
1572
1573 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1574 {
1575 ok(0, "unexpected call\n");
1576 return E_NOTIMPL;
1577 }
1578
1579 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1580 {
1581 ok(0, "unexpected call\n");
1582 return E_NOTIMPL;
1583 }
1584
1585 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1586 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1587 {
1588 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1589
1590 switch(ulStatusCode) {
1591 case BINDSTATUS_FINDINGRESOURCE:
1592 if(iface == &objbsc)
1593 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1594 else if(test_protocol == FTP_TEST)
1595 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1596 else
1597 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1598 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1599 SetEvent(complete_event);
1600 break;
1601 case BINDSTATUS_CONNECTING:
1602 if(iface == &objbsc)
1603 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1604 else if(test_protocol == FTP_TEST)
1605 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1606 else if(onsecurityproblem_hres == S_OK)
1607 CHECK_EXPECT2(OnProgress_CONNECTING);
1608 else
1609 CHECK_EXPECT(OnProgress_CONNECTING);
1610 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1611 SetEvent(complete_event);
1612 break;
1613 case BINDSTATUS_REDIRECTING:
1614 if(iface == &objbsc)
1615 CHECK_EXPECT(Obj_OnProgress_REDIRECTING);
1616 else
1617 CHECK_EXPECT(OnProgress_REDIRECTING);
1618 ok(!lstrcmpW(szStatusText, winetest_data_urlW), "unexpected status text %s\n",
1619 wine_dbgstr_w(szStatusText));
1620 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
1621 && (!bind_to_object || iface == &objbsc))
1622 SetEvent(complete_event);
1623 break;
1624 case BINDSTATUS_SENDINGREQUEST:
1625 if(iface == &objbsc)
1626 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1627 else if(test_protocol == FTP_TEST)
1628 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1629 else
1630 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1631 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1632 SetEvent(complete_event);
1633
1634 if(abort_progress) {
1635 if(filedwl_api)
1636 binding_hres = E_ABORT;
1637 return E_ABORT;
1638 }
1639
1640 break;
1641 case BINDSTATUS_MIMETYPEAVAILABLE:
1642 if(iface == &objbsc)
1643 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1644 else
1645 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1646 if(!bind_to_object)
1647 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1648 download_state);
1649 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1650 break;
1651 case BINDSTATUS_BEGINDOWNLOADDATA:
1652 if(iface == &objbsc)
1653 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1654 else
1655 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1656 ok(szStatusText != NULL, "szStatusText == NULL\n");
1657 if(szStatusText) {
1658 if(filedwl_api) {
1659 /* FIXME */
1660 }else {
1661 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1662 }
1663 }
1664 if(!bind_to_object)
1665 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1666 download_state);
1667 download_state = DOWNLOADING;
1668 break;
1669 case BINDSTATUS_DOWNLOADINGDATA:
1670 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1671 ok(iface != &objbsc, "unexpected call\n");
1672 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1673 download_state);
1674 if(test_abort) {
1675 HRESULT hres;
1676
1677 SET_EXPECT(Abort);
1678 hres = IBinding_Abort(current_binding);
1679 ok(hres == S_OK, "Abort failed: %08x\n", hres);
1680 CHECK_CALLED(Abort);
1681
1682 hres = IBinding_Abort(current_binding);
1683 ok(hres == E_FAIL, "Abort failed: %08x\n", hres);
1684
1685 binding_hres = E_ABORT;
1686 }
1687 break;
1688 case BINDSTATUS_ENDDOWNLOADDATA:
1689 if(iface == &objbsc)
1690 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1691 else
1692 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1693 ok(szStatusText != NULL, "szStatusText == NULL\n");
1694 if(szStatusText) {
1695 if(filedwl_api) {
1696 /* FIXME */
1697 }else {
1698 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1699 }
1700 }
1701 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1702 download_state);
1703 download_state = END_DOWNLOAD;
1704 break;
1705 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1706 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST && test_protocol != WINETEST_TEST) {
1707 if(iface == &objbsc)
1708 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1709 else
1710 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1711 }else { /* FIXME */
1712 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1713 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1714 }
1715
1716 ok(szStatusText != NULL, "szStatusText == NULL\n");
1717 if(szStatusText && test_protocol == FILE_TEST)
1718 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1719 break;
1720 case BINDSTATUS_CLASSIDAVAILABLE:
1721 {
1722 CLSID clsid;
1723 HRESULT hr;
1724 if(iface != &objbsc)
1725 ok(0, "unexpected call\n");
1726 else
1727 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1728 hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid);
1729 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1730 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1731 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1732 break;
1733 }
1734 case BINDSTATUS_BEGINSYNCOPERATION:
1735 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1736 if(iface != &objbsc)
1737 ok(0, "unexpected call\n");
1738 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1739 break;
1740 case BINDSTATUS_ENDSYNCOPERATION:
1741 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1742 if(iface != &objbsc)
1743 ok(0, "unexpected call\n");
1744 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1745 break;
1746 case BINDSTATUS_PROXYDETECTING:
1747 trace("BINDSTATUS_PROXYDETECTING\n");
1748 break;
1749 case BINDSTATUS_COOKIE_SENT:
1750 trace("BINDSTATUS_COOKIE_SENT\n");
1751 break;
1752 default:
1753 ok(0, "unexpected code %d\n", ulStatusCode);
1754 };
1755
1756 if(current_binding) {
1757 IWinInetHttpInfo *http_info;
1758 HRESULT hres;
1759
1760 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1761 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol)) {
1762 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1763 test_WinInetHttpInfo(http_info, ulStatusCode);
1764 } else
1765 ok(hres == E_NOINTERFACE,
1766 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1767 if(SUCCEEDED(hres))
1768 IWinInetHttpInfo_Release(http_info);
1769 }
1770
1771 return S_OK;
1772 }
1773
1774 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1775 {
1776 if(iface == &objbsc) {
1777 CHECK_EXPECT(Obj_OnStopBinding);
1778 stopped_obj_binding = TRUE;
1779 }else {
1780 CHECK_EXPECT(OnStopBinding);
1781 stopped_binding = TRUE;
1782 }
1783
1784 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1785
1786 if(only_check_prot_args) {
1787 todo_wine ok(hresult == S_OK, "Got %08x\n", hresult);
1788 return S_OK;
1789 }
1790
1791 /* ignore DNS failure */
1792 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1793 return S_OK;
1794
1795 if(filedwl_api) {
1796 if(!abort_progress && !abort_start)
1797 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1798 else if(abort_start && abort_hres == E_NOTIMPL)
1799 todo_wine ok(hresult == S_FALSE, "binding failed: %08x, expected S_FALSE\n", hresult);
1800 else
1801 ok(hresult == E_ABORT, "binding failed: %08x, expected E_ABORT\n", hresult);
1802 } else
1803 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1804 ok(szError == NULL, "szError should be NULL\n");
1805
1806 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) && emulate_protocol) {
1807 SetEvent(complete_event);
1808 if(iface != &objbsc)
1809 WaitForSingleObject(complete_event2, INFINITE);
1810 }
1811
1812 return S_OK;
1813 }
1814
1815 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1816 {
1817 DWORD cbSize;
1818
1819 if(iface == &objbsc)
1820 CHECK_EXPECT(Obj_GetBindInfo);
1821 else
1822 CHECK_EXPECT(GetBindInfo);
1823
1824 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1825
1826 *grfBINDF = bindf;
1827 cbSize = pbindinfo->cbSize;
1828 memset(pbindinfo, 0, cbSize);
1829 pbindinfo->cbSize = cbSize;
1830
1831 return S_OK;
1832 }
1833
1834 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1835 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1836 {
1837 HRESULT hres;
1838 DWORD readed;
1839 BYTE buf[512];
1840 CHAR clipfmt[512];
1841
1842 if(iface == &objbsc)
1843 ok(0, "unexpected call\n");
1844
1845 CHECK_EXPECT2(OnDataAvailable);
1846
1847 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1848
1849 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1850 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1851 download_state);
1852 data_available = TRUE;
1853
1854 if(bind_to_object && !is_async_prot)
1855 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), "grfBSCF = %x\n", grfBSCF);
1856
1857 ok(pformatetc != NULL, "pformatetx == NULL\n");
1858 if(pformatetc) {
1859 if (mime_type[0]) {
1860 INT ret;
1861 clipfmt[0] = 0;
1862 ret = GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1);
1863 ok(ret, "GetClipboardFormatName failed, error %d\n", GetLastError());
1864 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1865 pformatetc->cfFormat, clipfmt, mime_type);
1866 } else {
1867 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1868 }
1869 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1870 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1871 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1872 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1873 }
1874
1875 ok(pstgmed != NULL, "stgmeg == NULL\n");
1876 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1877 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1878
1879 switch(pstgmed->tymed) {
1880 case TYMED_ISTREAM:
1881 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1882 STATSTG stat;
1883
1884 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1885 ok(hres == STG_E_ACCESSDENIED,
1886 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1887
1888 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1889 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1890
1891 hres = IStream_Revert(U(*pstgmed).pstm);
1892 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1893
1894 hres = IStream_Stat(U(*pstgmed).pstm, NULL, STATFLAG_NONAME);
1895 ok(hres == E_FAIL, "hres = %x\n", hres);
1896 if(use_cache_file && emulate_protocol) {
1897 hres = IStream_Stat(U(*pstgmed).pstm, &stat, STATFLAG_DEFAULT);
1898 ok(hres == S_OK, "hres = %x\n", hres);
1899 ok(!lstrcmpW(stat.pwcsName, cache_file_name),
1900 "stat.pwcsName = %s, cache_file_name = %s\n",
1901 wine_dbgstr_w(stat.pwcsName), wine_dbgstr_w(cache_file_name));
1902 CoTaskMemFree(stat.pwcsName);
1903 ok(U(stat.cbSize).LowPart == (bindf&BINDF_ASYNCHRONOUS?0:6500),
1904 "stat.cbSize.LowPart = %u\n", U(stat.cbSize).LowPart);
1905 } else {
1906 hres = IStream_Stat(U(*pstgmed).pstm, &stat, STATFLAG_NONAME);
1907 ok(hres == S_OK, "hres = %x\n", hres);
1908 ok(!stat.pwcsName || broken(stat.pwcsName!=NULL),
1909 "stat.pwcsName = %s\n", wine_dbgstr_w(stat.pwcsName));
1910 }
1911 ok(stat.type == STGTY_STREAM, "stat.type = %x\n", stat.type);
1912 ok(U(stat.cbSize).HighPart == 0, "stat.cbSize.HighPart != 0\n");
1913 ok(stat.grfMode == (U(stat.cbSize).LowPart?GENERIC_READ:0), "stat.grfMode = %x\n", stat.grfMode);
1914 ok(stat.grfLocksSupported == 0, "stat.grfLocksSupported = %x\n", stat.grfLocksSupported);
1915 ok(stat.grfStateBits == 0, "stat.grfStateBits = %x\n", stat.grfStateBits);
1916 ok(stat.reserved == 0, "stat.reserved = %x\n", stat.reserved);
1917 }
1918
1919 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1920 if(callback_read) {
1921 do {
1922 hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1923 if(test_protocol == HTTP_TEST && emulate_protocol && readed)
1924 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
1925 }while(hres == S_OK);
1926 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1927 }
1928 break;
1929
1930 case TYMED_FILE:
1931 if(test_protocol == FILE_TEST)
1932 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1933 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1934 else if(emulate_protocol)
1935 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1936 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1937 else
1938 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1939 }
1940
1941 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
1942 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1943 SetEvent(complete_event);
1944
1945 return S_OK;
1946 }
1947
1948 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
1949 {
1950 CHECK_EXPECT(OnObjectAvailable);
1951
1952 if(iface != &objbsc)
1953 ok(0, "unexpected call\n");
1954
1955 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1956 ok(punk != NULL, "punk == NULL\n");
1957
1958 return S_OK;
1959 }
1960
1961 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
1962 DWORD *grfBINDF2, DWORD *pdwReserved)
1963 {
1964 CHECK_EXPECT(GetBindInfoEx);
1965
1966 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1967 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
1968 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1969 ok(pdwReserved != NULL, "dwReserved == NULL\n");
1970
1971 return S_OK;
1972 }
1973
1974 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
1975 statusclb_QueryInterface,
1976 statusclb_AddRef,
1977 statusclb_Release,
1978 statusclb_OnStartBinding,
1979 statusclb_GetPriority,
1980 statusclb_OnLowResource,
1981 statusclb_OnProgress,
1982 statusclb_OnStopBinding,
1983 statusclb_GetBindInfo,
1984 statusclb_OnDataAvailable,
1985 statusclb_OnObjectAvailable,
1986 statusclb_GetBindInfoEx
1987 };
1988
1989 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
1990 static IBindStatusCallbackEx bsc2 = { &BindStatusCallbackVtbl };
1991 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
1992
1993 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1994 {
1995 *ppv = NULL;
1996 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1997 return E_NOINTERFACE;
1998 }
1999
2000 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
2001 {
2002 return 2;
2003 }
2004
2005 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
2006 {
2007 return 1;
2008 }
2009
2010 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
2011 {
2012 switch(mkp) {
2013 case MIMETYPEPROP:
2014 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
2015 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
2016 break;
2017 case CLASSIDPROP:
2018 CHECK_EXPECT(PutProperty_CLASSIDPROP);
2019 break;
2020 default:
2021 break;
2022 }
2023
2024 return S_OK;
2025 }
2026
2027 static const IMonikerPropVtbl MonikerPropVtbl = {
2028 MonikerProp_QueryInterface,
2029 MonikerProp_AddRef,
2030 MonikerProp_Release,
2031 MonikerProp_PutProperty
2032 };
2033
2034 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
2035
2036 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
2037 {
2038 *ppv = NULL;
2039
2040 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
2041 *ppv = iface;
2042 else if(IsEqualGUID(&IID_IMonikerProp, riid))
2043 *ppv = &MonikerProp;
2044
2045 if(*ppv)
2046 return S_OK;
2047
2048 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2049 return E_NOINTERFACE;
2050 }
2051
2052 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
2053 {
2054 return 2;
2055 }
2056
2057 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
2058 {
2059 return 1;
2060 }
2061
2062 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
2063 {
2064 ok(0, "unexpected call\n");
2065 return E_NOTIMPL;
2066 }
2067
2068 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
2069 {
2070 ok(0, "unexpected call\n");
2071 return E_NOTIMPL;
2072 }
2073
2074 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
2075 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
2076 {
2077 IUnknown *unk;
2078 HRESULT hres;
2079
2080 static WCHAR cbinding_contextW[] =
2081 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
2082
2083 CHECK_EXPECT(Load);
2084 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
2085
2086 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2087 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
2088 else
2089 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
2090 ok(pimkName != NULL, "pimkName == NULL\n");
2091 ok(pibc != NULL, "pibc == NULL\n");
2092 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
2093
2094 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
2095 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
2096 if(SUCCEEDED(hres)) {
2097 IBinding *binding;
2098
2099 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
2100 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
2101
2102 IBinding_Release(binding);
2103 IUnknown_Release(unk);
2104 }
2105
2106 SET_EXPECT(QueryInterface_IServiceProvider);
2107 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
2108 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2109 CHECK_CALLED(QueryInterface_IServiceProvider);
2110
2111 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2112 SET_EXPECT(GetBindInfo);
2113 SET_EXPECT(OnStartBinding);
2114 if(test_redirect)
2115 SET_EXPECT(OnProgress_REDIRECTING);
2116 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2117 if(test_protocol == FILE_TEST)
2118 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2119 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2120 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2121 SET_EXPECT(LockRequest);
2122 SET_EXPECT(OnDataAvailable);
2123 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2124 SET_EXPECT(OnStopBinding);
2125
2126 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
2127 ok(hres == S_OK, "Load failed: %08x\n", hres);
2128
2129 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2130 CHECK_CALLED(GetBindInfo);
2131 CHECK_CALLED(OnStartBinding);
2132 if(test_redirect)
2133 CHECK_CALLED(OnProgress_REDIRECTING);
2134 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2135 if(test_protocol == FILE_TEST)
2136 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2137 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2138 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2139 CHECK_CALLED(LockRequest);
2140 CHECK_CALLED(OnDataAvailable);
2141 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2142 CHECK_CALLED(OnStopBinding);
2143
2144 if(unk)
2145 IUnknown_Release(unk);
2146
2147 return S_OK;
2148 }
2149
2150 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
2151 {
2152 ok(0, "unexpected call\n");
2153 return E_NOTIMPL;
2154 }
2155
2156 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
2157 {
2158 ok(0, "unexpected call\n");
2159 return E_NOTIMPL;
2160 }
2161
2162 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
2163 {
2164 ok(0, "unexpected call\n");
2165 return E_NOTIMPL;
2166 }
2167
2168 static const IPersistMonikerVtbl PersistMonikerVtbl = {
2169 PersistMoniker_QueryInterface,
2170 PersistMoniker_AddRef,
2171 PersistMoniker_Release,
2172 PersistMoniker_GetClassID,
2173 PersistMoniker_IsDirty,
2174 PersistMoniker_Load,
2175 PersistMoniker_Save,
2176 PersistMoniker_SaveCompleted,
2177 PersistMoniker_GetCurMoniker
2178 };
2179
2180 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
2181
2182 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2183 {
2184 *ppv = NULL;
2185
2186 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2187 *ppv = iface;
2188 return S_OK;
2189 }
2190
2191 if(IsEqualGUID(&IID_IMarshal, riid))
2192 return E_NOINTERFACE;
2193 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
2194 return E_NOINTERFACE;
2195
2196 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2197 return E_NOTIMPL;
2198 }
2199
2200 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2201 {
2202 return 2;
2203 }
2204
2205 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2206 {
2207 return 1;
2208 }
2209
2210 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2211 {
2212 CHECK_EXPECT(CreateInstance);
2213 ok(!outer, "outer = %p\n", outer);
2214 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2215 *ppv = &PersistMoniker;
2216 return S_OK;
2217 }
2218
2219 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
2220 {
2221 ok(0, "unexpected call\n");
2222 return S_OK;
2223 }
2224
2225 static const IClassFactoryVtbl ClassFactoryVtbl = {
2226 ClassFactory_QueryInterface,
2227 ClassFactory_AddRef,
2228 ClassFactory_Release,
2229 ClassFactory_CreateInstance,
2230 ClassFactory_LockServer
2231 };
2232
2233 static IClassFactory mime_cf = { &ClassFactoryVtbl };
2234
2235 static HRESULT WINAPI ProtocolCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2236 {
2237 *ppv = NULL;
2238
2239 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2240 *ppv = iface;
2241 return S_OK;
2242 }
2243
2244 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2245 return E_NOINTERFACE;
2246
2247 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2248 return E_NOTIMPL;
2249 }
2250
2251 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2252 {
2253 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2254 return E_NOINTERFACE;
2255
2256 todo_wine ok(outer != NULL, "outer == NULL\n");
2257 todo_wine ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2258 *ppv = &Protocol;
2259 return S_OK;
2260 }
2261
2262 static const IClassFactoryVtbl ProtocolCFVtbl = {
2263 ProtocolCF_QueryInterface,
2264 ClassFactory_AddRef,
2265 ClassFactory_Release,
2266 ProtocolCF_CreateInstance,
2267 ClassFactory_LockServer
2268 };
2269
2270 static IClassFactory protocol_cf = { &ProtocolCFVtbl };
2271
2272 static void test_CreateAsyncBindCtx(void)
2273 {
2274 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
2275 IUnknown *unk;
2276 HRESULT hres;
2277 ULONG ref;
2278 BIND_OPTS bindopts;
2279
2280 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
2281 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2282 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
2283
2284 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
2285 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2286
2287 SET_EXPECT(QueryInterface_IServiceProvider);
2288 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2289 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
2290 CHECK_CALLED(QueryInterface_IServiceProvider);
2291
2292 bindopts.cbStruct = sizeof(bindopts);
2293 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2294 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2295 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2296 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2297 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2298 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2299 bindopts.grfMode);
2300 ok(bindopts.dwTickCountDeadline == 0,
2301 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2302
2303 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2304 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
2305 if(SUCCEEDED(hres))
2306 IUnknown_Release(unk);
2307
2308 ref = IBindCtx_Release(bctx);
2309 ok(ref == 0, "bctx should be destroyed here\n");
2310 }
2311
2312 static void test_CreateAsyncBindCtxEx(void)
2313 {
2314 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
2315 IUnknown *unk;
2316 BIND_OPTS bindopts;
2317 HRESULT hres;
2318
2319 static WCHAR testW[] = {'t','e','s','t',0};
2320
2321 if (!pCreateAsyncBindCtxEx) {
2322 win_skip("CreateAsyncBindCtxEx not present\n");
2323 return;
2324 }
2325
2326 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
2327 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
2328
2329 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2330 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2331
2332 if(SUCCEEDED(hres)) {
2333 bindopts.cbStruct = sizeof(bindopts);
2334 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2335 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2336 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2337 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2338 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2339 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2340 bindopts.grfMode);
2341 ok(bindopts.dwTickCountDeadline == 0,
2342 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2343
2344 IBindCtx_Release(bctx);
2345 }
2346
2347 CreateBindCtx(0, &bctx_arg);
2348 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2349 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2350
2351 if(SUCCEEDED(hres)) {
2352 bindopts.cbStruct = sizeof(bindopts);
2353 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2354 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2355 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2356 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2357 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2358 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2359 bindopts.grfMode);
2360 ok(bindopts.dwTickCountDeadline == 0,
2361 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2362
2363 IBindCtx_Release(bctx);
2364 }
2365
2366 IBindCtx_Release(bctx_arg);
2367
2368 SET_EXPECT(QueryInterface_IServiceProvider);
2369 hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
2370 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2371 CHECK_CALLED(QueryInterface_IServiceProvider);
2372
2373 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2374 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
2375 if(SUCCEEDED(hres))
2376 IUnknown_Release(unk);
2377
2378 IBindCtx_Release(bctx);
2379
2380 hres = CreateBindCtx(0, &bctx2);
2381 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2382
2383 hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
2384 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2385
2386 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
2387 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2388
2389 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
2390 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2391 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
2392
2393 IBindCtx_Release(bctx);
2394 IBindCtx_Release(bctx2);
2395 }
2396
2397 static void test_GetBindInfoEx(IBindStatusCallback *holder)
2398 {
2399 IBindStatusCallbackEx *bscex;
2400 BINDINFO bindinfo = {sizeof(bindinfo)};
2401 DWORD bindf, bindf2, dw;
2402 HRESULT hres;
2403
2404 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
2405 if(FAILED(hres)) {
2406 win_skip("IBindStatusCallbackEx not supported\n");
2407 return;
2408 }
2409
2410 use_bscex = TRUE;
2411
2412 bindf = 0;
2413 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2414 SET_EXPECT(GetBindInfoEx);
2415 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
2416 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2417 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2418 CHECK_CALLED(GetBindInfoEx);
2419
2420 bindf = bindf2 = dw = 0;
2421 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2422 SET_EXPECT(GetBindInfoEx);
2423 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2424 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2425 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2426 CHECK_CALLED(GetBindInfoEx);
2427
2428 use_bscex = FALSE;
2429
2430 bindf = bindf2 = dw = 0xdeadbeef;
2431 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2432 SET_EXPECT(GetBindInfo);
2433 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2434 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2435 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2436 CHECK_CALLED(GetBindInfo);
2437 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
2438 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
2439
2440 IBindStatusCallbackEx_Release(bscex);
2441 }
2442
2443 static BOOL test_bscholder(IBindStatusCallback *holder)
2444 {
2445 IServiceProvider *serv_prov;
2446 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
2447 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
2448 IAuthenticate *authenticate, *authenticate_serv;
2449 IInternetProtocol *protocol;
2450 BINDINFO bindinfo = {sizeof(bindinfo)};
2451 BOOL ret = TRUE;
2452 LPWSTR wstr;
2453 DWORD dw;
2454 HRESULT hres;
2455
2456 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2457 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2458
2459 dw = 0xdeadbeef;
2460 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2461 SET_EXPECT(GetBindInfo);
2462 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2463 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2464 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2465 CHECK_CALLED(GetBindInfo);
2466
2467 test_GetBindInfoEx(holder);
2468
2469 SET_EXPECT(OnStartBinding);
2470 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2471 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2472 CHECK_CALLED(OnStartBinding);
2473
2474 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2475 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2476
2477 SET_EXPECT(QueryInterface_IHttpNegotiate);
2478 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2479 (void**)&http_negotiate_serv);
2480 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2481 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2482
2483 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2484
2485 wstr = (void*)0xdeadbeef;
2486 SET_EXPECT(QueryInterface_IHttpNegotiate);
2487 SET_EXPECT(BeginningTransaction);
2488 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
2489 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2490 CHECK_CALLED(BeginningTransaction);
2491 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2492 ok(wstr == NULL, "wstr = %p\n", wstr);
2493
2494 IHttpNegotiate_Release(http_negotiate_serv);
2495
2496 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2497 (void**)&http_negotiate_serv);
2498 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2499 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2500 IHttpNegotiate_Release(http_negotiate_serv);
2501
2502 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2503 if(SUCCEEDED(hres)) {
2504 have_IHttpNegotiate2 = TRUE;
2505
2506 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2507 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2508 (void**)&http_negotiate2_serv);
2509 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2510 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2511 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2512
2513 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2514 SET_EXPECT(GetRootSecurityId);
2515 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2516 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2517 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2518 CHECK_CALLED(GetRootSecurityId);
2519
2520 IHttpNegotiate_Release(http_negotiate2_serv);
2521 IHttpNegotiate_Release(http_negotiate2);
2522 }else {
2523 skip("Could not get IHttpNegotiate2\n");
2524 ret = FALSE;
2525 }
2526
2527 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2528 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2529 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2530 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2531
2532 SET_EXPECT(QueryInterface_IHttpNegotiate);
2533 SET_EXPECT(OnResponse);
2534 wstr = (void*)0xdeadbeef;
2535 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2536 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2537 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2538 CHECK_CALLED(OnResponse);
2539
2540 IHttpNegotiate_Release(http_negotiate);
2541
2542 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2543 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2544
2545 SET_EXPECT(QueryInterface_IAuthenticate);
2546 SET_EXPECT(QueryService_IAuthenticate);
2547 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2548 (void**)&authenticate_serv);
2549 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2550 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2551 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2552 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2553 IAuthenticate_Release(authenticate_serv);
2554
2555 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2556 (void**)&authenticate_serv);
2557 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2558 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2559
2560 IAuthenticate_Release(authenticate);
2561 IAuthenticate_Release(authenticate_serv);
2562
2563 SET_EXPECT(OnStopBinding);
2564 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2565 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2566 CHECK_CALLED(OnStopBinding);
2567
2568 SET_EXPECT(QueryInterface_IInternetProtocol);
2569 SET_EXPECT(QueryService_IInternetProtocol);
2570 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2571 (void**)&protocol);
2572 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2573 CHECK_CALLED(QueryInterface_IInternetProtocol);
2574 CHECK_CALLED(QueryService_IInternetProtocol);
2575
2576 IServiceProvider_Release(serv_prov);
2577 return ret;
2578 }
2579
2580 static BOOL test_RegisterBindStatusCallback(void)
2581 {
2582 IBindStatusCallback *prevbsc, *clb, *prev_clb;
2583 IBindCtx *bindctx;
2584 BOOL ret = TRUE;
2585 IUnknown *unk;
2586 HRESULT hres;
2587
2588 hres = CreateBindCtx(0, &bindctx);
2589 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2590
2591 SET_EXPECT(QueryInterface_IServiceProvider);
2592
2593 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2594 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2595
2596 SET_EXPECT(QueryInterface_IBindStatusCallback);
2597 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2598 prevbsc = (void*)0xdeadbeef;
2599 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2600 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2601 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2602 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2603 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2604
2605 CHECK_CALLED(QueryInterface_IServiceProvider);
2606
2607 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2608 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2609
2610 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2611 IUnknown_Release(unk);
2612 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2613 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2614
2615 if(!test_bscholder(clb))
2616 ret = FALSE;
2617
2618 IBindStatusCallback_Release(clb);
2619
2620 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2621 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2622
2623 unk = (void*)0xdeadbeef;
2624 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2625 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2626 ok(unk == NULL, "unk != NULL\n");
2627
2628 if(unk)
2629 IUnknown_Release(unk);
2630
2631 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2632 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2633
2634 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2635 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2636
2637 hres = RevokeBindStatusCallback(bindctx, NULL);
2638 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2639
2640 SET_EXPECT(QueryInterface_IServiceProvider);
2641 prevbsc = (void*)0xdeadbeef;
2642 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2643 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2644 ok(!prevbsc, "prevbsc=%p\n", prevbsc);
2645 CHECK_CALLED(QueryInterface_IServiceProvider);
2646
2647 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2648 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2649
2650 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&prev_clb);
2651 IUnknown_Release(unk);
2652 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2653 ok(prev_clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2654
2655 SET_EXPECT(QueryInterface_IServiceProvider);
2656 prevbsc = (void*)0xdeadbeef;
2657 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc2, &prevbsc, 0);
2658 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2659 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc != bsc\n");
2660 CHECK_CALLED(QueryInterface_IServiceProvider);
2661
2662 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2663 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2664
2665 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2666 IUnknown_Release(unk);
2667 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2668 ok(prev_clb == clb, "bsc != clb\n");
2669
2670 IBindStatusCallback_Release(clb);
2671 IBindStatusCallback_Release(prev_clb);
2672
2673 IBindCtx_Release(bindctx);
2674 return ret;
2675 }
2676
2677 #define BINDTEST_EMULATE 0x0001
2678 #define BINDTEST_TOOBJECT 0x0002
2679 #define BINDTEST_FILEDWLAPI 0x0004
2680 #define BINDTEST_HTTPRESPONSE 0x0008
2681 #define BINDTEST_REDIRECT 0x0010
2682 #define BINDTEST_USE_CACHE 0x0020
2683 #define BINDTEST_NO_CALLBACK_READ 0x0040
2684 #define BINDTEST_NO_CALLBACK 0x0080
2685 #define BINDTEST_ABORT 0x0100
2686 #define BINDTEST_INVALID_CN 0x0200
2687 #define BINDTEST_ABORT_START 0x0400
2688 #define BINDTEST_ABORT_PROGRESS 0x0800
2689
2690 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2691 {
2692 test_protocol = protocol;
2693 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2694 download_state = BEFORE_DOWNLOAD;
2695 stopped_binding = FALSE;
2696 stopped_obj_binding = FALSE;
2697 data_available = FALSE;
2698 mime_type[0] = 0;
2699 binding_hres = S_OK;
2700 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2701 tymed = t;
2702 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2703 if(flags & BINDTEST_HTTPRESPONSE)
2704 urls[HTTP_TEST] = winetest_post_urlW;
2705 else
2706 urls[HTTP_TEST] = winetest_data_urlW;
2707 if(flags & BINDTEST_INVALID_CN)
2708 urls[HTTPS_TEST] = https_invalid_cn_urlW;
2709 else
2710 urls[HTTPS_TEST] = https_urlW;
2711 test_redirect = (flags & BINDTEST_REDIRECT) != 0;
2712 use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
2713 callback_read = !(flags & BINDTEST_NO_CALLBACK_READ);
2714 no_callback = (flags & BINDTEST_NO_CALLBACK) != 0;
2715 test_abort = (flags & BINDTEST_ABORT) != 0;
2716 abort_start = (flags & BINDTEST_ABORT_START) != 0;
2717 abort_progress = (flags & BINDTEST_ABORT_PROGRESS) != 0;
2718 is_async_prot = protocol == HTTP_TEST || protocol == HTTPS_TEST || protocol == FTP_TEST || protocol == WINETEST_TEST;
2719 }
2720
2721 static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
2722 {
2723 IMoniker *mon;
2724 HRESULT hres;
2725 LPOLESTR display_name;
2726 IBindCtx *bctx = NULL;
2727 MSG msg;
2728 IBindStatusCallback *previousclb;
2729 IUnknown *unk = (IUnknown*)0x00ff00ff;
2730 IBinding *bind;
2731
2732 init_bind_test(protocol, flags, t);
2733
2734 if(no_callback) {
2735 hres = CreateBindCtx(0, &bctx);
2736 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2737 }else {
2738 SET_EXPECT(QueryInterface_IServiceProvider);
2739 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2740 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2741 CHECK_CALLED(QueryInterface_IServiceProvider);
2742 if(FAILED(hres))
2743 return;
2744
2745 SET_EXPECT(QueryInterface_IServiceProvider);
2746 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2747 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2748 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2749 CHECK_CALLED(QueryInterface_IServiceProvider);
2750 if(previousclb)
2751 IBindStatusCallback_Release(previousclb);
2752 }
2753
2754 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2755 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
2756 if(FAILED(hres))
2757 return;
2758
2759 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2760 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2761 if(SUCCEEDED(hres))
2762 IBinding_Release(bind);
2763
2764 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2765 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2766 ok(!lstrcmpW(display_name, urls[test_protocol]),
2767 "GetDisplayName got wrong name %s\n", wine_dbgstr_w(display_name));
2768 CoTaskMemFree(display_name);
2769
2770 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2771 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2772 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted &&
2773 (onsecurityproblem_hres != S_OK || security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)) {
2774 if(security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)
2775 binding_hres = INET_E_SECURITY_PROBLEM;
2776 else
2777 binding_hres = INET_E_INVALID_CERTIFICATE;
2778 }
2779
2780
2781 if(only_check_prot_args)
2782 SET_EXPECT(OnStopBinding);
2783 if(!no_callback) {
2784 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2785 SET_EXPECT(GetBindInfo);
2786 SET_EXPECT(QueryInterface_IInternetProtocol);
2787 if(!emulate_protocol)
2788 SET_EXPECT(QueryService_IInternetProtocol);
2789 SET_EXPECT(OnStartBinding);
2790 }
2791 if(emulate_protocol) {
2792 if(is_urlmon_protocol(test_protocol))
2793 SET_EXPECT(SetPriority);
2794 SET_EXPECT(Start);
2795 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
2796 SET_EXPECT(Terminate);
2797 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2798 SET_EXPECT(UnlockRequest);
2799 }else {
2800 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2801 SET_EXPECT(QueryInterface_IInternetBindInfo);
2802 SET_EXPECT(QueryService_IInternetBindInfo);
2803 if(!abort_start)
2804 SET_EXPECT(QueryInterface_IHttpNegotiate);
2805 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2806 SET_EXPECT(QueryService_IWindowForBindingUI);
2807 SET_EXPECT(GetWindow_IWindowForBindingUI);
2808 if(!abort_start) {
2809 SET_EXPECT(BeginningTransaction);
2810 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2811 SET_EXPECT(GetRootSecurityId);
2812 if(http_is_first)
2813 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2814 SET_EXPECT(OnProgress_CONNECTING);
2815 }
2816 if(flags & BINDTEST_INVALID_CN) {
2817 SET_EXPECT(QueryInterface_IHttpSecurity);
2818 SET_EXPECT(QueryService_IHttpSecurity);
2819 SET_EXPECT(OnSecurityProblem);
2820 if(SUCCEEDED(onsecurityproblem_hres))
2821 SET_EXPECT(GetWindow_IHttpSecurity);
2822 }
2823 }
2824 if(!no_callback) {
2825 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
2826 || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) && !abort_start)
2827 SET_EXPECT(OnProgress_SENDINGREQUEST);
2828 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2829 SET_EXPECT(QueryInterface_IHttpNegotiate);
2830 SET_EXPECT(OnResponse);
2831 }
2832 if(!abort_start) {
2833 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2834 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2835 }
2836 if(test_protocol == FILE_TEST)
2837 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2838 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
2839 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2840 if(!abort_start)
2841 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2842 if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
2843 SET_EXPECT(OnDataAvailable);
2844 SET_EXPECT(OnStopBinding);
2845 }
2846 }
2847
2848 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2849 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2850 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2851 {
2852 skip("Network unreachable, skipping tests\n");
2853 return;
2854 }
2855
2856 if(only_check_prot_args) {
2857 ok(hres == E_FAIL, "Got %08x\n", hres);
2858 CHECK_CALLED(OnStopBinding);
2859 } else if(abort_start)
2860 ok(hres == abort_hres, "IMoniker_BindToStorage failed: %08x, expected %08x\n", hres, abort_hres);
2861 else if(abort_progress)
2862 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2863 else if(no_callback) {
2864 if(emulate_protocol)
2865 WaitForSingleObject(complete_event2, INFINITE);
2866 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2867 ok(unk != NULL, "unk == NULL\n");
2868 }else if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) {
2869 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2870 ok(unk == NULL, "unk != NULL\n");
2871 }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2872 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2873 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2874 ok(unk == NULL, "istr should be NULL\n");
2875 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2876 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2877 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2878 ok(unk == NULL, "istr should be NULL\n");
2879 }else if((flags & BINDTEST_INVALID_CN) && binding_hres != S_OK) {
2880 ok(hres == binding_hres, "Got %08x\n", hres);
2881 ok(unk == NULL, "Got %p\n", unk);
2882 }else if((flags & BINDTEST_INVALID_CN) && invalid_cn_accepted) {
2883 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2884 ok(unk != NULL, "unk == NULL\n");
2885 if(unk == NULL) {
2886 ok(0, "Expected security problem to be ignored.\n");
2887 invalid_cn_accepted = FALSE;
2888 binding_hres = INET_E_INVALID_CERTIFICATE;
2889 }
2890 }else {
2891 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2892 ok(unk != NULL, "unk == NULL\n");
2893 }
2894 if(unk && callback_read && !no_callback) {
2895 IUnknown_Release(unk);
2896 unk = NULL;
2897 }
2898
2899 if(FAILED(hres) && !(flags & BINDTEST_INVALID_CN) && !(flags & BINDTEST_ABORT_START))
2900 return;
2901
2902 if((bindf & BINDF_ASYNCHRONOUS) && !no_callback) {
2903 while(!stopped_binding && GetMessage(&msg,NULL,0,0)) {
2904 TranslateMessage(&msg);
2905 DispatchMessage(&msg);
2906 }
2907 }
2908
2909 if(!no_callback) {
2910 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2911 CHECK_CALLED(GetBindInfo);
2912 if(abort_start)
2913 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
2914 else
2915 CHECK_CALLED(QueryInterface_IInternetProtocol);
2916 if(!emulate_protocol) {
2917 if(abort_start)
2918 todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
2919 else
2920 CHECK_CALLED(QueryService_IInternetProtocol);
2921 }
2922 CHECK_CALLED(OnStartBinding);
2923 }
2924 if(emulate_protocol) {
2925 if(is_urlmon_protocol(test_protocol))
2926 CHECK_CALLED(SetPriority);
2927 CHECK_CALLED(Start);
2928 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2929 if(tymed == TYMED_FILE)
2930 CLEAR_CALLED(Read);
2931 CHECK_CALLED(Terminate);
2932 }
2933 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2934 CHECK_CALLED(UnlockRequest);
2935 }else {
2936 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2937 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2938 CLEAR_CALLED(QueryService_IInternetBindInfo);
2939 if(!abort_start)
2940 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2941 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2942 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2943 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
2944 if(!abort_start)
2945 CHECK_CALLED(BeginningTransaction);
2946 if (have_IHttpNegotiate2 && !abort_start)
2947 {
2948 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2949 CHECK_CALLED(GetRootSecurityId);
2950 }
2951 if(http_is_first) {
2952 if (! proxy_active())
2953 {
2954 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2955 CHECK_CALLED(OnProgress_CONNECTING);
2956 }
2957 else
2958 {
2959 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
2960 CLEAR_CALLED(OnProgress_CONNECTING);
2961 }
2962 }else if(!abort_start) {
2963 /* IE7 does call this */
2964 CLEAR_CALLED(OnProgress_CONNECTING);
2965 }
2966 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted) {
2967 CHECK_CALLED(QueryInterface_IHttpSecurity);
2968 CHECK_CALLED(QueryService_IHttpSecurity);
2969 CHECK_CALLED(OnSecurityProblem);
2970 }else {
2971 CHECK_NOT_CALLED(QueryInterface_IHttpSecurity);
2972 CHECK_NOT_CALLED(QueryService_IHttpSecurity);
2973 CHECK_NOT_CALLED(OnSecurityProblem);
2974 }
2975 }
2976 if(!no_callback) {
2977 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) {
2978 if(flags & BINDTEST_INVALID_CN)
2979 CLEAR_CALLED(OnProgress_SENDINGREQUEST);
2980 else if(!abort_start)
2981 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2982 } else if(test_protocol == FTP_TEST)
2983 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
2984 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2985 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2986 if((!(flags & BINDTEST_INVALID_CN) || (binding_hres == S_OK)) && !abort_start) {
2987 CHECK_CALLED(OnResponse);
2988 }
2989 }
2990 if((!(flags & BINDTEST_INVALID_CN) || binding_hres == S_OK) && !abort_start) {
2991 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2992 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2993 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2994 }
2995 if(test_protocol == FILE_TEST)
2996 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2997 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
2998 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2999 if((flags & BINDTEST_INVALID_CN)) {
3000 if(binding_hres == S_OK)
3001 CHECK_CALLED(OnDataAvailable);
3002 else
3003 CHECK_NOT_CALLED(OnDataAvailable);
3004 }else if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
3005 CHECK_CALLED(OnDataAvailable);
3006 CHECK_CALLED(OnStopBinding);
3007 }
3008 }
3009
3010 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3011 if(bctx)
3012 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
3013
3014 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3015 http_is_first = FALSE;
3016
3017 if((flags & BINDTEST_INVALID_CN) && onsecurityproblem_hres == S_OK && security_problem != ERROR_INTERNET_SEC_CERT_ERRORS)
3018 invalid_cn_accepted = TRUE;
3019
3020 if(unk) {
3021 BYTE buf[512];
3022 DWORD readed;
3023 IStream *stream;
3024
3025 hres = IUnknown_QueryInterface(unk, &IID_IStream, (void**)&stream);
3026 ok(hres == S_OK, "Could not get IStream iface: %08x\n", hres);
3027 IUnknown_Release(unk);
3028
3029 do {
3030 readed = 0xdeadbeef;
3031 hres = IStream_Read(stream, buf, sizeof(buf), &readed);
3032 ok(readed != 0xdeadbeef, "readed = 0xdeadbeef\n");
3033 if(emulate_protocol && test_protocol == HTTP_TEST && readed)
3034 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
3035 }while(hres == S_OK);
3036 ok(hres == S_FALSE, "IStream_Read returned %08x\n", hres);
3037 ok(!readed, "readed = %d\n", readed);
3038
3039 IStream_Release(stream);
3040 }
3041 }
3042
3043 static void test_BindToObject(int protocol, DWORD flags)
3044 {
3045 IMoniker *mon;
3046 HRESULT hres;
3047 LPOLESTR display_name;
3048 IBindCtx *bctx;
3049 DWORD regid;
3050 MSG msg;
3051 IUnknown *unk = (IUnknown*)0x00ff00ff;
3052 IBinding *bind;
3053
3054 init_bind_test(protocol, BINDTEST_TOOBJECT|flags, TYMED_ISTREAM);
3055
3056 if(emulate_protocol)
3057 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
3058 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
3059
3060 SET_EXPECT(QueryInterface_IServiceProvider);
3061 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx);
3062 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3063 CHECK_CALLED(QueryInterface_IServiceProvider);
3064 if(FAILED(hres))
3065 return;
3066
3067 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
3068 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
3069 if(FAILED(hres)) {
3070 IBindCtx_Release(bctx);
3071 return;
3072 }
3073
3074 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
3075 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
3076 if(SUCCEEDED(hres))
3077 IBinding_Release(bind);
3078
3079 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
3080 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
3081 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
3082 CoTaskMemFree(display_name);
3083
3084 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3085 SET_EXPECT(Obj_GetBindInfo);
3086 SET_EXPECT(QueryInterface_IInternetProtocol);
3087 if(!emulate_protocol)
3088 SET_EXPECT(QueryService_IInternetProtocol);
3089 SET_EXPECT(Obj_OnStartBinding);
3090 if(emulate_protocol) {
3091 if(is_urlmon_protocol(test_protocol))
3092 SET_EXPECT(SetPriority);
3093 SET_EXPECT(Start);
3094 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3095 SET_EXPECT(Terminate);
3096 if(test_protocol == FILE_TEST)
3097 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3098 SET_EXPECT(UnlockRequest);
3099 }else {
3100 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3101 SET_EXPECT(QueryInterface_IHttpNegotiate);
3102 SET_EXPECT(BeginningTransaction);
3103 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3104 SET_EXPECT(GetRootSecurityId);
3105 if(http_is_first)
3106 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
3107 SET_EXPECT(Obj_OnProgress_CONNECTING);
3108 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3109 SET_EXPECT(QueryService_IWindowForBindingUI);
3110 SET_EXPECT(GetWindow_IWindowForBindingUI);
3111 }
3112 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3113 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
3114 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3115 SET_EXPECT(QueryInterface_IHttpNegotiate);
3116 SET_EXPECT(OnResponse);
3117 }
3118 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
3119 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
3120 if(test_protocol == FILE_TEST)
3121 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3122 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3123 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3124 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
3125 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
3126 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
3127 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
3128 SET_EXPECT(OnObjectAvailable);
3129 SET_EXPECT(Obj_OnStopBinding);
3130 }
3131
3132 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
3133
3134 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3135 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
3136 {
3137 skip( "Network unreachable, skipping tests\n" );
3138 return;
3139 }
3140
3141 /* no point testing the calls if binding didn't even work */
3142 if (FAILED(hres)) return;
3143
3144 if(bindf & BINDF_ASYNCHRONOUS) {
3145 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
3146 ok(unk == NULL, "istr should be NULL\n");
3147 }else {
3148 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3149 ok(unk != NULL, "unk == NULL\n");
3150 if(emulate_protocol)
3151 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
3152 }
3153 if(unk)
3154 IUnknown_Release(unk);
3155
3156 while((bindf & BINDF_ASYNCHRONOUS) &&
3157 !((!emulate_protocol || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
3158 TranslateMessage(&msg);
3159 DispatchMessage(&msg);
3160 }
3161
3162 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
3163 CHECK_CALLED(Obj_GetBindInfo);
3164 CHECK_CALLED(QueryInterface_IInternetProtocol);
3165 if(!emulate_protocol)
3166 CHECK_CALLED(QueryService_IInternetProtocol);
3167 CHECK_CALLED(Obj_OnStartBinding);
3168 if(emulate_protocol) {
3169 if(is_urlmon_protocol(test_protocol))
3170 CHECK_CALLED(SetPriority);
3171 CHECK_CALLED(Start);
3172 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3173 CHECK_CALLED(Terminate);
3174 if(test_protocol == FILE_TEST)
3175 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
3176 CHECK_CALLED(UnlockRequest);
3177 }else {
3178 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3179 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3180 CHECK_CALLED(BeginningTransaction);
3181 if (have_IHttpNegotiate2)
3182 {
3183 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3184 CHECK_CALLED(GetRootSecurityId);
3185 }
3186 if(http_is_first) {
3187 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
3188 CHECK_CALLED(Obj_OnProgress_CONNECTING);
3189 }else {
3190 /* IE7 does call this */
3191 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
3192 }
3193 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3194 CLEAR_CALLED(QueryService_IWindowForBindingUI);
3195 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
3196 }
3197 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
3198 if(urls[test_protocol] == winetest_post_urlW)
3199 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
3200 else
3201 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
3202 }
3203 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3204 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3205 CHECK_CALLED(OnResponse);
3206 }
3207 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
3208 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
3209 if(test_protocol == FILE_TEST)
3210 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3211 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3212 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3213 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
3214 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
3215 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
3216 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
3217 CHECK_CALLED(OnObjectAvailable);
3218 CHECK_CALLED(Obj_OnStopBinding);
3219 }
3220
3221 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3222 if(test_protocol != HTTP_TEST || emulate_protocol || !(bindf & BINDF_ASYNCHRONOUS))
3223 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
3224 else
3225 IBindCtx_Release(bctx);
3226
3227 if(emulate_protocol)
3228 CoRevokeClassObject(regid);
3229
3230 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3231 http_is_first = FALSE;
3232 }
3233
3234 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
3235 {
3236 BOOL res;
3237 HRESULT hres;
3238
3239 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
3240
3241 SET_EXPECT(GetBindInfo);
3242 SET_EXPECT(QueryInterface_IInternetProtocol);
3243 if(!emulate_protocol) {
3244 SET_EXPECT(QueryInterface_IServiceProvider);
3245 SET_EXPECT(QueryService_IInternetProtocol);
3246 }
3247 SET_EXPECT(OnStartBinding);
3248 if(emulate_protocol) {
3249 if(is_urlmon_protocol(test_protocol))
3250 SET_EXPECT(SetPriority);
3251 SET_EXPECT(Start);
3252 SET_EXPECT(UnlockRequest);
3253 }else {
3254 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3255 SET_EXPECT(QueryInterface_IHttpNegotiate);
3256 SET_EXPECT(BeginningTransaction);
3257 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3258 SET_EXPECT(GetRootSecurityId);
3259 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3260 SET_EXPECT(OnProgress_CONNECTING);
3261 }
3262 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3263 SET_EXPECT(OnProgress_SENDINGREQUEST);
3264 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3265 SET_EXPECT(QueryInterface_IHttpNegotiate);
3266 SET_EXPECT(OnResponse);
3267 }
3268 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3269 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3270 if(test_protocol == FILE_TEST)
3271 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
3272 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3273 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3274 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3275 SET_EXPECT(OnStopBinding);
3276 }
3277
3278 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol],
3279 dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3280 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3281
3282 CHECK_CALLED(GetBindInfo);
3283 CHECK_CALLED(QueryInterface_IInternetProtocol);
3284 if(!emulate_protocol) {
3285 CHECK_CALLED(QueryInterface_IServiceProvider);
3286 CHECK_CALLED(QueryService_IInternetProtocol);
3287 }
3288 CHECK_CALLED(OnStartBinding);
3289 if(emulate_protocol) {
3290 if(is_urlmon_protocol(test_protocol))
3291 CHECK_CALLED(SetPriority);
3292 CHECK_CALLED(Start);
3293 CHECK_CALLED(UnlockRequest);
3294 }else {
3295 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3296 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3297 CHECK_CALLED(BeginningTransaction);
3298 if (have_IHttpNegotiate2)
3299 {
3300 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3301 CHECK_CALLED(GetRootSecurityId);
3302 }
3303 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3304 CLEAR_CALLED(OnProgress_CONNECTING);
3305 }
3306 if(test_protocol == FILE_TEST)
3307 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3308 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3309 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
3310 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3311 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3312 CHECK_CALLED(OnResponse);
3313 }
3314 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3315 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3316 if(test_protocol == FILE_TEST)
3317 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
3318 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3319 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3320 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3321 CHECK_CALLED(OnStopBinding);
3322 }
3323
3324 res = DeleteFileA(dwl_htmlA);
3325 ok(res, "DeleteFile failed: %u\n", GetLastError());
3326
3327 if(prot != FILE_TEST || emul)
3328 return;
3329
3330 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
3331 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3332
3333 res = DeleteFileA(dwl_htmlA);
3334 ok(res, "DeleteFile failed: %u\n", GetLastError());
3335 }
3336
3337 static void test_URLDownloadToFile_abort(void)
3338 {
3339 HRESULT hres;
3340
3341 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_PROGRESS, TYMED_FILE);
3342
3343 SET_EXPECT(GetBindInfo);
3344 SET_EXPECT(QueryInterface_IInternetProtocol);
3345 SET_EXPECT(QueryInterface_IServiceProvider);
3346 SET_EXPECT(QueryService_IInternetProtocol);
3347 SET_EXPECT(OnStartBinding);
3348 SET_EXPECT(QueryInterface_IHttpNegotiate);
3349 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3350 SET_EXPECT(BeginningTransaction);
3351 SET_EXPECT(GetRootSecurityId);
3352 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3353 SET_EXPECT(OnProgress_CONNECTING);
3354 SET_EXPECT(OnProgress_SENDINGREQUEST);
3355 SET_EXPECT(OnStopBinding);
3356
3357 hres = URLDownloadToFileW(NULL, urls[HTTP_TEST], dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3358 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres);
3359
3360 CHECK_CALLED(GetBindInfo);
3361 CHECK_CALLED(QueryInterface_IInternetProtocol);
3362 CHECK_CALLED(QueryInterface_IServiceProvider);
3363 CHECK_CALLED(QueryService_IInternetProtocol);
3364 CHECK_CALLED(OnStartBinding);
3365 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3366 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3367 CHECK_CALLED(BeginningTransaction);
3368 CHECK_CALLED(GetRootSecurityId);
3369 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3370 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3371 CLEAR_CALLED(OnProgress_CONNECTING);
3372 CHECK_CALLED(OnStopBinding);
3373
3374 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE);
3375
3376 SET_EXPECT(GetBindInfo);
3377 SET_EXPECT(QueryInterface_IInternetProtocol);
3378 SET_EXPECT(QueryInterface_IServiceProvider);
3379 SET_EXPECT(QueryService_IInternetProtocol);
3380 SET_EXPECT(OnStartBinding);
3381 SET_EXPECT(OnStopBinding);
3382
3383 abort_hres = E_ABORT;
3384 hres = URLDownloadToFileW(NULL, urls[HTTP_TEST], dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3385 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres);
3386
3387 CHECK_CALLED(GetBindInfo);
3388 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
3389 todo_wine CHECK_CALLED(QueryInterface_IServiceProvider);
3390 todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
3391 CHECK_CALLED(OnStartBinding);
3392 CHECK_CALLED(OnStopBinding);
3393
3394 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE);
3395
3396 SET_EXPECT(GetBindInfo);
3397 SET_EXPECT(QueryInterface_IInternetProtocol);
3398 SET_EXPECT(QueryInterface_IServiceProvider);
3399 SET_EXPECT(QueryService_IInternetProtocol);
3400 SET_EXPECT(OnStartBinding);
3401 SET_EXPECT(QueryInterface_IHttpNegotiate);
3402 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3403 SET_EXPECT(BeginningTransaction);
3404 SET_EXPECT(GetRootSecurityId);
3405 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3406 SET_EXPECT(OnResponse);
3407 SET_EXPECT(OnProgress_CONNECTING);
3408 SET_EXPECT(OnProgress_SENDINGREQUEST);
3409 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3410 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3411 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3412 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3413 SET_EXPECT(OnStopBinding);
3414
3415 /* URLDownloadToFile doesn't abort if E_NOTIMPL is returned from the
3416 * IBindStatusCallback's OnStartBinding function.
3417 */
3418 abort_hres = E_NOTIMPL;
3419 hres = URLDownloadToFileW(NULL, urls[HTTP_TEST], dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3420 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3421
3422 CHECK_CALLED(GetBindInfo);
3423 CHECK_CALLED(QueryInterface_IInternetProtocol);
3424 CHECK_CALLED(QueryInterface_IServiceProvider);
3425 CHECK_CALLED(QueryService_IInternetProtocol);
3426 CHECK_CALLED(OnStartBinding);
3427 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3428 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3429 CHECK_CALLED(BeginningTransaction);
3430 CHECK_CALLED(GetRootSecurityId);
3431 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3432 CHECK_CALLED(OnResponse);
3433 CLEAR_CALLED(OnProgress_CONNECTING);
3434 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3435 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3436 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3437 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
3438 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3439 CHECK_CALLED(OnStopBinding);
3440
3441 DeleteFileA(dwl_htmlA);
3442 }
3443
3444 static void set_file_url(char *path)
3445 {
3446 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
3447 CHAR INDEX_HTMLA[MAX_PATH];
3448
3449 lstrcpyA(file_urlA, "file:///");
3450 lstrcatA(file_urlA, path);
3451 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
3452
3453 lstrcpyA(INDEX_HTMLA, "file://");
3454 lstrcatA(INDEX_HTMLA, path);
3455 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
3456 }
3457
3458 static void create_file(void)
3459 {
3460 HANDLE file;
3461 DWORD size;
3462 CHAR path[MAX_PATH];
3463
3464 static const char html_doc[] = "<HTML></HTML>";
3465
3466 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3467 FILE_ATTRIBUTE_NORMAL, NULL);
3468 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3469 if(file == INVALID_HANDLE_VALUE)
3470 return;
3471
3472 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
3473 CloseHandle(file);
3474
3475 GetCurrentDirectoryA(MAX_PATH, path);
3476 lstrcatA(path, "\\");
3477 lstrcatA(path, wszIndexHtmlA);
3478 set_file_url(path);
3479 }
3480
3481 static void create_cache_file(void)
3482 {
3483 char buf[6500], curdir[MAX_PATH];
3484 HANDLE file;
3485 DWORD size;
3486
3487 file = CreateFileA(test_txtA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3488 FILE_ATTRIBUTE_NORMAL, NULL);
3489 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3490 if(file == INVALID_HANDLE_VALUE)
3491 return;
3492
3493 memset(buf, 'X', sizeof(buf));
3494 WriteFile(file, buf, sizeof(buf), &size, NULL);
3495 CloseHandle(file);
3496
3497 memset(curdir, 0, sizeof(curdir));
3498 GetCurrentDirectoryA(MAX_PATH, curdir);
3499 lstrcatA(curdir, "\\");
3500 lstrcatA(curdir, test_txtA);
3501
3502 MultiByteToWideChar(CP_ACP, 0, curdir, -1, cache_file_name, MAX_PATH);
3503 }
3504
3505 static void test_ReportResult(HRESULT exhres)
3506 {
3507 IMoniker *mon = NULL;
3508 IBindCtx *bctx = NULL;
3509 IUnknown *unk = (void*)0xdeadbeef;
3510 HRESULT hres;
3511
3512 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3513 binding_hres = exhres;
3514
3515 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
3516 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3517
3518 SET_EXPECT(QueryInterface_IServiceProvider);
3519 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
3520 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3521 CHECK_CALLED(QueryInterface_IServiceProvider);
3522
3523 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3524 SET_EXPECT(GetBindInfo);
3525 SET_EXPECT(QueryInterface_IInternetProtocol);
3526 SET_EXPECT(OnStartBinding);
3527 if(is_urlmon_protocol(test_protocol))
3528 SET_EXPECT(SetPriority);
3529 SET_EXPECT(Start);
3530
3531 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3532 if(SUCCEEDED(exhres))
3533 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
3534 else
3535 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
3536 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
3537
3538 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
3539 CHECK_CALLED(GetBindInfo);
3540 CHECK_CALLED(QueryInterface_IInternetProtocol);
3541 CHECK_CALLED(OnStartBinding);
3542 if(is_urlmon_protocol(test_protocol))
3543 CHECK_CALLED(SetPriority);
3544 CHECK_CALLED(Start);
3545
3546 ok(unk == NULL, "unk=%p\n", unk);
3547
3548 IBindCtx_Release(bctx);
3549 IMoniker_Release(mon);
3550 }
3551
3552 static void test_BindToStorage_fail(void)
3553 {
3554 IMoniker *mon = NULL;
3555 IBindCtx *bctx = NULL;
3556 IUnknown *unk;
3557 HRESULT hres;
3558
3559 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
3560 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3561 if(FAILED(hres))
3562 return;
3563
3564 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
3565 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
3566
3567 unk = (void*)0xdeadbeef;
3568 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3569 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
3570 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
3571 ok(unk == NULL, "got %p\n", unk);
3572
3573 IBindCtx_Release(bctx);
3574
3575 IMoniker_Release(mon);
3576
3577 test_ReportResult(E_NOTIMPL);
3578 test_ReportResult(S_FALSE);
3579 }
3580
3581 static void test_StdURLMoniker(void)
3582 {
3583 IMoniker *mon, *async_mon;
3584 LPOLESTR display_name;
3585 HRESULT hres;
3586
3587 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3588 &IID_IMoniker, (void**)&mon);
3589 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
3590 if(FAILED(hres))
3591 return;
3592
3593 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
3594 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
3595 ok(mon == async_mon, "mon != async_mon\n");
3596 IMoniker_Release(async_mon);
3597
3598 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
3599 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
3600
3601 if(pCreateUri) {
3602 IUriContainer *uri_container;
3603 IUri *uri;
3604
3605 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
3606 ok(hres == S_OK, "Coud not get IUriMoniker iface: %08x\n", hres);
3607
3608
3609 uri = (void*)0xdeadbeef;
3610 hres = IUriContainer_GetIUri(uri_container, &uri);
3611 ok(hres == S_FALSE, "GetIUri failed: %08x\n", hres);
3612 ok(!uri, "uri = %p, expected NULL\n", uri);
3613
3614 IUriContainer_Release(uri_container);
3615 }
3616
3617 IMoniker_Release(mon);
3618 }
3619
3620 static void register_protocols(void)
3621 {
3622 IInternetSession *session;
3623 HRESULT hres;
3624
3625 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
3626
3627 hres = CoInternetGetSession(0, &session, 0);
3628 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3629 if(FAILED(hres))
3630 return;
3631
3632 hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
3633 winetestW, 0, NULL, 0);
3634 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3635
3636 IInternetSession_Release(session);
3637 }
3638
3639 START_TEST(url)
3640 {
3641 HMODULE hurlmon;
3642
3643 hurlmon = GetModuleHandle("urlmon.dll");
3644 pCreateAsyncBindCtxEx = (void*) GetProcAddress(hurlmon, "CreateAsyncBindCtxEx");
3645
3646 if(!GetProcAddress(hurlmon, "CompareSecurityIds")) {
3647 win_skip("Too old IE\n");
3648 return;
3649 }
3650
3651 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
3652 if(!pCreateUri)
3653 win_skip("IUri not supported\n");
3654
3655 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
3656 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
3657 thread_id = GetCurrentThreadId();
3658 create_file();
3659 create_cache_file();
3660 register_protocols();
3661
3662 test_create();
3663
3664 trace("test CreateAsyncBindCtx...\n");
3665 test_CreateAsyncBindCtx();
3666
3667 trace("test CreateAsyncBindCtxEx...\n");
3668 test_CreateAsyncBindCtxEx();
3669
3670 trace("test RegisterBindStatusCallback...\n");
3671 if(test_RegisterBindStatusCallback()) {
3672 trace("test BindToStorage failures...\n");
3673 test_BindToStorage_fail();
3674
3675 trace("synchronous http test (COM not initialised)...\n");
3676 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3677
3678 CoInitialize(NULL);
3679
3680 trace("test StdURLMoniker...\n");
3681 test_StdURLMoniker();
3682
3683 trace("synchronous http test...\n");
3684 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3685
3686 trace("emulated synchronous http test (to file)...\n");
3687 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3688
3689 trace("synchronous http test (to object)...\n");
3690 test_BindToObject(HTTP_TEST, 0);
3691
3692 trace("emulated synchronous http test (with cache)...\n");
3693 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3694
3695 trace("emulated synchronous http test (with cache, no read)...\n");
3696 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3697
3698 trace("synchronous http test (with cache, no read)...\n");
3699 test_BindToStorage(HTTP_TEST, BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3700
3701 trace("synchronous file test...\n");
3702 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3703
3704 trace("emulated synchronous file test (to file)...\n");
3705 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3706
3707 trace("synchronous file test (to object)...\n");
3708 test_BindToObject(FILE_TEST, 0);
3709
3710 trace("file test (no callback)...\n");
3711 test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM);
3712
3713 trace("synchronous https test (invalid CN, dialog)\n");
3714 onsecurityproblem_hres = S_FALSE;
3715 http_is_first = TRUE;
3716 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3717
3718 trace("synchronous https test (invalid CN, fail)\n");
3719 onsecurityproblem_hres = E_FAIL;
3720 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3721
3722 trace("synchronous https test (invalid CN, accept)\n");
3723 onsecurityproblem_hres = S_OK;
3724 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3725
3726 trace("asynchronous https test (invalid CN, dialog 2)\n");
3727 onsecurityproblem_hres = S_FALSE;
3728 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3729 invalid_cn_accepted = FALSE;
3730
3731 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
3732
3733 trace("about test (no read)...\n");
3734 test_BindToStorage(ABOUT_TEST, BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3735
3736 trace("http test...\n");
3737 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3738
3739 trace("http test (to file)...\n");
3740 test_BindToStorage(HTTP_TEST, 0, TYMED_FILE);
3741
3742 trace("http test (to object)...\n");
3743 test_BindToObject(HTTP_TEST, 0);
3744
3745 trace("http test (short response)...\n");
3746 test_BindToStorage(HTTP_TEST, BINDTEST_HTTPRESPONSE, TYMED_ISTREAM);
3747
3748 trace("http test (short response, to object)...\n");
3749 test_BindToObject(HTTP_TEST, 0);
3750
3751 trace("http test (abort start binding E_NOTIMPL)...\n");
3752 abort_hres = E_NOTIMPL;
3753 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
3754
3755 trace("http test (abort start binding E_ABORT)...\n");
3756 abort_hres = E_ABORT;
3757 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
3758
3759 trace("http test (abort progress)...\n");
3760 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_PROGRESS, TYMED_FILE);
3761
3762 trace("emulated http test...\n");
3763 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3764
3765 trace("emulated http test (to object)...\n");
3766 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE);
3767
3768 trace("emulated http test (to object, redirect)...\n");
3769 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT);
3770
3771 trace("emulated http test (to file)...\n");
3772 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3773
3774 trace("emulated http test (redirect)...\n");
3775 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, TYMED_ISTREAM);
3776
3777 trace("emulated http test (with cache)...\n");
3778 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3779
3780 trace("winetest test (no callback)...\n");
3781 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3782
3783 trace("asynchronous https test...\n");
3784 http_is_first = TRUE;
3785 test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
3786
3787 trace("emulated https test...\n");
3788 test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3789
3790 trace("about test...\n");
3791 test_BindToStorage(ABOUT_TEST, 0, TYMED_ISTREAM);
3792
3793 trace("about test (to file)...\n");
3794 test_BindToStorage(ABOUT_TEST, 0, TYMED_FILE);
3795
3796 trace("about test (to object)...\n");
3797 test_BindToObject(ABOUT_TEST, 0);
3798
3799 trace("emulated about test...\n");
3800 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3801
3802 trace("emulated about test (to file)...\n");
3803 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE);
3804
3805 trace("emulated about test (to object)...\n");
3806 test_BindToObject(ABOUT_TEST, BINDTEST_EMULATE);
3807
3808 trace("file test...\n");
3809 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3810
3811 trace("file test (to file)...\n");
3812 test_BindToStorage(FILE_TEST, 0, TYMED_FILE);
3813
3814 trace("file test (to object)...\n");
3815 test_BindToObject(FILE_TEST, 0);
3816
3817 trace("emulated file test...\n");
3818 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3819
3820 trace("emulated file test (to file)...\n");
3821 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3822
3823 trace("emulated file test (to object)...\n");
3824 test_BindToObject(FILE_TEST, BINDTEST_EMULATE);
3825
3826 trace("emulated its test...\n");
3827 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3828
3829 trace("emulated its test (to file)...\n");
3830 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_FILE);
3831
3832 trace("emulated mk test...\n");
3833 test_BindToStorage(MK_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3834
3835 trace("test URLDownloadToFile for file protocol...\n");
3836 test_URLDownloadToFile(FILE_TEST, FALSE);
3837
3838 trace("test URLDownloadToFile for emulated file protocol...\n");
3839 test_URLDownloadToFile(FILE_TEST, TRUE);
3840
3841 trace("test URLDownloadToFile for http protocol...\n");
3842 test_URLDownloadToFile(HTTP_TEST, FALSE);
3843
3844 trace("test URLDownloadToFile abort...\n");
3845 test_URLDownloadToFile_abort();
3846
3847 trace("test emulated http abort...\n");
3848 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_ABORT, TYMED_ISTREAM);
3849
3850 bindf |= BINDF_NOWRITECACHE;
3851
3852 trace("ftp test...\n");
3853 test_BindToStorage(FTP_TEST, 0, TYMED_ISTREAM);
3854
3855 trace("test failures...\n");
3856 test_BindToStorage_fail();
3857
3858 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE;
3859 only_check_prot_args = TRUE; /* Fail after checking arguments to Protocol_Start */
3860
3861 trace("check emulated http protocol arguments...\n");
3862 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3863 }
3864
3865 DeleteFileA(wszIndexHtmlA);
3866 DeleteFileA(test_txtA);
3867 CloseHandle(complete_event);
3868 CloseHandle(complete_event2);
3869 CoUninitialize();
3870 }