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
26 #define NONAMELESSUNION
36 #include "wine/test.h"
38 static HRESULT (WINAPI *pCreateAsyncBindCtxEx)(IBindCtx *, DWORD,
39 IBindStatusCallback *, IEnumFORMATETC *, IBindCtx **, DWORD);
40 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
42 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
43 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
44 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
46 #define DEFINE_EXPECT(func) \
47 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
49 #define SET_EXPECT(func) \
50 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
52 #define CHECK_EXPECT2(func) \
54 ok(expect_ ##func, "unexpected call " #func "\n"); \
55 called_ ## func = TRUE; \
58 #define CHECK_EXPECT(func) \
60 CHECK_EXPECT2(func); \
61 expect_ ## func = FALSE; \
64 #define CHECK_CALLED(func) \
66 ok(called_ ## func, "expected " #func "\n"); \
67 expect_ ## func = called_ ## func = FALSE; \
70 #define CHECK_NOT_CALLED(func) \
72 ok(!called_ ## func, "unexpected " #func "\n"); \
73 expect_ ## func = called_ ## func = FALSE; \
76 #define CHECK_CALLED_BROKEN(func) \
78 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
79 expect_ ## func = called_ ## func = FALSE; \
82 #define CLEAR_CALLED(func) \
83 expect_ ## func = called_ ## func = FALSE
85 DEFINE_EXPECT(QueryInterface_IServiceProvider);
86 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
87 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
88 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
89 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
90 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
91 DEFINE_EXPECT(QueryInterface_IAuthenticate);
92 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
93 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI);
94 DEFINE_EXPECT(QueryInterface_IHttpSecurity);
95 DEFINE_EXPECT(QueryService_IAuthenticate);
96 DEFINE_EXPECT(QueryService_IInternetProtocol);
97 DEFINE_EXPECT(QueryService_IInternetBindInfo);
98 DEFINE_EXPECT(QueryService_IWindowForBindingUI);
99 DEFINE_EXPECT(QueryService_IHttpSecurity);
100 DEFINE_EXPECT(BeginningTransaction);
101 DEFINE_EXPECT(OnResponse);
102 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
103 DEFINE_EXPECT(GetRootSecurityId);
104 DEFINE_EXPECT(GetBindInfo);
105 DEFINE_EXPECT(GetBindInfoEx);
106 DEFINE_EXPECT(OnStartBinding);
107 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
108 DEFINE_EXPECT(OnProgress_CONNECTING);
109 DEFINE_EXPECT(OnProgress_REDIRECTING);
110 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
111 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
112 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
113 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
114 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
115 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
116 DEFINE_EXPECT(OnStopBinding);
117 DEFINE_EXPECT(OnDataAvailable);
118 DEFINE_EXPECT(OnObjectAvailable);
119 DEFINE_EXPECT(Obj_OnStartBinding);
120 DEFINE_EXPECT(Obj_OnStopBinding);
121 DEFINE_EXPECT(Obj_GetBindInfo);
122 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
123 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
124 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
125 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
126 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
127 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
128 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
129 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
130 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
131 DEFINE_EXPECT(Obj_OnProgress_REDIRECTING);
132 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
133 DEFINE_EXPECT(Start);
135 DEFINE_EXPECT(LockRequest);
136 DEFINE_EXPECT(Terminate);
137 DEFINE_EXPECT(UnlockRequest);
138 DEFINE_EXPECT(Continue);
139 DEFINE_EXPECT(Abort);
140 DEFINE_EXPECT(CreateInstance);
142 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
143 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
144 DEFINE_EXPECT(SetPriority);
145 DEFINE_EXPECT(GetWindow_IHttpSecurity);
146 DEFINE_EXPECT(GetWindow_IWindowForBindingUI);
147 DEFINE_EXPECT(OnSecurityProblem);
149 static const WCHAR winetest_data_urlW[] =
150 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
151 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
153 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','s','/','d','a','t','a','.','p','h','p','\0'};
155 static const WCHAR winetest_post_urlW[] =
156 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
157 't','e','s','t','s','/','p','o','s','t','.','p','h','p',0};
158 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
159 static WCHAR INDEX_HTML[MAX_PATH];
160 static const WCHAR ITS_URL[] =
161 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
162 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
163 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
164 static const WCHAR https_urlW[] =
165 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
166 '/','t','e','s','t','.','h','t','m','l',0};
167 static const WCHAR https_invalid_cn_urlW[] =
168 {'h','t','t','p','s',':','/','/','2','0','9','.','4','6','.','2','5','.','1','3','2',
169 '/','t','e','s','t','.','h','t','m','l',0};
170 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
171 '/','p','u','b','/','o','t','h','e','r','/',
172 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
173 static const WCHAR winetest_urlW[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t',0};
176 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
178 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
180 static const WCHAR wszWineHQSite[] =
181 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
182 static const WCHAR wszWineHQIP[] =
183 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
184 static const CHAR wszIndexHtmlA[] = "index.html";
185 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
186 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
187 static const CHAR dwl_htmlA[] = "dwl.html";
188 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
189 static const CHAR test_txtA[] = "test.txt";
190 static const WCHAR emptyW[] = {0};
192 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
193 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
194 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed, security_problem;
195 static CHAR mime_type[512];
196 static IInternetProtocolSink *protocol_sink = NULL;
197 static IBinding *current_binding;
198 static HANDLE complete_event, complete_event2;
199 static HRESULT binding_hres;
200 static HRESULT onsecurityproblem_hres;
201 static HRESULT abort_hres;
202 static BOOL have_IHttpNegotiate2, use_bscex, is_async_prot;
203 static BOOL test_redirect, use_cache_file, callback_read, no_callback, test_abort;
204 static WCHAR cache_file_name[MAX_PATH];
205 static BOOL only_check_prot_args = FALSE;
206 static BOOL invalid_cn_accepted = FALSE;
207 static BOOL abort_start = FALSE;
208 static BOOL abort_progress = FALSE;
210 static LPCWSTR urls[] = {
221 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
240 static const char *debugstr_guid(REFIID riid)
244 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
245 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
246 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
247 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
252 static BOOL proxy_active(void)
254 HKEY internet_settings;
258 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
259 0, KEY_QUERY_VALUE, &internet_settings) != ERROR_SUCCESS)
262 size = sizeof(DWORD);
263 if (RegQueryValueExA(internet_settings, "ProxyEnable", NULL, NULL, (LPBYTE) &proxy_enable, &size) != ERROR_SUCCESS)
266 RegCloseKey(internet_settings);
268 return proxy_enable != 0;
271 static BOOL is_urlmon_protocol(int prot)
273 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
276 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
279 IMoniker *mon1 = NULL;
280 IMoniker *mon2 = NULL;
282 hr = CreateURLMoniker(NULL, NULL, NULL);
283 ok(hr == E_INVALIDARG,
284 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
286 mon1 = (IMoniker *)0xdeadbeef;
287 hr = CreateURLMoniker(NULL, NULL, &mon1);
288 ok(hr == E_INVALIDARG,
289 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
290 ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1);
292 hr = CreateURLMoniker(NULL, emptyW, NULL);
293 ok(hr == E_INVALIDARG,
294 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
296 hr = CreateURLMoniker(NULL, emptyW, &mon1);
298 broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */
299 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr);
300 if(mon1) IMoniker_Release(mon1);
302 hr = CreateURLMoniker(NULL, url1, &mon1);
303 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
305 hr = CreateURLMoniker(mon1, url2, &mon2);
306 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
308 if(mon1) IMoniker_Release(mon1);
309 if(mon2) IMoniker_Release(mon2);
312 static void test_create(void)
314 static const WCHAR relativeW[] = {'a','/','b','.','t','x','t',0};
320 test_CreateURLMoniker(winetest_data_urlW, TEST_PART_URL_1);
322 mon = (void*)0xdeadbeef;
323 hr = CreateURLMoniker(NULL, relativeW, &mon);
324 ok(hr == S_OK, "got 0x%08x\n", hr);
326 hr = CreateBindCtx(0, &bctx);
327 ok(hr == S_OK, "got 0x%08x\n", hr);
329 stream = (void*)0xdeadbeef;
330 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&stream);
331 todo_wine ok(hr == INET_E_UNKNOWN_PROTOCOL, "got 0x%08x\n", hr);
332 ok(stream == NULL, "got %p\n", stream);
334 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
335 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
337 stream = (void*)0xdeadbeef;
338 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
339 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
340 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
343 IMoniker_Release(mon);
345 mon = (void*)0xdaedbeef;
346 hr = CreateURLMoniker(NULL, winetest_data_urlW, &mon);
347 ok(hr == S_OK, "got 0x%08x\n", hr);
349 stream = (void*)0xdeadbeef;
350 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
351 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
352 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
355 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
356 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
358 IMoniker_Release(mon);
359 IBindCtx_Release(bctx);
362 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
364 ok(0, "unexpected call\n");
365 return E_NOINTERFACE;
368 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
373 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
378 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
380 CHECK_EXPECT(SetPriority);
381 ok(!nPriority, "nPriority = %d\n", nPriority);
385 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
387 ok(0, "unexpected call\n");
391 static const IInternetPriorityVtbl InternetPriorityVtbl = {
392 Priority_QueryInterface,
395 Priority_SetPriority,
399 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
401 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
405 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
410 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
411 if(!is_urlmon_protocol(test_protocol))
412 return E_NOINTERFACE;
414 *ppv = &InternetPriority;
418 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
419 return E_NOINTERFACE; /* TODO */
421 ok(0, "unexpected call %s\n", debugstr_guid(riid));
422 return E_NOINTERFACE;
425 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
430 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
435 static void test_switch_fail(void)
437 IInternetProtocolSink *binding_sink;
438 PROTOCOLDATA protocoldata = {0};
441 static BOOL tested_switch_fail;
443 if(tested_switch_fail)
446 tested_switch_fail = TRUE;
448 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
449 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
450 if(SUCCEEDED(hres)) {
451 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
452 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
453 IInternetProtocolSink_Release(binding_sink);
457 static DWORD WINAPI thread_proc(PVOID arg)
459 PROTOCOLDATA protocoldata = {0};
464 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
466 SET_EXPECT(OnProgress_FINDINGRESOURCE);
468 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
469 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
470 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
472 WaitForSingleObject(complete_event, INFINITE);
474 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
476 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
481 SET_EXPECT(Obj_OnProgress_CONNECTING);
483 SET_EXPECT(OnProgress_CONNECTING);
485 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
486 BINDSTATUS_CONNECTING, wszWineHQIP);
487 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
489 WaitForSingleObject(complete_event, INFINITE);
491 CHECK_CALLED(Obj_OnProgress_CONNECTING);
493 CHECK_CALLED(OnProgress_CONNECTING);
498 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
500 SET_EXPECT(OnProgress_SENDINGREQUEST);
502 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
503 BINDSTATUS_SENDINGREQUEST, NULL);
504 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
506 WaitForSingleObject(complete_event, INFINITE);
508 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
510 CHECK_CALLED(OnProgress_SENDINGREQUEST);
515 SET_EXPECT(Obj_OnProgress_REDIRECTING);
517 SET_EXPECT(OnProgress_REDIRECTING);
518 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_REDIRECTING, winetest_data_urlW);
519 ok(hres == S_OK, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres);
520 WaitForSingleObject(complete_event, INFINITE);
522 CHECK_CALLED(Obj_OnProgress_REDIRECTING);
524 CHECK_CALLED(OnProgress_REDIRECTING);
529 SET_EXPECT(Continue);
531 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
532 ok(hres == S_OK, "Switch failed: %08x\n", hres);
533 WaitForSingleObject(complete_event, INFINITE);
535 CHECK_CALLED(Continue);
538 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
539 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
540 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
541 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
542 CHECK_CALLED(CreateInstance);
543 CHECK_CALLED(PutProperty_MIMETYPEPROP);
544 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
546 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
547 CHECK_CALLED(OnObjectAvailable);
548 CHECK_CALLED(Obj_OnStopBinding);
549 }else if(!no_callback) {
550 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
551 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
552 CHECK_CALLED(OnDataAvailable);
554 CHECK_CALLED(LockRequest);
557 SET_EXPECT(Continue);
559 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
560 ok(hres == S_OK, "Switch failed: %08x\n", hres);
561 WaitForSingleObject(complete_event, INFINITE);
562 CHECK_CALLED(Continue);
564 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
565 CHECK_CALLED(OnStopBinding);
566 SetEvent(complete_event2);
571 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
572 CHECK_CALLED(OnDataAvailable);
576 SET_EXPECT(Continue);
578 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
579 ok(hres == S_OK, "Switch failed: %08x\n", hres);
580 WaitForSingleObject(complete_event, INFINITE);
581 CHECK_CALLED(Continue);
584 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
585 CHECK_CALLED(OnDataAvailable);
588 SET_EXPECT(Continue);
590 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
591 ok(hres == S_OK, "Switch failed: %08x\n", hres);
592 WaitForSingleObject(complete_event, INFINITE);
593 CHECK_CALLED(Continue);
596 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
597 CHECK_CALLED(OnDataAvailable);
598 CHECK_CALLED(OnStopBinding);
603 SetEvent(complete_event2);
607 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
608 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
609 DWORD grfPI, HANDLE_PTR dwReserved)
612 DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
615 static const STGMEDIUM stgmed_zero = {0};
616 static const SECURITY_ATTRIBUTES sa_zero = {0};
622 if(!filedwl_api) /* FIXME */
623 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", wine_dbgstr_w(szUrl));
624 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
625 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
626 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
627 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
629 if(!filedwl_api && binding_hres != S_OK) {
630 SET_EXPECT(OnStopBinding);
631 SET_EXPECT(Terminate);
632 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
633 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
634 CHECK_CALLED(OnStopBinding);
635 CHECK_CALLED(Terminate);
640 memset(&bindinfo, 0, sizeof(bindinfo));
641 bindinfo.cbSize = sizeof(bindinfo);
642 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
643 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
645 ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n");
647 if(filedwl_api || !is_urlmon_protocol(test_protocol) || tymed != TYMED_ISTREAM ||
648 !(bindf&BINDF_ASYNCSTORAGE) || !(bindf&BINDF_PULLDATA))
649 ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n");
651 ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n");
653 bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON);
654 if(filedwl_api || no_callback)
655 ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info);
657 ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n",
658 bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)));
660 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
661 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
662 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
663 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
664 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
665 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
666 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
667 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
668 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
669 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
670 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
671 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
672 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
673 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
675 if(only_check_prot_args)
678 switch(test_protocol) {
680 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
681 BINDSTATUS_DIRECTBIND, NULL);
683 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
688 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
690 SET_EXPECT(OnProgress_SENDINGREQUEST);
691 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
692 BINDSTATUS_SENDINGREQUEST, emptyW);
694 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
696 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
698 CHECK_CALLED(OnProgress_SENDINGREQUEST);
703 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
704 IServiceProvider *service_provider;
705 IHttpNegotiate *http_negotiate;
706 IHttpNegotiate2 *http_negotiate2;
707 IHttpSecurity *http_security;
708 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
709 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
711 DWORD fetched = 256, size = 100;
714 static const WCHAR wszMimes[] = {'*','/','*',0};
716 SET_EXPECT(QueryInterface_IInternetBindInfo);
717 SET_EXPECT(QueryService_IInternetBindInfo);
718 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
720 CLEAR_CALLED(QueryInterface_IInternetBindInfo); /* IE <8 */
721 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
723 ok(hres == E_NOINTERFACE,
724 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
725 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
726 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
728 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
729 accept_mimes, 256, &fetched);
731 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
732 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
733 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
734 CoTaskMemFree(accept_mimes[0]);
736 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
737 NULL, 256, &fetched);
738 ok(hres == E_INVALIDARG,
739 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
741 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
742 accept_mimes, 256, NULL);
743 ok(hres == E_INVALIDARG,
744 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
746 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
747 (void**)&service_provider);
748 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
750 SET_EXPECT(QueryInterface_IHttpNegotiate);
751 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
752 &IID_IHttpNegotiate, (void**)&http_negotiate);
753 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
754 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
757 SET_EXPECT(BeginningTransaction);
758 SET_EXPECT(QueryInterface_IHttpNegotiate);
760 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
761 NULL, 0, &additional_headers);
763 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
764 CHECK_CALLED(BeginningTransaction);
766 IHttpNegotiate_Release(http_negotiate);
767 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
768 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
770 SET_EXPECT(QueryInterface_IHttpNegotiate2);
771 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
772 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
773 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
774 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
778 SET_EXPECT(QueryInterface_IHttpNegotiate2);
779 SET_EXPECT(GetRootSecurityId);
781 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
783 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
784 CHECK_CALLED(GetRootSecurityId);
786 IHttpNegotiate2_Release(http_negotiate2);
787 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
788 ok(size == no_callback ? 512 : 13, "size=%d\n", size);
791 SET_EXPECT(QueryService_IHttpSecurity);
792 SET_EXPECT(QueryInterface_IHttpSecurity);
794 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpSecurity,
795 &IID_IHttpSecurity, (void**)&http_security);
796 ok(hres == (no_callback ? E_NOINTERFACE : S_OK), "QueryService failed: 0x%08x\n", hres);
798 CHECK_CALLED(QueryService_IHttpSecurity);
799 CHECK_CALLED(QueryInterface_IHttpSecurity);
802 IServiceProvider_Release(service_provider);
804 IInternetProtocolSink_AddRef(pOIProtSink);
805 protocol_sink = pOIProtSink;
806 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
811 if(test_protocol == FILE_TEST) {
812 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
813 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
815 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
818 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
820 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
821 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
822 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
824 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
826 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
828 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
830 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
831 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
833 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
836 if(test_protocol == ABOUT_TEST)
837 bscf |= BSCF_DATAFULLYAVAILABLE;
838 if(test_protocol == ITS_TEST)
839 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
843 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
844 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
845 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
846 if(test_protocol == FILE_TEST)
847 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
848 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
849 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
850 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
851 SET_EXPECT(CreateInstance);
852 SET_EXPECT(PutProperty_MIMETYPEPROP);
853 SET_EXPECT(PutProperty_CLASSIDPROP);
855 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
856 SET_EXPECT(OnObjectAvailable);
857 SET_EXPECT(Obj_OnStopBinding);
859 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
860 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
861 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
862 if(test_protocol == FILE_TEST)
863 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
864 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
865 SET_EXPECT(LockRequest);
867 SET_EXPECT(OnDataAvailable);
868 SET_EXPECT(OnStopBinding);
871 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
872 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
876 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
877 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
878 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
879 if(test_protocol == FILE_TEST)
880 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
881 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
882 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
883 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
884 CHECK_CALLED(CreateInstance);
885 CHECK_CALLED(PutProperty_MIMETYPEPROP);
886 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
888 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
889 CHECK_CALLED(OnObjectAvailable);
890 CHECK_CALLED(Obj_OnStopBinding);
892 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
893 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
894 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
895 if(test_protocol == FILE_TEST)
896 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
897 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
898 CHECK_CALLED(LockRequest);
900 CHECK_CALLED(OnDataAvailable);
901 CHECK_CALLED(OnStopBinding);
904 if(test_protocol == ITS_TEST) {
906 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
907 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
909 }else if(!bind_to_object && test_protocol == ABOUT_TEST) {
911 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
912 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
916 SET_EXPECT(Terminate);
917 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
918 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
919 CHECK_CALLED(Terminate);
924 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
925 PROTOCOLDATA *pProtocolData)
930 CHECK_EXPECT(Continue);
932 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
934 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
940 IServiceProvider *service_provider;
941 IHttpNegotiate *http_negotiate;
942 static WCHAR header[] = {'?',0};
944 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
945 (void**)&service_provider);
946 ok(hres == S_OK, "Could not get IServiceProvicder\n");
948 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
949 &IID_IHttpNegotiate, (void**)&http_negotiate);
950 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
953 SET_EXPECT(QueryInterface_IHttpNegotiate);
954 SET_EXPECT(OnResponse);
956 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
958 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
959 CHECK_CALLED(OnResponse);
961 IHttpNegotiate_Release(http_negotiate);
962 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
964 if(test_protocol == HTTPS_TEST || test_redirect) {
965 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
966 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
969 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
970 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
972 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
974 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
975 BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW);
976 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
978 bscf |= BSCF_FIRSTDATANOTIFICATION;
983 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
987 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
988 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
990 if(prot_state != 2 || !test_abort)
995 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
996 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
997 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
998 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
999 SET_EXPECT(CreateInstance);
1000 SET_EXPECT(PutProperty_MIMETYPEPROP);
1001 SET_EXPECT(PutProperty_CLASSIDPROP);
1003 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1004 SET_EXPECT(OnObjectAvailable);
1005 SET_EXPECT(Obj_OnStopBinding);
1006 }else if(!no_callback) {
1007 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1008 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1009 SET_EXPECT(LockRequest);
1011 SET_EXPECT(LockRequest);
1016 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1019 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1020 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1023 if((!bind_to_object || prot_state >= 2) && (!test_abort || prot_state != 2))
1024 SET_EXPECT(OnDataAvailable);
1025 if(prot_state == 3 || (test_abort && prot_state == 2))
1026 SET_EXPECT(OnStopBinding);
1031 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
1036 CHECK_EXPECT(Abort);
1038 ok(hrReason == E_ABORT, "hrReason = %08x\n", hrReason);
1039 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
1041 hres = IInternetProtocolSink_ReportResult(protocol_sink, E_ABORT, ERROR_SUCCESS, NULL);
1042 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1047 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
1049 CHECK_EXPECT(Terminate);
1051 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
1054 IInternetProtocolSink_Release(protocol_sink);
1055 protocol_sink = NULL;
1059 SetEvent(complete_event);
1063 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
1065 ok(0, "unexpected call\n");
1069 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
1071 ok(0, "unexpected call\n");
1075 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
1076 ULONG cb, ULONG *pcbRead)
1078 static const char data[] = "<HTML></HTML>";
1080 CHECK_EXPECT2(Read);
1082 ok(pv != NULL, "pv == NULL\n");
1083 ok(cb != 0, "cb == 0\n");
1084 ok(pcbRead != NULL, "pcbRead == NULL\n");
1086 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
1089 static int pending = TRUE;
1093 switch(prot_state) {
1098 memset(pv, '?', 10);
1099 if(prot_state == 2 && no_callback)
1100 SetEvent(complete_event);
1103 memset(pv, '?', cb);
1113 hres = IInternetProtocolSink_ReportData(protocol_sink,
1114 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
1115 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1117 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1118 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1132 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
1133 read += *pcbRead = sizeof(data)-1;
1134 memcpy(pv, data, sizeof(data));
1138 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
1139 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1141 ok(0, "unexpected call\n");
1145 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
1147 CHECK_EXPECT(LockRequest);
1149 SetEvent(complete_event);
1153 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
1155 CHECK_EXPECT(UnlockRequest);
1159 static const IInternetProtocolVtbl ProtocolVtbl = {
1160 Protocol_QueryInterface,
1171 Protocol_LockRequest,
1172 Protocol_UnlockRequest
1175 static IInternetProtocol Protocol = { &ProtocolVtbl };
1177 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
1179 if(IsEqualGUID(&IID_IUnknown, riid)
1180 || IsEqualGUID(&IID_IHttpNegotiate, riid)
1181 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1186 ok(0, "unexpected call\n");
1187 return E_NOINTERFACE;
1190 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
1195 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
1200 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
1201 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1203 if(onsecurityproblem_hres == S_OK)
1204 CHECK_EXPECT2(BeginningTransaction);
1206 CHECK_EXPECT(BeginningTransaction);
1208 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1210 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
1211 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1212 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1213 if(pszAdditionalHeaders)
1214 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1219 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1220 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1222 CHECK_EXPECT(OnResponse);
1224 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1226 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1227 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1228 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1229 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1230 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1231 if(pszAdditionalRequestHeaders)
1232 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1237 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1238 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1240 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1242 CHECK_EXPECT(GetRootSecurityId);
1244 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1246 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1247 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1248 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1250 if(pbSecurityId == (void*)0xdeadbeef)
1254 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1255 *pcbSecurityId = sizeof(sec_id);
1259 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1264 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1265 HttpNegotiate_QueryInterface,
1266 HttpNegotiate_AddRef,
1267 HttpNegotiate_Release,
1268 HttpNegotiate_BeginningTransaction,
1269 HttpNegotiate_OnResponse,
1270 HttpNegotiate_GetRootSecurityId
1273 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1275 static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv)
1277 ok(0, "Unexpected call\n");
1279 if(IsEqualGUID(&IID_IHttpSecurity, riid) ||
1280 IsEqualGUID(&IID_IWindowForBindingUI, riid) ||
1281 IsEqualGUID(&IID_IUnknown, riid))
1287 ok(0, "Unexpected interface requested.\n");
1289 return E_NOINTERFACE;
1292 static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface)
1297 static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface)
1302 static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity *iface, REFGUID rguidReason, HWND *phwnd)
1304 if(IsEqualGUID(rguidReason, &IID_IHttpSecurity))
1305 CHECK_EXPECT(GetWindow_IHttpSecurity);
1306 else if(IsEqualGUID(rguidReason, &IID_IWindowForBindingUI))
1307 CHECK_EXPECT2(GetWindow_IWindowForBindingUI);
1309 ok(0, "Unexpected rguidReason: %s\n", debugstr_guid(rguidReason));
1315 static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem)
1317 CHECK_EXPECT(OnSecurityProblem);
1318 if(!security_problem) {
1319 ok(dwProblem == ERROR_INTERNET_SEC_CERT_CN_INVALID ||
1320 broken(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) /* Some versions of IE6 */,
1321 "Got problem: %d\n", dwProblem);
1322 security_problem = dwProblem;
1324 if(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS)
1325 binding_hres = INET_E_SECURITY_PROBLEM;
1327 ok(dwProblem == security_problem, "Got problem: %d\n", dwProblem);
1329 return onsecurityproblem_hres;
1332 static const IHttpSecurityVtbl HttpSecurityVtbl = {
1333 HttpSecurity_QueryInterface,
1334 HttpSecurity_AddRef,
1335 HttpSecurity_Release,
1336 HttpSecurity_GetWindow,
1337 HttpSecurity_OnSecurityProblem
1340 static IHttpSecurity HttpSecurity = { &HttpSecurityVtbl };
1342 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1344 ok(0, "unexpected call\n");
1345 return E_NOINTERFACE;
1348 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1353 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1358 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1359 REFGUID guidService, REFIID riid, void **ppv)
1361 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1362 CHECK_EXPECT(QueryService_IAuthenticate);
1366 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1367 CHECK_EXPECT2(QueryService_IInternetProtocol);
1371 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1372 CHECK_EXPECT(QueryService_IInternetBindInfo);
1376 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1377 CHECK_EXPECT2(QueryService_IWindowForBindingUI);
1378 *ppv = &HttpSecurity;
1382 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
1383 CHECK_EXPECT(QueryService_IHttpSecurity);
1384 *ppv = &HttpSecurity;
1388 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1389 return E_NOINTERFACE;
1392 static IServiceProviderVtbl ServiceProviderVtbl = {
1393 ServiceProvider_QueryInterface,
1394 ServiceProvider_AddRef,
1395 ServiceProvider_Release,
1396 ServiceProvider_QueryService
1399 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1401 static IBindStatusCallbackEx objbsc;
1403 static void test_WinInetHttpInfo(IWinInetHttpInfo *http_info, DWORD progress)
1406 HRESULT hres, expect;
1408 /* QueryInfo changes it's behavior during this request */
1409 if(progress == BINDSTATUS_SENDINGREQUEST)
1412 if(test_protocol==FTP_TEST && download_state==BEFORE_DOWNLOAD
1413 && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1415 else if(test_protocol == FTP_TEST)
1420 size = sizeof(DWORD);
1421 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
1422 &status, &size, NULL, NULL);
1423 ok(hres == expect, "hres = %x, expected %x\n", hres, expect);
1425 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1426 ok(status == 0, "status = %d\n", status);
1428 ok(status == HTTP_STATUS_OK, "status = %d\n", status);
1429 ok(size == sizeof(DWORD), "size = %d\n", size);
1432 size = sizeof(DWORD);
1433 hres = IWinInetHttpInfo_QueryOption(http_info, INTERNET_OPTION_HANDLE_TYPE, &status, &size);
1434 if(test_protocol == FTP_TEST) {
1435 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1436 ok(hres == E_FAIL, "hres = %x\n", hres);
1438 ok(hres == S_OK, "hres = %x\n", hres);
1441 ok(status == INTERNET_HANDLE_TYPE_FTP_FILE, "status = %d\n", status);
1443 ok(hres == S_OK, "hres = %x\n", hres);
1444 ok(status == INTERNET_HANDLE_TYPE_HTTP_REQUEST, "status = %d\n", status);
1448 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1450 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1452 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1453 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1454 if(emulate_protocol) {
1458 return E_NOINTERFACE;
1461 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1463 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1464 *ppv = &ServiceProvider;
1467 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1469 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1470 *ppv = &HttpNegotiate;
1473 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1475 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1476 *ppv = &HttpNegotiate;
1479 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1481 CHECK_EXPECT(QueryInterface_IAuthenticate);
1482 return E_NOINTERFACE;
1484 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1486 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1490 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1492 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1493 return E_NOINTERFACE;
1495 else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid))
1497 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1499 return E_NOINTERFACE;
1503 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1506 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1508 else if(IsEqualGUID(&IID_IWindowForBindingUI, riid))
1510 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1511 return E_NOINTERFACE;
1513 else if(IsEqualGUID(&IID_IHttpSecurity, riid))
1515 CHECK_EXPECT2(QueryInterface_IHttpSecurity);
1516 return E_NOINTERFACE;
1520 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1523 return E_NOINTERFACE;
1526 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1531 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1536 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1539 IWinInetHttpInfo *http_info;
1543 if(iface == &objbsc)
1544 CHECK_EXPECT(Obj_OnStartBinding);
1546 CHECK_EXPECT(OnStartBinding);
1548 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1550 ok(pib != NULL, "pib should not be NULL\n");
1551 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1553 if(pib == (void*)0xdeadbeef)
1556 current_binding = pib;
1558 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1559 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1561 IMoniker_Release(mon);
1563 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1564 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1567 binding_hres = abort_hres;
1574 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1576 ok(0, "unexpected call\n");
1580 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1582 ok(0, "unexpected call\n");
1586 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1587 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1589 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1591 switch(ulStatusCode) {
1592 case BINDSTATUS_FINDINGRESOURCE:
1593 if(iface == &objbsc)
1594 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1595 else if(test_protocol == FTP_TEST)
1596 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1598 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1599 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1600 SetEvent(complete_event);
1602 case BINDSTATUS_CONNECTING:
1603 if(iface == &objbsc)
1604 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1605 else if(test_protocol == FTP_TEST)
1606 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1607 else if(onsecurityproblem_hres == S_OK)
1608 CHECK_EXPECT2(OnProgress_CONNECTING);
1610 CHECK_EXPECT(OnProgress_CONNECTING);
1611 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1612 SetEvent(complete_event);
1614 case BINDSTATUS_REDIRECTING:
1615 if(iface == &objbsc)
1616 CHECK_EXPECT(Obj_OnProgress_REDIRECTING);
1618 CHECK_EXPECT(OnProgress_REDIRECTING);
1619 ok(!lstrcmpW(szStatusText, winetest_data_urlW), "unexpected status text %s\n",
1620 wine_dbgstr_w(szStatusText));
1621 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
1622 && (!bind_to_object || iface == &objbsc))
1623 SetEvent(complete_event);
1625 case BINDSTATUS_SENDINGREQUEST:
1626 if(iface == &objbsc)
1627 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1628 else if(test_protocol == FTP_TEST)
1629 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1631 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1632 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST))
1633 SetEvent(complete_event);
1635 if(abort_progress) {
1637 binding_hres = E_ABORT;
1642 case BINDSTATUS_MIMETYPEAVAILABLE:
1643 if(iface == &objbsc)
1644 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1646 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1648 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1650 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1652 case BINDSTATUS_BEGINDOWNLOADDATA:
1653 if(iface == &objbsc)
1654 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1656 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1657 ok(szStatusText != NULL, "szStatusText == NULL\n");
1662 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1666 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1668 download_state = DOWNLOADING;
1670 case BINDSTATUS_DOWNLOADINGDATA:
1671 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1672 ok(iface != &objbsc, "unexpected call\n");
1673 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1679 hres = IBinding_Abort(current_binding);
1680 ok(hres == S_OK, "Abort failed: %08x\n", hres);
1681 CHECK_CALLED(Abort);
1683 hres = IBinding_Abort(current_binding);
1684 ok(hres == E_FAIL, "Abort failed: %08x\n", hres);
1686 binding_hres = E_ABORT;
1689 case BINDSTATUS_ENDDOWNLOADDATA:
1690 if(iface == &objbsc)
1691 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1693 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1694 ok(szStatusText != NULL, "szStatusText == NULL\n");
1699 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1702 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1704 download_state = END_DOWNLOAD;
1706 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1707 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST && test_protocol != WINETEST_TEST) {
1708 if(iface == &objbsc)
1709 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1711 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1713 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1714 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1717 ok(szStatusText != NULL, "szStatusText == NULL\n");
1718 if(szStatusText && test_protocol == FILE_TEST)
1719 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1721 case BINDSTATUS_CLASSIDAVAILABLE:
1725 if(iface != &objbsc)
1726 ok(0, "unexpected call\n");
1728 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1729 hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid);
1730 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1731 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1732 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1735 case BINDSTATUS_BEGINSYNCOPERATION:
1736 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1737 if(iface != &objbsc)
1738 ok(0, "unexpected call\n");
1739 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1741 case BINDSTATUS_ENDSYNCOPERATION:
1742 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1743 if(iface != &objbsc)
1744 ok(0, "unexpected call\n");
1745 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1747 case BINDSTATUS_PROXYDETECTING:
1748 trace("BINDSTATUS_PROXYDETECTING\n");
1750 case BINDSTATUS_COOKIE_SENT:
1751 trace("BINDSTATUS_COOKIE_SENT\n");
1754 ok(0, "unexpected code %d\n", ulStatusCode);
1757 if(current_binding) {
1758 IWinInetHttpInfo *http_info;
1761 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1762 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol)) {
1763 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1764 test_WinInetHttpInfo(http_info, ulStatusCode);
1766 ok(hres == E_NOINTERFACE,
1767 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1769 IWinInetHttpInfo_Release(http_info);
1775 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1777 if(iface == &objbsc) {
1778 CHECK_EXPECT(Obj_OnStopBinding);
1779 stopped_obj_binding = TRUE;
1781 CHECK_EXPECT(OnStopBinding);
1782 stopped_binding = TRUE;
1785 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1787 if(only_check_prot_args) {
1788 todo_wine ok(hresult == S_OK, "Got %08x\n", hresult);
1792 /* ignore DNS failure */
1793 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1797 if(!abort_progress && !abort_start)
1798 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1799 else if(abort_start && abort_hres == E_NOTIMPL)
1800 todo_wine ok(hresult == S_FALSE, "binding failed: %08x, expected S_FALSE\n", hresult);
1802 ok(hresult == E_ABORT, "binding failed: %08x, expected E_ABORT\n", hresult);
1804 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1805 ok(szError == NULL, "szError should be NULL\n");
1807 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) && emulate_protocol) {
1808 SetEvent(complete_event);
1809 if(iface != &objbsc)
1810 WaitForSingleObject(complete_event2, INFINITE);
1816 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1820 if(iface == &objbsc)
1821 CHECK_EXPECT(Obj_GetBindInfo);
1823 CHECK_EXPECT(GetBindInfo);
1825 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1828 cbSize = pbindinfo->cbSize;
1829 memset(pbindinfo, 0, cbSize);
1830 pbindinfo->cbSize = cbSize;
1835 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1836 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1843 if(iface == &objbsc)
1844 ok(0, "unexpected call\n");
1846 CHECK_EXPECT2(OnDataAvailable);
1848 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1850 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1851 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1853 data_available = TRUE;
1855 if(bind_to_object && !is_async_prot)
1856 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), "grfBSCF = %x\n", grfBSCF);
1858 ok(pformatetc != NULL, "pformatetx == NULL\n");
1863 ret = GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1);
1864 ok(ret, "GetClipboardFormatName failed, error %d\n", GetLastError());
1865 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1866 pformatetc->cfFormat, clipfmt, mime_type);
1868 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1870 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1871 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1872 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1873 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1876 ok(pstgmed != NULL, "stgmeg == NULL\n");
1877 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1878 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1880 switch(pstgmed->tymed) {
1882 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1885 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1886 ok(hres == STG_E_ACCESSDENIED,
1887 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1889 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1890 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1892 hres = IStream_Revert(U(*pstgmed).pstm);
1893 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1895 hres = IStream_Stat(U(*pstgmed).pstm, NULL, STATFLAG_NONAME);
1896 ok(hres == E_FAIL, "hres = %x\n", hres);
1897 if(use_cache_file && emulate_protocol) {
1898 hres = IStream_Stat(U(*pstgmed).pstm, &stat, STATFLAG_DEFAULT);
1899 ok(hres == S_OK, "hres = %x\n", hres);
1900 ok(!lstrcmpW(stat.pwcsName, cache_file_name),
1901 "stat.pwcsName = %s, cache_file_name = %s\n",
1902 wine_dbgstr_w(stat.pwcsName), wine_dbgstr_w(cache_file_name));
1903 CoTaskMemFree(stat.pwcsName);
1904 ok(U(stat.cbSize).LowPart == (bindf&BINDF_ASYNCHRONOUS?0:6500),
1905 "stat.cbSize.LowPart = %u\n", U(stat.cbSize).LowPart);
1907 hres = IStream_Stat(U(*pstgmed).pstm, &stat, STATFLAG_NONAME);
1908 ok(hres == S_OK, "hres = %x\n", hres);
1909 ok(!stat.pwcsName || broken(stat.pwcsName!=NULL),
1910 "stat.pwcsName = %s\n", wine_dbgstr_w(stat.pwcsName));
1912 ok(stat.type == STGTY_STREAM, "stat.type = %x\n", stat.type);
1913 ok(U(stat.cbSize).HighPart == 0, "stat.cbSize.HighPart != 0\n");
1914 ok(stat.grfMode == (U(stat.cbSize).LowPart?GENERIC_READ:0), "stat.grfMode = %x\n", stat.grfMode);
1915 ok(stat.grfLocksSupported == 0, "stat.grfLocksSupported = %x\n", stat.grfLocksSupported);
1916 ok(stat.grfStateBits == 0, "stat.grfStateBits = %x\n", stat.grfStateBits);
1917 ok(stat.reserved == 0, "stat.reserved = %x\n", stat.reserved);
1920 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1923 hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1924 if(test_protocol == HTTP_TEST && emulate_protocol && readed)
1925 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
1926 }while(hres == S_OK);
1927 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1932 if(test_protocol == FILE_TEST)
1933 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1934 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1935 else if(emulate_protocol)
1936 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1937 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1939 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1942 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
1943 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1944 SetEvent(complete_event);
1949 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
1951 CHECK_EXPECT(OnObjectAvailable);
1953 if(iface != &objbsc)
1954 ok(0, "unexpected call\n");
1956 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1957 ok(punk != NULL, "punk == NULL\n");
1962 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
1963 DWORD *grfBINDF2, DWORD *pdwReserved)
1965 CHECK_EXPECT(GetBindInfoEx);
1967 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1968 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
1969 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1970 ok(pdwReserved != NULL, "dwReserved == NULL\n");
1975 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
1976 statusclb_QueryInterface,
1979 statusclb_OnStartBinding,
1980 statusclb_GetPriority,
1981 statusclb_OnLowResource,
1982 statusclb_OnProgress,
1983 statusclb_OnStopBinding,
1984 statusclb_GetBindInfo,
1985 statusclb_OnDataAvailable,
1986 statusclb_OnObjectAvailable,
1987 statusclb_GetBindInfoEx
1990 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
1991 static IBindStatusCallbackEx bsc2 = { &BindStatusCallbackVtbl };
1992 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
1994 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1997 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1998 return E_NOINTERFACE;
2001 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
2006 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
2011 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
2015 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
2016 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
2019 CHECK_EXPECT(PutProperty_CLASSIDPROP);
2028 static const IMonikerPropVtbl MonikerPropVtbl = {
2029 MonikerProp_QueryInterface,
2031 MonikerProp_Release,
2032 MonikerProp_PutProperty
2035 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
2037 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
2041 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
2043 else if(IsEqualGUID(&IID_IMonikerProp, riid))
2044 *ppv = &MonikerProp;
2049 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2050 return E_NOINTERFACE;
2053 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
2058 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
2063 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
2065 ok(0, "unexpected call\n");
2069 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
2071 ok(0, "unexpected call\n");
2075 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
2076 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
2081 static WCHAR cbinding_contextW[] =
2082 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
2085 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
2087 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2088 ok(!fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable);
2090 ok(fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable);
2091 ok(pimkName != NULL, "pimkName == NULL\n");
2092 ok(pibc != NULL, "pibc == NULL\n");
2093 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
2095 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
2096 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
2097 if(SUCCEEDED(hres)) {
2100 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
2101 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
2103 IBinding_Release(binding);
2104 IUnknown_Release(unk);
2107 SET_EXPECT(QueryInterface_IServiceProvider);
2108 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
2109 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2110 CHECK_CALLED(QueryInterface_IServiceProvider);
2112 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2113 SET_EXPECT(GetBindInfo);
2114 SET_EXPECT(OnStartBinding);
2116 SET_EXPECT(OnProgress_REDIRECTING);
2117 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2118 if(test_protocol == FILE_TEST)
2119 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2120 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2121 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2122 SET_EXPECT(LockRequest);
2123 SET_EXPECT(OnDataAvailable);
2124 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2125 SET_EXPECT(OnStopBinding);
2127 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
2128 ok(hres == S_OK, "Load failed: %08x\n", hres);
2130 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2131 CHECK_CALLED(GetBindInfo);
2132 CHECK_CALLED(OnStartBinding);
2134 CHECK_CALLED(OnProgress_REDIRECTING);
2135 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2136 if(test_protocol == FILE_TEST)
2137 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2138 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2139 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2140 CHECK_CALLED(LockRequest);
2141 CHECK_CALLED(OnDataAvailable);
2142 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2143 CHECK_CALLED(OnStopBinding);
2146 IUnknown_Release(unk);
2151 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
2153 ok(0, "unexpected call\n");
2157 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
2159 ok(0, "unexpected call\n");
2163 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
2165 ok(0, "unexpected call\n");
2169 static const IPersistMonikerVtbl PersistMonikerVtbl = {
2170 PersistMoniker_QueryInterface,
2171 PersistMoniker_AddRef,
2172 PersistMoniker_Release,
2173 PersistMoniker_GetClassID,
2174 PersistMoniker_IsDirty,
2175 PersistMoniker_Load,
2176 PersistMoniker_Save,
2177 PersistMoniker_SaveCompleted,
2178 PersistMoniker_GetCurMoniker
2181 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
2183 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2187 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2192 if(IsEqualGUID(&IID_IMarshal, riid))
2193 return E_NOINTERFACE;
2194 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
2195 return E_NOINTERFACE;
2197 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2201 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2206 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2211 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2213 CHECK_EXPECT(CreateInstance);
2214 ok(!outer, "outer = %p\n", outer);
2215 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2216 *ppv = &PersistMoniker;
2220 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
2222 ok(0, "unexpected call\n");
2226 static const IClassFactoryVtbl ClassFactoryVtbl = {
2227 ClassFactory_QueryInterface,
2228 ClassFactory_AddRef,
2229 ClassFactory_Release,
2230 ClassFactory_CreateInstance,
2231 ClassFactory_LockServer
2234 static IClassFactory mime_cf = { &ClassFactoryVtbl };
2236 static HRESULT WINAPI ProtocolCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2240 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2245 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2246 return E_NOINTERFACE;
2248 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2252 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2254 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2255 return E_NOINTERFACE;
2257 todo_wine ok(outer != NULL, "outer == NULL\n");
2258 todo_wine ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2263 static const IClassFactoryVtbl ProtocolCFVtbl = {
2264 ProtocolCF_QueryInterface,
2265 ClassFactory_AddRef,
2266 ClassFactory_Release,
2267 ProtocolCF_CreateInstance,
2268 ClassFactory_LockServer
2271 static IClassFactory protocol_cf = { &ProtocolCFVtbl };
2273 static void test_CreateAsyncBindCtx(void)
2275 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
2281 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
2282 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2283 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
2285 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
2286 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2288 SET_EXPECT(QueryInterface_IServiceProvider);
2289 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2290 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
2291 CHECK_CALLED(QueryInterface_IServiceProvider);
2293 bindopts.cbStruct = sizeof(bindopts);
2294 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2295 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2296 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2297 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2298 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2299 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2301 ok(bindopts.dwTickCountDeadline == 0,
2302 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2304 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2305 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
2307 IUnknown_Release(unk);
2309 ref = IBindCtx_Release(bctx);
2310 ok(ref == 0, "bctx should be destroyed here\n");
2313 static void test_CreateAsyncBindCtxEx(void)
2315 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
2320 static WCHAR testW[] = {'t','e','s','t',0};
2322 if (!pCreateAsyncBindCtxEx) {
2323 win_skip("CreateAsyncBindCtxEx not present\n");
2327 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
2328 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
2330 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2331 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2333 if(SUCCEEDED(hres)) {
2334 bindopts.cbStruct = sizeof(bindopts);
2335 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2336 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2337 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2338 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2339 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2340 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2342 ok(bindopts.dwTickCountDeadline == 0,
2343 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2345 IBindCtx_Release(bctx);
2348 CreateBindCtx(0, &bctx_arg);
2349 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2350 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2352 if(SUCCEEDED(hres)) {
2353 bindopts.cbStruct = sizeof(bindopts);
2354 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2355 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2356 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2357 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2358 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2359 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2361 ok(bindopts.dwTickCountDeadline == 0,
2362 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2364 IBindCtx_Release(bctx);
2367 IBindCtx_Release(bctx_arg);
2369 SET_EXPECT(QueryInterface_IServiceProvider);
2370 hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
2371 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2372 CHECK_CALLED(QueryInterface_IServiceProvider);
2374 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2375 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
2377 IUnknown_Release(unk);
2379 IBindCtx_Release(bctx);
2381 hres = CreateBindCtx(0, &bctx2);
2382 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2384 hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
2385 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2387 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
2388 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2390 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
2391 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2392 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
2394 IBindCtx_Release(bctx);
2395 IBindCtx_Release(bctx2);
2398 static void test_GetBindInfoEx(IBindStatusCallback *holder)
2400 IBindStatusCallbackEx *bscex;
2401 BINDINFO bindinfo = {sizeof(bindinfo)};
2402 DWORD bindf, bindf2, dw;
2405 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
2407 win_skip("IBindStatusCallbackEx not supported\n");
2414 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2415 SET_EXPECT(GetBindInfoEx);
2416 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
2417 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2418 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2419 CHECK_CALLED(GetBindInfoEx);
2421 bindf = bindf2 = dw = 0;
2422 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2423 SET_EXPECT(GetBindInfoEx);
2424 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2425 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2426 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2427 CHECK_CALLED(GetBindInfoEx);
2431 bindf = bindf2 = dw = 0xdeadbeef;
2432 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2433 SET_EXPECT(GetBindInfo);
2434 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2435 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2436 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2437 CHECK_CALLED(GetBindInfo);
2438 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
2439 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
2441 IBindStatusCallbackEx_Release(bscex);
2444 static BOOL test_bscholder(IBindStatusCallback *holder)
2446 IServiceProvider *serv_prov;
2447 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
2448 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
2449 IAuthenticate *authenticate, *authenticate_serv;
2450 IInternetProtocol *protocol;
2451 BINDINFO bindinfo = {sizeof(bindinfo)};
2457 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2458 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2461 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2462 SET_EXPECT(GetBindInfo);
2463 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2464 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2465 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2466 CHECK_CALLED(GetBindInfo);
2468 test_GetBindInfoEx(holder);
2470 SET_EXPECT(OnStartBinding);
2471 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2472 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2473 CHECK_CALLED(OnStartBinding);
2475 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2476 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2478 SET_EXPECT(QueryInterface_IHttpNegotiate);
2479 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2480 (void**)&http_negotiate_serv);
2481 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2482 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2484 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2486 wstr = (void*)0xdeadbeef;
2487 SET_EXPECT(QueryInterface_IHttpNegotiate);
2488 SET_EXPECT(BeginningTransaction);
2489 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
2490 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2491 CHECK_CALLED(BeginningTransaction);
2492 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2493 ok(wstr == NULL, "wstr = %p\n", wstr);
2495 IHttpNegotiate_Release(http_negotiate_serv);
2497 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2498 (void**)&http_negotiate_serv);
2499 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2500 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2501 IHttpNegotiate_Release(http_negotiate_serv);
2503 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2504 if(SUCCEEDED(hres)) {
2505 have_IHttpNegotiate2 = TRUE;
2507 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2508 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2509 (void**)&http_negotiate2_serv);
2510 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2511 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2512 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2514 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2515 SET_EXPECT(GetRootSecurityId);
2516 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2517 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2518 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2519 CHECK_CALLED(GetRootSecurityId);
2521 IHttpNegotiate_Release(http_negotiate2_serv);
2522 IHttpNegotiate_Release(http_negotiate2);
2524 skip("Could not get IHttpNegotiate2\n");
2528 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2529 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2530 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2531 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2533 SET_EXPECT(QueryInterface_IHttpNegotiate);
2534 SET_EXPECT(OnResponse);
2535 wstr = (void*)0xdeadbeef;
2536 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2537 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2538 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2539 CHECK_CALLED(OnResponse);
2541 IHttpNegotiate_Release(http_negotiate);
2543 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2544 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2546 SET_EXPECT(QueryInterface_IAuthenticate);
2547 SET_EXPECT(QueryService_IAuthenticate);
2548 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2549 (void**)&authenticate_serv);
2550 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2551 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2552 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2553 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2554 IAuthenticate_Release(authenticate_serv);
2556 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2557 (void**)&authenticate_serv);
2558 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2559 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2561 IAuthenticate_Release(authenticate);
2562 IAuthenticate_Release(authenticate_serv);
2564 SET_EXPECT(OnStopBinding);
2565 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2566 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2567 CHECK_CALLED(OnStopBinding);
2569 SET_EXPECT(QueryInterface_IInternetProtocol);
2570 SET_EXPECT(QueryService_IInternetProtocol);
2571 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2573 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2574 CHECK_CALLED(QueryInterface_IInternetProtocol);
2575 CHECK_CALLED(QueryService_IInternetProtocol);
2577 IServiceProvider_Release(serv_prov);
2581 static BOOL test_RegisterBindStatusCallback(void)
2583 IBindStatusCallback *prevbsc, *clb, *prev_clb;
2589 hres = CreateBindCtx(0, &bindctx);
2590 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2592 SET_EXPECT(QueryInterface_IServiceProvider);
2594 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2595 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2597 SET_EXPECT(QueryInterface_IBindStatusCallback);
2598 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2599 prevbsc = (void*)0xdeadbeef;
2600 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2601 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2602 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2603 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2604 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2606 CHECK_CALLED(QueryInterface_IServiceProvider);
2608 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2609 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2611 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2612 IUnknown_Release(unk);
2613 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2614 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2616 if(!test_bscholder(clb))
2619 IBindStatusCallback_Release(clb);
2621 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2622 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2624 unk = (void*)0xdeadbeef;
2625 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2626 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2627 ok(unk == NULL, "unk != NULL\n");
2630 IUnknown_Release(unk);
2632 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2633 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2635 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2636 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2638 hres = RevokeBindStatusCallback(bindctx, NULL);
2639 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2641 SET_EXPECT(QueryInterface_IServiceProvider);
2642 prevbsc = (void*)0xdeadbeef;
2643 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2644 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2645 ok(!prevbsc, "prevbsc=%p\n", prevbsc);
2646 CHECK_CALLED(QueryInterface_IServiceProvider);
2648 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2649 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2651 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&prev_clb);
2652 IUnknown_Release(unk);
2653 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2654 ok(prev_clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2656 SET_EXPECT(QueryInterface_IServiceProvider);
2657 prevbsc = (void*)0xdeadbeef;
2658 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc2, &prevbsc, 0);
2659 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2660 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc != bsc\n");
2661 CHECK_CALLED(QueryInterface_IServiceProvider);
2663 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2664 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2666 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2667 IUnknown_Release(unk);
2668 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2669 ok(prev_clb == clb, "bsc != clb\n");
2671 IBindStatusCallback_Release(clb);
2672 IBindStatusCallback_Release(prev_clb);
2674 IBindCtx_Release(bindctx);
2678 #define BINDTEST_EMULATE 0x0001
2679 #define BINDTEST_TOOBJECT 0x0002
2680 #define BINDTEST_FILEDWLAPI 0x0004
2681 #define BINDTEST_HTTPRESPONSE 0x0008
2682 #define BINDTEST_REDIRECT 0x0010
2683 #define BINDTEST_USE_CACHE 0x0020
2684 #define BINDTEST_NO_CALLBACK_READ 0x0040
2685 #define BINDTEST_NO_CALLBACK 0x0080
2686 #define BINDTEST_ABORT 0x0100
2687 #define BINDTEST_INVALID_CN 0x0200
2688 #define BINDTEST_ABORT_START 0x0400
2689 #define BINDTEST_ABORT_PROGRESS 0x0800
2691 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2693 test_protocol = protocol;
2694 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2695 download_state = BEFORE_DOWNLOAD;
2696 stopped_binding = FALSE;
2697 stopped_obj_binding = FALSE;
2698 data_available = FALSE;
2700 binding_hres = S_OK;
2701 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2703 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2704 if(flags & BINDTEST_HTTPRESPONSE)
2705 urls[HTTP_TEST] = winetest_post_urlW;
2707 urls[HTTP_TEST] = winetest_data_urlW;
2708 if(flags & BINDTEST_INVALID_CN)
2709 urls[HTTPS_TEST] = https_invalid_cn_urlW;
2711 urls[HTTPS_TEST] = https_urlW;
2712 test_redirect = (flags & BINDTEST_REDIRECT) != 0;
2713 use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
2714 callback_read = !(flags & BINDTEST_NO_CALLBACK_READ);
2715 no_callback = (flags & BINDTEST_NO_CALLBACK) != 0;
2716 test_abort = (flags & BINDTEST_ABORT) != 0;
2717 abort_start = (flags & BINDTEST_ABORT_START) != 0;
2718 abort_progress = (flags & BINDTEST_ABORT_PROGRESS) != 0;
2719 is_async_prot = protocol == HTTP_TEST || protocol == HTTPS_TEST || protocol == FTP_TEST || protocol == WINETEST_TEST;
2722 static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
2726 LPOLESTR display_name;
2727 IBindCtx *bctx = NULL;
2729 IBindStatusCallback *previousclb;
2730 IUnknown *unk = (IUnknown*)0x00ff00ff;
2733 init_bind_test(protocol, flags, t);
2736 hres = CreateBindCtx(0, &bctx);
2737 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2739 SET_EXPECT(QueryInterface_IServiceProvider);
2740 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2741 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2742 CHECK_CALLED(QueryInterface_IServiceProvider);
2746 SET_EXPECT(QueryInterface_IServiceProvider);
2747 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2748 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2749 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2750 CHECK_CALLED(QueryInterface_IServiceProvider);
2752 IBindStatusCallback_Release(previousclb);
2755 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2756 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
2760 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2761 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2763 IBinding_Release(bind);
2765 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2766 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2767 ok(!lstrcmpW(display_name, urls[test_protocol]),
2768 "GetDisplayName got wrong name %s\n", wine_dbgstr_w(display_name));
2769 CoTaskMemFree(display_name);
2771 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2772 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2773 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted &&
2774 (onsecurityproblem_hres != S_OK || security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)) {
2775 if(security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)
2776 binding_hres = INET_E_SECURITY_PROBLEM;
2778 binding_hres = INET_E_INVALID_CERTIFICATE;
2782 if(only_check_prot_args)
2783 SET_EXPECT(OnStopBinding);
2785 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2786 SET_EXPECT(GetBindInfo);
2787 SET_EXPECT(QueryInterface_IInternetProtocol);
2788 if(!emulate_protocol)
2789 SET_EXPECT(QueryService_IInternetProtocol);
2790 SET_EXPECT(OnStartBinding);
2792 if(emulate_protocol) {
2793 if(is_urlmon_protocol(test_protocol))
2794 SET_EXPECT(SetPriority);
2796 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
2797 SET_EXPECT(Terminate);
2798 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2799 SET_EXPECT(UnlockRequest);
2801 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2802 SET_EXPECT(QueryInterface_IInternetBindInfo);
2803 SET_EXPECT(QueryService_IInternetBindInfo);
2805 SET_EXPECT(QueryInterface_IHttpNegotiate);
2806 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2807 SET_EXPECT(QueryService_IWindowForBindingUI);
2808 SET_EXPECT(GetWindow_IWindowForBindingUI);
2810 SET_EXPECT(BeginningTransaction);
2811 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2812 SET_EXPECT(GetRootSecurityId);
2814 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2815 SET_EXPECT(OnProgress_CONNECTING);
2817 if(flags & BINDTEST_INVALID_CN) {
2818 SET_EXPECT(QueryInterface_IHttpSecurity);
2819 SET_EXPECT(QueryService_IHttpSecurity);
2820 SET_EXPECT(OnSecurityProblem);
2821 if(SUCCEEDED(onsecurityproblem_hres))
2822 SET_EXPECT(GetWindow_IHttpSecurity);
2826 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
2827 || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) && !abort_start)
2828 SET_EXPECT(OnProgress_SENDINGREQUEST);
2829 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2830 SET_EXPECT(QueryInterface_IHttpNegotiate);
2831 SET_EXPECT(OnResponse);
2834 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2835 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2837 if(test_protocol == FILE_TEST)
2838 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2839 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
2840 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2842 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2843 if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
2844 SET_EXPECT(OnDataAvailable);
2845 SET_EXPECT(OnStopBinding);
2849 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2850 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2851 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2853 skip("Network unreachable, skipping tests\n");
2857 if(only_check_prot_args) {
2858 ok(hres == E_FAIL, "Got %08x\n", hres);
2859 CHECK_CALLED(OnStopBinding);
2860 } else if(abort_start)
2861 ok(hres == abort_hres, "IMoniker_BindToStorage failed: %08x, expected %08x\n", hres, abort_hres);
2862 else if(abort_progress)
2863 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2864 else if(no_callback) {
2865 if(emulate_protocol)
2866 WaitForSingleObject(complete_event2, INFINITE);
2867 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2868 ok(unk != NULL, "unk == NULL\n");
2869 }else if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) {
2870 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2871 ok(unk == NULL, "unk != NULL\n");
2872 }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2873 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2874 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2875 ok(unk == NULL, "istr should be NULL\n");
2876 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2877 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2878 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2879 ok(unk == NULL, "istr should be NULL\n");
2880 }else if((flags & BINDTEST_INVALID_CN) && binding_hres != S_OK) {
2881 ok(hres == binding_hres, "Got %08x\n", hres);
2882 ok(unk == NULL, "Got %p\n", unk);
2883 }else if((flags & BINDTEST_INVALID_CN) && invalid_cn_accepted) {
2884 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2885 ok(unk != NULL, "unk == NULL\n");
2887 ok(0, "Expected security problem to be ignored.\n");
2888 invalid_cn_accepted = FALSE;
2889 binding_hres = INET_E_INVALID_CERTIFICATE;
2892 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2893 ok(unk != NULL, "unk == NULL\n");
2895 if(unk && callback_read && !no_callback) {
2896 IUnknown_Release(unk);
2900 if(FAILED(hres) && !(flags & BINDTEST_INVALID_CN) && !(flags & BINDTEST_ABORT_START))
2903 if((bindf & BINDF_ASYNCHRONOUS) && !no_callback) {
2904 while(!stopped_binding && GetMessage(&msg,NULL,0,0)) {
2905 TranslateMessage(&msg);
2906 DispatchMessage(&msg);
2911 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2912 CHECK_CALLED(GetBindInfo);
2914 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
2916 CHECK_CALLED(QueryInterface_IInternetProtocol);
2917 if(!emulate_protocol) {
2919 todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
2921 CHECK_CALLED(QueryService_IInternetProtocol);
2923 CHECK_CALLED(OnStartBinding);
2925 if(emulate_protocol) {
2926 if(is_urlmon_protocol(test_protocol))
2927 CHECK_CALLED(SetPriority);
2928 CHECK_CALLED(Start);
2929 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2930 if(tymed == TYMED_FILE)
2932 CHECK_CALLED(Terminate);
2934 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2935 CHECK_CALLED(UnlockRequest);
2937 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2938 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2939 CLEAR_CALLED(QueryService_IInternetBindInfo);
2941 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2942 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2943 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2944 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
2946 CHECK_CALLED(BeginningTransaction);
2947 if (have_IHttpNegotiate2 && !abort_start)
2949 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2950 CHECK_CALLED(GetRootSecurityId);
2953 if (! proxy_active())
2955 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2956 CHECK_CALLED(OnProgress_CONNECTING);
2960 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
2961 CLEAR_CALLED(OnProgress_CONNECTING);
2963 }else if(!abort_start) {
2964 /* IE7 does call this */
2965 CLEAR_CALLED(OnProgress_CONNECTING);
2967 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted) {
2968 CHECK_CALLED(QueryInterface_IHttpSecurity);
2969 CHECK_CALLED(QueryService_IHttpSecurity);
2970 CHECK_CALLED(OnSecurityProblem);
2972 CHECK_NOT_CALLED(QueryInterface_IHttpSecurity);
2973 CHECK_NOT_CALLED(QueryService_IHttpSecurity);
2974 CHECK_NOT_CALLED(OnSecurityProblem);
2978 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) {
2979 if(flags & BINDTEST_INVALID_CN)
2980 CLEAR_CALLED(OnProgress_SENDINGREQUEST);
2981 else if(!abort_start)
2982 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2983 } else if(test_protocol == FTP_TEST)
2984 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
2985 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2986 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2987 if((!(flags & BINDTEST_INVALID_CN) || (binding_hres == S_OK)) && !abort_start) {
2988 CHECK_CALLED(OnResponse);
2991 if((!(flags & BINDTEST_INVALID_CN) || binding_hres == S_OK) && !abort_start) {
2992 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2993 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2994 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2996 if(test_protocol == FILE_TEST)
2997 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2998 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
2999 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3000 if((flags & BINDTEST_INVALID_CN)) {
3001 if(binding_hres == S_OK)
3002 CHECK_CALLED(OnDataAvailable);
3004 CHECK_NOT_CALLED(OnDataAvailable);
3005 }else if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
3006 CHECK_CALLED(OnDataAvailable);
3007 CHECK_CALLED(OnStopBinding);
3011 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3013 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
3015 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3016 http_is_first = FALSE;
3018 if((flags & BINDTEST_INVALID_CN) && onsecurityproblem_hres == S_OK && security_problem != ERROR_INTERNET_SEC_CERT_ERRORS)
3019 invalid_cn_accepted = TRUE;
3026 hres = IUnknown_QueryInterface(unk, &IID_IStream, (void**)&stream);
3027 ok(hres == S_OK, "Could not get IStream iface: %08x\n", hres);
3028 IUnknown_Release(unk);
3031 readed = 0xdeadbeef;
3032 hres = IStream_Read(stream, buf, sizeof(buf), &readed);
3033 ok(readed != 0xdeadbeef, "readed = 0xdeadbeef\n");
3034 if(emulate_protocol && test_protocol == HTTP_TEST && readed)
3035 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
3036 }while(hres == S_OK);
3037 ok(hres == S_FALSE, "IStream_Read returned %08x\n", hres);
3038 ok(!readed, "readed = %d\n", readed);
3040 IStream_Release(stream);
3044 static void test_BindToObject(int protocol, DWORD flags)
3048 LPOLESTR display_name;
3052 IUnknown *unk = (IUnknown*)0x00ff00ff;
3055 init_bind_test(protocol, BINDTEST_TOOBJECT|flags, TYMED_ISTREAM);
3057 if(emulate_protocol)
3058 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
3059 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
3061 SET_EXPECT(QueryInterface_IServiceProvider);
3062 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx);
3063 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3064 CHECK_CALLED(QueryInterface_IServiceProvider);
3068 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
3069 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
3071 IBindCtx_Release(bctx);
3075 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
3076 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
3078 IBinding_Release(bind);
3080 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
3081 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
3082 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
3083 CoTaskMemFree(display_name);
3085 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3086 SET_EXPECT(Obj_GetBindInfo);
3087 SET_EXPECT(QueryInterface_IInternetProtocol);
3088 if(!emulate_protocol)
3089 SET_EXPECT(QueryService_IInternetProtocol);
3090 SET_EXPECT(Obj_OnStartBinding);
3091 if(emulate_protocol) {
3092 if(is_urlmon_protocol(test_protocol))
3093 SET_EXPECT(SetPriority);
3095 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3096 SET_EXPECT(Terminate);
3097 if(test_protocol == FILE_TEST)
3098 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3099 SET_EXPECT(UnlockRequest);
3101 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3102 SET_EXPECT(QueryInterface_IHttpNegotiate);
3103 SET_EXPECT(BeginningTransaction);
3104 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3105 SET_EXPECT(GetRootSecurityId);
3107 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
3108 SET_EXPECT(Obj_OnProgress_CONNECTING);
3109 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3110 SET_EXPECT(QueryService_IWindowForBindingUI);
3111 SET_EXPECT(GetWindow_IWindowForBindingUI);
3113 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3114 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
3115 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3116 SET_EXPECT(QueryInterface_IHttpNegotiate);
3117 SET_EXPECT(OnResponse);
3119 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
3120 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
3121 if(test_protocol == FILE_TEST)
3122 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3123 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3124 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3125 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
3126 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
3127 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
3128 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
3129 SET_EXPECT(OnObjectAvailable);
3130 SET_EXPECT(Obj_OnStopBinding);
3133 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
3135 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3136 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
3138 skip( "Network unreachable, skipping tests\n" );
3142 /* no point testing the calls if binding didn't even work */
3143 if (FAILED(hres)) return;
3145 if(bindf & BINDF_ASYNCHRONOUS) {
3146 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
3147 ok(unk == NULL, "istr should be NULL\n");
3149 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3150 ok(unk != NULL, "unk == NULL\n");
3151 if(emulate_protocol)
3152 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
3155 IUnknown_Release(unk);
3157 while((bindf & BINDF_ASYNCHRONOUS) &&
3158 !((!emulate_protocol || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
3159 TranslateMessage(&msg);
3160 DispatchMessage(&msg);
3163 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
3164 CHECK_CALLED(Obj_GetBindInfo);
3165 CHECK_CALLED(QueryInterface_IInternetProtocol);
3166 if(!emulate_protocol)
3167 CHECK_CALLED(QueryService_IInternetProtocol);
3168 CHECK_CALLED(Obj_OnStartBinding);
3169 if(emulate_protocol) {
3170 if(is_urlmon_protocol(test_protocol))
3171 CHECK_CALLED(SetPriority);
3172 CHECK_CALLED(Start);
3173 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3174 CHECK_CALLED(Terminate);
3175 if(test_protocol == FILE_TEST)
3176 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
3177 CHECK_CALLED(UnlockRequest);
3179 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3180 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3181 CHECK_CALLED(BeginningTransaction);
3182 if (have_IHttpNegotiate2)
3184 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3185 CHECK_CALLED(GetRootSecurityId);
3188 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
3189 CHECK_CALLED(Obj_OnProgress_CONNECTING);
3191 /* IE7 does call this */
3192 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
3194 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3195 CLEAR_CALLED(QueryService_IWindowForBindingUI);
3196 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
3198 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
3199 if(urls[test_protocol] == winetest_post_urlW)
3200 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
3202 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
3204 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3205 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3206 CHECK_CALLED(OnResponse);
3208 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
3209 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
3210 if(test_protocol == FILE_TEST)
3211 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3212 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3213 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3214 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
3215 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
3216 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
3217 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
3218 CHECK_CALLED(OnObjectAvailable);
3219 CHECK_CALLED(Obj_OnStopBinding);
3222 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3223 if(test_protocol != HTTP_TEST || emulate_protocol || !(bindf & BINDF_ASYNCHRONOUS))
3224 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
3226 IBindCtx_Release(bctx);
3228 if(emulate_protocol)
3229 CoRevokeClassObject(regid);
3231 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3232 http_is_first = FALSE;
3235 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
3240 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
3242 SET_EXPECT(GetBindInfo);
3243 SET_EXPECT(QueryInterface_IInternetProtocol);
3244 if(!emulate_protocol) {
3245 SET_EXPECT(QueryInterface_IServiceProvider);
3246 SET_EXPECT(QueryService_IInternetProtocol);
3248 SET_EXPECT(OnStartBinding);
3249 if(emulate_protocol) {
3250 if(is_urlmon_protocol(test_protocol))
3251 SET_EXPECT(SetPriority);
3253 SET_EXPECT(UnlockRequest);
3255 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3256 SET_EXPECT(QueryInterface_IHttpNegotiate);
3257 SET_EXPECT(BeginningTransaction);
3258 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3259 SET_EXPECT(GetRootSecurityId);
3260 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3261 SET_EXPECT(OnProgress_CONNECTING);
3263 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3264 SET_EXPECT(OnProgress_SENDINGREQUEST);
3265 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3266 SET_EXPECT(QueryInterface_IHttpNegotiate);
3267 SET_EXPECT(OnResponse);
3269 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3270 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3271 if(test_protocol == FILE_TEST)
3272 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
3273 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3274 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3275 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3276 SET_EXPECT(OnStopBinding);
3279 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol],
3280 dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3281 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3283 CHECK_CALLED(GetBindInfo);
3284 CHECK_CALLED(QueryInterface_IInternetProtocol);
3285 if(!emulate_protocol) {
3286 CHECK_CALLED(QueryInterface_IServiceProvider);
3287 CHECK_CALLED(QueryService_IInternetProtocol);
3289 CHECK_CALLED(OnStartBinding);
3290 if(emulate_protocol) {
3291 if(is_urlmon_protocol(test_protocol))
3292 CHECK_CALLED(SetPriority);
3293 CHECK_CALLED(Start);
3294 CHECK_CALLED(UnlockRequest);
3296 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3297 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3298 CHECK_CALLED(BeginningTransaction);
3299 if (have_IHttpNegotiate2)
3301 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3302 CHECK_CALLED(GetRootSecurityId);
3304 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3305 CLEAR_CALLED(OnProgress_CONNECTING);
3307 if(test_protocol == FILE_TEST)
3308 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3309 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3310 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
3311 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3312 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3313 CHECK_CALLED(OnResponse);
3315 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3316 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3317 if(test_protocol == FILE_TEST)
3318 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
3319 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3320 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3321 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3322 CHECK_CALLED(OnStopBinding);
3325 res = DeleteFileA(dwl_htmlA);
3326 ok(res, "DeleteFile failed: %u\n", GetLastError());
3328 if(prot != FILE_TEST || emul)
3331 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
3332 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3334 res = DeleteFileA(dwl_htmlA);
3335 ok(res, "DeleteFile failed: %u\n", GetLastError());
3338 static void test_URLDownloadToFile_abort(void)
3342 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_PROGRESS, TYMED_FILE);
3344 SET_EXPECT(GetBindInfo);
3345 SET_EXPECT(QueryInterface_IInternetProtocol);
3346 SET_EXPECT(QueryInterface_IServiceProvider);
3347 SET_EXPECT(QueryService_IInternetProtocol);
3348 SET_EXPECT(OnStartBinding);
3349 SET_EXPECT(QueryInterface_IHttpNegotiate);
3350 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3351 SET_EXPECT(BeginningTransaction);
3352 SET_EXPECT(GetRootSecurityId);
3353 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3354 SET_EXPECT(OnProgress_CONNECTING);
3355 SET_EXPECT(OnProgress_SENDINGREQUEST);
3356 SET_EXPECT(OnStopBinding);
3358 hres = URLDownloadToFileW(NULL, urls[HTTP_TEST], dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3359 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres);
3361 CHECK_CALLED(GetBindInfo);
3362 CHECK_CALLED(QueryInterface_IInternetProtocol);
3363 CHECK_CALLED(QueryInterface_IServiceProvider);
3364 CHECK_CALLED(QueryService_IInternetProtocol);
3365 CHECK_CALLED(OnStartBinding);
3366 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3367 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3368 CHECK_CALLED(BeginningTransaction);
3369 CHECK_CALLED(GetRootSecurityId);
3370 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3371 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3372 CLEAR_CALLED(OnProgress_CONNECTING);
3373 CHECK_CALLED(OnStopBinding);
3375 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE);
3377 SET_EXPECT(GetBindInfo);
3378 SET_EXPECT(QueryInterface_IInternetProtocol);
3379 SET_EXPECT(QueryInterface_IServiceProvider);
3380 SET_EXPECT(QueryService_IInternetProtocol);
3381 SET_EXPECT(OnStartBinding);
3382 SET_EXPECT(OnStopBinding);
3384 abort_hres = E_ABORT;
3385 hres = URLDownloadToFileW(NULL, urls[HTTP_TEST], dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3386 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres);
3388 CHECK_CALLED(GetBindInfo);
3389 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
3390 todo_wine CHECK_CALLED(QueryInterface_IServiceProvider);
3391 todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
3392 CHECK_CALLED(OnStartBinding);
3393 CHECK_CALLED(OnStopBinding);
3395 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE);
3397 SET_EXPECT(GetBindInfo);
3398 SET_EXPECT(QueryInterface_IInternetProtocol);
3399 SET_EXPECT(QueryInterface_IServiceProvider);
3400 SET_EXPECT(QueryService_IInternetProtocol);
3401 SET_EXPECT(OnStartBinding);
3402 SET_EXPECT(QueryInterface_IHttpNegotiate);
3403 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3404 SET_EXPECT(BeginningTransaction);
3405 SET_EXPECT(GetRootSecurityId);
3406 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3407 SET_EXPECT(OnResponse);
3408 SET_EXPECT(OnProgress_CONNECTING);
3409 SET_EXPECT(OnProgress_SENDINGREQUEST);
3410 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3411 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3412 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3413 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3414 SET_EXPECT(OnStopBinding);
3416 /* URLDownloadToFile doesn't abort if E_NOTIMPL is returned from the
3417 * IBindStatusCallback's OnStartBinding function.
3419 abort_hres = E_NOTIMPL;
3420 hres = URLDownloadToFileW(NULL, urls[HTTP_TEST], dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
3421 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
3423 CHECK_CALLED(GetBindInfo);
3424 CHECK_CALLED(QueryInterface_IInternetProtocol);
3425 CHECK_CALLED(QueryInterface_IServiceProvider);
3426 CHECK_CALLED(QueryService_IInternetProtocol);
3427 CHECK_CALLED(OnStartBinding);
3428 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3429 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3430 CHECK_CALLED(BeginningTransaction);
3431 CHECK_CALLED(GetRootSecurityId);
3432 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3433 CHECK_CALLED(OnResponse);
3434 CLEAR_CALLED(OnProgress_CONNECTING);
3435 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3436 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3437 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3438 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
3439 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3440 CHECK_CALLED(OnStopBinding);
3442 DeleteFileA(dwl_htmlA);
3445 static void set_file_url(char *path)
3447 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
3448 CHAR INDEX_HTMLA[MAX_PATH];
3450 lstrcpyA(file_urlA, "file:///");
3451 lstrcatA(file_urlA, path);
3452 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
3454 lstrcpyA(INDEX_HTMLA, "file://");
3455 lstrcatA(INDEX_HTMLA, path);
3456 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
3459 static void create_file(void)
3463 CHAR path[MAX_PATH];
3465 static const char html_doc[] = "<HTML></HTML>";
3467 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3468 FILE_ATTRIBUTE_NORMAL, NULL);
3469 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3470 if(file == INVALID_HANDLE_VALUE)
3473 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
3476 GetCurrentDirectoryA(MAX_PATH, path);
3477 lstrcatA(path, "\\");
3478 lstrcatA(path, wszIndexHtmlA);
3482 static void create_cache_file(void)
3484 char buf[6500], curdir[MAX_PATH];
3488 file = CreateFileA(test_txtA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3489 FILE_ATTRIBUTE_NORMAL, NULL);
3490 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3491 if(file == INVALID_HANDLE_VALUE)
3494 memset(buf, 'X', sizeof(buf));
3495 WriteFile(file, buf, sizeof(buf), &size, NULL);
3498 memset(curdir, 0, sizeof(curdir));
3499 GetCurrentDirectoryA(MAX_PATH, curdir);
3500 lstrcatA(curdir, "\\");
3501 lstrcatA(curdir, test_txtA);
3503 MultiByteToWideChar(CP_ACP, 0, curdir, -1, cache_file_name, MAX_PATH);
3506 static void test_ReportResult(HRESULT exhres)
3508 IMoniker *mon = NULL;
3509 IBindCtx *bctx = NULL;
3510 IUnknown *unk = (void*)0xdeadbeef;
3513 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3514 binding_hres = exhres;
3516 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
3517 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3519 SET_EXPECT(QueryInterface_IServiceProvider);
3520 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
3521 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3522 CHECK_CALLED(QueryInterface_IServiceProvider);
3524 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3525 SET_EXPECT(GetBindInfo);
3526 SET_EXPECT(QueryInterface_IInternetProtocol);
3527 SET_EXPECT(OnStartBinding);
3528 if(is_urlmon_protocol(test_protocol))
3529 SET_EXPECT(SetPriority);
3532 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3533 if(SUCCEEDED(exhres))
3534 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
3536 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
3537 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
3539 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
3540 CHECK_CALLED(GetBindInfo);
3541 CHECK_CALLED(QueryInterface_IInternetProtocol);
3542 CHECK_CALLED(OnStartBinding);
3543 if(is_urlmon_protocol(test_protocol))
3544 CHECK_CALLED(SetPriority);
3545 CHECK_CALLED(Start);
3547 ok(unk == NULL, "unk=%p\n", unk);
3549 IBindCtx_Release(bctx);
3550 IMoniker_Release(mon);
3553 static void test_BindToStorage_fail(void)
3555 IMoniker *mon = NULL;
3556 IBindCtx *bctx = NULL;
3560 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
3561 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3565 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
3566 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
3568 unk = (void*)0xdeadbeef;
3569 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3570 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
3571 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
3572 ok(unk == NULL, "got %p\n", unk);
3574 IBindCtx_Release(bctx);
3576 IMoniker_Release(mon);
3578 test_ReportResult(E_NOTIMPL);
3579 test_ReportResult(S_FALSE);
3582 static void test_StdURLMoniker(void)
3584 IMoniker *mon, *async_mon;
3585 LPOLESTR display_name;
3590 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3591 &IID_IMoniker, (void**)&mon);
3592 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
3596 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
3597 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
3598 ok(mon == async_mon, "mon != async_mon\n");
3599 IMoniker_Release(async_mon);
3601 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
3602 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
3605 IUriContainer *uri_container;
3608 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
3609 ok(hres == S_OK, "Could not get IUriMoniker iface: %08x\n", hres);
3612 uri = (void*)0xdeadbeef;
3613 hres = IUriContainer_GetIUri(uri_container, &uri);
3614 ok(hres == S_FALSE, "GetIUri failed: %08x\n", hres);
3615 ok(!uri, "uri = %p, expected NULL\n", uri);
3617 IUriContainer_Release(uri_container);
3620 SET_EXPECT(QueryInterface_IServiceProvider);
3621 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
3622 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3623 CHECK_CALLED(QueryInterface_IServiceProvider);
3625 unk = (void*)0xdeadbeef;
3626 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3627 ok(hres == MK_E_SYNTAX, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres);
3628 ok(!unk, "unk = %p\n", unk);
3630 unk = (void*)0xdeadbeef;
3631 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
3632 ok(hres == MK_E_SYNTAX, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres);
3633 ok(!unk, "unk = %p\n", unk);
3635 IMoniker_Release(mon);
3638 static void register_protocols(void)
3640 IInternetSession *session;
3643 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
3645 hres = CoInternetGetSession(0, &session, 0);
3646 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3650 hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
3651 winetestW, 0, NULL, 0);
3652 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3654 IInternetSession_Release(session);
3661 hurlmon = GetModuleHandle("urlmon.dll");
3662 pCreateAsyncBindCtxEx = (void*) GetProcAddress(hurlmon, "CreateAsyncBindCtxEx");
3664 if(!GetProcAddress(hurlmon, "CompareSecurityIds")) {
3665 win_skip("Too old IE\n");
3669 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
3671 win_skip("IUri not supported\n");
3673 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
3674 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
3675 thread_id = GetCurrentThreadId();
3677 create_cache_file();
3678 register_protocols();
3682 trace("test CreateAsyncBindCtx...\n");
3683 test_CreateAsyncBindCtx();
3685 trace("test CreateAsyncBindCtxEx...\n");
3686 test_CreateAsyncBindCtxEx();
3688 trace("test RegisterBindStatusCallback...\n");
3689 if(test_RegisterBindStatusCallback()) {
3690 trace("test BindToStorage failures...\n");
3691 test_BindToStorage_fail();
3693 trace("synchronous http test (COM not initialised)...\n");
3694 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3698 trace("test StdURLMoniker...\n");
3699 test_StdURLMoniker();
3701 trace("synchronous http test...\n");
3702 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3704 trace("emulated synchronous http test (to file)...\n");
3705 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3707 trace("synchronous http test (to object)...\n");
3708 test_BindToObject(HTTP_TEST, 0);
3710 trace("emulated synchronous http test (with cache)...\n");
3711 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3713 trace("emulated synchronous http test (with cache, no read)...\n");
3714 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3716 trace("synchronous http test (with cache, no read)...\n");
3717 test_BindToStorage(HTTP_TEST, BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3719 trace("synchronous file test...\n");
3720 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3722 trace("emulated synchronous file test (to file)...\n");
3723 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3725 trace("synchronous file test (to object)...\n");
3726 test_BindToObject(FILE_TEST, 0);
3728 trace("file test (no callback)...\n");
3729 test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM);
3731 trace("synchronous https test (invalid CN, dialog)\n");
3732 onsecurityproblem_hres = S_FALSE;
3733 http_is_first = TRUE;
3734 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3736 trace("synchronous https test (invalid CN, fail)\n");
3737 onsecurityproblem_hres = E_FAIL;
3738 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3740 trace("synchronous https test (invalid CN, accept)\n");
3741 onsecurityproblem_hres = S_OK;
3742 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3744 trace("asynchronous https test (invalid CN, dialog 2)\n");
3745 onsecurityproblem_hres = S_FALSE;
3746 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3747 invalid_cn_accepted = FALSE;
3749 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
3751 trace("about test (no read)...\n");
3752 test_BindToStorage(ABOUT_TEST, BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3754 trace("http test...\n");
3755 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3757 trace("http test (to file)...\n");
3758 test_BindToStorage(HTTP_TEST, 0, TYMED_FILE);
3760 trace("http test (to object)...\n");
3761 test_BindToObject(HTTP_TEST, 0);
3763 trace("http test (short response)...\n");
3764 test_BindToStorage(HTTP_TEST, BINDTEST_HTTPRESPONSE, TYMED_ISTREAM);
3766 trace("http test (short response, to object)...\n");
3767 test_BindToObject(HTTP_TEST, 0);
3769 trace("http test (abort start binding E_NOTIMPL)...\n");
3770 abort_hres = E_NOTIMPL;
3771 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
3773 trace("http test (abort start binding E_ABORT)...\n");
3774 abort_hres = E_ABORT;
3775 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
3777 trace("http test (abort progress)...\n");
3778 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_PROGRESS, TYMED_FILE);
3780 trace("emulated http test...\n");
3781 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3783 trace("emulated http test (to object)...\n");
3784 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE);
3786 trace("emulated http test (to object, redirect)...\n");
3787 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT);
3789 trace("emulated http test (to file)...\n");
3790 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3792 trace("emulated http test (redirect)...\n");
3793 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, TYMED_ISTREAM);
3795 trace("emulated http test (with cache)...\n");
3796 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3798 trace("winetest test (no callback)...\n");
3799 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3801 trace("asynchronous https test...\n");
3802 http_is_first = TRUE;
3803 test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
3805 trace("emulated https test...\n");
3806 test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3808 trace("about test...\n");
3809 test_BindToStorage(ABOUT_TEST, 0, TYMED_ISTREAM);
3811 trace("about test (to file)...\n");
3812 test_BindToStorage(ABOUT_TEST, 0, TYMED_FILE);
3814 trace("about test (to object)...\n");
3815 test_BindToObject(ABOUT_TEST, 0);
3817 trace("emulated about test...\n");
3818 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3820 trace("emulated about test (to file)...\n");
3821 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE);
3823 trace("emulated about test (to object)...\n");
3824 test_BindToObject(ABOUT_TEST, BINDTEST_EMULATE);
3826 trace("file test...\n");
3827 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3829 trace("file test (to file)...\n");
3830 test_BindToStorage(FILE_TEST, 0, TYMED_FILE);
3832 trace("file test (to object)...\n");
3833 test_BindToObject(FILE_TEST, 0);
3835 trace("emulated file test...\n");
3836 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3838 trace("emulated file test (to file)...\n");
3839 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3841 trace("emulated file test (to object)...\n");
3842 test_BindToObject(FILE_TEST, BINDTEST_EMULATE);
3844 trace("emulated its test...\n");
3845 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3847 trace("emulated its test (to file)...\n");
3848 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_FILE);
3850 trace("emulated mk test...\n");
3851 test_BindToStorage(MK_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3853 trace("test URLDownloadToFile for file protocol...\n");
3854 test_URLDownloadToFile(FILE_TEST, FALSE);
3856 trace("test URLDownloadToFile for emulated file protocol...\n");
3857 test_URLDownloadToFile(FILE_TEST, TRUE);
3859 trace("test URLDownloadToFile for http protocol...\n");
3860 test_URLDownloadToFile(HTTP_TEST, FALSE);
3862 trace("test URLDownloadToFile abort...\n");
3863 test_URLDownloadToFile_abort();
3865 trace("test emulated http abort...\n");
3866 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_ABORT, TYMED_ISTREAM);
3868 bindf |= BINDF_NOWRITECACHE;
3870 trace("ftp test...\n");
3871 test_BindToStorage(FTP_TEST, 0, TYMED_ISTREAM);
3873 trace("test failures...\n");
3874 test_BindToStorage_fail();
3876 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE;
3877 only_check_prot_args = TRUE; /* Fail after checking arguments to Protocol_Start */
3879 trace("check emulated http protocol arguments...\n");
3880 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3883 DeleteFileA(wszIndexHtmlA);
3884 DeleteFileA(test_txtA);
3885 CloseHandle(complete_event);
3886 CloseHandle(complete_event2);