makefiles: Don't use standard libs for programs that specify -nodefaultlibs.
[wine/zf.git] / dlls / urlmon / tests / url.c
blobcfa29248d6c018f7ca1cc8259bd6572e579cb02c
1 /*
2 * UrlMon URL tests
4 * Copyright 2004 Kevin Koltzau
5 * Copyright 2004-2007 Jacek Caban for CodeWeavers
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.
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.
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
22 #include <stdarg.h>
23 #include <stdio.h>
25 #define COBJMACROS
26 #define NONAMELESSUNION
27 #define CONST_VTABLE
29 #include "windef.h"
30 #include "winbase.h"
31 #include "initguid.h"
32 #include "urlmon.h"
33 #include "wininet.h"
34 #include "mshtml.h"
35 #include "shlwapi.h"
37 #include "wine/test.h"
39 static HRESULT (WINAPI *pCreateAsyncBindCtxEx)(IBindCtx *, DWORD,
40 IBindStatusCallback *, IEnumFORMATETC *, IBindCtx **, DWORD);
41 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
43 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
45 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
46 extern CLSID CLSID_AboutProtocol;
48 #define DEFINE_EXPECT(func) \
49 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
51 #define SET_EXPECT(func) \
52 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
54 #define CHECK_EXPECT2(func) \
55 do { \
56 ok(expect_ ##func, "unexpected call " #func "\n"); \
57 called_ ## func = TRUE; \
58 }while(0)
60 #define CHECK_EXPECT(func) \
61 do { \
62 CHECK_EXPECT2(func); \
63 expect_ ## func = FALSE; \
64 }while(0)
66 #define CHECK_CALLED(func) \
67 do { \
68 ok(called_ ## func, "expected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
70 }while(0)
72 #define CHECK_NOT_CALLED(func) \
73 do { \
74 ok(!called_ ## func, "unexpected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
76 }while(0)
78 #define CHECK_CALLED_BROKEN(func) \
79 do { \
80 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
81 expect_ ## func = called_ ## func = FALSE; \
82 }while(0)
84 #define CLEAR_CALLED(func) \
85 expect_ ## func = called_ ## func = FALSE
87 DEFINE_EXPECT(QueryInterface_IServiceProvider);
88 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
89 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
90 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
91 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
92 DEFINE_EXPECT(QueryInterface_IAuthenticate);
93 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
94 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI);
95 DEFINE_EXPECT(QueryInterface_IHttpSecurity);
96 DEFINE_EXPECT(QueryService_IAuthenticate);
97 DEFINE_EXPECT(QueryService_IInternetProtocol);
98 DEFINE_EXPECT(QueryService_IInternetBindInfo);
99 DEFINE_EXPECT(QueryService_IWindowForBindingUI);
100 DEFINE_EXPECT(QueryService_IHttpSecurity);
101 DEFINE_EXPECT(BeginningTransaction);
102 DEFINE_EXPECT(OnResponse);
103 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
104 DEFINE_EXPECT(GetRootSecurityId);
105 DEFINE_EXPECT(GetBindInfo);
106 DEFINE_EXPECT(GetBindInfoEx);
107 DEFINE_EXPECT(OnStartBinding);
108 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
109 DEFINE_EXPECT(OnProgress_CONNECTING);
110 DEFINE_EXPECT(OnProgress_REDIRECTING);
111 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
112 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
113 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
114 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
115 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
116 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
117 DEFINE_EXPECT(OnStopBinding);
118 DEFINE_EXPECT(OnDataAvailable);
119 DEFINE_EXPECT(OnObjectAvailable);
120 DEFINE_EXPECT(Obj_OnStartBinding);
121 DEFINE_EXPECT(Obj_OnStopBinding);
122 DEFINE_EXPECT(Obj_GetBindInfo);
123 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
124 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
125 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
126 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
127 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
128 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
129 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
130 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
131 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
132 DEFINE_EXPECT(Obj_OnProgress_REDIRECTING);
133 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
134 DEFINE_EXPECT(Start);
135 DEFINE_EXPECT(Read);
136 DEFINE_EXPECT(LockRequest);
137 DEFINE_EXPECT(Terminate);
138 DEFINE_EXPECT(UnlockRequest);
139 DEFINE_EXPECT(Continue);
140 DEFINE_EXPECT(Abort);
141 DEFINE_EXPECT(CreateInstance);
142 DEFINE_EXPECT(Load);
143 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
144 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
145 DEFINE_EXPECT(SetPriority);
146 DEFINE_EXPECT(GetWindow_IHttpSecurity);
147 DEFINE_EXPECT(GetWindow_IWindowForBindingUI);
148 DEFINE_EXPECT(GetWindow_ICodeInstall);
149 DEFINE_EXPECT(OnSecurityProblem);
151 static const WCHAR winetest_data_urlW[] =
152 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
153 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
154 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
156 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
158 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
160 static const WCHAR wszWineHQSite[] =
161 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
162 static const WCHAR wszWineHQIP[] =
163 {'4','.','1','5','.','1','8','4','.','7','7',0};
164 static const CHAR wszIndexHtmlA[] = "index.html";
165 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
166 static const CHAR dwl_htmlA[] = "dwl.html";
167 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
168 static const CHAR test_txtA[] = "test.txt";
169 static const WCHAR emptyW[] = {0};
171 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
172 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api, post_test;
173 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed, security_problem;
174 static const WCHAR *reported_url;
175 static CHAR mime_type[512];
176 static IInternetProtocolSink *protocol_sink = NULL;
177 static IBinding *current_binding;
178 static HANDLE complete_event, complete_event2;
179 static HRESULT binding_hres;
180 static HRESULT onsecurityproblem_hres;
181 static HRESULT abort_hres;
182 static BOOL have_IHttpNegotiate2, use_bscex, is_async_prot;
183 static BOOL test_redirect, use_cache_file, callback_read, no_callback, test_abort;
184 static WCHAR cache_file_name[MAX_PATH];
185 static WCHAR http_cache_file[MAX_PATH];
186 static BOOL only_check_prot_args = FALSE;
187 static BOOL invalid_cn_accepted = FALSE;
188 static BOOL abort_start = FALSE;
189 static BOOL abort_progress = FALSE;
190 static BOOL async_switch = FALSE;
191 static BOOL strict_bsc_qi;
192 static DWORD bindtest_flags;
193 static const char *test_file;
195 static WCHAR file_url[INTERNET_MAX_URL_LENGTH], current_url[INTERNET_MAX_URL_LENGTH];
197 static enum {
198 HTTP_TEST,
199 ABOUT_TEST,
200 FILE_TEST,
201 ITS_TEST,
202 MK_TEST,
203 HTTPS_TEST,
204 FTP_TEST,
205 WINETEST_TEST,
206 WINETEST_SYNC_TEST
207 } test_protocol;
209 static enum {
210 BEFORE_DOWNLOAD,
211 DOWNLOADING,
212 END_DOWNLOAD
213 } download_state;
215 static BOOL proxy_active(void)
217 HKEY internet_settings;
218 DWORD proxy_enable;
219 DWORD size;
221 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
222 0, KEY_QUERY_VALUE, &internet_settings) != ERROR_SUCCESS)
223 return FALSE;
225 size = sizeof(DWORD);
226 if (RegQueryValueExA(internet_settings, "ProxyEnable", NULL, NULL, (LPBYTE) &proxy_enable, &size) != ERROR_SUCCESS)
227 proxy_enable = 0;
229 RegCloseKey(internet_settings);
231 return proxy_enable != 0;
234 static BOOL is_urlmon_protocol(int prot)
236 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
239 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
241 HRESULT hr;
242 IMoniker *mon1 = NULL;
243 IMoniker *mon2 = NULL;
245 hr = CreateURLMoniker(NULL, NULL, NULL);
246 ok(hr == E_INVALIDARG,
247 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
249 mon1 = (IMoniker *)0xdeadbeef;
250 hr = CreateURLMoniker(NULL, NULL, &mon1);
251 ok(hr == E_INVALIDARG,
252 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
253 ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1);
255 hr = CreateURLMoniker(NULL, emptyW, NULL);
256 ok(hr == E_INVALIDARG,
257 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
259 hr = CreateURLMoniker(NULL, emptyW, &mon1);
260 ok(hr == S_OK ||
261 broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */
262 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr);
263 if(mon1) IMoniker_Release(mon1);
265 hr = CreateURLMoniker(NULL, url1, &mon1);
266 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
267 if(hr == S_OK) {
268 hr = CreateURLMoniker(mon1, url2, &mon2);
269 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
271 if(mon1) IMoniker_Release(mon1);
272 if(mon2) IMoniker_Release(mon2);
275 static void test_create(void)
277 static const WCHAR relativeW[] = {'a','/','b','.','t','x','t',0};
278 IStream *stream;
279 IMoniker *mon;
280 IBindCtx *bctx;
281 HRESULT hr;
283 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
285 test_CreateURLMoniker(winetest_data_urlW, TEST_PART_URL_1);
287 mon = (void*)0xdeadbeef;
288 hr = CreateURLMoniker(NULL, relativeW, &mon);
289 ok(hr == S_OK, "got 0x%08x\n", hr);
291 hr = CreateBindCtx(0, &bctx);
292 ok(hr == S_OK, "got 0x%08x\n", hr);
294 stream = (void*)0xdeadbeef;
295 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&stream);
296 todo_wine ok(hr == INET_E_UNKNOWN_PROTOCOL, "got 0x%08x\n", hr);
297 ok(stream == NULL, "got %p\n", stream);
299 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
300 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
302 stream = (void*)0xdeadbeef;
303 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
304 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
305 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
306 "got %p\n", stream);
308 IMoniker_Release(mon);
310 mon = (void*)0xdaedbeef;
311 hr = CreateURLMoniker(NULL, winetest_data_urlW, &mon);
312 ok(hr == S_OK, "got 0x%08x\n", hr);
314 stream = (void*)0xdeadbeef;
315 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
316 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
317 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
318 "got %p\n", stream);
320 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
321 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
323 IMoniker_Release(mon);
324 IBindCtx_Release(bctx);
327 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
329 ok(0, "unexpected call\n");
330 return E_NOINTERFACE;
333 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
335 return 2;
338 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
340 return 1;
343 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
345 CHECK_EXPECT(SetPriority);
346 ok(!nPriority, "nPriority = %d\n", nPriority);
347 return S_OK;
350 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
352 ok(0, "unexpected call\n");
353 return S_OK;
356 static const IInternetPriorityVtbl InternetPriorityVtbl = {
357 Priority_QueryInterface,
358 Priority_AddRef,
359 Priority_Release,
360 Priority_SetPriority,
361 Priority_GetPriority
364 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
366 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
368 if (winetest_debug > 1) trace("IInternetProtocol::QueryInterface(%s)\n", debugstr_guid(riid));
370 *ppv = NULL;
372 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
373 *ppv = iface;
374 return S_OK;
377 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
378 if(!is_urlmon_protocol(test_protocol))
379 return E_NOINTERFACE;
381 *ppv = &InternetPriority;
382 return S_OK;
385 return E_NOINTERFACE;
388 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
390 return 2;
393 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
395 return 1;
398 static void test_switch_fail(void)
400 IInternetProtocolSink *binding_sink;
401 PROTOCOLDATA protocoldata = {0};
402 HRESULT hres;
404 static BOOL tested_switch_fail;
406 if(tested_switch_fail)
407 return;
409 tested_switch_fail = TRUE;
411 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
412 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
413 if(SUCCEEDED(hres)) {
414 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
415 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
416 IInternetProtocolSink_Release(binding_sink);
420 static DWORD WINAPI thread_proc(PVOID arg)
422 PROTOCOLDATA protocoldata = {0};
423 HRESULT hres;
425 if(!no_callback) {
426 if(bind_to_object)
427 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
428 else
429 SET_EXPECT(OnProgress_FINDINGRESOURCE);
431 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
432 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
433 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
434 if(!no_callback) {
435 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
436 if(bind_to_object)
437 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
438 else
439 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
442 if(!no_callback) {
443 if(bind_to_object)
444 SET_EXPECT(Obj_OnProgress_CONNECTING);
445 else
446 SET_EXPECT(OnProgress_CONNECTING);
448 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
449 BINDSTATUS_CONNECTING, wszWineHQIP);
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_CONNECTING);
455 else
456 CHECK_CALLED(OnProgress_CONNECTING);
459 if(!no_callback) {
460 if(bind_to_object)
461 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
462 else
463 SET_EXPECT(OnProgress_SENDINGREQUEST);
465 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
466 BINDSTATUS_SENDINGREQUEST, NULL);
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_SENDINGREQUEST);
472 else
473 CHECK_CALLED(OnProgress_SENDINGREQUEST);
476 if(test_redirect) {
477 if(bind_to_object)
478 SET_EXPECT(Obj_OnProgress_REDIRECTING);
479 else
480 SET_EXPECT(OnProgress_REDIRECTING);
481 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_REDIRECTING, winetest_data_urlW);
482 ok(hres == S_OK, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres);
483 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
484 if(bind_to_object)
485 CHECK_CALLED(Obj_OnProgress_REDIRECTING);
486 else
487 CHECK_CALLED(OnProgress_REDIRECTING);
490 test_switch_fail();
492 SET_EXPECT(Continue);
493 prot_state = 1;
494 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
495 ok(hres == S_OK, "Switch failed: %08x\n", hres);
496 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
498 CHECK_CALLED(Continue);
499 CHECK_CALLED(Read);
500 if(bind_to_object) {
501 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
502 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
503 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
504 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
505 CHECK_CALLED(CreateInstance);
506 CHECK_CALLED(PutProperty_MIMETYPEPROP);
507 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
508 CHECK_CALLED(Load);
509 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
510 CHECK_CALLED(OnObjectAvailable);
511 CHECK_CALLED(Obj_OnStopBinding);
512 }else if(!no_callback) {
513 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
514 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
515 CHECK_CALLED(OnDataAvailable);
516 }else {
517 CHECK_CALLED(LockRequest);
520 SET_EXPECT(Continue);
521 prot_state = 2;
522 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
523 ok(hres == S_OK, "Switch failed: %08x\n", hres);
524 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
525 CHECK_CALLED(Continue);
526 if(test_abort) {
527 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
528 CHECK_CALLED(OnStopBinding);
529 SetEvent(complete_event2);
530 return 0;
531 }else {
532 CHECK_CALLED(Read);
533 if(!no_callback) {
534 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
535 CHECK_CALLED(OnDataAvailable);
539 SET_EXPECT(Continue);
540 prot_state = 2;
541 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
542 ok(hres == S_OK, "Switch failed: %08x\n", hres);
543 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
544 CHECK_CALLED(Continue);
545 CHECK_CALLED(Read);
546 if(!no_callback) {
547 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
548 CHECK_CALLED(OnDataAvailable);
551 SET_EXPECT(Continue);
552 prot_state = 3;
553 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
554 ok(hres == S_OK, "Switch failed: %08x\n", hres);
555 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
556 CHECK_CALLED(Continue);
557 CHECK_CALLED(Read);
558 if(!no_callback) {
559 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
560 CHECK_CALLED(OnDataAvailable);
561 CHECK_CALLED(OnStopBinding);
564 SET_EXPECT(Read);
566 SetEvent(complete_event2);
567 return 0;
570 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
571 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
572 DWORD grfPI, HANDLE_PTR dwReserved)
574 BINDINFO bindinfo;
575 DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
576 HRESULT hres;
578 static const STGMEDIUM stgmed_zero = {0};
579 static const SECURITY_ATTRIBUTES sa_zero = {0};
581 CHECK_EXPECT(Start);
583 read = 0;
585 reported_url = szUrl;
586 if(!filedwl_api) /* FIXME */
587 ok(szUrl && !lstrcmpW(szUrl, current_url), "wrong url %s\n", wine_dbgstr_w(szUrl));
588 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
589 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
590 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
591 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
593 if(!filedwl_api && binding_hres != S_OK) {
594 SET_EXPECT(OnStopBinding);
595 SET_EXPECT(Terminate);
596 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
597 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
598 CHECK_CALLED(OnStopBinding);
599 CHECK_CALLED(Terminate);
601 return S_OK;
604 memset(&bindinfo, 0, sizeof(bindinfo));
605 bindinfo.cbSize = 0;
606 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
607 ok(hres == E_INVALIDARG, "GetBindInfo returned: %08x, expected E_INVALIDARG\n", hres);
609 memset(&bindinfo, 0, sizeof(bindinfo));
610 bindinfo.cbSize = sizeof(bindinfo);
611 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
612 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
614 ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n");
616 if(filedwl_api || !is_urlmon_protocol(test_protocol) || tymed != TYMED_ISTREAM ||
617 !(bindf&BINDF_ASYNCSTORAGE) || !(bindf&BINDF_PULLDATA))
618 ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n");
619 else if(test_protocol != MK_TEST) /* IE10 sets BINDF_NEEDFILE for mk: protocol */
620 ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n");
622 bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON);
623 if(filedwl_api || no_callback)
624 ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info);
625 else
626 ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n",
627 bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)));
629 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
630 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
631 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
632 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
633 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
634 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
635 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
636 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
637 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
638 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
639 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
640 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
641 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
642 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
644 if(only_check_prot_args)
645 return E_FAIL;
647 switch(test_protocol) {
648 case MK_TEST:
649 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
650 BINDSTATUS_DIRECTBIND, NULL);
651 ok(hres == S_OK,
652 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
654 case FILE_TEST:
655 case ITS_TEST:
656 if(bind_to_object)
657 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
658 else
659 SET_EXPECT(OnProgress_SENDINGREQUEST);
660 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
661 BINDSTATUS_SENDINGREQUEST, emptyW);
662 ok(hres == S_OK,
663 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
664 if(bind_to_object)
665 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
666 else
667 CHECK_CALLED(OnProgress_SENDINGREQUEST);
668 case WINETEST_SYNC_TEST:
669 IInternetProtocolSink_AddRef(pOIProtSink);
670 protocol_sink = pOIProtSink;
671 default:
672 break;
675 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
676 IServiceProvider *service_provider;
677 IHttpNegotiate *http_negotiate;
678 IHttpNegotiate2 *http_negotiate2;
679 IHttpSecurity *http_security;
680 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
681 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
682 BYTE sec_id[100];
683 DWORD fetched = 256, size = 100;
684 DWORD tid;
686 static const WCHAR wszMimes[] = {'*','/','*',0};
688 SET_EXPECT(QueryService_IInternetBindInfo);
689 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
690 &ua, 1, &fetched);
691 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
693 ok(hres == E_NOINTERFACE,
694 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
695 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
696 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
698 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
699 accept_mimes, 256, &fetched);
700 ok(hres == S_OK,
701 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
702 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
703 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
704 CoTaskMemFree(accept_mimes[0]);
706 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
707 NULL, 256, &fetched);
708 ok(hres == E_INVALIDARG,
709 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
711 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
712 accept_mimes, 256, NULL);
713 ok(hres == E_INVALIDARG,
714 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
716 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
717 (void**)&service_provider);
718 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
720 SET_EXPECT(QueryInterface_IHttpNegotiate);
721 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
722 &IID_IHttpNegotiate, (void**)&http_negotiate);
723 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
724 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
726 if(!no_callback) {
727 SET_EXPECT(BeginningTransaction);
728 SET_EXPECT(QueryInterface_IHttpNegotiate);
730 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, current_url,
731 NULL, 0, &additional_headers);
732 if(!no_callback) {
733 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
734 CHECK_CALLED(BeginningTransaction);
736 IHttpNegotiate_Release(http_negotiate);
737 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
738 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
740 SET_EXPECT(QueryInterface_IHttpNegotiate2);
741 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
742 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
743 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
744 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
746 size = 512;
747 if(!no_callback) {
748 SET_EXPECT(QueryInterface_IHttpNegotiate2);
749 SET_EXPECT(GetRootSecurityId);
751 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
752 if(!no_callback) {
753 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
754 CHECK_CALLED(GetRootSecurityId);
756 IHttpNegotiate2_Release(http_negotiate2);
757 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
758 ok(size == (no_callback ? 512 : 13), "size=%d\n", size);
760 if(!no_callback) {
761 SET_EXPECT(QueryService_IHttpSecurity);
762 SET_EXPECT(QueryInterface_IHttpSecurity);
764 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpSecurity,
765 &IID_IHttpSecurity, (void**)&http_security);
766 ok(hres == (no_callback ? E_NOINTERFACE : S_OK), "QueryService failed: 0x%08x\n", hres);
767 if(!no_callback) {
768 CHECK_CALLED(QueryService_IHttpSecurity);
769 CHECK_CALLED(QueryInterface_IHttpSecurity);
772 IServiceProvider_Release(service_provider);
774 IInternetProtocolSink_AddRef(pOIProtSink);
775 protocol_sink = pOIProtSink;
777 if(async_switch) {
778 PROTOCOLDATA data;
780 memset(&data, 0, sizeof(data));
781 data.grfFlags = PI_FORCE_ASYNC;
782 prot_state = 0;
783 hres = IInternetProtocolSink_Switch(pOIProtSink, &data);
784 ok(hres == S_OK, "Switch failed: %08x\n", hres);
785 SET_EXPECT(Continue);
786 SetEvent(complete_event2);
787 return E_PENDING;
788 } else {
789 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
790 return S_OK;
794 if(test_protocol == FILE_TEST) {
795 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
796 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+7);
797 ok(hres == S_OK,
798 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
800 if(bind_to_object)
801 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
802 else
803 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
804 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
805 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
806 ok(hres == S_OK,
807 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
808 if(bind_to_object)
809 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
810 else
811 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
812 }else if(test_protocol == WINETEST_SYNC_TEST) {
813 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
814 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
815 ok(hres == S_OK,
816 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
817 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
818 }else {
819 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
820 ok(hres == S_OK,
821 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
824 if(test_protocol == ABOUT_TEST)
825 bscf |= BSCF_DATAFULLYAVAILABLE;
826 if(test_protocol == ITS_TEST)
827 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
829 SET_EXPECT(Read);
830 if(bind_to_object) {
831 if(test_protocol != FILE_TEST && test_protocol != MK_TEST && test_protocol != WINETEST_SYNC_TEST)
832 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
833 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
834 if(test_protocol == FILE_TEST)
835 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
836 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
837 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
838 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
839 SET_EXPECT(CreateInstance);
840 SET_EXPECT(PutProperty_MIMETYPEPROP);
841 SET_EXPECT(PutProperty_CLASSIDPROP);
842 SET_EXPECT(Load);
843 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
844 SET_EXPECT(OnObjectAvailable);
845 SET_EXPECT(Obj_OnStopBinding);
846 }else {
847 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
848 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
849 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
850 if(test_protocol == FILE_TEST)
851 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
852 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
853 SET_EXPECT(LockRequest);
854 if(!filedwl_api)
855 SET_EXPECT(OnDataAvailable);
856 if(test_protocol != WINETEST_SYNC_TEST) /* Set in Read after ReportResult call */
857 SET_EXPECT(OnStopBinding);
860 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
861 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
863 CHECK_CALLED(Read);
864 if(bind_to_object) {
865 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
866 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
867 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
868 if(test_protocol == FILE_TEST)
869 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
870 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
871 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
872 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
873 CHECK_CALLED(CreateInstance);
874 CHECK_CALLED(PutProperty_MIMETYPEPROP);
875 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
876 CHECK_CALLED(Load);
877 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
878 CHECK_CALLED(OnObjectAvailable);
879 CHECK_CALLED(Obj_OnStopBinding);
880 }else {
881 if(test_protocol != FILE_TEST && test_protocol != MK_TEST && test_protocol != WINETEST_SYNC_TEST)
882 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
883 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
884 if(test_protocol == FILE_TEST)
885 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
886 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
887 CHECK_CALLED(LockRequest);
888 if(!filedwl_api)
889 CHECK_CALLED(OnDataAvailable);
890 CHECK_CALLED(OnStopBinding);
893 if(test_protocol == ITS_TEST) {
894 SET_EXPECT(Read);
895 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
896 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
897 CHECK_CALLED(Read);
898 }else if(!bind_to_object && test_protocol == FILE_TEST) {
899 SET_EXPECT(Read);
900 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
901 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
902 CHECK_CALLED(Read);
905 if(test_protocol != WINETEST_SYNC_TEST) {
906 SET_EXPECT(Terminate);
907 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
908 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
909 CHECK_CALLED(Terminate);
912 return S_OK;
915 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
916 PROTOCOLDATA *pProtocolData)
918 DWORD bscf = 0;
919 HRESULT hres;
921 CHECK_EXPECT(Continue);
923 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
925 if(!bind_to_object)
926 ok(reported_url && !lstrcmpW(reported_url, current_url), "wrong url %s\n", wine_dbgstr_w(reported_url));
928 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
929 if(!pProtocolData)
930 return S_OK;
932 switch(prot_state) {
933 case 0:
934 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
935 BINDSTATUS_SENDINGREQUEST, NULL);
936 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
938 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
939 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
940 ok(hres == S_OK,
941 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
943 bscf |= BSCF_FIRSTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION;
944 break;
945 case 1: {
946 IServiceProvider *service_provider;
947 IHttpNegotiate *http_negotiate;
948 static const WCHAR header[] = {'?',0};
950 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
951 (void**)&service_provider);
952 ok(hres == S_OK, "Could not get IServiceProvicder\n");
954 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
955 &IID_IHttpNegotiate, (void**)&http_negotiate);
956 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
958 if(!no_callback) {
959 SET_EXPECT(QueryInterface_IHttpNegotiate);
960 SET_EXPECT(OnResponse);
962 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
963 if(!no_callback) {
964 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
965 CHECK_CALLED(OnResponse);
967 IHttpNegotiate_Release(http_negotiate);
968 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
970 if(test_protocol == HTTPS_TEST || test_redirect) {
971 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
972 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
975 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
976 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
977 ok(hres == S_OK,
978 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
980 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
981 BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW);
982 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
984 bscf |= BSCF_FIRSTDATANOTIFICATION;
985 break;
987 case 2:
988 case 3:
989 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
990 break;
993 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
994 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
996 if(prot_state != 2 || !test_abort)
997 SET_EXPECT(Read);
998 switch(prot_state) {
999 case 0:
1000 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1001 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1002 SET_EXPECT(OnProgress_SENDINGREQUEST);
1003 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1004 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1005 SET_EXPECT(LockRequest);
1006 SET_EXPECT(OnStopBinding);
1007 break;
1008 case 1:
1009 if(bind_to_object) {
1010 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1011 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1012 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1013 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1014 SET_EXPECT(CreateInstance);
1015 SET_EXPECT(PutProperty_MIMETYPEPROP);
1016 SET_EXPECT(PutProperty_CLASSIDPROP);
1017 SET_EXPECT(Load);
1018 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1019 SET_EXPECT(OnObjectAvailable);
1020 SET_EXPECT(Obj_OnStopBinding);
1021 }else if(!no_callback) {
1022 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1023 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1024 SET_EXPECT(LockRequest);
1025 }else {
1026 SET_EXPECT(LockRequest);
1028 break;
1029 case 2:
1030 if(!no_callback)
1031 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1032 break;
1033 case 3:
1034 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1035 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1037 if(!no_callback) {
1038 if((!bind_to_object || prot_state >= 2) && (!test_abort || prot_state != 2))
1039 SET_EXPECT(OnDataAvailable);
1040 if(prot_state == 3 || (test_abort && prot_state == 2))
1041 SET_EXPECT(OnStopBinding);
1043 return S_OK;
1046 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
1047 DWORD dwOptions)
1049 HRESULT hres;
1051 CHECK_EXPECT(Abort);
1053 ok(hrReason == E_ABORT, "hrReason = %08x\n", hrReason);
1054 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
1056 hres = IInternetProtocolSink_ReportResult(protocol_sink, E_ABORT, ERROR_SUCCESS, NULL);
1057 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1059 return S_OK;
1062 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
1064 CHECK_EXPECT(Terminate);
1066 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
1068 if(protocol_sink) {
1069 IInternetProtocolSink_Release(protocol_sink);
1070 protocol_sink = NULL;
1073 if(no_callback)
1074 SetEvent(complete_event);
1075 return S_OK;
1078 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
1080 ok(0, "unexpected call\n");
1081 return E_NOTIMPL;
1084 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
1086 ok(0, "unexpected call\n");
1087 return E_NOTIMPL;
1090 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
1091 ULONG cb, ULONG *pcbRead)
1093 HRESULT hres;
1095 static const char data[] = "<HTML></HTML>";
1097 CHECK_EXPECT2(Read);
1099 ok(pv != NULL, "pv == NULL\n");
1100 ok(cb != 0, "cb == 0\n");
1101 ok(pcbRead != NULL, "pcbRead == NULL\n");
1103 if(async_switch) {
1104 if(prot_state++ > 1) {
1105 *pcbRead = 0;
1106 return S_FALSE;
1107 } else {
1108 memset(pv, '?', cb);
1109 *pcbRead = cb;
1110 return S_OK;
1114 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
1115 static BOOL pending = TRUE;
1117 pending = !pending;
1119 switch(prot_state) {
1120 case 1:
1121 case 2:
1122 if(pending) {
1123 *pcbRead = 10;
1124 memset(pv, '?', 10);
1125 if(prot_state == 2 && no_callback)
1126 SetEvent(complete_event);
1127 return E_PENDING;
1128 }else {
1129 memset(pv, '?', cb);
1130 *pcbRead = cb;
1131 read++;
1132 return S_OK;
1134 case 3:
1135 prot_state++;
1137 *pcbRead = 0;
1139 hres = IInternetProtocolSink_ReportData(protocol_sink,
1140 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
1141 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1143 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1144 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1146 return S_FALSE;
1147 case 4:
1148 *pcbRead = 0;
1149 return S_FALSE;
1153 if(read) {
1154 *pcbRead = 0;
1155 return S_FALSE;
1158 if(test_protocol == WINETEST_SYNC_TEST) {
1159 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1160 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1162 SET_EXPECT(OnStopBinding);
1165 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
1166 read += *pcbRead = sizeof(data)-1;
1167 memcpy(pv, data, sizeof(data));
1168 return S_OK;
1171 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
1172 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1174 ok(0, "unexpected call\n");
1175 return E_NOTIMPL;
1178 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
1180 CHECK_EXPECT(LockRequest);
1181 if(no_callback)
1182 SetEvent(complete_event);
1183 return S_OK;
1186 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
1188 CHECK_EXPECT(UnlockRequest);
1189 return S_OK;
1192 static const IInternetProtocolVtbl ProtocolVtbl = {
1193 Protocol_QueryInterface,
1194 Protocol_AddRef,
1195 Protocol_Release,
1196 Protocol_Start,
1197 Protocol_Continue,
1198 Protocol_Abort,
1199 Protocol_Terminate,
1200 Protocol_Suspend,
1201 Protocol_Resume,
1202 Protocol_Read,
1203 Protocol_Seek,
1204 Protocol_LockRequest,
1205 Protocol_UnlockRequest
1208 static IInternetProtocol Protocol = { &ProtocolVtbl };
1210 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
1212 if(IsEqualGUID(&IID_IUnknown, riid)
1213 || IsEqualGUID(&IID_IHttpNegotiate, riid)
1214 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1215 *ppv = iface;
1216 return S_OK;
1219 ok(0, "unexpected call\n");
1220 return E_NOINTERFACE;
1223 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
1225 return 2;
1228 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
1230 return 1;
1233 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
1234 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1236 if(onsecurityproblem_hres == S_OK)
1237 CHECK_EXPECT2(BeginningTransaction);
1238 else
1239 CHECK_EXPECT(BeginningTransaction);
1241 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1243 ok(!lstrcmpW(szURL, current_url), "szURL != current_url\n");
1244 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1245 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1246 if(pszAdditionalHeaders)
1247 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1249 return S_OK;
1252 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1253 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1255 CHECK_EXPECT(OnResponse);
1257 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1259 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1260 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1261 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1262 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1263 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1264 if(pszAdditionalRequestHeaders)
1265 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1267 return S_OK;
1270 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1271 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1273 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1275 CHECK_EXPECT(GetRootSecurityId);
1277 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1279 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1280 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1281 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1283 if(pbSecurityId == (void*)0xdeadbeef)
1284 return E_NOTIMPL;
1286 if(pcbSecurityId) {
1287 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1288 *pcbSecurityId = sizeof(sec_id);
1291 if(pbSecurityId)
1292 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1294 return E_FAIL;
1297 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1298 HttpNegotiate_QueryInterface,
1299 HttpNegotiate_AddRef,
1300 HttpNegotiate_Release,
1301 HttpNegotiate_BeginningTransaction,
1302 HttpNegotiate_OnResponse,
1303 HttpNegotiate_GetRootSecurityId
1306 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1308 static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv)
1310 ok(0, "Unexpected call\n");
1311 *ppv = NULL;
1312 if(IsEqualGUID(&IID_IHttpSecurity, riid) ||
1313 IsEqualGUID(&IID_IWindowForBindingUI, riid) ||
1314 IsEqualGUID(&IID_IUnknown, riid))
1316 *ppv = iface;
1317 return S_OK;
1320 ok(0, "Unexpected interface requested.\n");
1322 return E_NOINTERFACE;
1325 static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface)
1327 return 2;
1330 static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface)
1332 return 1;
1335 static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity *iface, REFGUID rguidReason, HWND *phwnd)
1337 if(IsEqualGUID(rguidReason, &IID_IHttpSecurity))
1338 CHECK_EXPECT(GetWindow_IHttpSecurity);
1339 else if(IsEqualGUID(rguidReason, &IID_IWindowForBindingUI))
1340 CHECK_EXPECT2(GetWindow_IWindowForBindingUI);
1341 else if(IsEqualGUID(rguidReason, &IID_ICodeInstall))
1342 CHECK_EXPECT(GetWindow_ICodeInstall);
1343 else
1344 ok(0, "Unexpected rguidReason: %s\n", wine_dbgstr_guid(rguidReason));
1346 *phwnd = NULL;
1347 return S_OK;
1350 static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem)
1352 CHECK_EXPECT(OnSecurityProblem);
1353 if(!security_problem) {
1354 ok(dwProblem == ERROR_INTERNET_SEC_CERT_CN_INVALID ||
1355 broken(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) /* Some versions of IE6 */,
1356 "Got problem: %d\n", dwProblem);
1357 security_problem = dwProblem;
1359 if(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS)
1360 binding_hres = INET_E_SECURITY_PROBLEM;
1361 }else
1362 ok(dwProblem == security_problem, "Got problem: %d\n", dwProblem);
1364 return onsecurityproblem_hres;
1367 static const IHttpSecurityVtbl HttpSecurityVtbl = {
1368 HttpSecurity_QueryInterface,
1369 HttpSecurity_AddRef,
1370 HttpSecurity_Release,
1371 HttpSecurity_GetWindow,
1372 HttpSecurity_OnSecurityProblem
1375 static IHttpSecurity HttpSecurity = { &HttpSecurityVtbl };
1377 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1379 ok(0, "unexpected call\n");
1380 return E_NOINTERFACE;
1383 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1385 return 2;
1388 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1390 return 1;
1393 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1394 REFGUID guidService, REFIID riid, void **ppv)
1396 if (winetest_debug > 1)
1397 trace("IServiceProvider::QueryService(service %s, iid %s)\n",
1398 debugstr_guid(guidService), debugstr_guid(riid));
1400 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1401 CHECK_EXPECT(QueryService_IAuthenticate);
1402 return E_NOTIMPL;
1405 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1406 CHECK_EXPECT2(QueryService_IInternetProtocol);
1407 return E_NOTIMPL;
1410 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1411 CHECK_EXPECT(QueryService_IInternetBindInfo);
1412 return E_NOTIMPL;
1415 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1416 CHECK_EXPECT2(QueryService_IWindowForBindingUI);
1417 *ppv = &HttpSecurity;
1418 return S_OK;
1421 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
1422 CHECK_EXPECT(QueryService_IHttpSecurity);
1423 *ppv = &HttpSecurity;
1424 return S_OK;
1427 *ppv = NULL;
1428 return E_NOINTERFACE;
1431 static IServiceProviderVtbl ServiceProviderVtbl = {
1432 ServiceProvider_QueryInterface,
1433 ServiceProvider_AddRef,
1434 ServiceProvider_Release,
1435 ServiceProvider_QueryService
1438 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1440 static IBindStatusCallbackEx objbsc;
1442 static void test_WinInetHttpInfo(IWinInetHttpInfo *http_info, DWORD progress)
1444 DWORD status, size;
1445 HRESULT hres, expect;
1447 /* QueryInfo changes its behavior during this request */
1448 if(progress == BINDSTATUS_SENDINGREQUEST)
1449 return;
1451 if(test_protocol==FTP_TEST && download_state==BEFORE_DOWNLOAD
1452 && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1453 expect = E_FAIL;
1454 else if(test_protocol == FTP_TEST)
1455 expect = S_FALSE;
1456 else
1457 expect = S_OK;
1459 size = sizeof(DWORD);
1460 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
1461 &status, &size, NULL, NULL);
1462 ok(hres == expect || ((progress == BINDSTATUS_COOKIE_SENT || progress == BINDSTATUS_PROXYDETECTING) && hres == S_FALSE),
1463 "progress %u: hres = %x, expected %x\n", progress, hres, expect);
1464 if(hres == S_OK) {
1465 if(download_state == BEFORE_DOWNLOAD && progress != BINDSTATUS_MIMETYPEAVAILABLE && progress != BINDSTATUS_DECODING)
1466 ok(status == 0, "progress %u: status = %d\n", progress, status);
1467 else
1468 ok(status == HTTP_STATUS_OK, "progress %u: status = %d\n", progress, status);
1469 ok(size == sizeof(DWORD), "size = %d\n", size);
1472 size = sizeof(DWORD);
1473 hres = IWinInetHttpInfo_QueryOption(http_info, INTERNET_OPTION_HANDLE_TYPE, &status, &size);
1474 if(test_protocol == FTP_TEST) {
1475 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1476 ok(hres == E_FAIL, "hres = %x\n", hres);
1477 else
1478 ok(hres == S_OK, "hres = %x\n", hres);
1480 if(hres == S_OK)
1481 ok(status == INTERNET_HANDLE_TYPE_FTP_FILE, "status = %d\n", status);
1482 } else {
1483 ok(hres == S_OK, "hres = %x\n", hres);
1484 ok(status == INTERNET_HANDLE_TYPE_HTTP_REQUEST, "status = %d\n", status);
1488 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1490 if (winetest_debug > 1) trace("IBindStatusCallback::QueryInterface(%s)\n", debugstr_guid(riid));
1492 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1494 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1495 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1496 if(emulate_protocol) {
1497 *ppv = &Protocol;
1498 return S_OK;
1499 }else {
1500 return E_NOINTERFACE;
1502 }else if (IsEqualGUID(&IID_IServiceProvider, riid)) {
1503 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1504 *ppv = &ServiceProvider;
1505 return S_OK;
1506 }else if (IsEqualGUID(&IID_IHttpNegotiate, riid)) {
1507 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1508 *ppv = &HttpNegotiate;
1509 return S_OK;
1510 }else if (IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1511 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1512 *ppv = &HttpNegotiate;
1513 return S_OK;
1514 }else if (IsEqualGUID(&IID_IAuthenticate, riid)) {
1515 CHECK_EXPECT(QueryInterface_IAuthenticate);
1516 return E_NOINTERFACE;
1517 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
1518 if(strict_bsc_qi)
1519 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1520 *ppv = iface;
1521 return S_OK;
1522 }else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid)) {
1523 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1524 return E_NOINTERFACE;
1525 }else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid)) {
1526 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1527 if(!use_bscex)
1528 return E_NOINTERFACE;
1529 *ppv = iface;
1530 return S_OK;
1531 }else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
1532 /* TODO */
1533 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
1534 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1535 return E_NOINTERFACE;
1536 }else if(IsEqualGUID(&IID_IHttpSecurity, riid)) {
1537 CHECK_EXPECT2(QueryInterface_IHttpSecurity);
1538 return E_NOINTERFACE;
1541 return E_NOINTERFACE;
1544 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1546 return 2;
1549 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1551 return 1;
1554 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1555 IBinding *pib)
1557 IWinInetHttpInfo *http_info;
1558 HRESULT hres;
1559 IMoniker *mon;
1560 DWORD res;
1561 CLSID clsid;
1562 LPOLESTR res_str;
1564 if(iface == &objbsc)
1565 CHECK_EXPECT(Obj_OnStartBinding);
1566 else
1567 CHECK_EXPECT(OnStartBinding);
1569 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1571 ok(pib != NULL, "pib should not be NULL\n");
1572 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1574 if(pib == (void*)0xdeadbeef)
1575 return S_OK;
1577 current_binding = pib;
1579 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1580 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1581 if(SUCCEEDED(hres))
1582 IMoniker_Release(mon);
1584 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1585 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1587 if(0) { /* crashes with native urlmon */
1588 hres = IBinding_GetBindResult(pib, NULL, &res, &res_str, NULL);
1589 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1591 hres = IBinding_GetBindResult(pib, &clsid, NULL, &res_str, NULL);
1592 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1593 hres = IBinding_GetBindResult(pib, &clsid, &res, NULL, NULL);
1594 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1595 hres = IBinding_GetBindResult(pib, &clsid, &res, &res_str, (void*)0xdeadbeef);
1596 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1598 hres = IBinding_GetBindResult(pib, &clsid, &res, &res_str, NULL);
1599 ok(hres == S_OK, "GetBindResult failed: %08x, expected S_OK\n", hres);
1600 ok(IsEqualCLSID(&clsid, &CLSID_NULL), "incorrect clsid: %s\n", wine_dbgstr_guid(&clsid));
1601 ok(!res, "incorrect res: %x\n", res);
1602 ok(!res_str, "incorrect res_str: %s\n", wine_dbgstr_w(res_str));
1604 if(abort_start) {
1605 binding_hres = abort_hres;
1606 return abort_hres;
1609 return S_OK;
1612 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1614 ok(0, "unexpected call\n");
1615 return E_NOTIMPL;
1618 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1620 ok(0, "unexpected call\n");
1621 return E_NOTIMPL;
1624 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1625 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1627 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1629 if (winetest_debug > 1)
1630 trace("IBindStatusCallbackEx::OnProgress(progress %u/%u, code %u, text %s)\n",
1631 ulProgress, ulProgressMax, ulStatusCode, debugstr_w(szStatusText));
1633 switch(ulStatusCode) {
1634 case BINDSTATUS_FINDINGRESOURCE:
1635 if(iface == &objbsc)
1636 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1637 else if(test_protocol == FTP_TEST)
1638 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1639 else if(test_protocol == HTTPS_TEST && !bindtest_flags)
1640 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1641 else
1642 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1643 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1644 SetEvent(complete_event);
1645 break;
1646 case BINDSTATUS_CONNECTING:
1647 if(iface == &objbsc)
1648 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1649 else if(test_protocol == FTP_TEST)
1650 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1651 else if(onsecurityproblem_hres == S_OK)
1652 CHECK_EXPECT2(OnProgress_CONNECTING);
1653 else
1654 CHECK_EXPECT(OnProgress_CONNECTING);
1655 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1656 SetEvent(complete_event);
1657 break;
1658 case BINDSTATUS_REDIRECTING:
1659 if(iface == &objbsc)
1660 CHECK_EXPECT(Obj_OnProgress_REDIRECTING);
1661 else
1662 CHECK_EXPECT(OnProgress_REDIRECTING);
1663 ok(!lstrcmpW(szStatusText, winetest_data_urlW), "unexpected status text %s\n",
1664 wine_dbgstr_w(szStatusText));
1665 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
1666 && (!bind_to_object || iface == &objbsc))
1667 SetEvent(complete_event);
1668 break;
1669 case BINDSTATUS_SENDINGREQUEST:
1670 if(iface == &objbsc)
1671 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1672 else if(test_protocol == FTP_TEST)
1673 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1674 else
1675 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1676 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1677 SetEvent(complete_event);
1679 if(abort_progress) {
1680 if(filedwl_api)
1681 binding_hres = E_ABORT;
1682 return E_ABORT;
1685 break;
1686 case BINDSTATUS_MIMETYPEAVAILABLE:
1687 if(iface == &objbsc)
1688 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1689 else
1690 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1691 if(!bind_to_object)
1692 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1693 download_state);
1694 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1695 break;
1696 case BINDSTATUS_BEGINDOWNLOADDATA:
1697 if(iface == &objbsc)
1698 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1699 else
1700 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1701 ok(szStatusText != NULL, "szStatusText == NULL\n");
1702 if(szStatusText) {
1703 if(filedwl_api) {
1704 /* FIXME */
1705 }else {
1706 ok(!lstrcmpW(szStatusText, current_url), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1709 if(!bind_to_object)
1710 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1711 download_state);
1712 download_state = DOWNLOADING;
1713 break;
1714 case BINDSTATUS_DOWNLOADINGDATA:
1715 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1716 ok(iface != &objbsc, "unexpected call\n");
1717 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1718 download_state);
1719 if(test_abort) {
1720 HRESULT hres;
1722 SET_EXPECT(Abort);
1723 hres = IBinding_Abort(current_binding);
1724 ok(hres == S_OK, "Abort failed: %08x\n", hres);
1725 CHECK_CALLED(Abort);
1727 hres = IBinding_Abort(current_binding);
1728 ok(hres == E_FAIL, "Abort failed: %08x\n", hres);
1730 binding_hres = E_ABORT;
1732 break;
1733 case BINDSTATUS_ENDDOWNLOADDATA:
1734 if(iface == &objbsc)
1735 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1736 else
1737 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1738 ok(szStatusText != NULL, "szStatusText == NULL\n");
1739 if(szStatusText) {
1740 if(filedwl_api) {
1741 /* FIXME */
1742 }else {
1743 ok(!lstrcmpW(szStatusText, current_url), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1746 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1747 download_state);
1748 download_state = END_DOWNLOAD;
1749 break;
1750 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1751 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST && test_protocol != WINETEST_TEST) {
1752 if(iface == &objbsc)
1753 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1754 else
1755 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1756 }else { /* FIXME */
1757 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1758 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1761 ok(szStatusText != NULL, "szStatusText == NULL\n");
1762 if(szStatusText && test_protocol == FILE_TEST)
1763 ok(!lstrcmpW(file_url+7, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1764 break;
1765 case BINDSTATUS_CLASSIDAVAILABLE:
1767 CLSID clsid;
1768 HRESULT hr;
1769 if(iface != &objbsc)
1770 ok(0, "unexpected call\n");
1771 else
1772 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1773 hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid);
1774 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1775 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1776 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", wine_dbgstr_guid(&clsid));
1777 break;
1779 case BINDSTATUS_BEGINSYNCOPERATION:
1780 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1781 if(iface != &objbsc)
1782 ok(0, "unexpected call\n");
1783 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1784 break;
1785 case BINDSTATUS_ENDSYNCOPERATION:
1786 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1787 if(iface != &objbsc)
1788 ok(0, "unexpected call\n");
1789 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1790 break;
1791 case BINDSTATUS_PROXYDETECTING:
1792 case BINDSTATUS_COOKIE_SENT:
1793 case BINDSTATUS_DECODING:
1794 break;
1795 default:
1796 ok(0, "unexpected code %d\n", ulStatusCode);
1799 if(current_binding) {
1800 IWinInetHttpInfo *http_info;
1801 HRESULT hres;
1803 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1804 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol)) {
1805 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1806 test_WinInetHttpInfo(http_info, ulStatusCode);
1807 } else
1808 ok(hres == E_NOINTERFACE,
1809 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1810 if(SUCCEEDED(hres))
1811 IWinInetHttpInfo_Release(http_info);
1814 return S_OK;
1817 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1819 if(iface == &objbsc) {
1820 CHECK_EXPECT(Obj_OnStopBinding);
1821 stopped_obj_binding = TRUE;
1822 }else {
1823 CHECK_EXPECT(OnStopBinding);
1824 stopped_binding = TRUE;
1827 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1829 if(only_check_prot_args) {
1830 todo_wine ok(hresult == S_OK, "Got %08x\n", hresult);
1831 return S_OK;
1834 /* ignore DNS failure */
1835 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1836 return S_OK;
1838 if(filedwl_api) {
1839 if(!abort_progress && !abort_start)
1840 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1841 else if(abort_start && abort_hres == E_NOTIMPL)
1842 todo_wine ok(hresult == S_FALSE, "binding failed: %08x, expected S_FALSE\n", hresult);
1843 else
1844 ok(hresult == E_ABORT, "binding failed: %08x, expected E_ABORT\n", hresult);
1845 } else
1846 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1847 ok(szError == NULL, "szError should be NULL\n");
1849 if(current_binding) {
1850 CLSID clsid;
1851 DWORD res;
1852 LPOLESTR res_str;
1853 HRESULT hres;
1855 hres = IBinding_GetBindResult(current_binding, &clsid, &res, &res_str, NULL);
1856 ok(hres == S_OK, "GetBindResult failed: %08x, expected S_OK\n", hres);
1857 ok(res == hresult, "res = %08x, expected %08x\n", res, binding_hres);
1858 ok(!res_str, "incorrect res_str = %s\n", wine_dbgstr_w(res_str));
1860 if(hresult==S_OK || (abort_start && hresult!=S_FALSE) || hresult == REGDB_E_CLASSNOTREG) {
1861 ok(IsEqualCLSID(&clsid, &CLSID_NULL),
1862 "incorrect protocol CLSID: %s, expected CLSID_NULL\n",
1863 wine_dbgstr_guid(&clsid));
1864 }else if(emulate_protocol) {
1865 todo_wine ok(IsEqualCLSID(&clsid, &CLSID_FtpProtocol),
1866 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n",
1867 wine_dbgstr_guid(&clsid));
1868 }else if(test_protocol == FTP_TEST) {
1869 ok(IsEqualCLSID(&clsid, &CLSID_FtpProtocol),
1870 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n",
1871 wine_dbgstr_guid(&clsid));
1872 }else if(test_protocol == FILE_TEST) {
1873 ok(IsEqualCLSID(&clsid, &CLSID_FileProtocol),
1874 "incorrect protocol CLSID: %s, expected CLSID_FileProtocol\n",
1875 wine_dbgstr_guid(&clsid));
1876 }else if(test_protocol == HTTP_TEST) {
1877 ok(IsEqualCLSID(&clsid, &CLSID_HttpProtocol),
1878 "incorrect protocol CLSID: %s, expected CLSID_HttpProtocol\n",
1879 wine_dbgstr_guid(&clsid));
1880 }else if(test_protocol == HTTPS_TEST) {
1881 ok(IsEqualCLSID(&clsid, &CLSID_HttpSProtocol),
1882 "incorrect protocol CLSID: %s, expected CLSID_HttpSProtocol\n",
1883 wine_dbgstr_guid(&clsid));
1884 }else if(test_protocol == ABOUT_TEST) {
1885 ok(IsEqualCLSID(&clsid, &CLSID_AboutProtocol),
1886 "incorrect protocol CLSID: %s, expected CLSID_AboutProtocol\n",
1887 wine_dbgstr_guid(&clsid));
1888 }else {
1889 ok(0, "unexpected (%d)\n", test_protocol);
1893 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) && emulate_protocol) {
1894 SetEvent(complete_event);
1895 if(iface != &objbsc)
1896 ok( WaitForSingleObject(complete_event2, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
1899 if(test_protocol == HTTP_TEST && !emulate_protocol && http_cache_file[0]) {
1900 HANDLE file = CreateFileW(http_cache_file, DELETE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
1901 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
1902 ok(file == INVALID_HANDLE_VALUE, "expected INVALID_HANDLE_VALUE, got %p\n", file);
1903 ok(GetLastError() == ERROR_SHARING_VIOLATION, "expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
1904 http_cache_file[0] = 0;
1907 return S_OK;
1910 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1912 DWORD cbSize;
1914 if(iface == &objbsc)
1915 CHECK_EXPECT(Obj_GetBindInfo);
1916 else
1917 CHECK_EXPECT(GetBindInfo);
1919 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1921 *grfBINDF = bindf;
1922 cbSize = pbindinfo->cbSize;
1923 memset(pbindinfo, 0, cbSize);
1924 pbindinfo->cbSize = cbSize;
1926 return S_OK;
1929 static void test_stream_seek(IStream *stream)
1931 ULARGE_INTEGER new_pos;
1932 LARGE_INTEGER pos;
1933 HRESULT hres;
1935 pos.QuadPart = 0;
1936 new_pos.QuadPart = 0xdeadbeef;
1937 hres = IStream_Seek(stream, pos, STREAM_SEEK_SET, &new_pos);
1938 ok(hres == S_OK, "Seek failed: %08x\n", hres);
1939 ok(!new_pos.QuadPart, "new_pos.QuadPart != 0\n");
1941 pos.QuadPart = 0;
1942 new_pos.QuadPart = 0xdeadbeef;
1943 hres = IStream_Seek(stream, pos, STREAM_SEEK_END, &new_pos);
1944 ok(hres == S_OK, "Seek failed: %08x\n", hres);
1945 ok(new_pos.QuadPart, "new_pos.QuadPart = 0\n");
1947 pos.QuadPart = 0;
1948 new_pos.QuadPart = 0xdeadbeef;
1949 hres = IStream_Seek(stream, pos, 100, &new_pos);
1950 ok(hres == E_FAIL, "Seek failed: %08x\n", hres);
1951 ok(new_pos.QuadPart == 0xdeadbeef, "unexpected new_pos.QuadPart\n");
1954 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1955 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1957 HRESULT hres;
1958 DWORD read;
1959 BYTE buf[512];
1960 CHAR clipfmt[512];
1962 if(iface == &objbsc)
1963 ok(0, "unexpected call\n");
1965 CHECK_EXPECT2(OnDataAvailable);
1967 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1969 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1970 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1971 download_state);
1972 data_available = TRUE;
1974 if(bind_to_object && !is_async_prot)
1975 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), "grfBSCF = %x\n", grfBSCF);
1977 ok(pformatetc != NULL, "pformatetx == NULL\n");
1978 if(pformatetc) {
1979 if (mime_type[0]) {
1980 INT ret;
1981 clipfmt[0] = 0;
1982 ret = GetClipboardFormatNameA(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1);
1983 ok(ret, "GetClipboardFormatName failed, error %d\n", GetLastError());
1984 ok(!strcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1985 pformatetc->cfFormat, clipfmt, mime_type);
1986 } else {
1987 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1989 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1990 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1991 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1992 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1995 ok(pstgmed != NULL, "stgmeg == NULL\n");
1996 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1997 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1999 switch(pstgmed->tymed) {
2000 case TYMED_ISTREAM: {
2001 IStream *stream = U(*pstgmed).pstm;
2003 ok(stream != NULL, "U(*pstgmed).pstm == NULL\n");
2005 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
2006 STATSTG stat;
2008 hres = IStream_Write(stream, buf, 10, NULL);
2009 ok(hres == STG_E_ACCESSDENIED,
2010 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
2012 hres = IStream_Commit(stream, 0);
2013 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
2015 hres = IStream_Revert(stream);
2016 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
2018 hres = IStream_Stat(stream, NULL, STATFLAG_NONAME);
2019 ok(hres == E_FAIL, "hres = %x\n", hres);
2020 if(use_cache_file && emulate_protocol) {
2021 hres = IStream_Stat(stream, &stat, STATFLAG_DEFAULT);
2022 ok(hres == S_OK, "hres = %x\n", hres);
2023 ok(!lstrcmpW(stat.pwcsName, cache_file_name),
2024 "stat.pwcsName = %s, cache_file_name = %s\n",
2025 wine_dbgstr_w(stat.pwcsName), wine_dbgstr_w(cache_file_name));
2026 CoTaskMemFree(stat.pwcsName);
2027 ok(U(stat.cbSize).LowPart == (bindf&BINDF_ASYNCHRONOUS?0:6500),
2028 "stat.cbSize.LowPart = %u\n", U(stat.cbSize).LowPart);
2029 } else {
2030 hres = IStream_Stat(stream, &stat, STATFLAG_NONAME);
2031 ok(hres == S_OK, "hres = %x\n", hres);
2032 ok(!stat.pwcsName || broken(stat.pwcsName!=NULL),
2033 "stat.pwcsName = %s\n", wine_dbgstr_w(stat.pwcsName));
2035 ok(stat.type == STGTY_STREAM, "stat.type = %x\n", stat.type);
2036 ok(U(stat.cbSize).HighPart == 0, "stat.cbSize.HighPart != 0\n");
2037 ok(stat.grfMode == (U(stat.cbSize).LowPart?GENERIC_READ:0), "stat.grfMode = %x\n", stat.grfMode);
2038 ok(stat.grfLocksSupported == 0, "stat.grfLocksSupported = %x\n", stat.grfLocksSupported);
2039 ok(stat.grfStateBits == 0, "stat.grfStateBits = %x\n", stat.grfStateBits);
2040 ok(stat.reserved == 0, "stat.reserved = %x\n", stat.reserved);
2043 if(callback_read) {
2044 do {
2045 hres = IStream_Read(stream, buf, 512, &read);
2046 if(test_protocol == HTTP_TEST && emulate_protocol && read)
2047 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
2048 }while(hres == S_OK);
2049 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
2052 if(use_cache_file && (grfBSCF & BSCF_FIRSTDATANOTIFICATION) && !(bindf & BINDF_PULLDATA))
2053 test_stream_seek(stream);
2054 break;
2056 case TYMED_FILE:
2057 if(test_protocol == FILE_TEST)
2058 ok(!lstrcmpW(pstgmed->u.lpszFileName, file_url+7),
2059 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
2060 else if(emulate_protocol)
2061 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
2062 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
2063 else if(test_protocol == HTTP_TEST)
2064 lstrcpyW(http_cache_file, pstgmed->u.lpszFileName);
2065 else
2066 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
2069 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
2070 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
2071 SetEvent(complete_event);
2073 return S_OK;
2076 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
2078 CHECK_EXPECT(OnObjectAvailable);
2080 if(iface != &objbsc)
2081 ok(0, "unexpected call\n");
2083 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", wine_dbgstr_guid(riid));
2084 ok(punk != NULL, "punk == NULL\n");
2086 return S_OK;
2089 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
2090 DWORD *grfBINDF2, DWORD *pdwReserved)
2092 CHECK_EXPECT(GetBindInfoEx);
2094 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
2095 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
2096 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
2097 ok(pdwReserved != NULL, "dwReserved == NULL\n");
2099 return S_OK;
2102 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
2103 statusclb_QueryInterface,
2104 statusclb_AddRef,
2105 statusclb_Release,
2106 statusclb_OnStartBinding,
2107 statusclb_GetPriority,
2108 statusclb_OnLowResource,
2109 statusclb_OnProgress,
2110 statusclb_OnStopBinding,
2111 statusclb_GetBindInfo,
2112 statusclb_OnDataAvailable,
2113 statusclb_OnObjectAvailable,
2114 statusclb_GetBindInfoEx
2117 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
2118 static IBindStatusCallbackEx bsc2 = { &BindStatusCallbackVtbl };
2119 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
2121 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
2123 *ppv = NULL;
2124 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2125 return E_NOINTERFACE;
2128 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
2130 return 2;
2133 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
2135 return 1;
2138 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
2140 switch(mkp) {
2141 case MIMETYPEPROP:
2142 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
2143 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
2144 break;
2145 case CLASSIDPROP:
2146 CHECK_EXPECT(PutProperty_CLASSIDPROP);
2147 break;
2148 default:
2149 break;
2152 return S_OK;
2155 static const IMonikerPropVtbl MonikerPropVtbl = {
2156 MonikerProp_QueryInterface,
2157 MonikerProp_AddRef,
2158 MonikerProp_Release,
2159 MonikerProp_PutProperty
2162 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
2164 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
2166 *ppv = NULL;
2168 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
2169 *ppv = iface;
2170 else if(IsEqualGUID(&IID_IMonikerProp, riid))
2171 *ppv = &MonikerProp;
2173 if(*ppv)
2174 return S_OK;
2176 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2177 return E_NOINTERFACE;
2180 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
2182 return 2;
2185 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
2187 return 1;
2190 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
2192 ok(0, "unexpected call\n");
2193 return E_NOTIMPL;
2196 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
2198 ok(0, "unexpected call\n");
2199 return E_NOTIMPL;
2202 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
2203 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
2205 IUnknown *unk;
2206 HRESULT hres;
2208 static WCHAR cbinding_contextW[] =
2209 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
2211 CHECK_EXPECT(Load);
2212 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
2214 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2215 ok(!fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable);
2216 else
2217 ok(fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable);
2218 ok(pimkName != NULL, "pimkName == NULL\n");
2219 ok(pibc != NULL, "pibc == NULL\n");
2220 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
2222 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
2223 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
2224 if(SUCCEEDED(hres)) {
2225 IBinding *binding;
2227 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
2228 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
2230 IBinding_Release(binding);
2231 IUnknown_Release(unk);
2234 SET_EXPECT(QueryInterface_IServiceProvider);
2235 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
2236 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2237 CHECK_CALLED(QueryInterface_IServiceProvider);
2239 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2240 SET_EXPECT(GetBindInfo);
2241 SET_EXPECT(OnStartBinding);
2242 if(test_redirect)
2243 SET_EXPECT(OnProgress_REDIRECTING);
2244 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2245 if(test_protocol == FILE_TEST)
2246 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2247 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2248 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2249 SET_EXPECT(LockRequest);
2250 SET_EXPECT(OnDataAvailable);
2251 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2252 SET_EXPECT(OnStopBinding);
2254 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
2255 ok(hres == S_OK, "Load failed: %08x\n", hres);
2257 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2258 CHECK_CALLED(GetBindInfo);
2259 CHECK_CALLED(OnStartBinding);
2260 if(test_redirect)
2261 CHECK_CALLED(OnProgress_REDIRECTING);
2262 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2263 if(test_protocol == FILE_TEST)
2264 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2265 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2266 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2267 CHECK_CALLED(LockRequest);
2268 CHECK_CALLED(OnDataAvailable);
2269 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2270 CHECK_CALLED(OnStopBinding);
2272 if(unk)
2273 IUnknown_Release(unk);
2275 return S_OK;
2278 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
2280 ok(0, "unexpected call\n");
2281 return E_NOTIMPL;
2284 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
2286 ok(0, "unexpected call\n");
2287 return E_NOTIMPL;
2290 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
2292 ok(0, "unexpected call\n");
2293 return E_NOTIMPL;
2296 static const IPersistMonikerVtbl PersistMonikerVtbl = {
2297 PersistMoniker_QueryInterface,
2298 PersistMoniker_AddRef,
2299 PersistMoniker_Release,
2300 PersistMoniker_GetClassID,
2301 PersistMoniker_IsDirty,
2302 PersistMoniker_Load,
2303 PersistMoniker_Save,
2304 PersistMoniker_SaveCompleted,
2305 PersistMoniker_GetCurMoniker
2308 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
2310 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2312 *ppv = NULL;
2314 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2315 *ppv = iface;
2316 return S_OK;
2319 if(IsEqualGUID(&IID_IMarshal, riid))
2320 return E_NOINTERFACE;
2321 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
2322 return E_NOINTERFACE;
2324 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2325 return E_NOTIMPL;
2328 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2330 return 2;
2333 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2335 return 1;
2338 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2340 CHECK_EXPECT(CreateInstance);
2341 ok(!outer, "outer = %p\n", outer);
2342 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
2343 *ppv = &PersistMoniker;
2344 return S_OK;
2347 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
2349 ok(0, "unexpected call\n");
2350 return S_OK;
2353 static const IClassFactoryVtbl ClassFactoryVtbl = {
2354 ClassFactory_QueryInterface,
2355 ClassFactory_AddRef,
2356 ClassFactory_Release,
2357 ClassFactory_CreateInstance,
2358 ClassFactory_LockServer
2361 static IClassFactory mime_cf = { &ClassFactoryVtbl };
2363 static HRESULT WINAPI ProtocolCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2365 *ppv = NULL;
2367 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2368 *ppv = iface;
2369 return S_OK;
2372 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2373 return E_NOINTERFACE;
2375 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2376 return E_NOTIMPL;
2379 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2381 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2382 return E_NOINTERFACE;
2384 ok(outer != NULL, "outer == NULL\n");
2385 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
2386 *ppv = &Protocol;
2387 return S_OK;
2390 static const IClassFactoryVtbl ProtocolCFVtbl = {
2391 ProtocolCF_QueryInterface,
2392 ClassFactory_AddRef,
2393 ClassFactory_Release,
2394 ProtocolCF_CreateInstance,
2395 ClassFactory_LockServer
2398 static IClassFactory protocol_cf = { &ProtocolCFVtbl };
2400 static void test_CreateAsyncBindCtx(void)
2402 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
2403 IUnknown *unk;
2404 HRESULT hres;
2405 ULONG ref;
2406 BIND_OPTS bindopts;
2408 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
2409 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2410 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
2412 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
2413 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2415 SET_EXPECT(QueryInterface_IServiceProvider);
2416 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2417 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
2418 CHECK_CALLED(QueryInterface_IServiceProvider);
2420 bindopts.cbStruct = sizeof(bindopts);
2421 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2422 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2423 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2424 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2425 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2426 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2427 bindopts.grfMode);
2428 ok(bindopts.dwTickCountDeadline == 0,
2429 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2431 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2432 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
2433 if(SUCCEEDED(hres))
2434 IUnknown_Release(unk);
2436 ref = IBindCtx_Release(bctx);
2437 ok(ref == 0, "bctx should be destroyed here\n");
2440 static void test_CreateAsyncBindCtxEx(void)
2442 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
2443 IUnknown *unk;
2444 BIND_OPTS bindopts;
2445 HRESULT hres;
2447 static WCHAR testW[] = {'t','e','s','t',0};
2449 if (!pCreateAsyncBindCtxEx) {
2450 win_skip("CreateAsyncBindCtxEx not present\n");
2451 return;
2454 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
2455 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
2457 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2458 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2460 if(SUCCEEDED(hres)) {
2461 bindopts.cbStruct = sizeof(bindopts);
2462 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2463 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2464 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2465 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2466 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2467 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2468 bindopts.grfMode);
2469 ok(bindopts.dwTickCountDeadline == 0,
2470 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2472 IBindCtx_Release(bctx);
2475 CreateBindCtx(0, &bctx_arg);
2476 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2477 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2479 if(SUCCEEDED(hres)) {
2480 bindopts.cbStruct = sizeof(bindopts);
2481 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2482 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2483 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2484 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2485 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2486 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2487 bindopts.grfMode);
2488 ok(bindopts.dwTickCountDeadline == 0,
2489 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2491 IBindCtx_Release(bctx);
2494 IBindCtx_Release(bctx_arg);
2496 SET_EXPECT(QueryInterface_IServiceProvider);
2497 hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
2498 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2499 CHECK_CALLED(QueryInterface_IServiceProvider);
2501 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2502 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
2503 if(SUCCEEDED(hres))
2504 IUnknown_Release(unk);
2506 IBindCtx_Release(bctx);
2508 hres = CreateBindCtx(0, &bctx2);
2509 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2511 hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
2512 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2514 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
2515 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2517 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
2518 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2519 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
2521 IBindCtx_Release(bctx);
2522 IBindCtx_Release(bctx2);
2525 static void test_GetBindInfoEx(IBindStatusCallback *holder)
2527 IBindStatusCallbackEx *bscex;
2528 BINDINFO bindinfo = {sizeof(bindinfo)};
2529 DWORD bindf, bindf2, dw;
2530 HRESULT hres;
2532 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
2533 if(FAILED(hres)) {
2534 win_skip("IBindStatusCallbackEx not supported\n");
2535 return;
2538 use_bscex = TRUE;
2540 bindf = 0;
2541 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2542 SET_EXPECT(GetBindInfoEx);
2543 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
2544 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2545 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2546 CHECK_CALLED(GetBindInfoEx);
2548 bindf = bindf2 = dw = 0;
2549 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2550 SET_EXPECT(GetBindInfoEx);
2551 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2552 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2553 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2554 CHECK_CALLED(GetBindInfoEx);
2556 use_bscex = FALSE;
2558 bindf = bindf2 = dw = 0xdeadbeef;
2559 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2560 SET_EXPECT(GetBindInfo);
2561 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2562 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2563 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2564 CHECK_CALLED(GetBindInfo);
2565 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
2566 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
2568 IBindStatusCallbackEx_Release(bscex);
2571 static BOOL test_bscholder(IBindStatusCallback *holder)
2573 IServiceProvider *serv_prov;
2574 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
2575 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
2576 IAuthenticate *authenticate, *authenticate_serv;
2577 IInternetBindInfo *bind_info;
2578 IInternetProtocol *protocol;
2579 BINDINFO bindinfo = {sizeof(bindinfo)};
2580 BOOL ret = TRUE;
2581 LPWSTR wstr;
2582 DWORD dw;
2583 HRESULT hres;
2585 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2586 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2588 dw = 0xdeadbeef;
2589 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2590 SET_EXPECT(GetBindInfo);
2591 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2592 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2593 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2594 CHECK_CALLED(GetBindInfo);
2596 test_GetBindInfoEx(holder);
2598 SET_EXPECT(OnStartBinding);
2599 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2600 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2601 CHECK_CALLED(OnStartBinding);
2603 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2604 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2606 SET_EXPECT(QueryInterface_IHttpNegotiate);
2607 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2608 (void**)&http_negotiate_serv);
2609 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2610 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2612 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2614 wstr = (void*)0xdeadbeef;
2615 SET_EXPECT(QueryInterface_IHttpNegotiate);
2616 SET_EXPECT(BeginningTransaction);
2617 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, current_url, emptyW, 0, &wstr);
2618 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2619 CHECK_CALLED(BeginningTransaction);
2620 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2621 ok(wstr == NULL, "wstr = %p\n", wstr);
2623 IHttpNegotiate_Release(http_negotiate_serv);
2625 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2626 (void**)&http_negotiate_serv);
2627 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2628 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2629 IHttpNegotiate_Release(http_negotiate_serv);
2631 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2632 if(SUCCEEDED(hres)) {
2633 have_IHttpNegotiate2 = TRUE;
2635 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2636 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2637 (void**)&http_negotiate2_serv);
2638 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2639 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2640 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2642 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2643 SET_EXPECT(GetRootSecurityId);
2644 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2645 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2646 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2647 CHECK_CALLED(GetRootSecurityId);
2649 IHttpNegotiate2_Release(http_negotiate2_serv);
2650 IHttpNegotiate2_Release(http_negotiate2);
2651 }else {
2652 skip("Could not get IHttpNegotiate2\n");
2653 ret = FALSE;
2656 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2657 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2658 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2659 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2661 SET_EXPECT(QueryInterface_IHttpNegotiate);
2662 SET_EXPECT(OnResponse);
2663 wstr = (void*)0xdeadbeef;
2664 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2665 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2666 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2667 CHECK_CALLED(OnResponse);
2669 IHttpNegotiate_Release(http_negotiate);
2671 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2672 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2674 SET_EXPECT(QueryInterface_IAuthenticate);
2675 SET_EXPECT(QueryService_IAuthenticate);
2676 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2677 (void**)&authenticate_serv);
2678 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2679 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2680 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2681 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2682 IAuthenticate_Release(authenticate_serv);
2684 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2685 (void**)&authenticate_serv);
2686 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2687 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2689 IAuthenticate_Release(authenticate);
2690 IAuthenticate_Release(authenticate_serv);
2692 hres = IBindStatusCallback_QueryInterface(holder, &IID_IInternetBindInfo, (void**)&bind_info);
2693 ok(hres == S_OK || broken(hres == E_NOINTERFACE /* win2k */), "Could not get IInternetBindInfo interface: %08x\n", hres);
2695 if(SUCCEEDED(hres)) {
2696 hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_USER_AGENT, &wstr, 1, &dw);
2697 ok(hres == E_NOINTERFACE, "GetBindString(BINDSTRING_USER_AGENT) failed: %08x\n", hres);
2699 IInternetBindInfo_Release(bind_info);
2702 SET_EXPECT(OnStopBinding);
2703 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2704 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2705 CHECK_CALLED(OnStopBinding);
2707 SET_EXPECT(QueryInterface_IInternetProtocol);
2708 SET_EXPECT(QueryService_IInternetProtocol);
2709 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2710 (void**)&protocol);
2711 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2712 CHECK_CALLED(QueryInterface_IInternetProtocol);
2713 CHECK_CALLED(QueryService_IInternetProtocol);
2715 IServiceProvider_Release(serv_prov);
2716 return ret;
2719 static BOOL test_RegisterBindStatusCallback(void)
2721 IBindStatusCallback *prevbsc, *clb, *prev_clb;
2722 IBindCtx *bindctx;
2723 BOOL ret = TRUE;
2724 IUnknown *unk;
2725 HRESULT hres;
2727 strict_bsc_qi = TRUE;
2729 hres = CreateBindCtx(0, &bindctx);
2730 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2732 SET_EXPECT(QueryInterface_IServiceProvider);
2734 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2735 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2737 SET_EXPECT(QueryInterface_IBindStatusCallback);
2738 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2739 prevbsc = (void*)0xdeadbeef;
2740 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2741 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2742 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2743 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2744 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2746 CHECK_CALLED(QueryInterface_IServiceProvider);
2748 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2749 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2751 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2752 IUnknown_Release(unk);
2753 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2754 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2756 if(!test_bscholder(clb))
2757 ret = FALSE;
2759 IBindStatusCallback_Release(clb);
2761 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2762 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2764 unk = (void*)0xdeadbeef;
2765 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2766 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2767 ok(unk == NULL, "unk != NULL\n");
2769 if(unk)
2770 IUnknown_Release(unk);
2772 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2773 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2775 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2776 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2778 hres = RevokeBindStatusCallback(bindctx, NULL);
2779 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2781 SET_EXPECT(QueryInterface_IServiceProvider);
2782 prevbsc = (void*)0xdeadbeef;
2783 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2784 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2785 ok(!prevbsc, "prevbsc=%p\n", prevbsc);
2786 CHECK_CALLED(QueryInterface_IServiceProvider);
2788 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2789 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2791 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&prev_clb);
2792 IUnknown_Release(unk);
2793 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2794 ok(prev_clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2796 SET_EXPECT(QueryInterface_IServiceProvider);
2797 prevbsc = (void*)0xdeadbeef;
2798 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc2, &prevbsc, 0);
2799 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2800 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc != bsc\n");
2801 CHECK_CALLED(QueryInterface_IServiceProvider);
2803 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2804 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2806 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2807 IUnknown_Release(unk);
2808 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2809 ok(prev_clb == clb, "bsc != clb\n");
2811 IBindStatusCallback_Release(clb);
2812 IBindStatusCallback_Release(prev_clb);
2814 IBindCtx_Release(bindctx);
2816 strict_bsc_qi = FALSE;
2817 return ret;
2820 #define BINDTEST_EMULATE 0x0001
2821 #define BINDTEST_TOOBJECT 0x0002
2822 #define BINDTEST_FILEDWLAPI 0x0004
2823 #define BINDTEST_HTTPRESPONSE 0x0008
2824 #define BINDTEST_REDIRECT 0x0010
2825 #define BINDTEST_USE_CACHE 0x0020
2826 #define BINDTEST_NO_CALLBACK_READ 0x0040
2827 #define BINDTEST_NO_CALLBACK 0x0080
2828 #define BINDTEST_ABORT 0x0100
2829 #define BINDTEST_INVALID_CN 0x0200
2830 #define BINDTEST_ABORT_START 0x0400
2831 #define BINDTEST_ABORT_PROGRESS 0x0800
2832 #define BINDTEST_ASYNC_SWITCH 0x1000
2833 #define BINDTEST_ALLOW_FINDINGRESOURCE 0x2000
2835 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2837 const char *url_a = NULL;
2839 test_protocol = protocol;
2840 bindtest_flags = flags;
2841 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2842 download_state = BEFORE_DOWNLOAD;
2843 stopped_binding = FALSE;
2844 stopped_obj_binding = FALSE;
2845 data_available = FALSE;
2846 mime_type[0] = 0;
2847 binding_hres = S_OK;
2848 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2849 tymed = t;
2850 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2851 post_test = (flags & BINDTEST_HTTPRESPONSE) != 0;
2853 switch(protocol) {
2854 case HTTP_TEST:
2855 if(post_test)
2856 url_a = "http://test.winehq.org/tests/post.php";
2857 else
2858 lstrcpyW(current_url, winetest_data_urlW);
2859 break;
2860 case ABOUT_TEST:
2861 url_a = "about:blank";
2862 break;
2863 case FILE_TEST:
2864 lstrcpyW(current_url, file_url);
2865 break;
2866 case MK_TEST:
2867 url_a = "mk:@MSITStore:test.chm::/blank.html";
2868 break;
2869 case ITS_TEST:
2870 url_a = "its:test.chm::/blank.html";
2871 break;
2872 case HTTPS_TEST:
2873 url_a = (flags & BINDTEST_INVALID_CN) ? "https://4.15.184.77/favicon.ico" : "https://test.winehq.org/tests/hello.html";
2874 break;
2875 case FTP_TEST:
2876 url_a = "ftp://ftp.winehq.org/welcome%2emsg";
2877 break;
2878 default:
2879 url_a = "winetest:test";
2882 if(url_a)
2883 MultiByteToWideChar(CP_ACP, 0, url_a, -1, current_url, ARRAY_SIZE(current_url));
2885 test_redirect = (flags & BINDTEST_REDIRECT) != 0;
2886 use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
2887 callback_read = !(flags & BINDTEST_NO_CALLBACK_READ);
2888 no_callback = (flags & BINDTEST_NO_CALLBACK) != 0;
2889 test_abort = (flags & BINDTEST_ABORT) != 0;
2890 abort_start = (flags & BINDTEST_ABORT_START) != 0;
2891 abort_progress = (flags & BINDTEST_ABORT_PROGRESS) != 0;
2892 async_switch = (flags & BINDTEST_ASYNC_SWITCH) != 0;
2893 is_async_prot = protocol == HTTP_TEST || protocol == HTTPS_TEST || protocol == FTP_TEST || protocol == WINETEST_TEST;
2894 prot_state = 0;
2895 ResetEvent(complete_event);
2897 if (winetest_debug > 1) trace("URL: %s\n", wine_dbgstr_w(current_url));
2900 static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
2902 IMoniker *mon;
2903 HRESULT hres;
2904 LPOLESTR display_name;
2905 IBindCtx *bctx = NULL;
2906 MSG msg;
2907 IBindStatusCallback *previousclb;
2908 IUnknown *unk = (IUnknown*)0x00ff00ff;
2909 BOOL allow_finding_resource;
2910 IBinding *bind;
2912 init_bind_test(protocol, flags, t);
2913 allow_finding_resource = (flags & BINDTEST_ALLOW_FINDINGRESOURCE) != 0;
2915 if(no_callback) {
2916 hres = CreateBindCtx(0, &bctx);
2917 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2918 }else {
2919 SET_EXPECT(QueryInterface_IServiceProvider);
2920 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2921 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2922 CHECK_CALLED(QueryInterface_IServiceProvider);
2923 if(FAILED(hres))
2924 return;
2926 SET_EXPECT(QueryInterface_IServiceProvider);
2927 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2928 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2929 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2930 CHECK_CALLED(QueryInterface_IServiceProvider);
2931 if(previousclb)
2932 IBindStatusCallback_Release(previousclb);
2935 hres = CreateURLMoniker(NULL, current_url, &mon);
2936 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
2937 if(FAILED(hres))
2938 return;
2940 if(protocol == FTP_TEST)
2942 /* FTP urls don't have any escape characters so convert the url to what is expected */
2943 DWORD size = 0;
2944 UrlUnescapeW(current_url, NULL, &size, URL_UNESCAPE_INPLACE);
2947 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2948 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2949 if(SUCCEEDED(hres))
2950 IBinding_Release(bind);
2952 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2953 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2954 ok(!lstrcmpW(display_name, current_url), "GetDisplayName got wrong name %s, expected %s\n",
2955 wine_dbgstr_w(display_name), wine_dbgstr_w(current_url));
2956 CoTaskMemFree(display_name);
2958 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2959 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2960 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted &&
2961 (onsecurityproblem_hres != S_OK || security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)) {
2962 if(security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)
2963 binding_hres = INET_E_SECURITY_PROBLEM;
2964 else
2965 binding_hres = INET_E_INVALID_CERTIFICATE;
2969 if(only_check_prot_args)
2970 SET_EXPECT(OnStopBinding);
2971 if(!no_callback) {
2972 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2973 SET_EXPECT(GetBindInfo);
2974 SET_EXPECT(QueryInterface_IInternetProtocol);
2975 if(!emulate_protocol)
2976 SET_EXPECT(QueryService_IInternetProtocol);
2977 SET_EXPECT(OnStartBinding);
2979 if(emulate_protocol) {
2980 if(is_urlmon_protocol(test_protocol))
2981 SET_EXPECT(SetPriority);
2982 SET_EXPECT(Start);
2983 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST
2984 || test_protocol == WINETEST_SYNC_TEST)
2985 SET_EXPECT(Terminate);
2986 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2987 SET_EXPECT(UnlockRequest);
2988 }else {
2989 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2990 SET_EXPECT(QueryService_IInternetBindInfo);
2991 if(!abort_start)
2992 SET_EXPECT(QueryInterface_IHttpNegotiate);
2993 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2994 SET_EXPECT(QueryService_IWindowForBindingUI);
2995 SET_EXPECT(GetWindow_IWindowForBindingUI);
2996 if(!abort_start) {
2997 SET_EXPECT(BeginningTransaction);
2998 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2999 SET_EXPECT(GetRootSecurityId);
3000 if(http_is_first || allow_finding_resource)
3001 SET_EXPECT(OnProgress_FINDINGRESOURCE);
3002 SET_EXPECT(OnProgress_CONNECTING);
3004 if(flags & BINDTEST_INVALID_CN) {
3005 SET_EXPECT(QueryInterface_IHttpSecurity);
3006 SET_EXPECT(QueryService_IHttpSecurity);
3007 SET_EXPECT(OnSecurityProblem);
3008 if(SUCCEEDED(onsecurityproblem_hres))
3009 SET_EXPECT(GetWindow_IHttpSecurity);
3012 if(!no_callback) {
3013 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
3014 || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) && !abort_start)
3015 SET_EXPECT(OnProgress_SENDINGREQUEST);
3016 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
3017 SET_EXPECT(QueryInterface_IHttpNegotiate);
3018 SET_EXPECT(OnResponse);
3020 if(!abort_start) {
3021 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3022 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3024 if(test_protocol == FILE_TEST)
3025 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
3026 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
3027 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3028 if(!abort_start)
3029 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3030 if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
3031 SET_EXPECT(OnDataAvailable);
3032 SET_EXPECT(OnStopBinding);
3036 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
3037 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3038 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
3040 skip("Network unreachable, skipping tests\n");
3041 return;
3044 if(only_check_prot_args) {
3045 ok(hres == E_FAIL, "Got %08x\n", hres);
3046 CHECK_CALLED(OnStopBinding);
3047 } else if(abort_start)
3048 ok(hres == abort_hres, "IMoniker_BindToStorage failed: %08x, expected %08x\n", hres, abort_hres);
3049 else if(abort_progress)
3050 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
3051 else if(no_callback) {
3052 if(emulate_protocol)
3053 ok( WaitForSingleObject(complete_event2, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
3054 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3055 ok(unk != NULL, "unk == NULL\n");
3056 }else if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) {
3057 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3058 ok(unk == NULL, "unk != NULL\n");
3059 }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
3060 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
3061 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
3062 ok(unk == NULL, "istr should be NULL\n");
3063 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
3064 ok(hres == INET_E_DATA_NOT_AVAILABLE,
3065 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
3066 ok(unk == NULL, "istr should be NULL\n");
3067 }else if((flags & BINDTEST_INVALID_CN) && binding_hres != S_OK) {
3068 ok(hres == binding_hres, "Got %08x\n", hres);
3069 ok(unk == NULL, "Got %p\n", unk);
3070 }else if((flags & BINDTEST_INVALID_CN) && invalid_cn_accepted) {
3071 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3072 ok(unk != NULL, "unk == NULL\n");
3073 if(unk == NULL) {
3074 ok(0, "Expected security problem to be ignored.\n");
3075 invalid_cn_accepted = FALSE;
3076 binding_hres = INET_E_INVALID_CERTIFICATE;
3078 }else {
3079 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3080 ok(unk != NULL, "unk == NULL\n");
3082 if(unk && callback_read && !no_callback) {
3083 IUnknown_Release(unk);
3084 unk = NULL;
3087 if(FAILED(hres) && !(flags & BINDTEST_INVALID_CN) && !(flags & BINDTEST_ABORT_START))
3088 return;
3090 if((bindf & BINDF_ASYNCHRONOUS) && !no_callback) {
3091 while(!stopped_binding && GetMessageA(&msg,NULL,0,0)) {
3092 TranslateMessage(&msg);
3093 DispatchMessageA(&msg);
3097 if(async_switch) {
3098 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3099 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3100 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3101 CHECK_CALLED(LockRequest);
3102 CHECK_CALLED(OnStopBinding);
3104 if(!no_callback) {
3105 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
3106 CHECK_CALLED(GetBindInfo);
3107 todo_wine_if(abort_start)
3108 CHECK_CALLED(QueryInterface_IInternetProtocol);
3109 if(!emulate_protocol) {
3110 todo_wine_if(abort_start)
3111 CHECK_CALLED(QueryService_IInternetProtocol);
3113 CHECK_CALLED(OnStartBinding);
3115 if(emulate_protocol) {
3116 if(is_urlmon_protocol(test_protocol))
3117 CLEAR_CALLED(SetPriority); /* Not called by IE11 */
3118 CHECK_CALLED(Start);
3119 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST
3120 || test_protocol == WINETEST_SYNC_TEST) {
3121 if(tymed == TYMED_FILE)
3122 CLEAR_CALLED(Read);
3123 CHECK_CALLED(Terminate);
3125 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
3126 CHECK_CALLED(UnlockRequest);
3127 }else {
3128 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
3129 CLEAR_CALLED(QueryService_IInternetBindInfo);
3130 if(!abort_start)
3131 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3132 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3133 CLEAR_CALLED(QueryService_IWindowForBindingUI);
3134 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
3135 if(!abort_start)
3136 CHECK_CALLED(BeginningTransaction);
3137 if (have_IHttpNegotiate2 && !abort_start)
3139 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3140 CHECK_CALLED(GetRootSecurityId);
3142 if(http_is_first) {
3143 if (! proxy_active())
3145 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
3146 CHECK_CALLED(OnProgress_CONNECTING);
3148 else
3150 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
3151 CLEAR_CALLED(OnProgress_CONNECTING);
3153 }else if(!abort_start) {
3154 if(allow_finding_resource)
3155 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
3156 /* IE7 does call this */
3157 CLEAR_CALLED(OnProgress_CONNECTING);
3159 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted) {
3160 CHECK_CALLED(QueryInterface_IHttpSecurity);
3161 CHECK_CALLED(QueryService_IHttpSecurity);
3162 CHECK_CALLED(OnSecurityProblem);
3163 }else {
3164 CHECK_NOT_CALLED(QueryInterface_IHttpSecurity);
3165 CHECK_NOT_CALLED(QueryService_IHttpSecurity);
3166 CHECK_NOT_CALLED(OnSecurityProblem);
3169 if(!no_callback) {
3170 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) {
3171 if(flags & BINDTEST_INVALID_CN)
3172 CLEAR_CALLED(OnProgress_SENDINGREQUEST);
3173 else if(!abort_start)
3174 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3175 } else if(test_protocol == FTP_TEST)
3176 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
3177 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
3178 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3179 if((!(flags & BINDTEST_INVALID_CN) || (binding_hres == S_OK)) && !abort_start) {
3180 CHECK_CALLED(OnResponse);
3183 if((!(flags & BINDTEST_INVALID_CN) || binding_hres == S_OK) && !abort_start) {
3184 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3185 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3186 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3188 if(test_protocol == FILE_TEST)
3189 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
3190 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
3191 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3192 if((flags & BINDTEST_INVALID_CN)) {
3193 if(binding_hres == S_OK)
3194 CHECK_CALLED(OnDataAvailable);
3195 else
3196 CHECK_NOT_CALLED(OnDataAvailable);
3197 }else if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
3198 CHECK_CALLED(OnDataAvailable);
3199 CHECK_CALLED(OnStopBinding);
3203 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3204 if(bctx)
3205 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
3207 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3208 http_is_first = FALSE;
3210 if((flags & BINDTEST_INVALID_CN) && onsecurityproblem_hres == S_OK && security_problem != ERROR_INTERNET_SEC_CERT_ERRORS)
3211 invalid_cn_accepted = TRUE;
3213 if(unk) {
3214 BYTE buf[512];
3215 DWORD read;
3216 IStream *stream;
3218 hres = IUnknown_QueryInterface(unk, &IID_IStream, (void**)&stream);
3219 ok(hres == S_OK, "Could not get IStream iface: %08x\n", hres);
3220 IUnknown_Release(unk);
3222 do {
3223 read = 0xdeadbeef;
3224 hres = IStream_Read(stream, buf, sizeof(buf), &read);
3225 ok(read != 0xdeadbeef, "read = 0xdeadbeef\n");
3226 if(emulate_protocol && test_protocol == HTTP_TEST && read)
3227 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
3228 }while(hres == S_OK);
3229 ok(hres == S_FALSE, "IStream_Read returned %08x\n", hres);
3230 ok(!read, "read = %d\n", read);
3232 IStream_Release(stream);
3236 static void test_BindToObject(int protocol, DWORD flags, HRESULT exhres)
3238 IMoniker *mon;
3239 HRESULT hres;
3240 LPOLESTR display_name;
3241 IBindCtx *bctx;
3242 DWORD regid;
3243 MSG msg;
3244 IUnknown *unk = (IUnknown*)0x00ff00ff;
3245 IBinding *bind;
3247 init_bind_test(protocol, BINDTEST_TOOBJECT|flags, TYMED_ISTREAM);
3248 binding_hres = exhres;
3250 if(emulate_protocol)
3251 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
3252 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
3254 SET_EXPECT(QueryInterface_IServiceProvider);
3255 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx);
3256 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3257 CHECK_CALLED(QueryInterface_IServiceProvider);
3258 if(FAILED(hres))
3259 return;
3261 hres = CreateURLMoniker(NULL, current_url, &mon);
3262 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
3263 if(FAILED(hres)) {
3264 IBindCtx_Release(bctx);
3265 return;
3268 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
3269 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
3270 if(SUCCEEDED(hres))
3271 IBinding_Release(bind);
3273 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
3274 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
3275 ok(!lstrcmpW(display_name, current_url), "GetDisplayName got wrong name\n");
3276 CoTaskMemFree(display_name);
3278 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3279 SET_EXPECT(Obj_GetBindInfo);
3280 SET_EXPECT(QueryInterface_IInternetProtocol);
3281 if(!emulate_protocol)
3282 SET_EXPECT(QueryService_IInternetProtocol);
3283 SET_EXPECT(Obj_OnStartBinding);
3284 if(emulate_protocol) {
3285 if(is_urlmon_protocol(test_protocol))
3286 SET_EXPECT(SetPriority);
3287 SET_EXPECT(Start);
3288 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3289 SET_EXPECT(Terminate);
3290 if(test_protocol == FILE_TEST)
3291 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3292 SET_EXPECT(UnlockRequest);
3293 }else {
3294 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3295 SET_EXPECT(QueryInterface_IHttpNegotiate);
3296 SET_EXPECT(BeginningTransaction);
3297 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3298 SET_EXPECT(GetRootSecurityId);
3299 if(http_is_first)
3300 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
3301 SET_EXPECT(Obj_OnProgress_CONNECTING);
3302 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3303 SET_EXPECT(QueryService_IWindowForBindingUI);
3304 SET_EXPECT(GetWindow_IWindowForBindingUI);
3306 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3307 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
3308 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3309 SET_EXPECT(QueryInterface_IHttpNegotiate);
3310 SET_EXPECT(OnResponse);
3312 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
3313 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
3314 if(test_protocol == FILE_TEST)
3315 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3316 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3317 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3318 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
3319 if(SUCCEEDED(hres))
3320 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
3321 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
3322 if(exhres == REGDB_E_CLASSNOTREG) {
3323 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3324 SET_EXPECT(QueryService_IWindowForBindingUI);
3325 SET_EXPECT(GetWindow_ICodeInstall);
3327 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
3328 if(SUCCEEDED(hres))
3329 SET_EXPECT(OnObjectAvailable);
3330 SET_EXPECT(Obj_OnStopBinding);
3333 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
3335 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3336 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
3338 skip( "Network unreachable, skipping tests\n" );
3339 return;
3342 if(FAILED(exhres)) {
3343 ok(hres == exhres, "BindToObject failed: %08x, expected %08x\n", hres, exhres);
3344 ok(!unk, "unk = %p, expected NULL\n", unk);
3345 }else if(bindf & BINDF_ASYNCHRONOUS) {
3346 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
3347 ok(unk == NULL, "istr should be NULL\n");
3348 }else {
3349 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3350 ok(unk != NULL, "unk == NULL\n");
3351 if(emulate_protocol)
3352 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
3354 if(unk)
3355 IUnknown_Release(unk);
3357 while((bindf & BINDF_ASYNCHRONOUS) &&
3358 !((!emulate_protocol || stopped_binding) && stopped_obj_binding) && GetMessageA(&msg,NULL,0,0)) {
3359 TranslateMessage(&msg);
3360 DispatchMessageA(&msg);
3363 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
3364 CHECK_CALLED(Obj_GetBindInfo);
3365 CHECK_CALLED(QueryInterface_IInternetProtocol);
3366 if(!emulate_protocol)
3367 CHECK_CALLED(QueryService_IInternetProtocol);
3368 CHECK_CALLED(Obj_OnStartBinding);
3369 if(emulate_protocol) {
3370 if(is_urlmon_protocol(test_protocol))
3371 CLEAR_CALLED(SetPriority); /* Not called by IE11 */
3372 CHECK_CALLED(Start);
3373 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3374 CHECK_CALLED(Terminate);
3375 if(test_protocol == FILE_TEST)
3376 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
3377 CHECK_CALLED(UnlockRequest);
3378 }else {
3379 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3380 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3381 CHECK_CALLED(BeginningTransaction);
3382 if (have_IHttpNegotiate2)
3384 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3385 CHECK_CALLED(GetRootSecurityId);
3387 if(http_is_first) {
3388 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
3389 CHECK_CALLED(Obj_OnProgress_CONNECTING);
3390 }else {
3391 /* IE7 does call this */
3392 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
3394 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3395 CLEAR_CALLED(QueryService_IWindowForBindingUI);
3396 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
3398 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
3399 if(post_test)
3400 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
3401 else
3402 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
3404 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3405 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3406 CHECK_CALLED(OnResponse);
3408 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
3409 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
3410 if(test_protocol == FILE_TEST)
3411 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3412 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3413 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3414 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
3415 if(SUCCEEDED(hres))
3416 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
3417 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
3418 if(exhres == REGDB_E_CLASSNOTREG) {
3419 todo_wine CHECK_CALLED(QueryInterface_IWindowForBindingUI);
3420 todo_wine CHECK_CALLED(QueryService_IWindowForBindingUI);
3421 todo_wine CHECK_CALLED(GetWindow_ICodeInstall);
3423 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
3424 if(SUCCEEDED(hres))
3425 CHECK_CALLED(OnObjectAvailable);
3426 CHECK_CALLED(Obj_OnStopBinding);
3429 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3430 IBindCtx_Release(bctx);
3432 if(emulate_protocol)
3433 CoRevokeClassObject(regid);
3435 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3436 http_is_first = FALSE;
3439 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
3441 BOOL res;
3442 HRESULT hres;
3444 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
3446 SET_EXPECT(GetBindInfo);
3447 SET_EXPECT(QueryInterface_IInternetProtocol);
3448 SET_EXPECT(QueryInterface_IServiceProvider);
3449 if(!emulate_protocol)
3450 SET_EXPECT(QueryService_IInternetProtocol);
3451 SET_EXPECT(OnStartBinding);
3452 if(emulate_protocol) {
3453 if(is_urlmon_protocol(test_protocol))
3454 SET_EXPECT(SetPriority);
3455 SET_EXPECT(Start);
3456 SET_EXPECT(UnlockRequest);
3457 }else {
3458 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3459 SET_EXPECT(QueryInterface_IHttpNegotiate);
3460 SET_EXPECT(BeginningTransaction);
3461 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3462 SET_EXPECT(GetRootSecurityId);
3463 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3464 SET_EXPECT(OnProgress_CONNECTING);
3466 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3467 SET_EXPECT(OnProgress_SENDINGREQUEST);
3468 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3469 SET_EXPECT(QueryInterface_IHttpNegotiate);
3470 SET_EXPECT(OnResponse);
3472 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3473 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3474 if(test_protocol == FILE_TEST)
3475 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
3476 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3477 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3478 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3479 SET_EXPECT(OnStopBinding);
3482 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3483 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3485 CHECK_CALLED(GetBindInfo);
3486 CHECK_CALLED(QueryInterface_IInternetProtocol);
3487 if(!emulate_protocol) {
3488 CHECK_CALLED(QueryInterface_IServiceProvider);
3489 CHECK_CALLED(QueryService_IInternetProtocol);
3490 }else {
3491 CLEAR_CALLED(QueryInterface_IServiceProvider);
3493 CHECK_CALLED(OnStartBinding);
3494 if(emulate_protocol) {
3495 if(is_urlmon_protocol(test_protocol))
3496 CLEAR_CALLED(SetPriority); /* Not called by IE11 */
3497 CHECK_CALLED(Start);
3498 CHECK_CALLED(UnlockRequest);
3499 }else {
3500 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3501 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3502 CHECK_CALLED(BeginningTransaction);
3503 if (have_IHttpNegotiate2)
3505 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3506 CHECK_CALLED(GetRootSecurityId);
3508 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3509 CLEAR_CALLED(OnProgress_CONNECTING);
3511 if(test_protocol == FILE_TEST)
3512 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3513 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3514 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
3515 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3516 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3517 CHECK_CALLED(OnResponse);
3519 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3520 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3521 if(test_protocol == FILE_TEST)
3522 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
3523 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3524 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3525 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3526 CHECK_CALLED(OnStopBinding);
3529 res = DeleteFileA(dwl_htmlA);
3530 ok(res, "DeleteFile failed: %u\n", GetLastError());
3532 if(prot != FILE_TEST || emul)
3533 return;
3535 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, NULL);
3536 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3538 res = DeleteFileA(dwl_htmlA);
3539 ok(res, "DeleteFile failed: %u\n", GetLastError());
3542 static void test_URLDownloadToFile_abort(void)
3544 HRESULT hres;
3546 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_PROGRESS, TYMED_FILE);
3548 SET_EXPECT(GetBindInfo);
3549 SET_EXPECT(QueryInterface_IInternetProtocol);
3550 SET_EXPECT(QueryInterface_IServiceProvider);
3551 SET_EXPECT(QueryService_IInternetProtocol);
3552 SET_EXPECT(OnStartBinding);
3553 SET_EXPECT(QueryInterface_IHttpNegotiate);
3554 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3555 SET_EXPECT(BeginningTransaction);
3556 SET_EXPECT(GetRootSecurityId);
3557 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3558 SET_EXPECT(OnProgress_CONNECTING);
3559 SET_EXPECT(OnProgress_SENDINGREQUEST);
3560 SET_EXPECT(OnStopBinding);
3562 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3563 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres);
3565 CHECK_CALLED(GetBindInfo);
3566 CHECK_CALLED(QueryInterface_IInternetProtocol);
3567 CHECK_CALLED(QueryInterface_IServiceProvider);
3568 CHECK_CALLED(QueryService_IInternetProtocol);
3569 CHECK_CALLED(OnStartBinding);
3570 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3571 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3572 CHECK_CALLED(BeginningTransaction);
3573 CHECK_CALLED(GetRootSecurityId);
3574 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3575 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3576 CLEAR_CALLED(OnProgress_CONNECTING);
3577 CHECK_CALLED(OnStopBinding);
3579 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE);
3581 SET_EXPECT(GetBindInfo);
3582 SET_EXPECT(QueryInterface_IInternetProtocol);
3583 SET_EXPECT(QueryInterface_IServiceProvider);
3584 SET_EXPECT(QueryService_IInternetProtocol);
3585 SET_EXPECT(OnStartBinding);
3586 SET_EXPECT(OnStopBinding);
3588 abort_hres = E_ABORT;
3589 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3590 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres);
3592 CHECK_CALLED(GetBindInfo);
3593 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
3594 todo_wine CHECK_CALLED(QueryInterface_IServiceProvider);
3595 todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
3596 CHECK_CALLED(OnStartBinding);
3597 CHECK_CALLED(OnStopBinding);
3599 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE);
3601 SET_EXPECT(GetBindInfo);
3602 SET_EXPECT(QueryInterface_IInternetProtocol);
3603 SET_EXPECT(QueryInterface_IServiceProvider);
3604 SET_EXPECT(QueryService_IInternetProtocol);
3605 SET_EXPECT(OnStartBinding);
3606 SET_EXPECT(QueryInterface_IHttpNegotiate);
3607 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3608 SET_EXPECT(BeginningTransaction);
3609 SET_EXPECT(GetRootSecurityId);
3610 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3611 SET_EXPECT(OnResponse);
3612 SET_EXPECT(OnProgress_CONNECTING);
3613 SET_EXPECT(OnProgress_SENDINGREQUEST);
3614 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3615 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3616 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3617 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3618 SET_EXPECT(OnStopBinding);
3620 /* URLDownloadToFile doesn't abort if E_NOTIMPL is returned from the
3621 * IBindStatusCallback's OnStartBinding function.
3623 abort_hres = E_NOTIMPL;
3624 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3625 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3627 CHECK_CALLED(GetBindInfo);
3628 CHECK_CALLED(QueryInterface_IInternetProtocol);
3629 CHECK_CALLED(QueryInterface_IServiceProvider);
3630 CHECK_CALLED(QueryService_IInternetProtocol);
3631 CHECK_CALLED(OnStartBinding);
3632 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3633 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3634 CHECK_CALLED(BeginningTransaction);
3635 CHECK_CALLED(GetRootSecurityId);
3636 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3637 CHECK_CALLED(OnResponse);
3638 CLEAR_CALLED(OnProgress_CONNECTING);
3639 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3640 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3641 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3642 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
3643 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3644 CHECK_CALLED(OnStopBinding);
3646 DeleteFileA(dwl_htmlA);
3649 static void set_file_url(char *path)
3651 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
3653 lstrcpyA(file_urlA, "file://");
3654 lstrcatA(file_urlA, path);
3655 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
3658 static void create_file(const char *file_name, const char *content)
3660 HANDLE file;
3661 DWORD size;
3662 CHAR path[MAX_PATH];
3664 file = CreateFileA(file_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3665 FILE_ATTRIBUTE_NORMAL, NULL);
3666 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3667 if(file == INVALID_HANDLE_VALUE)
3668 return;
3670 if(test_file)
3671 DeleteFileA(test_file);
3672 test_file = file_name;
3673 WriteFile(file, content, strlen(content), &size, NULL);
3674 CloseHandle(file);
3676 GetCurrentDirectoryA(MAX_PATH, path);
3677 lstrcatA(path, "\\");
3678 lstrcatA(path, file_name);
3679 set_file_url(path);
3682 static void create_html_file(void)
3684 create_file(wszIndexHtmlA, "<HTML></HTML>");
3687 static void create_cache_file(void)
3689 char buf[6500], curdir[MAX_PATH];
3690 HANDLE file;
3691 DWORD size;
3693 file = CreateFileA(test_txtA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3694 FILE_ATTRIBUTE_NORMAL, NULL);
3695 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3696 if(file == INVALID_HANDLE_VALUE)
3697 return;
3699 memset(buf, 'X', sizeof(buf));
3700 WriteFile(file, buf, sizeof(buf), &size, NULL);
3701 CloseHandle(file);
3703 memset(curdir, 0, sizeof(curdir));
3704 GetCurrentDirectoryA(MAX_PATH, curdir);
3705 lstrcatA(curdir, "\\");
3706 lstrcatA(curdir, test_txtA);
3708 MultiByteToWideChar(CP_ACP, 0, curdir, -1, cache_file_name, MAX_PATH);
3711 static void test_ReportResult(HRESULT exhres)
3713 IMoniker *mon = NULL;
3714 IBindCtx *bctx = NULL;
3715 IUnknown *unk = (void*)0xdeadbeef;
3716 HRESULT hres;
3718 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3719 binding_hres = exhres;
3721 hres = CreateURLMoniker(NULL, about_blankW, &mon);
3722 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3724 SET_EXPECT(QueryInterface_IServiceProvider);
3725 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
3726 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3727 CHECK_CALLED(QueryInterface_IServiceProvider);
3729 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3730 SET_EXPECT(GetBindInfo);
3731 SET_EXPECT(QueryInterface_IInternetProtocol);
3732 SET_EXPECT(OnStartBinding);
3733 if(is_urlmon_protocol(test_protocol))
3734 SET_EXPECT(SetPriority);
3735 SET_EXPECT(Start);
3737 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3738 if(SUCCEEDED(exhres))
3739 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
3740 else
3741 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
3742 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
3744 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
3745 CHECK_CALLED(GetBindInfo);
3746 CHECK_CALLED(QueryInterface_IInternetProtocol);
3747 CHECK_CALLED(OnStartBinding);
3748 if(is_urlmon_protocol(test_protocol))
3749 CLEAR_CALLED(SetPriority); /* Not called by IE11 */
3750 CHECK_CALLED(Start);
3752 ok(unk == NULL, "unk=%p\n", unk);
3754 IBindCtx_Release(bctx);
3755 IMoniker_Release(mon);
3758 static void test_BindToStorage_fail(void)
3760 IMoniker *mon = NULL;
3761 IBindCtx *bctx = NULL;
3762 IUnknown *unk;
3763 HRESULT hres;
3765 hres = CreateURLMoniker(NULL, about_blankW, &mon);
3766 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3767 if(FAILED(hres))
3768 return;
3770 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
3771 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
3773 unk = (void*)0xdeadbeef;
3774 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3775 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
3776 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
3777 ok(unk == NULL, "got %p\n", unk);
3779 IBindCtx_Release(bctx);
3781 IMoniker_Release(mon);
3783 test_ReportResult(E_NOTIMPL);
3784 test_ReportResult(S_FALSE);
3787 static void test_StdURLMoniker(void)
3789 IMoniker *mon, *async_mon;
3790 LPOLESTR display_name;
3791 IBindCtx *bctx;
3792 IUnknown *unk;
3793 HRESULT hres;
3795 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3796 &IID_IMoniker, (void**)&mon);
3797 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
3798 if(FAILED(hres))
3799 return;
3801 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
3802 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
3803 ok(mon == async_mon, "mon != async_mon\n");
3804 IMoniker_Release(async_mon);
3806 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
3807 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
3809 if(pCreateUri) {
3810 IUriContainer *uri_container;
3811 IUri *uri;
3813 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
3814 ok(hres == S_OK, "Could not get IUriMoniker iface: %08x\n", hres);
3817 uri = (void*)0xdeadbeef;
3818 hres = IUriContainer_GetIUri(uri_container, &uri);
3819 ok(hres == S_FALSE, "GetIUri failed: %08x\n", hres);
3820 ok(!uri, "uri = %p, expected NULL\n", uri);
3822 IUriContainer_Release(uri_container);
3825 SET_EXPECT(QueryInterface_IServiceProvider);
3826 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
3827 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3828 CHECK_CALLED(QueryInterface_IServiceProvider);
3830 if(pCreateUri) { /* Skip these tests on old IEs */
3831 unk = (void*)0xdeadbeef;
3832 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3833 ok(hres == MK_E_SYNTAX, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres);
3834 ok(!unk, "unk = %p\n", unk);
3836 unk = (void*)0xdeadbeef;
3837 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
3838 ok(hres == MK_E_SYNTAX, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres);
3839 ok(!unk, "unk = %p\n", unk);
3842 IMoniker_Release(mon);
3845 static void register_protocols(void)
3847 IInternetSession *session;
3848 HRESULT hres;
3850 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
3852 hres = CoInternetGetSession(0, &session, 0);
3853 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3854 if(FAILED(hres))
3855 return;
3857 hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
3858 winetestW, 0, NULL, 0);
3859 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3861 IInternetSession_Release(session);
3864 static BOOL can_do_https(void)
3866 HINTERNET ses, con, req;
3867 BOOL ret;
3869 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
3870 ok(ses != NULL, "InternetOpen failed\n");
3872 con = InternetConnectA(ses, "test.winehq.org", INTERNET_DEFAULT_HTTPS_PORT,
3873 NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
3874 ok(con != NULL, "InternetConnect failed\n");
3876 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
3877 INTERNET_FLAG_SECURE, 0);
3878 ok(req != NULL, "HttpOpenRequest failed\n");
3880 ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
3881 ok(ret || broken(GetLastError() == ERROR_INTERNET_CANNOT_CONNECT)
3882 || broken(GetLastError() == ERROR_INTERNET_SECURITY_CHANNEL_ERROR) /* WinXP */,
3883 "request failed: %u\n", GetLastError());
3885 InternetCloseHandle(req);
3886 InternetCloseHandle(con);
3887 InternetCloseHandle(ses);
3888 return ret;
3891 START_TEST(url)
3893 HMODULE hurlmon;
3895 hurlmon = GetModuleHandleA("urlmon.dll");
3896 pCreateAsyncBindCtxEx = (void*) GetProcAddress(hurlmon, "CreateAsyncBindCtxEx");
3898 if(!GetProcAddress(hurlmon, "CompareSecurityIds")) {
3899 win_skip("Too old IE\n");
3900 return;
3903 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
3904 if(!pCreateUri)
3905 win_skip("IUri not supported\n");
3907 complete_event = CreateEventW(NULL, FALSE, FALSE, NULL);
3908 complete_event2 = CreateEventW(NULL, FALSE, FALSE, NULL);
3909 thread_id = GetCurrentThreadId();
3910 create_html_file();
3911 create_cache_file();
3912 register_protocols();
3914 test_create();
3916 trace("test CreateAsyncBindCtx...\n");
3917 test_CreateAsyncBindCtx();
3919 trace("test CreateAsyncBindCtxEx...\n");
3920 test_CreateAsyncBindCtxEx();
3922 trace("test RegisterBindStatusCallback...\n");
3923 if(test_RegisterBindStatusCallback()) {
3924 trace("test BindToStorage failures...\n");
3925 test_BindToStorage_fail();
3927 trace("synchronous http test (COM not initialised)...\n");
3928 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3930 CoInitialize(NULL);
3932 trace("test StdURLMoniker...\n");
3933 test_StdURLMoniker();
3935 trace("synchronous http test...\n");
3936 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3938 trace("emulated synchronous http test (to file)...\n");
3939 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3941 trace("synchronous http test (to object)...\n");
3942 test_BindToObject(HTTP_TEST, 0, S_OK);
3944 trace("emulated synchronous http test (with cache)...\n");
3945 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3947 trace("emulated synchronous http test (with cache, no read)...\n");
3948 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3950 trace("synchronous http test (with cache, no read)...\n");
3951 test_BindToStorage(HTTP_TEST, BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3953 trace("synchronous file test...\n");
3954 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3956 trace("emulated synchronous file test (to file)...\n");
3957 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3959 trace("synchronous file test (to object)...\n");
3960 test_BindToObject(FILE_TEST, 0, S_OK);
3962 trace("bind to an object of not registered MIME type...\n");
3963 create_file("test.winetest", "\x01\x02\x03xxxxxxxxxxxxxxxxxxxxxxxxx");
3964 test_BindToObject(FILE_TEST, 0, REGDB_E_CLASSNOTREG);
3965 create_html_file();
3967 trace("file test (no callback)...\n");
3968 test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM);
3970 if(can_do_https()) {
3971 trace("synchronous https test (invalid CN, dialog)\n");
3972 onsecurityproblem_hres = S_FALSE;
3973 http_is_first = TRUE;
3974 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3976 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
3978 trace("asynchronous https test (invalid CN, fail)\n");
3979 onsecurityproblem_hres = E_FAIL;
3980 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3982 trace("asynchronous https test (invalid CN, accept)\n");
3983 onsecurityproblem_hres = S_OK;
3984 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3986 trace("asynchronous https test (invalid CN, dialog 2)\n");
3987 onsecurityproblem_hres = S_FALSE;
3988 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3989 invalid_cn_accepted = FALSE;
3991 trace("asynchronous https test...\n");
3992 test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
3993 }else {
3994 win_skip("Skipping https testt\n");
3997 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
3999 trace("winetest test (async switch)...\n");
4000 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_ASYNC_SWITCH, TYMED_ISTREAM);
4002 trace("about test (no read)...\n");
4003 test_BindToStorage(ABOUT_TEST, BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
4005 trace("http test...\n");
4006 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
4008 trace("http test (to file)...\n");
4009 test_BindToStorage(HTTP_TEST, 0, TYMED_FILE);
4011 trace("http test (to object)...\n");
4012 test_BindToObject(HTTP_TEST, 0, S_OK);
4014 trace("http test (short response)...\n");
4015 test_BindToStorage(HTTP_TEST, BINDTEST_HTTPRESPONSE|BINDTEST_ALLOW_FINDINGRESOURCE, TYMED_ISTREAM);
4017 trace("http test (short response, to object)...\n");
4018 test_BindToObject(HTTP_TEST, 0, S_OK);
4020 trace("http test (abort start binding E_NOTIMPL)...\n");
4021 abort_hres = E_NOTIMPL;
4022 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
4024 trace("http test (abort start binding E_ABORT)...\n");
4025 abort_hres = E_ABORT;
4026 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
4028 trace("http test (abort progress)...\n");
4029 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_PROGRESS|BINDTEST_ALLOW_FINDINGRESOURCE, TYMED_FILE);
4031 trace("emulated http test...\n");
4032 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4034 trace("emulated http test (to object)...\n");
4035 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE, S_OK);
4037 trace("emulated http test (to object, redirect)...\n");
4038 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, S_OK);
4040 trace("emulated http test (to file)...\n");
4041 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
4043 trace("emulated http test (redirect)...\n");
4044 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, TYMED_ISTREAM);
4046 trace("emulated http test (with cache)...\n");
4047 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
4049 trace("winetest test (no callback)...\n");
4050 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM);
4052 trace("emulated https test...\n");
4053 test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4055 trace("about test...\n");
4056 test_BindToStorage(ABOUT_TEST, 0, TYMED_ISTREAM);
4058 trace("about test (to file)...\n");
4059 test_BindToStorage(ABOUT_TEST, 0, TYMED_FILE);
4061 trace("about test (to object)...\n");
4062 test_BindToObject(ABOUT_TEST, 0, S_OK);
4064 trace("emulated about test...\n");
4065 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4067 trace("emulated about test (to file)...\n");
4068 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE);
4070 trace("emulated about test (to object)...\n");
4071 test_BindToObject(ABOUT_TEST, BINDTEST_EMULATE, S_OK);
4073 trace("emulalated test reporting result in read...\n");
4074 test_BindToStorage(WINETEST_SYNC_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4076 trace("file test...\n");
4077 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
4079 trace("file test (to file)...\n");
4080 test_BindToStorage(FILE_TEST, 0, TYMED_FILE);
4082 trace("file test (to object)...\n");
4083 test_BindToObject(FILE_TEST, 0, S_OK);
4085 trace("emulated file test...\n");
4086 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4088 trace("emulated file test (to file)...\n");
4089 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
4091 trace("emulated file test (to object)...\n");
4092 test_BindToObject(FILE_TEST, BINDTEST_EMULATE, S_OK);
4094 trace("emulated its test...\n");
4095 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4097 trace("emulated its test (to file)...\n");
4098 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_FILE);
4100 trace("emulated mk test...\n");
4101 test_BindToStorage(MK_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4103 trace("test URLDownloadToFile for file protocol...\n");
4104 test_URLDownloadToFile(FILE_TEST, FALSE);
4106 trace("test URLDownloadToFile for emulated file protocol...\n");
4107 test_URLDownloadToFile(FILE_TEST, TRUE);
4109 trace("test URLDownloadToFile for http protocol...\n");
4110 test_URLDownloadToFile(HTTP_TEST, FALSE);
4112 trace("test URLDownloadToFile abort...\n");
4113 test_URLDownloadToFile_abort();
4115 trace("test emulated http abort...\n");
4116 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_ABORT, TYMED_ISTREAM);
4118 bindf |= BINDF_NOWRITECACHE;
4120 trace("ftp test...\n");
4121 test_BindToStorage(FTP_TEST, 0, TYMED_ISTREAM);
4123 trace("test failures...\n");
4124 test_BindToStorage_fail();
4126 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE;
4127 only_check_prot_args = TRUE; /* Fail after checking arguments to Protocol_Start */
4129 trace("check emulated http protocol arguments...\n");
4130 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
4133 DeleteFileA(test_file);
4134 DeleteFileA(test_txtA);
4135 CloseHandle(complete_event);
4136 CloseHandle(complete_event2);
4137 CoUninitialize();