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 BOOL have_IHttpNegotiate2, use_bscex, is_async_prot;
202 static BOOL test_redirect, use_cache_file, callback_read, no_callback, test_abort;
203 static WCHAR cache_file_name[MAX_PATH];
204 static BOOL only_check_prot_args = FALSE;
205 static BOOL invalid_cn_accepted = FALSE;
206 static BOOL abort_start = FALSE;
207 static BOOL abort_progress = FALSE;
209 static LPCWSTR urls[] = {
220 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
239 static const char *debugstr_guid(REFIID riid)
243 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
244 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
245 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
246 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
251 static BOOL proxy_active(void)
253 HKEY internet_settings;
257 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
258 0, KEY_QUERY_VALUE, &internet_settings) != ERROR_SUCCESS)
261 size = sizeof(DWORD);
262 if (RegQueryValueExA(internet_settings, "ProxyEnable", NULL, NULL, (LPBYTE) &proxy_enable, &size) != ERROR_SUCCESS)
265 RegCloseKey(internet_settings);
267 return proxy_enable != 0;
270 static BOOL is_urlmon_protocol(int prot)
272 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
275 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
278 IMoniker *mon1 = NULL;
279 IMoniker *mon2 = NULL;
281 hr = CreateURLMoniker(NULL, NULL, NULL);
282 ok(hr == E_INVALIDARG,
283 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
285 mon1 = (IMoniker *)0xdeadbeef;
286 hr = CreateURLMoniker(NULL, NULL, &mon1);
287 ok(hr == E_INVALIDARG,
288 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
289 ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1);
291 hr = CreateURLMoniker(NULL, emptyW, NULL);
292 ok(hr == E_INVALIDARG,
293 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
295 hr = CreateURLMoniker(NULL, emptyW, &mon1);
297 broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */
298 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr);
299 if(mon1) IMoniker_Release(mon1);
301 hr = CreateURLMoniker(NULL, url1, &mon1);
302 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
304 hr = CreateURLMoniker(mon1, url2, &mon2);
305 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
307 if(mon1) IMoniker_Release(mon1);
308 if(mon2) IMoniker_Release(mon2);
311 static void test_create(void)
313 static const WCHAR relativeW[] = {'a','/','b','.','t','x','t',0};
319 test_CreateURLMoniker(winetest_data_urlW, TEST_PART_URL_1);
321 mon = (void*)0xdeadbeef;
322 hr = CreateURLMoniker(NULL, relativeW, &mon);
323 ok(hr == S_OK, "got 0x%08x\n", hr);
325 hr = CreateBindCtx(0, &bctx);
327 stream = (void*)0xdeadbeef;
328 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&stream);
329 todo_wine ok(hr == INET_E_UNKNOWN_PROTOCOL, "got 0x%08x\n", hr);
330 ok(stream == NULL, "got %p\n", stream);
332 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
333 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
335 stream = (void*)0xdeadbeef;
336 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
337 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
338 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
341 IMoniker_Release(mon);
343 mon = (void*)0xdaedbeef;
344 hr = CreateURLMoniker(NULL, winetest_data_urlW, &mon);
345 ok(hr == S_OK, "got 0x%08x\n", hr);
347 stream = (void*)0xdeadbeef;
348 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
349 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
350 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
353 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
354 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
356 IMoniker_Release(mon);
357 IBindCtx_Release(bctx);
360 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
362 ok(0, "unexpected call\n");
363 return E_NOINTERFACE;
366 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
371 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
376 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
378 CHECK_EXPECT(SetPriority);
379 ok(!nPriority, "nPriority = %d\n", nPriority);
383 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
385 ok(0, "unexpected call\n");
389 static const IInternetPriorityVtbl InternetPriorityVtbl = {
390 Priority_QueryInterface,
393 Priority_SetPriority,
397 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
399 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
403 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
408 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
409 if(!is_urlmon_protocol(test_protocol))
410 return E_NOINTERFACE;
412 *ppv = &InternetPriority;
416 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
417 return E_NOINTERFACE; /* TODO */
419 ok(0, "unexpected call %s\n", debugstr_guid(riid));
420 return E_NOINTERFACE;
423 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
428 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
433 static void test_switch_fail(void)
435 IInternetProtocolSink *binding_sink;
436 PROTOCOLDATA protocoldata;
439 static BOOL tested_switch_fail;
441 if(tested_switch_fail)
444 tested_switch_fail = TRUE;
446 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
447 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
448 if(SUCCEEDED(hres)) {
449 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
450 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
451 IInternetProtocolSink_Release(binding_sink);
455 static DWORD WINAPI thread_proc(PVOID arg)
457 PROTOCOLDATA protocoldata;
462 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
464 SET_EXPECT(OnProgress_FINDINGRESOURCE);
466 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
467 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
468 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
470 WaitForSingleObject(complete_event, INFINITE);
472 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
474 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
479 SET_EXPECT(Obj_OnProgress_CONNECTING);
481 SET_EXPECT(OnProgress_CONNECTING);
483 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
484 BINDSTATUS_CONNECTING, wszWineHQIP);
485 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
487 WaitForSingleObject(complete_event, INFINITE);
489 CHECK_CALLED(Obj_OnProgress_CONNECTING);
491 CHECK_CALLED(OnProgress_CONNECTING);
496 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
498 SET_EXPECT(OnProgress_SENDINGREQUEST);
500 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
501 BINDSTATUS_SENDINGREQUEST, NULL);
502 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
504 WaitForSingleObject(complete_event, INFINITE);
506 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
508 CHECK_CALLED(OnProgress_SENDINGREQUEST);
513 SET_EXPECT(Obj_OnProgress_REDIRECTING);
515 SET_EXPECT(OnProgress_REDIRECTING);
516 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_REDIRECTING, winetest_data_urlW);
517 ok(hres == S_OK, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres);
518 WaitForSingleObject(complete_event, INFINITE);
520 CHECK_CALLED(Obj_OnProgress_REDIRECTING);
522 CHECK_CALLED(OnProgress_REDIRECTING);
527 SET_EXPECT(Continue);
529 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
530 ok(hres == S_OK, "Switch failed: %08x\n", hres);
531 WaitForSingleObject(complete_event, INFINITE);
533 CHECK_CALLED(Continue);
536 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
537 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
538 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
539 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
540 CHECK_CALLED(CreateInstance);
541 CHECK_CALLED(PutProperty_MIMETYPEPROP);
542 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
544 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
545 CHECK_CALLED(OnObjectAvailable);
546 CHECK_CALLED(Obj_OnStopBinding);
547 }else if(!no_callback) {
548 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
549 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
550 CHECK_CALLED(OnDataAvailable);
552 CHECK_CALLED(LockRequest);
555 SET_EXPECT(Continue);
557 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
558 ok(hres == S_OK, "Switch failed: %08x\n", hres);
559 WaitForSingleObject(complete_event, INFINITE);
560 CHECK_CALLED(Continue);
562 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
563 CHECK_CALLED(OnStopBinding);
564 SetEvent(complete_event2);
569 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
570 CHECK_CALLED(OnDataAvailable);
574 SET_EXPECT(Continue);
576 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
577 ok(hres == S_OK, "Switch failed: %08x\n", hres);
578 WaitForSingleObject(complete_event, INFINITE);
579 CHECK_CALLED(Continue);
582 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
583 CHECK_CALLED(OnDataAvailable);
586 SET_EXPECT(Continue);
588 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
589 ok(hres == S_OK, "Switch failed: %08x\n", hres);
590 WaitForSingleObject(complete_event, INFINITE);
591 CHECK_CALLED(Continue);
594 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
595 CHECK_CALLED(OnDataAvailable);
596 CHECK_CALLED(OnStopBinding);
601 SetEvent(complete_event2);
605 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
606 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
607 DWORD grfPI, HANDLE_PTR dwReserved)
610 DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
613 static const STGMEDIUM stgmed_zero = {0};
614 static const SECURITY_ATTRIBUTES sa_zero = {0};
620 if(!filedwl_api) /* FIXME */
621 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", wine_dbgstr_w(szUrl));
622 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
623 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
624 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
625 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
627 if(!filedwl_api && binding_hres != S_OK) {
628 SET_EXPECT(OnStopBinding);
629 SET_EXPECT(Terminate);
630 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
631 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
632 CHECK_CALLED(OnStopBinding);
633 CHECK_CALLED(Terminate);
638 memset(&bindinfo, 0, sizeof(bindinfo));
639 bindinfo.cbSize = sizeof(bindinfo);
640 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
641 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
643 ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n");
645 if(filedwl_api || !is_urlmon_protocol(test_protocol) || tymed != TYMED_ISTREAM ||
646 !(bindf&BINDF_ASYNCSTORAGE) || !(bindf&BINDF_PULLDATA))
647 ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n");
649 ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n");
651 bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON);
652 if(filedwl_api || no_callback)
653 ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info);
655 ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n",
656 bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)));
658 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
659 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
660 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
661 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
662 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
663 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
664 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
665 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
666 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
667 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
668 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
669 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
670 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
671 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
673 if(only_check_prot_args)
676 switch(test_protocol) {
678 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
679 BINDSTATUS_DIRECTBIND, NULL);
681 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
686 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
688 SET_EXPECT(OnProgress_SENDINGREQUEST);
689 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
690 BINDSTATUS_SENDINGREQUEST, emptyW);
692 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
694 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
696 CHECK_CALLED(OnProgress_SENDINGREQUEST);
701 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
702 IServiceProvider *service_provider;
703 IHttpNegotiate *http_negotiate;
704 IHttpNegotiate2 *http_negotiate2;
705 IHttpSecurity *http_security;
706 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
707 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
709 DWORD fetched = 256, size = 100;
712 static const WCHAR wszMimes[] = {'*','/','*',0};
714 SET_EXPECT(QueryInterface_IInternetBindInfo);
715 SET_EXPECT(QueryService_IInternetBindInfo);
716 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
718 CLEAR_CALLED(QueryInterface_IInternetBindInfo); /* IE <8 */
719 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
721 ok(hres == E_NOINTERFACE,
722 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
723 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
724 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
726 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
727 accept_mimes, 256, &fetched);
729 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
730 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
731 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
732 CoTaskMemFree(accept_mimes[0]);
734 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
735 NULL, 256, &fetched);
736 ok(hres == E_INVALIDARG,
737 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
739 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
740 accept_mimes, 256, NULL);
741 ok(hres == E_INVALIDARG,
742 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
744 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
745 (void**)&service_provider);
746 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
748 SET_EXPECT(QueryInterface_IHttpNegotiate);
749 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
750 &IID_IHttpNegotiate, (void**)&http_negotiate);
751 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
752 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
755 SET_EXPECT(BeginningTransaction);
756 SET_EXPECT(QueryInterface_IHttpNegotiate);
758 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
759 NULL, 0, &additional_headers);
761 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
762 CHECK_CALLED(BeginningTransaction);
764 IHttpNegotiate_Release(http_negotiate);
765 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
766 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
768 SET_EXPECT(QueryInterface_IHttpNegotiate2);
769 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
770 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
771 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
772 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
776 SET_EXPECT(QueryInterface_IHttpNegotiate2);
777 SET_EXPECT(GetRootSecurityId);
779 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
781 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
782 CHECK_CALLED(GetRootSecurityId);
784 IHttpNegotiate2_Release(http_negotiate2);
785 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
786 ok(size == no_callback ? 512 : 13, "size=%d\n", size);
789 SET_EXPECT(QueryService_IHttpSecurity);
790 SET_EXPECT(QueryInterface_IHttpSecurity);
792 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpSecurity,
793 &IID_IHttpSecurity, (void**)&http_security);
794 ok(hres == (no_callback ? E_NOINTERFACE : S_OK), "QueryService failed: 0x%08x\n", hres);
796 CHECK_CALLED(QueryService_IHttpSecurity);
797 CHECK_CALLED(QueryInterface_IHttpSecurity);
800 IServiceProvider_Release(service_provider);
802 IInternetProtocolSink_AddRef(pOIProtSink);
803 protocol_sink = pOIProtSink;
804 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
809 if(test_protocol == FILE_TEST) {
810 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
811 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
813 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
816 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
818 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
819 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
820 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
822 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
824 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
826 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
828 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
829 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
831 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
834 if(test_protocol == ABOUT_TEST)
835 bscf |= BSCF_DATAFULLYAVAILABLE;
836 if(test_protocol == ITS_TEST)
837 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
841 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
842 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
843 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
844 if(test_protocol == FILE_TEST)
845 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
846 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
847 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
848 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
849 SET_EXPECT(CreateInstance);
850 SET_EXPECT(PutProperty_MIMETYPEPROP);
851 SET_EXPECT(PutProperty_CLASSIDPROP);
853 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
854 SET_EXPECT(OnObjectAvailable);
855 SET_EXPECT(Obj_OnStopBinding);
857 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
858 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
859 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
860 if(test_protocol == FILE_TEST)
861 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
862 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
863 SET_EXPECT(LockRequest);
865 SET_EXPECT(OnDataAvailable);
866 SET_EXPECT(OnStopBinding);
869 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
870 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
874 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
875 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
876 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
877 if(test_protocol == FILE_TEST)
878 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
879 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
880 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
881 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
882 CHECK_CALLED(CreateInstance);
883 CHECK_CALLED(PutProperty_MIMETYPEPROP);
884 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
886 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
887 CHECK_CALLED(OnObjectAvailable);
888 CHECK_CALLED(Obj_OnStopBinding);
890 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
891 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
892 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
893 if(test_protocol == FILE_TEST)
894 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
895 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
896 CHECK_CALLED(LockRequest);
898 CHECK_CALLED(OnDataAvailable);
899 CHECK_CALLED(OnStopBinding);
902 if(test_protocol == ITS_TEST) {
904 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
905 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
907 }else if(!bind_to_object && test_protocol == ABOUT_TEST) {
909 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
910 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
914 SET_EXPECT(Terminate);
915 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
916 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
917 CHECK_CALLED(Terminate);
922 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
923 PROTOCOLDATA *pProtocolData)
928 CHECK_EXPECT(Continue);
930 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
932 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
938 IServiceProvider *service_provider;
939 IHttpNegotiate *http_negotiate;
940 static WCHAR header[] = {'?',0};
942 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
943 (void**)&service_provider);
944 ok(hres == S_OK, "Could not get IServiceProvicder\n");
946 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
947 &IID_IHttpNegotiate, (void**)&http_negotiate);
948 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
951 SET_EXPECT(QueryInterface_IHttpNegotiate);
952 SET_EXPECT(OnResponse);
954 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
956 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
957 CHECK_CALLED(OnResponse);
959 IHttpNegotiate_Release(http_negotiate);
960 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
962 if(test_protocol == HTTPS_TEST || test_redirect) {
963 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
964 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
967 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
968 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
970 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
972 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
973 BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW);
974 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
976 bscf |= BSCF_FIRSTDATANOTIFICATION;
981 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
985 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
986 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
988 if(prot_state != 2 || !test_abort)
993 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
994 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
995 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
996 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
997 SET_EXPECT(CreateInstance);
998 SET_EXPECT(PutProperty_MIMETYPEPROP);
999 SET_EXPECT(PutProperty_CLASSIDPROP);
1001 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1002 SET_EXPECT(OnObjectAvailable);
1003 SET_EXPECT(Obj_OnStopBinding);
1004 }else if(!no_callback) {
1005 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1006 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1007 SET_EXPECT(LockRequest);
1009 SET_EXPECT(LockRequest);
1014 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1017 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1018 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1021 if((!bind_to_object || prot_state >= 2) && (!test_abort || prot_state != 2))
1022 SET_EXPECT(OnDataAvailable);
1023 if(prot_state == 3 || (test_abort && prot_state == 2))
1024 SET_EXPECT(OnStopBinding);
1029 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
1034 CHECK_EXPECT(Abort);
1036 ok(hrReason == E_ABORT, "hrReason = %08x\n", hrReason);
1037 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
1039 hres = IInternetProtocolSink_ReportResult(protocol_sink, E_ABORT, ERROR_SUCCESS, NULL);
1040 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1045 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
1047 CHECK_EXPECT(Terminate);
1049 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
1052 IInternetProtocolSink_Release(protocol_sink);
1053 protocol_sink = NULL;
1057 SetEvent(complete_event);
1061 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
1063 ok(0, "unexpected call\n");
1067 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
1069 ok(0, "unexpected call\n");
1073 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
1074 ULONG cb, ULONG *pcbRead)
1076 static const char data[] = "<HTML></HTML>";
1078 CHECK_EXPECT2(Read);
1080 ok(pv != NULL, "pv == NULL\n");
1081 ok(cb != 0, "cb == 0\n");
1082 ok(pcbRead != NULL, "pcbRead == NULL\n");
1084 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
1087 static int pending = TRUE;
1091 switch(prot_state) {
1096 memset(pv, '?', 10);
1097 if(prot_state == 2 && no_callback)
1098 SetEvent(complete_event);
1101 memset(pv, '?', cb);
1111 hres = IInternetProtocolSink_ReportData(protocol_sink,
1112 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
1113 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1115 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1116 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1130 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
1131 read += *pcbRead = sizeof(data)-1;
1132 memcpy(pv, data, sizeof(data));
1136 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
1137 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1139 ok(0, "unexpected call\n");
1143 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
1145 CHECK_EXPECT(LockRequest);
1147 SetEvent(complete_event);
1151 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
1153 CHECK_EXPECT(UnlockRequest);
1157 static const IInternetProtocolVtbl ProtocolVtbl = {
1158 Protocol_QueryInterface,
1169 Protocol_LockRequest,
1170 Protocol_UnlockRequest
1173 static IInternetProtocol Protocol = { &ProtocolVtbl };
1175 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
1177 if(IsEqualGUID(&IID_IUnknown, riid)
1178 || IsEqualGUID(&IID_IHttpNegotiate, riid)
1179 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1184 ok(0, "unexpected call\n");
1185 return E_NOINTERFACE;
1188 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
1193 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
1198 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
1199 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1201 if(onsecurityproblem_hres == S_OK)
1202 CHECK_EXPECT2(BeginningTransaction);
1204 CHECK_EXPECT(BeginningTransaction);
1206 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1208 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
1209 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1210 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1211 if(pszAdditionalHeaders)
1212 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1217 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1218 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1220 CHECK_EXPECT(OnResponse);
1222 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1224 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1225 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1226 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1227 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1228 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1229 if(pszAdditionalRequestHeaders)
1230 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1235 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1236 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1238 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1240 CHECK_EXPECT(GetRootSecurityId);
1242 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1244 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1245 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1246 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1248 if(pbSecurityId == (void*)0xdeadbeef)
1252 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1253 *pcbSecurityId = sizeof(sec_id);
1257 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1262 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1263 HttpNegotiate_QueryInterface,
1264 HttpNegotiate_AddRef,
1265 HttpNegotiate_Release,
1266 HttpNegotiate_BeginningTransaction,
1267 HttpNegotiate_OnResponse,
1268 HttpNegotiate_GetRootSecurityId
1271 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1273 static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv)
1275 ok(0, "Unexpected call\n");
1277 if(IsEqualGUID(&IID_IHttpSecurity, riid) ||
1278 IsEqualGUID(&IID_IWindowForBindingUI, riid) ||
1279 IsEqualGUID(&IID_IUnknown, riid))
1285 ok(0, "Unexpected interface requested.\n");
1287 return E_NOINTERFACE;
1290 static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface)
1295 static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface)
1300 static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity *iface, REFGUID rguidReason, HWND *phwnd)
1302 if(IsEqualGUID(rguidReason, &IID_IHttpSecurity))
1303 CHECK_EXPECT(GetWindow_IHttpSecurity);
1304 else if(IsEqualGUID(rguidReason, &IID_IWindowForBindingUI))
1305 CHECK_EXPECT2(GetWindow_IWindowForBindingUI);
1307 ok(0, "Unexpected rguidReason: %s\n", debugstr_guid(rguidReason));
1313 static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem)
1315 CHECK_EXPECT(OnSecurityProblem);
1316 if(!security_problem) {
1317 ok(dwProblem == ERROR_INTERNET_SEC_CERT_CN_INVALID ||
1318 broken(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) /* Some versions of IE6 */,
1319 "Got problem: %d\n", dwProblem);
1320 security_problem = dwProblem;
1322 if(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS)
1323 binding_hres = INET_E_SECURITY_PROBLEM;
1325 ok(dwProblem == security_problem, "Got problem: %d\n", dwProblem);
1327 return onsecurityproblem_hres;
1330 static const IHttpSecurityVtbl HttpSecurityVtbl = {
1331 HttpSecurity_QueryInterface,
1332 HttpSecurity_AddRef,
1333 HttpSecurity_Release,
1334 HttpSecurity_GetWindow,
1335 HttpSecurity_OnSecurityProblem
1338 static IHttpSecurity HttpSecurity = { &HttpSecurityVtbl };
1340 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1342 ok(0, "unexpected call\n");
1343 return E_NOINTERFACE;
1346 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1351 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1356 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1357 REFGUID guidService, REFIID riid, void **ppv)
1359 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1360 CHECK_EXPECT(QueryService_IAuthenticate);
1364 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1365 CHECK_EXPECT2(QueryService_IInternetProtocol);
1369 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1370 CHECK_EXPECT(QueryService_IInternetBindInfo);
1374 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1375 CHECK_EXPECT2(QueryService_IWindowForBindingUI);
1376 *ppv = &HttpSecurity;
1380 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
1381 CHECK_EXPECT(QueryService_IHttpSecurity);
1382 *ppv = &HttpSecurity;
1386 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1387 return E_NOINTERFACE;
1390 static IServiceProviderVtbl ServiceProviderVtbl = {
1391 ServiceProvider_QueryInterface,
1392 ServiceProvider_AddRef,
1393 ServiceProvider_Release,
1394 ServiceProvider_QueryService
1397 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1399 static IBindStatusCallbackEx objbsc;
1401 static void test_WinInetHttpInfo(IWinInetHttpInfo *http_info, DWORD progress)
1404 HRESULT hres, expect;
1406 /* QueryInfo changes it's behavior during this request */
1407 if(progress == BINDSTATUS_SENDINGREQUEST)
1410 if(test_protocol==FTP_TEST && download_state==BEFORE_DOWNLOAD
1411 && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1413 else if(test_protocol == FTP_TEST)
1418 size = sizeof(DWORD);
1419 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
1420 &status, &size, NULL, NULL);
1421 ok(hres == expect, "hres = %x, expected %x\n", hres, expect);
1423 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1424 ok(status == 0, "status = %d\n", status);
1426 ok(status == HTTP_STATUS_OK, "status = %d\n", status);
1427 ok(size == sizeof(DWORD), "size = %d\n", size);
1430 size = sizeof(DWORD);
1431 hres = IWinInetHttpInfo_QueryOption(http_info, INTERNET_OPTION_HANDLE_TYPE, &status, &size);
1432 if(test_protocol == FTP_TEST) {
1433 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1434 ok(hres == E_FAIL, "hres = %x\n", hres);
1436 ok(hres == S_OK, "hres = %x\n", hres);
1439 ok(status == INTERNET_HANDLE_TYPE_FTP_FILE, "status = %d\n", status);
1441 ok(hres == S_OK, "hres = %x\n", hres);
1442 ok(status == INTERNET_HANDLE_TYPE_HTTP_REQUEST, "status = %d\n", status);
1446 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1448 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1450 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1451 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1452 if(emulate_protocol) {
1456 return E_NOINTERFACE;
1459 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1461 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1462 *ppv = &ServiceProvider;
1465 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1467 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1468 *ppv = &HttpNegotiate;
1471 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1473 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1474 *ppv = &HttpNegotiate;
1477 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1479 CHECK_EXPECT(QueryInterface_IAuthenticate);
1480 return E_NOINTERFACE;
1482 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1484 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1488 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1490 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1491 return E_NOINTERFACE;
1493 else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid))
1495 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1497 return E_NOINTERFACE;
1501 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1504 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1506 else if(IsEqualGUID(&IID_IWindowForBindingUI, riid))
1508 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1509 return E_NOINTERFACE;
1511 else if(IsEqualGUID(&IID_IHttpSecurity, riid))
1513 CHECK_EXPECT2(QueryInterface_IHttpSecurity);
1514 return E_NOINTERFACE;
1518 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1521 return E_NOINTERFACE;
1524 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1529 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1534 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1537 IWinInetHttpInfo *http_info;
1541 if(iface == &objbsc)
1542 CHECK_EXPECT(Obj_OnStartBinding);
1544 CHECK_EXPECT(OnStartBinding);
1546 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1548 ok(pib != NULL, "pib should not be NULL\n");
1549 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1551 if(pib == (void*)0xdeadbeef)
1554 current_binding = pib;
1556 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1557 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1559 IMoniker_Release(mon);
1561 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1562 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1565 binding_hres = E_ABORT;
1572 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1574 ok(0, "unexpected call\n");
1578 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1580 ok(0, "unexpected call\n");
1584 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1585 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1587 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1589 switch(ulStatusCode) {
1590 case BINDSTATUS_FINDINGRESOURCE:
1591 if(iface == &objbsc)
1592 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1593 else if(test_protocol == FTP_TEST)
1594 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1595 else if(onsecurityproblem_hres == S_OK)
1596 CHECK_EXPECT2(OnProgress_FINDINGRESOURCE); /* todo wine */
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);
1639 case BINDSTATUS_MIMETYPEAVAILABLE:
1640 if(iface == &objbsc)
1641 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1643 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1645 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1647 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1649 case BINDSTATUS_BEGINDOWNLOADDATA:
1650 if(iface == &objbsc)
1651 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1653 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1654 ok(szStatusText != NULL, "szStatusText == NULL\n");
1659 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1663 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1665 download_state = DOWNLOADING;
1667 case BINDSTATUS_DOWNLOADINGDATA:
1668 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1669 ok(iface != &objbsc, "unexpected call\n");
1670 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1676 hres = IBinding_Abort(current_binding);
1677 ok(hres == S_OK, "Abort failed: %08x\n", hres);
1678 CHECK_CALLED(Abort);
1680 hres = IBinding_Abort(current_binding);
1681 ok(hres == E_FAIL, "Abort failed: %08x\n", hres);
1683 binding_hres = E_ABORT;
1686 case BINDSTATUS_ENDDOWNLOADDATA:
1687 if(iface == &objbsc)
1688 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1690 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1691 ok(szStatusText != NULL, "szStatusText == NULL\n");
1696 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1699 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1701 download_state = END_DOWNLOAD;
1703 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1704 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST && test_protocol != WINETEST_TEST) {
1705 if(iface == &objbsc)
1706 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1708 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1710 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1711 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1714 ok(szStatusText != NULL, "szStatusText == NULL\n");
1715 if(szStatusText && test_protocol == FILE_TEST)
1716 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1718 case BINDSTATUS_CLASSIDAVAILABLE:
1722 if(iface != &objbsc)
1723 ok(0, "unexpected call\n");
1724 else if(1||emulate_protocol)
1725 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1727 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1728 hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid);
1729 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1730 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1731 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1734 case BINDSTATUS_BEGINSYNCOPERATION:
1735 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1736 if(iface != &objbsc)
1737 ok(0, "unexpected call\n");
1738 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1740 case BINDSTATUS_ENDSYNCOPERATION:
1741 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1742 if(iface != &objbsc)
1743 ok(0, "unexpected call\n");
1744 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1746 case BINDSTATUS_PROXYDETECTING:
1747 trace("BINDSTATUS_PROXYDETECTING\n");
1749 case BINDSTATUS_COOKIE_SENT:
1750 trace("BINDSTATUS_COOKIE_SENT\n");
1753 ok(0, "unexpected code %d\n", ulStatusCode);
1756 if(current_binding) {
1757 IWinInetHttpInfo *http_info;
1760 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1761 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol)) {
1762 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1763 test_WinInetHttpInfo(http_info, ulStatusCode);
1765 ok(hres == E_NOINTERFACE,
1766 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1768 IWinInetHttpInfo_Release(http_info);
1774 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1776 if(iface == &objbsc) {
1777 CHECK_EXPECT(Obj_OnStopBinding);
1778 stopped_obj_binding = TRUE;
1780 CHECK_EXPECT(OnStopBinding);
1781 stopped_binding = TRUE;
1784 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1786 if(only_check_prot_args) {
1787 todo_wine ok(hresult == S_OK, "Got %08x\n", hresult);
1791 /* ignore DNS failure */
1792 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1796 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1797 else if(invalid_cn_accepted)
1798 todo_wine ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1800 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1801 ok(szError == NULL, "szError should be NULL\n");
1803 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) && emulate_protocol) {
1804 SetEvent(complete_event);
1805 if(iface != &objbsc)
1806 WaitForSingleObject(complete_event2, INFINITE);
1812 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1816 if(iface == &objbsc)
1817 CHECK_EXPECT(Obj_GetBindInfo);
1819 CHECK_EXPECT(GetBindInfo);
1821 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1824 cbSize = pbindinfo->cbSize;
1825 memset(pbindinfo, 0, cbSize);
1826 pbindinfo->cbSize = cbSize;
1831 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1832 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1839 if(iface == &objbsc)
1840 ok(0, "unexpected call\n");
1842 CHECK_EXPECT2(OnDataAvailable);
1844 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1846 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1847 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1849 data_available = TRUE;
1851 if(bind_to_object && !is_async_prot)
1852 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), "grfBSCF = %x\n", grfBSCF);
1854 ok(pformatetc != NULL, "pformatetx == NULL\n");
1859 ret = GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1);
1860 ok(ret, "GetClipboardFormatName failed, error %d\n", GetLastError());
1861 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1862 pformatetc->cfFormat, clipfmt, mime_type);
1864 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1866 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1867 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1868 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1869 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1872 ok(pstgmed != NULL, "stgmeg == NULL\n");
1873 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1874 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1876 switch(pstgmed->tymed) {
1878 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1881 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1882 ok(hres == STG_E_ACCESSDENIED,
1883 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1885 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1886 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1888 hres = IStream_Revert(U(*pstgmed).pstm);
1889 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1891 hres = IStream_Stat(U(*pstgmed).pstm, NULL, STATFLAG_NONAME);
1892 ok(hres == E_FAIL, "hres = %x\n", hres);
1893 if(use_cache_file && emulate_protocol) {
1894 hres = IStream_Stat(U(*pstgmed).pstm, &stat, STATFLAG_DEFAULT);
1895 ok(hres == S_OK, "hres = %x\n", hres);
1896 ok(!lstrcmpW(stat.pwcsName, cache_file_name),
1897 "stat.pwcsName = %s, cache_file_name = %s\n",
1898 wine_dbgstr_w(stat.pwcsName), wine_dbgstr_w(cache_file_name));
1899 CoTaskMemFree(stat.pwcsName);
1900 ok(U(stat.cbSize).LowPart == (bindf&BINDF_ASYNCHRONOUS?0:6500),
1901 "stat.cbSize.LowPart = %u\n", U(stat.cbSize).LowPart);
1903 hres = IStream_Stat(U(*pstgmed).pstm, &stat, STATFLAG_NONAME);
1904 ok(hres == S_OK, "hres = %x\n", hres);
1905 ok(!stat.pwcsName || broken(stat.pwcsName!=NULL),
1906 "stat.pwcsName = %s\n", wine_dbgstr_w(stat.pwcsName));
1908 ok(stat.type == STGTY_STREAM, "stat.type = %x\n", stat.type);
1909 ok(U(stat.cbSize).HighPart == 0, "stat.cbSize.HighPart != 0\n");
1910 ok(stat.grfMode == (U(stat.cbSize).LowPart?GENERIC_READ:0), "stat.grfMode = %x\n", stat.grfMode);
1911 ok(stat.grfLocksSupported == 0, "stat.grfLocksSupported = %x\n", stat.grfLocksSupported);
1912 ok(stat.grfStateBits == 0, "stat.grfStateBits = %x\n", stat.grfStateBits);
1913 ok(stat.reserved == 0, "stat.reserved = %x\n", stat.reserved);
1916 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1919 hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1920 if(test_protocol == HTTP_TEST && emulate_protocol && readed)
1921 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
1922 }while(hres == S_OK);
1923 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1928 if(test_protocol == FILE_TEST)
1929 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1930 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1931 else if(emulate_protocol)
1932 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1933 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1935 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1938 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
1939 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1940 SetEvent(complete_event);
1945 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
1947 CHECK_EXPECT(OnObjectAvailable);
1949 if(iface != &objbsc)
1950 ok(0, "unexpected call\n");
1952 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1953 ok(punk != NULL, "punk == NULL\n");
1958 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
1959 DWORD *grfBINDF2, DWORD *pdwReserved)
1961 CHECK_EXPECT(GetBindInfoEx);
1963 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1964 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
1965 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1966 ok(pdwReserved != NULL, "dwReserved == NULL\n");
1971 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
1972 statusclb_QueryInterface,
1975 statusclb_OnStartBinding,
1976 statusclb_GetPriority,
1977 statusclb_OnLowResource,
1978 statusclb_OnProgress,
1979 statusclb_OnStopBinding,
1980 statusclb_GetBindInfo,
1981 statusclb_OnDataAvailable,
1982 statusclb_OnObjectAvailable,
1983 statusclb_GetBindInfoEx
1986 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
1987 static IBindStatusCallbackEx bsc2 = { &BindStatusCallbackVtbl };
1988 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
1990 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1993 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1994 return E_NOINTERFACE;
1997 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
2002 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
2007 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
2011 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
2012 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
2015 CHECK_EXPECT(PutProperty_CLASSIDPROP);
2024 static const IMonikerPropVtbl MonikerPropVtbl = {
2025 MonikerProp_QueryInterface,
2027 MonikerProp_Release,
2028 MonikerProp_PutProperty
2031 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
2033 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
2037 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
2039 else if(IsEqualGUID(&IID_IMonikerProp, riid))
2040 *ppv = &MonikerProp;
2045 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2046 return E_NOINTERFACE;
2049 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
2054 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
2059 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
2061 ok(0, "unexpected call\n");
2065 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
2067 ok(0, "unexpected call\n");
2071 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
2072 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
2077 static WCHAR cbinding_contextW[] =
2078 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
2081 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
2083 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2084 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
2086 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
2087 ok(pimkName != NULL, "pimkName == NULL\n");
2088 ok(pibc != NULL, "pibc == NULL\n");
2089 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
2091 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
2092 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
2093 if(SUCCEEDED(hres)) {
2096 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
2097 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
2099 IBinding_Release(binding);
2100 IUnknown_Release(unk);
2103 SET_EXPECT(QueryInterface_IServiceProvider);
2104 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
2105 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2106 CHECK_CALLED(QueryInterface_IServiceProvider);
2108 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2109 SET_EXPECT(GetBindInfo);
2110 SET_EXPECT(OnStartBinding);
2112 SET_EXPECT(OnProgress_REDIRECTING);
2113 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2114 if(test_protocol == FILE_TEST)
2115 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2116 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2117 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2118 SET_EXPECT(LockRequest);
2119 SET_EXPECT(OnDataAvailable);
2120 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2121 SET_EXPECT(OnStopBinding);
2123 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
2124 ok(hres == S_OK, "Load failed: %08x\n", hres);
2126 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2127 CHECK_CALLED(GetBindInfo);
2128 CHECK_CALLED(OnStartBinding);
2130 CHECK_CALLED(OnProgress_REDIRECTING);
2131 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2132 if(test_protocol == FILE_TEST)
2133 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2134 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2135 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2136 CHECK_CALLED(LockRequest);
2137 CHECK_CALLED(OnDataAvailable);
2138 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
2139 CHECK_CALLED(OnStopBinding);
2142 IUnknown_Release(unk);
2147 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
2149 ok(0, "unexpected call\n");
2153 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
2155 ok(0, "unexpected call\n");
2159 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
2161 ok(0, "unexpected call\n");
2165 static const IPersistMonikerVtbl PersistMonikerVtbl = {
2166 PersistMoniker_QueryInterface,
2167 PersistMoniker_AddRef,
2168 PersistMoniker_Release,
2169 PersistMoniker_GetClassID,
2170 PersistMoniker_IsDirty,
2171 PersistMoniker_Load,
2172 PersistMoniker_Save,
2173 PersistMoniker_SaveCompleted,
2174 PersistMoniker_GetCurMoniker
2177 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
2179 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2183 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2188 if(IsEqualGUID(&IID_IMarshal, riid))
2189 return E_NOINTERFACE;
2190 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
2191 return E_NOINTERFACE;
2193 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2197 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2202 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2207 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2209 CHECK_EXPECT(CreateInstance);
2210 ok(!outer, "outer = %p\n", outer);
2211 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2212 *ppv = &PersistMoniker;
2216 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
2218 ok(0, "unexpected call\n");
2222 static const IClassFactoryVtbl ClassFactoryVtbl = {
2223 ClassFactory_QueryInterface,
2224 ClassFactory_AddRef,
2225 ClassFactory_Release,
2226 ClassFactory_CreateInstance,
2227 ClassFactory_LockServer
2230 static IClassFactory mime_cf = { &ClassFactoryVtbl };
2232 static HRESULT WINAPI ProtocolCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2236 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
2241 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2242 return E_NOINTERFACE;
2244 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
2248 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2250 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2251 return E_NOINTERFACE;
2253 todo_wine ok(outer != NULL, "outer == NULL\n");
2254 todo_wine ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2259 static const IClassFactoryVtbl ProtocolCFVtbl = {
2260 ProtocolCF_QueryInterface,
2261 ClassFactory_AddRef,
2262 ClassFactory_Release,
2263 ProtocolCF_CreateInstance,
2264 ClassFactory_LockServer
2267 static IClassFactory protocol_cf = { &ProtocolCFVtbl };
2269 static void test_CreateAsyncBindCtx(void)
2271 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
2277 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
2278 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2279 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
2281 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
2282 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2284 SET_EXPECT(QueryInterface_IServiceProvider);
2285 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2286 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
2287 CHECK_CALLED(QueryInterface_IServiceProvider);
2289 bindopts.cbStruct = sizeof(bindopts);
2290 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2291 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2292 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2293 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2294 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2295 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2297 ok(bindopts.dwTickCountDeadline == 0,
2298 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2300 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2301 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
2303 IUnknown_Release(unk);
2305 ref = IBindCtx_Release(bctx);
2306 ok(ref == 0, "bctx should be destroyed here\n");
2309 static void test_CreateAsyncBindCtxEx(void)
2311 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
2316 static WCHAR testW[] = {'t','e','s','t',0};
2318 if (!pCreateAsyncBindCtxEx) {
2319 win_skip("CreateAsyncBindCtxEx not present\n");
2323 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
2324 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
2326 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2327 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2329 if(SUCCEEDED(hres)) {
2330 bindopts.cbStruct = sizeof(bindopts);
2331 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2332 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2333 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2334 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2335 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2336 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2338 ok(bindopts.dwTickCountDeadline == 0,
2339 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2341 IBindCtx_Release(bctx);
2344 CreateBindCtx(0, &bctx_arg);
2345 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2346 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2348 if(SUCCEEDED(hres)) {
2349 bindopts.cbStruct = sizeof(bindopts);
2350 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2351 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2352 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2353 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2354 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2355 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2357 ok(bindopts.dwTickCountDeadline == 0,
2358 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2360 IBindCtx_Release(bctx);
2363 IBindCtx_Release(bctx_arg);
2365 SET_EXPECT(QueryInterface_IServiceProvider);
2366 hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
2367 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2368 CHECK_CALLED(QueryInterface_IServiceProvider);
2370 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2371 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
2373 IUnknown_Release(unk);
2375 IBindCtx_Release(bctx);
2377 hres = CreateBindCtx(0, &bctx2);
2378 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2380 hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
2381 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2383 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
2384 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2386 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
2387 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2388 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
2390 IBindCtx_Release(bctx);
2391 IBindCtx_Release(bctx2);
2394 static void test_GetBindInfoEx(IBindStatusCallback *holder)
2396 IBindStatusCallbackEx *bscex;
2397 BINDINFO bindinfo = {sizeof(bindinfo)};
2398 DWORD bindf, bindf2, dw;
2401 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
2403 win_skip("IBindStatusCallbackEx not supported\n");
2410 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2411 SET_EXPECT(GetBindInfoEx);
2412 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
2413 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2414 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2415 CHECK_CALLED(GetBindInfoEx);
2417 bindf = bindf2 = dw = 0;
2418 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2419 SET_EXPECT(GetBindInfoEx);
2420 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2421 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2422 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2423 CHECK_CALLED(GetBindInfoEx);
2427 bindf = bindf2 = dw = 0xdeadbeef;
2428 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2429 SET_EXPECT(GetBindInfo);
2430 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2431 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2432 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2433 CHECK_CALLED(GetBindInfo);
2434 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
2435 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
2437 IBindStatusCallbackEx_Release(bscex);
2440 static BOOL test_bscholder(IBindStatusCallback *holder)
2442 IServiceProvider *serv_prov;
2443 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
2444 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
2445 IAuthenticate *authenticate, *authenticate_serv;
2446 IInternetProtocol *protocol;
2447 BINDINFO bindinfo = {sizeof(bindinfo)};
2453 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2454 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2457 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2458 SET_EXPECT(GetBindInfo);
2459 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2460 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2461 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2462 CHECK_CALLED(GetBindInfo);
2464 test_GetBindInfoEx(holder);
2466 SET_EXPECT(OnStartBinding);
2467 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2468 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2469 CHECK_CALLED(OnStartBinding);
2471 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2472 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2474 SET_EXPECT(QueryInterface_IHttpNegotiate);
2475 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2476 (void**)&http_negotiate_serv);
2477 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2478 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2480 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2482 wstr = (void*)0xdeadbeef;
2483 SET_EXPECT(QueryInterface_IHttpNegotiate);
2484 SET_EXPECT(BeginningTransaction);
2485 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
2486 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2487 CHECK_CALLED(BeginningTransaction);
2488 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2489 ok(wstr == NULL, "wstr = %p\n", wstr);
2491 IHttpNegotiate_Release(http_negotiate_serv);
2493 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2494 (void**)&http_negotiate_serv);
2495 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2496 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2497 IHttpNegotiate_Release(http_negotiate_serv);
2499 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2500 if(SUCCEEDED(hres)) {
2501 have_IHttpNegotiate2 = TRUE;
2503 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2504 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2505 (void**)&http_negotiate2_serv);
2506 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2507 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2508 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2510 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2511 SET_EXPECT(GetRootSecurityId);
2512 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2513 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2514 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2515 CHECK_CALLED(GetRootSecurityId);
2517 IHttpNegotiate_Release(http_negotiate2_serv);
2518 IHttpNegotiate_Release(http_negotiate2);
2520 skip("Could not get IHttpNegotiate2\n");
2524 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2525 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2526 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2527 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2529 SET_EXPECT(QueryInterface_IHttpNegotiate);
2530 SET_EXPECT(OnResponse);
2531 wstr = (void*)0xdeadbeef;
2532 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2533 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2534 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2535 CHECK_CALLED(OnResponse);
2537 IHttpNegotiate_Release(http_negotiate);
2539 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2540 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2542 SET_EXPECT(QueryInterface_IAuthenticate);
2543 SET_EXPECT(QueryService_IAuthenticate);
2544 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2545 (void**)&authenticate_serv);
2546 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2547 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2548 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2549 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2550 IAuthenticate_Release(authenticate_serv);
2552 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2553 (void**)&authenticate_serv);
2554 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2555 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2557 IAuthenticate_Release(authenticate);
2558 IAuthenticate_Release(authenticate_serv);
2560 SET_EXPECT(OnStopBinding);
2561 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2562 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2563 CHECK_CALLED(OnStopBinding);
2565 SET_EXPECT(QueryInterface_IInternetProtocol);
2566 SET_EXPECT(QueryService_IInternetProtocol);
2567 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2569 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2570 CHECK_CALLED(QueryInterface_IInternetProtocol);
2571 CHECK_CALLED(QueryService_IInternetProtocol);
2573 IServiceProvider_Release(serv_prov);
2577 static BOOL test_RegisterBindStatusCallback(void)
2579 IBindStatusCallback *prevbsc, *clb, *prev_clb;
2585 hres = CreateBindCtx(0, &bindctx);
2586 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2588 SET_EXPECT(QueryInterface_IServiceProvider);
2590 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2591 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2593 SET_EXPECT(QueryInterface_IBindStatusCallback);
2594 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2595 prevbsc = (void*)0xdeadbeef;
2596 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2597 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2598 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2599 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2600 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2602 CHECK_CALLED(QueryInterface_IServiceProvider);
2604 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2605 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2607 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2608 IUnknown_Release(unk);
2609 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2610 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2612 if(!test_bscholder(clb))
2615 IBindStatusCallback_Release(clb);
2617 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2618 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2620 unk = (void*)0xdeadbeef;
2621 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2622 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2623 ok(unk == NULL, "unk != NULL\n");
2626 IUnknown_Release(unk);
2628 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2629 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2631 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2632 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2634 hres = RevokeBindStatusCallback(bindctx, NULL);
2635 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2637 SET_EXPECT(QueryInterface_IServiceProvider);
2638 prevbsc = (void*)0xdeadbeef;
2639 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2640 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2641 ok(!prevbsc, "prevbsc=%p\n", prevbsc);
2642 CHECK_CALLED(QueryInterface_IServiceProvider);
2644 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2645 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2647 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&prev_clb);
2648 IUnknown_Release(unk);
2649 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2650 ok(prev_clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2652 SET_EXPECT(QueryInterface_IServiceProvider);
2653 prevbsc = (void*)0xdeadbeef;
2654 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc2, &prevbsc, 0);
2655 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2656 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc != bsc\n");
2657 CHECK_CALLED(QueryInterface_IServiceProvider);
2659 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2660 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2662 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2663 IUnknown_Release(unk);
2664 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2665 ok(prev_clb == clb, "bsc != clb\n");
2667 IBindStatusCallback_Release(clb);
2668 IBindStatusCallback_Release(prev_clb);
2670 IBindCtx_Release(bindctx);
2674 #define BINDTEST_EMULATE 0x0001
2675 #define BINDTEST_TOOBJECT 0x0002
2676 #define BINDTEST_FILEDWLAPI 0x0004
2677 #define BINDTEST_HTTPRESPONSE 0x0008
2678 #define BINDTEST_REDIRECT 0x0010
2679 #define BINDTEST_USE_CACHE 0x0020
2680 #define BINDTEST_NO_CALLBACK_READ 0x0040
2681 #define BINDTEST_NO_CALLBACK 0x0080
2682 #define BINDTEST_ABORT 0x0100
2683 #define BINDTEST_INVALID_CN 0x0200
2684 #define BINDTEST_ABORT_START 0x0400
2685 #define BINDTEST_ABORT_PROGRESS 0x0800
2687 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2689 test_protocol = protocol;
2690 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2691 download_state = BEFORE_DOWNLOAD;
2692 stopped_binding = FALSE;
2693 stopped_obj_binding = FALSE;
2694 data_available = FALSE;
2696 binding_hres = S_OK;
2697 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2699 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2700 if(flags & BINDTEST_HTTPRESPONSE)
2701 urls[HTTP_TEST] = winetest_post_urlW;
2703 urls[HTTP_TEST] = winetest_data_urlW;
2704 if(flags & BINDTEST_INVALID_CN)
2705 urls[HTTPS_TEST] = https_invalid_cn_urlW;
2707 urls[HTTPS_TEST] = https_urlW;
2708 test_redirect = (flags & BINDTEST_REDIRECT) != 0;
2709 use_cache_file = (flags & BINDTEST_USE_CACHE) != 0;
2710 callback_read = !(flags & BINDTEST_NO_CALLBACK_READ);
2711 no_callback = (flags & BINDTEST_NO_CALLBACK) != 0;
2712 test_abort = (flags & BINDTEST_ABORT) != 0;
2713 abort_start = (flags & BINDTEST_ABORT_START) != 0;
2714 abort_progress = (flags & BINDTEST_ABORT_PROGRESS) != 0;
2715 is_async_prot = protocol == HTTP_TEST || protocol == HTTPS_TEST || protocol == FTP_TEST || protocol == WINETEST_TEST;
2718 static void test_BindToStorage(int protocol, DWORD flags, DWORD t)
2722 LPOLESTR display_name;
2723 IBindCtx *bctx = NULL;
2725 IBindStatusCallback *previousclb;
2726 IUnknown *unk = (IUnknown*)0x00ff00ff;
2729 init_bind_test(protocol, flags, t);
2732 hres = CreateBindCtx(0, &bctx);
2733 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2735 SET_EXPECT(QueryInterface_IServiceProvider);
2736 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2737 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2738 CHECK_CALLED(QueryInterface_IServiceProvider);
2742 SET_EXPECT(QueryInterface_IServiceProvider);
2743 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2744 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2745 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2746 CHECK_CALLED(QueryInterface_IServiceProvider);
2748 IBindStatusCallback_Release(previousclb);
2751 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2752 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
2756 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2757 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2759 IBinding_Release(bind);
2761 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2762 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2763 ok(!lstrcmpW(display_name, urls[test_protocol]),
2764 "GetDisplayName got wrong name %s\n", wine_dbgstr_w(display_name));
2765 CoTaskMemFree(display_name);
2767 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2768 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2769 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted &&
2770 (onsecurityproblem_hres != S_OK || security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)) {
2771 if(security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)
2772 binding_hres = INET_E_SECURITY_PROBLEM;
2774 binding_hres = INET_E_INVALID_CERTIFICATE;
2778 if(only_check_prot_args)
2779 SET_EXPECT(OnStopBinding);
2781 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2782 SET_EXPECT(GetBindInfo);
2783 SET_EXPECT(QueryInterface_IInternetProtocol);
2784 if(!emulate_protocol)
2785 SET_EXPECT(QueryService_IInternetProtocol);
2786 SET_EXPECT(OnStartBinding);
2788 if(emulate_protocol) {
2789 if(is_urlmon_protocol(test_protocol))
2790 SET_EXPECT(SetPriority);
2792 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)
2793 SET_EXPECT(Terminate);
2794 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2795 SET_EXPECT(UnlockRequest);
2797 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2798 SET_EXPECT(QueryInterface_IInternetBindInfo);
2799 SET_EXPECT(QueryService_IInternetBindInfo);
2801 SET_EXPECT(QueryInterface_IHttpNegotiate);
2802 SET_EXPECT(QueryInterface_IWindowForBindingUI);
2803 SET_EXPECT(QueryService_IWindowForBindingUI);
2804 SET_EXPECT(GetWindow_IWindowForBindingUI);
2806 SET_EXPECT(BeginningTransaction);
2807 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2808 SET_EXPECT(GetRootSecurityId);
2809 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2810 SET_EXPECT(OnProgress_CONNECTING);
2812 if(flags & BINDTEST_INVALID_CN) {
2813 SET_EXPECT(QueryInterface_IHttpSecurity);
2814 SET_EXPECT(QueryService_IHttpSecurity);
2815 SET_EXPECT(OnSecurityProblem);
2816 if(SUCCEEDED(onsecurityproblem_hres))
2817 SET_EXPECT(GetWindow_IHttpSecurity);
2821 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
2822 || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) && !abort_start)
2823 SET_EXPECT(OnProgress_SENDINGREQUEST);
2824 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2825 SET_EXPECT(QueryInterface_IHttpNegotiate);
2826 SET_EXPECT(OnResponse);
2829 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2830 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2832 if(test_protocol == FILE_TEST)
2833 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2834 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST)
2835 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2837 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2838 if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
2839 SET_EXPECT(OnDataAvailable);
2840 SET_EXPECT(OnStopBinding);
2844 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2845 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2846 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2848 skip("Network unreachable, skipping tests\n");
2852 if(only_check_prot_args) {
2853 ok(hres == E_FAIL, "Got %08x\n", hres);
2854 CHECK_CALLED(OnStopBinding);
2855 } else if(abort_start)
2856 ok(hres == E_ABORT, "IMoniker_BindToStorage failed: %08x, expected E_ABORT\n", hres);
2857 else if(abort_progress)
2858 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2859 else if(no_callback) {
2860 if(emulate_protocol)
2861 WaitForSingleObject(complete_event2, INFINITE);
2862 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2863 ok(unk != NULL, "unk == NULL\n");
2864 }else if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) {
2865 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2866 ok(unk == NULL, "unk != NULL\n");
2867 }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2868 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2869 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2870 ok(unk == NULL, "istr should be NULL\n");
2871 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2872 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2873 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2874 ok(unk == NULL, "istr should be NULL\n");
2875 }else if((flags & BINDTEST_INVALID_CN) && binding_hres != S_OK) {
2876 ok(hres == binding_hres, "Got %08x\n", hres);
2877 ok(unk == NULL, "Got %p\n", unk);
2878 }else if((flags & BINDTEST_INVALID_CN) && invalid_cn_accepted) {
2880 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2881 ok(unk != NULL, "unk == NULL\n");
2883 ok(0, "Expected security problem to be ignored.\n");
2884 invalid_cn_accepted = FALSE;
2885 binding_hres = INET_E_INVALID_CERTIFICATE;
2889 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2890 ok(unk != NULL, "unk == NULL\n");
2892 if(unk && callback_read && !no_callback) {
2893 IUnknown_Release(unk);
2897 if(FAILED(hres) && !(flags & BINDTEST_INVALID_CN) && !(flags & BINDTEST_ABORT_START))
2900 if((bindf & BINDF_ASYNCHRONOUS) && !no_callback) {
2901 while(!stopped_binding && GetMessage(&msg,NULL,0,0)) {
2902 TranslateMessage(&msg);
2903 DispatchMessage(&msg);
2908 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2909 CHECK_CALLED(GetBindInfo);
2911 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol);
2913 CHECK_CALLED(QueryInterface_IInternetProtocol);
2914 if(!emulate_protocol) {
2916 todo_wine CHECK_CALLED(QueryService_IInternetProtocol);
2918 CHECK_CALLED(QueryService_IInternetProtocol);
2920 CHECK_CALLED(OnStartBinding);
2922 if(emulate_protocol) {
2923 if(is_urlmon_protocol(test_protocol))
2924 CHECK_CALLED(SetPriority);
2925 CHECK_CALLED(Start);
2926 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2927 if(tymed == TYMED_FILE)
2929 CHECK_CALLED(Terminate);
2931 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2932 CHECK_CALLED(UnlockRequest);
2934 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) {
2935 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2936 CLEAR_CALLED(QueryService_IInternetBindInfo);
2938 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2939 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
2940 CLEAR_CALLED(QueryService_IWindowForBindingUI);
2941 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
2943 CHECK_CALLED(BeginningTransaction);
2944 if (have_IHttpNegotiate2 && !abort_start)
2946 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2947 CHECK_CALLED(GetRootSecurityId);
2949 if(http_is_first || (test_protocol == HTTPS_TEST && !(flags & BINDTEST_INVALID_CN))) {
2950 if (! proxy_active())
2952 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2953 CHECK_CALLED(OnProgress_CONNECTING);
2957 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
2958 CLEAR_CALLED(OnProgress_CONNECTING);
2960 }else if(!abort_start) {
2962 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2963 /* IE7 does call this */
2964 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);
3106 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
3107 SET_EXPECT(Obj_OnProgress_CONNECTING);
3108 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3109 SET_EXPECT(QueryService_IWindowForBindingUI);
3110 SET_EXPECT(GetWindow_IWindowForBindingUI);
3112 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
3113 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
3114 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3115 SET_EXPECT(QueryInterface_IHttpNegotiate);
3116 SET_EXPECT(OnResponse);
3118 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
3119 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
3120 if(test_protocol == FILE_TEST)
3121 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
3122 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3123 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3124 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
3125 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
3126 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
3127 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
3128 SET_EXPECT(OnObjectAvailable);
3129 SET_EXPECT(Obj_OnStopBinding);
3132 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
3134 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3135 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
3137 skip( "Network unreachable, skipping tests\n" );
3141 /* no point testing the calls if binding didn't even work */
3142 if (FAILED(hres)) return;
3144 if(bindf & BINDF_ASYNCHRONOUS) {
3145 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
3146 ok(unk == NULL, "istr should be NULL\n");
3148 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3149 ok(unk != NULL, "unk == NULL\n");
3150 if(emulate_protocol)
3151 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
3154 IUnknown_Release(unk);
3156 while((bindf & BINDF_ASYNCHRONOUS) &&
3157 !((!emulate_protocol || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
3158 TranslateMessage(&msg);
3159 DispatchMessage(&msg);
3162 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
3163 CHECK_CALLED(Obj_GetBindInfo);
3164 CHECK_CALLED(QueryInterface_IInternetProtocol);
3165 if(!emulate_protocol)
3166 CHECK_CALLED(QueryService_IInternetProtocol);
3167 CHECK_CALLED(Obj_OnStartBinding);
3168 if(emulate_protocol) {
3169 if(is_urlmon_protocol(test_protocol))
3170 CHECK_CALLED(SetPriority);
3171 CHECK_CALLED(Start);
3172 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
3173 CHECK_CALLED(Terminate);
3174 if(test_protocol == FILE_TEST)
3175 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
3176 CHECK_CALLED(UnlockRequest);
3178 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
3179 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3180 CHECK_CALLED(BeginningTransaction);
3181 if (have_IHttpNegotiate2)
3183 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3184 CHECK_CALLED(GetRootSecurityId);
3187 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
3188 CHECK_CALLED(Obj_OnProgress_CONNECTING);
3190 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
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 set_file_url(char *path)
3340 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
3341 CHAR INDEX_HTMLA[MAX_PATH];
3343 lstrcpyA(file_urlA, "file:///");
3344 lstrcatA(file_urlA, path);
3345 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
3347 lstrcpyA(INDEX_HTMLA, "file://");
3348 lstrcatA(INDEX_HTMLA, path);
3349 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
3352 static void create_file(void)
3356 CHAR path[MAX_PATH];
3358 static const char html_doc[] = "<HTML></HTML>";
3360 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3361 FILE_ATTRIBUTE_NORMAL, NULL);
3362 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3363 if(file == INVALID_HANDLE_VALUE)
3366 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
3369 GetCurrentDirectoryA(MAX_PATH, path);
3370 lstrcatA(path, "\\");
3371 lstrcatA(path, wszIndexHtmlA);
3375 static void create_cache_file(void)
3377 char buf[6500], curdir[MAX_PATH];
3381 file = CreateFileA(test_txtA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
3382 FILE_ATTRIBUTE_NORMAL, NULL);
3383 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
3384 if(file == INVALID_HANDLE_VALUE)
3387 memset(buf, 'X', sizeof(buf));
3388 WriteFile(file, buf, sizeof(buf), &size, NULL);
3391 memset(curdir, 0, sizeof(curdir));
3392 GetCurrentDirectoryA(MAX_PATH, curdir);
3393 lstrcatA(curdir, "\\");
3394 lstrcatA(curdir, test_txtA);
3396 MultiByteToWideChar(CP_ACP, 0, curdir, -1, cache_file_name, MAX_PATH);
3399 static void test_ReportResult(HRESULT exhres)
3401 IMoniker *mon = NULL;
3402 IBindCtx *bctx = NULL;
3403 IUnknown *unk = (void*)0xdeadbeef;
3406 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3407 binding_hres = exhres;
3409 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
3410 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3412 SET_EXPECT(QueryInterface_IServiceProvider);
3413 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
3414 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3415 CHECK_CALLED(QueryInterface_IServiceProvider);
3417 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3418 SET_EXPECT(GetBindInfo);
3419 SET_EXPECT(QueryInterface_IInternetProtocol);
3420 SET_EXPECT(OnStartBinding);
3421 if(is_urlmon_protocol(test_protocol))
3422 SET_EXPECT(SetPriority);
3425 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3426 if(SUCCEEDED(exhres))
3427 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
3429 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
3430 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
3432 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
3433 CHECK_CALLED(GetBindInfo);
3434 CHECK_CALLED(QueryInterface_IInternetProtocol);
3435 CHECK_CALLED(OnStartBinding);
3436 if(is_urlmon_protocol(test_protocol))
3437 CHECK_CALLED(SetPriority);
3438 CHECK_CALLED(Start);
3440 ok(unk == NULL, "unk=%p\n", unk);
3442 IBindCtx_Release(bctx);
3443 IMoniker_Release(mon);
3446 static void test_BindToStorage_fail(void)
3448 IMoniker *mon = NULL;
3449 IBindCtx *bctx = NULL;
3453 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
3454 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
3458 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
3459 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
3461 unk = (void*)0xdeadbeef;
3462 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
3463 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
3464 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
3465 ok(unk == NULL, "got %p\n", unk);
3467 IBindCtx_Release(bctx);
3469 IMoniker_Release(mon);
3471 test_ReportResult(E_NOTIMPL);
3472 test_ReportResult(S_FALSE);
3475 static void test_StdURLMoniker(void)
3477 IMoniker *mon, *async_mon;
3478 LPOLESTR display_name;
3481 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
3482 &IID_IMoniker, (void**)&mon);
3483 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
3487 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
3488 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
3489 ok(mon == async_mon, "mon != async_mon\n");
3490 IMoniker_Release(async_mon);
3492 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
3493 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
3496 IUriContainer *uri_container;
3499 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
3500 ok(hres == S_OK, "Coud not get IUriMoniker iface: %08x\n", hres);
3503 uri = (void*)0xdeadbeef;
3504 hres = IUriContainer_GetIUri(uri_container, &uri);
3505 ok(hres == S_FALSE, "GetIUri failed: %08x\n", hres);
3506 ok(!uri, "uri = %p, expected NULL\n", uri);
3508 IUriContainer_Release(uri_container);
3511 IMoniker_Release(mon);
3514 static void register_protocols(void)
3516 IInternetSession *session;
3519 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0};
3521 hres = CoInternetGetSession(0, &session, 0);
3522 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3526 hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL,
3527 winetestW, 0, NULL, 0);
3528 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3530 IInternetSession_Release(session);
3537 hurlmon = GetModuleHandle("urlmon.dll");
3538 pCreateAsyncBindCtxEx = (void*) GetProcAddress(hurlmon, "CreateAsyncBindCtxEx");
3540 if(!GetProcAddress(hurlmon, "CompareSecurityIds")) {
3541 win_skip("Too old IE\n");
3545 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
3547 win_skip("IUri not supported\n");
3549 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
3550 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
3551 thread_id = GetCurrentThreadId();
3553 create_cache_file();
3554 register_protocols();
3558 trace("test CreateAsyncBindCtx...\n");
3559 test_CreateAsyncBindCtx();
3561 trace("test CreateAsyncBindCtxEx...\n");
3562 test_CreateAsyncBindCtxEx();
3564 trace("test RegisterBindStatusCallback...\n");
3565 if(test_RegisterBindStatusCallback()) {
3566 trace("test BindToStorage failures...\n");
3567 test_BindToStorage_fail();
3569 trace("synchronous http test (COM not initialised)...\n");
3570 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3574 trace("test StdURLMoniker...\n");
3575 test_StdURLMoniker();
3577 trace("synchronous http test...\n");
3578 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3580 trace("emulated synchronous http test (to file)...\n");
3581 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3583 trace("synchronous http test (to object)...\n");
3584 test_BindToObject(HTTP_TEST, 0);
3586 trace("emulated synchronous http test (with cache)...\n");
3587 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3589 trace("emulated synchronous http test (with cache, no read)...\n");
3590 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3592 trace("synchronous http test (with cache, no read)...\n");
3593 test_BindToStorage(HTTP_TEST, BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3595 trace("synchronous file test...\n");
3596 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3598 trace("emulated synchronous file test (to file)...\n");
3599 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3601 trace("synchronous file test (to object)...\n");
3602 test_BindToObject(FILE_TEST, 0);
3604 trace("file test (no callback)...\n");
3605 test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM);
3607 trace("synchronous https test (invalid CN, dialog)\n");
3608 onsecurityproblem_hres = S_FALSE;
3609 http_is_first = TRUE;
3610 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3612 trace("synchronous https test (invalid CN, fail)\n");
3613 onsecurityproblem_hres = E_FAIL;
3614 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3616 trace("synchronous https test (invalid CN, accept)\n");
3617 onsecurityproblem_hres = S_OK;
3618 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3620 trace("asynchronous https test (invalid CN, dialog 2)\n");
3621 onsecurityproblem_hres = S_FALSE;
3622 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
3623 invalid_cn_accepted = FALSE;
3625 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
3627 trace("about test (no read)...\n");
3628 test_BindToStorage(ABOUT_TEST, BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM);
3630 trace("http test...\n");
3631 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM);
3633 trace("http test (to file)...\n");
3634 test_BindToStorage(HTTP_TEST, 0, TYMED_FILE);
3636 trace("http test (to object)...\n");
3637 test_BindToObject(HTTP_TEST, 0);
3639 trace("http test (short response)...\n");
3640 test_BindToStorage(HTTP_TEST, BINDTEST_HTTPRESPONSE, TYMED_ISTREAM);
3642 trace("http test (short response, to object)...\n");
3643 test_BindToObject(HTTP_TEST, 0);
3645 trace("http test (abort start binding)...\n");
3646 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE);
3648 trace("http test (abort progress)...\n");
3649 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_PROGRESS, TYMED_FILE);
3651 trace("emulated http test...\n");
3652 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3654 trace("emulated http test (to object)...\n");
3655 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE);
3657 trace("emulated http test (to object, redirect)...\n");
3658 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT);
3660 trace("emulated http test (to file)...\n");
3661 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE);
3663 trace("emulated http test (redirect)...\n");
3664 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, TYMED_ISTREAM);
3666 trace("emulated http test (with cache)...\n");
3667 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3669 trace("winetest test (no callback)...\n");
3670 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM);
3672 trace("asynchronous https test...\n");
3673 test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
3675 trace("emulated https test...\n");
3676 test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3678 trace("about test...\n");
3679 test_BindToStorage(ABOUT_TEST, 0, TYMED_ISTREAM);
3681 trace("about test (to file)...\n");
3682 test_BindToStorage(ABOUT_TEST, 0, TYMED_FILE);
3684 trace("about test (to object)...\n");
3685 test_BindToObject(ABOUT_TEST, 0);
3687 trace("emulated about test...\n");
3688 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3690 trace("emulated about test (to file)...\n");
3691 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE);
3693 trace("emulated about test (to object)...\n");
3694 test_BindToObject(ABOUT_TEST, BINDTEST_EMULATE);
3696 trace("file test...\n");
3697 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM);
3699 trace("file test (to file)...\n");
3700 test_BindToStorage(FILE_TEST, 0, TYMED_FILE);
3702 trace("file test (to object)...\n");
3703 test_BindToObject(FILE_TEST, 0);
3705 trace("emulated file test...\n");
3706 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3708 trace("emulated file test (to file)...\n");
3709 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE);
3711 trace("emulated file test (to object)...\n");
3712 test_BindToObject(FILE_TEST, BINDTEST_EMULATE);
3714 trace("emulated its test...\n");
3715 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3717 trace("emulated its test (to file)...\n");
3718 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_FILE);
3720 trace("emulated mk test...\n");
3721 test_BindToStorage(MK_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3723 trace("test URLDownloadToFile for file protocol...\n");
3724 test_URLDownloadToFile(FILE_TEST, FALSE);
3726 trace("test URLDownloadToFile for emulated file protocol...\n");
3727 test_URLDownloadToFile(FILE_TEST, TRUE);
3729 trace("test URLDownloadToFile for http protocol...\n");
3730 test_URLDownloadToFile(HTTP_TEST, FALSE);
3732 trace("test emulated http abort...\n");
3733 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_ABORT, TYMED_ISTREAM);
3735 bindf |= BINDF_NOWRITECACHE;
3737 trace("ftp test...\n");
3738 test_BindToStorage(FTP_TEST, 0, TYMED_ISTREAM);
3740 trace("test failures...\n");
3741 test_BindToStorage_fail();
3743 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE;
3744 only_check_prot_args = TRUE; /* Fail after checking arguments to Protocol_Start */
3746 trace("check emulated http protocol arguments...\n");
3747 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
3750 DeleteFileA(wszIndexHtmlA);
3751 DeleteFileA(test_txtA);
3752 CloseHandle(complete_event);
3753 CloseHandle(complete_event2);