2 * Copyright 2005-2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <wine/test.h>
32 static HRESULT (WINAPI *pCoInternetGetSession)(DWORD, IInternetSession **, DWORD);
33 static HRESULT (WINAPI *pReleaseBindInfo)(BINDINFO*);
34 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
36 #define DEFINE_EXPECT(func) \
37 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
39 #define SET_EXPECT(func) \
40 expect_ ## func = TRUE
42 #define CHECK_EXPECT2(func) \
44 ok(expect_ ##func, "unexpected call " #func "\n"); \
45 called_ ## func = TRUE; \
48 #define CHECK_EXPECT(func) \
50 CHECK_EXPECT2(func); \
51 expect_ ## func = FALSE; \
54 #define CHECK_CALLED(func) \
56 ok(called_ ## func, "expected " #func "\n"); \
57 expect_ ## func = called_ ## func = FALSE; \
60 #define CHECK_NOT_CALLED(func) \
62 ok(!called_ ## func, "unexpected " #func "\n"); \
63 expect_ ## func = called_ ## func = FALSE; \
66 #define CLEAR_CALLED(func) \
67 expect_ ## func = called_ ## func = FALSE
69 DEFINE_EXPECT(GetBindInfo);
70 DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
71 DEFINE_EXPECT(ReportProgress_DIRECTBIND);
72 DEFINE_EXPECT(ReportProgress_RAWMIMETYPE);
73 DEFINE_EXPECT(ReportProgress_FINDINGRESOURCE);
74 DEFINE_EXPECT(ReportProgress_CONNECTING);
75 DEFINE_EXPECT(ReportProgress_SENDINGREQUEST);
76 DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
77 DEFINE_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
78 DEFINE_EXPECT(ReportProgress_PROTOCOLCLASSID);
79 DEFINE_EXPECT(ReportProgress_COOKIE_SENT);
80 DEFINE_EXPECT(ReportProgress_REDIRECTING);
81 DEFINE_EXPECT(ReportProgress_ENCODING);
82 DEFINE_EXPECT(ReportProgress_ACCEPTRANGES);
83 DEFINE_EXPECT(ReportProgress_PROXYDETECTING);
84 DEFINE_EXPECT(ReportProgress_LOADINGMIMEHANDLER);
85 DEFINE_EXPECT(ReportProgress_DECODING);
86 DEFINE_EXPECT(ReportData);
87 DEFINE_EXPECT(ReportData2);
88 DEFINE_EXPECT(ReportResult);
89 DEFINE_EXPECT(GetBindString_ACCEPT_MIMES);
90 DEFINE_EXPECT(GetBindString_USER_AGENT);
91 DEFINE_EXPECT(GetBindString_POST_COOKIE);
92 DEFINE_EXPECT(GetBindString_URL);
93 DEFINE_EXPECT(QueryService_HttpNegotiate);
94 DEFINE_EXPECT(QueryService_InternetProtocol);
95 DEFINE_EXPECT(QueryService_HttpSecurity);
96 DEFINE_EXPECT(QueryInterface_IWinInetInfo);
97 DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo);
98 DEFINE_EXPECT(BeginningTransaction);
99 DEFINE_EXPECT(GetRootSecurityId);
100 DEFINE_EXPECT(OnResponse);
101 DEFINE_EXPECT(Switch);
102 DEFINE_EXPECT(Continue);
103 DEFINE_EXPECT(CreateInstance);
104 DEFINE_EXPECT(Start);
105 DEFINE_EXPECT(StartEx);
106 DEFINE_EXPECT(Terminate);
108 DEFINE_EXPECT(Read2);
109 DEFINE_EXPECT(SetPriority);
110 DEFINE_EXPECT(LockRequest);
111 DEFINE_EXPECT(UnlockRequest);
112 DEFINE_EXPECT(Abort);
113 DEFINE_EXPECT(MimeFilter_CreateInstance);
114 DEFINE_EXPECT(MimeFilter_Start);
115 DEFINE_EXPECT(MimeFilter_ReportProgress);
116 DEFINE_EXPECT(MimeFilter_ReportData);
117 DEFINE_EXPECT(MimeFilter_ReportResult);
118 DEFINE_EXPECT(MimeFilter_Terminate);
119 DEFINE_EXPECT(MimeFilter_LockRequest);
120 DEFINE_EXPECT(MimeFilter_UnlockRequest);
121 DEFINE_EXPECT(MimeFilter_Read);
122 DEFINE_EXPECT(MimeFilter_Switch);
123 DEFINE_EXPECT(MimeFilter_Continue);
124 DEFINE_EXPECT(Stream_Seek);
125 DEFINE_EXPECT(Stream_Read);
127 static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
128 static const WCHAR index_url[] =
129 {'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0};
131 static const WCHAR acc_mimeW[] = {'*','/','*',0};
132 static const WCHAR user_agentW[] = {'W','i','n','e',0};
133 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
134 static const WCHAR hostW[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
135 static const WCHAR winehq_ipW[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0};
136 static const WCHAR emptyW[] = {0};
137 static const WCHAR gzipW[] = {'g','z','i','p',0};
139 static HRESULT expect_hrResult;
140 static LPCWSTR file_name, http_url, expect_wsz;
141 static IInternetProtocol *async_protocol = NULL;
142 static BOOL first_data_notif, http_is_first, test_redirect;
143 static int prot_state, read_report_data, post_stream_read;
144 static DWORD bindf, ex_priority , pi;
145 static IInternetProtocol *binding_protocol, *filtered_protocol;
146 static IInternetBindInfo *prot_bind_info;
147 static IInternetProtocolSink *binding_sink, *filtered_sink;
148 static void *expect_pv;
149 static HANDLE event_complete, event_complete2, event_continue, event_continue_done;
150 static BOOL binding_test;
151 static PROTOCOLDATA protocoldata, *pdata, continue_protdata;
152 static DWORD prot_read, pi, filter_state, http_post_test, thread_id;
153 static BOOL security_problem, test_async_req, impl_protex;
154 static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort;
158 STATE_SENDINGREQUEST,
159 STATE_STARTDOWNLOADING,
173 static const WCHAR protocol_names[][10] = {
176 {'h','t','t','p','s',0},
183 static const WCHAR binding_urls[][130] = {
184 {'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0},
185 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
186 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0},
187 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
188 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0},
189 {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
190 '/','p','u','b','/','o','t','h','e','r',
191 '/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0},
192 {'m','k',':','t','e','s','t',0},
193 {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0},
194 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}
197 static const CHAR post_data[] = "mode=Test";
199 static const char *debugstr_guid(REFIID riid)
203 sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
204 riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
205 riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
206 riid->Data4[5], riid->Data4[6], riid->Data4[7]);
211 static int strcmp_wa(LPCWSTR strw, const char *stra)
214 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
215 return lstrcmpA(stra, buf);
218 /* lstrcmpW is not implemented on Win9x */
219 static int strcmp_ww(LPCWSTR strw1, LPCWSTR strw2)
221 CHAR stra1[512], stra2[512];
222 WideCharToMultiByte(CP_ACP, 0, strw1, -1, stra1, MAX_PATH, NULL, NULL);
223 WideCharToMultiByte(CP_ACP, 0, strw2, -1, stra2, MAX_PATH, NULL, NULL);
224 return lstrcmpA(stra1, stra2);
227 static BOOL proxy_active(void)
229 HKEY internet_settings;
233 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
234 0, KEY_QUERY_VALUE, &internet_settings) != ERROR_SUCCESS)
237 size = sizeof(DWORD);
238 if (RegQueryValueExA(internet_settings, "ProxyEnable", NULL, NULL, (LPBYTE) &proxy_enable, &size) != ERROR_SUCCESS)
241 RegCloseKey(internet_settings);
243 return proxy_enable != 0;
246 static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv)
248 if(IsEqualGUID(&IID_IUnknown, riid)
249 || IsEqualGUID(&IID_IHttpSecurity, riid)) {
254 ok(0, "unexpected call\n");
255 return E_NOINTERFACE;
258 static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface)
263 static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface)
268 static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity* iface, REFGUID rguidReason, HWND *phwnd)
270 trace("HttpSecurity_GetWindow\n");
275 static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem)
277 trace("Security problem: %u\n", dwProblem);
278 ok(dwProblem == ERROR_INTERNET_SEC_CERT_REV_FAILED, "Expected ERROR_INTERNET_SEC_CERT_REV_FAILED got %u\n", dwProblem);
280 /* Only retry once */
281 if (security_problem)
284 security_problem = TRUE;
285 SET_EXPECT(BeginningTransaction);
290 static IHttpSecurityVtbl HttpSecurityVtbl = {
291 HttpSecurity_QueryInterface,
293 HttpSecurity_Release,
294 HttpSecurity_GetWindow,
295 HttpSecurity_OnSecurityProblem
298 static IHttpSecurity http_security = { &HttpSecurityVtbl };
300 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv)
302 if(IsEqualGUID(&IID_IUnknown, riid)
303 || IsEqualGUID(&IID_IHttpNegotiate, riid)
304 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
309 ok(0, "unexpected call\n");
310 return E_NOINTERFACE;
313 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface)
318 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface)
323 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL,
324 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
328 static const WCHAR wszHeaders[] =
329 {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t',
330 'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o',
331 'd','e','d','\r','\n',0};
333 CHECK_EXPECT(BeginningTransaction);
336 ok(!strcmp_ww(szURL, binding_urls[tested_protocol]), "szURL != http_url\n");
338 ok(!strcmp_ww(szURL, http_url), "szURL != http_url\n");
339 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
340 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
341 if(pszAdditionalHeaders)
343 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
346 addl_headers = CoTaskMemAlloc(sizeof(wszHeaders));
347 memcpy(addl_headers, wszHeaders, sizeof(wszHeaders));
348 *pszAdditionalHeaders = addl_headers;
355 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode,
356 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
358 CHECK_EXPECT(OnResponse);
360 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
361 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
362 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
363 ok(pszAdditionalRequestHeaders == NULL, "pszAdditionalHeaders != NULL\n");
368 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface,
369 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
371 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
373 CHECK_EXPECT(GetRootSecurityId);
375 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
376 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
377 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
380 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
381 *pcbSecurityId = sizeof(sec_id);
385 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
390 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
391 HttpNegotiate_QueryInterface,
392 HttpNegotiate_AddRef,
393 HttpNegotiate_Release,
394 HttpNegotiate_BeginningTransaction,
395 HttpNegotiate_OnResponse,
396 HttpNegotiate_GetRootSecurityId
399 static IHttpNegotiate2 http_negotiate = { &HttpNegotiateVtbl };
401 static HRESULT QueryInterface(REFIID,void**);
403 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
405 return QueryInterface(riid, ppv);
408 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface)
413 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface)
418 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService,
419 REFIID riid, void **ppv)
421 if(IsEqualGUID(&IID_IHttpNegotiate, guidService) || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
422 CHECK_EXPECT2(QueryService_HttpNegotiate);
423 return IHttpNegotiate2_QueryInterface(&http_negotiate, riid, ppv);
426 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
427 ok(IsEqualGUID(&IID_IInternetProtocol, riid), "unexpected riid\n");
428 CHECK_EXPECT(QueryService_InternetProtocol);
429 return E_NOINTERFACE;
432 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
433 ok(IsEqualGUID(&IID_IHttpSecurity, riid), "unexpected riid\n");
434 CHECK_EXPECT(QueryService_HttpSecurity);
435 return IHttpSecurity_QueryInterface(&http_security, riid, ppv);
438 ok(0, "unexpected service %s\n", debugstr_guid(guidService));
442 static const IServiceProviderVtbl ServiceProviderVtbl = {
443 ServiceProvider_QueryInterface,
444 ServiceProvider_AddRef,
445 ServiceProvider_Release,
446 ServiceProvider_QueryService
449 static IServiceProvider service_provider = { &ServiceProviderVtbl };
451 static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv)
453 ok(0, "unexpected call\n");
454 return E_NOINTERFACE;
457 static ULONG WINAPI Stream_AddRef(IStream *iface)
462 static ULONG WINAPI Stream_Release(IStream *iface)
467 static HRESULT WINAPI Stream_Read(IStream *iface, void *pv,
468 ULONG cb, ULONG *pcbRead)
470 CHECK_EXPECT2(Stream_Read);
472 ok(GetCurrentThreadId() != thread_id, "wrong thread %d\n", GetCurrentThreadId());
474 ok(pv != NULL, "pv == NULL\n");
475 ok(cb == 0x20000 || broken(cb == 0x2000), "cb = %d\n", cb);
476 ok(pcbRead != NULL, "pcbRead == NULL\n");
478 if(post_stream_read) {
483 memcpy(pv, post_data, sizeof(post_data)-1);
484 post_stream_read += *pcbRead = sizeof(post_data)-1;
488 static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv,
489 ULONG cb, ULONG *pcbWritten)
491 ok(0, "unexpected call\n");
495 static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove,
496 DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
498 CHECK_EXPECT(Stream_Seek);
500 ok(!dlibMove.QuadPart, "dlibMove != 0\n");
501 ok(dwOrigin == STREAM_SEEK_SET, "dwOrigin = %d\n", dwOrigin);
502 ok(!plibNewPosition, "plibNewPosition == NULL\n");
507 static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
509 ok(0, "unexpected call\n");
513 static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm,
514 ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
516 ok(0, "unexpected call\n");
520 static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags)
522 ok(0, "unexpected call\n");
526 static HRESULT WINAPI Stream_Revert(IStream *iface)
528 ok(0, "unexpected call\n");
532 static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
533 ULARGE_INTEGER cb, DWORD dwLockType)
535 ok(0, "unexpected call\n");
539 static HRESULT WINAPI Stream_UnlockRegion(IStream *iface,
540 ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
542 ok(0, "unexpected call\n");
546 static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg,
549 ok(0, "unexpected call\n");
553 static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm)
555 ok(0, "unexpected call\n");
559 static const IStreamVtbl StreamVtbl = {
560 Stream_QueryInterface,
576 static IStream Stream = { &StreamVtbl };
578 static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
580 return QueryInterface(riid, ppv);
583 static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
588 static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
593 static void call_continue(PROTOCOLDATA *protocol_data)
597 if(state == STATE_CONNECTING) {
598 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST)
599 CLEAR_CALLED(ReportProgress_COOKIE_SENT);
600 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST) {
602 CLEAR_CALLED(ReportProgress_FINDINGRESOURCE);
603 CLEAR_CALLED(ReportProgress_CONNECTING);
604 CLEAR_CALLED(ReportProgress_PROXYDETECTING);
605 }else if(test_redirect) {
606 if (! proxy_active())
607 CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
609 CLEAR_CALLED(ReportProgress_FINDINGRESOURCE);
611 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE);
612 /* IE7 does call this */
613 CLEAR_CALLED(ReportProgress_CONNECTING);
616 if(tested_protocol == FTP_TEST)
617 todo_wine CHECK_CALLED(ReportProgress_SENDINGREQUEST);
618 else if (tested_protocol != HTTPS_TEST)
619 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
621 CHECK_CALLED(ReportProgress_REDIRECTING);
622 state = test_async_req ? STATE_SENDINGREQUEST : STATE_STARTDOWNLOADING;
626 case STATE_SENDINGREQUEST:
627 SET_EXPECT(Stream_Read);
628 SET_EXPECT(ReportProgress_SENDINGREQUEST);
630 case STATE_STARTDOWNLOADING:
631 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
632 SET_EXPECT(OnResponse);
633 if(tested_protocol == HTTPS_TEST || test_redirect || test_abort)
634 SET_EXPECT(ReportProgress_ACCEPTRANGES);
635 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
636 if(bindf & BINDF_NEEDFILE)
637 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
643 if(state != STATE_SENDINGREQUEST)
644 SET_EXPECT(ReportData);
645 hres = IInternetProtocol_Continue(async_protocol, protocol_data);
646 ok(hres == S_OK, "Continue failed: %08x\n", hres);
647 if(tested_protocol == FTP_TEST || security_problem)
648 CLEAR_CALLED(ReportData);
649 else if(state != STATE_SENDINGREQUEST)
650 CHECK_CALLED(ReportData);
653 case STATE_SENDINGREQUEST:
654 CHECK_CALLED(Stream_Read);
655 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
656 state = STATE_STARTDOWNLOADING;
658 case STATE_STARTDOWNLOADING:
659 if (! security_problem)
661 state = STATE_DOWNLOADING;
662 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
663 CHECK_CALLED(OnResponse);
664 if(tested_protocol == HTTPS_TEST || test_abort)
665 CHECK_CALLED(ReportProgress_ACCEPTRANGES);
666 else if(test_redirect)
667 CLEAR_CALLED(ReportProgress_ACCEPTRANGES);
668 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
669 if(bindf & BINDF_NEEDFILE)
670 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
675 security_problem = FALSE;
676 SET_EXPECT(ReportProgress_CONNECTING);
683 static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
685 if(tested_protocol == FTP_TEST)
686 CHECK_EXPECT2(Switch);
688 CHECK_EXPECT(Switch);
690 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
692 ok(pProtocolData != &protocoldata, "pProtocolData == &protocoldata\n");
693 ok(pProtocolData->grfFlags == protocoldata.grfFlags, "grfFlags wrong %x/%x\n",
694 pProtocolData->grfFlags, protocoldata.grfFlags );
695 ok(pProtocolData->dwState == protocoldata.dwState, "dwState wrong %x/%x\n",
696 pProtocolData->dwState, protocoldata.dwState );
697 ok(pProtocolData->pData == protocoldata.pData, "pData wrong %p/%p\n",
698 pProtocolData->pData, protocoldata.pData );
699 ok(pProtocolData->cbData == protocoldata.cbData, "cbData wrong %x/%x\n",
700 pProtocolData->cbData, protocoldata.cbData );
703 pdata = pProtocolData;
706 SetEvent(event_complete);
707 WaitForSingleObject(event_complete2, INFINITE);
710 continue_protdata = *pProtocolData;
711 SetEvent(event_continue);
712 WaitForSingleObject(event_continue_done, INFINITE);
714 call_continue(pProtocolData);
715 SetEvent(event_complete);
721 static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
722 LPCWSTR szStatusText)
724 static const WCHAR null_guid[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-',
725 '0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
726 static const WCHAR text_plain[] = {'t','e','x','t','/','p','l','a','i','n',0};
728 switch(ulStatusCode) {
729 case BINDSTATUS_MIMETYPEAVAILABLE:
730 CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
731 if(tested_protocol != FILE_TEST && tested_protocol != ITS_TEST && !mimefilter_test && (pi & PI_MIMEVERIFICATION)) {
732 if(!short_read || !direct_read)
733 CHECK_CALLED(Read); /* set in Continue */
735 CHECK_CALLED(Read2); /* set in Read */
737 ok(szStatusText != NULL, "szStatusText == NULL\n");
739 if(tested_protocol == BIND_TEST)
740 ok(szStatusText == expect_wsz, "unexpected szStatusText\n");
741 else if (http_post_test)
742 ok(lstrlenW(text_plain) <= lstrlenW(szStatusText) &&
743 !memcmp(szStatusText, text_plain, lstrlenW(text_plain)*sizeof(WCHAR)),
744 "szStatusText != text/plain\n");
745 else if(!mimefilter_test)
746 ok(lstrlenW(text_htmlW) <= lstrlenW(szStatusText) &&
747 !memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)),
748 "szStatusText != text/html\n");
751 case BINDSTATUS_DIRECTBIND:
752 CHECK_EXPECT2(ReportProgress_DIRECTBIND);
753 ok(szStatusText == NULL, "szStatusText != NULL\n");
755 case BINDSTATUS_RAWMIMETYPE:
756 CHECK_EXPECT2(ReportProgress_RAWMIMETYPE);
757 ok(szStatusText != NULL, "szStatusText == NULL\n");
759 ok(lstrlenW(szStatusText) < lstrlenW(text_htmlW) ||
760 !memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)),
761 "szStatusText != text/html\n");
763 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
764 CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
765 ok(szStatusText != NULL, "szStatusText == NULL\n");
768 ok(!strcmp_ww(szStatusText, expect_wsz), "unexpected szStatusText\n");
769 else if(tested_protocol == FILE_TEST)
770 ok(!strcmp_ww(szStatusText, file_name), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
772 ok(szStatusText != NULL, "szStatusText == NULL\n");
775 case BINDSTATUS_FINDINGRESOURCE:
776 CHECK_EXPECT2(ReportProgress_FINDINGRESOURCE);
777 ok(szStatusText != NULL, "szStatusText == NULL\n");
779 case BINDSTATUS_CONNECTING:
780 CHECK_EXPECT2(ReportProgress_CONNECTING);
781 ok(szStatusText != NULL, "szStatusText == NULL\n");
783 case BINDSTATUS_SENDINGREQUEST:
784 CHECK_EXPECT2(ReportProgress_SENDINGREQUEST);
785 if(tested_protocol == FILE_TEST || tested_protocol == ITS_TEST) {
786 ok(szStatusText != NULL, "szStatusText == NULL\n");
788 ok(!*szStatusText, "wrong szStatusText\n");
791 case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE:
792 CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
793 ok(szStatusText != NULL, "szStatusText == NULL\n");
795 ok(!strcmp_ww(szStatusText, text_htmlW), "szStatusText != text/html\n");
797 case BINDSTATUS_PROTOCOLCLASSID:
798 CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID);
799 ok(szStatusText != NULL, "szStatusText == NULL\n");
800 ok(!strcmp_ww(szStatusText, null_guid), "unexpected classid %s\n", wine_dbgstr_w(szStatusText));
802 case BINDSTATUS_COOKIE_SENT:
803 CHECK_EXPECT(ReportProgress_COOKIE_SENT);
804 ok(szStatusText == NULL, "szStatusText != NULL\n");
806 case BINDSTATUS_REDIRECTING:
807 CHECK_EXPECT(ReportProgress_REDIRECTING);
809 ok(!strcmp_wa(szStatusText, "http://test.winehq.org/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
811 ok(szStatusText == NULL, "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
813 case BINDSTATUS_ENCODING:
814 CHECK_EXPECT(ReportProgress_ENCODING);
815 ok(!strcmp_wa(szStatusText, "gzip"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
817 case BINDSTATUS_ACCEPTRANGES:
818 CHECK_EXPECT(ReportProgress_ACCEPTRANGES);
819 ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
821 case BINDSTATUS_PROXYDETECTING:
822 CHECK_EXPECT(ReportProgress_PROXYDETECTING);
823 SET_EXPECT(ReportProgress_CONNECTING);
824 ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
826 case BINDSTATUS_LOADINGMIMEHANDLER:
827 CHECK_EXPECT(ReportProgress_LOADINGMIMEHANDLER);
828 ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
830 case BINDSTATUS_DECODING:
831 CHECK_EXPECT(ReportProgress_DECODING);
832 ok(!strcmp_ww(szStatusText, gzipW), "szStatusText = %s\n", wine_dbgstr_w(szStatusText));
835 ok(0, "Unexpected status %d\n", ulStatusCode);
841 static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF,
842 ULONG ulProgress, ULONG ulProgressMax)
846 static int rec_depth;
849 if(!mimefilter_test && (tested_protocol == FILE_TEST || tested_protocol == ITS_TEST)) {
850 CHECK_EXPECT2(ReportData);
852 ok(ulProgress == ulProgressMax, "ulProgress (%d) != ulProgressMax (%d)\n",
853 ulProgress, ulProgressMax);
854 ok(ulProgressMax == 13, "ulProgressMax=%d, expected 13\n", ulProgressMax);
855 /* BSCF_SKIPDRAINDATAFORFILEURLS added in IE8 */
856 if(tested_protocol == FILE_TEST)
857 ok((grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION)) ||
858 (grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_SKIPDRAINDATAFORFILEURLS)),
859 "grcfBSCF = %08x\n", grfBSCF);
861 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE), "grcfBSCF = %08x\n", grfBSCF);
862 }else if(direct_read) {
866 if(!read_report_data && rec_depth == 1) {
867 BOOL reported_all_data = called_ReportData2;
869 CHECK_EXPECT2(ReportData);
872 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE)
873 || grfBSCF == BSCF_FIRSTDATANOTIFICATION, /* < IE8 */
874 "grcfBSCF = %08x\n", grfBSCF);
875 CHECK_CALLED(Read); /* Set in Continue */
876 first_data_notif = FALSE;
877 }else if(first_data_notif) {
878 ok(grfBSCF == BSCF_FIRSTDATANOTIFICATION, "grcfBSCF = %08x\n", grfBSCF);
879 first_data_notif = FALSE;
880 }else if(reported_all_data) {
881 ok(grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION),
882 "grcfBSCF = %08x\n", grfBSCF);
883 }else if(!direct_read) {
884 ok(grfBSCF == BSCF_INTERMEDIATEDATANOTIFICATION, "grcfBSCF = %08x\n", grfBSCF);
892 SET_EXPECT(ReportData2);
893 SET_EXPECT(ReportResult);
896 hres = IInternetProtocol_Read(binding_test ? binding_protocol : async_protocol, expect_pv = buf, sizeof(buf), &read);
897 ok(hres == E_PENDING || hres == S_FALSE || hres == S_OK, "Read failed: %08x\n", hres);
899 ok(read, "read == 0\n");
900 if(reported_all_data)
901 ok(hres == S_FALSE, "Read failed: %08x, expected S_FALSE\n", hres);
902 if(!emulate_prot && hres != E_PENDING)
903 CHECK_NOT_CALLED(Switch); /* otherwise checked in wait_for_switch loop */
906 if(!reported_all_data && called_ReportData2) {
908 CHECK_CALLED(ReportData2);
909 CHECK_CALLED(ReportResult);
910 ok(hres == S_OK, "Read failed: %08x\n", hres);
911 reported_all_data = TRUE;
914 CHECK_NOT_CALLED(ReportData2);
915 CHECK_NOT_CALLED(ReportResult);
917 }while(hres == S_OK);
919 wait_for_switch = FALSE;
921 CHECK_EXPECT(ReportData2);
923 ok(grfBSCF & BSCF_LASTDATANOTIFICATION, "grfBSCF = %08x\n", grfBSCF);
928 hres = IInternetProtocol_Read(binding_test ? binding_protocol : async_protocol, expect_pv = buf, sizeof(buf), &read);
931 ok(hres == S_FALSE, "Read returned: %08x, expected E_FALSE\n", hres);
932 ok(!read, "read = %d\n", read);
934 }else if(!binding_test && (tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST
935 || tested_protocol == FTP_TEST)) {
936 if(!(grfBSCF & BSCF_LASTDATANOTIFICATION) || (grfBSCF & BSCF_DATAFULLYAVAILABLE))
937 CHECK_EXPECT(ReportData);
938 else if (http_post_test)
939 ok(ulProgress == 13, "Read %u bytes instead of 13\n", ulProgress);
941 ok(ulProgress, "ulProgress == 0\n");
943 if(first_data_notif) {
944 ok(grfBSCF == BSCF_FIRSTDATANOTIFICATION
945 || grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE),
946 "grcfBSCF = %08x\n", grfBSCF);
947 first_data_notif = FALSE;
949 ok(grfBSCF == BSCF_INTERMEDIATEDATANOTIFICATION
950 || grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION)
951 || broken(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION)),
952 "grcfBSCF = %08x\n", grfBSCF);
955 if(!(bindf & BINDF_FROMURLMON) &&
956 !(grfBSCF & BSCF_LASTDATANOTIFICATION)) {
957 if(state == STATE_CONNECTING) {
958 state = STATE_DOWNLOADING;
960 CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
961 CHECK_CALLED(ReportProgress_CONNECTING);
963 CHECK_NOT_CALLED(ReportProgress_FINDINGRESOURCE);
964 CHECK_NOT_CALLED(ReportProgress_CONNECTING);
966 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
967 CHECK_CALLED(OnResponse);
968 CHECK_CALLED(ReportProgress_RAWMIMETYPE);
970 SetEvent(event_complete);
972 }else if(!read_report_data) {
977 CHECK_EXPECT(ReportData);
979 if(tested_protocol != BIND_TEST) {
982 SET_EXPECT(MimeFilter_Read);
983 else if(rec_depth > 1)
987 hres = IInternetProtocol_Read(binding_protocol, expect_pv=buf, sizeof(buf), &read);
989 CHECK_CALLED(MimeFilter_Read);
990 else if(rec_depth > 1)
994 }while(hres == S_OK);
1002 static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult,
1003 DWORD dwError, LPCWSTR szResult)
1005 CHECK_EXPECT(ReportResult);
1007 if(tested_protocol == FTP_TEST)
1008 ok(hrResult == E_PENDING || hrResult == S_OK, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult);
1010 ok(hrResult == expect_hrResult, "hrResult = %08x, expected: %08x\n",
1011 hrResult, expect_hrResult);
1012 if(SUCCEEDED(hrResult) || tested_protocol == FTP_TEST || test_abort)
1013 ok(dwError == ERROR_SUCCESS, "dwError = %d, expected ERROR_SUCCESS\n", dwError);
1015 ok(dwError != ERROR_SUCCESS ||
1016 broken(tested_protocol == MK_TEST), /* Win9x, WinME and NT4 */
1017 "dwError == ERROR_SUCCESS\n");
1018 ok(!szResult, "szResult != NULL\n");
1021 SET_EXPECT(ReportData); /* checked after main loop */
1026 static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
1027 ProtocolSink_QueryInterface,
1028 ProtocolSink_AddRef,
1029 ProtocolSink_Release,
1030 ProtocolSink_Switch,
1031 ProtocolSink_ReportProgress,
1032 ProtocolSink_ReportData,
1033 ProtocolSink_ReportResult
1036 static IInternetProtocolSink protocol_sink = { &protocol_sink_vtbl };
1038 static HRESULT WINAPI MimeProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
1040 ok(0, "unexpected call\n");
1044 static ULONG WINAPI MimeProtocolSink_AddRef(IInternetProtocolSink *iface)
1049 static ULONG WINAPI MimeProtocolSink_Release(IInternetProtocolSink *iface)
1054 static HRESULT WINAPI MimeProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
1058 CHECK_EXPECT(MimeFilter_Switch);
1061 hres = IInternetProtocolSink_Switch(filtered_sink, pProtocolData);
1062 ok(hres == S_OK, "Switch failed: %08x\n", hres);
1063 CHECK_CALLED(Switch);
1068 static HRESULT WINAPI MimeProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
1069 LPCWSTR szStatusText)
1071 CHECK_EXPECT(MimeFilter_ReportProgress);
1075 static HRESULT WINAPI MimeProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF,
1076 ULONG ulProgress, ULONG ulProgressMax)
1082 CHECK_EXPECT(MimeFilter_ReportData);
1086 hres = IInternetProtocol_Read(filtered_protocol, buf, sizeof(buf), &read);
1087 if(tested_protocol == HTTP_TEST)
1088 ok(hres == S_OK || hres == E_PENDING || hres == S_FALSE, "Read failed: %08x\n", hres);
1090 ok(hres == S_OK, "Read failed: %08x\n", hres);
1093 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1094 hres = IInternetProtocolSink_ReportProgress(filtered_sink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, text_htmlW);
1095 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
1096 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1098 /* FIXME: test BINDSTATUS_CACHEFILENAMEAVAILABLE */
1101 if(!read_report_data)
1102 SET_EXPECT(ReportData);
1103 hres = IInternetProtocolSink_ReportData(filtered_sink, grfBSCF, ulProgress, ulProgressMax);
1104 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1105 if(!read_report_data)
1106 CHECK_CALLED(ReportData);
1114 static HRESULT WINAPI MimeProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult,
1115 DWORD dwError, LPCWSTR szResult)
1119 CHECK_EXPECT(MimeFilter_ReportResult);
1121 ok(hrResult == S_OK, "hrResult = %08x\n", hrResult);
1122 ok(dwError == ERROR_SUCCESS, "dwError = %u\n", dwError);
1123 ok(!szResult, "szResult = %s\n", wine_dbgstr_w(szResult));
1125 SET_EXPECT(ReportResult);
1126 hres = IInternetProtocolSink_ReportResult(filtered_sink, hrResult, dwError, szResult);
1127 ok(SUCCEEDED(hres), "ReportResult failed: %08x\n", hres);
1128 CHECK_CALLED(ReportResult);
1133 static IInternetProtocolSinkVtbl mime_protocol_sink_vtbl = {
1134 MimeProtocolSink_QueryInterface,
1135 MimeProtocolSink_AddRef,
1136 MimeProtocolSink_Release,
1137 MimeProtocolSink_Switch,
1138 MimeProtocolSink_ReportProgress,
1139 MimeProtocolSink_ReportData,
1140 MimeProtocolSink_ReportResult
1143 static IInternetProtocolSink mime_protocol_sink = { &mime_protocol_sink_vtbl };
1145 static HRESULT QueryInterface(REFIID riid, void **ppv)
1147 static const IID IID_undocumented = {0x58DFC7D0,0x5381,0x43E5,{0x9D,0x72,0x4C,0xDD,0xE4,0xCB,0x0F,0x1A}};
1151 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid))
1152 *ppv = &protocol_sink;
1153 if(IsEqualGUID(&IID_IServiceProvider, riid))
1154 *ppv = &service_provider;
1155 if(IsEqualGUID(&IID_IUriContainer, riid))
1156 return E_NOINTERFACE; /* TODO */
1158 /* NOTE: IE8 queries for undocumented {58DFC7D0-5381-43E5-9D72-4CDDE4CB0F1A} interface. */
1159 if(IsEqualGUID(&IID_undocumented, riid))
1160 return E_NOINTERFACE;
1165 ok(0, "unexpected call %s\n", debugstr_guid(riid));
1166 return E_NOINTERFACE;
1169 static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
1171 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
1175 return E_NOINTERFACE;
1178 static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
1183 static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
1188 static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1192 CHECK_EXPECT(GetBindInfo);
1194 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
1195 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
1196 ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize);
1200 *grfBINDF |= BINDF_FROMURLMON;
1201 cbSize = pbindinfo->cbSize;
1202 memset(pbindinfo, 0, cbSize);
1203 pbindinfo->cbSize = cbSize;
1207 pbindinfo->cbstgmedData = sizeof(post_data)-1;
1208 pbindinfo->dwBindVerb = BINDVERB_POST;
1209 pbindinfo->stgmedData.tymed = http_post_test;
1211 if(http_post_test == TYMED_HGLOBAL) {
1214 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly */
1215 data = GlobalAlloc(GPTR, sizeof(post_data));
1216 memcpy(data, post_data, sizeof(post_data));
1217 U(pbindinfo->stgmedData).hGlobal = data;
1219 IStream *post_stream;
1224 /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly */
1225 data = GlobalAlloc(GPTR, sizeof(post_data));
1226 memcpy(data, post_data, sizeof(post_data));
1227 U(pbindinfo->stgmedData).hGlobal = data;
1229 hres = CreateStreamOnHGlobal(data, FALSE, &post_stream);
1230 ok(hres == S_OK, "CreateStreamOnHGlobal failed: %08x\n", hres);
1232 U(pbindinfo->stgmedData).pstm =post_stream;/* &Stream; */
1234 U(pbindinfo->stgmedData).pstm = &Stream;
1241 static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType,
1242 LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched)
1244 ok(ppwzStr != NULL, "ppwzStr == NULL\n");
1245 ok(pcElFetched != NULL, "pcElFetched == NULL\n");
1247 switch(ulStringType) {
1248 case BINDSTRING_ACCEPT_MIMES:
1249 CHECK_EXPECT(GetBindString_ACCEPT_MIMES);
1250 ok(cEl == 256, "cEl=%d, expected 256\n", cEl);
1252 ok(*pcElFetched == 256, "*pcElFetched=%d, expected 256\n", *pcElFetched);
1256 *ppwzStr = CoTaskMemAlloc(sizeof(acc_mimeW));
1257 memcpy(*ppwzStr, acc_mimeW, sizeof(acc_mimeW));
1260 case BINDSTRING_USER_AGENT:
1261 CHECK_EXPECT(GetBindString_USER_AGENT);
1262 ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
1264 ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
1268 *ppwzStr = CoTaskMemAlloc(sizeof(user_agentW));
1269 memcpy(*ppwzStr, user_agentW, sizeof(user_agentW));
1272 case BINDSTRING_POST_COOKIE:
1273 CHECK_EXPECT(GetBindString_POST_COOKIE);
1274 ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
1276 ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
1278 case BINDSTRING_URL: {
1281 CHECK_EXPECT(GetBindString_URL);
1282 ok(cEl == 1, "cEl=%d, expected 1\n", cEl);
1283 ok(*pcElFetched == 0, "*pcElFetch=%d, expectd 0\n", *pcElFetched);
1286 size = (lstrlenW(binding_urls[tested_protocol])+1)*sizeof(WCHAR);
1287 *ppwzStr = CoTaskMemAlloc(size);
1288 memcpy(*ppwzStr, binding_urls[tested_protocol], size);
1292 ok(0, "unexpected call\n");
1298 static IInternetBindInfoVtbl bind_info_vtbl = {
1299 BindInfo_QueryInterface,
1302 BindInfo_GetBindInfo,
1303 BindInfo_GetBindString
1306 static IInternetBindInfo bind_info = { &bind_info_vtbl };
1308 static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface,
1309 REFIID riid, void **ppv)
1311 ok(0, "unexpected call\n");
1312 return E_NOINTERFACE;
1315 static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface)
1320 static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface)
1325 static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
1327 CHECK_EXPECT(SetPriority);
1328 ok(nPriority == ex_priority, "nPriority=%d\n", nPriority);
1332 static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
1334 ok(0, "unexpected call\n");
1339 static const IInternetPriorityVtbl InternetPriorityVtbl = {
1340 InternetPriority_QueryInterface,
1341 InternetPriority_AddRef,
1342 InternetPriority_Release,
1343 InternetPriority_SetPriority,
1344 InternetPriority_GetPriority
1347 static IInternetPriority InternetPriority = { &InternetPriorityVtbl };
1349 static ULONG WINAPI Protocol_AddRef(IInternetProtocolEx *iface)
1354 static ULONG WINAPI Protocol_Release(IInternetProtocolEx *iface)
1359 static HRESULT WINAPI Protocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason,
1364 CHECK_EXPECT(Abort);
1366 SET_EXPECT(ReportResult);
1367 hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL);
1368 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1369 CHECK_CALLED(ReportResult);
1374 static HRESULT WINAPI Protocol_Suspend(IInternetProtocolEx *iface)
1376 ok(0, "unexpected call\n");
1380 static HRESULT WINAPI Protocol_Resume(IInternetProtocolEx *iface)
1382 ok(0, "unexpected call\n");
1386 static HRESULT WINAPI Protocol_Seek(IInternetProtocolEx *iface,
1387 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1389 ok(0, "unexpected call\n");
1393 static HRESULT WINAPI ProtocolEmul_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
1395 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
1400 if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) {
1406 return E_NOINTERFACE;
1409 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
1410 *ppv = &InternetPriority;
1414 if(IsEqualGUID(&IID_IWinInetInfo, riid)) {
1415 CHECK_EXPECT(QueryInterface_IWinInetInfo);
1417 return E_NOINTERFACE;
1420 if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) {
1421 CHECK_EXPECT(QueryInterface_IWinInetHttpInfo);
1423 return E_NOINTERFACE;
1426 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1428 return E_NOINTERFACE;
1431 static DWORD WINAPI thread_proc(PVOID arg)
1435 memset(&protocoldata, -1, sizeof(protocoldata));
1439 SET_EXPECT(ReportProgress_FINDINGRESOURCE);
1440 hres = IInternetProtocolSink_ReportProgress(binding_sink,
1441 BINDSTATUS_FINDINGRESOURCE, hostW);
1442 CHECK_CALLED(ReportProgress_FINDINGRESOURCE);
1443 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
1445 SET_EXPECT(ReportProgress_CONNECTING);
1446 hres = IInternetProtocolSink_ReportProgress(binding_sink,
1447 BINDSTATUS_CONNECTING, winehq_ipW);
1448 CHECK_CALLED(ReportProgress_CONNECTING);
1449 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
1451 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1452 hres = IInternetProtocolSink_ReportProgress(binding_sink,
1453 BINDSTATUS_SENDINGREQUEST, NULL);
1454 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
1455 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
1459 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
1460 CHECK_CALLED(Switch);
1461 ok(hres == S_OK, "Switch failed: %08x\n", hres);
1466 SET_EXPECT(MimeFilter_Switch);
1469 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
1470 ok(hres == S_OK, "Switch failed: %08x\n", hres);
1472 CHECK_CALLED(MimeFilter_Switch);
1474 CHECK_CALLED(Switch);
1477 SetEvent(event_complete);
1483 SET_EXPECT(MimeFilter_Switch);
1486 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
1487 ok(hres == S_OK, "Switch failed: %08x\n", hres);
1489 CHECK_CALLED(MimeFilter_Switch);
1491 CHECK_CALLED(Switch);
1495 SET_EXPECT(MimeFilter_Switch);
1498 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
1499 ok(hres == S_OK, "Switch failed: %08x\n", hres);
1501 CHECK_CALLED(MimeFilter_Switch);
1503 CHECK_CALLED(Switch);
1506 SetEvent(event_complete);
1511 static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD pi)
1513 BINDINFO bindinfo, exp_bindinfo;
1517 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
1518 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
1519 ok(pOIProtSink != &protocol_sink, "unexpected pOIProtSink\n");
1520 ok(pOIBindInfo != &bind_info, "unexpected pOIBindInfo\n");
1521 ok(!pi, "pi = %x\n", pi);
1524 ok(pOIProtSink == binding_sink, "pOIProtSink != binding_sink\n");
1526 memset(&bindinfo, 0, sizeof(bindinfo));
1527 bindinfo.cbSize = sizeof(bindinfo);
1528 memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo));
1529 SET_EXPECT(GetBindInfo);
1530 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo);
1531 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
1532 CHECK_CALLED(GetBindInfo);
1533 ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n",
1534 cbindf, (bindf|BINDF_FROMURLMON));
1535 ok(!memcmp(&exp_bindinfo, &bindinfo, sizeof(bindinfo)), "unexpected bindinfo\n");
1536 pReleaseBindInfo(&bindinfo);
1538 SET_EXPECT(ReportProgress_SENDINGREQUEST);
1539 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, emptyW);
1540 ok(hres == S_OK, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
1541 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
1543 if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
1544 IServiceProvider *service_provider;
1545 IHttpNegotiate *http_negotiate;
1546 IHttpNegotiate2 *http_negotiate2;
1547 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
1548 LPWSTR additional_headers = NULL;
1550 DWORD fetched = 0, size = 100;
1553 SET_EXPECT(GetBindString_USER_AGENT);
1554 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
1556 CHECK_CALLED(GetBindString_USER_AGENT);
1557 ok(hres == S_OK, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
1558 ok(fetched == 1, "fetched = %d, expected 254\n", fetched);
1559 ok(ua != NULL, "ua = %p\n", ua);
1560 ok(!strcmp_ww(ua, user_agentW), "unexpected user agent %s\n", wine_dbgstr_w(ua));
1564 SET_EXPECT(GetBindString_ACCEPT_MIMES);
1565 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
1566 accept_mimes, 256, &fetched);
1567 CHECK_CALLED(GetBindString_ACCEPT_MIMES);
1570 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
1571 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
1572 ok(!strcmp_ww(acc_mimeW, accept_mimes[0]), "unexpected mimes %s\n", wine_dbgstr_w(accept_mimes[0]));
1573 CoTaskMemFree(accept_mimes[0]);
1575 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
1576 (void**)&service_provider);
1577 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
1579 SET_EXPECT(QueryService_HttpNegotiate);
1580 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
1581 &IID_IHttpNegotiate, (void**)&http_negotiate);
1582 CHECK_CALLED(QueryService_HttpNegotiate);
1583 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
1585 SET_EXPECT(BeginningTransaction);
1586 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, binding_urls[tested_protocol],
1587 NULL, 0, &additional_headers);
1588 CHECK_CALLED(BeginningTransaction);
1589 IHttpNegotiate_Release(http_negotiate);
1590 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
1591 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
1593 SET_EXPECT(QueryService_HttpNegotiate);
1594 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
1595 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
1596 CHECK_CALLED(QueryService_HttpNegotiate);
1597 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
1600 SET_EXPECT(GetRootSecurityId);
1601 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
1602 CHECK_CALLED(GetRootSecurityId);
1603 IHttpNegotiate2_Release(http_negotiate2);
1604 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
1605 ok(size == 13, "size=%d\n", size);
1607 IServiceProvider_Release(service_provider);
1609 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid);
1613 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
1614 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
1615 BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW);
1616 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
1617 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
1619 if(mimefilter_test) {
1620 SET_EXPECT(MimeFilter_CreateInstance);
1621 SET_EXPECT(MimeFilter_Start);
1622 SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER);
1624 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1625 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE,
1626 mimefilter_test ? gzipW : (expect_wsz = text_htmlW));
1628 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
1629 if(mimefilter_test) {
1630 CHECK_CALLED(MimeFilter_CreateInstance);
1631 CHECK_CALLED(MimeFilter_Start);
1632 CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER);
1633 todo_wine CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1635 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1639 SET_EXPECT(MimeFilter_ReportData);
1641 SET_EXPECT(ReportData);
1642 hres = IInternetProtocolSink_ReportData(pOIProtSink,
1643 BSCF_FIRSTDATANOTIFICATION | (tested_protocol == ITS_TEST ? BSCF_DATAFULLYAVAILABLE : BSCF_LASTDATANOTIFICATION),
1645 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1647 CHECK_CALLED(MimeFilter_ReportData);
1649 CHECK_CALLED(ReportData);
1651 if(tested_protocol == ITS_TEST) {
1652 SET_EXPECT(ReportData);
1653 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
1654 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
1655 CHECK_CALLED(ReportData);
1658 if(tested_protocol == BIND_TEST) {
1659 hres = IInternetProtocol_Terminate(binding_protocol, 0);
1660 ok(hres == E_FAIL, "Termiante failed: %08x\n", hres);
1664 SET_EXPECT(MimeFilter_ReportResult);
1666 SET_EXPECT(ReportResult);
1667 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
1668 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1670 CHECK_CALLED(MimeFilter_ReportResult);
1672 CHECK_CALLED(ReportResult);
1675 static HRESULT WINAPI ProtocolEmul_Start(IInternetProtocolEx *iface, LPCWSTR szUrl,
1676 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
1677 DWORD grfPI, HANDLE_PTR dwReserved)
1679 CHECK_EXPECT(Start);
1681 ok(!dwReserved, "dwReserved = %lx\n", dwReserved);
1682 protocol_start(pOIProtSink, pOIBindInfo, grfPI);
1686 static HRESULT WINAPI ProtocolEmul_Continue(IInternetProtocolEx *iface,
1687 PROTOCOLDATA *pProtocolData)
1692 CHECK_EXPECT(Continue);
1694 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
1695 if(!pProtocolData || tested_protocol == BIND_TEST)
1698 ok(pProtocolData != &protocoldata, "pProtocolData == &protocoldata\n");
1699 ok(pProtocolData->grfFlags == protocoldata.grfFlags, "grfFlags wrong %x/%x\n",
1700 pProtocolData->grfFlags, protocoldata.grfFlags );
1701 ok(pProtocolData->dwState == protocoldata.dwState, "dwState wrong %x/%x\n",
1702 pProtocolData->dwState, protocoldata.dwState );
1703 ok(pProtocolData->pData == protocoldata.pData, "pData wrong %p/%p\n",
1704 pProtocolData->pData, protocoldata.pData );
1705 ok(pProtocolData->cbData == protocoldata.cbData, "cbData wrong %x/%x\n",
1706 pProtocolData->cbData, protocoldata.cbData );
1709 switch(prot_state) {
1711 IServiceProvider *service_provider;
1712 IHttpNegotiate *http_negotiate;
1713 static WCHAR header[] = {'?',0};
1715 hres = IInternetProtocolSink_QueryInterface(binding_sink, &IID_IServiceProvider,
1716 (void**)&service_provider);
1717 ok(hres == S_OK, "Could not get IServiceProvicder\n");
1719 SET_EXPECT(QueryService_HttpNegotiate);
1720 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
1721 &IID_IHttpNegotiate, (void**)&http_negotiate);
1722 IServiceProvider_Release(service_provider);
1723 CHECK_CALLED(QueryService_HttpNegotiate);
1724 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
1726 SET_EXPECT(OnResponse);
1727 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
1728 IHttpNegotiate_Release(http_negotiate);
1729 CHECK_CALLED(OnResponse);
1730 IHttpNegotiate_Release(http_negotiate);
1731 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
1733 if(mimefilter_test) {
1734 SET_EXPECT(MimeFilter_CreateInstance);
1735 SET_EXPECT(MimeFilter_Start);
1736 SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER);
1737 }else if(!(pi & PI_MIMEVERIFICATION)) {
1738 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1740 hres = IInternetProtocolSink_ReportProgress(binding_sink,
1741 BINDSTATUS_MIMETYPEAVAILABLE, mimefilter_test ? gzipW : text_htmlW);
1742 if(mimefilter_test) {
1743 CHECK_CALLED(MimeFilter_CreateInstance);
1744 CHECK_CALLED(MimeFilter_Start);
1745 CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER);
1746 }else if(!(pi & PI_MIMEVERIFICATION)) {
1747 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1750 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
1752 bscf |= BSCF_FIRSTDATANOTIFICATION;
1757 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
1762 if(mimefilter_test) {
1763 SET_EXPECT(MimeFilter_ReportData);
1764 }else if(pi & PI_MIMEVERIFICATION) {
1766 SET_EXPECT(Read); /* checked in ReportData for short_read */
1768 if(!mimefilter_test)
1769 SET_EXPECT(Read); /* checked in BINDSTATUS_MIMETYPEAVAILABLE or ReportData */
1770 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1773 SET_EXPECT(ReportData);
1775 SET_EXPECT(ReportData);
1778 hres = IInternetProtocolSink_ReportData(binding_sink, bscf, pr, 400);
1779 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1781 if(mimefilter_test) {
1782 SET_EXPECT(MimeFilter_ReportData);
1783 }else if(pi & PI_MIMEVERIFICATION) {
1784 if(!short_read && pr < 200)
1787 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1790 CHECK_CALLED(ReportData);
1799 static HRESULT WINAPI ProtocolEmul_Terminate(IInternetProtocolEx *iface, DWORD dwOptions)
1801 CHECK_EXPECT(Terminate);
1802 ok(!dwOptions, "dwOptions=%d\n", dwOptions);
1806 static HRESULT WINAPI ProtocolEmul_Read(IInternetProtocolEx *iface, void *pv,
1807 ULONG cb, ULONG *pcbRead)
1809 if(read_report_data)
1810 CHECK_EXPECT2(Read2);
1812 if(mimefilter_test || short_read) {
1813 if(!read_report_data)
1814 CHECK_EXPECT2(Read);
1815 }else if((pi & PI_MIMEVERIFICATION)) {
1816 if(!read_report_data)
1817 CHECK_EXPECT2(Read);
1819 if(prot_read < 300) {
1820 ok(pv != expect_pv, "pv == expect_pv\n");
1822 ok(cb == 2048-prot_read, "cb=%d\n", cb);
1824 ok(cb == 700, "cb=%d\n", cb);
1826 ok(expect_pv <= pv && (BYTE*)pv < (BYTE*)expect_pv + cb, "pv != expect_pv\n");
1829 if(!read_report_data)
1832 ok(pv == expect_pv, "pv != expect_pv\n");
1833 ok(cb == 1000, "cb=%d\n", cb);
1834 ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead);
1836 ok(pcbRead != NULL, "pcbRead == NULL\n");
1838 if(prot_state == 3 || (short_read && prot_state != 4)) {
1843 SET_EXPECT(Read2); /* checked in BINDSTATUS_MIMETYPEAVAILABLE */
1844 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
1847 SET_EXPECT(MimeFilter_ReportData);
1848 else if(direct_read)
1849 SET_EXPECT(ReportData2);
1851 hres = IInternetProtocolSink_ReportData(binding_sink,
1852 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 0, 0);
1854 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1856 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
1858 CHECK_CALLED(MimeFilter_ReportData);
1859 else if(direct_read)
1860 CHECK_CALLED(ReportData2);
1863 SET_EXPECT(MimeFilter_ReportResult);
1865 SET_EXPECT(ReportResult);
1866 hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL);
1867 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1869 CHECK_CALLED(MimeFilter_ReportResult);
1871 CHECK_CALLED(ReportResult);
1873 memset(pv, 'x', 100);
1874 prot_read += *pcbRead = 100;
1876 }if(prot_state == 4) {
1881 if((async_read_pending = !async_read_pending)) {
1883 return tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST ? E_PENDING : S_FALSE;
1886 memset(pv, 'x', 100);
1887 prot_read += *pcbRead = 100;
1891 static HRESULT WINAPI ProtocolEmul_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions)
1893 CHECK_EXPECT(LockRequest);
1894 ok(dwOptions == 0, "dwOptions=%x\n", dwOptions);
1898 static HRESULT WINAPI ProtocolEmul_UnlockRequest(IInternetProtocolEx *iface)
1900 CHECK_EXPECT(UnlockRequest);
1904 static HRESULT WINAPI ProtocolEmul_StartEx(IInternetProtocolEx *iface, IUri *pUri,
1905 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
1906 DWORD grfPI, HANDLE *dwReserved)
1908 CHECK_EXPECT(StartEx);
1909 ok(!dwReserved, "dwReserved = %p\n", dwReserved);
1910 protocol_start(pOIProtSink, pOIBindInfo, grfPI);
1914 static const IInternetProtocolExVtbl ProtocolVtbl = {
1915 ProtocolEmul_QueryInterface,
1919 ProtocolEmul_Continue,
1921 ProtocolEmul_Terminate,
1926 ProtocolEmul_LockRequest,
1927 ProtocolEmul_UnlockRequest,
1928 ProtocolEmul_StartEx
1931 static IInternetProtocolEx Protocol = { &ProtocolVtbl };
1933 static HRESULT WINAPI MimeProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv)
1935 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
1940 if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
1941 *ppv = &mime_protocol_sink;
1945 ok(0, "unexpected riid %s\n", debugstr_guid(riid));
1947 return E_NOINTERFACE;
1950 static HRESULT WINAPI MimeProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl,
1951 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
1952 DWORD grfPI, HANDLE_PTR dwReserved)
1954 PROTOCOLFILTERDATA *data;
1955 LPOLESTR url_str = NULL;
1961 CHECK_EXPECT(MimeFilter_Start);
1963 ok(!strcmp_ww(szUrl, gzipW), "wrong url %s\n", wine_dbgstr_w(szUrl));
1964 ok(grfPI == (PI_FILTER_MODE|PI_FORCE_ASYNC), "grfPI=%x, expected PI_FILTER_MODE|PI_FORCE_ASYNC\n", grfPI);
1965 ok(dwReserved, "dwReserved == 0\n");
1966 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
1967 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
1970 ok(pOIProtSink != binding_sink, "pOIProtSink == protocol_sink\n");
1971 ok(pOIBindInfo == prot_bind_info, "pOIBindInfo != bind_info\n");
1973 ok(pOIProtSink == &protocol_sink, "pOIProtSink != protocol_sink\n");
1974 ok(pOIBindInfo == &bind_info, "pOIBindInfo != bind_info\n");
1977 data = (void*)dwReserved;
1978 ok(data->cbSize == sizeof(*data), "data->cbSize = %d\n", data->cbSize);
1979 ok(!data->pProtocolSink, "data->pProtocolSink != NULL\n");
1980 ok(data->pProtocol != NULL, "data->pProtocol == NULL\n");
1981 ok(!data->pUnk, "data->pUnk != NULL\n");
1982 ok(!data->dwFilterFlags, "data->dwProtocolFlags = %x\n", data->dwFilterFlags);
1984 IInternetProtocolSink *prot_sink;
1986 IInternetProtocol_QueryInterface(data->pProtocol, &IID_IInternetProtocolSink, (void**)&prot_sink);
1987 ok(prot_sink == pOIProtSink, "QI(data->pProtocol, IID_IInternetProtocolSink) != pOIProtSink\n");
1988 IInternetProtocolSink_Release(prot_sink);
1990 ok(data->pProtocol != binding_protocol, "data->pProtocol == binding_protocol\n");
1992 filtered_protocol = data->pProtocol;
1993 IInternetProtocol_AddRef(filtered_protocol);
1995 IInternetProtocol *prot;
1997 IInternetProtocol_QueryInterface(data->pProtocol, &IID_IInternetProtocol, (void**)&prot);
1998 ok(prot == async_protocol, "QI(data->pProtocol, IID_IInternetProtocol) != async_protocol\n");
1999 IInternetProtocol_Release(prot);
2001 ok(data->pProtocol != async_protocol, "data->pProtocol == async_protocol\n");
2004 filtered_sink = pOIProtSink;
2006 SET_EXPECT(ReportProgress_DECODING);
2007 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DECODING, gzipW);
2008 ok(hres == S_OK, "ReportProgress(BINDSTATUS_DECODING) failed: %08x\n", hres);
2009 CHECK_CALLED(ReportProgress_DECODING);
2011 SET_EXPECT(GetBindInfo);
2012 memset(&bindinfo, 0, sizeof(bindinfo));
2013 bindinfo.cbSize = sizeof(bindinfo);
2014 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo);
2015 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2016 ok(cbindf == (bindf|BINDF_FROMURLMON), "cbindf = %x, expected %x\n", cbindf, bindf);
2017 CHECK_CALLED(GetBindInfo);
2019 SET_EXPECT(GetBindString_URL);
2020 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_URL, &url_str, 1, &fetched);
2021 ok(hres == S_OK, "GetBindString(BINDSTRING_URL) failed: %08x\n", hres);
2022 ok(fetched == 1, "fetched = %d\n", fetched);
2023 ok(!strcmp_ww(url_str, binding_urls[tested_protocol]), "wrong url_str %s\n", wine_dbgstr_w(url_str));
2024 CoTaskMemFree(url_str);
2025 CHECK_CALLED(GetBindString_URL);
2030 static HRESULT WINAPI Protocol_Continue(IInternetProtocolEx *iface,
2031 PROTOCOLDATA *pProtocolData)
2033 CHECK_EXPECT(MimeFilter_Continue);
2037 static HRESULT WINAPI MimeProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions)
2041 CHECK_EXPECT(MimeFilter_Terminate);
2043 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
2045 SET_EXPECT(Terminate);
2046 hres = IInternetProtocol_Terminate(filtered_protocol, dwOptions);
2047 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2048 CHECK_CALLED(Terminate);
2053 static HRESULT WINAPI MimeProtocol_Read(IInternetProtocolEx *iface, void *pv,
2054 ULONG cb, ULONG *pcbRead)
2060 CHECK_EXPECT(MimeFilter_Read);
2062 ok(pv != NULL, "pv == NULL\n");
2063 ok(cb != 0, "cb == 0\n");
2064 ok(pcbRead != NULL, "pcbRead == NULL\n");
2066 if(read_report_data)
2070 hres = IInternetProtocol_Read(filtered_protocol, buf, sizeof(buf), &read);
2071 ok(hres == S_OK || hres == S_FALSE || hres == E_PENDING, "Read failed: %08x\n", hres);
2072 if(read_report_data)
2073 CHECK_CALLED(Read2);
2078 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
2082 memset(pv, 'x', read);
2086 static HRESULT WINAPI MimeProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions)
2090 CHECK_EXPECT(MimeFilter_LockRequest);
2092 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
2094 SET_EXPECT(LockRequest);
2095 hres = IInternetProtocol_LockRequest(filtered_protocol, dwOptions);
2096 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
2097 CHECK_CALLED(LockRequest);
2102 static HRESULT WINAPI MimeProtocol_UnlockRequest(IInternetProtocolEx *iface)
2106 CHECK_EXPECT(MimeFilter_UnlockRequest);
2108 SET_EXPECT(UnlockRequest);
2109 hres = IInternetProtocol_UnlockRequest(filtered_protocol);
2110 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2111 CHECK_CALLED(UnlockRequest);
2116 static const IInternetProtocolExVtbl MimeProtocolVtbl = {
2117 MimeProtocol_QueryInterface,
2123 MimeProtocol_Terminate,
2128 MimeProtocol_LockRequest,
2129 MimeProtocol_UnlockRequest
2132 static IInternetProtocolEx MimeProtocol = { &MimeProtocolVtbl };
2134 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
2136 ok(0, "unexpected call\n");
2137 return E_NOINTERFACE;
2140 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
2145 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
2150 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter,
2151 REFIID riid, void **ppv)
2153 CHECK_EXPECT(CreateInstance);
2155 ok(pOuter == (IUnknown*)prot_bind_info, "pOuter != protocol_unk\n");
2156 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", debugstr_guid(riid));
2157 ok(ppv != NULL, "ppv == NULL\n");
2163 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
2165 ok(0, "unexpected call\n");
2169 static const IClassFactoryVtbl ClassFactoryVtbl = {
2170 ClassFactory_QueryInterface,
2171 ClassFactory_AddRef,
2172 ClassFactory_Release,
2173 ClassFactory_CreateInstance,
2174 ClassFactory_LockServer
2177 static IClassFactory ClassFactory = { &ClassFactoryVtbl };
2179 static HRESULT WINAPI MimeFilter_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
2181 CHECK_EXPECT(MimeFilter_CreateInstance);
2183 ok(!outer, "outer = %p\n", outer);
2184 ok(IsEqualGUID(&IID_IInternetProtocol, riid), "unexpected riid %s\n", debugstr_guid(riid));
2186 *ppv = &MimeProtocol;
2190 static const IClassFactoryVtbl MimeFilterCFVtbl = {
2191 ClassFactory_QueryInterface,
2192 ClassFactory_AddRef,
2193 ClassFactory_Release,
2194 MimeFilter_CreateInstance,
2195 ClassFactory_LockServer
2198 static IClassFactory mimefilter_cf = { &MimeFilterCFVtbl };
2200 #define TEST_BINDING 0x0001
2201 #define TEST_FILTER 0x0002
2202 #define TEST_FIRST_HTTP 0x0004
2203 #define TEST_DIRECT_READ 0x0008
2204 #define TEST_POST 0x0010
2205 #define TEST_EMULATEPROT 0x0020
2206 #define TEST_SHORT_READ 0x0040
2207 #define TEST_REDIRECT 0x0080
2208 #define TEST_ABORT 0x0100
2209 #define TEST_ASYNCREQ 0x0200
2210 #define TEST_USEIURI 0x0400
2211 #define TEST_IMPLPROTEX 0x0800
2213 static void register_filter(BOOL do_register)
2215 IInternetSession *session;
2218 static const WCHAR gzipW[] = {'g','z','i','p',0};
2220 hres = pCoInternetGetSession(0, &session, 0);
2221 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
2224 hres = IInternetSession_RegisterMimeFilter(session, &mimefilter_cf, &IID_IInternetProtocol, gzipW);
2225 ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres);
2227 hres = IInternetSession_UnregisterMimeFilter(session, &mimefilter_cf, gzipW);
2228 ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres);
2231 IInternetSession_Release(session);
2234 static void init_test(int prot, DWORD flags)
2236 tested_protocol = prot;
2237 binding_test = (flags & TEST_BINDING) != 0;
2238 first_data_notif = TRUE;
2241 async_read_pending = TRUE;
2242 mimefilter_test = (flags & TEST_FILTER) != 0;
2244 post_stream_read = 0;
2245 ResetEvent(event_complete);
2246 ResetEvent(event_complete2);
2247 ResetEvent(event_continue);
2248 ResetEvent(event_continue_done);
2249 async_protocol = binding_protocol = filtered_protocol = NULL;
2250 filtered_sink = NULL;
2251 http_is_first = (flags & TEST_FIRST_HTTP) != 0;
2252 first_data_notif = TRUE;
2253 state = STATE_CONNECTING;
2254 test_async_req = (flags & TEST_ASYNCREQ) != 0;
2255 direct_read = (flags & TEST_DIRECT_READ) != 0;
2256 emulate_prot = (flags & TEST_EMULATEPROT) != 0;
2257 wait_for_switch = TRUE;
2258 short_read = (flags & TEST_SHORT_READ) != 0;
2259 http_post_test = TYMED_NULL;
2260 test_redirect = (flags & TEST_REDIRECT) != 0;
2261 test_abort = (flags & TEST_ABORT) != 0;
2262 impl_protex = (flags & TEST_IMPLPROTEX) != 0;
2264 register_filter(mimefilter_test);
2267 static void test_priority(IInternetProtocol *protocol)
2269 IInternetPriority *priority;
2273 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority,
2275 ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
2279 hres = IInternetPriority_GetPriority(priority, &pr);
2280 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
2281 ok(pr == 0, "pr=%d, expected 0\n", pr);
2283 hres = IInternetPriority_SetPriority(priority, 1);
2284 ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
2286 hres = IInternetPriority_GetPriority(priority, &pr);
2287 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
2288 ok(pr == 1, "pr=%d, expected 1\n", pr);
2290 IInternetPriority_Release(priority);
2293 static void test_early_abort(const CLSID *clsid)
2295 IInternetProtocol *protocol;
2298 hres = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2299 &IID_IInternetProtocol, (void**)&protocol);
2300 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
2302 hres = IInternetProtocol_Abort(protocol, E_ABORT, 0);
2303 ok(hres == S_OK, "Abort failed: %08x\n", hres);
2305 hres = IInternetProtocol_Abort(protocol, E_FAIL, 0);
2306 ok(hres == S_OK, "Abort failed: %08x\n", hres);
2308 IInternetProtocol_Release(protocol);
2311 static BOOL file_protocol_start(IInternetProtocol *protocol, LPCWSTR url,
2312 IInternetProtocolEx *protocolex, IUri *uri, BOOL is_first)
2316 SET_EXPECT(GetBindInfo);
2317 if(!(bindf & BINDF_FROMURLMON))
2318 SET_EXPECT(ReportProgress_DIRECTBIND);
2320 SET_EXPECT(ReportProgress_SENDINGREQUEST);
2321 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
2322 if(bindf & BINDF_FROMURLMON)
2323 SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
2325 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
2327 SET_EXPECT(ReportData);
2329 SET_EXPECT(ReportResult);
2331 expect_hrResult = S_OK;
2334 hres = IInternetProtocolEx_StartEx(protocolex, uri, &protocol_sink, &bind_info, 0, 0);
2335 ok(hres == S_OK, "StartEx failed: %08x\n", hres);
2337 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
2338 if(hres == INET_E_RESOURCE_NOT_FOUND) {
2339 win_skip("Start failed\n");
2342 ok(hres == S_OK, "Start failed: %08x\n", hres);
2345 CHECK_CALLED(GetBindInfo);
2346 if(!(bindf & BINDF_FROMURLMON))
2347 CHECK_CALLED(ReportProgress_DIRECTBIND);
2349 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
2350 CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE);
2351 if(bindf & BINDF_FROMURLMON)
2352 CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE);
2354 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
2356 CHECK_CALLED(ReportData);
2358 CHECK_CALLED(ReportResult);
2363 static void test_file_protocol_url(LPCWSTR url)
2365 IInternetProtocolInfo *protocol_info;
2367 IClassFactory *factory;
2368 IInternetProtocol *protocol;
2373 hres = CoGetClassObject(&CLSID_FileProtocol, CLSCTX_INPROC_SERVER, NULL,
2374 &IID_IUnknown, (void**)&unk);
2375 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
2379 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
2380 ok(hres == E_NOINTERFACE,
2381 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
2383 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
2384 ok(hres == S_OK, "Could not get IClassFactory interface\n");
2385 IUnknown_Release(unk);
2389 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
2390 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
2392 if(SUCCEEDED(hres)) {
2393 if(file_protocol_start(protocol, url, NULL, NULL, TRUE)) {
2394 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
2395 ok(hres == S_OK, "Read failed: %08x\n", hres);
2396 ok(cb == 2, "cb=%u expected 2\n", cb);
2397 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
2398 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
2399 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
2400 ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres);
2401 ok(cb == 0, "cb=%u expected 0\n", cb);
2402 hres = IInternetProtocol_UnlockRequest(protocol);
2403 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2406 if(file_protocol_start(protocol, url, NULL, NULL, FALSE)) {
2407 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
2408 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
2409 hres = IInternetProtocol_LockRequest(protocol, 0);
2410 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
2411 hres = IInternetProtocol_UnlockRequest(protocol);
2412 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2415 IInternetProtocol_Release(protocol);
2418 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
2419 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
2420 if(SUCCEEDED(hres)) {
2421 if(file_protocol_start(protocol, url, NULL, NULL, TRUE)) {
2422 hres = IInternetProtocol_LockRequest(protocol, 0);
2423 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
2424 hres = IInternetProtocol_Terminate(protocol, 0);
2425 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2426 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
2427 ok(hres == S_OK, "Read failed: %08x\n\n", hres);
2428 hres = IInternetProtocol_UnlockRequest(protocol);
2429 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2430 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
2431 ok(hres == S_OK, "Read failed: %08x\n", hres);
2432 hres = IInternetProtocol_Terminate(protocol, 0);
2433 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2436 IInternetProtocol_Release(protocol);
2439 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
2440 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
2441 if(SUCCEEDED(hres)) {
2442 if(file_protocol_start(protocol, url, NULL, NULL, TRUE)) {
2443 hres = IInternetProtocol_Terminate(protocol, 0);
2444 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2445 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
2446 ok(hres == S_OK, "Read failed: %08x\n", hres);
2447 ok(cb == 2, "cb=%u expected 2\n", cb);
2450 IInternetProtocol_Release(protocol);
2454 IInternetProtocolEx *protocolex;
2457 hres = pCreateUri(url, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri);
2458 ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
2460 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocolEx, (void**)&protocolex);
2461 ok(hres == S_OK, "Could not get IInternetProtocolEx: %08x\n", hres);
2463 if(file_protocol_start(NULL, NULL, protocolex, uri, TRUE)) {
2464 hres = IInternetProtocolEx_Read(protocolex, buf, 2, &cb);
2465 ok(hres == S_OK, "Read failed: %08x\n", hres);
2466 hres = IInternetProtocolEx_LockRequest(protocolex, 0);
2467 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
2468 hres = IInternetProtocolEx_UnlockRequest(protocolex);
2469 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2473 IInternetProtocolEx_Release(protocolex);
2475 win_skip("Skipping file protocol StartEx tests\n");
2478 IClassFactory_Release(factory);
2481 static void test_file_protocol_fail(void)
2483 IInternetProtocol *protocol;
2486 static const WCHAR index_url2[] =
2487 {'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0};
2489 hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2490 &IID_IInternetProtocol, (void**)&protocol);
2491 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
2495 SET_EXPECT(GetBindInfo);
2496 expect_hrResult = MK_E_SYNTAX;
2497 hres = IInternetProtocol_Start(protocol, wszIndexHtml, &protocol_sink, &bind_info, 0, 0);
2498 ok(hres == MK_E_SYNTAX ||
2499 hres == E_INVALIDARG,
2500 "Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres);
2501 CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
2503 SET_EXPECT(GetBindInfo);
2504 if(!(bindf & BINDF_FROMURLMON))
2505 SET_EXPECT(ReportProgress_DIRECTBIND);
2506 SET_EXPECT(ReportProgress_SENDINGREQUEST);
2507 SET_EXPECT(ReportResult);
2508 expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
2509 hres = IInternetProtocol_Start(protocol, index_url, &protocol_sink, &bind_info, 0, 0);
2510 ok(hres == INET_E_RESOURCE_NOT_FOUND,
2511 "Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres);
2512 CHECK_CALLED(GetBindInfo);
2513 if(!(bindf & BINDF_FROMURLMON))
2514 CHECK_CALLED(ReportProgress_DIRECTBIND);
2515 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
2516 CHECK_CALLED(ReportResult);
2518 IInternetProtocol_Release(protocol);
2520 hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
2521 &IID_IInternetProtocol, (void**)&protocol);
2522 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
2526 SET_EXPECT(GetBindInfo);
2527 if(!(bindf & BINDF_FROMURLMON))
2528 SET_EXPECT(ReportProgress_DIRECTBIND);
2529 SET_EXPECT(ReportProgress_SENDINGREQUEST);
2530 SET_EXPECT(ReportResult);
2531 expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
2533 hres = IInternetProtocol_Start(protocol, index_url2, &protocol_sink, &bind_info, 0, 0);
2534 ok(hres == INET_E_RESOURCE_NOT_FOUND,
2535 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres);
2536 CHECK_CALLED(GetBindInfo);
2537 if(!(bindf & BINDF_FROMURLMON))
2538 CHECK_CALLED(ReportProgress_DIRECTBIND);
2539 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
2540 CHECK_CALLED(ReportResult);
2542 SET_EXPECT(GetBindInfo);
2543 hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
2544 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
2545 CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
2547 SET_EXPECT(GetBindInfo);
2548 hres = IInternetProtocol_Start(protocol, emptyW, &protocol_sink, &bind_info, 0, 0);
2549 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
2550 CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
2552 IInternetProtocol_Release(protocol);
2555 static void test_file_protocol(void) {
2556 WCHAR buf[INTERNET_MAX_URL_LENGTH], file_name_buf[MAX_PATH];
2561 static const WCHAR wszFile[] = {'f','i','l','e',':',0};
2562 static const WCHAR wszFile2[] = {'f','i','l','e',':','/','/',0};
2563 static const WCHAR wszFile3[] = {'f','i','l','e',':','/','/','/',0};
2564 static const WCHAR wszFile4[] = {'f','i','l','e',':','\\','\\',0};
2565 static const char html_doc[] = "<HTML></HTML>";
2567 trace("Testing file protocol...\n");
2568 init_test(FILE_TEST, 0);
2570 SetLastError(0xdeadbeef);
2571 file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
2572 FILE_ATTRIBUTE_NORMAL, NULL);
2573 if(!file && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
2575 win_skip("Detected Win9x or WinMe\n");
2578 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
2579 if(file == INVALID_HANDLE_VALUE)
2581 WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL);
2584 file_name = wszIndexHtml;
2586 test_file_protocol_url(index_url);
2587 bindf = BINDF_FROMURLMON;
2588 test_file_protocol_url(index_url);
2589 bindf = BINDF_FROMURLMON | BINDF_NEEDFILE;
2590 test_file_protocol_url(index_url);
2592 memcpy(buf, wszFile, sizeof(wszFile));
2593 len = sizeof(wszFile)/sizeof(WCHAR)-1;
2594 len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
2596 memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
2598 file_name = buf + sizeof(wszFile)/sizeof(WCHAR)-1;
2600 test_file_protocol_url(buf);
2601 bindf = BINDF_FROMURLMON;
2602 test_file_protocol_url(buf);
2604 memcpy(buf, wszFile2, sizeof(wszFile2));
2605 len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
2606 file_name_buf[len++] = '\\';
2607 memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
2608 lstrcpyW(buf+sizeof(wszFile2)/sizeof(WCHAR)-1, file_name_buf);
2609 file_name = file_name_buf;
2611 test_file_protocol_url(buf);
2612 bindf = BINDF_FROMURLMON;
2613 test_file_protocol_url(buf);
2615 buf[sizeof(wszFile2)/sizeof(WCHAR)] = '|';
2616 test_file_protocol_url(buf);
2618 memcpy(buf, wszFile3, sizeof(wszFile3));
2619 len = sizeof(wszFile3)/sizeof(WCHAR)-1;
2620 len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len);
2622 memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml));
2624 file_name = buf + sizeof(wszFile3)/sizeof(WCHAR)-1;
2626 test_file_protocol_url(buf);
2627 bindf = BINDF_FROMURLMON;
2628 test_file_protocol_url(buf);
2630 memcpy(buf, wszFile4, sizeof(wszFile4));
2631 len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf);
2632 file_name_buf[len++] = '\\';
2633 memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml));
2634 lstrcpyW(buf+sizeof(wszFile4)/sizeof(WCHAR)-1, file_name_buf);
2635 file_name = file_name_buf;
2637 test_file_protocol_url(buf);
2638 bindf = BINDF_FROMURLMON;
2639 test_file_protocol_url(buf);
2641 buf[sizeof(wszFile4)/sizeof(WCHAR)] = '|';
2642 test_file_protocol_url(buf);
2644 DeleteFileW(wszIndexHtml);
2647 test_file_protocol_fail();
2648 bindf = BINDF_FROMURLMON;
2649 test_file_protocol_fail();
2652 static BOOL http_protocol_start(LPCWSTR url, BOOL use_iuri)
2654 static BOOL got_user_agent = FALSE;
2658 if(use_iuri && pCreateUri) {
2659 hres = pCreateUri(url, 0, 0, &uri);
2660 ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
2663 SET_EXPECT(GetBindInfo);
2664 if (!(bindf & BINDF_FROMURLMON))
2665 SET_EXPECT(ReportProgress_DIRECTBIND);
2667 SET_EXPECT(GetBindString_USER_AGENT);
2668 SET_EXPECT(GetBindString_ACCEPT_MIMES);
2669 SET_EXPECT(QueryService_HttpNegotiate);
2670 SET_EXPECT(BeginningTransaction);
2671 SET_EXPECT(GetRootSecurityId);
2672 if(http_post_test) {
2673 SET_EXPECT(GetBindString_POST_COOKIE);
2674 if(http_post_test == TYMED_ISTREAM)
2675 SET_EXPECT(Stream_Seek);
2679 IInternetProtocolEx *protocolex;
2681 hres = IInternetProtocol_QueryInterface(async_protocol, &IID_IInternetProtocolEx, (void**)&protocolex);
2682 ok(hres == S_OK, "Could not get IInternetProtocolEx iface: %08x\n", hres);
2684 hres = IInternetProtocolEx_StartEx(protocolex, uri, &protocol_sink, &bind_info, 0, 0);
2685 ok(hres == S_OK, "Start failed: %08x\n", hres);
2687 IInternetProtocolEx_Release(protocolex);
2690 hres = IInternetProtocol_Start(async_protocol, url, &protocol_sink, &bind_info, 0, 0);
2691 ok(hres == S_OK, "Start failed: %08x\n", hres);
2696 CHECK_CALLED(GetBindInfo);
2697 if (!(bindf & BINDF_FROMURLMON))
2698 CHECK_CALLED(ReportProgress_DIRECTBIND);
2699 if (!got_user_agent)
2701 CHECK_CALLED(GetBindString_USER_AGENT);
2702 got_user_agent = TRUE;
2704 CHECK_CALLED(GetBindString_ACCEPT_MIMES);
2705 CHECK_CALLED(QueryService_HttpNegotiate);
2706 CHECK_CALLED(BeginningTransaction);
2707 /* GetRootSecurityId called on WinXP but not on Win98 */
2708 CLEAR_CALLED(GetRootSecurityId);
2709 if(http_post_test) {
2710 CHECK_CALLED(GetBindString_POST_COOKIE);
2711 if(http_post_test == TYMED_ISTREAM)
2712 CHECK_CALLED(Stream_Seek);
2718 static void test_protocol_terminate(IInternetProtocol *protocol)
2724 hres = IInternetProtocol_LockRequest(protocol, 0);
2725 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
2727 hres = IInternetProtocol_Read(protocol, buf, 1, &cb);
2728 ok(hres == test_abort ? S_OK : S_FALSE, "Read failed: %08x\n", hres);
2730 hres = IInternetProtocol_Terminate(protocol, 0);
2731 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
2733 /* This wait is to give the internet handles being freed in Terminate
2734 * enough time to actually terminate in all cases. Internet handles
2735 * terminate asynchronously and native reuses the main InternetOpen
2736 * handle. The only case in which this seems to be necessary is on
2737 * wine with native wininet and urlmon, resulting in the next time
2738 * test_http_protocol_url being called the first data notification actually
2739 * being an extra last data notification from the previous connection
2740 * about once out of every ten times. */
2743 hres = IInternetProtocol_UnlockRequest(protocol);
2744 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
2747 static void test_http_info(IInternetProtocol *protocol)
2749 IWinInetHttpInfo *info;
2752 hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetHttpInfo, (void**)&info);
2753 ok(hres == S_OK, "Could not get IWinInterHttpInfo iface: %08x\n", hres);
2757 IWinInetHttpInfo_Release(info);
2760 /* is_first refers to whether this is the first call to this function
2762 static void test_http_protocol_url(LPCWSTR url, int prot, DWORD flags, DWORD tymed)
2764 IInternetProtocolInfo *protocol_info;
2765 IClassFactory *factory;
2769 init_test(prot, flags);
2771 http_post_test = tymed;
2773 hres = CoGetClassObject(prot == HTTPS_TEST ? &CLSID_HttpSProtocol : &CLSID_HttpProtocol,
2774 CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
2775 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
2779 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
2780 ok(hres == E_NOINTERFACE,
2781 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
2784 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
2785 ok(hres == S_OK, "Could not get IClassFactory interface\n");
2786 IUnknown_Release(unk);
2790 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
2791 (void**)&async_protocol);
2792 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
2793 if(SUCCEEDED(hres)) {
2798 test_priority(async_protocol);
2799 test_http_info(async_protocol);
2801 SET_EXPECT(ReportProgress_COOKIE_SENT);
2802 SET_EXPECT(ReportProgress_FINDINGRESOURCE);
2803 SET_EXPECT(ReportProgress_CONNECTING);
2804 SET_EXPECT(ReportProgress_SENDINGREQUEST);
2806 SET_EXPECT(ReportProgress_REDIRECTING);
2807 SET_EXPECT(ReportProgress_PROXYDETECTING);
2808 if(prot == HTTP_TEST)
2809 SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
2811 SET_EXPECT(QueryService_HttpSecurity);
2812 if(!(bindf & BINDF_FROMURLMON)) {
2813 SET_EXPECT(OnResponse);
2814 SET_EXPECT(ReportProgress_RAWMIMETYPE);
2815 SET_EXPECT(ReportData);
2820 if(!http_protocol_start(url, (flags & TEST_USEIURI) != 0))
2823 if(!direct_read && !test_abort)
2824 SET_EXPECT(ReportResult);
2825 expect_hrResult = test_abort ? E_ABORT : S_OK;
2829 while(wait_for_switch) {
2830 WaitForSingleObject(event_continue, INFINITE);
2831 CHECK_CALLED(Switch); /* Set in ReportData */
2832 call_continue(&continue_protdata);
2833 SetEvent(event_continue_done);
2836 hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
2837 ok((hres == E_PENDING && cb==0) ||
2838 (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
2840 WaitForSingleObject(event_complete, INFINITE);
2841 if(bindf & BINDF_FROMURLMON)
2842 CHECK_CALLED(Switch);
2844 CHECK_CALLED(ReportData);
2845 if(prot == HTTPS_TEST)
2846 CLEAR_CALLED(QueryService_HttpSecurity);
2849 if(bindf & BINDF_FROMURLMON)
2852 SET_EXPECT(ReportData);
2853 hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb);
2854 if(hres == E_PENDING) {
2855 hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
2856 ok((hres == E_PENDING && cb==0) ||
2857 (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
2858 WaitForSingleObject(event_complete, INFINITE);
2859 if(bindf & BINDF_FROMURLMON)
2860 CHECK_CALLED(Switch);
2862 CHECK_CALLED(ReportData);
2867 SET_EXPECT(ReportResult);
2868 hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0);
2869 ok(hres == S_OK, "Abort failed: %08x\n", hres);
2870 CHECK_CALLED(ReportResult);
2872 hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0);
2873 ok(hres == INET_E_RESULT_DISPATCHED, "Abort failed: %08x\n", hres);
2877 if(bindf & BINDF_FROMURLMON)
2878 CHECK_NOT_CALLED(Switch);
2880 CHECK_NOT_CALLED(ReportData);
2885 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
2886 CHECK_CALLED(ReportResult);
2889 if(prot == HTTPS_TEST)
2890 CLEAR_CALLED(ReportProgress_SENDINGREQUEST);
2892 hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0);
2893 ok(hres == INET_E_RESULT_DISPATCHED, "Abort failed: %08x\n", hres);
2895 test_protocol_terminate(async_protocol);
2897 hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0);
2898 ok(hres == S_OK, "Abort failed: %08x\n", hres);
2900 ref = IInternetProtocol_Release(async_protocol);
2901 ok(!ref, "ref=%x\n", ref);
2904 IClassFactory_Release(factory);
2907 static void test_http_protocol(void)
2909 static const WCHAR winehq_url[] =
2910 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.',
2911 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
2912 static const WCHAR posttest_url[] =
2913 {'h','t','t','p',':','/','/','c','r','o','s','s','o','v','e','r','.',
2914 'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m','/',
2915 'p','o','s','t','t','e','s','t','.','p','h','p',0};
2916 static const WCHAR redirect_url[] =
2917 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
2918 't','e','s','t','r','e','d','i','r','e','c','t',0};
2919 static const WCHAR winetest_url[] =
2920 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/','d','a','t','a','/',0};
2922 trace("Testing http protocol (not from urlmon)...\n");
2923 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
2924 test_http_protocol_url(winehq_url, HTTP_TEST, TEST_FIRST_HTTP, TYMED_NULL);
2926 trace("Testing http protocol (from urlmon)...\n");
2927 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON;
2928 test_http_protocol_url(winehq_url, HTTP_TEST, 0, TYMED_NULL);
2930 trace("Testing http protocol (to file)...\n");
2931 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NEEDFILE;
2932 test_http_protocol_url(winehq_url, HTTP_TEST, 0, TYMED_NULL);
2934 trace("Testing http protocol (post data)...\n");
2935 /* Without this flag we get a ReportProgress_CACHEFILENAMEAVAILABLE
2936 * notification with BINDVERB_POST */
2937 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
2938 test_http_protocol_url(posttest_url, HTTP_TEST, TEST_FIRST_HTTP|TEST_POST, TYMED_HGLOBAL);
2940 trace("Testing http protocol (post data stream)...\n");
2941 test_http_protocol_url(posttest_url, HTTP_TEST, TEST_FIRST_HTTP|TEST_POST|TEST_ASYNCREQ, TYMED_ISTREAM);
2943 trace("Testing http protocol (direct read)...\n");
2944 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON;
2945 test_http_protocol_url(winehq_url, HTTP_TEST, TEST_DIRECT_READ|TEST_USEIURI, TYMED_NULL);
2947 trace("Testing http protocol (redirected)...\n");
2948 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON;
2949 test_http_protocol_url(redirect_url, HTTP_TEST, TEST_REDIRECT, TYMED_NULL);
2951 trace("Testing http protocol abort...\n");
2952 test_http_protocol_url(winetest_url, HTTP_TEST, TEST_ABORT, TYMED_NULL);
2954 test_early_abort(&CLSID_HttpProtocol);
2955 test_early_abort(&CLSID_HttpSProtocol);
2958 static void test_https_protocol(void)
2960 static const WCHAR codeweavers_url[] =
2961 {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s',
2962 '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0};
2964 trace("Testing https protocol (from urlmon)...\n");
2965 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
2966 test_http_protocol_url(codeweavers_url, HTTPS_TEST, TEST_FIRST_HTTP, TYMED_NULL);
2970 static void test_ftp_protocol(void)
2972 IInternetProtocolInfo *protocol_info;
2973 IClassFactory *factory;
2980 static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g',
2981 '/','p','u','b','/','o','t','h','e','r','/',
2982 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0};
2984 trace("Testing ftp protocol...\n");
2986 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE;
2987 state = STATE_STARTDOWNLOADING;
2988 tested_protocol = FTP_TEST;
2989 first_data_notif = TRUE;
2990 expect_hrResult = E_PENDING;
2992 hres = CoGetClassObject(&CLSID_FtpProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
2993 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
2997 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
2998 ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
3000 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
3001 ok(hres == S_OK, "Could not get IClassFactory interface\n");
3002 IUnknown_Release(unk);
3006 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
3007 (void**)&async_protocol);
3008 IClassFactory_Release(factory);
3009 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
3011 test_priority(async_protocol);
3012 test_http_info(async_protocol);
3014 SET_EXPECT(GetBindInfo);
3015 SET_EXPECT(ReportProgress_FINDINGRESOURCE);
3016 SET_EXPECT(ReportProgress_CONNECTING);
3017 SET_EXPECT(ReportProgress_SENDINGREQUEST);
3020 hres = IInternetProtocol_Start(async_protocol, ftp_urlW, &protocol_sink, &bind_info, 0, 0);
3021 ok(hres == S_OK, "Start failed: %08x\n", hres);
3022 CHECK_CALLED(GetBindInfo);
3024 SET_EXPECT(ReportResult);
3026 hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb);
3027 ok((hres == E_PENDING && cb==0) ||
3028 (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb);
3030 WaitForSingleObject(event_complete, INFINITE);
3033 hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb);
3034 if(hres == E_PENDING)
3035 WaitForSingleObject(event_complete, INFINITE);
3040 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
3041 CHECK_CALLED(ReportResult);
3042 CHECK_CALLED(Switch);
3044 test_protocol_terminate(async_protocol);
3047 IInternetProtocolEx *protocolex;
3049 hres = IInternetProtocol_QueryInterface(async_protocol, &IID_IInternetProtocolEx, (void**)&protocolex);
3050 ok(hres == S_OK, "Could not get IInternetProtocolEx iface: %08x\n", hres);
3051 IInternetProtocolEx_Release(protocolex);
3054 ref = IInternetProtocol_Release(async_protocol);
3055 ok(!ref, "ref=%d\n", ref);
3057 test_early_abort(&CLSID_FtpProtocol);
3060 static void test_gopher_protocol(void)
3062 IInternetProtocolInfo *protocol_info;
3063 IClassFactory *factory;
3067 trace("Testing gopher protocol...\n");
3069 hres = CoGetClassObject(&CLSID_GopherProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
3071 hres == REGDB_E_CLASSNOTREG, /* Gopher protocol has been removed as of Vista */
3072 "CoGetClassObject failed: %08x\n", hres);
3076 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
3077 ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres);
3079 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
3080 ok(hres == S_OK, "Could not get IClassFactory interface\n");
3081 IUnknown_Release(unk);
3085 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
3086 (void**)&async_protocol);
3087 IClassFactory_Release(factory);
3088 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
3090 test_priority(async_protocol);
3092 IInternetProtocol_Release(async_protocol);
3094 test_early_abort(&CLSID_GopherProtocol);
3097 static void test_mk_protocol(void)
3099 IInternetProtocolInfo *protocol_info;
3100 IInternetProtocol *protocol;
3101 IClassFactory *factory;
3105 static const WCHAR wrong_url1[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e',
3106 ':',':','/','t','e','s','t','.','h','t','m','l',0};
3107 static const WCHAR wrong_url2[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0};
3109 trace("Testing mk protocol...\n");
3110 init_test(MK_TEST, 0);
3112 hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL,
3113 &IID_IUnknown, (void**)&unk);
3114 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
3116 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
3117 ok(hres == E_NOINTERFACE,
3118 "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n",
3121 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
3122 ok(hres == S_OK, "Could not get IClassFactory interface\n");
3123 IUnknown_Release(unk);
3127 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol,
3129 IClassFactory_Release(factory);
3130 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
3132 SET_EXPECT(GetBindInfo);
3133 hres = IInternetProtocol_Start(protocol, wrong_url1, &protocol_sink, &bind_info, 0, 0);
3134 ok(hres == MK_E_SYNTAX || hres == INET_E_INVALID_URL,
3135 "Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres);
3136 CLEAR_CALLED(GetBindInfo);
3138 SET_EXPECT(GetBindInfo);
3139 SET_EXPECT(ReportProgress_DIRECTBIND);
3140 SET_EXPECT(ReportProgress_SENDINGREQUEST);
3141 SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
3142 SET_EXPECT(ReportResult);
3143 expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
3145 hres = IInternetProtocol_Start(protocol, wrong_url2, &protocol_sink, &bind_info, 0, 0);
3146 ok(hres == INET_E_RESOURCE_NOT_FOUND ||
3147 hres == INET_E_INVALID_URL, /* win2k3 */
3148 "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres);
3150 if (hres == INET_E_RESOURCE_NOT_FOUND) {
3151 CHECK_CALLED(GetBindInfo);
3152 CLEAR_CALLED(ReportProgress_DIRECTBIND);
3153 CHECK_CALLED(ReportProgress_SENDINGREQUEST);
3154 CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
3155 CHECK_CALLED(ReportResult);
3157 CLEAR_CALLED(GetBindInfo);
3158 CLEAR_CALLED(ReportProgress_DIRECTBIND);
3159 CLEAR_CALLED(ReportProgress_SENDINGREQUEST);
3160 CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE);
3161 CLEAR_CALLED(ReportResult);
3164 IInternetProtocol_Release(protocol);
3167 static void test_CreateBinding(void)
3169 IInternetProtocol *protocol;
3170 IInternetPriority *priority;
3171 IInternetSession *session;
3172 IWinInetHttpInfo *http_info;
3173 IWinInetInfo *inet_info;
3179 static const WCHAR test_url[] =
3180 {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0};
3181 static const WCHAR wsz_test[] = {'t','e','s','t',0};
3183 trace("Testing CreateBinding...\n");
3184 init_test(BIND_TEST, TEST_BINDING);
3186 hres = pCoInternetGetSession(0, &session, 0);
3187 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3189 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, wsz_test, 0, NULL, 0);
3190 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3192 hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0);
3193 binding_protocol = protocol;
3194 ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
3195 ok(protocol != NULL, "protocol == NULL\n");
3197 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info);
3198 ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres);
3200 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&binding_sink);
3201 ok(hres == S_OK, "Could not get IInternetProtocolSink: %08x\n", hres);
3203 hres = IInternetProtocol_Start(protocol, test_url, NULL, &bind_info, 0, 0);
3204 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
3205 hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, NULL, 0, 0);
3206 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
3207 hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
3208 ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
3210 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
3211 ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres);
3214 hres = IInternetPriority_GetPriority(priority, &p);
3215 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
3216 ok(!p, "p=%d\n", p);
3219 hres = IInternetPriority_SetPriority(priority, 100);
3220 ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
3223 hres = IInternetPriority_GetPriority(priority, &p);
3224 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
3225 ok(p == 100, "p=%d\n", p);
3227 hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&inet_info);
3228 ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres);
3230 SET_EXPECT(QueryService_InternetProtocol);
3231 SET_EXPECT(CreateInstance);
3232 SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
3233 SET_EXPECT(SetPriority);
3236 expect_hrResult = S_OK;
3237 hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, &bind_info, 0, 0);
3238 ok(hres == S_OK, "Start failed: %08x\n", hres);
3240 CHECK_CALLED(QueryService_InternetProtocol);
3241 CHECK_CALLED(CreateInstance);
3242 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
3243 CHECK_CALLED(SetPriority);
3244 CHECK_CALLED(Start);
3246 SET_EXPECT(QueryInterface_IWinInetInfo);
3247 hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&inet_info);
3248 ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres);
3249 CHECK_CALLED(QueryInterface_IWinInetInfo);
3251 SET_EXPECT(QueryInterface_IWinInetInfo);
3252 hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&inet_info);
3253 ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres);
3254 CHECK_CALLED(QueryInterface_IWinInetInfo);
3256 SET_EXPECT(QueryInterface_IWinInetHttpInfo);
3257 hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetHttpInfo, (void**)&http_info);
3258 ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres);
3259 CHECK_CALLED(QueryInterface_IWinInetHttpInfo);
3263 hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read);
3264 ok(hres == S_OK, "Read failed: %08x\n", hres);
3265 ok(read == 100, "read = %d\n", read);
3270 hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read);
3271 ok(hres == S_FALSE, "Read failed: %08x\n", hres);
3272 ok(!read, "read = %d\n", read);
3276 hres = IInternetPriority_GetPriority(priority, &p);
3277 ok(hres == S_OK, "GetPriority failed: %08x\n", hres);
3278 ok(p == 100, "p=%d\n", p);
3280 hres = IInternetPriority_SetPriority(priority, 101);
3281 ok(hres == S_OK, "SetPriority failed: %08x\n", hres);
3283 SET_EXPECT(Terminate);
3284 hres = IInternetProtocol_Terminate(protocol, 0xdeadbeef);
3285 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
3286 CHECK_CALLED(Terminate);
3288 SET_EXPECT(Continue);
3289 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
3290 ok(hres == S_OK, "Switch failed: %08x\n", hres);
3291 CHECK_CALLED(Continue);
3293 hres = IInternetProtocolSink_ReportProgress(binding_sink,
3294 BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW);
3295 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
3297 hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL);
3298 ok(hres == E_FAIL, "ReportResult failed: %08x, expected E_FAIL\n", hres);
3300 hres = IInternetProtocolSink_ReportData(binding_sink, 0, 0, 0);
3301 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
3303 IInternetProtocolSink_Release(binding_sink);
3304 IInternetPriority_Release(priority);
3305 IInternetBindInfo_Release(prot_bind_info);
3306 IInternetProtocol_Release(protocol);
3308 hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0);
3309 ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
3310 ok(protocol != NULL, "protocol == NULL\n");
3312 hres = IInternetProtocol_Abort(protocol, E_ABORT, 0);
3313 ok(hres == S_OK, "Abort failed: %08x\n", hres);
3315 hres = IInternetProtocol_Abort(protocol, E_FAIL, 0);
3316 ok(hres == S_OK, "Abort failed: %08x\n", hres);
3318 IInternetProtocol_Release(protocol);
3320 hres = IInternetSession_UnregisterNameSpace(session, &ClassFactory, wsz_test);
3321 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
3323 hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0);
3324 ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
3325 ok(protocol != NULL, "protocol == NULL\n");
3327 SET_EXPECT(QueryService_InternetProtocol);
3328 hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, &bind_info, 0, 0);
3329 ok(hres == MK_E_SYNTAX, "Start failed: %08x, expected MK_E_SYNTAX\n", hres);
3330 CHECK_CALLED(QueryService_InternetProtocol);
3332 IInternetProtocol_Release(protocol);
3334 IInternetSession_Release(session);
3337 static void test_binding(int prot, DWORD grf_pi, DWORD test_flags)
3339 IInternetProtocolEx *protocolex = NULL;
3340 IInternetProtocol *protocol;
3341 IInternetSession *session;
3348 init_test(prot, test_flags|TEST_BINDING);
3350 hres = pCoInternetGetSession(0, &session, 0);
3351 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres);
3353 if(test_flags & TEST_EMULATEPROT) {
3354 hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, protocol_names[prot], 0, NULL, 0);
3355 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres);
3358 hres = IInternetSession_CreateBinding(session, NULL, binding_urls[prot], NULL, NULL, &protocol, 0);
3359 binding_protocol = protocol;
3360 ok(hres == S_OK, "CreateBinding failed: %08x\n", hres);
3361 ok(protocol != NULL, "protocol == NULL\n");
3363 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info);
3364 ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres);
3366 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&binding_sink);
3367 ok(hres == S_OK, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres);
3369 if(test_flags & TEST_USEIURI) {
3370 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolEx, (void**)&protocolex);
3371 ok(hres == S_OK, "Could not get IInternetProtocolEx iface: %08x\n", hres);
3373 hres = pCreateUri(binding_urls[prot], Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri);
3374 ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
3378 SET_EXPECT(QueryService_InternetProtocol);
3379 SET_EXPECT(CreateInstance);
3380 SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
3381 SET_EXPECT(SetPriority);
3383 SET_EXPECT(StartEx);
3387 expect_hrResult = S_OK;
3390 hres = IInternetProtocolEx_StartEx(protocolex, uri, &protocol_sink, &bind_info, pi, 0);
3391 ok(hres == S_OK, "StartEx failed: %08x\n", hres);
3393 hres = IInternetProtocol_Start(protocol, binding_urls[prot], &protocol_sink, &bind_info, pi, 0);
3394 ok(hres == S_OK, "Start failed: %08x\n", hres);
3397 CHECK_CALLED(QueryService_InternetProtocol);
3398 CHECK_CALLED(CreateInstance);
3399 CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
3400 CHECK_CALLED(SetPriority);
3402 CHECK_CALLED(StartEx);
3404 CHECK_CALLED(Start);
3407 IInternetProtocolEx_Release(protocolex);
3411 if(prot == HTTP_TEST || prot == HTTPS_TEST) {
3412 while(prot_state < 4) {
3413 WaitForSingleObject(event_complete, INFINITE);
3414 if(mimefilter_test && filtered_protocol) {
3415 SET_EXPECT(Continue);
3416 IInternetProtocol_Continue(filtered_protocol, pdata);
3417 CHECK_CALLED(Continue);
3419 SET_EXPECT(Continue);
3420 IInternetProtocol_Continue(protocol, pdata);
3421 CHECK_CALLED(Continue);
3423 if(test_abort && prot_state == 2) {
3425 hres = IInternetProtocol_Abort(protocol, E_ABORT, 0);
3426 ok(hres == S_OK, "Abort failed: %08x\n", hres);
3427 CHECK_CALLED(Abort);
3429 hres = IInternetProtocol_Abort(protocol, E_ABORT, 0);
3430 ok(hres == S_OK, "Abort failed: %08x\n", hres);
3431 SetEvent(event_complete2);
3434 SetEvent(event_complete2);
3437 CHECK_CALLED(ReportData); /* Set in ReportResult */
3438 WaitForSingleObject(event_complete, INFINITE);
3441 SET_EXPECT(MimeFilter_LockRequest);
3443 SET_EXPECT(LockRequest);
3444 hres = IInternetProtocol_LockRequest(protocol, 0);
3445 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
3447 CHECK_CALLED(MimeFilter_LockRequest);
3449 CHECK_CALLED(LockRequest);
3452 SET_EXPECT(MimeFilter_UnlockRequest);
3454 SET_EXPECT(UnlockRequest);
3455 hres = IInternetProtocol_UnlockRequest(protocol);
3456 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
3458 CHECK_CALLED(MimeFilter_UnlockRequest);
3460 CHECK_CALLED(UnlockRequest);
3464 SET_EXPECT(MimeFilter_Terminate);
3466 SET_EXPECT(Terminate);
3467 hres = IInternetProtocol_Terminate(protocol, 0);
3468 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
3470 CLEAR_CALLED(MimeFilter_Terminate);
3472 CHECK_CALLED(Terminate);
3474 if(filtered_protocol)
3475 IInternetProtocol_Release(filtered_protocol);
3476 IInternetBindInfo_Release(prot_bind_info);
3477 IInternetProtocolSink_Release(binding_sink);
3478 ref = IInternetProtocol_Release(protocol);
3479 ok(!ref, "ref=%u, expected 0\n", ref);
3481 if(test_flags & TEST_EMULATEPROT) {
3482 hres = IInternetSession_UnregisterNameSpace(session, &ClassFactory, protocol_names[prot]);
3483 ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres);
3486 IInternetSession_Release(session);
3489 START_TEST(protocol)
3493 hurlmon = GetModuleHandle("urlmon.dll");
3494 pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession");
3495 pReleaseBindInfo = (void*) GetProcAddress(hurlmon, "ReleaseBindInfo");
3496 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri");
3498 if(!GetProcAddress(hurlmon, "CompareSecurityIds")) {
3499 win_skip("Various needed functions not present, too old IE\n");
3504 win_skip("CreateUri not supported\n");
3506 OleInitialize(NULL);
3508 event_complete = CreateEvent(NULL, FALSE, FALSE, NULL);
3509 event_complete2 = CreateEvent(NULL, FALSE, FALSE, NULL);
3510 event_continue = CreateEvent(NULL, FALSE, FALSE, NULL);
3511 event_continue_done = CreateEvent(NULL, FALSE, FALSE, NULL);
3512 thread_id = GetCurrentThreadId();
3514 test_file_protocol();
3515 test_http_protocol();
3516 test_https_protocol();
3517 test_ftp_protocol();
3518 test_gopher_protocol();
3520 test_CreateBinding();
3522 bindf &= ~BINDF_FROMURLMON;
3523 trace("Testing file binding (mime verification, emulate prot)...\n");
3524 test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
3525 trace("Testing http binding (mime verification, emulate prot)...\n");
3526 test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
3527 trace("Testing its binding (mime verification, emulate prot)...\n");
3528 test_binding(ITS_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
3529 trace("Testing http binding (mime verification, emulate prot, short read, direct read)...\n");
3530 test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_SHORT_READ|TEST_DIRECT_READ);
3531 trace("Testing file binding (mime verification, emulate prot, mime filter)...\n");
3532 test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER);
3533 trace("Testing http binding (mime verification, emulate prot, mime filter)...\n");
3534 test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER);
3535 trace("Testing http binding (mime verification, emulate prot, direct read)...\n");
3536 test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_DIRECT_READ);
3537 trace("Testing http binding (mime verification, emulate prot, abort)...\n");
3538 test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_ABORT);
3540 trace("Testing file binding (use IUri, mime verification, emulate prot)...\n");
3541 test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_USEIURI);
3542 trace("Testing file binding (use IUri, impl StartEx, mime verification, emulate prot)...\n");
3543 test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_USEIURI|TEST_IMPLPROTEX);
3544 trace("Testing file binding (impl StartEx, mime verification, emulate prot)...\n");
3545 test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_IMPLPROTEX);
3548 CloseHandle(event_complete);
3549 CloseHandle(event_complete2);
3550 CloseHandle(event_continue);
3551 CloseHandle(event_continue_done);