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 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
39 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
40 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
45 #define SET_EXPECT(func) \
46 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
48 #define CHECK_EXPECT2(func) \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 called_ ## func = TRUE; \
54 #define CHECK_EXPECT(func) \
56 CHECK_EXPECT2(func); \
57 expect_ ## func = FALSE; \
60 #define CHECK_CALLED(func) \
62 ok(called_ ## func, "expected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
66 #define CHECK_NOT_CALLED(func) \
68 ok(!called_ ## func, "unexpected " #func "\n"); \
69 expect_ ## func = called_ ## func = FALSE; \
72 #define CHECK_CALLED_BROKEN(func) \
74 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
75 expect_ ## func = called_ ## func = FALSE; \
78 #define CLEAR_CALLED(func) \
79 expect_ ## func = called_ ## func = FALSE
81 DEFINE_EXPECT(QueryInterface_IServiceProvider);
82 DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
83 DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
84 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
85 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
86 DEFINE_EXPECT(QueryInterface_IInternetBindInfo);
87 DEFINE_EXPECT(QueryInterface_IAuthenticate);
88 DEFINE_EXPECT(QueryInterface_IInternetProtocol);
89 DEFINE_EXPECT(QueryService_IAuthenticate);
90 DEFINE_EXPECT(QueryService_IInternetProtocol);
91 DEFINE_EXPECT(QueryService_IInternetBindInfo);
92 DEFINE_EXPECT(BeginningTransaction);
93 DEFINE_EXPECT(OnResponse);
94 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
95 DEFINE_EXPECT(GetRootSecurityId);
96 DEFINE_EXPECT(GetBindInfo);
97 DEFINE_EXPECT(GetBindInfoEx);
98 DEFINE_EXPECT(OnStartBinding);
99 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
100 DEFINE_EXPECT(OnProgress_CONNECTING);
101 DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
102 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
103 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
104 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
105 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
106 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
107 DEFINE_EXPECT(OnStopBinding);
108 DEFINE_EXPECT(OnDataAvailable);
109 DEFINE_EXPECT(OnObjectAvailable);
110 DEFINE_EXPECT(Obj_OnStartBinding);
111 DEFINE_EXPECT(Obj_OnStopBinding);
112 DEFINE_EXPECT(Obj_GetBindInfo);
113 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
114 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
115 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
116 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
117 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
118 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
119 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
120 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
121 DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
122 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
123 DEFINE_EXPECT(Start);
125 DEFINE_EXPECT(LockRequest);
126 DEFINE_EXPECT(Terminate);
127 DEFINE_EXPECT(UnlockRequest);
128 DEFINE_EXPECT(Continue);
129 DEFINE_EXPECT(CreateInstance);
131 DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
132 DEFINE_EXPECT(PutProperty_CLASSIDPROP);
133 DEFINE_EXPECT(SetPriority);
135 static const WCHAR TEST_URL_1[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','\0'};
136 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','/','\0'};
138 static const WCHAR WINE_ABOUT_URL[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
139 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
140 static const WCHAR SHORT_RESPONSE_URL[] =
141 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
142 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
143 'p','o','s','t','t','e','s','t','.','p','h','p',0};
144 static const WCHAR ABOUT_BLANK[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
145 static WCHAR INDEX_HTML[MAX_PATH];
146 static const WCHAR ITS_URL[] =
147 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
148 static const WCHAR MK_URL[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
149 't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
150 static const WCHAR https_urlW[] =
151 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',
152 '/','t','e','s','t','.','h','t','m','l',0};
153 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
154 '/','p','u','b','/','o','t','h','e','r','/',
155 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
158 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
160 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
162 static const WCHAR wszWineHQSite[] =
163 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
164 static const WCHAR wszWineHQIP[] =
165 {'2','0','9','.','3','2','.','1','4','1','.','3',0};
166 static const CHAR wszIndexHtmlA[] = "index.html";
167 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
168 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
169 static const CHAR dwl_htmlA[] = "dwl.html";
170 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
171 static const WCHAR emptyW[] = {0};
173 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE,
174 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api;
175 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed;
176 static CHAR mime_type[512];
177 static IInternetProtocolSink *protocol_sink = NULL;
178 static IBinding *current_binding;
179 static HANDLE complete_event, complete_event2;
180 static HRESULT binding_hres;
181 static BOOL have_IHttpNegotiate2, use_bscex;
183 static LPCWSTR urls[] = {
193 static WCHAR file_url[INTERNET_MAX_URL_LENGTH];
211 static const char *debugstr_guid(REFIID riid)
215 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
216 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
217 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
218 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
223 static BOOL is_urlmon_protocol(int prot)
225 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
228 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2)
231 IMoniker *mon1 = NULL;
232 IMoniker *mon2 = NULL;
234 hr = CreateURLMoniker(NULL, url1, &mon1);
235 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
237 hr = CreateURLMoniker(mon1, url2, &mon2);
238 ok(SUCCEEDED(hr), "failed to create moniker: 0x%08x\n", hr);
240 if(mon1) IMoniker_Release(mon1);
241 if(mon2) IMoniker_Release(mon2);
244 static void test_create(void)
246 test_CreateURLMoniker(TEST_URL_1, TEST_PART_URL_1);
249 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
251 ok(0, "unexpected call\n");
252 return E_NOINTERFACE;
255 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface)
260 static ULONG WINAPI Priority_Release(IInternetPriority *iface)
265 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority)
267 CHECK_EXPECT(SetPriority);
268 ok(!nPriority, "nPriority = %d\n", nPriority);
272 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
274 ok(0, "unexpected call\n");
278 static const IInternetPriorityVtbl InternetPriorityVtbl = {
279 Priority_QueryInterface,
282 Priority_SetPriority,
286 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
288 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
292 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
297 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
298 if(!is_urlmon_protocol(test_protocol))
299 return E_NOINTERFACE;
301 *ppv = &InternetPriority;
305 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
306 return E_NOINTERFACE; /* TODO */
308 ok(0, "unexpected call %s\n", debugstr_guid(riid));
309 return E_NOINTERFACE;
312 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface)
317 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface)
322 static void test_switch_fail(void)
324 IInternetProtocolSink *binding_sink;
325 PROTOCOLDATA protocoldata;
328 static BOOL tested_switch_fail;
330 if(tested_switch_fail)
333 tested_switch_fail = TRUE;
335 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
336 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
337 if(SUCCEEDED(hres)) {
338 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
339 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
340 IInternetProtocolSink_Release(binding_sink);
344 static DWORD WINAPI thread_proc(PVOID arg)
346 PROTOCOLDATA protocoldata;
350 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
352 SET_EXPECT(OnProgress_FINDINGRESOURCE);
353 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
354 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
355 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
356 WaitForSingleObject(complete_event, INFINITE);
358 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
360 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
363 SET_EXPECT(Obj_OnProgress_CONNECTING);
365 SET_EXPECT(OnProgress_CONNECTING);
366 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
367 BINDSTATUS_CONNECTING, wszWineHQIP);
368 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
369 WaitForSingleObject(complete_event, INFINITE);
371 CHECK_CALLED(Obj_OnProgress_CONNECTING);
373 CHECK_CALLED(OnProgress_CONNECTING);
376 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
378 SET_EXPECT(OnProgress_SENDINGREQUEST);
379 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
380 BINDSTATUS_SENDINGREQUEST, NULL);
381 ok(hres == S_OK, "ReportProxgress failed: %08x\n", hres);
382 WaitForSingleObject(complete_event, INFINITE);
384 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
386 CHECK_CALLED(OnProgress_SENDINGREQUEST);
390 SET_EXPECT(Continue);
392 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
393 ok(hres == S_OK, "Switch failed: %08x\n", hres);
394 WaitForSingleObject(complete_event, INFINITE);
396 CHECK_CALLED(Continue);
399 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
400 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
401 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
402 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
403 CHECK_CALLED(CreateInstance);
404 CHECK_CALLED(PutProperty_MIMETYPEPROP);
405 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
407 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
408 CHECK_CALLED(OnObjectAvailable);
409 CHECK_CALLED(Obj_OnStopBinding);
411 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
412 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
413 CHECK_CALLED(LockRequest);
414 CHECK_CALLED(OnDataAvailable);
417 SET_EXPECT(Continue);
419 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
420 ok(hres == S_OK, "Switch failed: %08x\n", hres);
421 WaitForSingleObject(complete_event, INFINITE);
422 CHECK_CALLED(Continue);
424 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
425 CHECK_CALLED(OnDataAvailable);
427 SET_EXPECT(Continue);
429 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
430 ok(hres == S_OK, "Switch failed: %08x\n", hres);
431 WaitForSingleObject(complete_event, INFINITE);
432 CHECK_CALLED(Continue);
434 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
435 CHECK_CALLED(OnDataAvailable);
437 SET_EXPECT(Continue);
439 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
440 ok(hres == S_OK, "Switch failed: %08x\n", hres);
441 WaitForSingleObject(complete_event, INFINITE);
442 CHECK_CALLED(Continue);
444 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
445 CHECK_CALLED(OnDataAvailable);
446 CHECK_CALLED(OnStopBinding);
450 SetEvent(complete_event2);
454 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
455 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
456 DWORD grfPI, HANDLE_PTR dwReserved)
459 DWORD bindf, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
462 static const STGMEDIUM stgmed_zero = {0};
463 static const SECURITY_ATTRIBUTES sa_zero = {0};
469 if(!filedwl_api) /* FIXME */
470 ok(szUrl && !lstrcmpW(szUrl, urls[test_protocol]), "wrong url %s\n", wine_dbgstr_w(szUrl));
471 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
472 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
473 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
474 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
476 if(!filedwl_api && binding_hres != S_OK) {
477 SET_EXPECT(OnStopBinding);
478 SET_EXPECT(Terminate);
479 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
480 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
481 CHECK_CALLED(OnStopBinding);
482 CHECK_CALLED(Terminate);
487 memset(&bindinfo, 0, sizeof(bindinfo));
488 bindinfo.cbSize = sizeof(bindinfo);
489 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bindf, &bindinfo);
490 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
493 ok(bindf == (BINDF_PULLDATA|BINDF_FROMURLMON|BINDF_NEEDFILE), "bindf=%08x\n", bindf);
494 }else if(tymed == TYMED_ISTREAM && is_urlmon_protocol(test_protocol)) {
495 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
497 "bindf=%08x\n", bindf);
499 ok(bindf == (BINDF_ASYNCHRONOUS|BINDF_ASYNCSTORAGE|BINDF_PULLDATA
500 |BINDF_FROMURLMON|BINDF_NEEDFILE),
501 "bindf=%08x\n", bindf);
504 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
505 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
506 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
507 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
508 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
509 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
510 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
511 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
512 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
513 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
514 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
515 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
516 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
517 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
519 switch(test_protocol) {
521 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
522 BINDSTATUS_DIRECTBIND, NULL);
524 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
529 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
531 SET_EXPECT(OnProgress_SENDINGREQUEST);
532 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
533 BINDSTATUS_SENDINGREQUEST, emptyW);
535 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
537 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
539 CHECK_CALLED(OnProgress_SENDINGREQUEST);
544 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
545 IServiceProvider *service_provider;
546 IHttpNegotiate *http_negotiate;
547 IHttpNegotiate2 *http_negotiate2;
548 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
549 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
551 DWORD fetched = 256, size = 100;
554 static const WCHAR wszMimes[] = {'*','/','*',0};
556 SET_EXPECT(QueryInterface_IInternetBindInfo);
557 SET_EXPECT(QueryService_IInternetBindInfo);
558 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
560 CLEAR_CALLED(QueryInterface_IInternetBindInfo); /* IE <8 */
561 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
563 ok(hres == E_NOINTERFACE,
564 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
565 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
566 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
568 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
569 accept_mimes, 256, &fetched);
571 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
572 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
573 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
575 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
576 NULL, 256, &fetched);
577 ok(hres == E_INVALIDARG,
578 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
580 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
581 accept_mimes, 256, NULL);
582 ok(hres == E_INVALIDARG,
583 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
585 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
586 (void**)&service_provider);
587 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
589 SET_EXPECT(QueryInterface_IHttpNegotiate);
590 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
591 &IID_IHttpNegotiate, (void**)&http_negotiate);
592 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
593 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
595 SET_EXPECT(BeginningTransaction);
596 SET_EXPECT(QueryInterface_IHttpNegotiate);
597 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, urls[test_protocol],
598 NULL, 0, &additional_headers);
599 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
600 CHECK_CALLED(BeginningTransaction);
601 IHttpNegotiate_Release(http_negotiate);
602 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
603 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
605 SET_EXPECT(QueryInterface_IHttpNegotiate2);
606 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
607 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
608 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
609 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
612 SET_EXPECT(QueryInterface_IHttpNegotiate2);
613 SET_EXPECT(GetRootSecurityId);
614 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
615 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
616 CHECK_CALLED(GetRootSecurityId);
617 IHttpNegotiate2_Release(http_negotiate2);
618 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
619 ok(size == 13, "size=%d\n", size);
621 IServiceProvider_Release(service_provider);
623 IInternetProtocolSink_AddRef(pOIProtSink);
624 protocol_sink = pOIProtSink;
625 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
630 if(test_protocol == FILE_TEST) {
631 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
632 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+8);
634 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
637 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
639 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
640 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
641 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
643 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
645 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
647 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
649 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
650 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
652 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
655 if(test_protocol == ABOUT_TEST)
656 bscf |= BSCF_DATAFULLYAVAILABLE;
657 if(test_protocol == ITS_TEST)
658 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
662 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
663 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
664 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
665 if(test_protocol == FILE_TEST)
666 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
667 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
668 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
669 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
670 SET_EXPECT(CreateInstance);
671 SET_EXPECT(PutProperty_MIMETYPEPROP);
672 SET_EXPECT(PutProperty_CLASSIDPROP);
674 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
675 SET_EXPECT(OnObjectAvailable);
676 SET_EXPECT(Obj_OnStopBinding);
678 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
679 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
680 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
681 if(test_protocol == FILE_TEST)
682 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
683 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
684 SET_EXPECT(LockRequest);
686 SET_EXPECT(OnDataAvailable);
687 SET_EXPECT(OnStopBinding);
690 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
691 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
695 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
696 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
697 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
698 if(test_protocol == FILE_TEST)
699 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
700 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
701 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
702 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
703 CHECK_CALLED(CreateInstance);
704 CHECK_CALLED(PutProperty_MIMETYPEPROP);
705 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
707 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
708 CHECK_CALLED(OnObjectAvailable);
709 CHECK_CALLED(Obj_OnStopBinding);
711 if(test_protocol != FILE_TEST && test_protocol != MK_TEST)
712 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
713 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
714 if(test_protocol == FILE_TEST)
715 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
716 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
717 CHECK_CALLED(LockRequest);
719 CHECK_CALLED(OnDataAvailable);
720 CHECK_CALLED(OnStopBinding);
723 if(test_protocol == ITS_TEST) {
725 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
726 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
730 SET_EXPECT(Terminate);
731 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
732 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
733 CHECK_CALLED(Terminate);
738 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface,
739 PROTOCOLDATA *pProtocolData)
744 CHECK_EXPECT(Continue);
746 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
748 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
754 IServiceProvider *service_provider;
755 IHttpNegotiate *http_negotiate;
756 static WCHAR header[] = {'?',0};
758 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
759 (void**)&service_provider);
760 ok(hres == S_OK, "Could not get IServiceProvicder\n");
762 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
763 &IID_IHttpNegotiate, (void**)&http_negotiate);
764 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
766 SET_EXPECT(QueryInterface_IHttpNegotiate);
767 SET_EXPECT(OnResponse);
768 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
769 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
770 CHECK_CALLED(OnResponse);
771 IHttpNegotiate_Release(http_negotiate);
772 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
774 if(test_protocol == HTTPS_TEST) {
775 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
776 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
779 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
780 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
782 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
784 if(tymed == TYMED_FILE) {
785 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
786 BINDSTATUS_CACHEFILENAMEAVAILABLE, cache_fileW);
788 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
791 bscf |= BSCF_FIRSTDATANOTIFICATION;
796 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
800 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
801 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
807 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
808 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
809 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
810 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
811 SET_EXPECT(CreateInstance);
812 SET_EXPECT(PutProperty_MIMETYPEPROP);
813 SET_EXPECT(PutProperty_CLASSIDPROP);
815 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
816 SET_EXPECT(OnObjectAvailable);
817 SET_EXPECT(Obj_OnStopBinding);
819 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
820 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
821 SET_EXPECT(LockRequest);
825 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
828 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
829 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
831 if(!bind_to_object || prot_state >= 2)
832 SET_EXPECT(OnDataAvailable);
834 SET_EXPECT(OnStopBinding);
839 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
842 ok(0, "unexpected call\n");
846 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
848 CHECK_EXPECT(Terminate);
850 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
853 IInternetProtocolSink_Release(protocol_sink);
854 protocol_sink = NULL;
860 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface)
862 ok(0, "unexpected call\n");
866 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface)
868 ok(0, "unexpected call\n");
872 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv,
873 ULONG cb, ULONG *pcbRead)
875 static const char data[] = "<HTML></HTML>";
879 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
882 static BOOL pending = TRUE;
904 hres = IInternetProtocolSink_ReportData(protocol_sink,
905 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
906 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
908 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
909 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
923 ok(pv != NULL, "pv == NULL\n");
924 ok(cb != 0, "cb == 0\n");
925 ok(pcbRead != NULL, "pcbRead == NULL\n");
927 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
928 read += *pcbRead = sizeof(data)-1;
931 memcpy(pv, data, sizeof(data));
936 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface,
937 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
939 ok(0, "unexpected call\n");
943 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
945 CHECK_EXPECT(LockRequest);
949 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface)
951 CHECK_EXPECT(UnlockRequest);
955 static const IInternetProtocolVtbl ProtocolVtbl = {
956 Protocol_QueryInterface,
967 Protocol_LockRequest,
968 Protocol_UnlockRequest
971 static IInternetProtocol Protocol = { &ProtocolVtbl };
973 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
975 if(IsEqualGUID(&IID_IUnknown, riid)
976 || IsEqualGUID(&IID_IHttpNegotiate, riid)
977 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
982 ok(0, "unexpected call\n");
983 return E_NOINTERFACE;
986 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
991 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
996 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
997 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
999 CHECK_EXPECT(BeginningTransaction);
1001 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1003 ok(!lstrcmpW(szURL, urls[test_protocol]), "szURL != urls[test_protocol]\n");
1004 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1005 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1006 if(pszAdditionalHeaders)
1007 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1012 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
1013 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1015 CHECK_EXPECT(OnResponse);
1017 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1019 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1020 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1021 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1022 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1023 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1024 if(pszAdditionalRequestHeaders)
1025 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1030 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
1031 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1033 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1035 CHECK_EXPECT(GetRootSecurityId);
1037 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1039 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1040 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1041 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1043 if(pbSecurityId == (void*)0xdeadbeef)
1047 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1048 *pcbSecurityId = sizeof(sec_id);
1052 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1057 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1058 HttpNegotiate_QueryInterface,
1059 HttpNegotiate_AddRef,
1060 HttpNegotiate_Release,
1061 HttpNegotiate_BeginningTransaction,
1062 HttpNegotiate_OnResponse,
1063 HttpNegotiate_GetRootSecurityId
1066 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl };
1068 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
1070 ok(0, "unexpected call\n");
1071 return E_NOINTERFACE;
1074 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
1079 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
1084 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface,
1085 REFGUID guidService, REFIID riid, void **ppv)
1087 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1088 CHECK_EXPECT(QueryService_IAuthenticate);
1092 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1093 CHECK_EXPECT2(QueryService_IInternetProtocol);
1097 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1098 CHECK_EXPECT(QueryService_IInternetBindInfo);
1102 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
1103 return E_NOINTERFACE;
1106 static IServiceProviderVtbl ServiceProviderVtbl = {
1107 ServiceProvider_QueryInterface,
1108 ServiceProvider_AddRef,
1109 ServiceProvider_Release,
1110 ServiceProvider_QueryService
1113 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl };
1115 static IBindStatusCallbackEx objbsc;
1117 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv)
1119 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1121 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1122 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1123 if(emulate_protocol) {
1127 return E_NOINTERFACE;
1130 else if (IsEqualGUID(&IID_IServiceProvider, riid))
1132 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1133 *ppv = &ServiceProvider;
1136 else if (IsEqualGUID(&IID_IHttpNegotiate, riid))
1138 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1139 *ppv = &HttpNegotiate;
1142 else if (IsEqualGUID(&IID_IHttpNegotiate2, riid))
1144 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1145 *ppv = &HttpNegotiate;
1148 else if (IsEqualGUID(&IID_IAuthenticate, riid))
1150 CHECK_EXPECT(QueryInterface_IAuthenticate);
1151 return E_NOINTERFACE;
1153 else if(IsEqualGUID(&IID_IBindStatusCallback, riid))
1155 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1159 else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid))
1161 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1162 return E_NOINTERFACE;
1164 else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid))
1166 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1168 return E_NOINTERFACE;
1172 else if(IsEqualGUID(&IID_IInternetBindInfo, riid))
1175 CHECK_EXPECT2(QueryInterface_IInternetBindInfo);
1179 ok(0, "unexpected interface %s\n", debugstr_guid(riid));
1182 return E_NOINTERFACE;
1185 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface)
1190 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface)
1195 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved,
1198 IWinInetHttpInfo *http_info;
1202 if(iface == &objbsc)
1203 CHECK_EXPECT(Obj_OnStartBinding);
1205 CHECK_EXPECT(OnStartBinding);
1207 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1209 ok(pib != NULL, "pib should not be NULL\n");
1210 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1212 if(pib == (void*)0xdeadbeef)
1215 current_binding = pib;
1217 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1218 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1220 IMoniker_Release(mon);
1222 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1223 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1228 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority)
1230 ok(0, "unexpected call\n");
1234 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved)
1236 ok(0, "unexpected call\n");
1240 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress,
1241 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1243 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1245 switch(ulStatusCode) {
1246 case BINDSTATUS_FINDINGRESOURCE:
1247 if(iface == &objbsc)
1248 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1249 else if(test_protocol == FTP_TEST)
1250 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1252 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1253 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1254 SetEvent(complete_event);
1256 case BINDSTATUS_CONNECTING:
1257 if(iface == &objbsc)
1258 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1259 else if(test_protocol == FTP_TEST)
1260 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1262 CHECK_EXPECT(OnProgress_CONNECTING);
1263 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1264 SetEvent(complete_event);
1266 case BINDSTATUS_SENDINGREQUEST:
1267 if(iface == &objbsc)
1268 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1269 else if(test_protocol == FTP_TEST)
1270 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1272 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1273 if((bindf & BINDF_ASYNCHRONOUS) && emulate_protocol)
1274 SetEvent(complete_event);
1276 case BINDSTATUS_MIMETYPEAVAILABLE:
1277 if(iface == &objbsc)
1278 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1280 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1282 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1284 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1286 case BINDSTATUS_BEGINDOWNLOADDATA:
1287 if(iface == &objbsc)
1288 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1290 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1291 ok(szStatusText != NULL, "szStatusText == NULL\n");
1296 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1300 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1302 download_state = DOWNLOADING;
1304 case BINDSTATUS_DOWNLOADINGDATA:
1305 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1306 ok(iface != &objbsc, "unexpected call\n");
1307 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1310 case BINDSTATUS_ENDDOWNLOADDATA:
1311 if(iface == &objbsc)
1312 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1314 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1315 ok(szStatusText != NULL, "szStatusText == NULL\n");
1320 ok(!lstrcmpW(szStatusText, urls[test_protocol]), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1323 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1325 download_state = END_DOWNLOAD;
1327 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1328 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) {
1329 if(iface == &objbsc)
1330 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1332 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1334 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1335 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1338 ok(szStatusText != NULL, "szStatusText == NULL\n");
1339 if(szStatusText && test_protocol == FILE_TEST)
1340 ok(!lstrcmpW(file_url+8, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1342 case BINDSTATUS_CLASSIDAVAILABLE:
1346 if(iface != &objbsc)
1347 ok(0, "unexpected call\n");
1348 else if(1||emulate_protocol)
1349 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1351 todo_wine CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1352 hr = CLSIDFromString((LPOLESTR)szStatusText, &clsid);
1353 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1354 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1355 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", debugstr_guid(&clsid));
1358 case BINDSTATUS_BEGINSYNCOPERATION:
1359 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1360 if(iface != &objbsc)
1361 ok(0, "unexpected call\n");
1362 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1364 case BINDSTATUS_ENDSYNCOPERATION:
1365 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1366 if(iface != &objbsc)
1367 ok(0, "unexpected call\n");
1368 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1370 case BINDSTATUS_PROXYDETECTING:
1371 trace("BINDSTATUS_PROXYDETECTING\n");
1373 case BINDSTATUS_COOKIE_SENT:
1374 trace("BINDSTATUS_COOKIE_SENT\n");
1377 ok(0, "unexpected code %d\n", ulStatusCode);
1380 if(current_binding) {
1381 IWinInetHttpInfo *http_info;
1384 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1385 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol))
1386 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1388 ok(hres == E_NOINTERFACE,
1389 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1391 IWinInetHttpInfo_Release(http_info);
1397 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError)
1399 if(iface == &objbsc) {
1400 CHECK_EXPECT(Obj_OnStopBinding);
1401 stopped_obj_binding = TRUE;
1403 CHECK_EXPECT(OnStopBinding);
1404 stopped_binding = TRUE;
1407 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1409 /* ignore DNS failure */
1410 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
1414 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1416 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1417 ok(szError == NULL, "szError should be NULL\n");
1419 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) && emulate_protocol) {
1420 SetEvent(complete_event);
1421 if(iface != &objbsc)
1422 WaitForSingleObject(complete_event2, INFINITE);
1428 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1432 if(iface == &objbsc)
1433 CHECK_EXPECT(Obj_GetBindInfo);
1435 CHECK_EXPECT(GetBindInfo);
1437 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1440 cbSize = pbindinfo->cbSize;
1441 memset(pbindinfo, 0, cbSize);
1442 pbindinfo->cbSize = cbSize;
1447 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF,
1448 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1455 if(iface == &objbsc)
1456 ok(0, "unexpected call\n");
1458 CHECK_EXPECT2(OnDataAvailable);
1460 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1462 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD,
1463 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1465 data_available = TRUE;
1467 ok(pformatetc != NULL, "pformatetx == NULL\n");
1471 ok(GetClipboardFormatName(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1),
1472 "GetClipboardFormatName failed, error %d\n", GetLastError());
1473 ok(!lstrcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1474 pformatetc->cfFormat, clipfmt, mime_type);
1476 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
1478 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
1479 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
1480 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
1481 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
1484 ok(pstgmed != NULL, "stgmeg == NULL\n");
1485 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
1486 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
1488 switch(pstgmed->tymed) {
1490 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
1491 hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
1492 ok(hres == STG_E_ACCESSDENIED,
1493 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
1495 hres = IStream_Commit(U(*pstgmed).pstm, 0);
1496 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
1498 hres = IStream_Revert(U(*pstgmed).pstm);
1499 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
1502 ok(U(*pstgmed).pstm != NULL, "U(*pstgmed).pstm == NULL\n");
1503 do hres = IStream_Read(U(*pstgmed).pstm, buf, 512, &readed);
1504 while(hres == S_OK);
1505 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
1509 if(test_protocol == FILE_TEST)
1510 ok(!lstrcmpW(pstgmed->u.lpszFileName, INDEX_HTML+7),
1511 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1512 else if(emulate_protocol)
1513 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
1514 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
1516 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
1519 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1520 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1))
1521 SetEvent(complete_event);
1526 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk)
1528 CHECK_EXPECT(OnObjectAvailable);
1530 if(iface != &objbsc)
1531 ok(0, "unexpected call\n");
1533 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", debugstr_guid(riid));
1534 ok(punk != NULL, "punk == NULL\n");
1539 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
1540 DWORD *grfBINDF2, DWORD *pdwReserved)
1542 CHECK_EXPECT(GetBindInfoEx);
1544 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1545 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
1546 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1547 ok(pdwReserved != NULL, "dwReserved == NULL\n");
1552 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
1553 statusclb_QueryInterface,
1556 statusclb_OnStartBinding,
1557 statusclb_GetPriority,
1558 statusclb_OnLowResource,
1559 statusclb_OnProgress,
1560 statusclb_OnStopBinding,
1561 statusclb_GetBindInfo,
1562 statusclb_OnDataAvailable,
1563 statusclb_OnObjectAvailable,
1564 statusclb_GetBindInfoEx
1567 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl };
1568 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl };
1570 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv)
1573 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1574 return E_NOINTERFACE;
1577 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface)
1582 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface)
1587 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
1591 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
1592 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
1595 CHECK_EXPECT(PutProperty_CLASSIDPROP);
1604 static const IMonikerPropVtbl MonikerPropVtbl = {
1605 MonikerProp_QueryInterface,
1607 MonikerProp_Release,
1608 MonikerProp_PutProperty
1611 static IMonikerProp MonikerProp = { &MonikerPropVtbl };
1613 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv)
1617 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
1619 else if(IsEqualGUID(&IID_IMonikerProp, riid))
1620 *ppv = &MonikerProp;
1625 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1626 return E_NOINTERFACE;
1629 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface)
1634 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface)
1639 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID)
1641 ok(0, "unexpected call\n");
1645 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface)
1647 ok(0, "unexpected call\n");
1651 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable,
1652 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
1657 static WCHAR cbinding_contextW[] =
1658 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
1661 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1663 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
1664 ok(!fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1666 ok(fFullyAvailable, "fFulyAvailable = %x\n", fFullyAvailable);
1667 ok(pimkName != NULL, "pimkName == NULL\n");
1668 ok(pibc != NULL, "pibc == NULL\n");
1669 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
1671 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
1672 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
1673 if(SUCCEEDED(hres)) {
1676 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
1677 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
1679 IBinding_Release(binding);
1680 IUnknown_Release(unk);
1683 SET_EXPECT(QueryInterface_IServiceProvider);
1684 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0);
1685 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
1686 CHECK_CALLED(QueryInterface_IServiceProvider);
1688 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1689 SET_EXPECT(GetBindInfo);
1690 SET_EXPECT(OnStartBinding);
1691 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1692 if(test_protocol == FILE_TEST)
1693 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1694 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1695 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1696 SET_EXPECT(LockRequest);
1697 SET_EXPECT(OnDataAvailable);
1698 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1699 SET_EXPECT(OnStopBinding);
1701 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
1702 ok(hres == S_OK, "Load failed: %08x\n", hres);
1704 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
1705 CHECK_CALLED(GetBindInfo);
1706 CHECK_CALLED(OnStartBinding);
1707 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
1708 if(test_protocol == FILE_TEST)
1709 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1710 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1711 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
1712 CHECK_CALLED(LockRequest);
1713 CHECK_CALLED(OnDataAvailable);
1714 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST)
1715 CHECK_CALLED(OnStopBinding);
1718 IUnknown_Release(unk);
1723 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
1725 ok(0, "unexpected call\n");
1729 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc)
1731 ok(0, "unexpected call\n");
1735 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName)
1737 ok(0, "unexpected call\n");
1741 static const IPersistMonikerVtbl PersistMonikerVtbl = {
1742 PersistMoniker_QueryInterface,
1743 PersistMoniker_AddRef,
1744 PersistMoniker_Release,
1745 PersistMoniker_GetClassID,
1746 PersistMoniker_IsDirty,
1747 PersistMoniker_Load,
1748 PersistMoniker_Save,
1749 PersistMoniker_SaveCompleted,
1750 PersistMoniker_GetCurMoniker
1753 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl };
1755 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
1759 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) {
1764 if(IsEqualGUID(&IID_IMarshal, riid))
1765 return E_NOINTERFACE;
1766 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid))
1767 return E_NOINTERFACE;
1769 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1773 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
1778 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
1783 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
1785 CHECK_EXPECT(CreateInstance);
1786 ok(!outer, "outer = %p\n", outer);
1787 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
1788 *ppv = &PersistMoniker;
1792 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
1794 ok(0, "unexpected call\n");
1798 static const IClassFactoryVtbl ClassFactoryVtbl = {
1799 ClassFactory_QueryInterface,
1800 ClassFactory_AddRef,
1801 ClassFactory_Release,
1802 ClassFactory_CreateInstance,
1803 ClassFactory_LockServer
1806 static IClassFactory mime_cf = { &ClassFactoryVtbl };
1808 static void test_CreateAsyncBindCtx(void)
1810 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
1816 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
1817 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1818 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
1820 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL);
1821 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
1823 SET_EXPECT(QueryInterface_IServiceProvider);
1824 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
1825 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
1826 CHECK_CALLED(QueryInterface_IServiceProvider);
1828 bindopts.cbStruct = sizeof(bindopts);
1829 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1830 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1831 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1832 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1833 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1834 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1836 ok(bindopts.dwTickCountDeadline == 0,
1837 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1839 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1840 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
1842 IUnknown_Release(unk);
1844 ref = IBindCtx_Release(bctx);
1845 ok(ref == 0, "bctx should be destroyed here\n");
1848 static void test_CreateAsyncBindCtxEx(void)
1850 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
1855 static WCHAR testW[] = {'t','e','s','t',0};
1857 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
1858 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
1860 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1861 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1863 if(SUCCEEDED(hres)) {
1864 bindopts.cbStruct = sizeof(bindopts);
1865 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1866 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1867 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1868 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1869 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1870 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1872 ok(bindopts.dwTickCountDeadline == 0,
1873 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1875 IBindCtx_Release(bctx);
1878 CreateBindCtx(0, &bctx_arg);
1879 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
1880 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1882 if(SUCCEEDED(hres)) {
1883 bindopts.cbStruct = sizeof(bindopts);
1884 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
1885 ok(SUCCEEDED(hres), "IBindCtx_GetBindOptions failed: %08x\n", hres);
1886 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
1887 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
1888 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
1889 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
1891 ok(bindopts.dwTickCountDeadline == 0,
1892 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
1894 IBindCtx_Release(bctx);
1897 IBindCtx_Release(bctx_arg);
1899 SET_EXPECT(QueryInterface_IServiceProvider);
1900 hres = CreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
1901 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1902 CHECK_CALLED(QueryInterface_IServiceProvider);
1904 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
1905 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
1907 IUnknown_Release(unk);
1909 IBindCtx_Release(bctx);
1911 hres = CreateBindCtx(0, &bctx2);
1912 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
1914 hres = CreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
1915 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
1917 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
1918 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
1920 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
1921 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
1922 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
1924 IBindCtx_Release(bctx);
1925 IBindCtx_Release(bctx2);
1928 static void test_GetBindInfoEx(IBindStatusCallback *holder)
1930 IBindStatusCallbackEx *bscex;
1931 BINDINFO bindinfo = {sizeof(bindinfo)};
1932 DWORD bindf, bindf2, dw;
1935 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
1937 win_skip("IBindStatusCallbackEx not supported\n");
1944 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1945 SET_EXPECT(GetBindInfoEx);
1946 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
1947 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1948 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1949 CHECK_CALLED(GetBindInfoEx);
1951 bindf = bindf2 = dw = 0;
1952 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1953 SET_EXPECT(GetBindInfoEx);
1954 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
1955 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1956 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1957 CHECK_CALLED(GetBindInfoEx);
1961 bindf = bindf2 = dw = 0xdeadbeef;
1962 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1963 SET_EXPECT(GetBindInfo);
1964 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
1965 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1966 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
1967 CHECK_CALLED(GetBindInfo);
1968 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
1969 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
1971 IBindStatusCallbackEx_Release(bscex);
1974 static BOOL test_bscholder(IBindStatusCallback *holder)
1976 IServiceProvider *serv_prov;
1977 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
1978 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
1979 IAuthenticate *authenticate, *authenticate_serv;
1980 IInternetProtocol *protocol;
1981 BINDINFO bindinfo = {sizeof(bindinfo)};
1987 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
1988 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
1991 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
1992 SET_EXPECT(GetBindInfo);
1993 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
1994 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1995 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
1996 CHECK_CALLED(GetBindInfo);
1998 test_GetBindInfoEx(holder);
2000 SET_EXPECT(OnStartBinding);
2001 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2002 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2003 CHECK_CALLED(OnStartBinding);
2005 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2006 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2008 SET_EXPECT(QueryInterface_IHttpNegotiate);
2009 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2010 (void**)&http_negotiate_serv);
2011 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2012 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2014 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2016 wstr = (void*)0xdeadbeef;
2017 SET_EXPECT(QueryInterface_IHttpNegotiate);
2018 SET_EXPECT(BeginningTransaction);
2019 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, urls[test_protocol], emptyW, 0, &wstr);
2020 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2021 CHECK_CALLED(BeginningTransaction);
2022 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2023 ok(wstr == NULL, "wstr = %p\n", wstr);
2025 IHttpNegotiate_Release(http_negotiate_serv);
2027 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2028 (void**)&http_negotiate_serv);
2029 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2030 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2031 IHttpNegotiate_Release(http_negotiate_serv);
2033 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2034 if(SUCCEEDED(hres)) {
2035 have_IHttpNegotiate2 = TRUE;
2037 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2038 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2039 (void**)&http_negotiate2_serv);
2040 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2041 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2042 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2044 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2045 SET_EXPECT(GetRootSecurityId);
2046 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2047 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2048 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2049 CHECK_CALLED(GetRootSecurityId);
2051 IHttpNegotiate_Release(http_negotiate2_serv);
2052 IHttpNegotiate_Release(http_negotiate2);
2054 skip("Could not get IHttpNegotiate2\n");
2058 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2059 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2060 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2061 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2063 SET_EXPECT(QueryInterface_IHttpNegotiate);
2064 SET_EXPECT(OnResponse);
2065 wstr = (void*)0xdeadbeef;
2066 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2067 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2068 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2069 CHECK_CALLED(OnResponse);
2071 IHttpNegotiate_Release(http_negotiate);
2073 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2074 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2076 SET_EXPECT(QueryInterface_IAuthenticate);
2077 SET_EXPECT(QueryService_IAuthenticate);
2078 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2079 (void**)&authenticate_serv);
2080 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2081 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2082 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2083 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2084 IAuthenticate_Release(authenticate_serv);
2086 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2087 (void**)&authenticate_serv);
2088 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2089 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2091 IAuthenticate_Release(authenticate);
2092 IAuthenticate_Release(authenticate_serv);
2094 SET_EXPECT(OnStopBinding);
2095 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2096 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2097 CHECK_CALLED(OnStopBinding);
2099 SET_EXPECT(QueryInterface_IInternetProtocol);
2100 SET_EXPECT(QueryService_IInternetProtocol);
2101 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2103 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2104 CHECK_CALLED(QueryInterface_IInternetProtocol);
2105 CHECK_CALLED(QueryService_IInternetProtocol);
2107 IServiceProvider_Release(serv_prov);
2111 static BOOL test_RegisterBindStatusCallback(void)
2113 IBindStatusCallback *prevbsc, *clb;
2119 hres = CreateBindCtx(0, &bindctx);
2120 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2122 SET_EXPECT(QueryInterface_IServiceProvider);
2124 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2125 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2127 SET_EXPECT(QueryInterface_IBindStatusCallback);
2128 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2129 prevbsc = (void*)0xdeadbeef;
2130 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2131 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2132 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2133 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2134 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2136 CHECK_CALLED(QueryInterface_IServiceProvider);
2138 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2139 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2141 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2142 IUnknown_Release(unk);
2143 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2144 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2146 if(!test_bscholder(clb))
2149 IBindStatusCallback_Release(clb);
2151 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc);
2152 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2154 unk = (void*)0xdeadbeef;
2155 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2156 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2157 ok(unk == NULL, "unk != NULL\n");
2160 IUnknown_Release(unk);
2162 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2163 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2165 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2166 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2168 hres = RevokeBindStatusCallback(bindctx, NULL);
2169 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2171 IBindCtx_Release(bindctx);
2175 #define BINDTEST_EMULATE 1
2176 #define BINDTEST_TOOBJECT 2
2177 #define BINDTEST_FILEDWLAPI 4
2179 static void init_bind_test(int protocol, DWORD flags, DWORD t)
2181 test_protocol = protocol;
2182 emulate_protocol = (flags & BINDTEST_EMULATE) != 0;
2183 download_state = BEFORE_DOWNLOAD;
2184 stopped_binding = FALSE;
2185 stopped_obj_binding = FALSE;
2186 data_available = FALSE;
2188 binding_hres = S_OK;
2189 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0;
2191 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0;
2194 static void test_BindToStorage(int protocol, BOOL emul, DWORD t)
2198 LPOLESTR display_name;
2201 IBindStatusCallback *previousclb;
2202 IUnknown *unk = (IUnknown*)0x00ff00ff;
2205 init_bind_test(protocol, emul ? BINDTEST_EMULATE : 0, t);
2207 SET_EXPECT(QueryInterface_IServiceProvider);
2208 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2209 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2210 CHECK_CALLED(QueryInterface_IServiceProvider);
2214 SET_EXPECT(QueryInterface_IServiceProvider);
2215 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2216 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2217 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2218 CHECK_CALLED(QueryInterface_IServiceProvider);
2220 IBindStatusCallback_Release(previousclb);
2222 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2223 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2225 IBindCtx_Release(bctx);
2229 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2230 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2232 IBinding_Release(bind);
2234 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2235 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2236 ok(!lstrcmpW(display_name, urls[test_protocol]),
2237 "GetDisplayName got wrong name %s\n", wine_dbgstr_w(display_name));
2238 CoTaskMemFree(display_name);
2240 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2241 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2243 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2244 SET_EXPECT(GetBindInfo);
2245 SET_EXPECT(QueryInterface_IInternetProtocol);
2246 if(!emulate_protocol)
2247 SET_EXPECT(QueryService_IInternetProtocol);
2248 SET_EXPECT(OnStartBinding);
2249 if(emulate_protocol) {
2250 if(is_urlmon_protocol(test_protocol))
2251 SET_EXPECT(SetPriority);
2253 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2254 SET_EXPECT(Terminate);
2255 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2256 SET_EXPECT(UnlockRequest);
2258 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2259 SET_EXPECT(QueryInterface_IInternetBindInfo);
2260 SET_EXPECT(QueryService_IInternetBindInfo);
2261 SET_EXPECT(QueryInterface_IHttpNegotiate);
2262 SET_EXPECT(BeginningTransaction);
2263 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2264 SET_EXPECT(GetRootSecurityId);
2265 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2266 SET_EXPECT(OnProgress_CONNECTING);
2268 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST
2269 || test_protocol == FILE_TEST)
2270 SET_EXPECT(OnProgress_SENDINGREQUEST);
2271 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2272 SET_EXPECT(QueryInterface_IHttpNegotiate);
2273 SET_EXPECT(OnResponse);
2275 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2276 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2277 if(test_protocol == FILE_TEST)
2278 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2279 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST)
2280 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2281 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2282 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2283 SET_EXPECT(OnDataAvailable);
2284 SET_EXPECT(OnStopBinding);
2287 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
2288 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2289 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2291 skip("Network unreachable, skipping tests\n");
2295 if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
2296 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
2297 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
2298 ok(unk == NULL, "istr should be NULL\n");
2299 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
2300 ok(hres == INET_E_DATA_NOT_AVAILABLE,
2301 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
2302 ok(unk == NULL, "istr should be NULL\n");
2304 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2305 ok(unk != NULL, "unk == NULL\n");
2308 IUnknown_Release(unk);
2313 while((bindf & BINDF_ASYNCHRONOUS) &&
2314 !stopped_binding && GetMessage(&msg,NULL,0,0)) {
2315 TranslateMessage(&msg);
2316 DispatchMessage(&msg);
2319 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2320 CHECK_CALLED(GetBindInfo);
2321 CHECK_CALLED(QueryInterface_IInternetProtocol);
2322 if(!emulate_protocol)
2323 CHECK_CALLED(QueryService_IInternetProtocol);
2324 CHECK_CALLED(OnStartBinding);
2325 if(emulate_protocol) {
2326 if(is_urlmon_protocol(test_protocol))
2327 CHECK_CALLED(SetPriority);
2328 CHECK_CALLED(Start);
2329 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2330 if(tymed == TYMED_FILE)
2332 CHECK_CALLED(Terminate);
2334 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
2335 CHECK_CALLED(UnlockRequest);
2337 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2338 CLEAR_CALLED(QueryInterface_IInternetBindInfo);
2339 CLEAR_CALLED(QueryService_IInternetBindInfo);
2340 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2341 CHECK_CALLED(BeginningTransaction);
2342 if (have_IHttpNegotiate2)
2344 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2345 CHECK_CALLED(GetRootSecurityId);
2347 if(http_is_first || test_protocol == HTTPS_TEST) {
2348 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2349 CHECK_CALLED(OnProgress_CONNECTING);
2351 CHECK_NOT_CALLED(OnProgress_FINDINGRESOURCE);
2352 /* IE7 does call this */
2353 CLEAR_CALLED(OnProgress_CONNECTING);
2356 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2357 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2358 else if(test_protocol == FTP_TEST)
2359 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
2360 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2361 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2362 CHECK_CALLED(OnResponse);
2364 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2365 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2366 if(test_protocol == FILE_TEST)
2367 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2368 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST)
2369 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2370 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2371 if(tymed != TYMED_FILE || test_protocol != ABOUT_TEST)
2372 CHECK_CALLED(OnDataAvailable);
2373 CHECK_CALLED(OnStopBinding);
2376 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2377 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2379 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2380 http_is_first = FALSE;
2383 static void test_BindToObject(int protocol, BOOL emul)
2387 LPOLESTR display_name;
2391 IUnknown *unk = (IUnknown*)0x00ff00ff;
2394 init_bind_test(protocol, BINDTEST_TOOBJECT | (emul ? BINDTEST_EMULATE : 0), TYMED_ISTREAM);
2397 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
2398 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id);
2400 SET_EXPECT(QueryInterface_IServiceProvider);
2401 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx);
2402 ok(SUCCEEDED(hres), "CreateAsyncBindCtx failed: %08x\n\n", hres);
2403 CHECK_CALLED(QueryInterface_IServiceProvider);
2407 hres = CreateURLMoniker(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol], &mon);
2408 ok(SUCCEEDED(hres), "failed to create moniker: %08x\n", hres);
2410 IBindCtx_Release(bctx);
2414 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2415 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2417 IBinding_Release(bind);
2419 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2420 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2421 ok(!lstrcmpW(display_name, urls[test_protocol]), "GetDisplayName got wrong name\n");
2423 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2424 SET_EXPECT(Obj_GetBindInfo);
2425 SET_EXPECT(QueryInterface_IInternetProtocol);
2426 if(!emulate_protocol)
2427 SET_EXPECT(QueryService_IInternetProtocol);
2428 SET_EXPECT(Obj_OnStartBinding);
2429 if(emulate_protocol) {
2430 if(is_urlmon_protocol(test_protocol))
2431 SET_EXPECT(SetPriority);
2433 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2434 SET_EXPECT(Terminate);
2435 if(test_protocol == FILE_TEST)
2436 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2437 SET_EXPECT(UnlockRequest);
2439 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2440 SET_EXPECT(QueryInterface_IHttpNegotiate);
2441 SET_EXPECT(BeginningTransaction);
2442 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2443 SET_EXPECT(GetRootSecurityId);
2444 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
2445 SET_EXPECT(Obj_OnProgress_CONNECTING);
2447 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2448 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
2449 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2450 SET_EXPECT(QueryInterface_IHttpNegotiate);
2451 SET_EXPECT(OnResponse);
2453 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
2454 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
2455 if(test_protocol == FILE_TEST)
2456 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2457 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2458 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2459 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
2460 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
2461 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
2462 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
2463 SET_EXPECT(OnObjectAvailable);
2464 SET_EXPECT(Obj_OnStopBinding);
2467 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk);
2469 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2470 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED))
2472 skip( "Network unreachable, skipping tests\n" );
2476 /* no point testing the calls if binding didn't even work */
2477 if (FAILED(hres)) return;
2479 if(bindf & BINDF_ASYNCHRONOUS) {
2480 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres);
2481 ok(unk == NULL, "istr should be NULL\n");
2483 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
2484 ok(unk != NULL, "unk == NULL\n");
2486 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n");
2489 IUnknown_Release(unk);
2491 while((bindf & BINDF_ASYNCHRONOUS) &&
2492 !((!emul || stopped_binding) && stopped_obj_binding) && GetMessage(&msg,NULL,0,0)) {
2493 TranslateMessage(&msg);
2494 DispatchMessage(&msg);
2497 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx);
2498 CHECK_CALLED(Obj_GetBindInfo);
2499 CHECK_CALLED(QueryInterface_IInternetProtocol);
2500 if(!emulate_protocol)
2501 CHECK_CALLED(QueryService_IInternetProtocol);
2502 CHECK_CALLED(Obj_OnStartBinding);
2503 if(emulate_protocol) {
2504 if(is_urlmon_protocol(test_protocol))
2505 CHECK_CALLED(SetPriority);
2506 CHECK_CALLED(Start);
2507 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2508 CHECK_CALLED(Terminate);
2509 if(test_protocol == FILE_TEST)
2510 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
2511 CHECK_CALLED(UnlockRequest);
2513 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2514 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2515 CHECK_CALLED(BeginningTransaction);
2516 if (have_IHttpNegotiate2)
2518 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2519 CHECK_CALLED(GetRootSecurityId);
2522 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2523 CHECK_CALLED(Obj_OnProgress_CONNECTING);
2525 CHECK_NOT_CALLED(Obj_OnProgress_FINDINGRESOURCE);
2526 /* IE7 does call this */
2527 CLEAR_CALLED(Obj_OnProgress_CONNECTING);
2530 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) {
2531 if(urls[test_protocol] == SHORT_RESPONSE_URL)
2532 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST);
2534 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
2536 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2537 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2538 CHECK_CALLED(OnResponse);
2540 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
2541 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
2542 if(test_protocol == FILE_TEST)
2543 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
2544 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2545 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2546 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
2547 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
2548 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
2549 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
2550 CHECK_CALLED(OnObjectAvailable);
2551 CHECK_CALLED(Obj_OnStopBinding);
2554 if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL || !(bindf & BINDF_ASYNCHRONOUS)) {
2555 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2556 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
2558 todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
2559 IBindCtx_Release(bctx);
2563 CoRevokeClassObject(regid);
2565 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2566 http_is_first = FALSE;
2569 static void test_URLDownloadToFile(DWORD prot, BOOL emul)
2574 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE);
2576 SET_EXPECT(GetBindInfo);
2577 SET_EXPECT(QueryInterface_IInternetProtocol);
2578 if(!emulate_protocol) {
2579 SET_EXPECT(QueryInterface_IServiceProvider);
2580 SET_EXPECT(QueryService_IInternetProtocol);
2582 SET_EXPECT(OnStartBinding);
2583 if(emulate_protocol) {
2584 if(is_urlmon_protocol(test_protocol))
2585 SET_EXPECT(SetPriority);
2587 SET_EXPECT(UnlockRequest);
2589 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2590 SET_EXPECT(QueryInterface_IHttpNegotiate);
2591 SET_EXPECT(BeginningTransaction);
2592 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2593 SET_EXPECT(GetRootSecurityId);
2595 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST)
2596 SET_EXPECT(OnProgress_SENDINGREQUEST);
2597 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2598 SET_EXPECT(QueryInterface_IHttpNegotiate);
2599 SET_EXPECT(OnResponse);
2601 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
2602 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2603 if(test_protocol == FILE_TEST)
2604 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2605 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2606 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
2607 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2608 SET_EXPECT(OnStopBinding);
2611 hres = URLDownloadToFileW(NULL, test_protocol == FILE_TEST ? file_url : urls[test_protocol],
2612 dwl_htmlW, 0, (IBindStatusCallback*)&bsc);
2613 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2615 CHECK_CALLED(GetBindInfo);
2616 CHECK_CALLED(QueryInterface_IInternetProtocol);
2617 if(!emulate_protocol) {
2618 CHECK_CALLED(QueryInterface_IServiceProvider);
2619 CHECK_CALLED(QueryService_IInternetProtocol);
2621 CHECK_CALLED(OnStartBinding);
2622 if(emulate_protocol) {
2623 if(is_urlmon_protocol(test_protocol))
2624 CHECK_CALLED(SetPriority);
2625 CHECK_CALLED(Start);
2626 CHECK_CALLED(UnlockRequest);
2628 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2629 CHECK_CALLED(QueryInterface_IHttpNegotiate);
2630 CHECK_CALLED(BeginningTransaction);
2631 if (have_IHttpNegotiate2)
2633 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
2634 CHECK_CALLED(GetRootSecurityId);
2637 if(test_protocol == FILE_TEST)
2638 CHECK_CALLED(OnProgress_SENDINGREQUEST);
2639 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2640 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */
2641 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) {
2642 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
2643 CHECK_CALLED(OnResponse);
2645 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
2646 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2647 if(test_protocol == FILE_TEST)
2648 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2649 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST)
2650 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
2651 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2652 CHECK_CALLED(OnStopBinding);
2655 res = DeleteFileA(dwl_htmlA);
2656 ok(res, "DeleteFile failed: %u\n", GetLastError());
2658 if(prot != FILE_TEST || emul)
2661 hres = URLDownloadToFileW(NULL, urls[test_protocol], dwl_htmlW, 0, NULL);
2662 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres);
2664 res = DeleteFileA(dwl_htmlA);
2665 ok(res, "DeleteFile failed: %u\n", GetLastError());
2668 static void set_file_url(char *path)
2670 CHAR file_urlA[INTERNET_MAX_URL_LENGTH];
2671 CHAR INDEX_HTMLA[MAX_PATH];
2673 lstrcpyA(file_urlA, "file:///");
2674 lstrcatA(file_urlA, path);
2675 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH);
2677 lstrcpyA(INDEX_HTMLA, "file://");
2678 lstrcatA(INDEX_HTMLA, path);
2679 MultiByteToWideChar(CP_ACP, 0, INDEX_HTMLA, -1, INDEX_HTML, MAX_PATH);
2682 static void create_file(void)
2686 CHAR path[MAX_PATH];
2688 static const char html_doc[] = "<HTML></HTML>";
2690 file = CreateFileA(wszIndexHtmlA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2691 FILE_ATTRIBUTE_NORMAL, NULL);
2692 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2693 if(file == INVALID_HANDLE_VALUE)
2696 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2699 GetCurrentDirectoryA(MAX_PATH, path);
2700 lstrcatA(path, "\\");
2701 lstrcatA(path, wszIndexHtmlA);
2705 static void test_ReportResult(HRESULT exhres)
2707 IMoniker *mon = NULL;
2708 IBindCtx *bctx = NULL;
2709 IUnknown *unk = (void*)0xdeadbeef;
2712 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);
2713 binding_hres = exhres;
2715 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2716 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2718 SET_EXPECT(QueryInterface_IServiceProvider);
2719 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx);
2720 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2721 CHECK_CALLED(QueryInterface_IServiceProvider);
2723 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2724 SET_EXPECT(GetBindInfo);
2725 SET_EXPECT(QueryInterface_IInternetProtocol);
2726 SET_EXPECT(OnStartBinding);
2727 if(is_urlmon_protocol(test_protocol))
2728 SET_EXPECT(SetPriority);
2731 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2732 if(SUCCEEDED(exhres))
2733 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres);
2735 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS,
2736 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres);
2738 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2739 CHECK_CALLED(GetBindInfo);
2740 CHECK_CALLED(QueryInterface_IInternetProtocol);
2741 CHECK_CALLED(OnStartBinding);
2742 if(is_urlmon_protocol(test_protocol))
2743 CHECK_CALLED(SetPriority);
2744 CHECK_CALLED(Start);
2746 ok(unk == NULL, "unk=%p\n", unk);
2748 IBindCtx_Release(bctx);
2749 IMoniker_Release(mon);
2752 static void test_BindToStorage_fail(void)
2754 IMoniker *mon = NULL;
2755 IBindCtx *bctx = NULL;
2759 hres = CreateURLMoniker(NULL, ABOUT_BLANK, &mon);
2760 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres);
2764 hres = CreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2765 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2767 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk);
2768 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE,
2769 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres);
2771 IBindCtx_Release(bctx);
2773 IMoniker_Release(mon);
2775 test_ReportResult(E_NOTIMPL);
2776 test_ReportResult(S_FALSE);
2779 static void test_StdURLMoniker(void)
2781 IMoniker *mon, *async_mon;
2782 LPOLESTR display_name;
2785 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2786 &IID_IMoniker, (void**)&mon);
2787 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres);
2791 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon);
2792 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres);
2793 ok(mon == async_mon, "mon != async_mon\n");
2794 IMoniker_Release(async_mon);
2796 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name);
2797 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres);
2799 IMoniker_Release(mon);
2802 static void gecko_installer_workaround(BOOL disable)
2807 static BOOL has_url = FALSE;
2808 static char url[2048];
2810 if(!disable && !has_url)
2813 res = RegOpenKey(HKEY_CURRENT_USER, "Software\\Wine\\MSHTML", &hkey);
2814 if(res != ERROR_SUCCESS)
2818 DWORD type, size = sizeof(url);
2820 res = RegQueryValueEx(hkey, "GeckoUrl", NULL, &type, (PVOID)url, &size);
2821 if(res == ERROR_SUCCESS && type == REG_SZ)
2824 RegDeleteValue(hkey, "GeckoUrl");
2826 RegSetValueEx(hkey, "GeckoUrl", 0, REG_SZ, (PVOID)url, lstrlenA(url)+1);
2834 gecko_installer_workaround(TRUE);
2836 complete_event = CreateEvent(NULL, FALSE, FALSE, NULL);
2837 complete_event2 = CreateEvent(NULL, FALSE, FALSE, NULL);
2838 thread_id = GetCurrentThreadId();
2843 trace("test CreateAsyncBindCtx...\n");
2844 test_CreateAsyncBindCtx();
2846 trace("test CreateAsyncBindCtxEx...\n");
2847 test_CreateAsyncBindCtxEx();
2849 trace("test RegisterBindStatusCallback...\n");
2850 if(test_RegisterBindStatusCallback()) {
2851 trace("test BindToStorage failures...\n");
2852 test_BindToStorage_fail();
2854 trace("synchronous http test (COM not initialised)...\n");
2855 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2859 trace("test StdURLMoniker...\n");
2860 test_StdURLMoniker();
2862 trace("synchronous http test...\n");
2863 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2865 trace("synchronous http test (to object)...\n");
2866 test_BindToObject(HTTP_TEST, FALSE);
2868 trace("synchronous file test...\n");
2869 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2871 trace("synchronous file test (to object)...\n");
2872 test_BindToObject(FILE_TEST, FALSE);
2874 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2876 trace("http test...\n");
2877 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2879 trace("http test (to file)...\n");
2880 test_BindToStorage(HTTP_TEST, FALSE, TYMED_FILE);
2882 trace("http test (to object)...\n");
2883 test_BindToObject(HTTP_TEST, FALSE);
2885 trace("http test (short response)...\n");
2886 http_is_first = TRUE;
2887 urls[HTTP_TEST] = SHORT_RESPONSE_URL;
2888 test_BindToStorage(HTTP_TEST, FALSE, TYMED_ISTREAM);
2890 trace("http test (short response, to object)...\n");
2891 test_BindToObject(HTTP_TEST, FALSE);
2893 trace("emulated http test...\n");
2894 test_BindToStorage(HTTP_TEST, TRUE, TYMED_ISTREAM);
2896 trace("emulated http test (to object)...\n");
2897 test_BindToObject(HTTP_TEST, TRUE);
2899 trace("emulated http test (to file)...\n");
2900 test_BindToStorage(HTTP_TEST, TRUE, TYMED_FILE);
2902 trace("asynchronous https test...\n");
2903 test_BindToStorage(HTTPS_TEST, FALSE, TYMED_ISTREAM);
2905 trace("emulated https test...\n");
2906 test_BindToStorage(HTTPS_TEST, TRUE, TYMED_ISTREAM);
2908 trace("about test...\n");
2909 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_ISTREAM);
2911 trace("about test (to file)...\n");
2912 test_BindToStorage(ABOUT_TEST, FALSE, TYMED_FILE);
2914 trace("about test (to object)...\n");
2915 test_BindToObject(ABOUT_TEST, FALSE);
2917 trace("emulated about test...\n");
2918 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_ISTREAM);
2920 trace("emulated about test (to file)...\n");
2921 test_BindToStorage(ABOUT_TEST, TRUE, TYMED_FILE);
2923 trace("emulated about test (to object)...\n");
2924 test_BindToObject(ABOUT_TEST, TRUE);
2926 trace("file test...\n");
2927 test_BindToStorage(FILE_TEST, FALSE, TYMED_ISTREAM);
2929 trace("file test (to file)...\n");
2930 test_BindToStorage(FILE_TEST, FALSE, TYMED_FILE);
2932 trace("file test (to object)...\n");
2933 test_BindToObject(FILE_TEST, FALSE);
2935 trace("emulated file test...\n");
2936 test_BindToStorage(FILE_TEST, TRUE, TYMED_ISTREAM);
2938 trace("emulated file test (to file)...\n");
2939 test_BindToStorage(FILE_TEST, TRUE, TYMED_FILE);
2941 trace("emulated file test (to object)...\n");
2942 test_BindToObject(FILE_TEST, TRUE);
2944 trace("emulated its test...\n");
2945 test_BindToStorage(ITS_TEST, TRUE, TYMED_ISTREAM);
2947 trace("emulated its test (to file)...\n");
2948 test_BindToStorage(ITS_TEST, TRUE, TYMED_FILE);
2950 trace("emulated mk test...\n");
2951 test_BindToStorage(MK_TEST, TRUE, TYMED_ISTREAM);
2953 trace("test URLDownloadToFile for file protocol...\n");
2954 test_URLDownloadToFile(FILE_TEST, FALSE);
2956 trace("test URLDownloadToFile for emulated file protocol...\n");
2957 test_URLDownloadToFile(FILE_TEST, TRUE);
2959 trace("test URLDownloadToFile for http protocol...\n");
2960 test_URLDownloadToFile(HTTP_TEST, FALSE);
2962 bindf |= BINDF_NOWRITECACHE;
2964 trace("ftp test...\n");
2965 test_BindToStorage(FTP_TEST, FALSE, TYMED_ISTREAM);
2967 trace("test failures...\n");
2968 test_BindToStorage_fail();
2971 DeleteFileA(wszIndexHtmlA);
2972 CloseHandle(complete_event);
2973 CloseHandle(complete_event2);
2976 gecko_installer_workaround(FALSE);