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