1*c2c66affSColin Finck /* 2*c2c66affSColin Finck * Copyright 2005-2011 Jacek Caban for CodeWeavers 3*c2c66affSColin Finck * 4*c2c66affSColin Finck * This library is free software; you can redistribute it and/or 5*c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public 6*c2c66affSColin Finck * License as published by the Free Software Foundation; either 7*c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version. 8*c2c66affSColin Finck * 9*c2c66affSColin Finck * This library is distributed in the hope that it will be useful, 10*c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of 11*c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12*c2c66affSColin Finck * Lesser General Public License for more details. 13*c2c66affSColin Finck * 14*c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public 15*c2c66affSColin Finck * License along with this library; if not, write to the Free Software 16*c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 17*c2c66affSColin Finck */ 18*c2c66affSColin Finck 19*c2c66affSColin Finck #define WIN32_NO_STATUS 20*c2c66affSColin Finck #define _INC_WINDOWS 21*c2c66affSColin Finck #define COM_NO_WINDOWS_H 22*c2c66affSColin Finck 23*c2c66affSColin Finck #define COBJMACROS 24*c2c66affSColin Finck #define CONST_VTABLE 25*c2c66affSColin Finck 26*c2c66affSColin Finck #include <wine/test.h> 27*c2c66affSColin Finck //#include <stdarg.h> 28*c2c66affSColin Finck #include <stdio.h> 29*c2c66affSColin Finck 30*c2c66affSColin Finck //#include "windef.h" 31*c2c66affSColin Finck //#include "winbase.h" 32*c2c66affSColin Finck #include <winnls.h> 33*c2c66affSColin Finck #include <ole2.h> 34*c2c66affSColin Finck #include <urlmon.h> 35*c2c66affSColin Finck #include <wininet.h> 36*c2c66affSColin Finck 37*c2c66affSColin Finck static HRESULT (WINAPI *pCoInternetGetSession)(DWORD, IInternetSession **, DWORD); 38*c2c66affSColin Finck static HRESULT (WINAPI *pReleaseBindInfo)(BINDINFO*); 39*c2c66affSColin Finck static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**); 40*c2c66affSColin Finck 41*c2c66affSColin Finck #define DEFINE_EXPECT(func) \ 42*c2c66affSColin Finck static BOOL expect_ ## func = FALSE, called_ ## func = FALSE 43*c2c66affSColin Finck 44*c2c66affSColin Finck #define SET_EXPECT(func) \ 45*c2c66affSColin Finck expect_ ## func = TRUE 46*c2c66affSColin Finck 47*c2c66affSColin Finck #define CHECK_EXPECT2(func) \ 48*c2c66affSColin Finck do { \ 49*c2c66affSColin Finck ok(expect_ ##func, "unexpected call " #func "\n"); \ 50*c2c66affSColin Finck called_ ## func = TRUE; \ 51*c2c66affSColin Finck }while(0) 52*c2c66affSColin Finck 53*c2c66affSColin Finck #define CHECK_EXPECT(func) \ 54*c2c66affSColin Finck do { \ 55*c2c66affSColin Finck CHECK_EXPECT2(func); \ 56*c2c66affSColin Finck expect_ ## func = FALSE; \ 57*c2c66affSColin Finck }while(0) 58*c2c66affSColin Finck 59*c2c66affSColin Finck #define CHECK_CALLED(func) \ 60*c2c66affSColin Finck do { \ 61*c2c66affSColin Finck ok(called_ ## func, "expected " #func "\n"); \ 62*c2c66affSColin Finck expect_ ## func = called_ ## func = FALSE; \ 63*c2c66affSColin Finck }while(0) 64*c2c66affSColin Finck 65*c2c66affSColin Finck #define CHECK_NOT_CALLED(func) \ 66*c2c66affSColin Finck do { \ 67*c2c66affSColin Finck ok(!called_ ## func, "unexpected " #func "\n"); \ 68*c2c66affSColin Finck expect_ ## func = called_ ## func = FALSE; \ 69*c2c66affSColin Finck }while(0) 70*c2c66affSColin Finck 71*c2c66affSColin Finck #define CLEAR_CALLED(func) \ 72*c2c66affSColin Finck expect_ ## func = called_ ## func = FALSE 73*c2c66affSColin Finck 74*c2c66affSColin Finck DEFINE_EXPECT(GetBindInfo); 75*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 76*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_DIRECTBIND); 77*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_RAWMIMETYPE); 78*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_FINDINGRESOURCE); 79*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_CONNECTING); 80*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_SENDINGREQUEST); 81*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); 82*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE); 83*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_PROTOCOLCLASSID); 84*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_COOKIE_SENT); 85*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_REDIRECTING); 86*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_ENCODING); 87*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_ACCEPTRANGES); 88*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_PROXYDETECTING); 89*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_LOADINGMIMEHANDLER); 90*c2c66affSColin Finck DEFINE_EXPECT(ReportProgress_DECODING); 91*c2c66affSColin Finck DEFINE_EXPECT(ReportData); 92*c2c66affSColin Finck DEFINE_EXPECT(ReportData2); 93*c2c66affSColin Finck DEFINE_EXPECT(ReportResult); 94*c2c66affSColin Finck DEFINE_EXPECT(GetBindString_ACCEPT_MIMES); 95*c2c66affSColin Finck DEFINE_EXPECT(GetBindString_USER_AGENT); 96*c2c66affSColin Finck DEFINE_EXPECT(GetBindString_POST_COOKIE); 97*c2c66affSColin Finck DEFINE_EXPECT(GetBindString_URL); 98*c2c66affSColin Finck DEFINE_EXPECT(GetBindString_ROOTDOC_URL); 99*c2c66affSColin Finck DEFINE_EXPECT(QueryService_HttpNegotiate); 100*c2c66affSColin Finck DEFINE_EXPECT(QueryService_InternetProtocol); 101*c2c66affSColin Finck DEFINE_EXPECT(QueryService_HttpSecurity); 102*c2c66affSColin Finck DEFINE_EXPECT(QueryService_IBindCallbackRedirect); 103*c2c66affSColin Finck DEFINE_EXPECT(QueryInterface_IWinInetInfo); 104*c2c66affSColin Finck DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo); 105*c2c66affSColin Finck DEFINE_EXPECT(BeginningTransaction); 106*c2c66affSColin Finck DEFINE_EXPECT(GetRootSecurityId); 107*c2c66affSColin Finck DEFINE_EXPECT(OnResponse); 108*c2c66affSColin Finck DEFINE_EXPECT(Switch); 109*c2c66affSColin Finck DEFINE_EXPECT(Continue); 110*c2c66affSColin Finck DEFINE_EXPECT(CreateInstance); 111*c2c66affSColin Finck DEFINE_EXPECT(Start); 112*c2c66affSColin Finck DEFINE_EXPECT(StartEx); 113*c2c66affSColin Finck DEFINE_EXPECT(Terminate); 114*c2c66affSColin Finck DEFINE_EXPECT(Read); 115*c2c66affSColin Finck DEFINE_EXPECT(Read2); 116*c2c66affSColin Finck DEFINE_EXPECT(SetPriority); 117*c2c66affSColin Finck DEFINE_EXPECT(LockRequest); 118*c2c66affSColin Finck DEFINE_EXPECT(UnlockRequest); 119*c2c66affSColin Finck DEFINE_EXPECT(Abort); 120*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_CreateInstance); 121*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_Start); 122*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_ReportData); 123*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_ReportResult); 124*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_Terminate); 125*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_LockRequest); 126*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_UnlockRequest); 127*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_Read); 128*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_Switch); 129*c2c66affSColin Finck DEFINE_EXPECT(MimeFilter_Continue); 130*c2c66affSColin Finck DEFINE_EXPECT(Stream_Seek); 131*c2c66affSColin Finck DEFINE_EXPECT(Stream_Read); 132*c2c66affSColin Finck DEFINE_EXPECT(Redirect); 133*c2c66affSColin Finck 134*c2c66affSColin Finck static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0}; 135*c2c66affSColin Finck static const WCHAR index_url[] = 136*c2c66affSColin Finck {'f','i','l','e',':','i','n','d','e','x','.','h','t','m','l',0}; 137*c2c66affSColin Finck 138*c2c66affSColin Finck static const WCHAR acc_mimeW[] = {'*','/','*',0}; 139*c2c66affSColin Finck static const WCHAR user_agentW[] = {'W','i','n','e',0}; 140*c2c66affSColin Finck static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0}; 141*c2c66affSColin Finck static const WCHAR hostW[] = {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}; 142*c2c66affSColin Finck static const WCHAR winehq_ipW[] = {'2','0','9','.','4','6','.','2','5','.','1','3','4',0}; 143*c2c66affSColin Finck static const WCHAR emptyW[] = {0}; 144*c2c66affSColin Finck static const WCHAR pjpegW[] = {'i','m','a','g','e','/','p','j','p','e','g',0}; 145*c2c66affSColin Finck static const WCHAR gifW[] = {'i','m','a','g','e','/','g','i','f',0}; 146*c2c66affSColin Finck 147*c2c66affSColin Finck static HRESULT expect_hrResult; 148*c2c66affSColin Finck static LPCWSTR file_name, http_url, expect_wsz; 149*c2c66affSColin Finck static IInternetProtocol *async_protocol = NULL; 150*c2c66affSColin Finck static BOOL first_data_notif, http_is_first, test_redirect, redirect_on_continue; 151*c2c66affSColin Finck static int prot_state, read_report_data, post_stream_read; 152*c2c66affSColin Finck static DWORD bindf, ex_priority , pi, bindinfo_options; 153*c2c66affSColin Finck static IInternetProtocol *binding_protocol, *filtered_protocol; 154*c2c66affSColin Finck static IInternetBindInfo *prot_bind_info; 155*c2c66affSColin Finck static IInternetProtocolSink *binding_sink, *filtered_sink; 156*c2c66affSColin Finck static void *expect_pv; 157*c2c66affSColin Finck static HANDLE event_complete, event_complete2, event_continue, event_continue_done; 158*c2c66affSColin Finck static BOOL binding_test; 159*c2c66affSColin Finck static PROTOCOLDATA protocoldata, *pdata, continue_protdata; 160*c2c66affSColin Finck static DWORD prot_read, filter_state, http_post_test, thread_id; 161*c2c66affSColin Finck static BOOL security_problem, test_async_req, impl_protex; 162*c2c66affSColin Finck static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort; 163*c2c66affSColin Finck static BOOL empty_file, no_mime, bind_from_cache, file_with_hash; 164*c2c66affSColin Finck 165*c2c66affSColin Finck enum { 166*c2c66affSColin Finck STATE_CONNECTING, 167*c2c66affSColin Finck STATE_SENDINGREQUEST, 168*c2c66affSColin Finck STATE_STARTDOWNLOADING, 169*c2c66affSColin Finck STATE_DOWNLOADING 170*c2c66affSColin Finck } state; 171*c2c66affSColin Finck 172*c2c66affSColin Finck static enum { 173*c2c66affSColin Finck FILE_TEST, 174*c2c66affSColin Finck HTTP_TEST, 175*c2c66affSColin Finck HTTPS_TEST, 176*c2c66affSColin Finck FTP_TEST, 177*c2c66affSColin Finck MK_TEST, 178*c2c66affSColin Finck ITS_TEST, 179*c2c66affSColin Finck BIND_TEST 180*c2c66affSColin Finck } tested_protocol; 181*c2c66affSColin Finck 182*c2c66affSColin Finck static const WCHAR protocol_names[][10] = { 183*c2c66affSColin Finck {'f','i','l','e',0}, 184*c2c66affSColin Finck {'h','t','t','p',0}, 185*c2c66affSColin Finck {'h','t','t','p','s',0}, 186*c2c66affSColin Finck {'f','t','p',0}, 187*c2c66affSColin Finck {'m','k',0}, 188*c2c66affSColin Finck {'i','t','s',0}, 189*c2c66affSColin Finck {'t','e','s','t',0} 190*c2c66affSColin Finck }; 191*c2c66affSColin Finck 192*c2c66affSColin Finck static const WCHAR binding_urls[][130] = { 193*c2c66affSColin Finck {'f','i','l','e',':','t','e','s','t','.','h','t','m','l',0}, 194*c2c66affSColin Finck {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.', 195*c2c66affSColin Finck 'o','r','g','/','s','i','t','e','/','a','b','o','u','t',0}, 196*c2c66affSColin Finck {'h','t','t','p','s',':','/','/','w','w','w','.','c','o','d','e','w','e','a','v','e','r','s', 197*c2c66affSColin Finck '.','c','o','m','/','t','e','s','t','.','h','t','m','l',0}, 198*c2c66affSColin Finck {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g', 199*c2c66affSColin Finck '/','p','u','b','/','o','t','h','e','r', 200*c2c66affSColin Finck '/','w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0}, 201*c2c66affSColin Finck {'m','k',':','t','e','s','t',0}, 202*c2c66affSColin Finck {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0}, 203*c2c66affSColin Finck {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0} 204*c2c66affSColin Finck }; 205*c2c66affSColin Finck 206*c2c66affSColin Finck static const CHAR post_data[] = "mode=Test"; 207*c2c66affSColin Finck 208*c2c66affSColin Finck static int strcmp_wa(LPCWSTR strw, const char *stra) 209*c2c66affSColin Finck { 210*c2c66affSColin Finck CHAR buf[512]; 211*c2c66affSColin Finck WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL); 212*c2c66affSColin Finck return lstrcmpA(stra, buf); 213*c2c66affSColin Finck } 214*c2c66affSColin Finck 215*c2c66affSColin Finck static const char *w2a(LPCWSTR str) 216*c2c66affSColin Finck { 217*c2c66affSColin Finck static char buf[INTERNET_MAX_URL_LENGTH]; 218*c2c66affSColin Finck WideCharToMultiByte(CP_ACP, 0, str, -1, buf, sizeof(buf), NULL, NULL); 219*c2c66affSColin Finck return buf; 220*c2c66affSColin Finck } 221*c2c66affSColin Finck 222*c2c66affSColin Finck static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv) 223*c2c66affSColin Finck { 224*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) 225*c2c66affSColin Finck || IsEqualGUID(&IID_IHttpSecurity, riid)) { 226*c2c66affSColin Finck *ppv = iface; 227*c2c66affSColin Finck return S_OK; 228*c2c66affSColin Finck } 229*c2c66affSColin Finck 230*c2c66affSColin Finck ok(0, "unexpected call\n"); 231*c2c66affSColin Finck return E_NOINTERFACE; 232*c2c66affSColin Finck } 233*c2c66affSColin Finck 234*c2c66affSColin Finck static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface) 235*c2c66affSColin Finck { 236*c2c66affSColin Finck return 2; 237*c2c66affSColin Finck } 238*c2c66affSColin Finck 239*c2c66affSColin Finck static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface) 240*c2c66affSColin Finck { 241*c2c66affSColin Finck return 1; 242*c2c66affSColin Finck } 243*c2c66affSColin Finck 244*c2c66affSColin Finck static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity* iface, REFGUID rguidReason, HWND *phwnd) 245*c2c66affSColin Finck { 246*c2c66affSColin Finck trace("HttpSecurity_GetWindow\n"); 247*c2c66affSColin Finck 248*c2c66affSColin Finck return S_FALSE; 249*c2c66affSColin Finck } 250*c2c66affSColin Finck 251*c2c66affSColin Finck static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem) 252*c2c66affSColin Finck { 253*c2c66affSColin Finck trace("Security problem: %u\n", dwProblem); 254*c2c66affSColin Finck ok(dwProblem == ERROR_INTERNET_SEC_CERT_REV_FAILED, "Expected ERROR_INTERNET_SEC_CERT_REV_FAILED got %u\n", dwProblem); 255*c2c66affSColin Finck 256*c2c66affSColin Finck /* Only retry once */ 257*c2c66affSColin Finck if (security_problem) 258*c2c66affSColin Finck return E_ABORT; 259*c2c66affSColin Finck 260*c2c66affSColin Finck security_problem = TRUE; 261*c2c66affSColin Finck SET_EXPECT(BeginningTransaction); 262*c2c66affSColin Finck 263*c2c66affSColin Finck return RPC_E_RETRY; 264*c2c66affSColin Finck } 265*c2c66affSColin Finck 266*c2c66affSColin Finck static IHttpSecurityVtbl HttpSecurityVtbl = { 267*c2c66affSColin Finck HttpSecurity_QueryInterface, 268*c2c66affSColin Finck HttpSecurity_AddRef, 269*c2c66affSColin Finck HttpSecurity_Release, 270*c2c66affSColin Finck HttpSecurity_GetWindow, 271*c2c66affSColin Finck HttpSecurity_OnSecurityProblem 272*c2c66affSColin Finck }; 273*c2c66affSColin Finck 274*c2c66affSColin Finck static IHttpSecurity http_security = { &HttpSecurityVtbl }; 275*c2c66affSColin Finck 276*c2c66affSColin Finck static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv) 277*c2c66affSColin Finck { 278*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) 279*c2c66affSColin Finck || IsEqualGUID(&IID_IHttpNegotiate, riid) 280*c2c66affSColin Finck || IsEqualGUID(&IID_IHttpNegotiate2, riid)) { 281*c2c66affSColin Finck *ppv = iface; 282*c2c66affSColin Finck return S_OK; 283*c2c66affSColin Finck } 284*c2c66affSColin Finck 285*c2c66affSColin Finck ok(0, "unexpected call\n"); 286*c2c66affSColin Finck return E_NOINTERFACE; 287*c2c66affSColin Finck } 288*c2c66affSColin Finck 289*c2c66affSColin Finck static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface) 290*c2c66affSColin Finck { 291*c2c66affSColin Finck return 2; 292*c2c66affSColin Finck } 293*c2c66affSColin Finck 294*c2c66affSColin Finck static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface) 295*c2c66affSColin Finck { 296*c2c66affSColin Finck return 1; 297*c2c66affSColin Finck } 298*c2c66affSColin Finck 299*c2c66affSColin Finck static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL, 300*c2c66affSColin Finck LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders) 301*c2c66affSColin Finck { 302*c2c66affSColin Finck LPWSTR addl_headers; 303*c2c66affSColin Finck 304*c2c66affSColin Finck static const WCHAR wszHeaders[] = 305*c2c66affSColin Finck {'C','o','n','t','e','n','t','-','T','y','p','e',':',' ','a','p','p','l','i','c','a','t', 306*c2c66affSColin Finck 'i','o','n','/','x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o', 307*c2c66affSColin Finck 'd','e','d','\r','\n',0}; 308*c2c66affSColin Finck 309*c2c66affSColin Finck CHECK_EXPECT(BeginningTransaction); 310*c2c66affSColin Finck 311*c2c66affSColin Finck if(binding_test) 312*c2c66affSColin Finck ok(!lstrcmpW(szURL, binding_urls[tested_protocol]), "szURL != http_url\n"); 313*c2c66affSColin Finck else 314*c2c66affSColin Finck ok(!lstrcmpW(szURL, http_url), "szURL != http_url\n"); 315*c2c66affSColin Finck ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved); 316*c2c66affSColin Finck ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n"); 317*c2c66affSColin Finck if(pszAdditionalHeaders) 318*c2c66affSColin Finck { 319*c2c66affSColin Finck ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n"); 320*c2c66affSColin Finck if (http_post_test) 321*c2c66affSColin Finck { 322*c2c66affSColin Finck addl_headers = CoTaskMemAlloc(sizeof(wszHeaders)); 323*c2c66affSColin Finck memcpy(addl_headers, wszHeaders, sizeof(wszHeaders)); 324*c2c66affSColin Finck *pszAdditionalHeaders = addl_headers; 325*c2c66affSColin Finck } 326*c2c66affSColin Finck } 327*c2c66affSColin Finck 328*c2c66affSColin Finck return S_OK; 329*c2c66affSColin Finck } 330*c2c66affSColin Finck 331*c2c66affSColin Finck static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode, 332*c2c66affSColin Finck LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) 333*c2c66affSColin Finck { 334*c2c66affSColin Finck CHECK_EXPECT(OnResponse); 335*c2c66affSColin Finck 336*c2c66affSColin Finck ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode); 337*c2c66affSColin Finck ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n"); 338*c2c66affSColin Finck ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n"); 339*c2c66affSColin Finck ok(pszAdditionalRequestHeaders == NULL, "pszAdditionalHeaders != NULL\n"); 340*c2c66affSColin Finck 341*c2c66affSColin Finck return S_OK; 342*c2c66affSColin Finck } 343*c2c66affSColin Finck 344*c2c66affSColin Finck static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface, 345*c2c66affSColin Finck BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved) 346*c2c66affSColin Finck { 347*c2c66affSColin Finck static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0}; 348*c2c66affSColin Finck 349*c2c66affSColin Finck CHECK_EXPECT(GetRootSecurityId); 350*c2c66affSColin Finck 351*c2c66affSColin Finck ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved); 352*c2c66affSColin Finck ok(pbSecurityId != NULL, "pbSecurityId == NULL\n"); 353*c2c66affSColin Finck ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n"); 354*c2c66affSColin Finck 355*c2c66affSColin Finck if(pcbSecurityId) { 356*c2c66affSColin Finck ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId); 357*c2c66affSColin Finck *pcbSecurityId = sizeof(sec_id); 358*c2c66affSColin Finck } 359*c2c66affSColin Finck 360*c2c66affSColin Finck if(pbSecurityId) 361*c2c66affSColin Finck memcpy(pbSecurityId, sec_id, sizeof(sec_id)); 362*c2c66affSColin Finck 363*c2c66affSColin Finck return E_FAIL; 364*c2c66affSColin Finck } 365*c2c66affSColin Finck 366*c2c66affSColin Finck static IHttpNegotiate2Vtbl HttpNegotiateVtbl = { 367*c2c66affSColin Finck HttpNegotiate_QueryInterface, 368*c2c66affSColin Finck HttpNegotiate_AddRef, 369*c2c66affSColin Finck HttpNegotiate_Release, 370*c2c66affSColin Finck HttpNegotiate_BeginningTransaction, 371*c2c66affSColin Finck HttpNegotiate_OnResponse, 372*c2c66affSColin Finck HttpNegotiate_GetRootSecurityId 373*c2c66affSColin Finck }; 374*c2c66affSColin Finck 375*c2c66affSColin Finck static IHttpNegotiate2 http_negotiate = { &HttpNegotiateVtbl }; 376*c2c66affSColin Finck 377*c2c66affSColin Finck static HRESULT WINAPI BindCallbackRedirect_QueryInterface(IBindCallbackRedirect *iface, REFIID riid, void **ppv) 378*c2c66affSColin Finck { 379*c2c66affSColin Finck ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid)); 380*c2c66affSColin Finck *ppv = NULL; 381*c2c66affSColin Finck return E_NOINTERFACE; 382*c2c66affSColin Finck } 383*c2c66affSColin Finck 384*c2c66affSColin Finck static ULONG WINAPI BindCallbackRedirect_AddRef(IBindCallbackRedirect *iface) 385*c2c66affSColin Finck { 386*c2c66affSColin Finck return 2; 387*c2c66affSColin Finck } 388*c2c66affSColin Finck 389*c2c66affSColin Finck static ULONG WINAPI BindCallbackRedirect_Release(IBindCallbackRedirect *iface) 390*c2c66affSColin Finck { 391*c2c66affSColin Finck return 1; 392*c2c66affSColin Finck } 393*c2c66affSColin Finck 394*c2c66affSColin Finck static HRESULT WINAPI BindCallbackRedirect_Redirect(IBindCallbackRedirect *iface, const WCHAR *url, VARIANT_BOOL *cancel) 395*c2c66affSColin Finck { 396*c2c66affSColin Finck CHECK_EXPECT(Redirect); 397*c2c66affSColin Finck *cancel = VARIANT_FALSE; 398*c2c66affSColin Finck return S_OK; 399*c2c66affSColin Finck } 400*c2c66affSColin Finck 401*c2c66affSColin Finck static const IBindCallbackRedirectVtbl BindCallbackRedirectVtbl = { 402*c2c66affSColin Finck BindCallbackRedirect_QueryInterface, 403*c2c66affSColin Finck BindCallbackRedirect_AddRef, 404*c2c66affSColin Finck BindCallbackRedirect_Release, 405*c2c66affSColin Finck BindCallbackRedirect_Redirect 406*c2c66affSColin Finck }; 407*c2c66affSColin Finck 408*c2c66affSColin Finck static IBindCallbackRedirect redirect_callback = { &BindCallbackRedirectVtbl }; 409*c2c66affSColin Finck 410*c2c66affSColin Finck static HRESULT QueryInterface(REFIID,void**); 411*c2c66affSColin Finck 412*c2c66affSColin Finck static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) 413*c2c66affSColin Finck { 414*c2c66affSColin Finck return QueryInterface(riid, ppv); 415*c2c66affSColin Finck } 416*c2c66affSColin Finck 417*c2c66affSColin Finck static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface) 418*c2c66affSColin Finck { 419*c2c66affSColin Finck return 2; 420*c2c66affSColin Finck } 421*c2c66affSColin Finck 422*c2c66affSColin Finck static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface) 423*c2c66affSColin Finck { 424*c2c66affSColin Finck return 1; 425*c2c66affSColin Finck } 426*c2c66affSColin Finck 427*c2c66affSColin Finck static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFGUID guidService, 428*c2c66affSColin Finck REFIID riid, void **ppv) 429*c2c66affSColin Finck { 430*c2c66affSColin Finck if(IsEqualGUID(&IID_IHttpNegotiate, guidService) || IsEqualGUID(&IID_IHttpNegotiate2, riid)) { 431*c2c66affSColin Finck CHECK_EXPECT2(QueryService_HttpNegotiate); 432*c2c66affSColin Finck return IHttpNegotiate2_QueryInterface(&http_negotiate, riid, ppv); 433*c2c66affSColin Finck } 434*c2c66affSColin Finck 435*c2c66affSColin Finck if(IsEqualGUID(&IID_IInternetProtocol, guidService)) { 436*c2c66affSColin Finck ok(IsEqualGUID(&IID_IInternetProtocol, riid), "unexpected riid\n"); 437*c2c66affSColin Finck CHECK_EXPECT(QueryService_InternetProtocol); 438*c2c66affSColin Finck return E_NOINTERFACE; 439*c2c66affSColin Finck } 440*c2c66affSColin Finck 441*c2c66affSColin Finck if(IsEqualGUID(&IID_IHttpSecurity, guidService)) { 442*c2c66affSColin Finck ok(IsEqualGUID(&IID_IHttpSecurity, riid), "unexpected riid\n"); 443*c2c66affSColin Finck CHECK_EXPECT(QueryService_HttpSecurity); 444*c2c66affSColin Finck return IHttpSecurity_QueryInterface(&http_security, riid, ppv); 445*c2c66affSColin Finck } 446*c2c66affSColin Finck 447*c2c66affSColin Finck if(IsEqualGUID(&IID_IBindCallbackRedirect, guidService)) { 448*c2c66affSColin Finck CHECK_EXPECT(QueryService_IBindCallbackRedirect); 449*c2c66affSColin Finck ok(IsEqualGUID(&IID_IBindCallbackRedirect, riid), "riid = %s\n", wine_dbgstr_guid(riid)); 450*c2c66affSColin Finck *ppv = &redirect_callback; 451*c2c66affSColin Finck return S_OK; 452*c2c66affSColin Finck } 453*c2c66affSColin Finck 454*c2c66affSColin Finck if(IsEqualGUID(&IID_IGetBindHandle, guidService)) { 455*c2c66affSColin Finck trace("QueryService(IID_IGetBindHandle)\n"); 456*c2c66affSColin Finck *ppv = NULL; 457*c2c66affSColin Finck return E_NOINTERFACE; 458*c2c66affSColin Finck } 459*c2c66affSColin Finck 460*c2c66affSColin Finck if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) { 461*c2c66affSColin Finck trace("QueryService(IID_IWindowForBindingUI)\n"); 462*c2c66affSColin Finck *ppv = NULL; 463*c2c66affSColin Finck return E_NOINTERFACE; 464*c2c66affSColin Finck } 465*c2c66affSColin Finck 466*c2c66affSColin Finck ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService)); 467*c2c66affSColin Finck return E_FAIL; 468*c2c66affSColin Finck } 469*c2c66affSColin Finck 470*c2c66affSColin Finck static const IServiceProviderVtbl ServiceProviderVtbl = { 471*c2c66affSColin Finck ServiceProvider_QueryInterface, 472*c2c66affSColin Finck ServiceProvider_AddRef, 473*c2c66affSColin Finck ServiceProvider_Release, 474*c2c66affSColin Finck ServiceProvider_QueryService 475*c2c66affSColin Finck }; 476*c2c66affSColin Finck 477*c2c66affSColin Finck static IServiceProvider service_provider = { &ServiceProviderVtbl }; 478*c2c66affSColin Finck 479*c2c66affSColin Finck static HRESULT WINAPI Stream_QueryInterface(IStream *iface, REFIID riid, void **ppv) 480*c2c66affSColin Finck { 481*c2c66affSColin Finck static const IID IID_strm_unknown = {0x2f68429a,0x199a,0x4043,{0x93,0x11,0xf2,0xfe,0x7c,0x13,0xcc,0xb9}}; 482*c2c66affSColin Finck 483*c2c66affSColin Finck if(!IsEqualGUID(&IID_strm_unknown, riid)) /* IE11 */ 484*c2c66affSColin Finck ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid)); 485*c2c66affSColin Finck 486*c2c66affSColin Finck *ppv = NULL; 487*c2c66affSColin Finck return E_NOINTERFACE; 488*c2c66affSColin Finck } 489*c2c66affSColin Finck 490*c2c66affSColin Finck static ULONG WINAPI Stream_AddRef(IStream *iface) 491*c2c66affSColin Finck { 492*c2c66affSColin Finck return 2; 493*c2c66affSColin Finck } 494*c2c66affSColin Finck 495*c2c66affSColin Finck static ULONG WINAPI Stream_Release(IStream *iface) 496*c2c66affSColin Finck { 497*c2c66affSColin Finck return 1; 498*c2c66affSColin Finck } 499*c2c66affSColin Finck 500*c2c66affSColin Finck static HRESULT WINAPI Stream_Read(IStream *iface, void *pv, 501*c2c66affSColin Finck ULONG cb, ULONG *pcbRead) 502*c2c66affSColin Finck { 503*c2c66affSColin Finck CHECK_EXPECT2(Stream_Read); 504*c2c66affSColin Finck 505*c2c66affSColin Finck ok(GetCurrentThreadId() != thread_id, "wrong thread %d\n", GetCurrentThreadId()); 506*c2c66affSColin Finck 507*c2c66affSColin Finck ok(pv != NULL, "pv == NULL\n"); 508*c2c66affSColin Finck ok(cb == 0x20000 || broken(cb == 0x2000), "cb = %d\n", cb); 509*c2c66affSColin Finck ok(pcbRead != NULL, "pcbRead == NULL\n"); 510*c2c66affSColin Finck 511*c2c66affSColin Finck if(post_stream_read) { 512*c2c66affSColin Finck *pcbRead = 0; 513*c2c66affSColin Finck return S_FALSE; 514*c2c66affSColin Finck } 515*c2c66affSColin Finck 516*c2c66affSColin Finck memcpy(pv, post_data, sizeof(post_data)-1); 517*c2c66affSColin Finck post_stream_read += *pcbRead = sizeof(post_data)-1; 518*c2c66affSColin Finck return S_OK; 519*c2c66affSColin Finck } 520*c2c66affSColin Finck 521*c2c66affSColin Finck static HRESULT WINAPI Stream_Write(IStream *iface, const void *pv, 522*c2c66affSColin Finck ULONG cb, ULONG *pcbWritten) 523*c2c66affSColin Finck { 524*c2c66affSColin Finck ok(0, "unexpected call\n"); 525*c2c66affSColin Finck return E_NOTIMPL; 526*c2c66affSColin Finck } 527*c2c66affSColin Finck 528*c2c66affSColin Finck static HRESULT WINAPI Stream_Seek(IStream *iface, LARGE_INTEGER dlibMove, 529*c2c66affSColin Finck DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) 530*c2c66affSColin Finck { 531*c2c66affSColin Finck CHECK_EXPECT(Stream_Seek); 532*c2c66affSColin Finck 533*c2c66affSColin Finck ok(!dlibMove.QuadPart, "dlibMove != 0\n"); 534*c2c66affSColin Finck ok(dwOrigin == STREAM_SEEK_SET, "dwOrigin = %d\n", dwOrigin); 535*c2c66affSColin Finck ok(!plibNewPosition, "plibNewPosition == NULL\n"); 536*c2c66affSColin Finck 537*c2c66affSColin Finck return S_OK; 538*c2c66affSColin Finck } 539*c2c66affSColin Finck 540*c2c66affSColin Finck static HRESULT WINAPI Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize) 541*c2c66affSColin Finck { 542*c2c66affSColin Finck ok(0, "unexpected call\n"); 543*c2c66affSColin Finck return E_NOTIMPL; 544*c2c66affSColin Finck } 545*c2c66affSColin Finck 546*c2c66affSColin Finck static HRESULT WINAPI Stream_CopyTo(IStream *iface, IStream *pstm, 547*c2c66affSColin Finck ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten) 548*c2c66affSColin Finck { 549*c2c66affSColin Finck ok(0, "unexpected call\n"); 550*c2c66affSColin Finck return E_NOTIMPL; 551*c2c66affSColin Finck } 552*c2c66affSColin Finck 553*c2c66affSColin Finck static HRESULT WINAPI Stream_Commit(IStream *iface, DWORD grfCommitFlags) 554*c2c66affSColin Finck { 555*c2c66affSColin Finck ok(0, "unexpected call\n"); 556*c2c66affSColin Finck return E_NOTIMPL; 557*c2c66affSColin Finck } 558*c2c66affSColin Finck 559*c2c66affSColin Finck static HRESULT WINAPI Stream_Revert(IStream *iface) 560*c2c66affSColin Finck { 561*c2c66affSColin Finck ok(0, "unexpected call\n"); 562*c2c66affSColin Finck return E_NOTIMPL; 563*c2c66affSColin Finck } 564*c2c66affSColin Finck 565*c2c66affSColin Finck static HRESULT WINAPI Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset, 566*c2c66affSColin Finck ULARGE_INTEGER cb, DWORD dwLockType) 567*c2c66affSColin Finck { 568*c2c66affSColin Finck ok(0, "unexpected call\n"); 569*c2c66affSColin Finck return E_NOTIMPL; 570*c2c66affSColin Finck } 571*c2c66affSColin Finck 572*c2c66affSColin Finck static HRESULT WINAPI Stream_UnlockRegion(IStream *iface, 573*c2c66affSColin Finck ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 574*c2c66affSColin Finck { 575*c2c66affSColin Finck ok(0, "unexpected call\n"); 576*c2c66affSColin Finck return E_NOTIMPL; 577*c2c66affSColin Finck } 578*c2c66affSColin Finck 579*c2c66affSColin Finck static HRESULT WINAPI Stream_Stat(IStream *iface, STATSTG *pstatstg, 580*c2c66affSColin Finck DWORD dwStatFlag) 581*c2c66affSColin Finck { 582*c2c66affSColin Finck ok(0, "unexpected call\n"); 583*c2c66affSColin Finck return E_NOTIMPL; 584*c2c66affSColin Finck } 585*c2c66affSColin Finck 586*c2c66affSColin Finck static HRESULT WINAPI Stream_Clone(IStream *iface, IStream **ppstm) 587*c2c66affSColin Finck { 588*c2c66affSColin Finck ok(0, "unexpected call\n"); 589*c2c66affSColin Finck return E_NOTIMPL; 590*c2c66affSColin Finck } 591*c2c66affSColin Finck 592*c2c66affSColin Finck static const IStreamVtbl StreamVtbl = { 593*c2c66affSColin Finck Stream_QueryInterface, 594*c2c66affSColin Finck Stream_AddRef, 595*c2c66affSColin Finck Stream_Release, 596*c2c66affSColin Finck Stream_Read, 597*c2c66affSColin Finck Stream_Write, 598*c2c66affSColin Finck Stream_Seek, 599*c2c66affSColin Finck Stream_SetSize, 600*c2c66affSColin Finck Stream_CopyTo, 601*c2c66affSColin Finck Stream_Commit, 602*c2c66affSColin Finck Stream_Revert, 603*c2c66affSColin Finck Stream_LockRegion, 604*c2c66affSColin Finck Stream_UnlockRegion, 605*c2c66affSColin Finck Stream_Stat, 606*c2c66affSColin Finck Stream_Clone 607*c2c66affSColin Finck }; 608*c2c66affSColin Finck 609*c2c66affSColin Finck static IStream Stream = { &StreamVtbl }; 610*c2c66affSColin Finck 611*c2c66affSColin Finck static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv) 612*c2c66affSColin Finck { 613*c2c66affSColin Finck return QueryInterface(riid, ppv); 614*c2c66affSColin Finck } 615*c2c66affSColin Finck 616*c2c66affSColin Finck static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface) 617*c2c66affSColin Finck { 618*c2c66affSColin Finck return 2; 619*c2c66affSColin Finck } 620*c2c66affSColin Finck 621*c2c66affSColin Finck static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface) 622*c2c66affSColin Finck { 623*c2c66affSColin Finck return 1; 624*c2c66affSColin Finck } 625*c2c66affSColin Finck 626*c2c66affSColin Finck static void call_continue(PROTOCOLDATA *protocol_data) 627*c2c66affSColin Finck { 628*c2c66affSColin Finck HRESULT hres; 629*c2c66affSColin Finck 630*c2c66affSColin Finck if (winetest_debug > 1) 631*c2c66affSColin Finck trace("continue in state %d\n", state); 632*c2c66affSColin Finck 633*c2c66affSColin Finck if(state == STATE_CONNECTING) { 634*c2c66affSColin Finck if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST) { 635*c2c66affSColin Finck if (http_is_first){ 636*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_FINDINGRESOURCE); 637*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_PROXYDETECTING); 638*c2c66affSColin Finck } 639*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_CONNECTING); 640*c2c66affSColin Finck } 641*c2c66affSColin Finck if(tested_protocol == FTP_TEST) 642*c2c66affSColin Finck todo_wine CHECK_CALLED(ReportProgress_SENDINGREQUEST); 643*c2c66affSColin Finck else if (tested_protocol != HTTPS_TEST) 644*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 645*c2c66affSColin Finck if(test_redirect && !(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)) 646*c2c66affSColin Finck CHECK_CALLED(ReportProgress_REDIRECTING); 647*c2c66affSColin Finck state = test_async_req ? STATE_SENDINGREQUEST : STATE_STARTDOWNLOADING; 648*c2c66affSColin Finck } 649*c2c66affSColin Finck 650*c2c66affSColin Finck switch(state) { 651*c2c66affSColin Finck case STATE_SENDINGREQUEST: 652*c2c66affSColin Finck SET_EXPECT(Stream_Read); 653*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 654*c2c66affSColin Finck break; 655*c2c66affSColin Finck case STATE_STARTDOWNLOADING: 656*c2c66affSColin Finck if((tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) 657*c2c66affSColin Finck && (!test_redirect || !(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))) { 658*c2c66affSColin Finck SET_EXPECT(OnResponse); 659*c2c66affSColin Finck if(tested_protocol == HTTPS_TEST || test_redirect || test_abort || empty_file) 660*c2c66affSColin Finck SET_EXPECT(ReportProgress_ACCEPTRANGES); 661*c2c66affSColin Finck SET_EXPECT(ReportProgress_ENCODING); 662*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 663*c2c66affSColin Finck if(bindf & BINDF_NEEDFILE) 664*c2c66affSColin Finck SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); 665*c2c66affSColin Finck } 666*c2c66affSColin Finck default: 667*c2c66affSColin Finck break; 668*c2c66affSColin Finck } 669*c2c66affSColin Finck 670*c2c66affSColin Finck if(state != STATE_SENDINGREQUEST && (!test_redirect || !(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))) 671*c2c66affSColin Finck SET_EXPECT(ReportData); 672*c2c66affSColin Finck hres = IInternetProtocol_Continue(async_protocol, protocol_data); 673*c2c66affSColin Finck ok(hres == S_OK, "Continue failed: %08x\n", hres); 674*c2c66affSColin Finck if(tested_protocol == FTP_TEST || security_problem) 675*c2c66affSColin Finck CLEAR_CALLED(ReportData); 676*c2c66affSColin Finck else if(state != STATE_SENDINGREQUEST && (!test_redirect || !(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))) 677*c2c66affSColin Finck CHECK_CALLED(ReportData); 678*c2c66affSColin Finck 679*c2c66affSColin Finck switch(state) { 680*c2c66affSColin Finck case STATE_SENDINGREQUEST: 681*c2c66affSColin Finck CHECK_CALLED(Stream_Read); 682*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 683*c2c66affSColin Finck state = STATE_STARTDOWNLOADING; 684*c2c66affSColin Finck break; 685*c2c66affSColin Finck case STATE_STARTDOWNLOADING: 686*c2c66affSColin Finck if(!security_problem) { 687*c2c66affSColin Finck state = STATE_DOWNLOADING; 688*c2c66affSColin Finck if((tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) 689*c2c66affSColin Finck && (!test_redirect || !(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))) { 690*c2c66affSColin Finck CHECK_CALLED(OnResponse); 691*c2c66affSColin Finck if(tested_protocol == HTTPS_TEST || empty_file) 692*c2c66affSColin Finck CHECK_CALLED(ReportProgress_ACCEPTRANGES); 693*c2c66affSColin Finck else if(test_redirect || test_abort) 694*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_ACCEPTRANGES); 695*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_ENCODING); 696*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 697*c2c66affSColin Finck if(bindf & BINDF_NEEDFILE) 698*c2c66affSColin Finck CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE); 699*c2c66affSColin Finck } 700*c2c66affSColin Finck } 701*c2c66affSColin Finck else 702*c2c66affSColin Finck { 703*c2c66affSColin Finck security_problem = FALSE; 704*c2c66affSColin Finck SET_EXPECT(ReportProgress_CONNECTING); 705*c2c66affSColin Finck } 706*c2c66affSColin Finck default: 707*c2c66affSColin Finck break; 708*c2c66affSColin Finck } 709*c2c66affSColin Finck } 710*c2c66affSColin Finck 711*c2c66affSColin Finck static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData) 712*c2c66affSColin Finck { 713*c2c66affSColin Finck if(tested_protocol == FTP_TEST) 714*c2c66affSColin Finck CHECK_EXPECT2(Switch); 715*c2c66affSColin Finck else 716*c2c66affSColin Finck CHECK_EXPECT(Switch); 717*c2c66affSColin Finck 718*c2c66affSColin Finck ok(pProtocolData != NULL, "pProtocolData == NULL\n"); 719*c2c66affSColin Finck if(binding_test) { 720*c2c66affSColin Finck ok(pProtocolData != &protocoldata, "pProtocolData == &protocoldata\n"); 721*c2c66affSColin Finck ok(pProtocolData->grfFlags == protocoldata.grfFlags, "grfFlags wrong %x/%x\n", 722*c2c66affSColin Finck pProtocolData->grfFlags, protocoldata.grfFlags ); 723*c2c66affSColin Finck ok(pProtocolData->dwState == protocoldata.dwState, "dwState wrong %x/%x\n", 724*c2c66affSColin Finck pProtocolData->dwState, protocoldata.dwState ); 725*c2c66affSColin Finck ok(pProtocolData->pData == protocoldata.pData, "pData wrong %p/%p\n", 726*c2c66affSColin Finck pProtocolData->pData, protocoldata.pData ); 727*c2c66affSColin Finck ok(pProtocolData->cbData == protocoldata.cbData, "cbData wrong %x/%x\n", 728*c2c66affSColin Finck pProtocolData->cbData, protocoldata.cbData ); 729*c2c66affSColin Finck } 730*c2c66affSColin Finck 731*c2c66affSColin Finck pdata = pProtocolData; 732*c2c66affSColin Finck 733*c2c66affSColin Finck if(binding_test) { 734*c2c66affSColin Finck SetEvent(event_complete); 735*c2c66affSColin Finck ok( WaitForSingleObject(event_complete2, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 736*c2c66affSColin Finck return S_OK; 737*c2c66affSColin Finck }if(direct_read) { 738*c2c66affSColin Finck continue_protdata = *pProtocolData; 739*c2c66affSColin Finck SetEvent(event_continue); 740*c2c66affSColin Finck ok( WaitForSingleObject(event_continue_done, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 741*c2c66affSColin Finck }else { 742*c2c66affSColin Finck call_continue(pProtocolData); 743*c2c66affSColin Finck SetEvent(event_complete); 744*c2c66affSColin Finck } 745*c2c66affSColin Finck 746*c2c66affSColin Finck return S_OK; 747*c2c66affSColin Finck } 748*c2c66affSColin Finck 749*c2c66affSColin Finck static const char *status_names[] = 750*c2c66affSColin Finck { 751*c2c66affSColin Finck "0", 752*c2c66affSColin Finck "FINDINGRESOURCE", 753*c2c66affSColin Finck "CONNECTING", 754*c2c66affSColin Finck "REDIRECTING", 755*c2c66affSColin Finck "BEGINDOWNLOADDATA", 756*c2c66affSColin Finck "DOWNLOADINGDATA", 757*c2c66affSColin Finck "ENDDOWNLOADDATA", 758*c2c66affSColin Finck "BEGINDOWNLOADCOMPONENTS", 759*c2c66affSColin Finck "INSTALLINGCOMPONENTS", 760*c2c66affSColin Finck "ENDDOWNLOADCOMPONENTS", 761*c2c66affSColin Finck "USINGCACHEDCOPY", 762*c2c66affSColin Finck "SENDINGREQUEST", 763*c2c66affSColin Finck "CLASSIDAVAILABLE", 764*c2c66affSColin Finck "MIMETYPEAVAILABLE", 765*c2c66affSColin Finck "CACHEFILENAMEAVAILABLE", 766*c2c66affSColin Finck "BEGINSYNCOPERATION", 767*c2c66affSColin Finck "ENDSYNCOPERATION", 768*c2c66affSColin Finck "BEGINUPLOADDATA", 769*c2c66affSColin Finck "UPLOADINGDATA", 770*c2c66affSColin Finck "ENDUPLOADINGDATA", 771*c2c66affSColin Finck "PROTOCOLCLASSID", 772*c2c66affSColin Finck "ENCODING", 773*c2c66affSColin Finck "VERIFIEDMIMETYPEAVAILABLE", 774*c2c66affSColin Finck "CLASSINSTALLLOCATION", 775*c2c66affSColin Finck "DECODING", 776*c2c66affSColin Finck "LOADINGMIMEHANDLER", 777*c2c66affSColin Finck "CONTENTDISPOSITIONATTACH", 778*c2c66affSColin Finck "FILTERREPORTMIMETYPE", 779*c2c66affSColin Finck "CLSIDCANINSTANTIATE", 780*c2c66affSColin Finck "IUNKNOWNAVAILABLE", 781*c2c66affSColin Finck "DIRECTBIND", 782*c2c66affSColin Finck "RAWMIMETYPE", 783*c2c66affSColin Finck "PROXYDETECTING", 784*c2c66affSColin Finck "ACCEPTRANGES", 785*c2c66affSColin Finck "COOKIE_SENT", 786*c2c66affSColin Finck "COMPACT_POLICY_RECEIVED", 787*c2c66affSColin Finck "COOKIE_SUPPRESSED", 788*c2c66affSColin Finck "COOKIE_STATE_UNKNOWN", 789*c2c66affSColin Finck "COOKIE_STATE_ACCEPT", 790*c2c66affSColin Finck "COOKIE_STATE_REJECT", 791*c2c66affSColin Finck "COOKIE_STATE_PROMPT", 792*c2c66affSColin Finck "COOKIE_STATE_LEASH", 793*c2c66affSColin Finck "COOKIE_STATE_DOWNGRADE", 794*c2c66affSColin Finck "POLICY_HREF", 795*c2c66affSColin Finck "P3P_HEADER", 796*c2c66affSColin Finck "SESSION_COOKIE_RECEIVED", 797*c2c66affSColin Finck "PERSISTENT_COOKIE_RECEIVED", 798*c2c66affSColin Finck "SESSION_COOKIES_ALLOWED", 799*c2c66affSColin Finck "CACHECONTROL", 800*c2c66affSColin Finck "CONTENTDISPOSITIONFILENAME", 801*c2c66affSColin Finck "MIMETEXTPLAINMISMATCH", 802*c2c66affSColin Finck "PUBLISHERAVAILABLE", 803*c2c66affSColin Finck "DISPLAYNAMEAVAILABLE" 804*c2c66affSColin Finck }; 805*c2c66affSColin Finck 806*c2c66affSColin Finck static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode, 807*c2c66affSColin Finck LPCWSTR szStatusText) 808*c2c66affSColin Finck { 809*c2c66affSColin Finck static const WCHAR null_guid[] = {'{','0','0','0','0','0','0','0','0','-','0','0','0','0','-', 810*c2c66affSColin Finck '0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0}; 811*c2c66affSColin Finck static const WCHAR text_plain[] = {'t','e','x','t','/','p','l','a','i','n',0}; 812*c2c66affSColin Finck 813*c2c66affSColin Finck if (winetest_debug > 1) 814*c2c66affSColin Finck { 815*c2c66affSColin Finck if (ulStatusCode < sizeof(status_names)/sizeof(status_names[0])) 816*c2c66affSColin Finck trace( "progress: %s %s\n", status_names[ulStatusCode], wine_dbgstr_w(szStatusText) ); 817*c2c66affSColin Finck else 818*c2c66affSColin Finck trace( "progress: %u %s\n", ulStatusCode, wine_dbgstr_w(szStatusText) ); 819*c2c66affSColin Finck } 820*c2c66affSColin Finck 821*c2c66affSColin Finck switch(ulStatusCode) { 822*c2c66affSColin Finck case BINDSTATUS_MIMETYPEAVAILABLE: 823*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_MIMETYPEAVAILABLE); 824*c2c66affSColin Finck if(tested_protocol != FILE_TEST && tested_protocol != ITS_TEST && !mimefilter_test && (pi & PI_MIMEVERIFICATION)) { 825*c2c66affSColin Finck if(!short_read || !direct_read) 826*c2c66affSColin Finck CHECK_CALLED(Read); /* set in Continue */ 827*c2c66affSColin Finck else if(short_read) 828*c2c66affSColin Finck CHECK_CALLED(Read2); /* set in Read */ 829*c2c66affSColin Finck } 830*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 831*c2c66affSColin Finck if(szStatusText) { 832*c2c66affSColin Finck if(tested_protocol == BIND_TEST) 833*c2c66affSColin Finck ok(!lstrcmpW(szStatusText, expect_wsz), "unexpected szStatusText %s\n", wine_dbgstr_w(szStatusText)); 834*c2c66affSColin Finck else if (http_post_test) 835*c2c66affSColin Finck ok(lstrlenW(text_plain) <= lstrlenW(szStatusText) && 836*c2c66affSColin Finck !memcmp(szStatusText, text_plain, lstrlenW(text_plain)*sizeof(WCHAR)), 837*c2c66affSColin Finck "szStatusText != text/plain\n"); 838*c2c66affSColin Finck else if(empty_file) 839*c2c66affSColin Finck ok(!strcmp_wa(szStatusText, "application/javascript"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 840*c2c66affSColin Finck else if((pi & PI_MIMEVERIFICATION) && emulate_prot && !mimefilter_test 841*c2c66affSColin Finck && tested_protocol==HTTP_TEST && !short_read) 842*c2c66affSColin Finck ok(lstrlenW(gifW) <= lstrlenW(szStatusText) && 843*c2c66affSColin Finck !memcmp(szStatusText, gifW, lstrlenW(gifW)*sizeof(WCHAR)), 844*c2c66affSColin Finck "szStatusText != image/gif\n"); 845*c2c66affSColin Finck else if(!mimefilter_test) 846*c2c66affSColin Finck ok(lstrlenW(text_htmlW) <= lstrlenW(szStatusText) && 847*c2c66affSColin Finck !memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)), 848*c2c66affSColin Finck "szStatusText != text/html\n"); 849*c2c66affSColin Finck } 850*c2c66affSColin Finck break; 851*c2c66affSColin Finck case BINDSTATUS_DIRECTBIND: 852*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_DIRECTBIND); 853*c2c66affSColin Finck ok(szStatusText == NULL, "szStatusText != NULL\n"); 854*c2c66affSColin Finck break; 855*c2c66affSColin Finck case BINDSTATUS_RAWMIMETYPE: 856*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_RAWMIMETYPE); 857*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 858*c2c66affSColin Finck if(szStatusText) 859*c2c66affSColin Finck ok(lstrlenW(szStatusText) < lstrlenW(text_htmlW) || 860*c2c66affSColin Finck !memcmp(szStatusText, text_htmlW, lstrlenW(text_htmlW)*sizeof(WCHAR)), 861*c2c66affSColin Finck "szStatusText != text/html\n"); 862*c2c66affSColin Finck break; 863*c2c66affSColin Finck case BINDSTATUS_CACHEFILENAMEAVAILABLE: 864*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); 865*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 866*c2c66affSColin Finck if(szStatusText) { 867*c2c66affSColin Finck if(binding_test) 868*c2c66affSColin Finck ok(!lstrcmpW(szStatusText, expect_wsz), "unexpected szStatusText\n"); 869*c2c66affSColin Finck else if(tested_protocol == FILE_TEST) 870*c2c66affSColin Finck ok(!lstrcmpW(szStatusText, file_name), "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 871*c2c66affSColin Finck else 872*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 873*c2c66affSColin Finck } 874*c2c66affSColin Finck break; 875*c2c66affSColin Finck case BINDSTATUS_FINDINGRESOURCE: 876*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_FINDINGRESOURCE); 877*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 878*c2c66affSColin Finck break; 879*c2c66affSColin Finck case BINDSTATUS_CONNECTING: 880*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_CONNECTING); 881*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 882*c2c66affSColin Finck break; 883*c2c66affSColin Finck case BINDSTATUS_SENDINGREQUEST: 884*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_SENDINGREQUEST); 885*c2c66affSColin Finck if(tested_protocol == FILE_TEST || tested_protocol == ITS_TEST) { 886*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 887*c2c66affSColin Finck if(szStatusText) 888*c2c66affSColin Finck ok(!*szStatusText, "wrong szStatusText\n"); 889*c2c66affSColin Finck } 890*c2c66affSColin Finck break; 891*c2c66affSColin Finck case BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE: 892*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE); 893*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 894*c2c66affSColin Finck if(szStatusText) 895*c2c66affSColin Finck ok(!strcmp_wa(szStatusText, "text/html"), "szStatusText != text/html\n"); 896*c2c66affSColin Finck break; 897*c2c66affSColin Finck case BINDSTATUS_PROTOCOLCLASSID: 898*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_PROTOCOLCLASSID); 899*c2c66affSColin Finck ok(szStatusText != NULL, "szStatusText == NULL\n"); 900*c2c66affSColin Finck ok(!lstrcmpW(szStatusText, null_guid), "unexpected classid %s\n", wine_dbgstr_w(szStatusText)); 901*c2c66affSColin Finck break; 902*c2c66affSColin Finck case BINDSTATUS_COOKIE_SENT: 903*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_COOKIE_SENT); 904*c2c66affSColin Finck ok(szStatusText == NULL, "szStatusText != NULL\n"); 905*c2c66affSColin Finck break; 906*c2c66affSColin Finck case BINDSTATUS_REDIRECTING: 907*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_REDIRECTING); 908*c2c66affSColin Finck if(test_redirect) 909*c2c66affSColin Finck ok(!strcmp_wa(szStatusText, "http://test.winehq.org/tests/hello.html"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 910*c2c66affSColin Finck else 911*c2c66affSColin Finck ok(szStatusText == NULL, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 912*c2c66affSColin Finck break; 913*c2c66affSColin Finck case BINDSTATUS_ENCODING: 914*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_ENCODING); 915*c2c66affSColin Finck ok(!strcmp_wa(szStatusText, "gzip"), "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 916*c2c66affSColin Finck break; 917*c2c66affSColin Finck case BINDSTATUS_ACCEPTRANGES: 918*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_ACCEPTRANGES); 919*c2c66affSColin Finck ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 920*c2c66affSColin Finck break; 921*c2c66affSColin Finck case BINDSTATUS_PROXYDETECTING: 922*c2c66affSColin Finck if(!called_ReportProgress_PROXYDETECTING) 923*c2c66affSColin Finck SET_EXPECT(ReportProgress_CONNECTING); 924*c2c66affSColin Finck CHECK_EXPECT2(ReportProgress_PROXYDETECTING); 925*c2c66affSColin Finck ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 926*c2c66affSColin Finck break; 927*c2c66affSColin Finck case BINDSTATUS_LOADINGMIMEHANDLER: 928*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_LOADINGMIMEHANDLER); 929*c2c66affSColin Finck ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 930*c2c66affSColin Finck break; 931*c2c66affSColin Finck case BINDSTATUS_DECODING: 932*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_DECODING); 933*c2c66affSColin Finck ok(!lstrcmpW(szStatusText, pjpegW), "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 934*c2c66affSColin Finck break; 935*c2c66affSColin Finck case BINDSTATUS_RESERVED_7: 936*c2c66affSColin Finck trace("BINDSTATUS_RESERVED_7\n"); 937*c2c66affSColin Finck break; 938*c2c66affSColin Finck case BINDSTATUS_RESERVED_8: 939*c2c66affSColin Finck trace("BINDSTATUS_RESERVED_8\n"); 940*c2c66affSColin Finck break; 941*c2c66affSColin Finck default: 942*c2c66affSColin Finck ok(0, "Unexpected status %d (%d)\n", ulStatusCode, ulStatusCode-BINDSTATUS_LAST); 943*c2c66affSColin Finck }; 944*c2c66affSColin Finck 945*c2c66affSColin Finck return S_OK; 946*c2c66affSColin Finck } 947*c2c66affSColin Finck 948*c2c66affSColin Finck static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, 949*c2c66affSColin Finck ULONG ulProgress, ULONG ulProgressMax) 950*c2c66affSColin Finck { 951*c2c66affSColin Finck HRESULT hres; 952*c2c66affSColin Finck 953*c2c66affSColin Finck static int rec_depth; 954*c2c66affSColin Finck rec_depth++; 955*c2c66affSColin Finck 956*c2c66affSColin Finck if(!mimefilter_test && (tested_protocol == FILE_TEST || tested_protocol == ITS_TEST)) { 957*c2c66affSColin Finck CHECK_EXPECT2(ReportData); 958*c2c66affSColin Finck 959*c2c66affSColin Finck ok(ulProgress == ulProgressMax, "ulProgress (%d) != ulProgressMax (%d)\n", 960*c2c66affSColin Finck ulProgress, ulProgressMax); 961*c2c66affSColin Finck if(!file_with_hash) 962*c2c66affSColin Finck ok(ulProgressMax == 13, "ulProgressMax=%d, expected 13\n", ulProgressMax); 963*c2c66affSColin Finck /* BSCF_SKIPDRAINDATAFORFILEURLS added in IE8 */ 964*c2c66affSColin Finck if(tested_protocol == FILE_TEST) 965*c2c66affSColin Finck ok((grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION)) || 966*c2c66affSColin Finck (grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_SKIPDRAINDATAFORFILEURLS)), 967*c2c66affSColin Finck "grcfBSCF = %08x\n", grfBSCF); 968*c2c66affSColin Finck else 969*c2c66affSColin Finck ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE), "grcfBSCF = %08x\n", grfBSCF); 970*c2c66affSColin Finck }else if(bind_from_cache) { 971*c2c66affSColin Finck CHECK_EXPECT(ReportData); 972*c2c66affSColin Finck 973*c2c66affSColin Finck ok(grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE), "grcfBSCF = %08x\n", grfBSCF); 974*c2c66affSColin Finck ok(ulProgress == 1000, "ulProgress = %u\n", ulProgress); 975*c2c66affSColin Finck ok(!ulProgressMax, "ulProgressMax = %u\n", ulProgressMax); 976*c2c66affSColin Finck }else if(direct_read) { 977*c2c66affSColin Finck BYTE buf[14096]; 978*c2c66affSColin Finck ULONG read; 979*c2c66affSColin Finck 980*c2c66affSColin Finck if(!read_report_data && rec_depth == 1) { 981*c2c66affSColin Finck BOOL reported_all_data = called_ReportData2; 982*c2c66affSColin Finck 983*c2c66affSColin Finck CHECK_EXPECT2(ReportData); 984*c2c66affSColin Finck 985*c2c66affSColin Finck if(short_read) { 986*c2c66affSColin Finck ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE) 987*c2c66affSColin Finck || grfBSCF == BSCF_FIRSTDATANOTIFICATION, /* < IE8 */ 988*c2c66affSColin Finck "grcfBSCF = %08x\n", grfBSCF); 989*c2c66affSColin Finck CHECK_CALLED(Read); /* Set in Continue */ 990*c2c66affSColin Finck first_data_notif = FALSE; 991*c2c66affSColin Finck }else if(first_data_notif) { 992*c2c66affSColin Finck ok(grfBSCF == BSCF_FIRSTDATANOTIFICATION, "grcfBSCF = %08x\n", grfBSCF); 993*c2c66affSColin Finck first_data_notif = FALSE; 994*c2c66affSColin Finck }else if(reported_all_data) { 995*c2c66affSColin Finck ok(grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION), 996*c2c66affSColin Finck "grcfBSCF = %08x\n", grfBSCF); 997*c2c66affSColin Finck }else if(!direct_read) { 998*c2c66affSColin Finck ok(grfBSCF == BSCF_INTERMEDIATEDATANOTIFICATION, "grcfBSCF = %08x\n", grfBSCF); 999*c2c66affSColin Finck } 1000*c2c66affSColin Finck 1001*c2c66affSColin Finck do { 1002*c2c66affSColin Finck read = 0; 1003*c2c66affSColin Finck if(emulate_prot) 1004*c2c66affSColin Finck SET_EXPECT(Read); 1005*c2c66affSColin Finck else 1006*c2c66affSColin Finck SET_EXPECT(ReportData2); 1007*c2c66affSColin Finck SET_EXPECT(ReportResult); 1008*c2c66affSColin Finck if(!emulate_prot) 1009*c2c66affSColin Finck SET_EXPECT(Switch); 1010*c2c66affSColin Finck hres = IInternetProtocol_Read(binding_test ? binding_protocol : async_protocol, expect_pv = buf, sizeof(buf), &read); 1011*c2c66affSColin Finck ok(hres == E_PENDING || hres == S_FALSE || hres == S_OK, "Read failed: %08x\n", hres); 1012*c2c66affSColin Finck if(hres == S_OK) 1013*c2c66affSColin Finck ok(read, "read == 0\n"); 1014*c2c66affSColin Finck if(reported_all_data) 1015*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x, expected S_FALSE\n", hres); 1016*c2c66affSColin Finck if(!emulate_prot && hres != E_PENDING) 1017*c2c66affSColin Finck CHECK_NOT_CALLED(Switch); /* otherwise checked in wait_for_switch loop */ 1018*c2c66affSColin Finck if(emulate_prot) 1019*c2c66affSColin Finck CHECK_CALLED(Read); 1020*c2c66affSColin Finck if(!reported_all_data && called_ReportData2) { 1021*c2c66affSColin Finck if(!emulate_prot) 1022*c2c66affSColin Finck CHECK_CALLED(ReportData2); 1023*c2c66affSColin Finck CHECK_CALLED(ReportResult); 1024*c2c66affSColin Finck reported_all_data = TRUE; 1025*c2c66affSColin Finck }else { 1026*c2c66affSColin Finck if(!emulate_prot) 1027*c2c66affSColin Finck CHECK_NOT_CALLED(ReportData2); 1028*c2c66affSColin Finck CHECK_NOT_CALLED(ReportResult); 1029*c2c66affSColin Finck } 1030*c2c66affSColin Finck }while(hres == S_OK); 1031*c2c66affSColin Finck if(hres == S_FALSE) 1032*c2c66affSColin Finck wait_for_switch = FALSE; 1033*c2c66affSColin Finck }else { 1034*c2c66affSColin Finck CHECK_EXPECT(ReportData2); 1035*c2c66affSColin Finck 1036*c2c66affSColin Finck ok(grfBSCF & BSCF_LASTDATANOTIFICATION, "grfBSCF = %08x\n", grfBSCF); 1037*c2c66affSColin Finck 1038*c2c66affSColin Finck read = 0xdeadbeef; 1039*c2c66affSColin Finck if(emulate_prot) 1040*c2c66affSColin Finck SET_EXPECT(Read2); 1041*c2c66affSColin Finck hres = IInternetProtocol_Read(binding_test ? binding_protocol : async_protocol, expect_pv = buf, sizeof(buf), &read); 1042*c2c66affSColin Finck if(emulate_prot) 1043*c2c66affSColin Finck CHECK_CALLED(Read2); 1044*c2c66affSColin Finck ok(hres == S_FALSE, "Read returned: %08x, expected E_FALSE\n", hres); 1045*c2c66affSColin Finck ok(!read, "read = %d\n", read); 1046*c2c66affSColin Finck } 1047*c2c66affSColin Finck }else if(!binding_test && (tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST 1048*c2c66affSColin Finck || tested_protocol == FTP_TEST)) { 1049*c2c66affSColin Finck if(empty_file) 1050*c2c66affSColin Finck CHECK_EXPECT2(ReportData); 1051*c2c66affSColin Finck else if(!(grfBSCF & BSCF_LASTDATANOTIFICATION) || (grfBSCF & BSCF_DATAFULLYAVAILABLE)) 1052*c2c66affSColin Finck CHECK_EXPECT(ReportData); 1053*c2c66affSColin Finck else if (http_post_test) 1054*c2c66affSColin Finck ok(ulProgress == 13, "Read %u bytes instead of 13\n", ulProgress); 1055*c2c66affSColin Finck 1056*c2c66affSColin Finck if(empty_file) { 1057*c2c66affSColin Finck ok(!ulProgress, "ulProgress = %d\n", ulProgress); 1058*c2c66affSColin Finck ok(!ulProgressMax, "ulProgressMax = %d\n", ulProgressMax); 1059*c2c66affSColin Finck }else { 1060*c2c66affSColin Finck ok(ulProgress, "ulProgress == 0\n"); 1061*c2c66affSColin Finck } 1062*c2c66affSColin Finck 1063*c2c66affSColin Finck if(empty_file) { 1064*c2c66affSColin Finck ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), 1065*c2c66affSColin Finck "grcfBSCF = %08x\n", grfBSCF); 1066*c2c66affSColin Finck first_data_notif = FALSE; 1067*c2c66affSColin Finck }else if(first_data_notif) { 1068*c2c66affSColin Finck ok(grfBSCF == BSCF_FIRSTDATANOTIFICATION 1069*c2c66affSColin Finck || grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE), 1070*c2c66affSColin Finck "grcfBSCF = %08x\n", grfBSCF); 1071*c2c66affSColin Finck first_data_notif = FALSE; 1072*c2c66affSColin Finck } else { 1073*c2c66affSColin Finck ok(grfBSCF == BSCF_INTERMEDIATEDATANOTIFICATION 1074*c2c66affSColin Finck || grfBSCF == (BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION) 1075*c2c66affSColin Finck || broken(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION)), 1076*c2c66affSColin Finck "grcfBSCF = %08x\n", grfBSCF); 1077*c2c66affSColin Finck } 1078*c2c66affSColin Finck 1079*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON) && 1080*c2c66affSColin Finck !(grfBSCF & BSCF_LASTDATANOTIFICATION)) { 1081*c2c66affSColin Finck if(state == STATE_CONNECTING) { 1082*c2c66affSColin Finck state = STATE_DOWNLOADING; 1083*c2c66affSColin Finck if(http_is_first) { 1084*c2c66affSColin Finck CHECK_CALLED(ReportProgress_FINDINGRESOURCE); 1085*c2c66affSColin Finck CHECK_CALLED(ReportProgress_CONNECTING); 1086*c2c66affSColin Finck } 1087*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 1088*c2c66affSColin Finck CHECK_CALLED(OnResponse); 1089*c2c66affSColin Finck CHECK_CALLED(ReportProgress_RAWMIMETYPE); 1090*c2c66affSColin Finck } 1091*c2c66affSColin Finck SetEvent(event_complete); 1092*c2c66affSColin Finck } 1093*c2c66affSColin Finck }else if(!read_report_data) { 1094*c2c66affSColin Finck BYTE buf[1000]; 1095*c2c66affSColin Finck ULONG read; 1096*c2c66affSColin Finck HRESULT hres; 1097*c2c66affSColin Finck 1098*c2c66affSColin Finck CHECK_EXPECT(ReportData); 1099*c2c66affSColin Finck 1100*c2c66affSColin Finck if(tested_protocol != BIND_TEST) { 1101*c2c66affSColin Finck do { 1102*c2c66affSColin Finck if(mimefilter_test) 1103*c2c66affSColin Finck SET_EXPECT(MimeFilter_Read); 1104*c2c66affSColin Finck else if(rec_depth > 1) 1105*c2c66affSColin Finck SET_EXPECT(Read2); 1106*c2c66affSColin Finck else 1107*c2c66affSColin Finck SET_EXPECT(Read); 1108*c2c66affSColin Finck hres = IInternetProtocol_Read(binding_protocol, expect_pv=buf, sizeof(buf), &read); 1109*c2c66affSColin Finck if(mimefilter_test) 1110*c2c66affSColin Finck CHECK_CALLED(MimeFilter_Read); 1111*c2c66affSColin Finck else if(rec_depth > 1) 1112*c2c66affSColin Finck CHECK_CALLED(Read2); 1113*c2c66affSColin Finck else 1114*c2c66affSColin Finck CHECK_CALLED(Read); 1115*c2c66affSColin Finck }while(hres == S_OK); 1116*c2c66affSColin Finck } 1117*c2c66affSColin Finck } 1118*c2c66affSColin Finck 1119*c2c66affSColin Finck rec_depth--; 1120*c2c66affSColin Finck return S_OK; 1121*c2c66affSColin Finck } 1122*c2c66affSColin Finck 1123*c2c66affSColin Finck static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, 1124*c2c66affSColin Finck DWORD dwError, LPCWSTR szResult) 1125*c2c66affSColin Finck { 1126*c2c66affSColin Finck CHECK_EXPECT(ReportResult); 1127*c2c66affSColin Finck 1128*c2c66affSColin Finck if(tested_protocol == FTP_TEST) 1129*c2c66affSColin Finck ok(hrResult == E_PENDING || hrResult == S_OK, "hrResult = %08x, expected E_PENDING or S_OK\n", hrResult); 1130*c2c66affSColin Finck else 1131*c2c66affSColin Finck ok(hrResult == expect_hrResult, "hrResult = %08x, expected: %08x\n", 1132*c2c66affSColin Finck hrResult, expect_hrResult); 1133*c2c66affSColin Finck #ifdef __REACTOS__ 1134*c2c66affSColin Finck if(!winetest_interactive && tested_protocol != FTP_TEST && hrResult != expect_hrResult) { 1135*c2c66affSColin Finck skip("CORE-10360/ROSTESTS-192: Test might hang, skipping the rest!\n"); 1136*c2c66affSColin Finck exit(1); 1137*c2c66affSColin Finck } 1138*c2c66affSColin Finck #endif 1139*c2c66affSColin Finck if(SUCCEEDED(hrResult) || tested_protocol == FTP_TEST || test_abort || hrResult == INET_E_REDIRECT_FAILED) 1140*c2c66affSColin Finck ok(dwError == ERROR_SUCCESS, "dwError = %d, expected ERROR_SUCCESS\n", dwError); 1141*c2c66affSColin Finck else 1142*c2c66affSColin Finck ok(dwError != ERROR_SUCCESS || 1143*c2c66affSColin Finck broken(tested_protocol == MK_TEST), /* WinME and NT4 */ 1144*c2c66affSColin Finck "dwError == ERROR_SUCCESS\n"); 1145*c2c66affSColin Finck 1146*c2c66affSColin Finck if(hrResult == INET_E_REDIRECT_FAILED) 1147*c2c66affSColin Finck ok(!strcmp_wa(szResult, "http://test.winehq.org/tests/hello.html"), "szResult = %s\n", wine_dbgstr_w(szResult)); 1148*c2c66affSColin Finck else 1149*c2c66affSColin Finck ok(!szResult, "szResult = %s\n", wine_dbgstr_w(szResult)); 1150*c2c66affSColin Finck 1151*c2c66affSColin Finck if(direct_read) 1152*c2c66affSColin Finck SET_EXPECT(ReportData); /* checked after main loop */ 1153*c2c66affSColin Finck 1154*c2c66affSColin Finck return S_OK; 1155*c2c66affSColin Finck } 1156*c2c66affSColin Finck 1157*c2c66affSColin Finck static IInternetProtocolSinkVtbl protocol_sink_vtbl = { 1158*c2c66affSColin Finck ProtocolSink_QueryInterface, 1159*c2c66affSColin Finck ProtocolSink_AddRef, 1160*c2c66affSColin Finck ProtocolSink_Release, 1161*c2c66affSColin Finck ProtocolSink_Switch, 1162*c2c66affSColin Finck ProtocolSink_ReportProgress, 1163*c2c66affSColin Finck ProtocolSink_ReportData, 1164*c2c66affSColin Finck ProtocolSink_ReportResult 1165*c2c66affSColin Finck }; 1166*c2c66affSColin Finck 1167*c2c66affSColin Finck static IInternetProtocolSink protocol_sink = { &protocol_sink_vtbl }; 1168*c2c66affSColin Finck 1169*c2c66affSColin Finck static HRESULT WINAPI MimeProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv) 1170*c2c66affSColin Finck { 1171*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) 1172*c2c66affSColin Finck || IsEqualGUID(&IID_IInternetProtocolSink, riid)) { 1173*c2c66affSColin Finck *ppv = iface; 1174*c2c66affSColin Finck return S_OK; 1175*c2c66affSColin Finck } 1176*c2c66affSColin Finck 1177*c2c66affSColin Finck ok(0, "unexpected call\n"); 1178*c2c66affSColin Finck return E_NOTIMPL; 1179*c2c66affSColin Finck } 1180*c2c66affSColin Finck 1181*c2c66affSColin Finck static ULONG WINAPI MimeProtocolSink_AddRef(IInternetProtocolSink *iface) 1182*c2c66affSColin Finck { 1183*c2c66affSColin Finck return 2; 1184*c2c66affSColin Finck } 1185*c2c66affSColin Finck 1186*c2c66affSColin Finck static ULONG WINAPI MimeProtocolSink_Release(IInternetProtocolSink *iface) 1187*c2c66affSColin Finck { 1188*c2c66affSColin Finck return 1; 1189*c2c66affSColin Finck } 1190*c2c66affSColin Finck 1191*c2c66affSColin Finck static HRESULT WINAPI MimeProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData) 1192*c2c66affSColin Finck { 1193*c2c66affSColin Finck HRESULT hres; 1194*c2c66affSColin Finck 1195*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_Switch); 1196*c2c66affSColin Finck 1197*c2c66affSColin Finck SET_EXPECT(Switch); 1198*c2c66affSColin Finck hres = IInternetProtocolSink_Switch(filtered_sink, pProtocolData); 1199*c2c66affSColin Finck ok(hres == S_OK, "Switch failed: %08x\n", hres); 1200*c2c66affSColin Finck CHECK_CALLED(Switch); 1201*c2c66affSColin Finck 1202*c2c66affSColin Finck return S_OK; 1203*c2c66affSColin Finck } 1204*c2c66affSColin Finck 1205*c2c66affSColin Finck static HRESULT WINAPI MimeProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode, 1206*c2c66affSColin Finck LPCWSTR szStatusText) 1207*c2c66affSColin Finck { 1208*c2c66affSColin Finck switch(ulStatusCode) { 1209*c2c66affSColin Finck case BINDSTATUS_LOADINGMIMEHANDLER: 1210*c2c66affSColin Finck /* 1211*c2c66affSColin Finck * IE9 for some reason (bug?) calls this on mime handler's protocol sink instead of the 1212*c2c66affSColin Finck * main protocol sink. We check ReportProgress_LOADINGMIMEHANDLER both here and in 1213*c2c66affSColin Finck * ProtocolSink_ReportProgress to workaround it. 1214*c2c66affSColin Finck */ 1215*c2c66affSColin Finck CHECK_EXPECT(ReportProgress_LOADINGMIMEHANDLER); 1216*c2c66affSColin Finck ok(!szStatusText, "szStatusText = %s\n", wine_dbgstr_w(szStatusText)); 1217*c2c66affSColin Finck break; 1218*c2c66affSColin Finck default: 1219*c2c66affSColin Finck ok(0, "Unexpected status code %d\n", ulStatusCode); 1220*c2c66affSColin Finck } 1221*c2c66affSColin Finck 1222*c2c66affSColin Finck return S_OK; 1223*c2c66affSColin Finck } 1224*c2c66affSColin Finck 1225*c2c66affSColin Finck static HRESULT WINAPI MimeProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, 1226*c2c66affSColin Finck ULONG ulProgress, ULONG ulProgressMax) 1227*c2c66affSColin Finck { 1228*c2c66affSColin Finck DWORD read = 0; 1229*c2c66affSColin Finck BYTE buf[8192]; 1230*c2c66affSColin Finck HRESULT hres; 1231*c2c66affSColin Finck BOOL report_mime = FALSE; 1232*c2c66affSColin Finck 1233*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_ReportData); 1234*c2c66affSColin Finck 1235*c2c66affSColin Finck if(!filter_state && !no_mime) { 1236*c2c66affSColin Finck SET_EXPECT(Read); 1237*c2c66affSColin Finck hres = IInternetProtocol_Read(filtered_protocol, buf, sizeof(buf), &read); 1238*c2c66affSColin Finck if(tested_protocol == HTTP_TEST) 1239*c2c66affSColin Finck ok(hres == S_OK || hres == E_PENDING || hres == S_FALSE, "Read failed: %08x\n", hres); 1240*c2c66affSColin Finck else 1241*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 1242*c2c66affSColin Finck CHECK_CALLED(Read); 1243*c2c66affSColin Finck 1244*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 1245*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(filtered_sink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, text_htmlW); 1246*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 1247*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 1248*c2c66affSColin Finck 1249*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 1250*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(filtered_sink, BINDSTATUS_MIMETYPEAVAILABLE, text_htmlW); 1251*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 1252*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 1253*c2c66affSColin Finck 1254*c2c66affSColin Finck /* FIXME: test BINDSTATUS_CACHEFILENAMEAVAILABLE */ 1255*c2c66affSColin Finck } 1256*c2c66affSColin Finck 1257*c2c66affSColin Finck if(no_mime && prot_read<200) { 1258*c2c66affSColin Finck SET_EXPECT(Read); 1259*c2c66affSColin Finck }else if(no_mime && prot_read<300) { 1260*c2c66affSColin Finck report_mime = TRUE; 1261*c2c66affSColin Finck SET_EXPECT(Read); 1262*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 1263*c2c66affSColin Finck SET_EXPECT(ReportData); 1264*c2c66affSColin Finck }else if(!read_report_data) { 1265*c2c66affSColin Finck SET_EXPECT(ReportData); 1266*c2c66affSColin Finck } 1267*c2c66affSColin Finck hres = IInternetProtocolSink_ReportData(filtered_sink, grfBSCF, ulProgress, ulProgressMax); 1268*c2c66affSColin Finck ok(hres == S_OK, "ReportData failed: %08x\n", hres); 1269*c2c66affSColin Finck if(no_mime && prot_read<=200) { 1270*c2c66affSColin Finck CHECK_CALLED(Read); 1271*c2c66affSColin Finck }else if(report_mime) { 1272*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 1273*c2c66affSColin Finck CHECK_CALLED(ReportData); 1274*c2c66affSColin Finck }else if(!read_report_data) { 1275*c2c66affSColin Finck CHECK_CALLED(ReportData); 1276*c2c66affSColin Finck } 1277*c2c66affSColin Finck 1278*c2c66affSColin Finck if(!filter_state) 1279*c2c66affSColin Finck filter_state = 1; 1280*c2c66affSColin Finck 1281*c2c66affSColin Finck return S_OK; 1282*c2c66affSColin Finck } 1283*c2c66affSColin Finck 1284*c2c66affSColin Finck static HRESULT WINAPI MimeProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, 1285*c2c66affSColin Finck DWORD dwError, LPCWSTR szResult) 1286*c2c66affSColin Finck { 1287*c2c66affSColin Finck HRESULT hres; 1288*c2c66affSColin Finck 1289*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_ReportResult); 1290*c2c66affSColin Finck 1291*c2c66affSColin Finck ok(hrResult == S_OK, "hrResult = %08x\n", hrResult); 1292*c2c66affSColin Finck ok(dwError == ERROR_SUCCESS, "dwError = %u\n", dwError); 1293*c2c66affSColin Finck ok(!szResult, "szResult = %s\n", wine_dbgstr_w(szResult)); 1294*c2c66affSColin Finck 1295*c2c66affSColin Finck SET_EXPECT(ReportResult); 1296*c2c66affSColin Finck hres = IInternetProtocolSink_ReportResult(filtered_sink, hrResult, dwError, szResult); 1297*c2c66affSColin Finck ok(SUCCEEDED(hres), "ReportResult failed: %08x\n", hres); 1298*c2c66affSColin Finck CHECK_CALLED(ReportResult); 1299*c2c66affSColin Finck 1300*c2c66affSColin Finck return S_OK; 1301*c2c66affSColin Finck } 1302*c2c66affSColin Finck 1303*c2c66affSColin Finck static IInternetProtocolSinkVtbl mime_protocol_sink_vtbl = { 1304*c2c66affSColin Finck MimeProtocolSink_QueryInterface, 1305*c2c66affSColin Finck MimeProtocolSink_AddRef, 1306*c2c66affSColin Finck MimeProtocolSink_Release, 1307*c2c66affSColin Finck MimeProtocolSink_Switch, 1308*c2c66affSColin Finck MimeProtocolSink_ReportProgress, 1309*c2c66affSColin Finck MimeProtocolSink_ReportData, 1310*c2c66affSColin Finck MimeProtocolSink_ReportResult 1311*c2c66affSColin Finck }; 1312*c2c66affSColin Finck 1313*c2c66affSColin Finck static IInternetProtocolSink mime_protocol_sink = { &mime_protocol_sink_vtbl }; 1314*c2c66affSColin Finck 1315*c2c66affSColin Finck static HRESULT QueryInterface(REFIID riid, void **ppv) 1316*c2c66affSColin Finck { 1317*c2c66affSColin Finck static const IID IID_undocumented = {0x58DFC7D0,0x5381,0x43E5,{0x9D,0x72,0x4C,0xDD,0xE4,0xCB,0x0F,0x1A}}; 1318*c2c66affSColin Finck static const IID IID_undocumentedIE10 = {0xc28722e5,0xbc1a,0x4c55,{0xa6,0x8d,0x33,0x21,0x9f,0x69,0x89,0x10}}; 1319*c2c66affSColin Finck 1320*c2c66affSColin Finck *ppv = NULL; 1321*c2c66affSColin Finck 1322*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid)) 1323*c2c66affSColin Finck *ppv = &protocol_sink; 1324*c2c66affSColin Finck if(IsEqualGUID(&IID_IServiceProvider, riid)) 1325*c2c66affSColin Finck *ppv = &service_provider; 1326*c2c66affSColin Finck if(IsEqualGUID(&IID_IUriContainer, riid)) 1327*c2c66affSColin Finck return E_NOINTERFACE; /* TODO */ 1328*c2c66affSColin Finck 1329*c2c66affSColin Finck /* NOTE: IE8 queries for undocumented {58DFC7D0-5381-43E5-9D72-4CDDE4CB0F1A} interface. */ 1330*c2c66affSColin Finck if(IsEqualGUID(&IID_undocumented, riid)) 1331*c2c66affSColin Finck return E_NOINTERFACE; 1332*c2c66affSColin Finck /* NOTE: IE10 queries for undocumented {c28722e5-bc1a-4c55-a68d-33219f698910} interface. */ 1333*c2c66affSColin Finck if(IsEqualGUID(&IID_undocumentedIE10, riid)) 1334*c2c66affSColin Finck return E_NOINTERFACE; 1335*c2c66affSColin Finck 1336*c2c66affSColin Finck if(*ppv) 1337*c2c66affSColin Finck return S_OK; 1338*c2c66affSColin Finck 1339*c2c66affSColin Finck ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid)); 1340*c2c66affSColin Finck return E_NOINTERFACE; 1341*c2c66affSColin Finck } 1342*c2c66affSColin Finck 1343*c2c66affSColin Finck static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv) 1344*c2c66affSColin Finck { 1345*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) { 1346*c2c66affSColin Finck *ppv = iface; 1347*c2c66affSColin Finck return S_OK; 1348*c2c66affSColin Finck } 1349*c2c66affSColin Finck return E_NOINTERFACE; 1350*c2c66affSColin Finck } 1351*c2c66affSColin Finck 1352*c2c66affSColin Finck static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface) 1353*c2c66affSColin Finck { 1354*c2c66affSColin Finck return 2; 1355*c2c66affSColin Finck } 1356*c2c66affSColin Finck 1357*c2c66affSColin Finck static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface) 1358*c2c66affSColin Finck { 1359*c2c66affSColin Finck return 1; 1360*c2c66affSColin Finck } 1361*c2c66affSColin Finck 1362*c2c66affSColin Finck static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo) 1363*c2c66affSColin Finck { 1364*c2c66affSColin Finck DWORD cbSize; 1365*c2c66affSColin Finck 1366*c2c66affSColin Finck CHECK_EXPECT(GetBindInfo); 1367*c2c66affSColin Finck 1368*c2c66affSColin Finck ok(grfBINDF != NULL, "grfBINDF == NULL\n"); 1369*c2c66affSColin Finck ok(pbindinfo != NULL, "pbindinfo == NULL\n"); 1370*c2c66affSColin Finck ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize); 1371*c2c66affSColin Finck 1372*c2c66affSColin Finck *grfBINDF = bindf; 1373*c2c66affSColin Finck if(binding_test) 1374*c2c66affSColin Finck *grfBINDF |= BINDF_FROMURLMON; 1375*c2c66affSColin Finck cbSize = pbindinfo->cbSize; 1376*c2c66affSColin Finck memset(pbindinfo, 0, cbSize); 1377*c2c66affSColin Finck pbindinfo->cbSize = cbSize; 1378*c2c66affSColin Finck pbindinfo->dwOptions = bindinfo_options; 1379*c2c66affSColin Finck 1380*c2c66affSColin Finck if(http_post_test) 1381*c2c66affSColin Finck { 1382*c2c66affSColin Finck pbindinfo->cbstgmedData = sizeof(post_data)-1; 1383*c2c66affSColin Finck pbindinfo->dwBindVerb = BINDVERB_POST; 1384*c2c66affSColin Finck pbindinfo->stgmedData.tymed = http_post_test; 1385*c2c66affSColin Finck 1386*c2c66affSColin Finck if(http_post_test == TYMED_HGLOBAL) { 1387*c2c66affSColin Finck HGLOBAL data; 1388*c2c66affSColin Finck 1389*c2c66affSColin Finck /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly */ 1390*c2c66affSColin Finck data = GlobalAlloc(GPTR, sizeof(post_data)); 1391*c2c66affSColin Finck memcpy(data, post_data, sizeof(post_data)); 1392*c2c66affSColin Finck U(pbindinfo->stgmedData).hGlobal = data; 1393*c2c66affSColin Finck }else { 1394*c2c66affSColin Finck U(pbindinfo->stgmedData).pstm = &Stream; 1395*c2c66affSColin Finck } 1396*c2c66affSColin Finck } 1397*c2c66affSColin Finck 1398*c2c66affSColin Finck return S_OK; 1399*c2c66affSColin Finck } 1400*c2c66affSColin Finck 1401*c2c66affSColin Finck static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, 1402*c2c66affSColin Finck LPOLESTR *ppwzStr, ULONG cEl, ULONG *pcElFetched) 1403*c2c66affSColin Finck { 1404*c2c66affSColin Finck ok(ppwzStr != NULL, "ppwzStr == NULL\n"); 1405*c2c66affSColin Finck ok(pcElFetched != NULL, "pcElFetched == NULL\n"); 1406*c2c66affSColin Finck 1407*c2c66affSColin Finck switch(ulStringType) { 1408*c2c66affSColin Finck case BINDSTRING_ACCEPT_MIMES: 1409*c2c66affSColin Finck CHECK_EXPECT(GetBindString_ACCEPT_MIMES); 1410*c2c66affSColin Finck ok(cEl == 256, "cEl=%d, expected 256\n", cEl); 1411*c2c66affSColin Finck if(pcElFetched) { 1412*c2c66affSColin Finck ok(*pcElFetched == 256, "*pcElFetched=%d, expected 256\n", *pcElFetched); 1413*c2c66affSColin Finck *pcElFetched = 1; 1414*c2c66affSColin Finck } 1415*c2c66affSColin Finck if(ppwzStr) { 1416*c2c66affSColin Finck *ppwzStr = CoTaskMemAlloc(sizeof(acc_mimeW)); 1417*c2c66affSColin Finck memcpy(*ppwzStr, acc_mimeW, sizeof(acc_mimeW)); 1418*c2c66affSColin Finck } 1419*c2c66affSColin Finck return S_OK; 1420*c2c66affSColin Finck case BINDSTRING_USER_AGENT: 1421*c2c66affSColin Finck CHECK_EXPECT(GetBindString_USER_AGENT); 1422*c2c66affSColin Finck ok(cEl == 1, "cEl=%d, expected 1\n", cEl); 1423*c2c66affSColin Finck if(pcElFetched) { 1424*c2c66affSColin Finck ok(*pcElFetched == 0, "*pcElFetch=%d, expected 0\n", *pcElFetched); 1425*c2c66affSColin Finck *pcElFetched = 1; 1426*c2c66affSColin Finck } 1427*c2c66affSColin Finck if(ppwzStr) { 1428*c2c66affSColin Finck *ppwzStr = CoTaskMemAlloc(sizeof(user_agentW)); 1429*c2c66affSColin Finck memcpy(*ppwzStr, user_agentW, sizeof(user_agentW)); 1430*c2c66affSColin Finck } 1431*c2c66affSColin Finck return S_OK; 1432*c2c66affSColin Finck case BINDSTRING_POST_COOKIE: 1433*c2c66affSColin Finck CHECK_EXPECT(GetBindString_POST_COOKIE); 1434*c2c66affSColin Finck ok(cEl == 1, "cEl=%d, expected 1\n", cEl); 1435*c2c66affSColin Finck if(pcElFetched) 1436*c2c66affSColin Finck ok(*pcElFetched == 0, "*pcElFetch=%d, expected 0\n", *pcElFetched); 1437*c2c66affSColin Finck return S_OK; 1438*c2c66affSColin Finck case BINDSTRING_URL: { 1439*c2c66affSColin Finck DWORD size; 1440*c2c66affSColin Finck 1441*c2c66affSColin Finck CHECK_EXPECT(GetBindString_URL); 1442*c2c66affSColin Finck ok(cEl == 1, "cEl=%d, expected 1\n", cEl); 1443*c2c66affSColin Finck ok(*pcElFetched == 0, "*pcElFetch=%d, expected 0\n", *pcElFetched); 1444*c2c66affSColin Finck *pcElFetched = 1; 1445*c2c66affSColin Finck 1446*c2c66affSColin Finck size = (lstrlenW(binding_urls[tested_protocol])+1)*sizeof(WCHAR); 1447*c2c66affSColin Finck *ppwzStr = CoTaskMemAlloc(size); 1448*c2c66affSColin Finck memcpy(*ppwzStr, binding_urls[tested_protocol], size); 1449*c2c66affSColin Finck return S_OK; 1450*c2c66affSColin Finck } 1451*c2c66affSColin Finck case BINDSTRING_ROOTDOC_URL: 1452*c2c66affSColin Finck CHECK_EXPECT(GetBindString_ROOTDOC_URL); 1453*c2c66affSColin Finck ok(cEl == 1, "cEl=%d, expected 1\n", cEl); 1454*c2c66affSColin Finck return E_NOTIMPL; 1455*c2c66affSColin Finck case BINDSTRING_ENTERPRISE_ID: 1456*c2c66affSColin Finck ok(cEl == 1, "cEl=%d, expected 1\n", cEl); 1457*c2c66affSColin Finck return E_NOTIMPL; 1458*c2c66affSColin Finck default: 1459*c2c66affSColin Finck ok(0, "unexpected ulStringType %d\n", ulStringType); 1460*c2c66affSColin Finck } 1461*c2c66affSColin Finck 1462*c2c66affSColin Finck return E_NOTIMPL; 1463*c2c66affSColin Finck } 1464*c2c66affSColin Finck 1465*c2c66affSColin Finck static IInternetBindInfoVtbl bind_info_vtbl = { 1466*c2c66affSColin Finck BindInfo_QueryInterface, 1467*c2c66affSColin Finck BindInfo_AddRef, 1468*c2c66affSColin Finck BindInfo_Release, 1469*c2c66affSColin Finck BindInfo_GetBindInfo, 1470*c2c66affSColin Finck BindInfo_GetBindString 1471*c2c66affSColin Finck }; 1472*c2c66affSColin Finck 1473*c2c66affSColin Finck static IInternetBindInfo bind_info = { &bind_info_vtbl }; 1474*c2c66affSColin Finck 1475*c2c66affSColin Finck static HRESULT WINAPI InternetPriority_QueryInterface(IInternetPriority *iface, 1476*c2c66affSColin Finck REFIID riid, void **ppv) 1477*c2c66affSColin Finck { 1478*c2c66affSColin Finck ok(0, "unexpected call\n"); 1479*c2c66affSColin Finck return E_NOINTERFACE; 1480*c2c66affSColin Finck } 1481*c2c66affSColin Finck 1482*c2c66affSColin Finck static ULONG WINAPI InternetPriority_AddRef(IInternetPriority *iface) 1483*c2c66affSColin Finck { 1484*c2c66affSColin Finck return 2; 1485*c2c66affSColin Finck } 1486*c2c66affSColin Finck 1487*c2c66affSColin Finck static ULONG WINAPI InternetPriority_Release(IInternetPriority *iface) 1488*c2c66affSColin Finck { 1489*c2c66affSColin Finck return 1; 1490*c2c66affSColin Finck } 1491*c2c66affSColin Finck 1492*c2c66affSColin Finck static HRESULT WINAPI InternetPriority_SetPriority(IInternetPriority *iface, LONG nPriority) 1493*c2c66affSColin Finck { 1494*c2c66affSColin Finck CHECK_EXPECT(SetPriority); 1495*c2c66affSColin Finck ok(nPriority == ex_priority, "nPriority=%d\n", nPriority); 1496*c2c66affSColin Finck return S_OK; 1497*c2c66affSColin Finck } 1498*c2c66affSColin Finck 1499*c2c66affSColin Finck static HRESULT WINAPI InternetPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority) 1500*c2c66affSColin Finck { 1501*c2c66affSColin Finck ok(0, "unexpected call\n"); 1502*c2c66affSColin Finck return E_NOTIMPL; 1503*c2c66affSColin Finck } 1504*c2c66affSColin Finck 1505*c2c66affSColin Finck 1506*c2c66affSColin Finck static const IInternetPriorityVtbl InternetPriorityVtbl = { 1507*c2c66affSColin Finck InternetPriority_QueryInterface, 1508*c2c66affSColin Finck InternetPriority_AddRef, 1509*c2c66affSColin Finck InternetPriority_Release, 1510*c2c66affSColin Finck InternetPriority_SetPriority, 1511*c2c66affSColin Finck InternetPriority_GetPriority 1512*c2c66affSColin Finck }; 1513*c2c66affSColin Finck 1514*c2c66affSColin Finck static IInternetPriority InternetPriority = { &InternetPriorityVtbl }; 1515*c2c66affSColin Finck 1516*c2c66affSColin Finck static ULONG WINAPI Protocol_AddRef(IInternetProtocolEx *iface) 1517*c2c66affSColin Finck { 1518*c2c66affSColin Finck return 2; 1519*c2c66affSColin Finck } 1520*c2c66affSColin Finck 1521*c2c66affSColin Finck static ULONG WINAPI Protocol_Release(IInternetProtocolEx *iface) 1522*c2c66affSColin Finck { 1523*c2c66affSColin Finck return 1; 1524*c2c66affSColin Finck } 1525*c2c66affSColin Finck 1526*c2c66affSColin Finck static HRESULT WINAPI Protocol_Abort(IInternetProtocolEx *iface, HRESULT hrReason, 1527*c2c66affSColin Finck DWORD dwOptions) 1528*c2c66affSColin Finck { 1529*c2c66affSColin Finck HRESULT hres; 1530*c2c66affSColin Finck 1531*c2c66affSColin Finck CHECK_EXPECT(Abort); 1532*c2c66affSColin Finck 1533*c2c66affSColin Finck SET_EXPECT(ReportResult); 1534*c2c66affSColin Finck hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL); 1535*c2c66affSColin Finck ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1536*c2c66affSColin Finck CHECK_CALLED(ReportResult); 1537*c2c66affSColin Finck 1538*c2c66affSColin Finck return S_OK; 1539*c2c66affSColin Finck } 1540*c2c66affSColin Finck 1541*c2c66affSColin Finck static HRESULT WINAPI Protocol_Suspend(IInternetProtocolEx *iface) 1542*c2c66affSColin Finck { 1543*c2c66affSColin Finck ok(0, "unexpected call\n"); 1544*c2c66affSColin Finck return E_NOTIMPL; 1545*c2c66affSColin Finck } 1546*c2c66affSColin Finck 1547*c2c66affSColin Finck static HRESULT WINAPI Protocol_Resume(IInternetProtocolEx *iface) 1548*c2c66affSColin Finck { 1549*c2c66affSColin Finck ok(0, "unexpected call\n"); 1550*c2c66affSColin Finck return E_NOTIMPL; 1551*c2c66affSColin Finck } 1552*c2c66affSColin Finck 1553*c2c66affSColin Finck static HRESULT WINAPI Protocol_Seek(IInternetProtocolEx *iface, 1554*c2c66affSColin Finck LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) 1555*c2c66affSColin Finck { 1556*c2c66affSColin Finck ok(0, "unexpected call\n"); 1557*c2c66affSColin Finck return E_NOTIMPL; 1558*c2c66affSColin Finck } 1559*c2c66affSColin Finck 1560*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) 1561*c2c66affSColin Finck { 1562*c2c66affSColin Finck static const IID unknown_iid = {0x7daf9908,0x8415,0x4005,{0x95,0xae, 0xbd,0x27,0xf6,0xe3,0xdc,0x00}}; 1563*c2c66affSColin Finck 1564*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) { 1565*c2c66affSColin Finck *ppv = iface; 1566*c2c66affSColin Finck return S_OK; 1567*c2c66affSColin Finck } 1568*c2c66affSColin Finck 1569*c2c66affSColin Finck if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) { 1570*c2c66affSColin Finck if(impl_protex) { 1571*c2c66affSColin Finck *ppv = iface; 1572*c2c66affSColin Finck return S_OK; 1573*c2c66affSColin Finck } 1574*c2c66affSColin Finck *ppv = NULL; 1575*c2c66affSColin Finck return E_NOINTERFACE; 1576*c2c66affSColin Finck } 1577*c2c66affSColin Finck 1578*c2c66affSColin Finck if(IsEqualGUID(&IID_IInternetPriority, riid)) { 1579*c2c66affSColin Finck *ppv = &InternetPriority; 1580*c2c66affSColin Finck return S_OK; 1581*c2c66affSColin Finck } 1582*c2c66affSColin Finck 1583*c2c66affSColin Finck if(IsEqualGUID(&IID_IWinInetInfo, riid)) { 1584*c2c66affSColin Finck CHECK_EXPECT(QueryInterface_IWinInetInfo); 1585*c2c66affSColin Finck *ppv = NULL; 1586*c2c66affSColin Finck return E_NOINTERFACE; 1587*c2c66affSColin Finck } 1588*c2c66affSColin Finck 1589*c2c66affSColin Finck if(IsEqualGUID(&IID_IWinInetHttpInfo, riid)) { 1590*c2c66affSColin Finck CHECK_EXPECT(QueryInterface_IWinInetHttpInfo); 1591*c2c66affSColin Finck *ppv = NULL; 1592*c2c66affSColin Finck return E_NOINTERFACE; 1593*c2c66affSColin Finck } 1594*c2c66affSColin Finck 1595*c2c66affSColin Finck if(!IsEqualGUID(riid, &unknown_iid)) /* IE10 */ 1596*c2c66affSColin Finck ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); 1597*c2c66affSColin Finck *ppv = NULL; 1598*c2c66affSColin Finck return E_NOINTERFACE; 1599*c2c66affSColin Finck } 1600*c2c66affSColin Finck 1601*c2c66affSColin Finck static DWORD WINAPI thread_proc(PVOID arg) 1602*c2c66affSColin Finck { 1603*c2c66affSColin Finck BOOL redirect_only = redirect_on_continue; 1604*c2c66affSColin Finck HRESULT hres; 1605*c2c66affSColin Finck 1606*c2c66affSColin Finck memset(&protocoldata, -1, sizeof(protocoldata)); 1607*c2c66affSColin Finck 1608*c2c66affSColin Finck prot_state = 0; 1609*c2c66affSColin Finck 1610*c2c66affSColin Finck SET_EXPECT(ReportProgress_FINDINGRESOURCE); 1611*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(binding_sink, 1612*c2c66affSColin Finck BINDSTATUS_FINDINGRESOURCE, hostW); 1613*c2c66affSColin Finck CHECK_CALLED(ReportProgress_FINDINGRESOURCE); 1614*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 1615*c2c66affSColin Finck 1616*c2c66affSColin Finck SET_EXPECT(ReportProgress_CONNECTING); 1617*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(binding_sink, 1618*c2c66affSColin Finck BINDSTATUS_CONNECTING, winehq_ipW); 1619*c2c66affSColin Finck CHECK_CALLED(ReportProgress_CONNECTING); 1620*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 1621*c2c66affSColin Finck 1622*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 1623*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(binding_sink, 1624*c2c66affSColin Finck BINDSTATUS_SENDINGREQUEST, NULL); 1625*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 1626*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 1627*c2c66affSColin Finck 1628*c2c66affSColin Finck prot_state = 1; 1629*c2c66affSColin Finck SET_EXPECT(Switch); 1630*c2c66affSColin Finck hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata); 1631*c2c66affSColin Finck CHECK_CALLED(Switch); 1632*c2c66affSColin Finck ok(hres == S_OK, "Switch failed: %08x\n", hres); 1633*c2c66affSColin Finck 1634*c2c66affSColin Finck if(redirect_only) { 1635*c2c66affSColin Finck prot_state = 0; 1636*c2c66affSColin Finck return 0; 1637*c2c66affSColin Finck } 1638*c2c66affSColin Finck 1639*c2c66affSColin Finck if(!short_read) { 1640*c2c66affSColin Finck prot_state = 2; 1641*c2c66affSColin Finck if(mimefilter_test) 1642*c2c66affSColin Finck SET_EXPECT(MimeFilter_Switch); 1643*c2c66affSColin Finck else 1644*c2c66affSColin Finck SET_EXPECT(Switch); 1645*c2c66affSColin Finck hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata); 1646*c2c66affSColin Finck ok(hres == S_OK, "Switch failed: %08x\n", hres); 1647*c2c66affSColin Finck if(mimefilter_test) 1648*c2c66affSColin Finck CHECK_CALLED(MimeFilter_Switch); 1649*c2c66affSColin Finck else 1650*c2c66affSColin Finck CHECK_CALLED(Switch); 1651*c2c66affSColin Finck 1652*c2c66affSColin Finck if(test_abort) { 1653*c2c66affSColin Finck SetEvent(event_complete); 1654*c2c66affSColin Finck return 0; 1655*c2c66affSColin Finck } 1656*c2c66affSColin Finck 1657*c2c66affSColin Finck prot_state = 2; 1658*c2c66affSColin Finck if(mimefilter_test) 1659*c2c66affSColin Finck SET_EXPECT(MimeFilter_Switch); 1660*c2c66affSColin Finck else 1661*c2c66affSColin Finck SET_EXPECT(Switch); 1662*c2c66affSColin Finck hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata); 1663*c2c66affSColin Finck ok(hres == S_OK, "Switch failed: %08x\n", hres); 1664*c2c66affSColin Finck if(mimefilter_test) 1665*c2c66affSColin Finck CHECK_CALLED(MimeFilter_Switch); 1666*c2c66affSColin Finck else 1667*c2c66affSColin Finck CHECK_CALLED(Switch); 1668*c2c66affSColin Finck 1669*c2c66affSColin Finck prot_state = 3; 1670*c2c66affSColin Finck if(mimefilter_test) 1671*c2c66affSColin Finck SET_EXPECT(MimeFilter_Switch); 1672*c2c66affSColin Finck else 1673*c2c66affSColin Finck SET_EXPECT(Switch); 1674*c2c66affSColin Finck hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata); 1675*c2c66affSColin Finck ok(hres == S_OK, "Switch failed: %08x\n", hres); 1676*c2c66affSColin Finck if(mimefilter_test) 1677*c2c66affSColin Finck CHECK_CALLED(MimeFilter_Switch); 1678*c2c66affSColin Finck else 1679*c2c66affSColin Finck CHECK_CALLED(Switch); 1680*c2c66affSColin Finck } 1681*c2c66affSColin Finck 1682*c2c66affSColin Finck SetEvent(event_complete); 1683*c2c66affSColin Finck 1684*c2c66affSColin Finck return 0; 1685*c2c66affSColin Finck } 1686*c2c66affSColin Finck 1687*c2c66affSColin Finck static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, DWORD pi) 1688*c2c66affSColin Finck { 1689*c2c66affSColin Finck BINDINFO bindinfo, exp_bindinfo; 1690*c2c66affSColin Finck DWORD cbindf = 0; 1691*c2c66affSColin Finck HRESULT hres; 1692*c2c66affSColin Finck 1693*c2c66affSColin Finck ok(pOIProtSink != NULL, "pOIProtSink == NULL\n"); 1694*c2c66affSColin Finck ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n"); 1695*c2c66affSColin Finck ok(pOIProtSink != &protocol_sink, "unexpected pOIProtSink\n"); 1696*c2c66affSColin Finck ok(pOIBindInfo != &bind_info, "unexpected pOIBindInfo\n"); 1697*c2c66affSColin Finck ok(!pi, "pi = %x\n", pi); 1698*c2c66affSColin Finck 1699*c2c66affSColin Finck if(binding_test) 1700*c2c66affSColin Finck ok(pOIProtSink == binding_sink, "pOIProtSink != binding_sink\n"); 1701*c2c66affSColin Finck 1702*c2c66affSColin Finck memset(&bindinfo, 0, sizeof(bindinfo)); 1703*c2c66affSColin Finck bindinfo.cbSize = sizeof(bindinfo); 1704*c2c66affSColin Finck memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo)); 1705*c2c66affSColin Finck if(test_redirect) 1706*c2c66affSColin Finck exp_bindinfo.dwOptions = bindinfo_options; 1707*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 1708*c2c66affSColin Finck if(redirect_on_continue && (bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)) 1709*c2c66affSColin Finck SET_EXPECT(QueryService_IBindCallbackRedirect); 1710*c2c66affSColin Finck hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo); 1711*c2c66affSColin Finck if(redirect_on_continue && (bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)) 1712*c2c66affSColin Finck CHECK_CALLED(QueryService_IBindCallbackRedirect); 1713*c2c66affSColin Finck ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 1714*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 1715*c2c66affSColin Finck ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n", 1716*c2c66affSColin Finck cbindf, (bindf|BINDF_FROMURLMON)); 1717*c2c66affSColin Finck ok(!memcmp(&exp_bindinfo, &bindinfo, sizeof(bindinfo)), "unexpected bindinfo\n"); 1718*c2c66affSColin Finck pReleaseBindInfo(&bindinfo); 1719*c2c66affSColin Finck 1720*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 1721*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, emptyW); 1722*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres); 1723*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 1724*c2c66affSColin Finck 1725*c2c66affSColin Finck if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) { 1726*c2c66affSColin Finck IServiceProvider *service_provider; 1727*c2c66affSColin Finck IHttpNegotiate *http_negotiate; 1728*c2c66affSColin Finck IHttpNegotiate2 *http_negotiate2; 1729*c2c66affSColin Finck LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256]; 1730*c2c66affSColin Finck LPWSTR additional_headers = NULL; 1731*c2c66affSColin Finck BYTE sec_id[100]; 1732*c2c66affSColin Finck DWORD fetched = 0, size = 100; 1733*c2c66affSColin Finck DWORD tid; 1734*c2c66affSColin Finck 1735*c2c66affSColin Finck SET_EXPECT(GetBindString_USER_AGENT); 1736*c2c66affSColin Finck hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT, 1737*c2c66affSColin Finck &ua, 1, &fetched); 1738*c2c66affSColin Finck CHECK_CALLED(GetBindString_USER_AGENT); 1739*c2c66affSColin Finck ok(hres == S_OK, "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres); 1740*c2c66affSColin Finck ok(fetched == 1, "fetched = %d, expected 254\n", fetched); 1741*c2c66affSColin Finck ok(ua != NULL, "ua = %p\n", ua); 1742*c2c66affSColin Finck ok(!lstrcmpW(ua, user_agentW), "unexpected user agent %s\n", wine_dbgstr_w(ua)); 1743*c2c66affSColin Finck CoTaskMemFree(ua); 1744*c2c66affSColin Finck 1745*c2c66affSColin Finck fetched = 256; 1746*c2c66affSColin Finck SET_EXPECT(GetBindString_ACCEPT_MIMES); 1747*c2c66affSColin Finck hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES, 1748*c2c66affSColin Finck accept_mimes, 256, &fetched); 1749*c2c66affSColin Finck CHECK_CALLED(GetBindString_ACCEPT_MIMES); 1750*c2c66affSColin Finck 1751*c2c66affSColin Finck ok(hres == S_OK, 1752*c2c66affSColin Finck "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres); 1753*c2c66affSColin Finck ok(fetched == 1, "fetched = %d, expected 1\n", fetched); 1754*c2c66affSColin Finck ok(!lstrcmpW(acc_mimeW, accept_mimes[0]), "unexpected mimes %s\n", wine_dbgstr_w(accept_mimes[0])); 1755*c2c66affSColin Finck CoTaskMemFree(accept_mimes[0]); 1756*c2c66affSColin Finck 1757*c2c66affSColin Finck hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider, 1758*c2c66affSColin Finck (void**)&service_provider); 1759*c2c66affSColin Finck ok(hres == S_OK, "QueryInterface failed: %08x\n", hres); 1760*c2c66affSColin Finck 1761*c2c66affSColin Finck SET_EXPECT(QueryService_HttpNegotiate); 1762*c2c66affSColin Finck hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, 1763*c2c66affSColin Finck &IID_IHttpNegotiate, (void**)&http_negotiate); 1764*c2c66affSColin Finck CHECK_CALLED(QueryService_HttpNegotiate); 1765*c2c66affSColin Finck ok(hres == S_OK, "QueryService failed: %08x\n", hres); 1766*c2c66affSColin Finck 1767*c2c66affSColin Finck SET_EXPECT(BeginningTransaction); 1768*c2c66affSColin Finck hres = IHttpNegotiate_BeginningTransaction(http_negotiate, binding_urls[tested_protocol], 1769*c2c66affSColin Finck NULL, 0, &additional_headers); 1770*c2c66affSColin Finck CHECK_CALLED(BeginningTransaction); 1771*c2c66affSColin Finck IHttpNegotiate_Release(http_negotiate); 1772*c2c66affSColin Finck ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres); 1773*c2c66affSColin Finck ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers); 1774*c2c66affSColin Finck 1775*c2c66affSColin Finck SET_EXPECT(QueryService_HttpNegotiate); 1776*c2c66affSColin Finck hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2, 1777*c2c66affSColin Finck &IID_IHttpNegotiate2, (void**)&http_negotiate2); 1778*c2c66affSColin Finck CHECK_CALLED(QueryService_HttpNegotiate); 1779*c2c66affSColin Finck ok(hres == S_OK, "QueryService failed: %08x\n", hres); 1780*c2c66affSColin Finck 1781*c2c66affSColin Finck size = 512; 1782*c2c66affSColin Finck SET_EXPECT(GetRootSecurityId); 1783*c2c66affSColin Finck hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0); 1784*c2c66affSColin Finck CHECK_CALLED(GetRootSecurityId); 1785*c2c66affSColin Finck IHttpNegotiate2_Release(http_negotiate2); 1786*c2c66affSColin Finck ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres); 1787*c2c66affSColin Finck ok(size == 13, "size=%d\n", size); 1788*c2c66affSColin Finck 1789*c2c66affSColin Finck IServiceProvider_Release(service_provider); 1790*c2c66affSColin Finck 1791*c2c66affSColin Finck CreateThread(NULL, 0, thread_proc, NULL, 0, &tid); 1792*c2c66affSColin Finck return; 1793*c2c66affSColin Finck } 1794*c2c66affSColin Finck 1795*c2c66affSColin Finck SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); 1796*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(pOIProtSink, 1797*c2c66affSColin Finck BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW); 1798*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres); 1799*c2c66affSColin Finck CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE); 1800*c2c66affSColin Finck 1801*c2c66affSColin Finck if(mimefilter_test) { 1802*c2c66affSColin Finck SET_EXPECT(MimeFilter_CreateInstance); 1803*c2c66affSColin Finck SET_EXPECT(MimeFilter_Start); 1804*c2c66affSColin Finck SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER); 1805*c2c66affSColin Finck } 1806*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 1807*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, 1808*c2c66affSColin Finck mimefilter_test ? pjpegW : (expect_wsz = text_htmlW)); 1809*c2c66affSColin Finck ok(hres == S_OK, 1810*c2c66affSColin Finck "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres); 1811*c2c66affSColin Finck if(mimefilter_test) { 1812*c2c66affSColin Finck CHECK_CALLED(MimeFilter_CreateInstance); 1813*c2c66affSColin Finck CHECK_CALLED(MimeFilter_Start); 1814*c2c66affSColin Finck CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER); 1815*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 1816*c2c66affSColin Finck }else { 1817*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 1818*c2c66affSColin Finck } 1819*c2c66affSColin Finck 1820*c2c66affSColin Finck if(mimefilter_test) 1821*c2c66affSColin Finck SET_EXPECT(MimeFilter_ReportData); 1822*c2c66affSColin Finck else 1823*c2c66affSColin Finck SET_EXPECT(ReportData); 1824*c2c66affSColin Finck hres = IInternetProtocolSink_ReportData(pOIProtSink, 1825*c2c66affSColin Finck BSCF_FIRSTDATANOTIFICATION | (tested_protocol == ITS_TEST ? BSCF_DATAFULLYAVAILABLE : BSCF_LASTDATANOTIFICATION), 1826*c2c66affSColin Finck 13, 13); 1827*c2c66affSColin Finck ok(hres == S_OK, "ReportData failed: %08x\n", hres); 1828*c2c66affSColin Finck if(mimefilter_test) 1829*c2c66affSColin Finck CHECK_CALLED(MimeFilter_ReportData); 1830*c2c66affSColin Finck else 1831*c2c66affSColin Finck CHECK_CALLED(ReportData); 1832*c2c66affSColin Finck 1833*c2c66affSColin Finck if(tested_protocol == ITS_TEST) { 1834*c2c66affSColin Finck SET_EXPECT(ReportData); 1835*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL); 1836*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres); 1837*c2c66affSColin Finck CHECK_CALLED(ReportData); 1838*c2c66affSColin Finck } 1839*c2c66affSColin Finck 1840*c2c66affSColin Finck if(tested_protocol == BIND_TEST) { 1841*c2c66affSColin Finck hres = IInternetProtocol_Terminate(binding_protocol, 0); 1842*c2c66affSColin Finck ok(hres == E_FAIL, "Termiante failed: %08x\n", hres); 1843*c2c66affSColin Finck } 1844*c2c66affSColin Finck 1845*c2c66affSColin Finck if(mimefilter_test) 1846*c2c66affSColin Finck SET_EXPECT(MimeFilter_ReportResult); 1847*c2c66affSColin Finck else 1848*c2c66affSColin Finck SET_EXPECT(ReportResult); 1849*c2c66affSColin Finck hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL); 1850*c2c66affSColin Finck ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1851*c2c66affSColin Finck if(mimefilter_test) 1852*c2c66affSColin Finck CHECK_CALLED(MimeFilter_ReportResult); 1853*c2c66affSColin Finck else 1854*c2c66affSColin Finck CHECK_CALLED(ReportResult); 1855*c2c66affSColin Finck } 1856*c2c66affSColin Finck 1857*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_Start(IInternetProtocolEx *iface, LPCWSTR szUrl, 1858*c2c66affSColin Finck IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, 1859*c2c66affSColin Finck DWORD grfPI, HANDLE_PTR dwReserved) 1860*c2c66affSColin Finck { 1861*c2c66affSColin Finck CHECK_EXPECT(Start); 1862*c2c66affSColin Finck 1863*c2c66affSColin Finck ok(!dwReserved, "dwReserved = %lx\n", dwReserved); 1864*c2c66affSColin Finck protocol_start(pOIProtSink, pOIBindInfo, grfPI); 1865*c2c66affSColin Finck return S_OK; 1866*c2c66affSColin Finck } 1867*c2c66affSColin Finck 1868*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_Continue(IInternetProtocolEx *iface, 1869*c2c66affSColin Finck PROTOCOLDATA *pProtocolData) 1870*c2c66affSColin Finck { 1871*c2c66affSColin Finck DWORD bscf = 0, pr; 1872*c2c66affSColin Finck HRESULT hres; 1873*c2c66affSColin Finck 1874*c2c66affSColin Finck CHECK_EXPECT(Continue); 1875*c2c66affSColin Finck 1876*c2c66affSColin Finck ok(pProtocolData != NULL, "pProtocolData == NULL\n"); 1877*c2c66affSColin Finck if(!pProtocolData || tested_protocol == BIND_TEST) 1878*c2c66affSColin Finck return S_OK; 1879*c2c66affSColin Finck if(binding_test) { 1880*c2c66affSColin Finck ok(pProtocolData != &protocoldata, "pProtocolData == &protocoldata\n"); 1881*c2c66affSColin Finck ok(pProtocolData->grfFlags == protocoldata.grfFlags, "grfFlags wrong %x/%x\n", 1882*c2c66affSColin Finck pProtocolData->grfFlags, protocoldata.grfFlags ); 1883*c2c66affSColin Finck ok(pProtocolData->dwState == protocoldata.dwState, "dwState wrong %x/%x\n", 1884*c2c66affSColin Finck pProtocolData->dwState, protocoldata.dwState ); 1885*c2c66affSColin Finck ok(pProtocolData->pData == protocoldata.pData, "pData wrong %p/%p\n", 1886*c2c66affSColin Finck pProtocolData->pData, protocoldata.pData ); 1887*c2c66affSColin Finck ok(pProtocolData->cbData == protocoldata.cbData, "cbData wrong %x/%x\n", 1888*c2c66affSColin Finck pProtocolData->cbData, protocoldata.cbData ); 1889*c2c66affSColin Finck } 1890*c2c66affSColin Finck 1891*c2c66affSColin Finck switch(prot_state) { 1892*c2c66affSColin Finck case 1: { 1893*c2c66affSColin Finck IServiceProvider *service_provider; 1894*c2c66affSColin Finck IHttpNegotiate *http_negotiate; 1895*c2c66affSColin Finck static const WCHAR header[] = {'?',0}; 1896*c2c66affSColin Finck static const WCHAR redirect_urlW[] = {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g', 1897*c2c66affSColin Finck '/','t','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0}; 1898*c2c66affSColin Finck 1899*c2c66affSColin Finck if(redirect_on_continue) { 1900*c2c66affSColin Finck redirect_on_continue = FALSE; 1901*c2c66affSColin Finck 1902*c2c66affSColin Finck if(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS) 1903*c2c66affSColin Finck SET_EXPECT(Redirect); 1904*c2c66affSColin Finck SET_EXPECT(ReportProgress_REDIRECTING); 1905*c2c66affSColin Finck SET_EXPECT(Terminate); 1906*c2c66affSColin Finck SET_EXPECT(QueryService_InternetProtocol); 1907*c2c66affSColin Finck SET_EXPECT(CreateInstance); 1908*c2c66affSColin Finck SET_EXPECT(ReportProgress_PROTOCOLCLASSID); 1909*c2c66affSColin Finck SET_EXPECT(SetPriority); 1910*c2c66affSColin Finck SET_EXPECT(Start); 1911*c2c66affSColin Finck hres = IInternetProtocolSink_ReportResult(binding_sink, INET_E_REDIRECT_FAILED, ERROR_SUCCESS, redirect_urlW); 1912*c2c66affSColin Finck ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1913*c2c66affSColin Finck if(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS) 1914*c2c66affSColin Finck CHECK_CALLED(Redirect); 1915*c2c66affSColin Finck CHECK_CALLED(ReportProgress_REDIRECTING); 1916*c2c66affSColin Finck CHECK_CALLED(Terminate); 1917*c2c66affSColin Finck CHECK_CALLED(QueryService_InternetProtocol); 1918*c2c66affSColin Finck CHECK_CALLED(CreateInstance); 1919*c2c66affSColin Finck CHECK_CALLED(ReportProgress_PROTOCOLCLASSID); 1920*c2c66affSColin Finck todo_wine CHECK_NOT_CALLED(SetPriority); 1921*c2c66affSColin Finck CHECK_CALLED(Start); 1922*c2c66affSColin Finck 1923*c2c66affSColin Finck return S_OK; 1924*c2c66affSColin Finck } 1925*c2c66affSColin Finck 1926*c2c66affSColin Finck hres = IInternetProtocolSink_QueryInterface(binding_sink, &IID_IServiceProvider, 1927*c2c66affSColin Finck (void**)&service_provider); 1928*c2c66affSColin Finck ok(hres == S_OK, "Could not get IServiceProvicder\n"); 1929*c2c66affSColin Finck 1930*c2c66affSColin Finck SET_EXPECT(QueryService_HttpNegotiate); 1931*c2c66affSColin Finck hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, 1932*c2c66affSColin Finck &IID_IHttpNegotiate, (void**)&http_negotiate); 1933*c2c66affSColin Finck IServiceProvider_Release(service_provider); 1934*c2c66affSColin Finck CHECK_CALLED(QueryService_HttpNegotiate); 1935*c2c66affSColin Finck ok(hres == S_OK, "Could not get IHttpNegotiate\n"); 1936*c2c66affSColin Finck 1937*c2c66affSColin Finck SET_EXPECT(OnResponse); 1938*c2c66affSColin Finck hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL); 1939*c2c66affSColin Finck IHttpNegotiate_Release(http_negotiate); 1940*c2c66affSColin Finck CHECK_CALLED(OnResponse); 1941*c2c66affSColin Finck IHttpNegotiate_Release(http_negotiate); 1942*c2c66affSColin Finck ok(hres == S_OK, "OnResponse failed: %08x\n", hres); 1943*c2c66affSColin Finck 1944*c2c66affSColin Finck if(mimefilter_test) { 1945*c2c66affSColin Finck SET_EXPECT(MimeFilter_CreateInstance); 1946*c2c66affSColin Finck SET_EXPECT(MimeFilter_Start); 1947*c2c66affSColin Finck SET_EXPECT(ReportProgress_LOADINGMIMEHANDLER); 1948*c2c66affSColin Finck }else if(!(pi & PI_MIMEVERIFICATION)) { 1949*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 1950*c2c66affSColin Finck } 1951*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(binding_sink, 1952*c2c66affSColin Finck BINDSTATUS_MIMETYPEAVAILABLE, mimefilter_test ? pjpegW : text_htmlW); 1953*c2c66affSColin Finck if(mimefilter_test) { 1954*c2c66affSColin Finck CHECK_CALLED(MimeFilter_CreateInstance); 1955*c2c66affSColin Finck CHECK_CALLED(MimeFilter_Start); 1956*c2c66affSColin Finck CHECK_CALLED(ReportProgress_LOADINGMIMEHANDLER); 1957*c2c66affSColin Finck }else if(!(pi & PI_MIMEVERIFICATION)) { 1958*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 1959*c2c66affSColin Finck } 1960*c2c66affSColin Finck ok(hres == S_OK, 1961*c2c66affSColin Finck "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres); 1962*c2c66affSColin Finck 1963*c2c66affSColin Finck bscf |= BSCF_FIRSTDATANOTIFICATION; 1964*c2c66affSColin Finck break; 1965*c2c66affSColin Finck } 1966*c2c66affSColin Finck case 2: 1967*c2c66affSColin Finck case 3: 1968*c2c66affSColin Finck bscf = BSCF_INTERMEDIATEDATANOTIFICATION; 1969*c2c66affSColin Finck break; 1970*c2c66affSColin Finck } 1971*c2c66affSColin Finck 1972*c2c66affSColin Finck pr = prot_read; 1973*c2c66affSColin Finck if(mimefilter_test) 1974*c2c66affSColin Finck SET_EXPECT(MimeFilter_ReportData); 1975*c2c66affSColin Finck if((!mimefilter_test || no_mime) && (pi & PI_MIMEVERIFICATION)) { 1976*c2c66affSColin Finck if(pr < 200) 1977*c2c66affSColin Finck SET_EXPECT(Read); /* checked in ReportData for short_read */ 1978*c2c66affSColin Finck if(pr == 200) { 1979*c2c66affSColin Finck if(!mimefilter_test) 1980*c2c66affSColin Finck SET_EXPECT(Read); /* checked in BINDSTATUS_MIMETYPEAVAILABLE or ReportData */ 1981*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 1982*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 1983*c2c66affSColin Finck } 1984*c2c66affSColin Finck if(pr >= 200) 1985*c2c66affSColin Finck SET_EXPECT(ReportData); 1986*c2c66affSColin Finck }else { 1987*c2c66affSColin Finck SET_EXPECT(ReportData); 1988*c2c66affSColin Finck } 1989*c2c66affSColin Finck 1990*c2c66affSColin Finck hres = IInternetProtocolSink_ReportData(binding_sink, bscf, pr, 400); 1991*c2c66affSColin Finck ok(hres == S_OK, "ReportData failed: %08x\n", hres); 1992*c2c66affSColin Finck 1993*c2c66affSColin Finck if(mimefilter_test) { 1994*c2c66affSColin Finck SET_EXPECT(MimeFilter_ReportData); 1995*c2c66affSColin Finck }else if(pi & PI_MIMEVERIFICATION) { 1996*c2c66affSColin Finck if(!short_read && pr < 200) 1997*c2c66affSColin Finck CHECK_CALLED(Read); 1998*c2c66affSColin Finck if(pr == 200) { 1999*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); /* IE9 */ 2000*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 2001*c2c66affSColin Finck } 2002*c2c66affSColin Finck }else { 2003*c2c66affSColin Finck CHECK_CALLED(ReportData); 2004*c2c66affSColin Finck } 2005*c2c66affSColin Finck 2006*c2c66affSColin Finck if(prot_state == 3) 2007*c2c66affSColin Finck prot_state = 4; 2008*c2c66affSColin Finck 2009*c2c66affSColin Finck return S_OK; 2010*c2c66affSColin Finck } 2011*c2c66affSColin Finck 2012*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_Terminate(IInternetProtocolEx *iface, DWORD dwOptions) 2013*c2c66affSColin Finck { 2014*c2c66affSColin Finck CHECK_EXPECT(Terminate); 2015*c2c66affSColin Finck ok(!dwOptions, "dwOptions=%d\n", dwOptions); 2016*c2c66affSColin Finck return S_OK; 2017*c2c66affSColin Finck } 2018*c2c66affSColin Finck 2019*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_Read(IInternetProtocolEx *iface, void *pv, 2020*c2c66affSColin Finck ULONG cb, ULONG *pcbRead) 2021*c2c66affSColin Finck { 2022*c2c66affSColin Finck if(read_report_data) 2023*c2c66affSColin Finck CHECK_EXPECT2(Read2); 2024*c2c66affSColin Finck 2025*c2c66affSColin Finck if(mimefilter_test || short_read) { 2026*c2c66affSColin Finck if(!read_report_data) 2027*c2c66affSColin Finck CHECK_EXPECT2(Read); 2028*c2c66affSColin Finck }else if((pi & PI_MIMEVERIFICATION)) { 2029*c2c66affSColin Finck if(!read_report_data) 2030*c2c66affSColin Finck CHECK_EXPECT2(Read); 2031*c2c66affSColin Finck 2032*c2c66affSColin Finck if(prot_read < 300) { 2033*c2c66affSColin Finck ok(pv != expect_pv, "pv == expect_pv\n"); 2034*c2c66affSColin Finck if(prot_read < 300) 2035*c2c66affSColin Finck ok(cb == 2048-prot_read, "cb=%d\n", cb); 2036*c2c66affSColin Finck else 2037*c2c66affSColin Finck ok(cb == 700, "cb=%d\n", cb); 2038*c2c66affSColin Finck }else { 2039*c2c66affSColin Finck ok(expect_pv <= pv && (BYTE*)pv < (BYTE*)expect_pv + cb, "pv != expect_pv\n"); 2040*c2c66affSColin Finck } 2041*c2c66affSColin Finck }else { 2042*c2c66affSColin Finck if(!read_report_data) 2043*c2c66affSColin Finck CHECK_EXPECT(Read); 2044*c2c66affSColin Finck 2045*c2c66affSColin Finck ok(pv == expect_pv, "pv != expect_pv\n"); 2046*c2c66affSColin Finck ok(cb == 1000, "cb=%d\n", cb); 2047*c2c66affSColin Finck ok(!*pcbRead, "*pcbRead = %d\n", *pcbRead); 2048*c2c66affSColin Finck } 2049*c2c66affSColin Finck ok(pcbRead != NULL, "pcbRead == NULL\n"); 2050*c2c66affSColin Finck 2051*c2c66affSColin Finck if(prot_state == 3 || (short_read && prot_state != 4)) { 2052*c2c66affSColin Finck HRESULT hres; 2053*c2c66affSColin Finck 2054*c2c66affSColin Finck prot_state = 4; 2055*c2c66affSColin Finck if(short_read) { 2056*c2c66affSColin Finck SET_EXPECT(Read2); /* checked in BINDSTATUS_MIMETYPEAVAILABLE */ 2057*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2058*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 2059*c2c66affSColin Finck } 2060*c2c66affSColin Finck if(mimefilter_test) 2061*c2c66affSColin Finck SET_EXPECT(MimeFilter_ReportData); 2062*c2c66affSColin Finck else if(direct_read) 2063*c2c66affSColin Finck SET_EXPECT(ReportData2); 2064*c2c66affSColin Finck read_report_data++; 2065*c2c66affSColin Finck hres = IInternetProtocolSink_ReportData(binding_sink, 2066*c2c66affSColin Finck BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 0, 0); 2067*c2c66affSColin Finck read_report_data--; 2068*c2c66affSColin Finck ok(hres == S_OK, "ReportData failed: %08x\n", hres); 2069*c2c66affSColin Finck if(short_read) { 2070*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); /* IE9 */ 2071*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 2072*c2c66affSColin Finck } 2073*c2c66affSColin Finck if(mimefilter_test) 2074*c2c66affSColin Finck CHECK_CALLED(MimeFilter_ReportData); 2075*c2c66affSColin Finck else if(direct_read) 2076*c2c66affSColin Finck CHECK_CALLED(ReportData2); 2077*c2c66affSColin Finck 2078*c2c66affSColin Finck if(mimefilter_test) 2079*c2c66affSColin Finck SET_EXPECT(MimeFilter_ReportResult); 2080*c2c66affSColin Finck else 2081*c2c66affSColin Finck SET_EXPECT(ReportResult); 2082*c2c66affSColin Finck hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL); 2083*c2c66affSColin Finck ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 2084*c2c66affSColin Finck if(mimefilter_test) 2085*c2c66affSColin Finck CHECK_CALLED(MimeFilter_ReportResult); 2086*c2c66affSColin Finck else 2087*c2c66affSColin Finck CHECK_CALLED(ReportResult); 2088*c2c66affSColin Finck 2089*c2c66affSColin Finck if(cb > 100) 2090*c2c66affSColin Finck cb = 100; 2091*c2c66affSColin Finck memset(pv, 'x', cb); 2092*c2c66affSColin Finck if(cb>6) 2093*c2c66affSColin Finck memcpy(pv, "gif87a", 6); 2094*c2c66affSColin Finck prot_read += *pcbRead = cb; 2095*c2c66affSColin Finck return S_OK; 2096*c2c66affSColin Finck } 2097*c2c66affSColin Finck 2098*c2c66affSColin Finck if(prot_state == 4) { 2099*c2c66affSColin Finck *pcbRead = 0; 2100*c2c66affSColin Finck return S_FALSE; 2101*c2c66affSColin Finck } 2102*c2c66affSColin Finck 2103*c2c66affSColin Finck if((async_read_pending = !async_read_pending)) { 2104*c2c66affSColin Finck *pcbRead = 0; 2105*c2c66affSColin Finck return tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST ? E_PENDING : S_FALSE; 2106*c2c66affSColin Finck } 2107*c2c66affSColin Finck 2108*c2c66affSColin Finck if(cb > 100) 2109*c2c66affSColin Finck cb = 100; 2110*c2c66affSColin Finck memset(pv, 'x', cb); 2111*c2c66affSColin Finck if(cb>6) 2112*c2c66affSColin Finck memcpy(pv, "gif87a", 6); 2113*c2c66affSColin Finck prot_read += *pcbRead = cb; 2114*c2c66affSColin Finck return S_OK; 2115*c2c66affSColin Finck } 2116*c2c66affSColin Finck 2117*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions) 2118*c2c66affSColin Finck { 2119*c2c66affSColin Finck CHECK_EXPECT(LockRequest); 2120*c2c66affSColin Finck ok(dwOptions == 0, "dwOptions=%x\n", dwOptions); 2121*c2c66affSColin Finck return S_OK; 2122*c2c66affSColin Finck } 2123*c2c66affSColin Finck 2124*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_UnlockRequest(IInternetProtocolEx *iface) 2125*c2c66affSColin Finck { 2126*c2c66affSColin Finck CHECK_EXPECT(UnlockRequest); 2127*c2c66affSColin Finck return S_OK; 2128*c2c66affSColin Finck } 2129*c2c66affSColin Finck 2130*c2c66affSColin Finck static HRESULT WINAPI ProtocolEmul_StartEx(IInternetProtocolEx *iface, IUri *pUri, 2131*c2c66affSColin Finck IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, 2132*c2c66affSColin Finck DWORD grfPI, HANDLE *dwReserved) 2133*c2c66affSColin Finck { 2134*c2c66affSColin Finck CHECK_EXPECT(StartEx); 2135*c2c66affSColin Finck ok(!dwReserved, "dwReserved = %p\n", dwReserved); 2136*c2c66affSColin Finck protocol_start(pOIProtSink, pOIBindInfo, grfPI); 2137*c2c66affSColin Finck return S_OK; 2138*c2c66affSColin Finck } 2139*c2c66affSColin Finck 2140*c2c66affSColin Finck static const IInternetProtocolExVtbl ProtocolVtbl = { 2141*c2c66affSColin Finck ProtocolEmul_QueryInterface, 2142*c2c66affSColin Finck Protocol_AddRef, 2143*c2c66affSColin Finck Protocol_Release, 2144*c2c66affSColin Finck ProtocolEmul_Start, 2145*c2c66affSColin Finck ProtocolEmul_Continue, 2146*c2c66affSColin Finck Protocol_Abort, 2147*c2c66affSColin Finck ProtocolEmul_Terminate, 2148*c2c66affSColin Finck Protocol_Suspend, 2149*c2c66affSColin Finck Protocol_Resume, 2150*c2c66affSColin Finck ProtocolEmul_Read, 2151*c2c66affSColin Finck Protocol_Seek, 2152*c2c66affSColin Finck ProtocolEmul_LockRequest, 2153*c2c66affSColin Finck ProtocolEmul_UnlockRequest, 2154*c2c66affSColin Finck ProtocolEmul_StartEx 2155*c2c66affSColin Finck }; 2156*c2c66affSColin Finck 2157*c2c66affSColin Finck static IInternetProtocolEx Protocol = { &ProtocolVtbl }; 2158*c2c66affSColin Finck 2159*c2c66affSColin Finck static HRESULT WINAPI MimeProtocol_QueryInterface(IInternetProtocolEx *iface, REFIID riid, void **ppv) 2160*c2c66affSColin Finck { 2161*c2c66affSColin Finck if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) { 2162*c2c66affSColin Finck *ppv = iface; 2163*c2c66affSColin Finck return S_OK; 2164*c2c66affSColin Finck } 2165*c2c66affSColin Finck 2166*c2c66affSColin Finck if(IsEqualGUID(&IID_IInternetProtocolSink, riid)) { 2167*c2c66affSColin Finck *ppv = &mime_protocol_sink; 2168*c2c66affSColin Finck return S_OK; 2169*c2c66affSColin Finck } 2170*c2c66affSColin Finck 2171*c2c66affSColin Finck ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2172*c2c66affSColin Finck *ppv = NULL; 2173*c2c66affSColin Finck return E_NOINTERFACE; 2174*c2c66affSColin Finck } 2175*c2c66affSColin Finck 2176*c2c66affSColin Finck static HRESULT WINAPI MimeProtocol_Start(IInternetProtocolEx *iface, LPCWSTR szUrl, 2177*c2c66affSColin Finck IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, 2178*c2c66affSColin Finck DWORD grfPI, HANDLE_PTR dwReserved) 2179*c2c66affSColin Finck { 2180*c2c66affSColin Finck PROTOCOLFILTERDATA *data; 2181*c2c66affSColin Finck LPOLESTR url_str = NULL; 2182*c2c66affSColin Finck DWORD fetched = 0; 2183*c2c66affSColin Finck BINDINFO bindinfo; 2184*c2c66affSColin Finck DWORD cbindf = 0; 2185*c2c66affSColin Finck HRESULT hres; 2186*c2c66affSColin Finck 2187*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_Start); 2188*c2c66affSColin Finck 2189*c2c66affSColin Finck ok(!lstrcmpW(szUrl, pjpegW), "wrong url %s\n", wine_dbgstr_w(szUrl)); 2190*c2c66affSColin Finck ok(grfPI == (PI_FILTER_MODE|PI_FORCE_ASYNC), "grfPI=%x, expected PI_FILTER_MODE|PI_FORCE_ASYNC\n", grfPI); 2191*c2c66affSColin Finck ok(dwReserved, "dwReserved == 0\n"); 2192*c2c66affSColin Finck ok(pOIProtSink != NULL, "pOIProtSink == NULL\n"); 2193*c2c66affSColin Finck ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n"); 2194*c2c66affSColin Finck 2195*c2c66affSColin Finck if(binding_test) { 2196*c2c66affSColin Finck ok(pOIProtSink != binding_sink, "pOIProtSink == protocol_sink\n"); 2197*c2c66affSColin Finck ok(pOIBindInfo == prot_bind_info, "pOIBindInfo != bind_info\n"); 2198*c2c66affSColin Finck }else { 2199*c2c66affSColin Finck ok(pOIProtSink == &protocol_sink, "pOIProtSink != protocol_sink\n"); 2200*c2c66affSColin Finck ok(pOIBindInfo == &bind_info, "pOIBindInfo != bind_info\n"); 2201*c2c66affSColin Finck } 2202*c2c66affSColin Finck 2203*c2c66affSColin Finck data = (void*)dwReserved; 2204*c2c66affSColin Finck ok(data->cbSize == sizeof(*data), "data->cbSize = %d\n", data->cbSize); 2205*c2c66affSColin Finck ok(!data->pProtocolSink, "data->pProtocolSink != NULL\n"); 2206*c2c66affSColin Finck ok(data->pProtocol != NULL, "data->pProtocol == NULL\n"); 2207*c2c66affSColin Finck ok(!data->pUnk, "data->pUnk != NULL\n"); 2208*c2c66affSColin Finck ok(!data->dwFilterFlags, "data->dwProtocolFlags = %x\n", data->dwFilterFlags); 2209*c2c66affSColin Finck if(binding_test) { 2210*c2c66affSColin Finck IInternetProtocolSink *prot_sink; 2211*c2c66affSColin Finck 2212*c2c66affSColin Finck IInternetProtocol_QueryInterface(data->pProtocol, &IID_IInternetProtocolSink, (void**)&prot_sink); 2213*c2c66affSColin Finck ok(prot_sink == pOIProtSink, "QI(data->pProtocol, IID_IInternetProtocolSink) != pOIProtSink\n"); 2214*c2c66affSColin Finck IInternetProtocolSink_Release(prot_sink); 2215*c2c66affSColin Finck 2216*c2c66affSColin Finck ok(data->pProtocol != binding_protocol, "data->pProtocol == binding_protocol\n"); 2217*c2c66affSColin Finck 2218*c2c66affSColin Finck filtered_protocol = data->pProtocol; 2219*c2c66affSColin Finck IInternetProtocol_AddRef(filtered_protocol); 2220*c2c66affSColin Finck }else { 2221*c2c66affSColin Finck IInternetProtocol *prot; 2222*c2c66affSColin Finck 2223*c2c66affSColin Finck IInternetProtocol_QueryInterface(data->pProtocol, &IID_IInternetProtocol, (void**)&prot); 2224*c2c66affSColin Finck ok(prot == async_protocol, "QI(data->pProtocol, IID_IInternetProtocol) != async_protocol\n"); 2225*c2c66affSColin Finck IInternetProtocol_Release(prot); 2226*c2c66affSColin Finck 2227*c2c66affSColin Finck ok(data->pProtocol != async_protocol, "data->pProtocol == async_protocol\n"); 2228*c2c66affSColin Finck } 2229*c2c66affSColin Finck 2230*c2c66affSColin Finck filtered_sink = pOIProtSink; 2231*c2c66affSColin Finck 2232*c2c66affSColin Finck SET_EXPECT(ReportProgress_DECODING); 2233*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_DECODING, pjpegW); 2234*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress(BINDSTATUS_DECODING) failed: %08x\n", hres); 2235*c2c66affSColin Finck CHECK_CALLED(ReportProgress_DECODING); 2236*c2c66affSColin Finck 2237*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2238*c2c66affSColin Finck memset(&bindinfo, 0, sizeof(bindinfo)); 2239*c2c66affSColin Finck bindinfo.cbSize = sizeof(bindinfo); 2240*c2c66affSColin Finck hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo); 2241*c2c66affSColin Finck ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 2242*c2c66affSColin Finck ok(cbindf == (bindf|BINDF_FROMURLMON), "cbindf = %x, expected %x\n", cbindf, bindf); 2243*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 2244*c2c66affSColin Finck 2245*c2c66affSColin Finck SET_EXPECT(GetBindString_URL); 2246*c2c66affSColin Finck hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_URL, &url_str, 1, &fetched); 2247*c2c66affSColin Finck ok(hres == S_OK, "GetBindString(BINDSTRING_URL) failed: %08x\n", hres); 2248*c2c66affSColin Finck ok(fetched == 1, "fetched = %d\n", fetched); 2249*c2c66affSColin Finck ok(!lstrcmpW(url_str, binding_urls[tested_protocol]), "wrong url_str %s\n", wine_dbgstr_w(url_str)); 2250*c2c66affSColin Finck CoTaskMemFree(url_str); 2251*c2c66affSColin Finck CHECK_CALLED(GetBindString_URL); 2252*c2c66affSColin Finck 2253*c2c66affSColin Finck return S_OK; 2254*c2c66affSColin Finck } 2255*c2c66affSColin Finck 2256*c2c66affSColin Finck static HRESULT WINAPI Protocol_Continue(IInternetProtocolEx *iface, 2257*c2c66affSColin Finck PROTOCOLDATA *pProtocolData) 2258*c2c66affSColin Finck { 2259*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_Continue); 2260*c2c66affSColin Finck return E_NOTIMPL; 2261*c2c66affSColin Finck } 2262*c2c66affSColin Finck 2263*c2c66affSColin Finck static HRESULT WINAPI MimeProtocol_Terminate(IInternetProtocolEx *iface, DWORD dwOptions) 2264*c2c66affSColin Finck { 2265*c2c66affSColin Finck HRESULT hres; 2266*c2c66affSColin Finck 2267*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_Terminate); 2268*c2c66affSColin Finck 2269*c2c66affSColin Finck ok(!dwOptions, "dwOptions = %x\n", dwOptions); 2270*c2c66affSColin Finck 2271*c2c66affSColin Finck SET_EXPECT(Terminate); 2272*c2c66affSColin Finck hres = IInternetProtocol_Terminate(filtered_protocol, dwOptions); 2273*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 2274*c2c66affSColin Finck CHECK_CALLED(Terminate); 2275*c2c66affSColin Finck 2276*c2c66affSColin Finck return S_OK; 2277*c2c66affSColin Finck } 2278*c2c66affSColin Finck 2279*c2c66affSColin Finck static HRESULT WINAPI MimeProtocol_Read(IInternetProtocolEx *iface, void *pv, 2280*c2c66affSColin Finck ULONG cb, ULONG *pcbRead) 2281*c2c66affSColin Finck { 2282*c2c66affSColin Finck BYTE buf[2096]; 2283*c2c66affSColin Finck DWORD read = 0; 2284*c2c66affSColin Finck HRESULT hres; 2285*c2c66affSColin Finck 2286*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_Read); 2287*c2c66affSColin Finck 2288*c2c66affSColin Finck ok(pv != NULL, "pv == NULL\n"); 2289*c2c66affSColin Finck ok(cb != 0, "cb == 0\n"); 2290*c2c66affSColin Finck ok(pcbRead != NULL, "pcbRead == NULL\n"); 2291*c2c66affSColin Finck 2292*c2c66affSColin Finck if(read_report_data) 2293*c2c66affSColin Finck SET_EXPECT(Read2); 2294*c2c66affSColin Finck else 2295*c2c66affSColin Finck SET_EXPECT(Read); 2296*c2c66affSColin Finck hres = IInternetProtocol_Read(filtered_protocol, buf, sizeof(buf), &read); 2297*c2c66affSColin Finck ok(hres == S_OK || hres == S_FALSE || hres == E_PENDING, "Read failed: %08x\n", hres); 2298*c2c66affSColin Finck if(read_report_data) 2299*c2c66affSColin Finck CHECK_CALLED(Read2); 2300*c2c66affSColin Finck else 2301*c2c66affSColin Finck CHECK_CALLED(Read); 2302*c2c66affSColin Finck 2303*c2c66affSColin Finck if(pcbRead) { 2304*c2c66affSColin Finck ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead); 2305*c2c66affSColin Finck *pcbRead = read; 2306*c2c66affSColin Finck } 2307*c2c66affSColin Finck 2308*c2c66affSColin Finck memset(pv, 'x', read); 2309*c2c66affSColin Finck return hres; 2310*c2c66affSColin Finck } 2311*c2c66affSColin Finck 2312*c2c66affSColin Finck static HRESULT WINAPI MimeProtocol_LockRequest(IInternetProtocolEx *iface, DWORD dwOptions) 2313*c2c66affSColin Finck { 2314*c2c66affSColin Finck HRESULT hres; 2315*c2c66affSColin Finck 2316*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_LockRequest); 2317*c2c66affSColin Finck 2318*c2c66affSColin Finck ok(!dwOptions, "dwOptions = %x\n", dwOptions); 2319*c2c66affSColin Finck 2320*c2c66affSColin Finck SET_EXPECT(LockRequest); 2321*c2c66affSColin Finck hres = IInternetProtocol_LockRequest(filtered_protocol, dwOptions); 2322*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 2323*c2c66affSColin Finck CHECK_CALLED(LockRequest); 2324*c2c66affSColin Finck 2325*c2c66affSColin Finck return S_OK; 2326*c2c66affSColin Finck } 2327*c2c66affSColin Finck 2328*c2c66affSColin Finck static HRESULT WINAPI MimeProtocol_UnlockRequest(IInternetProtocolEx *iface) 2329*c2c66affSColin Finck { 2330*c2c66affSColin Finck HRESULT hres; 2331*c2c66affSColin Finck 2332*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_UnlockRequest); 2333*c2c66affSColin Finck 2334*c2c66affSColin Finck SET_EXPECT(UnlockRequest); 2335*c2c66affSColin Finck hres = IInternetProtocol_UnlockRequest(filtered_protocol); 2336*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 2337*c2c66affSColin Finck CHECK_CALLED(UnlockRequest); 2338*c2c66affSColin Finck 2339*c2c66affSColin Finck return S_OK; 2340*c2c66affSColin Finck } 2341*c2c66affSColin Finck 2342*c2c66affSColin Finck static const IInternetProtocolExVtbl MimeProtocolVtbl = { 2343*c2c66affSColin Finck MimeProtocol_QueryInterface, 2344*c2c66affSColin Finck Protocol_AddRef, 2345*c2c66affSColin Finck Protocol_Release, 2346*c2c66affSColin Finck MimeProtocol_Start, 2347*c2c66affSColin Finck Protocol_Continue, 2348*c2c66affSColin Finck Protocol_Abort, 2349*c2c66affSColin Finck MimeProtocol_Terminate, 2350*c2c66affSColin Finck Protocol_Suspend, 2351*c2c66affSColin Finck Protocol_Resume, 2352*c2c66affSColin Finck MimeProtocol_Read, 2353*c2c66affSColin Finck Protocol_Seek, 2354*c2c66affSColin Finck MimeProtocol_LockRequest, 2355*c2c66affSColin Finck MimeProtocol_UnlockRequest 2356*c2c66affSColin Finck }; 2357*c2c66affSColin Finck 2358*c2c66affSColin Finck static IInternetProtocolEx MimeProtocol = { &MimeProtocolVtbl }; 2359*c2c66affSColin Finck 2360*c2c66affSColin Finck static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv) 2361*c2c66affSColin Finck { 2362*c2c66affSColin Finck ok(0, "unexpected call\n"); 2363*c2c66affSColin Finck return E_NOINTERFACE; 2364*c2c66affSColin Finck } 2365*c2c66affSColin Finck 2366*c2c66affSColin Finck static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface) 2367*c2c66affSColin Finck { 2368*c2c66affSColin Finck return 2; 2369*c2c66affSColin Finck } 2370*c2c66affSColin Finck 2371*c2c66affSColin Finck static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface) 2372*c2c66affSColin Finck { 2373*c2c66affSColin Finck return 1; 2374*c2c66affSColin Finck } 2375*c2c66affSColin Finck 2376*c2c66affSColin Finck static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR pwzUrl, 2377*c2c66affSColin Finck PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult, 2378*c2c66affSColin Finck DWORD *pcchResult, DWORD dwReserved) 2379*c2c66affSColin Finck { 2380*c2c66affSColin Finck ok(0, "unexpected call %d\n", ParseAction); 2381*c2c66affSColin Finck return E_NOTIMPL; 2382*c2c66affSColin Finck } 2383*c2c66affSColin Finck 2384*c2c66affSColin Finck static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, 2385*c2c66affSColin Finck LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags, 2386*c2c66affSColin Finck LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved) 2387*c2c66affSColin Finck { 2388*c2c66affSColin Finck ok(0, "unexpected call\n"); 2389*c2c66affSColin Finck return E_NOTIMPL; 2390*c2c66affSColin Finck } 2391*c2c66affSColin Finck 2392*c2c66affSColin Finck static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface, 2393*c2c66affSColin Finck LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags) 2394*c2c66affSColin Finck { 2395*c2c66affSColin Finck ok(0, "unexpected call\n"); 2396*c2c66affSColin Finck return E_NOTIMPL; 2397*c2c66affSColin Finck } 2398*c2c66affSColin Finck 2399*c2c66affSColin Finck static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface, 2400*c2c66affSColin Finck LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer, 2401*c2c66affSColin Finck DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved) 2402*c2c66affSColin Finck { 2403*c2c66affSColin Finck ok(0, "unexpected call\n"); 2404*c2c66affSColin Finck return E_NOTIMPL; 2405*c2c66affSColin Finck } 2406*c2c66affSColin Finck 2407*c2c66affSColin Finck static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = { 2408*c2c66affSColin Finck InternetProtocolInfo_QueryInterface, 2409*c2c66affSColin Finck InternetProtocolInfo_AddRef, 2410*c2c66affSColin Finck InternetProtocolInfo_Release, 2411*c2c66affSColin Finck InternetProtocolInfo_ParseUrl, 2412*c2c66affSColin Finck InternetProtocolInfo_CombineUrl, 2413*c2c66affSColin Finck InternetProtocolInfo_CompareUrl, 2414*c2c66affSColin Finck InternetProtocolInfo_QueryInfo 2415*c2c66affSColin Finck }; 2416*c2c66affSColin Finck 2417*c2c66affSColin Finck static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl }; 2418*c2c66affSColin Finck 2419*c2c66affSColin Finck static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) 2420*c2c66affSColin Finck { 2421*c2c66affSColin Finck if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) { 2422*c2c66affSColin Finck *ppv = &protocol_info; 2423*c2c66affSColin Finck return S_OK; 2424*c2c66affSColin Finck } 2425*c2c66affSColin Finck 2426*c2c66affSColin Finck ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid)); 2427*c2c66affSColin Finck return E_NOINTERFACE; 2428*c2c66affSColin Finck } 2429*c2c66affSColin Finck 2430*c2c66affSColin Finck static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface) 2431*c2c66affSColin Finck { 2432*c2c66affSColin Finck return 2; 2433*c2c66affSColin Finck } 2434*c2c66affSColin Finck 2435*c2c66affSColin Finck static ULONG WINAPI ClassFactory_Release(IClassFactory *iface) 2436*c2c66affSColin Finck { 2437*c2c66affSColin Finck return 1; 2438*c2c66affSColin Finck } 2439*c2c66affSColin Finck 2440*c2c66affSColin Finck static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pOuter, 2441*c2c66affSColin Finck REFIID riid, void **ppv) 2442*c2c66affSColin Finck { 2443*c2c66affSColin Finck CHECK_EXPECT(CreateInstance); 2444*c2c66affSColin Finck 2445*c2c66affSColin Finck ok(pOuter == (IUnknown*)prot_bind_info, "pOuter != protocol_unk\n"); 2446*c2c66affSColin Finck ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2447*c2c66affSColin Finck ok(ppv != NULL, "ppv == NULL\n"); 2448*c2c66affSColin Finck 2449*c2c66affSColin Finck *ppv = &Protocol; 2450*c2c66affSColin Finck return S_OK; 2451*c2c66affSColin Finck } 2452*c2c66affSColin Finck 2453*c2c66affSColin Finck static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock) 2454*c2c66affSColin Finck { 2455*c2c66affSColin Finck ok(0, "unexpected call\n"); 2456*c2c66affSColin Finck return S_OK; 2457*c2c66affSColin Finck } 2458*c2c66affSColin Finck 2459*c2c66affSColin Finck static const IClassFactoryVtbl ClassFactoryVtbl = { 2460*c2c66affSColin Finck ClassFactory_QueryInterface, 2461*c2c66affSColin Finck ClassFactory_AddRef, 2462*c2c66affSColin Finck ClassFactory_Release, 2463*c2c66affSColin Finck ClassFactory_CreateInstance, 2464*c2c66affSColin Finck ClassFactory_LockServer 2465*c2c66affSColin Finck }; 2466*c2c66affSColin Finck 2467*c2c66affSColin Finck static IClassFactory ClassFactory = { &ClassFactoryVtbl }; 2468*c2c66affSColin Finck 2469*c2c66affSColin Finck static HRESULT WINAPI MimeFilter_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv) 2470*c2c66affSColin Finck { 2471*c2c66affSColin Finck CHECK_EXPECT(MimeFilter_CreateInstance); 2472*c2c66affSColin Finck 2473*c2c66affSColin Finck ok(!outer, "outer = %p\n", outer); 2474*c2c66affSColin Finck ok(IsEqualGUID(&IID_IInternetProtocol, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2475*c2c66affSColin Finck 2476*c2c66affSColin Finck *ppv = &MimeProtocol; 2477*c2c66affSColin Finck return S_OK; 2478*c2c66affSColin Finck } 2479*c2c66affSColin Finck 2480*c2c66affSColin Finck static const IClassFactoryVtbl MimeFilterCFVtbl = { 2481*c2c66affSColin Finck ClassFactory_QueryInterface, 2482*c2c66affSColin Finck ClassFactory_AddRef, 2483*c2c66affSColin Finck ClassFactory_Release, 2484*c2c66affSColin Finck MimeFilter_CreateInstance, 2485*c2c66affSColin Finck ClassFactory_LockServer 2486*c2c66affSColin Finck }; 2487*c2c66affSColin Finck 2488*c2c66affSColin Finck static IClassFactory mimefilter_cf = { &MimeFilterCFVtbl }; 2489*c2c66affSColin Finck 2490*c2c66affSColin Finck #define TEST_BINDING 0x0001 2491*c2c66affSColin Finck #define TEST_FILTER 0x0002 2492*c2c66affSColin Finck #define TEST_FIRST_HTTP 0x0004 2493*c2c66affSColin Finck #define TEST_DIRECT_READ 0x0008 2494*c2c66affSColin Finck #define TEST_POST 0x0010 2495*c2c66affSColin Finck #define TEST_EMULATEPROT 0x0020 2496*c2c66affSColin Finck #define TEST_SHORT_READ 0x0040 2497*c2c66affSColin Finck #define TEST_REDIRECT 0x0080 2498*c2c66affSColin Finck #define TEST_ABORT 0x0100 2499*c2c66affSColin Finck #define TEST_ASYNCREQ 0x0200 2500*c2c66affSColin Finck #define TEST_USEIURI 0x0400 2501*c2c66affSColin Finck #define TEST_IMPLPROTEX 0x0800 2502*c2c66affSColin Finck #define TEST_EMPTY 0x1000 2503*c2c66affSColin Finck #define TEST_NOMIME 0x2000 2504*c2c66affSColin Finck #define TEST_FROMCACHE 0x4000 2505*c2c66affSColin Finck #define TEST_DISABLEAUTOREDIRECT 0x8000 2506*c2c66affSColin Finck 2507*c2c66affSColin Finck static void register_filter(BOOL do_register) 2508*c2c66affSColin Finck { 2509*c2c66affSColin Finck IInternetSession *session; 2510*c2c66affSColin Finck HRESULT hres; 2511*c2c66affSColin Finck 2512*c2c66affSColin Finck hres = pCoInternetGetSession(0, &session, 0); 2513*c2c66affSColin Finck ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres); 2514*c2c66affSColin Finck 2515*c2c66affSColin Finck if(do_register) { 2516*c2c66affSColin Finck hres = IInternetSession_RegisterMimeFilter(session, &mimefilter_cf, &IID_IInternetProtocol, pjpegW); 2517*c2c66affSColin Finck ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres); 2518*c2c66affSColin Finck hres = IInternetSession_RegisterMimeFilter(session, &mimefilter_cf, &IID_IInternetProtocol, gifW); 2519*c2c66affSColin Finck ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres); 2520*c2c66affSColin Finck }else { 2521*c2c66affSColin Finck hres = IInternetSession_UnregisterMimeFilter(session, &mimefilter_cf, pjpegW); 2522*c2c66affSColin Finck ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres); 2523*c2c66affSColin Finck hres = IInternetSession_UnregisterMimeFilter(session, &mimefilter_cf, gifW); 2524*c2c66affSColin Finck ok(hres == S_OK, "RegisterMimeFilter failed: %08x\n", hres); 2525*c2c66affSColin Finck } 2526*c2c66affSColin Finck 2527*c2c66affSColin Finck IInternetSession_Release(session); 2528*c2c66affSColin Finck } 2529*c2c66affSColin Finck 2530*c2c66affSColin Finck static void init_test(int prot, DWORD flags) 2531*c2c66affSColin Finck { 2532*c2c66affSColin Finck tested_protocol = prot; 2533*c2c66affSColin Finck binding_test = (flags & TEST_BINDING) != 0; 2534*c2c66affSColin Finck first_data_notif = TRUE; 2535*c2c66affSColin Finck prot_read = 0; 2536*c2c66affSColin Finck prot_state = 0; 2537*c2c66affSColin Finck async_read_pending = TRUE; 2538*c2c66affSColin Finck mimefilter_test = (flags & TEST_FILTER) != 0; 2539*c2c66affSColin Finck no_mime = (flags & TEST_NOMIME) != 0; 2540*c2c66affSColin Finck filter_state = 0; 2541*c2c66affSColin Finck post_stream_read = 0; 2542*c2c66affSColin Finck ResetEvent(event_complete); 2543*c2c66affSColin Finck ResetEvent(event_complete2); 2544*c2c66affSColin Finck ResetEvent(event_continue); 2545*c2c66affSColin Finck ResetEvent(event_continue_done); 2546*c2c66affSColin Finck async_protocol = binding_protocol = filtered_protocol = NULL; 2547*c2c66affSColin Finck filtered_sink = NULL; 2548*c2c66affSColin Finck http_is_first = (flags & TEST_FIRST_HTTP) != 0; 2549*c2c66affSColin Finck first_data_notif = TRUE; 2550*c2c66affSColin Finck state = STATE_CONNECTING; 2551*c2c66affSColin Finck test_async_req = (flags & TEST_ASYNCREQ) != 0; 2552*c2c66affSColin Finck direct_read = (flags & TEST_DIRECT_READ) != 0; 2553*c2c66affSColin Finck emulate_prot = (flags & TEST_EMULATEPROT) != 0; 2554*c2c66affSColin Finck wait_for_switch = TRUE; 2555*c2c66affSColin Finck short_read = (flags & TEST_SHORT_READ) != 0; 2556*c2c66affSColin Finck http_post_test = TYMED_NULL; 2557*c2c66affSColin Finck redirect_on_continue = test_redirect = (flags & TEST_REDIRECT) != 0; 2558*c2c66affSColin Finck test_abort = (flags & TEST_ABORT) != 0; 2559*c2c66affSColin Finck impl_protex = (flags & TEST_IMPLPROTEX) != 0; 2560*c2c66affSColin Finck empty_file = (flags & TEST_EMPTY) != 0; 2561*c2c66affSColin Finck bind_from_cache = (flags & TEST_FROMCACHE) != 0; 2562*c2c66affSColin Finck file_with_hash = FALSE; 2563*c2c66affSColin Finck 2564*c2c66affSColin Finck bindinfo_options = 0; 2565*c2c66affSColin Finck if(flags & TEST_DISABLEAUTOREDIRECT) 2566*c2c66affSColin Finck bindinfo_options |= BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS; 2567*c2c66affSColin Finck 2568*c2c66affSColin Finck register_filter(mimefilter_test); 2569*c2c66affSColin Finck } 2570*c2c66affSColin Finck 2571*c2c66affSColin Finck static void test_priority(IInternetProtocol *protocol) 2572*c2c66affSColin Finck { 2573*c2c66affSColin Finck IInternetPriority *priority; 2574*c2c66affSColin Finck LONG pr; 2575*c2c66affSColin Finck HRESULT hres; 2576*c2c66affSColin Finck 2577*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, 2578*c2c66affSColin Finck (void**)&priority); 2579*c2c66affSColin Finck ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres); 2580*c2c66affSColin Finck if(FAILED(hres)) 2581*c2c66affSColin Finck return; 2582*c2c66affSColin Finck 2583*c2c66affSColin Finck hres = IInternetPriority_GetPriority(priority, &pr); 2584*c2c66affSColin Finck ok(hres == S_OK, "GetPriority failed: %08x\n", hres); 2585*c2c66affSColin Finck ok(pr == 0, "pr=%d, expected 0\n", pr); 2586*c2c66affSColin Finck 2587*c2c66affSColin Finck hres = IInternetPriority_SetPriority(priority, 1); 2588*c2c66affSColin Finck ok(hres == S_OK, "SetPriority failed: %08x\n", hres); 2589*c2c66affSColin Finck 2590*c2c66affSColin Finck hres = IInternetPriority_GetPriority(priority, &pr); 2591*c2c66affSColin Finck ok(hres == S_OK, "GetPriority failed: %08x\n", hres); 2592*c2c66affSColin Finck ok(pr == 1, "pr=%d, expected 1\n", pr); 2593*c2c66affSColin Finck 2594*c2c66affSColin Finck IInternetPriority_Release(priority); 2595*c2c66affSColin Finck } 2596*c2c66affSColin Finck 2597*c2c66affSColin Finck static void test_early_abort(const CLSID *clsid) 2598*c2c66affSColin Finck { 2599*c2c66affSColin Finck IInternetProtocol *protocol; 2600*c2c66affSColin Finck HRESULT hres; 2601*c2c66affSColin Finck 2602*c2c66affSColin Finck hres = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, 2603*c2c66affSColin Finck &IID_IInternetProtocol, (void**)&protocol); 2604*c2c66affSColin Finck ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); 2605*c2c66affSColin Finck 2606*c2c66affSColin Finck hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); 2607*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 2608*c2c66affSColin Finck 2609*c2c66affSColin Finck hres = IInternetProtocol_Abort(protocol, E_FAIL, 0); 2610*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 2611*c2c66affSColin Finck 2612*c2c66affSColin Finck IInternetProtocol_Release(protocol); 2613*c2c66affSColin Finck } 2614*c2c66affSColin Finck 2615*c2c66affSColin Finck static BOOL file_protocol_start(IInternetProtocol *protocol, LPCWSTR url, 2616*c2c66affSColin Finck IInternetProtocolEx *protocolex, IUri *uri, BOOL is_first) 2617*c2c66affSColin Finck { 2618*c2c66affSColin Finck HRESULT hres; 2619*c2c66affSColin Finck 2620*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2621*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) 2622*c2c66affSColin Finck SET_EXPECT(ReportProgress_DIRECTBIND); 2623*c2c66affSColin Finck if(is_first) { 2624*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 2625*c2c66affSColin Finck SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); 2626*c2c66affSColin Finck if(bindf & BINDF_FROMURLMON) 2627*c2c66affSColin Finck SET_EXPECT(ReportProgress_VERIFIEDMIMETYPEAVAILABLE); 2628*c2c66affSColin Finck else 2629*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 2630*c2c66affSColin Finck } 2631*c2c66affSColin Finck SET_EXPECT(ReportData); 2632*c2c66affSColin Finck if(is_first) 2633*c2c66affSColin Finck SET_EXPECT(ReportResult); 2634*c2c66affSColin Finck 2635*c2c66affSColin Finck expect_hrResult = S_OK; 2636*c2c66affSColin Finck 2637*c2c66affSColin Finck if(protocolex) { 2638*c2c66affSColin Finck hres = IInternetProtocolEx_StartEx(protocolex, uri, &protocol_sink, &bind_info, 0, 0); 2639*c2c66affSColin Finck ok(hres == S_OK, "StartEx failed: %08x\n", hres); 2640*c2c66affSColin Finck }else { 2641*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0); 2642*c2c66affSColin Finck if(hres == INET_E_RESOURCE_NOT_FOUND) { 2643*c2c66affSColin Finck win_skip("Start failed\n"); 2644*c2c66affSColin Finck return FALSE; 2645*c2c66affSColin Finck } 2646*c2c66affSColin Finck ok(hres == S_OK, "Start failed: %08x\n", hres); 2647*c2c66affSColin Finck } 2648*c2c66affSColin Finck 2649*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 2650*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) 2651*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_DIRECTBIND); /* Not called by IE10 */ 2652*c2c66affSColin Finck if(is_first) { 2653*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 2654*c2c66affSColin Finck CHECK_CALLED(ReportProgress_CACHEFILENAMEAVAILABLE); 2655*c2c66affSColin Finck if(bindf & BINDF_FROMURLMON) 2656*c2c66affSColin Finck CHECK_CALLED(ReportProgress_VERIFIEDMIMETYPEAVAILABLE); 2657*c2c66affSColin Finck else 2658*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 2659*c2c66affSColin Finck } 2660*c2c66affSColin Finck CHECK_CALLED(ReportData); 2661*c2c66affSColin Finck if(is_first) 2662*c2c66affSColin Finck CHECK_CALLED(ReportResult); 2663*c2c66affSColin Finck 2664*c2c66affSColin Finck return TRUE; 2665*c2c66affSColin Finck } 2666*c2c66affSColin Finck 2667*c2c66affSColin Finck static void test_file_protocol_url(LPCWSTR url) 2668*c2c66affSColin Finck { 2669*c2c66affSColin Finck IInternetProtocolInfo *protocol_info; 2670*c2c66affSColin Finck IUnknown *unk; 2671*c2c66affSColin Finck IClassFactory *factory; 2672*c2c66affSColin Finck IInternetProtocol *protocol; 2673*c2c66affSColin Finck BYTE buf[512]; 2674*c2c66affSColin Finck ULONG cb; 2675*c2c66affSColin Finck HRESULT hres; 2676*c2c66affSColin Finck 2677*c2c66affSColin Finck hres = CoGetClassObject(&CLSID_FileProtocol, CLSCTX_INPROC_SERVER, NULL, 2678*c2c66affSColin Finck &IID_IUnknown, (void**)&unk); 2679*c2c66affSColin Finck ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres); 2680*c2c66affSColin Finck if(FAILED(hres)) 2681*c2c66affSColin Finck return; 2682*c2c66affSColin Finck 2683*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); 2684*c2c66affSColin Finck ok(hres == E_NOINTERFACE, 2685*c2c66affSColin Finck "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres); 2686*c2c66affSColin Finck 2687*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); 2688*c2c66affSColin Finck ok(hres == S_OK, "Could not get IClassFactory interface\n"); 2689*c2c66affSColin Finck IUnknown_Release(unk); 2690*c2c66affSColin Finck if(FAILED(hres)) 2691*c2c66affSColin Finck return; 2692*c2c66affSColin Finck 2693*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); 2694*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 2695*c2c66affSColin Finck 2696*c2c66affSColin Finck if(SUCCEEDED(hres)) { 2697*c2c66affSColin Finck if(file_protocol_start(protocol, url, NULL, NULL, TRUE)) { 2698*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, 2, &cb); 2699*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 2700*c2c66affSColin Finck ok(cb == 2, "cb=%u expected 2\n", cb); 2701*c2c66affSColin Finck buf[2] = 0; 2702*c2c66affSColin Finck ok(!memcmp(buf, file_with_hash ? "XX" : "<H", 2), "Unexpected data %s\n", buf); 2703*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); 2704*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x\n", hres); 2705*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); 2706*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres); 2707*c2c66affSColin Finck ok(cb == 0, "cb=%u expected 0\n", cb); 2708*c2c66affSColin Finck hres = IInternetProtocol_UnlockRequest(protocol); 2709*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 2710*c2c66affSColin Finck } 2711*c2c66affSColin Finck 2712*c2c66affSColin Finck if(file_protocol_start(protocol, url, NULL, NULL, FALSE)) { 2713*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, 2, &cb); 2714*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x\n", hres); 2715*c2c66affSColin Finck hres = IInternetProtocol_LockRequest(protocol, 0); 2716*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 2717*c2c66affSColin Finck hres = IInternetProtocol_UnlockRequest(protocol); 2718*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 2719*c2c66affSColin Finck } 2720*c2c66affSColin Finck 2721*c2c66affSColin Finck IInternetProtocol_Release(protocol); 2722*c2c66affSColin Finck } 2723*c2c66affSColin Finck 2724*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); 2725*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 2726*c2c66affSColin Finck if(SUCCEEDED(hres)) { 2727*c2c66affSColin Finck if(file_protocol_start(protocol, url, NULL, NULL, TRUE)) { 2728*c2c66affSColin Finck hres = IInternetProtocol_LockRequest(protocol, 0); 2729*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 2730*c2c66affSColin Finck hres = IInternetProtocol_Terminate(protocol, 0); 2731*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 2732*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, 2, &cb); 2733*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n\n", hres); 2734*c2c66affSColin Finck hres = IInternetProtocol_UnlockRequest(protocol); 2735*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 2736*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, 2, &cb); 2737*c2c66affSColin Finck todo_wine_if(file_with_hash) /* FIXME: An effect of UnlockRequest call? */ 2738*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 2739*c2c66affSColin Finck hres = IInternetProtocol_Terminate(protocol, 0); 2740*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 2741*c2c66affSColin Finck } 2742*c2c66affSColin Finck 2743*c2c66affSColin Finck IInternetProtocol_Release(protocol); 2744*c2c66affSColin Finck } 2745*c2c66affSColin Finck 2746*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); 2747*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 2748*c2c66affSColin Finck if(SUCCEEDED(hres)) { 2749*c2c66affSColin Finck if(file_protocol_start(protocol, url, NULL, NULL, TRUE)) { 2750*c2c66affSColin Finck hres = IInternetProtocol_Terminate(protocol, 0); 2751*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 2752*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, 2, &cb); 2753*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 2754*c2c66affSColin Finck ok(cb == 2, "cb=%u expected 2\n", cb); 2755*c2c66affSColin Finck } 2756*c2c66affSColin Finck 2757*c2c66affSColin Finck IInternetProtocol_Release(protocol); 2758*c2c66affSColin Finck } 2759*c2c66affSColin Finck 2760*c2c66affSColin Finck if(pCreateUri) { 2761*c2c66affSColin Finck IInternetProtocolEx *protocolex; 2762*c2c66affSColin Finck IUri *uri; 2763*c2c66affSColin Finck 2764*c2c66affSColin Finck hres = pCreateUri(url, Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri); 2765*c2c66affSColin Finck ok(hres == S_OK, "CreateUri failed: %08x\n", hres); 2766*c2c66affSColin Finck 2767*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocolEx, (void**)&protocolex); 2768*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocolEx: %08x\n", hres); 2769*c2c66affSColin Finck 2770*c2c66affSColin Finck if(file_protocol_start(NULL, NULL, protocolex, uri, TRUE)) { 2771*c2c66affSColin Finck hres = IInternetProtocolEx_Read(protocolex, buf, 2, &cb); 2772*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 2773*c2c66affSColin Finck hres = IInternetProtocolEx_LockRequest(protocolex, 0); 2774*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 2775*c2c66affSColin Finck hres = IInternetProtocolEx_UnlockRequest(protocolex); 2776*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 2777*c2c66affSColin Finck } 2778*c2c66affSColin Finck 2779*c2c66affSColin Finck IUri_Release(uri); 2780*c2c66affSColin Finck IInternetProtocolEx_Release(protocolex); 2781*c2c66affSColin Finck 2782*c2c66affSColin Finck hres = pCreateUri(url, 0, 0, &uri); 2783*c2c66affSColin Finck ok(hres == S_OK, "CreateUri failed: %08x\n", hres); 2784*c2c66affSColin Finck 2785*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocolEx, (void**)&protocolex); 2786*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocolEx: %08x\n", hres); 2787*c2c66affSColin Finck 2788*c2c66affSColin Finck if(file_protocol_start(NULL, NULL, protocolex, uri, TRUE)) { 2789*c2c66affSColin Finck hres = IInternetProtocolEx_Read(protocolex, buf, 2, &cb); 2790*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 2791*c2c66affSColin Finck hres = IInternetProtocolEx_LockRequest(protocolex, 0); 2792*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 2793*c2c66affSColin Finck hres = IInternetProtocolEx_UnlockRequest(protocolex); 2794*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 2795*c2c66affSColin Finck } 2796*c2c66affSColin Finck 2797*c2c66affSColin Finck IUri_Release(uri); 2798*c2c66affSColin Finck IInternetProtocolEx_Release(protocolex); 2799*c2c66affSColin Finck }else { 2800*c2c66affSColin Finck win_skip("Skipping file protocol StartEx tests\n"); 2801*c2c66affSColin Finck } 2802*c2c66affSColin Finck 2803*c2c66affSColin Finck IClassFactory_Release(factory); 2804*c2c66affSColin Finck } 2805*c2c66affSColin Finck 2806*c2c66affSColin Finck static void test_file_protocol_fail(void) 2807*c2c66affSColin Finck { 2808*c2c66affSColin Finck IInternetProtocol *protocol; 2809*c2c66affSColin Finck HRESULT hres; 2810*c2c66affSColin Finck 2811*c2c66affSColin Finck static const WCHAR index_url2[] = 2812*c2c66affSColin Finck {'f','i','l','e',':','/','/','i','n','d','e','x','.','h','t','m','l',0}; 2813*c2c66affSColin Finck 2814*c2c66affSColin Finck hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, 2815*c2c66affSColin Finck &IID_IInternetProtocol, (void**)&protocol); 2816*c2c66affSColin Finck ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); 2817*c2c66affSColin Finck if(FAILED(hres)) 2818*c2c66affSColin Finck return; 2819*c2c66affSColin Finck 2820*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2821*c2c66affSColin Finck expect_hrResult = MK_E_SYNTAX; 2822*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, wszIndexHtml, &protocol_sink, &bind_info, 0, 0); 2823*c2c66affSColin Finck ok(hres == MK_E_SYNTAX || 2824*c2c66affSColin Finck hres == E_INVALIDARG, 2825*c2c66affSColin Finck "Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres); 2826*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */ 2827*c2c66affSColin Finck 2828*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2829*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) 2830*c2c66affSColin Finck SET_EXPECT(ReportProgress_DIRECTBIND); 2831*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 2832*c2c66affSColin Finck SET_EXPECT(ReportResult); 2833*c2c66affSColin Finck expect_hrResult = INET_E_RESOURCE_NOT_FOUND; 2834*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, index_url, &protocol_sink, &bind_info, 0, 0); 2835*c2c66affSColin Finck ok(hres == INET_E_RESOURCE_NOT_FOUND, 2836*c2c66affSColin Finck "Start failed: %08x expected INET_E_RESOURCE_NOT_FOUND\n", hres); 2837*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 2838*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) 2839*c2c66affSColin Finck CHECK_CALLED(ReportProgress_DIRECTBIND); 2840*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 2841*c2c66affSColin Finck CHECK_CALLED(ReportResult); 2842*c2c66affSColin Finck 2843*c2c66affSColin Finck IInternetProtocol_Release(protocol); 2844*c2c66affSColin Finck 2845*c2c66affSColin Finck hres = CoCreateInstance(&CLSID_FileProtocol, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, 2846*c2c66affSColin Finck &IID_IInternetProtocol, (void**)&protocol); 2847*c2c66affSColin Finck ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); 2848*c2c66affSColin Finck if(FAILED(hres)) 2849*c2c66affSColin Finck return; 2850*c2c66affSColin Finck 2851*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2852*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) 2853*c2c66affSColin Finck SET_EXPECT(ReportProgress_DIRECTBIND); 2854*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 2855*c2c66affSColin Finck SET_EXPECT(ReportResult); 2856*c2c66affSColin Finck expect_hrResult = INET_E_RESOURCE_NOT_FOUND; 2857*c2c66affSColin Finck 2858*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, index_url2, &protocol_sink, &bind_info, 0, 0); 2859*c2c66affSColin Finck ok(hres == INET_E_RESOURCE_NOT_FOUND, 2860*c2c66affSColin Finck "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres); 2861*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 2862*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) 2863*c2c66affSColin Finck CHECK_CALLED(ReportProgress_DIRECTBIND); 2864*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 2865*c2c66affSColin Finck CHECK_CALLED(ReportResult); 2866*c2c66affSColin Finck 2867*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2868*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0); 2869*c2c66affSColin Finck ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres); 2870*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */ 2871*c2c66affSColin Finck 2872*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 2873*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, emptyW, &protocol_sink, &bind_info, 0, 0); 2874*c2c66affSColin Finck ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres); 2875*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */ 2876*c2c66affSColin Finck 2877*c2c66affSColin Finck IInternetProtocol_Release(protocol); 2878*c2c66affSColin Finck } 2879*c2c66affSColin Finck 2880*c2c66affSColin Finck static void test_file_protocol(void) { 2881*c2c66affSColin Finck WCHAR buf[INTERNET_MAX_URL_LENGTH], file_name_buf[MAX_PATH]; 2882*c2c66affSColin Finck DWORD size; 2883*c2c66affSColin Finck ULONG len; 2884*c2c66affSColin Finck HANDLE file; 2885*c2c66affSColin Finck 2886*c2c66affSColin Finck static const WCHAR wszFile[] = {'f','i','l','e',':',0}; 2887*c2c66affSColin Finck static const WCHAR wszFile2[] = {'f','i','l','e',':','/','/',0}; 2888*c2c66affSColin Finck static const WCHAR wszFile3[] = {'f','i','l','e',':','/','/','/',0}; 2889*c2c66affSColin Finck static const WCHAR wszFile4[] = {'f','i','l','e',':','\\','\\',0}; 2890*c2c66affSColin Finck static const char html_doc[] = "<HTML></HTML>"; 2891*c2c66affSColin Finck static const WCHAR fragmentW[] = {'#','f','r','a','g',0}; 2892*c2c66affSColin Finck 2893*c2c66affSColin Finck trace("Testing file protocol...\n"); 2894*c2c66affSColin Finck init_test(FILE_TEST, 0); 2895*c2c66affSColin Finck 2896*c2c66affSColin Finck SetLastError(0xdeadbeef); 2897*c2c66affSColin Finck file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 2898*c2c66affSColin Finck FILE_ATTRIBUTE_NORMAL, NULL); 2899*c2c66affSColin Finck ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); 2900*c2c66affSColin Finck if(file == INVALID_HANDLE_VALUE) 2901*c2c66affSColin Finck return; 2902*c2c66affSColin Finck WriteFile(file, html_doc, sizeof(html_doc)-1, &size, NULL); 2903*c2c66affSColin Finck CloseHandle(file); 2904*c2c66affSColin Finck 2905*c2c66affSColin Finck file_name = wszIndexHtml; 2906*c2c66affSColin Finck bindf = 0; 2907*c2c66affSColin Finck test_file_protocol_url(index_url); 2908*c2c66affSColin Finck bindf = BINDF_FROMURLMON; 2909*c2c66affSColin Finck test_file_protocol_url(index_url); 2910*c2c66affSColin Finck bindf = BINDF_FROMURLMON | BINDF_NEEDFILE; 2911*c2c66affSColin Finck test_file_protocol_url(index_url); 2912*c2c66affSColin Finck 2913*c2c66affSColin Finck memcpy(buf, wszFile, sizeof(wszFile)); 2914*c2c66affSColin Finck len = sizeof(wszFile)/sizeof(WCHAR)-1; 2915*c2c66affSColin Finck len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len); 2916*c2c66affSColin Finck buf[len++] = '\\'; 2917*c2c66affSColin Finck memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml)); 2918*c2c66affSColin Finck 2919*c2c66affSColin Finck file_name = buf + sizeof(wszFile)/sizeof(WCHAR)-1; 2920*c2c66affSColin Finck bindf = 0; 2921*c2c66affSColin Finck test_file_protocol_url(buf); 2922*c2c66affSColin Finck bindf = BINDF_FROMURLMON; 2923*c2c66affSColin Finck test_file_protocol_url(buf); 2924*c2c66affSColin Finck 2925*c2c66affSColin Finck memcpy(buf, wszFile2, sizeof(wszFile2)); 2926*c2c66affSColin Finck len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf); 2927*c2c66affSColin Finck file_name_buf[len++] = '\\'; 2928*c2c66affSColin Finck memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml)); 2929*c2c66affSColin Finck lstrcpyW(buf+sizeof(wszFile2)/sizeof(WCHAR)-1, file_name_buf); 2930*c2c66affSColin Finck file_name = file_name_buf; 2931*c2c66affSColin Finck bindf = 0; 2932*c2c66affSColin Finck test_file_protocol_url(buf); 2933*c2c66affSColin Finck bindf = BINDF_FROMURLMON; 2934*c2c66affSColin Finck test_file_protocol_url(buf); 2935*c2c66affSColin Finck 2936*c2c66affSColin Finck buf[sizeof(wszFile2)/sizeof(WCHAR)] = '|'; 2937*c2c66affSColin Finck test_file_protocol_url(buf); 2938*c2c66affSColin Finck 2939*c2c66affSColin Finck memcpy(buf, wszFile3, sizeof(wszFile3)); 2940*c2c66affSColin Finck len = sizeof(wszFile3)/sizeof(WCHAR)-1; 2941*c2c66affSColin Finck len += GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR)-len, buf+len); 2942*c2c66affSColin Finck buf[len++] = '\\'; 2943*c2c66affSColin Finck memcpy(buf+len, wszIndexHtml, sizeof(wszIndexHtml)); 2944*c2c66affSColin Finck 2945*c2c66affSColin Finck file_name = buf + sizeof(wszFile3)/sizeof(WCHAR)-1; 2946*c2c66affSColin Finck bindf = 0; 2947*c2c66affSColin Finck test_file_protocol_url(buf); 2948*c2c66affSColin Finck bindf = BINDF_FROMURLMON; 2949*c2c66affSColin Finck test_file_protocol_url(buf); 2950*c2c66affSColin Finck 2951*c2c66affSColin Finck memcpy(buf, wszFile4, sizeof(wszFile4)); 2952*c2c66affSColin Finck len = GetCurrentDirectoryW(sizeof(file_name_buf)/sizeof(WCHAR), file_name_buf); 2953*c2c66affSColin Finck file_name_buf[len++] = '\\'; 2954*c2c66affSColin Finck memcpy(file_name_buf+len, wszIndexHtml, sizeof(wszIndexHtml)); 2955*c2c66affSColin Finck lstrcpyW(buf+sizeof(wszFile4)/sizeof(WCHAR)-1, file_name_buf); 2956*c2c66affSColin Finck file_name = file_name_buf; 2957*c2c66affSColin Finck bindf = 0; 2958*c2c66affSColin Finck test_file_protocol_url(buf); 2959*c2c66affSColin Finck bindf = BINDF_FROMURLMON; 2960*c2c66affSColin Finck test_file_protocol_url(buf); 2961*c2c66affSColin Finck 2962*c2c66affSColin Finck buf[sizeof(wszFile4)/sizeof(WCHAR)] = '|'; 2963*c2c66affSColin Finck test_file_protocol_url(buf); 2964*c2c66affSColin Finck 2965*c2c66affSColin Finck /* Fragment part of URL is skipped if the file doesn't exist. */ 2966*c2c66affSColin Finck lstrcatW(buf, fragmentW); 2967*c2c66affSColin Finck test_file_protocol_url(buf); 2968*c2c66affSColin Finck 2969*c2c66affSColin Finck /* Fragment part is considered a part of the file name, if the file exsists. */ 2970*c2c66affSColin Finck len = lstrlenW(file_name_buf); 2971*c2c66affSColin Finck lstrcpyW(file_name_buf+len, fragmentW); 2972*c2c66affSColin Finck file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 2973*c2c66affSColin Finck FILE_ATTRIBUTE_NORMAL, NULL); 2974*c2c66affSColin Finck ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); 2975*c2c66affSColin Finck WriteFile(file, "XXX", 3, &size, NULL); 2976*c2c66affSColin Finck CloseHandle(file); 2977*c2c66affSColin Finck file_name_buf[len] = 0; 2978*c2c66affSColin Finck 2979*c2c66affSColin Finck file_with_hash = TRUE; 2980*c2c66affSColin Finck test_file_protocol_url(buf); 2981*c2c66affSColin Finck 2982*c2c66affSColin Finck DeleteFileW(wszIndexHtml); 2983*c2c66affSColin Finck DeleteFileW(file_name_buf); 2984*c2c66affSColin Finck 2985*c2c66affSColin Finck bindf = 0; 2986*c2c66affSColin Finck test_file_protocol_fail(); 2987*c2c66affSColin Finck bindf = BINDF_FROMURLMON; 2988*c2c66affSColin Finck test_file_protocol_fail(); 2989*c2c66affSColin Finck } 2990*c2c66affSColin Finck 2991*c2c66affSColin Finck static void create_cache_entry(const WCHAR *urlw) 2992*c2c66affSColin Finck { 2993*c2c66affSColin Finck FILETIME now, tomorrow, yesterday; 2994*c2c66affSColin Finck char file_path[MAX_PATH]; 2995*c2c66affSColin Finck BYTE content[1000]; 2996*c2c66affSColin Finck ULARGE_INTEGER li; 2997*c2c66affSColin Finck const char *url; 2998*c2c66affSColin Finck HANDLE file; 2999*c2c66affSColin Finck DWORD size; 3000*c2c66affSColin Finck unsigned i; 3001*c2c66affSColin Finck BOOL res; 3002*c2c66affSColin Finck 3003*c2c66affSColin Finck BYTE cache_headers[] = "HTTP/1.1 200 OK\r\n\r\n"; 3004*c2c66affSColin Finck 3005*c2c66affSColin Finck trace("Testing cache read...\n"); 3006*c2c66affSColin Finck 3007*c2c66affSColin Finck url = w2a(urlw); 3008*c2c66affSColin Finck 3009*c2c66affSColin Finck for(i = 0; i < sizeof(content); i++) 3010*c2c66affSColin Finck content[i] = '0' + (i%10); 3011*c2c66affSColin Finck 3012*c2c66affSColin Finck GetSystemTimeAsFileTime(&now); 3013*c2c66affSColin Finck li.u.HighPart = now.dwHighDateTime; 3014*c2c66affSColin Finck li.u.LowPart = now.dwLowDateTime; 3015*c2c66affSColin Finck li.QuadPart += (LONGLONG)10000000 * 3600 * 24; 3016*c2c66affSColin Finck tomorrow.dwHighDateTime = li.u.HighPart; 3017*c2c66affSColin Finck tomorrow.dwLowDateTime = li.u.LowPart; 3018*c2c66affSColin Finck li.QuadPart -= (LONGLONG)10000000 * 3600 * 24 * 2; 3019*c2c66affSColin Finck yesterday.dwHighDateTime = li.u.HighPart; 3020*c2c66affSColin Finck yesterday.dwLowDateTime = li.u.LowPart; 3021*c2c66affSColin Finck 3022*c2c66affSColin Finck res = CreateUrlCacheEntryA(url, sizeof(content), "", file_path, 0); 3023*c2c66affSColin Finck ok(res, "CreateUrlCacheEntryA failed: %u\n", GetLastError()); 3024*c2c66affSColin Finck 3025*c2c66affSColin Finck file = CreateFileA(file_path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 3026*c2c66affSColin Finck ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); 3027*c2c66affSColin Finck 3028*c2c66affSColin Finck WriteFile(file, content, sizeof(content), &size, NULL); 3029*c2c66affSColin Finck CloseHandle(file); 3030*c2c66affSColin Finck 3031*c2c66affSColin Finck res = CommitUrlCacheEntryA(url, file_path, tomorrow, yesterday, NORMAL_CACHE_ENTRY, 3032*c2c66affSColin Finck cache_headers, sizeof(cache_headers)-1, "", 0); 3033*c2c66affSColin Finck ok(res, "CommitUrlCacheEntryA failed: %u\n", GetLastError()); 3034*c2c66affSColin Finck } 3035*c2c66affSColin Finck 3036*c2c66affSColin Finck static BOOL http_protocol_start(LPCWSTR url, BOOL use_iuri) 3037*c2c66affSColin Finck { 3038*c2c66affSColin Finck static BOOL got_user_agent = FALSE; 3039*c2c66affSColin Finck IUri *uri = NULL; 3040*c2c66affSColin Finck HRESULT hres; 3041*c2c66affSColin Finck 3042*c2c66affSColin Finck if(use_iuri && pCreateUri) { 3043*c2c66affSColin Finck hres = pCreateUri(url, 0, 0, &uri); 3044*c2c66affSColin Finck ok(hres == S_OK, "CreateUri failed: %08x\n", hres); 3045*c2c66affSColin Finck } 3046*c2c66affSColin Finck 3047*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 3048*c2c66affSColin Finck if (!(bindf & BINDF_FROMURLMON)) 3049*c2c66affSColin Finck SET_EXPECT(ReportProgress_DIRECTBIND); 3050*c2c66affSColin Finck if(!got_user_agent) 3051*c2c66affSColin Finck SET_EXPECT(GetBindString_USER_AGENT); 3052*c2c66affSColin Finck SET_EXPECT(GetBindString_ROOTDOC_URL); 3053*c2c66affSColin Finck SET_EXPECT(GetBindString_ACCEPT_MIMES); 3054*c2c66affSColin Finck SET_EXPECT(QueryService_HttpNegotiate); 3055*c2c66affSColin Finck SET_EXPECT(BeginningTransaction); 3056*c2c66affSColin Finck SET_EXPECT(GetRootSecurityId); 3057*c2c66affSColin Finck if(http_post_test) { 3058*c2c66affSColin Finck SET_EXPECT(GetBindString_POST_COOKIE); 3059*c2c66affSColin Finck if(http_post_test == TYMED_ISTREAM) 3060*c2c66affSColin Finck SET_EXPECT(Stream_Seek); 3061*c2c66affSColin Finck } 3062*c2c66affSColin Finck if(bind_from_cache) { 3063*c2c66affSColin Finck SET_EXPECT(OnResponse); 3064*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 3065*c2c66affSColin Finck SET_EXPECT(ReportData); 3066*c2c66affSColin Finck } 3067*c2c66affSColin Finck 3068*c2c66affSColin Finck if(uri) { 3069*c2c66affSColin Finck IInternetProtocolEx *protocolex; 3070*c2c66affSColin Finck 3071*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(async_protocol, &IID_IInternetProtocolEx, (void**)&protocolex); 3072*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocolEx iface: %08x\n", hres); 3073*c2c66affSColin Finck 3074*c2c66affSColin Finck hres = IInternetProtocolEx_StartEx(protocolex, uri, &protocol_sink, &bind_info, 0, 0); 3075*c2c66affSColin Finck ok(hres == S_OK, "Start failed: %08x\n", hres); 3076*c2c66affSColin Finck 3077*c2c66affSColin Finck IInternetProtocolEx_Release(protocolex); 3078*c2c66affSColin Finck IUri_Release(uri); 3079*c2c66affSColin Finck }else { 3080*c2c66affSColin Finck hres = IInternetProtocol_Start(async_protocol, url, &protocol_sink, &bind_info, 0, 0); 3081*c2c66affSColin Finck ok(hres == S_OK, "Start failed: %08x\n", hres); 3082*c2c66affSColin Finck } 3083*c2c66affSColin Finck if(FAILED(hres)) 3084*c2c66affSColin Finck return FALSE; 3085*c2c66affSColin Finck 3086*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 3087*c2c66affSColin Finck if (!(bindf & BINDF_FROMURLMON)) 3088*c2c66affSColin Finck CHECK_CALLED(ReportProgress_DIRECTBIND); 3089*c2c66affSColin Finck if (!got_user_agent) 3090*c2c66affSColin Finck { 3091*c2c66affSColin Finck CHECK_CALLED(GetBindString_USER_AGENT); 3092*c2c66affSColin Finck got_user_agent = TRUE; 3093*c2c66affSColin Finck } 3094*c2c66affSColin Finck CLEAR_CALLED(GetBindString_ROOTDOC_URL); /* New in IE11 */ 3095*c2c66affSColin Finck CHECK_CALLED(GetBindString_ACCEPT_MIMES); 3096*c2c66affSColin Finck CHECK_CALLED(QueryService_HttpNegotiate); 3097*c2c66affSColin Finck CHECK_CALLED(BeginningTransaction); 3098*c2c66affSColin Finck /* GetRootSecurityId called on WinXP but not on Win98 */ 3099*c2c66affSColin Finck CLEAR_CALLED(GetRootSecurityId); 3100*c2c66affSColin Finck if(http_post_test) { 3101*c2c66affSColin Finck CHECK_CALLED(GetBindString_POST_COOKIE); 3102*c2c66affSColin Finck if(http_post_test == TYMED_ISTREAM) 3103*c2c66affSColin Finck CHECK_CALLED(Stream_Seek); 3104*c2c66affSColin Finck } 3105*c2c66affSColin Finck if(bind_from_cache) { 3106*c2c66affSColin Finck CHECK_CALLED(OnResponse); 3107*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 3108*c2c66affSColin Finck CHECK_CALLED(ReportData); 3109*c2c66affSColin Finck } 3110*c2c66affSColin Finck 3111*c2c66affSColin Finck return TRUE; 3112*c2c66affSColin Finck } 3113*c2c66affSColin Finck 3114*c2c66affSColin Finck static void test_protocol_terminate(IInternetProtocol *protocol) 3115*c2c66affSColin Finck { 3116*c2c66affSColin Finck BYTE buf[3600]; 3117*c2c66affSColin Finck DWORD cb; 3118*c2c66affSColin Finck HRESULT hres; 3119*c2c66affSColin Finck 3120*c2c66affSColin Finck hres = IInternetProtocol_LockRequest(protocol, 0); 3121*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 3122*c2c66affSColin Finck 3123*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, buf, 1, &cb); 3124*c2c66affSColin Finck ok(hres == (test_abort ? S_OK : S_FALSE), "Read failed: %08x\n", hres); 3125*c2c66affSColin Finck 3126*c2c66affSColin Finck hres = IInternetProtocol_Terminate(protocol, 0); 3127*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 3128*c2c66affSColin Finck 3129*c2c66affSColin Finck /* This wait is to give the internet handles being freed in Terminate 3130*c2c66affSColin Finck * enough time to actually terminate in all cases. Internet handles 3131*c2c66affSColin Finck * terminate asynchronously and native reuses the main InternetOpen 3132*c2c66affSColin Finck * handle. The only case in which this seems to be necessary is on 3133*c2c66affSColin Finck * wine with native wininet and urlmon, resulting in the next time 3134*c2c66affSColin Finck * test_http_protocol_url being called the first data notification actually 3135*c2c66affSColin Finck * being an extra last data notification from the previous connection 3136*c2c66affSColin Finck * about once out of every ten times. */ 3137*c2c66affSColin Finck Sleep(100); 3138*c2c66affSColin Finck 3139*c2c66affSColin Finck hres = IInternetProtocol_UnlockRequest(protocol); 3140*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 3141*c2c66affSColin Finck } 3142*c2c66affSColin Finck 3143*c2c66affSColin Finck static void test_http_info(IInternetProtocol *protocol) 3144*c2c66affSColin Finck { 3145*c2c66affSColin Finck IWinInetHttpInfo *info; 3146*c2c66affSColin Finck HRESULT hres; 3147*c2c66affSColin Finck 3148*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetHttpInfo, (void**)&info); 3149*c2c66affSColin Finck ok(hres == S_OK, "Could not get IWinInterHttpInfo iface: %08x\n", hres); 3150*c2c66affSColin Finck 3151*c2c66affSColin Finck /* TODO */ 3152*c2c66affSColin Finck 3153*c2c66affSColin Finck IWinInetHttpInfo_Release(info); 3154*c2c66affSColin Finck } 3155*c2c66affSColin Finck 3156*c2c66affSColin Finck /* is_first refers to whether this is the first call to this function 3157*c2c66affSColin Finck * _for this url_ */ 3158*c2c66affSColin Finck static void test_http_protocol_url(LPCWSTR url, int prot, DWORD flags, DWORD tymed) 3159*c2c66affSColin Finck { 3160*c2c66affSColin Finck IInternetProtocolInfo *protocol_info; 3161*c2c66affSColin Finck IClassFactory *factory; 3162*c2c66affSColin Finck IUnknown *unk; 3163*c2c66affSColin Finck HRESULT hres; 3164*c2c66affSColin Finck 3165*c2c66affSColin Finck init_test(prot, flags); 3166*c2c66affSColin Finck http_url = url; 3167*c2c66affSColin Finck http_post_test = tymed; 3168*c2c66affSColin Finck if(flags & TEST_FROMCACHE) 3169*c2c66affSColin Finck create_cache_entry(url); 3170*c2c66affSColin Finck 3171*c2c66affSColin Finck hres = CoGetClassObject(prot == HTTPS_TEST ? &CLSID_HttpSProtocol : &CLSID_HttpProtocol, 3172*c2c66affSColin Finck CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk); 3173*c2c66affSColin Finck ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres); 3174*c2c66affSColin Finck if(FAILED(hres)) 3175*c2c66affSColin Finck return; 3176*c2c66affSColin Finck 3177*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); 3178*c2c66affSColin Finck ok(hres == E_NOINTERFACE, 3179*c2c66affSColin Finck "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", 3180*c2c66affSColin Finck hres); 3181*c2c66affSColin Finck 3182*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); 3183*c2c66affSColin Finck ok(hres == S_OK, "Could not get IClassFactory interface\n"); 3184*c2c66affSColin Finck IUnknown_Release(unk); 3185*c2c66affSColin Finck if(FAILED(hres)) 3186*c2c66affSColin Finck return; 3187*c2c66affSColin Finck 3188*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, 3189*c2c66affSColin Finck (void**)&async_protocol); 3190*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 3191*c2c66affSColin Finck if(SUCCEEDED(hres)) { 3192*c2c66affSColin Finck BYTE buf[3600]; 3193*c2c66affSColin Finck DWORD cb; 3194*c2c66affSColin Finck ULONG ref; 3195*c2c66affSColin Finck 3196*c2c66affSColin Finck test_priority(async_protocol); 3197*c2c66affSColin Finck test_http_info(async_protocol); 3198*c2c66affSColin Finck 3199*c2c66affSColin Finck SET_EXPECT(ReportProgress_COOKIE_SENT); 3200*c2c66affSColin Finck if(http_is_first) { 3201*c2c66affSColin Finck SET_EXPECT(ReportProgress_FINDINGRESOURCE); 3202*c2c66affSColin Finck SET_EXPECT(ReportProgress_CONNECTING); 3203*c2c66affSColin Finck } 3204*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 3205*c2c66affSColin Finck if(test_redirect && !(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)) 3206*c2c66affSColin Finck SET_EXPECT(ReportProgress_REDIRECTING); 3207*c2c66affSColin Finck SET_EXPECT(ReportProgress_PROXYDETECTING); 3208*c2c66affSColin Finck if(prot == HTTP_TEST) 3209*c2c66affSColin Finck SET_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE); 3210*c2c66affSColin Finck else 3211*c2c66affSColin Finck SET_EXPECT(QueryService_HttpSecurity); 3212*c2c66affSColin Finck if(!(bindf & BINDF_FROMURLMON)) { 3213*c2c66affSColin Finck SET_EXPECT(OnResponse); 3214*c2c66affSColin Finck SET_EXPECT(ReportProgress_RAWMIMETYPE); 3215*c2c66affSColin Finck SET_EXPECT(ReportData); 3216*c2c66affSColin Finck } else { 3217*c2c66affSColin Finck SET_EXPECT(Switch); 3218*c2c66affSColin Finck } 3219*c2c66affSColin Finck 3220*c2c66affSColin Finck if(!http_protocol_start(url, (flags & TEST_USEIURI) != 0)) { 3221*c2c66affSColin Finck IInternetProtocol_Abort(async_protocol, E_ABORT, 0); 3222*c2c66affSColin Finck IInternetProtocol_Release(async_protocol); 3223*c2c66affSColin Finck return; 3224*c2c66affSColin Finck } 3225*c2c66affSColin Finck 3226*c2c66affSColin Finck if(!direct_read && !test_abort && !bind_from_cache) 3227*c2c66affSColin Finck SET_EXPECT(ReportResult); 3228*c2c66affSColin Finck 3229*c2c66affSColin Finck if(flags & TEST_DISABLEAUTOREDIRECT) 3230*c2c66affSColin Finck expect_hrResult = INET_E_REDIRECT_FAILED; 3231*c2c66affSColin Finck else if(test_abort) 3232*c2c66affSColin Finck expect_hrResult = E_ABORT; 3233*c2c66affSColin Finck else 3234*c2c66affSColin Finck expect_hrResult = S_OK; 3235*c2c66affSColin Finck 3236*c2c66affSColin Finck if(direct_read) { 3237*c2c66affSColin Finck SET_EXPECT(Switch); 3238*c2c66affSColin Finck while(wait_for_switch) { 3239*c2c66affSColin Finck ok( WaitForSingleObject(event_continue, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3240*c2c66affSColin Finck CHECK_CALLED(Switch); /* Set in ReportData */ 3241*c2c66affSColin Finck call_continue(&continue_protdata); 3242*c2c66affSColin Finck SetEvent(event_continue_done); 3243*c2c66affSColin Finck } 3244*c2c66affSColin Finck }else if(bind_from_cache) { 3245*c2c66affSColin Finck BYTE buf[1500]; 3246*c2c66affSColin Finck 3247*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, 100, &cb); 3248*c2c66affSColin Finck ok(hres == S_OK && cb == 100, "Read failed: %08x (%d bytes)\n", hres, cb); 3249*c2c66affSColin Finck 3250*c2c66affSColin Finck SET_EXPECT(ReportResult); 3251*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb); 3252*c2c66affSColin Finck ok(hres == S_OK && cb == 900, "Read failed: %08x (%d bytes)\n", hres, cb); 3253*c2c66affSColin Finck CHECK_CALLED(ReportResult); 3254*c2c66affSColin Finck 3255*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb); 3256*c2c66affSColin Finck ok(hres == S_FALSE && !cb, "Read failed: %08x (%d bytes)\n", hres, cb); 3257*c2c66affSColin Finck }else { 3258*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb); 3259*c2c66affSColin Finck ok((hres == E_PENDING && cb==0) || 3260*c2c66affSColin Finck (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb); 3261*c2c66affSColin Finck 3262*c2c66affSColin Finck ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3263*c2c66affSColin Finck if(bindf & BINDF_FROMURLMON) 3264*c2c66affSColin Finck CHECK_CALLED(Switch); 3265*c2c66affSColin Finck else 3266*c2c66affSColin Finck CHECK_CALLED(ReportData); 3267*c2c66affSColin Finck if(prot == HTTPS_TEST) 3268*c2c66affSColin Finck CLEAR_CALLED(QueryService_HttpSecurity); 3269*c2c66affSColin Finck 3270*c2c66affSColin Finck while(1) { 3271*c2c66affSColin Finck if(bindf & BINDF_FROMURLMON) 3272*c2c66affSColin Finck SET_EXPECT(Switch); 3273*c2c66affSColin Finck else 3274*c2c66affSColin Finck SET_EXPECT(ReportData); 3275*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb); 3276*c2c66affSColin Finck if(hres == E_PENDING) { 3277*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb); 3278*c2c66affSColin Finck ok((hres == E_PENDING && cb==0) || 3279*c2c66affSColin Finck (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb); 3280*c2c66affSColin Finck ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3281*c2c66affSColin Finck if(bindf & BINDF_FROMURLMON) 3282*c2c66affSColin Finck CHECK_CALLED(Switch); 3283*c2c66affSColin Finck else 3284*c2c66affSColin Finck CHECK_CALLED(ReportData); 3285*c2c66affSColin Finck 3286*c2c66affSColin Finck if(test_abort) { 3287*c2c66affSColin Finck HRESULT hres; 3288*c2c66affSColin Finck 3289*c2c66affSColin Finck SET_EXPECT(ReportResult); 3290*c2c66affSColin Finck hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0); 3291*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 3292*c2c66affSColin Finck CHECK_CALLED(ReportResult); 3293*c2c66affSColin Finck 3294*c2c66affSColin Finck hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0); 3295*c2c66affSColin Finck ok(hres == INET_E_RESULT_DISPATCHED || hres == S_OK /* IE10 */, "Abort failed: %08x\n", hres); 3296*c2c66affSColin Finck break; 3297*c2c66affSColin Finck } 3298*c2c66affSColin Finck }else { 3299*c2c66affSColin Finck if(bindf & BINDF_FROMURLMON) 3300*c2c66affSColin Finck CHECK_NOT_CALLED(Switch); 3301*c2c66affSColin Finck else 3302*c2c66affSColin Finck CHECK_NOT_CALLED(ReportData); 3303*c2c66affSColin Finck if(cb == 0) break; 3304*c2c66affSColin Finck } 3305*c2c66affSColin Finck } 3306*c2c66affSColin Finck if(!test_abort) { 3307*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x\n", hres); 3308*c2c66affSColin Finck CHECK_CALLED(ReportResult); 3309*c2c66affSColin Finck } 3310*c2c66affSColin Finck } 3311*c2c66affSColin Finck if(prot == HTTPS_TEST) 3312*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_SENDINGREQUEST); 3313*c2c66affSColin Finck 3314*c2c66affSColin Finck if (prot == HTTP_TEST || prot == HTTPS_TEST) 3315*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_COOKIE_SENT); 3316*c2c66affSColin Finck 3317*c2c66affSColin Finck hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0); 3318*c2c66affSColin Finck ok(hres == INET_E_RESULT_DISPATCHED || hres == S_OK /* IE10 */, "Abort failed: %08x\n", hres); 3319*c2c66affSColin Finck 3320*c2c66affSColin Finck test_protocol_terminate(async_protocol); 3321*c2c66affSColin Finck 3322*c2c66affSColin Finck hres = IInternetProtocol_Abort(async_protocol, E_ABORT, 0); 3323*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 3324*c2c66affSColin Finck 3325*c2c66affSColin Finck ref = IInternetProtocol_Release(async_protocol); 3326*c2c66affSColin Finck ok(!ref, "ref=%x\n", ref); 3327*c2c66affSColin Finck } 3328*c2c66affSColin Finck 3329*c2c66affSColin Finck IClassFactory_Release(factory); 3330*c2c66affSColin Finck 3331*c2c66affSColin Finck if(flags & TEST_FROMCACHE) { 3332*c2c66affSColin Finck BOOL res; 3333*c2c66affSColin Finck 3334*c2c66affSColin Finck res = DeleteUrlCacheEntryW(url); 3335*c2c66affSColin Finck ok(res, "DeleteUrlCacheEntryA failed: %u\n", GetLastError()); 3336*c2c66affSColin Finck } 3337*c2c66affSColin Finck } 3338*c2c66affSColin Finck 3339*c2c66affSColin Finck static void test_http_protocol(void) 3340*c2c66affSColin Finck { 3341*c2c66affSColin Finck static const WCHAR posttest_url[] = 3342*c2c66affSColin Finck {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 3343*c2c66affSColin Finck 't','e','s','t','s','/','p','o','s','t','.','p','h','p',0}; 3344*c2c66affSColin Finck static const WCHAR redirect_url[] = 3345*c2c66affSColin Finck {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 3346*c2c66affSColin Finck 't','e','s','t','s','/','r','e','d','i','r','e','c','t',0}; 3347*c2c66affSColin Finck static const WCHAR winetest_url[] = 3348*c2c66affSColin Finck {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 3349*c2c66affSColin Finck 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0}; 3350*c2c66affSColin Finck static const WCHAR empty_url[] = 3351*c2c66affSColin Finck {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 3352*c2c66affSColin Finck 't','e','s','t','s','/','e','m','p','t','y','.','j','s',0}; 3353*c2c66affSColin Finck static const WCHAR cache_only_url[] = 3354*c2c66affSColin Finck {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 3355*c2c66affSColin Finck 't','e','s','t','s','/','c','a','c','h','e','-','o','n','l','y',0}; 3356*c2c66affSColin Finck 3357*c2c66affSColin Finck 3358*c2c66affSColin Finck trace("Testing http protocol (not from urlmon)...\n"); 3359*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; 3360*c2c66affSColin Finck test_http_protocol_url(winetest_url, HTTP_TEST, TEST_FIRST_HTTP, TYMED_NULL); 3361*c2c66affSColin Finck 3362*c2c66affSColin Finck trace("Testing http protocol (from urlmon)...\n"); 3363*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON; 3364*c2c66affSColin Finck test_http_protocol_url(winetest_url, HTTP_TEST, 0, TYMED_NULL); 3365*c2c66affSColin Finck 3366*c2c66affSColin Finck trace("Testing http protocol (to file)...\n"); 3367*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NEEDFILE; 3368*c2c66affSColin Finck test_http_protocol_url(winetest_url, HTTP_TEST, 0, TYMED_NULL); 3369*c2c66affSColin Finck 3370*c2c66affSColin Finck trace("Testing http protocol (post data)...\n"); 3371*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON; 3372*c2c66affSColin Finck test_http_protocol_url(posttest_url, HTTP_TEST, TEST_FIRST_HTTP|TEST_POST, TYMED_HGLOBAL); 3373*c2c66affSColin Finck 3374*c2c66affSColin Finck trace("Testing http protocol (post data stream)...\n"); 3375*c2c66affSColin Finck test_http_protocol_url(posttest_url, HTTP_TEST, TEST_FIRST_HTTP|TEST_POST|TEST_ASYNCREQ, TYMED_ISTREAM); 3376*c2c66affSColin Finck 3377*c2c66affSColin Finck trace("Testing http protocol (direct read)...\n"); 3378*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON; 3379*c2c66affSColin Finck test_http_protocol_url(winetest_url, HTTP_TEST, TEST_DIRECT_READ|TEST_USEIURI, TYMED_NULL); 3380*c2c66affSColin Finck 3381*c2c66affSColin Finck trace("Testing http protocol (redirected)...\n"); 3382*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE; 3383*c2c66affSColin Finck test_http_protocol_url(redirect_url, HTTP_TEST, TEST_REDIRECT, TYMED_NULL); 3384*c2c66affSColin Finck 3385*c2c66affSColin Finck trace("Testing http protocol (redirected, disable auto redirect)...\n"); 3386*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE; 3387*c2c66affSColin Finck test_http_protocol_url(redirect_url, HTTP_TEST, TEST_REDIRECT | TEST_DISABLEAUTOREDIRECT, TYMED_NULL); 3388*c2c66affSColin Finck 3389*c2c66affSColin Finck trace("Testing http protocol empty file...\n"); 3390*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE; 3391*c2c66affSColin Finck test_http_protocol_url(empty_url, HTTP_TEST, TEST_EMPTY, TYMED_NULL); 3392*c2c66affSColin Finck 3393*c2c66affSColin Finck /* This is a bit ugly. We unconditionally disable this test on Wine. This won't work until we have 3394*c2c66affSColin Finck * support for reading from cache via HTTP layer in wininet. Until then, Wine will fail badly, affecting 3395*c2c66affSColin Finck * other, unrelated, tests. Working around it is not worth the trouble, we may simply make sure those 3396*c2c66affSColin Finck * tests work on Windows and have them around for the future. 3397*c2c66affSColin Finck */ 3398*c2c66affSColin Finck if(broken(1)) { 3399*c2c66affSColin Finck trace("Testing http protocol (from cache)...\n"); 3400*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON; 3401*c2c66affSColin Finck test_http_protocol_url(cache_only_url, HTTP_TEST, TEST_FROMCACHE, TYMED_NULL); 3402*c2c66affSColin Finck } 3403*c2c66affSColin Finck 3404*c2c66affSColin Finck trace("Testing http protocol abort...\n"); 3405*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE; 3406*c2c66affSColin Finck test_http_protocol_url(winetest_url, HTTP_TEST, TEST_ABORT, TYMED_NULL); 3407*c2c66affSColin Finck 3408*c2c66affSColin Finck test_early_abort(&CLSID_HttpProtocol); 3409*c2c66affSColin Finck test_early_abort(&CLSID_HttpSProtocol); 3410*c2c66affSColin Finck } 3411*c2c66affSColin Finck 3412*c2c66affSColin Finck static void test_https_protocol(void) 3413*c2c66affSColin Finck { 3414*c2c66affSColin Finck static const WCHAR https_winehq_url[] = 3415*c2c66affSColin Finck {'h','t','t','p','s',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 3416*c2c66affSColin Finck 't','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0}; 3417*c2c66affSColin Finck 3418*c2c66affSColin Finck trace("Testing https protocol (from urlmon)...\n"); 3419*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE; 3420*c2c66affSColin Finck test_http_protocol_url(https_winehq_url, HTTPS_TEST, TEST_FIRST_HTTP, TYMED_NULL); 3421*c2c66affSColin Finck } 3422*c2c66affSColin Finck 3423*c2c66affSColin Finck 3424*c2c66affSColin Finck static void test_ftp_protocol(void) 3425*c2c66affSColin Finck { 3426*c2c66affSColin Finck IInternetProtocolInfo *protocol_info; 3427*c2c66affSColin Finck IClassFactory *factory; 3428*c2c66affSColin Finck IUnknown *unk; 3429*c2c66affSColin Finck BYTE buf[4096]; 3430*c2c66affSColin Finck ULONG ref; 3431*c2c66affSColin Finck DWORD cb; 3432*c2c66affSColin Finck HRESULT hres; 3433*c2c66affSColin Finck 3434*c2c66affSColin Finck static const WCHAR ftp_urlW[] = {'f','t','p',':','/','/','f','t','p','.','w','i','n','e','h','q','.','o','r','g', 3435*c2c66affSColin Finck '/','p','u','b','/','o','t','h','e','r','/', 3436*c2c66affSColin Finck 'w','i','n','e','l','o','g','o','.','x','c','f','.','t','a','r','.','b','z','2',0}; 3437*c2c66affSColin Finck 3438*c2c66affSColin Finck trace("Testing ftp protocol...\n"); 3439*c2c66affSColin Finck 3440*c2c66affSColin Finck init_test(FTP_TEST, 0); 3441*c2c66affSColin Finck 3442*c2c66affSColin Finck bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NOWRITECACHE; 3443*c2c66affSColin Finck state = STATE_STARTDOWNLOADING; 3444*c2c66affSColin Finck expect_hrResult = E_PENDING; 3445*c2c66affSColin Finck 3446*c2c66affSColin Finck hres = CoGetClassObject(&CLSID_FtpProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk); 3447*c2c66affSColin Finck ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres); 3448*c2c66affSColin Finck if(FAILED(hres)) 3449*c2c66affSColin Finck return; 3450*c2c66affSColin Finck 3451*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); 3452*c2c66affSColin Finck ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres); 3453*c2c66affSColin Finck 3454*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); 3455*c2c66affSColin Finck ok(hres == S_OK, "Could not get IClassFactory interface\n"); 3456*c2c66affSColin Finck IUnknown_Release(unk); 3457*c2c66affSColin Finck if(FAILED(hres)) 3458*c2c66affSColin Finck return; 3459*c2c66affSColin Finck 3460*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, 3461*c2c66affSColin Finck (void**)&async_protocol); 3462*c2c66affSColin Finck IClassFactory_Release(factory); 3463*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 3464*c2c66affSColin Finck 3465*c2c66affSColin Finck test_priority(async_protocol); 3466*c2c66affSColin Finck test_http_info(async_protocol); 3467*c2c66affSColin Finck 3468*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 3469*c2c66affSColin Finck SET_EXPECT(ReportProgress_FINDINGRESOURCE); 3470*c2c66affSColin Finck SET_EXPECT(ReportProgress_CONNECTING); 3471*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 3472*c2c66affSColin Finck SET_EXPECT(Switch); 3473*c2c66affSColin Finck 3474*c2c66affSColin Finck hres = IInternetProtocol_Start(async_protocol, ftp_urlW, &protocol_sink, &bind_info, 0, 0); 3475*c2c66affSColin Finck ok(hres == S_OK, "Start failed: %08x\n", hres); 3476*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 3477*c2c66affSColin Finck 3478*c2c66affSColin Finck SET_EXPECT(ReportResult); 3479*c2c66affSColin Finck 3480*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, 1, &cb); 3481*c2c66affSColin Finck ok((hres == E_PENDING && cb==0) || 3482*c2c66affSColin Finck (hres == S_OK && cb==1), "Read failed: %08x (%d bytes)\n", hres, cb); 3483*c2c66affSColin Finck 3484*c2c66affSColin Finck ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3485*c2c66affSColin Finck 3486*c2c66affSColin Finck while(1) { 3487*c2c66affSColin Finck hres = IInternetProtocol_Read(async_protocol, buf, sizeof(buf), &cb); 3488*c2c66affSColin Finck if(hres == E_PENDING) 3489*c2c66affSColin Finck { 3490*c2c66affSColin Finck DWORD ret = WaitForSingleObject(event_complete, 90000); 3491*c2c66affSColin Finck ok( ret == WAIT_OBJECT_0, "wait timed out\n" ); 3492*c2c66affSColin Finck if (ret != WAIT_OBJECT_0) break; 3493*c2c66affSColin Finck } 3494*c2c66affSColin Finck else 3495*c2c66affSColin Finck if(cb == 0) break; 3496*c2c66affSColin Finck } 3497*c2c66affSColin Finck 3498*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x\n", hres); 3499*c2c66affSColin Finck CHECK_CALLED(ReportResult); 3500*c2c66affSColin Finck CHECK_CALLED(Switch); 3501*c2c66affSColin Finck 3502*c2c66affSColin Finck test_protocol_terminate(async_protocol); 3503*c2c66affSColin Finck 3504*c2c66affSColin Finck if(pCreateUri) { 3505*c2c66affSColin Finck IInternetProtocolEx *protocolex; 3506*c2c66affSColin Finck 3507*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(async_protocol, &IID_IInternetProtocolEx, (void**)&protocolex); 3508*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocolEx iface: %08x\n", hres); 3509*c2c66affSColin Finck IInternetProtocolEx_Release(protocolex); 3510*c2c66affSColin Finck } 3511*c2c66affSColin Finck 3512*c2c66affSColin Finck ref = IInternetProtocol_Release(async_protocol); 3513*c2c66affSColin Finck ok(!ref, "ref=%d\n", ref); 3514*c2c66affSColin Finck 3515*c2c66affSColin Finck test_early_abort(&CLSID_FtpProtocol); 3516*c2c66affSColin Finck } 3517*c2c66affSColin Finck 3518*c2c66affSColin Finck static void test_gopher_protocol(void) 3519*c2c66affSColin Finck { 3520*c2c66affSColin Finck IInternetProtocolInfo *protocol_info; 3521*c2c66affSColin Finck IClassFactory *factory; 3522*c2c66affSColin Finck IUnknown *unk; 3523*c2c66affSColin Finck HRESULT hres; 3524*c2c66affSColin Finck 3525*c2c66affSColin Finck trace("Testing gopher protocol...\n"); 3526*c2c66affSColin Finck 3527*c2c66affSColin Finck hres = CoGetClassObject(&CLSID_GopherProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk); 3528*c2c66affSColin Finck ok(hres == S_OK || 3529*c2c66affSColin Finck broken(hres == REGDB_E_CLASSNOTREG || hres == CLASS_E_CLASSNOTAVAILABLE), /* Gopher protocol has been removed as of Vista */ 3530*c2c66affSColin Finck "CoGetClassObject failed: %08x\n", hres); 3531*c2c66affSColin Finck if(FAILED(hres)) 3532*c2c66affSColin Finck return; 3533*c2c66affSColin Finck 3534*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); 3535*c2c66affSColin Finck ok(hres == E_NOINTERFACE, "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", hres); 3536*c2c66affSColin Finck 3537*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); 3538*c2c66affSColin Finck ok(hres == S_OK, "Could not get IClassFactory interface\n"); 3539*c2c66affSColin Finck IUnknown_Release(unk); 3540*c2c66affSColin Finck if(FAILED(hres)) 3541*c2c66affSColin Finck return; 3542*c2c66affSColin Finck 3543*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, 3544*c2c66affSColin Finck (void**)&async_protocol); 3545*c2c66affSColin Finck IClassFactory_Release(factory); 3546*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 3547*c2c66affSColin Finck 3548*c2c66affSColin Finck test_priority(async_protocol); 3549*c2c66affSColin Finck 3550*c2c66affSColin Finck IInternetProtocol_Release(async_protocol); 3551*c2c66affSColin Finck 3552*c2c66affSColin Finck test_early_abort(&CLSID_GopherProtocol); 3553*c2c66affSColin Finck } 3554*c2c66affSColin Finck 3555*c2c66affSColin Finck static void test_mk_protocol(void) 3556*c2c66affSColin Finck { 3557*c2c66affSColin Finck IInternetProtocolInfo *protocol_info; 3558*c2c66affSColin Finck IInternetProtocol *protocol; 3559*c2c66affSColin Finck IClassFactory *factory; 3560*c2c66affSColin Finck IUnknown *unk; 3561*c2c66affSColin Finck HRESULT hres; 3562*c2c66affSColin Finck 3563*c2c66affSColin Finck static const WCHAR wrong_url1[] = {'t','e','s','t',':','@','M','S','I','T','S','t','o','r','e', 3564*c2c66affSColin Finck ':',':','/','t','e','s','t','.','h','t','m','l',0}; 3565*c2c66affSColin Finck static const WCHAR wrong_url2[] = {'m','k',':','/','t','e','s','t','.','h','t','m','l',0}; 3566*c2c66affSColin Finck 3567*c2c66affSColin Finck trace("Testing mk protocol...\n"); 3568*c2c66affSColin Finck init_test(MK_TEST, 0); 3569*c2c66affSColin Finck 3570*c2c66affSColin Finck hres = CoGetClassObject(&CLSID_MkProtocol, CLSCTX_INPROC_SERVER, NULL, 3571*c2c66affSColin Finck &IID_IUnknown, (void**)&unk); 3572*c2c66affSColin Finck ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres); 3573*c2c66affSColin Finck 3574*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); 3575*c2c66affSColin Finck ok(hres == E_NOINTERFACE, 3576*c2c66affSColin Finck "Could not get IInternetProtocolInfo interface: %08x, expected E_NOINTERFACE\n", 3577*c2c66affSColin Finck hres); 3578*c2c66affSColin Finck 3579*c2c66affSColin Finck hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); 3580*c2c66affSColin Finck ok(hres == S_OK, "Could not get IClassFactory interface\n"); 3581*c2c66affSColin Finck IUnknown_Release(unk); 3582*c2c66affSColin Finck if(FAILED(hres)) 3583*c2c66affSColin Finck return; 3584*c2c66affSColin Finck 3585*c2c66affSColin Finck hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, 3586*c2c66affSColin Finck (void**)&protocol); 3587*c2c66affSColin Finck IClassFactory_Release(factory); 3588*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); 3589*c2c66affSColin Finck 3590*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 3591*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, wrong_url1, &protocol_sink, &bind_info, 0, 0); 3592*c2c66affSColin Finck ok(hres == MK_E_SYNTAX || hres == INET_E_INVALID_URL, 3593*c2c66affSColin Finck "Start failed: %08x, expected MK_E_SYNTAX or INET_E_INVALID_URL\n", hres); 3594*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); 3595*c2c66affSColin Finck 3596*c2c66affSColin Finck SET_EXPECT(GetBindInfo); 3597*c2c66affSColin Finck SET_EXPECT(ReportProgress_DIRECTBIND); 3598*c2c66affSColin Finck SET_EXPECT(ReportProgress_SENDINGREQUEST); 3599*c2c66affSColin Finck SET_EXPECT(ReportProgress_MIMETYPEAVAILABLE); 3600*c2c66affSColin Finck SET_EXPECT(ReportResult); 3601*c2c66affSColin Finck expect_hrResult = INET_E_RESOURCE_NOT_FOUND; 3602*c2c66affSColin Finck 3603*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, wrong_url2, &protocol_sink, &bind_info, 0, 0); 3604*c2c66affSColin Finck ok(hres == INET_E_RESOURCE_NOT_FOUND || 3605*c2c66affSColin Finck hres == INET_E_INVALID_URL, /* win2k3 */ 3606*c2c66affSColin Finck "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres); 3607*c2c66affSColin Finck 3608*c2c66affSColin Finck if (hres == INET_E_RESOURCE_NOT_FOUND) { 3609*c2c66affSColin Finck CHECK_CALLED(GetBindInfo); 3610*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_DIRECTBIND); 3611*c2c66affSColin Finck CHECK_CALLED(ReportProgress_SENDINGREQUEST); 3612*c2c66affSColin Finck CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE); 3613*c2c66affSColin Finck CHECK_CALLED(ReportResult); 3614*c2c66affSColin Finck }else { 3615*c2c66affSColin Finck CLEAR_CALLED(GetBindInfo); 3616*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_DIRECTBIND); 3617*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_SENDINGREQUEST); 3618*c2c66affSColin Finck CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE); 3619*c2c66affSColin Finck CLEAR_CALLED(ReportResult); 3620*c2c66affSColin Finck } 3621*c2c66affSColin Finck 3622*c2c66affSColin Finck IInternetProtocol_Release(protocol); 3623*c2c66affSColin Finck } 3624*c2c66affSColin Finck 3625*c2c66affSColin Finck static void test_CreateBinding(void) 3626*c2c66affSColin Finck { 3627*c2c66affSColin Finck IInternetProtocol *protocol; 3628*c2c66affSColin Finck IInternetPriority *priority; 3629*c2c66affSColin Finck IInternetSession *session; 3630*c2c66affSColin Finck IWinInetHttpInfo *http_info; 3631*c2c66affSColin Finck IWinInetInfo *inet_info; 3632*c2c66affSColin Finck LONG p; 3633*c2c66affSColin Finck BYTE buf[1000]; 3634*c2c66affSColin Finck DWORD read; 3635*c2c66affSColin Finck HRESULT hres; 3636*c2c66affSColin Finck 3637*c2c66affSColin Finck static const WCHAR test_url[] = 3638*c2c66affSColin Finck {'t','e','s','t',':','/','/','f','i','l','e','.','h','t','m','l',0}; 3639*c2c66affSColin Finck static const WCHAR wsz_test[] = {'t','e','s','t',0}; 3640*c2c66affSColin Finck 3641*c2c66affSColin Finck trace("Testing CreateBinding...\n"); 3642*c2c66affSColin Finck init_test(BIND_TEST, TEST_BINDING); 3643*c2c66affSColin Finck 3644*c2c66affSColin Finck hres = pCoInternetGetSession(0, &session, 0); 3645*c2c66affSColin Finck ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres); 3646*c2c66affSColin Finck 3647*c2c66affSColin Finck hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, wsz_test, 0, NULL, 0); 3648*c2c66affSColin Finck ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres); 3649*c2c66affSColin Finck 3650*c2c66affSColin Finck hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0); 3651*c2c66affSColin Finck binding_protocol = protocol; 3652*c2c66affSColin Finck ok(hres == S_OK, "CreateBinding failed: %08x\n", hres); 3653*c2c66affSColin Finck ok(protocol != NULL, "protocol == NULL\n"); 3654*c2c66affSColin Finck 3655*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info); 3656*c2c66affSColin Finck ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres); 3657*c2c66affSColin Finck 3658*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&binding_sink); 3659*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocolSink: %08x\n", hres); 3660*c2c66affSColin Finck 3661*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, test_url, NULL, &bind_info, 0, 0); 3662*c2c66affSColin Finck ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres); 3663*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, NULL, 0, 0); 3664*c2c66affSColin Finck ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres); 3665*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0); 3666*c2c66affSColin Finck ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres); 3667*c2c66affSColin Finck 3668*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority); 3669*c2c66affSColin Finck ok(hres == S_OK, "QueryInterface(IID_IInternetPriority) failed: %08x\n", hres); 3670*c2c66affSColin Finck 3671*c2c66affSColin Finck p = 0xdeadbeef; 3672*c2c66affSColin Finck hres = IInternetPriority_GetPriority(priority, &p); 3673*c2c66affSColin Finck ok(hres == S_OK, "GetPriority failed: %08x\n", hres); 3674*c2c66affSColin Finck ok(!p, "p=%d\n", p); 3675*c2c66affSColin Finck 3676*c2c66affSColin Finck ex_priority = 100; 3677*c2c66affSColin Finck hres = IInternetPriority_SetPriority(priority, 100); 3678*c2c66affSColin Finck ok(hres == S_OK, "SetPriority failed: %08x\n", hres); 3679*c2c66affSColin Finck 3680*c2c66affSColin Finck p = 0xdeadbeef; 3681*c2c66affSColin Finck hres = IInternetPriority_GetPriority(priority, &p); 3682*c2c66affSColin Finck ok(hres == S_OK, "GetPriority failed: %08x\n", hres); 3683*c2c66affSColin Finck ok(p == 100, "p=%d\n", p); 3684*c2c66affSColin Finck 3685*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&inet_info); 3686*c2c66affSColin Finck ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres); 3687*c2c66affSColin Finck 3688*c2c66affSColin Finck SET_EXPECT(QueryService_InternetProtocol); 3689*c2c66affSColin Finck SET_EXPECT(CreateInstance); 3690*c2c66affSColin Finck SET_EXPECT(ReportProgress_PROTOCOLCLASSID); 3691*c2c66affSColin Finck SET_EXPECT(SetPriority); 3692*c2c66affSColin Finck SET_EXPECT(Start); 3693*c2c66affSColin Finck 3694*c2c66affSColin Finck expect_hrResult = S_OK; 3695*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, &bind_info, 0, 0); 3696*c2c66affSColin Finck ok(hres == S_OK, "Start failed: %08x\n", hres); 3697*c2c66affSColin Finck 3698*c2c66affSColin Finck CHECK_CALLED(QueryService_InternetProtocol); 3699*c2c66affSColin Finck CHECK_CALLED(CreateInstance); 3700*c2c66affSColin Finck CHECK_CALLED(ReportProgress_PROTOCOLCLASSID); 3701*c2c66affSColin Finck CHECK_CALLED(SetPriority); 3702*c2c66affSColin Finck CHECK_CALLED(Start); 3703*c2c66affSColin Finck 3704*c2c66affSColin Finck SET_EXPECT(QueryInterface_IWinInetInfo); 3705*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&inet_info); 3706*c2c66affSColin Finck ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres); 3707*c2c66affSColin Finck CHECK_CALLED(QueryInterface_IWinInetInfo); 3708*c2c66affSColin Finck 3709*c2c66affSColin Finck SET_EXPECT(QueryInterface_IWinInetInfo); 3710*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetInfo, (void**)&inet_info); 3711*c2c66affSColin Finck ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres); 3712*c2c66affSColin Finck CHECK_CALLED(QueryInterface_IWinInetInfo); 3713*c2c66affSColin Finck 3714*c2c66affSColin Finck SET_EXPECT(QueryInterface_IWinInetHttpInfo); 3715*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IWinInetHttpInfo, (void**)&http_info); 3716*c2c66affSColin Finck ok(hres == E_NOINTERFACE, "Could not get IWinInetInfo protocol: %08x\n", hres); 3717*c2c66affSColin Finck CHECK_CALLED(QueryInterface_IWinInetHttpInfo); 3718*c2c66affSColin Finck 3719*c2c66affSColin Finck SET_EXPECT(Read); 3720*c2c66affSColin Finck read = 0xdeadbeef; 3721*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read); 3722*c2c66affSColin Finck ok(hres == S_OK, "Read failed: %08x\n", hres); 3723*c2c66affSColin Finck ok(read == 100, "read = %d\n", read); 3724*c2c66affSColin Finck CHECK_CALLED(Read); 3725*c2c66affSColin Finck 3726*c2c66affSColin Finck SET_EXPECT(Read); 3727*c2c66affSColin Finck read = 0xdeadbeef; 3728*c2c66affSColin Finck hres = IInternetProtocol_Read(protocol, expect_pv = buf, sizeof(buf), &read); 3729*c2c66affSColin Finck ok(hres == S_FALSE, "Read failed: %08x\n", hres); 3730*c2c66affSColin Finck ok(!read, "read = %d\n", read); 3731*c2c66affSColin Finck CHECK_CALLED(Read); 3732*c2c66affSColin Finck 3733*c2c66affSColin Finck p = 0xdeadbeef; 3734*c2c66affSColin Finck hres = IInternetPriority_GetPriority(priority, &p); 3735*c2c66affSColin Finck ok(hres == S_OK, "GetPriority failed: %08x\n", hres); 3736*c2c66affSColin Finck ok(p == 100, "p=%d\n", p); 3737*c2c66affSColin Finck 3738*c2c66affSColin Finck hres = IInternetPriority_SetPriority(priority, 101); 3739*c2c66affSColin Finck ok(hres == S_OK, "SetPriority failed: %08x\n", hres); 3740*c2c66affSColin Finck 3741*c2c66affSColin Finck SET_EXPECT(Terminate); 3742*c2c66affSColin Finck hres = IInternetProtocol_Terminate(protocol, 0xdeadbeef); 3743*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 3744*c2c66affSColin Finck CHECK_CALLED(Terminate); 3745*c2c66affSColin Finck 3746*c2c66affSColin Finck SET_EXPECT(Continue); 3747*c2c66affSColin Finck hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata); 3748*c2c66affSColin Finck ok(hres == S_OK, "Switch failed: %08x\n", hres); 3749*c2c66affSColin Finck CHECK_CALLED(Continue); 3750*c2c66affSColin Finck 3751*c2c66affSColin Finck hres = IInternetProtocolSink_ReportProgress(binding_sink, 3752*c2c66affSColin Finck BINDSTATUS_CACHEFILENAMEAVAILABLE, expect_wsz = emptyW); 3753*c2c66affSColin Finck ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres); 3754*c2c66affSColin Finck 3755*c2c66affSColin Finck hres = IInternetProtocolSink_ReportResult(binding_sink, S_OK, ERROR_SUCCESS, NULL); 3756*c2c66affSColin Finck ok(hres == E_FAIL, "ReportResult failed: %08x, expected E_FAIL\n", hres); 3757*c2c66affSColin Finck 3758*c2c66affSColin Finck hres = IInternetProtocolSink_ReportData(binding_sink, 0, 0, 0); 3759*c2c66affSColin Finck ok(hres == S_OK, "ReportData failed: %08x\n", hres); 3760*c2c66affSColin Finck 3761*c2c66affSColin Finck IInternetProtocolSink_Release(binding_sink); 3762*c2c66affSColin Finck IInternetPriority_Release(priority); 3763*c2c66affSColin Finck IInternetBindInfo_Release(prot_bind_info); 3764*c2c66affSColin Finck IInternetProtocol_Release(protocol); 3765*c2c66affSColin Finck 3766*c2c66affSColin Finck hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0); 3767*c2c66affSColin Finck ok(hres == S_OK, "CreateBinding failed: %08x\n", hres); 3768*c2c66affSColin Finck ok(protocol != NULL, "protocol == NULL\n"); 3769*c2c66affSColin Finck 3770*c2c66affSColin Finck hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); 3771*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 3772*c2c66affSColin Finck 3773*c2c66affSColin Finck hres = IInternetProtocol_Abort(protocol, E_FAIL, 0); 3774*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 3775*c2c66affSColin Finck 3776*c2c66affSColin Finck IInternetProtocol_Release(protocol); 3777*c2c66affSColin Finck 3778*c2c66affSColin Finck hres = IInternetSession_UnregisterNameSpace(session, &ClassFactory, wsz_test); 3779*c2c66affSColin Finck ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres); 3780*c2c66affSColin Finck 3781*c2c66affSColin Finck hres = IInternetSession_CreateBinding(session, NULL, test_url, NULL, NULL, &protocol, 0); 3782*c2c66affSColin Finck ok(hres == S_OK, "CreateBinding failed: %08x\n", hres); 3783*c2c66affSColin Finck ok(protocol != NULL, "protocol == NULL\n"); 3784*c2c66affSColin Finck 3785*c2c66affSColin Finck SET_EXPECT(QueryService_InternetProtocol); 3786*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, test_url, &protocol_sink, &bind_info, 0, 0); 3787*c2c66affSColin Finck ok(hres == MK_E_SYNTAX, "Start failed: %08x, expected MK_E_SYNTAX\n", hres); 3788*c2c66affSColin Finck CHECK_CALLED(QueryService_InternetProtocol); 3789*c2c66affSColin Finck 3790*c2c66affSColin Finck IInternetProtocol_Release(protocol); 3791*c2c66affSColin Finck 3792*c2c66affSColin Finck IInternetSession_Release(session); 3793*c2c66affSColin Finck } 3794*c2c66affSColin Finck 3795*c2c66affSColin Finck static void test_binding(int prot, DWORD grf_pi, DWORD test_flags) 3796*c2c66affSColin Finck { 3797*c2c66affSColin Finck IInternetProtocolEx *protocolex = NULL; 3798*c2c66affSColin Finck IInternetProtocol *protocol; 3799*c2c66affSColin Finck IInternetSession *session; 3800*c2c66affSColin Finck IUri *uri = NULL; 3801*c2c66affSColin Finck ULONG ref; 3802*c2c66affSColin Finck HRESULT hres; 3803*c2c66affSColin Finck 3804*c2c66affSColin Finck pi = grf_pi; 3805*c2c66affSColin Finck 3806*c2c66affSColin Finck init_test(prot, test_flags|TEST_BINDING); 3807*c2c66affSColin Finck 3808*c2c66affSColin Finck hres = pCoInternetGetSession(0, &session, 0); 3809*c2c66affSColin Finck ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres); 3810*c2c66affSColin Finck 3811*c2c66affSColin Finck if(test_flags & TEST_EMULATEPROT) { 3812*c2c66affSColin Finck hres = IInternetSession_RegisterNameSpace(session, &ClassFactory, &IID_NULL, protocol_names[prot], 0, NULL, 0); 3813*c2c66affSColin Finck ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres); 3814*c2c66affSColin Finck } 3815*c2c66affSColin Finck 3816*c2c66affSColin Finck hres = IInternetSession_CreateBinding(session, NULL, binding_urls[prot], NULL, NULL, &protocol, 0); 3817*c2c66affSColin Finck binding_protocol = protocol; 3818*c2c66affSColin Finck ok(hres == S_OK, "CreateBinding failed: %08x\n", hres); 3819*c2c66affSColin Finck ok(protocol != NULL, "protocol == NULL\n"); 3820*c2c66affSColin Finck 3821*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetBindInfo, (void**)&prot_bind_info); 3822*c2c66affSColin Finck ok(hres == S_OK, "QueryInterface(IID_IInternetBindInfo) failed: %08x\n", hres); 3823*c2c66affSColin Finck 3824*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolSink, (void**)&binding_sink); 3825*c2c66affSColin Finck ok(hres == S_OK, "QueryInterface(IID_IInternetProtocolSink) failed: %08x\n", hres); 3826*c2c66affSColin Finck 3827*c2c66affSColin Finck if(test_flags & TEST_USEIURI) { 3828*c2c66affSColin Finck hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetProtocolEx, (void**)&protocolex); 3829*c2c66affSColin Finck ok(hres == S_OK, "Could not get IInternetProtocolEx iface: %08x\n", hres); 3830*c2c66affSColin Finck 3831*c2c66affSColin Finck hres = pCreateUri(binding_urls[prot], Uri_CREATE_FILE_USE_DOS_PATH, 0, &uri); 3832*c2c66affSColin Finck ok(hres == S_OK, "CreateUri failed: %08x\n", hres); 3833*c2c66affSColin Finck } 3834*c2c66affSColin Finck 3835*c2c66affSColin Finck ex_priority = 0; 3836*c2c66affSColin Finck SET_EXPECT(QueryService_InternetProtocol); 3837*c2c66affSColin Finck SET_EXPECT(CreateInstance); 3838*c2c66affSColin Finck SET_EXPECT(ReportProgress_PROTOCOLCLASSID); 3839*c2c66affSColin Finck SET_EXPECT(SetPriority); 3840*c2c66affSColin Finck if(impl_protex) 3841*c2c66affSColin Finck SET_EXPECT(StartEx); 3842*c2c66affSColin Finck else 3843*c2c66affSColin Finck SET_EXPECT(Start); 3844*c2c66affSColin Finck 3845*c2c66affSColin Finck expect_hrResult = S_OK; 3846*c2c66affSColin Finck 3847*c2c66affSColin Finck if(protocolex) { 3848*c2c66affSColin Finck hres = IInternetProtocolEx_StartEx(protocolex, uri, &protocol_sink, &bind_info, pi, 0); 3849*c2c66affSColin Finck ok(hres == S_OK, "StartEx failed: %08x\n", hres); 3850*c2c66affSColin Finck }else { 3851*c2c66affSColin Finck hres = IInternetProtocol_Start(protocol, binding_urls[prot], &protocol_sink, &bind_info, pi, 0); 3852*c2c66affSColin Finck ok(hres == S_OK, "Start failed: %08x\n", hres); 3853*c2c66affSColin Finck } 3854*c2c66affSColin Finck 3855*c2c66affSColin Finck CHECK_CALLED(QueryService_InternetProtocol); 3856*c2c66affSColin Finck CHECK_CALLED(CreateInstance); 3857*c2c66affSColin Finck CHECK_CALLED(ReportProgress_PROTOCOLCLASSID); 3858*c2c66affSColin Finck CLEAR_CALLED(SetPriority); /* IE11 does not call it. */ 3859*c2c66affSColin Finck if(impl_protex) 3860*c2c66affSColin Finck CHECK_CALLED(StartEx); 3861*c2c66affSColin Finck else 3862*c2c66affSColin Finck CHECK_CALLED(Start); 3863*c2c66affSColin Finck 3864*c2c66affSColin Finck if(protocolex) 3865*c2c66affSColin Finck IInternetProtocolEx_Release(protocolex); 3866*c2c66affSColin Finck if(uri) 3867*c2c66affSColin Finck IUri_Release(uri); 3868*c2c66affSColin Finck 3869*c2c66affSColin Finck if(prot == HTTP_TEST || prot == HTTPS_TEST) { 3870*c2c66affSColin Finck while(prot_state < 4) { 3871*c2c66affSColin Finck ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3872*c2c66affSColin Finck if(mimefilter_test && filtered_protocol) { 3873*c2c66affSColin Finck SET_EXPECT(Continue); 3874*c2c66affSColin Finck IInternetProtocol_Continue(filtered_protocol, pdata); 3875*c2c66affSColin Finck CHECK_CALLED(Continue); 3876*c2c66affSColin Finck }else { 3877*c2c66affSColin Finck SET_EXPECT(Continue); 3878*c2c66affSColin Finck IInternetProtocol_Continue(protocol, pdata); 3879*c2c66affSColin Finck CHECK_CALLED(Continue); 3880*c2c66affSColin Finck } 3881*c2c66affSColin Finck if(test_abort && prot_state == 2) { 3882*c2c66affSColin Finck SET_EXPECT(Abort); 3883*c2c66affSColin Finck hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); 3884*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 3885*c2c66affSColin Finck CHECK_CALLED(Abort); 3886*c2c66affSColin Finck 3887*c2c66affSColin Finck hres = IInternetProtocol_Abort(protocol, E_ABORT, 0); 3888*c2c66affSColin Finck ok(hres == S_OK, "Abort failed: %08x\n", hres); 3889*c2c66affSColin Finck SetEvent(event_complete2); 3890*c2c66affSColin Finck break; 3891*c2c66affSColin Finck } 3892*c2c66affSColin Finck SetEvent(event_complete2); 3893*c2c66affSColin Finck } 3894*c2c66affSColin Finck if(direct_read) 3895*c2c66affSColin Finck CHECK_CALLED(ReportData); /* Set in ReportResult */ 3896*c2c66affSColin Finck ok( WaitForSingleObject(event_complete, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3897*c2c66affSColin Finck }else { 3898*c2c66affSColin Finck if(mimefilter_test) 3899*c2c66affSColin Finck SET_EXPECT(MimeFilter_LockRequest); 3900*c2c66affSColin Finck else 3901*c2c66affSColin Finck SET_EXPECT(LockRequest); 3902*c2c66affSColin Finck hres = IInternetProtocol_LockRequest(protocol, 0); 3903*c2c66affSColin Finck ok(hres == S_OK, "LockRequest failed: %08x\n", hres); 3904*c2c66affSColin Finck if(mimefilter_test) 3905*c2c66affSColin Finck CHECK_CALLED(MimeFilter_LockRequest); 3906*c2c66affSColin Finck else 3907*c2c66affSColin Finck CHECK_CALLED(LockRequest); 3908*c2c66affSColin Finck 3909*c2c66affSColin Finck if(mimefilter_test) 3910*c2c66affSColin Finck SET_EXPECT(MimeFilter_UnlockRequest); 3911*c2c66affSColin Finck else 3912*c2c66affSColin Finck SET_EXPECT(UnlockRequest); 3913*c2c66affSColin Finck hres = IInternetProtocol_UnlockRequest(protocol); 3914*c2c66affSColin Finck ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); 3915*c2c66affSColin Finck if(mimefilter_test) 3916*c2c66affSColin Finck CHECK_CALLED(MimeFilter_UnlockRequest); 3917*c2c66affSColin Finck else 3918*c2c66affSColin Finck CHECK_CALLED(UnlockRequest); 3919*c2c66affSColin Finck } 3920*c2c66affSColin Finck 3921*c2c66affSColin Finck if(mimefilter_test) 3922*c2c66affSColin Finck SET_EXPECT(MimeFilter_Terminate); 3923*c2c66affSColin Finck else 3924*c2c66affSColin Finck SET_EXPECT(Terminate); 3925*c2c66affSColin Finck hres = IInternetProtocol_Terminate(protocol, 0); 3926*c2c66affSColin Finck ok(hres == S_OK, "Terminate failed: %08x\n", hres); 3927*c2c66affSColin Finck if(mimefilter_test) 3928*c2c66affSColin Finck CLEAR_CALLED(MimeFilter_Terminate); 3929*c2c66affSColin Finck else 3930*c2c66affSColin Finck CHECK_CALLED(Terminate); 3931*c2c66affSColin Finck 3932*c2c66affSColin Finck if(filtered_protocol) 3933*c2c66affSColin Finck IInternetProtocol_Release(filtered_protocol); 3934*c2c66affSColin Finck IInternetBindInfo_Release(prot_bind_info); 3935*c2c66affSColin Finck IInternetProtocolSink_Release(binding_sink); 3936*c2c66affSColin Finck ref = IInternetProtocol_Release(protocol); 3937*c2c66affSColin Finck ok(!ref, "ref=%u, expected 0\n", ref); 3938*c2c66affSColin Finck 3939*c2c66affSColin Finck if(test_flags & TEST_EMULATEPROT) { 3940*c2c66affSColin Finck hres = IInternetSession_UnregisterNameSpace(session, &ClassFactory, protocol_names[prot]); 3941*c2c66affSColin Finck ok(hres == S_OK, "UnregisterNameSpace failed: %08x\n", hres); 3942*c2c66affSColin Finck } 3943*c2c66affSColin Finck 3944*c2c66affSColin Finck IInternetSession_Release(session); 3945*c2c66affSColin Finck } 3946*c2c66affSColin Finck 3947*c2c66affSColin Finck START_TEST(protocol) 3948*c2c66affSColin Finck { 3949*c2c66affSColin Finck HMODULE hurlmon; 3950*c2c66affSColin Finck 3951*c2c66affSColin Finck hurlmon = GetModuleHandleA("urlmon.dll"); 3952*c2c66affSColin Finck pCoInternetGetSession = (void*) GetProcAddress(hurlmon, "CoInternetGetSession"); 3953*c2c66affSColin Finck pReleaseBindInfo = (void*) GetProcAddress(hurlmon, "ReleaseBindInfo"); 3954*c2c66affSColin Finck pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri"); 3955*c2c66affSColin Finck 3956*c2c66affSColin Finck if(!GetProcAddress(hurlmon, "CompareSecurityIds")) { 3957*c2c66affSColin Finck win_skip("Various needed functions not present, too old IE\n"); 3958*c2c66affSColin Finck return; 3959*c2c66affSColin Finck } 3960*c2c66affSColin Finck 3961*c2c66affSColin Finck if(!pCreateUri) 3962*c2c66affSColin Finck win_skip("CreateUri not supported\n"); 3963*c2c66affSColin Finck 3964*c2c66affSColin Finck OleInitialize(NULL); 3965*c2c66affSColin Finck 3966*c2c66affSColin Finck event_complete = CreateEventW(NULL, FALSE, FALSE, NULL); 3967*c2c66affSColin Finck event_complete2 = CreateEventW(NULL, FALSE, FALSE, NULL); 3968*c2c66affSColin Finck event_continue = CreateEventW(NULL, FALSE, FALSE, NULL); 3969*c2c66affSColin Finck event_continue_done = CreateEventW(NULL, FALSE, FALSE, NULL); 3970*c2c66affSColin Finck thread_id = GetCurrentThreadId(); 3971*c2c66affSColin Finck 3972*c2c66affSColin Finck test_file_protocol(); 3973*c2c66affSColin Finck test_http_protocol(); 3974*c2c66affSColin Finck if(pCreateUri) 3975*c2c66affSColin Finck test_https_protocol(); 3976*c2c66affSColin Finck else 3977*c2c66affSColin Finck win_skip("Skipping https tests on too old platform\n"); 3978*c2c66affSColin Finck test_ftp_protocol(); 3979*c2c66affSColin Finck test_gopher_protocol(); 3980*c2c66affSColin Finck test_mk_protocol(); 3981*c2c66affSColin Finck test_CreateBinding(); 3982*c2c66affSColin Finck 3983*c2c66affSColin Finck bindf &= ~BINDF_FROMURLMON; 3984*c2c66affSColin Finck trace("Testing file binding (mime verification, emulate prot)...\n"); 3985*c2c66affSColin Finck test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT); 3986*c2c66affSColin Finck trace("Testing http binding (mime verification, emulate prot)...\n"); 3987*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT); 3988*c2c66affSColin Finck trace("Testing its binding (mime verification, emulate prot)...\n"); 3989*c2c66affSColin Finck test_binding(ITS_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT); 3990*c2c66affSColin Finck trace("Testing http binding (mime verification, emulate prot, short read, direct read)...\n"); 3991*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_SHORT_READ|TEST_DIRECT_READ); 3992*c2c66affSColin Finck trace("Testing http binding (mime verification, redirect, emulate prot)...\n"); 3993*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_REDIRECT); 3994*c2c66affSColin Finck trace("Testing http binding (mime verification, redirect, disable auto redirect, emulate prot)...\n"); 3995*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_REDIRECT|TEST_DISABLEAUTOREDIRECT); 3996*c2c66affSColin Finck trace("Testing file binding (mime verification, emulate prot, mime filter)...\n"); 3997*c2c66affSColin Finck test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER); 3998*c2c66affSColin Finck trace("Testing http binding (mime verification, emulate prot, mime filter)...\n"); 3999*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER); 4000*c2c66affSColin Finck trace("Testing http binding (mime verification, emulate prot, mime filter, no mime)...\n"); 4001*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER|TEST_NOMIME); 4002*c2c66affSColin Finck trace("Testing http binding (mime verification, emulate prot, direct read)...\n"); 4003*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_DIRECT_READ); 4004*c2c66affSColin Finck trace("Testing http binding (mime verification, emulate prot, abort)...\n"); 4005*c2c66affSColin Finck test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_ABORT); 4006*c2c66affSColin Finck if(pCreateUri) { 4007*c2c66affSColin Finck trace("Testing file binding (use IUri, mime verification, emulate prot)...\n"); 4008*c2c66affSColin Finck test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_USEIURI); 4009*c2c66affSColin Finck trace("Testing file binding (use IUri, impl StartEx, mime verification, emulate prot)...\n"); 4010*c2c66affSColin Finck test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_USEIURI|TEST_IMPLPROTEX); 4011*c2c66affSColin Finck trace("Testing file binding (impl StartEx, mime verification, emulate prot)...\n"); 4012*c2c66affSColin Finck test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_IMPLPROTEX); 4013*c2c66affSColin Finck } 4014*c2c66affSColin Finck 4015*c2c66affSColin Finck CloseHandle(event_complete); 4016*c2c66affSColin Finck CloseHandle(event_complete2); 4017*c2c66affSColin Finck CloseHandle(event_continue); 4018*c2c66affSColin Finck CloseHandle(event_continue_done); 4019*c2c66affSColin Finck 4020*c2c66affSColin Finck OleUninitialize(); 4021*c2c66affSColin Finck } 4022