1 /* 2 * UrlMon URL tests 3 * 4 * Copyright 2004 Kevin Koltzau 5 * Copyright 2004-2007 Jacek Caban for CodeWeavers 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 20 */ 21 22 #define WIN32_NO_STATUS 23 #define _INC_WINDOWS 24 #define COM_NO_WINDOWS_H 25 26 //#include <stdarg.h> 27 #include <stdio.h> 28 29 #define COBJMACROS 30 #define NONAMELESSUNION 31 #define CONST_VTABLE 32 33 #include <windef.h> 34 #include <winbase.h> 35 #include <winnls.h> 36 #include <winreg.h> 37 #include <wingdi.h> 38 #include <objbase.h> 39 //#include "initguid.h" 40 //#include "urlmon.h" 41 #include <wininet.h> 42 #include <mshtml.h> 43 44 #include <wine/test.h> 45 46 static HRESULT (WINAPI *pCreateAsyncBindCtxEx)(IBindCtx *, DWORD, 47 IBindStatusCallback *, IEnumFORMATETC *, IBindCtx **, DWORD); 48 static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**); 49 50 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); 51 DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46); 52 DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b); 53 static const IID IID_undocumentedIE11 = {0xd5ae15f6,0x2032,0x488e,{0x8f,0x96,0xf9,0x24,0x06,0xd8,0xd8,0xb4}}; 54 extern CLSID CLSID_AboutProtocol; 55 56 #define DEFINE_EXPECT(func) \ 57 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE 58 59 #define SET_EXPECT(func) \ 60 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0) 61 62 #define CHECK_EXPECT2(func) \ 63 do { \ 64 ok(expect_ ##func, "unexpected call " #func "\n"); \ 65 called_ ## func = TRUE; \ 66 }while(0) 67 68 #define CHECK_EXPECT(func) \ 69 do { \ 70 CHECK_EXPECT2(func); \ 71 expect_ ## func = FALSE; \ 72 }while(0) 73 74 #define CHECK_CALLED(func) \ 75 do { \ 76 ok(called_ ## func, "expected " #func "\n"); \ 77 expect_ ## func = called_ ## func = FALSE; \ 78 }while(0) 79 80 #define CHECK_NOT_CALLED(func) \ 81 do { \ 82 ok(!called_ ## func, "unexpected " #func "\n"); \ 83 expect_ ## func = called_ ## func = FALSE; \ 84 }while(0) 85 86 #define CHECK_CALLED_BROKEN(func) \ 87 do { \ 88 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \ 89 expect_ ## func = called_ ## func = FALSE; \ 90 }while(0) 91 92 #define CLEAR_CALLED(func) \ 93 expect_ ## func = called_ ## func = FALSE 94 95 DEFINE_EXPECT(QueryInterface_IServiceProvider); 96 DEFINE_EXPECT(QueryInterface_IHttpNegotiate); 97 DEFINE_EXPECT(QueryInterface_IBindStatusCallback); 98 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx); 99 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder); 100 DEFINE_EXPECT(QueryInterface_IAuthenticate); 101 DEFINE_EXPECT(QueryInterface_IInternetProtocol); 102 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI); 103 DEFINE_EXPECT(QueryInterface_IHttpSecurity); 104 DEFINE_EXPECT(QueryService_IAuthenticate); 105 DEFINE_EXPECT(QueryService_IInternetProtocol); 106 DEFINE_EXPECT(QueryService_IInternetBindInfo); 107 DEFINE_EXPECT(QueryService_IWindowForBindingUI); 108 DEFINE_EXPECT(QueryService_IHttpSecurity); 109 DEFINE_EXPECT(BeginningTransaction); 110 DEFINE_EXPECT(OnResponse); 111 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2); 112 DEFINE_EXPECT(GetRootSecurityId); 113 DEFINE_EXPECT(GetBindInfo); 114 DEFINE_EXPECT(GetBindInfoEx); 115 DEFINE_EXPECT(OnStartBinding); 116 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE); 117 DEFINE_EXPECT(OnProgress_CONNECTING); 118 DEFINE_EXPECT(OnProgress_REDIRECTING); 119 DEFINE_EXPECT(OnProgress_SENDINGREQUEST); 120 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE); 121 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA); 122 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA); 123 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA); 124 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE); 125 DEFINE_EXPECT(OnStopBinding); 126 DEFINE_EXPECT(OnDataAvailable); 127 DEFINE_EXPECT(OnObjectAvailable); 128 DEFINE_EXPECT(Obj_OnStartBinding); 129 DEFINE_EXPECT(Obj_OnStopBinding); 130 DEFINE_EXPECT(Obj_GetBindInfo); 131 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA); 132 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA); 133 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST); 134 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE); 135 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE); 136 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION); 137 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION); 138 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE); 139 DEFINE_EXPECT(Obj_OnProgress_CONNECTING); 140 DEFINE_EXPECT(Obj_OnProgress_REDIRECTING); 141 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 142 DEFINE_EXPECT(Start); 143 DEFINE_EXPECT(Read); 144 DEFINE_EXPECT(LockRequest); 145 DEFINE_EXPECT(Terminate); 146 DEFINE_EXPECT(UnlockRequest); 147 DEFINE_EXPECT(Continue); 148 DEFINE_EXPECT(Abort); 149 DEFINE_EXPECT(CreateInstance); 150 DEFINE_EXPECT(Load); 151 DEFINE_EXPECT(PutProperty_MIMETYPEPROP); 152 DEFINE_EXPECT(PutProperty_CLASSIDPROP); 153 DEFINE_EXPECT(SetPriority); 154 DEFINE_EXPECT(GetWindow_IHttpSecurity); 155 DEFINE_EXPECT(GetWindow_IWindowForBindingUI); 156 DEFINE_EXPECT(GetWindow_ICodeInstall); 157 DEFINE_EXPECT(OnSecurityProblem); 158 159 static const WCHAR winetest_data_urlW[] = 160 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/', 161 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0}; 162 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; 163 164 static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0}; 165 166 static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 }; 167 168 static const WCHAR wszWineHQSite[] = 169 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0}; 170 static const WCHAR wszWineHQIP[] = 171 {'2','0','9','.','3','2','.','1','4','1','.','3',0}; 172 static const CHAR wszIndexHtmlA[] = "index.html"; 173 static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0}; 174 static const CHAR dwl_htmlA[] = "dwl.html"; 175 static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0}; 176 static const CHAR test_txtA[] = "test.txt"; 177 static const WCHAR emptyW[] = {0}; 178 179 static BOOL stopped_binding = FALSE, stopped_obj_binding = FALSE, emulate_protocol = FALSE, 180 data_available = FALSE, http_is_first = TRUE, bind_to_object = FALSE, filedwl_api, post_test; 181 static DWORD read = 0, bindf = 0, prot_state = 0, thread_id, tymed, security_problem; 182 static const WCHAR *reported_url; 183 static CHAR mime_type[512]; 184 static IInternetProtocolSink *protocol_sink = NULL; 185 static IBinding *current_binding; 186 static HANDLE complete_event, complete_event2; 187 static HRESULT binding_hres; 188 static HRESULT onsecurityproblem_hres; 189 static HRESULT abort_hres; 190 static BOOL have_IHttpNegotiate2, use_bscex, is_async_prot; 191 static BOOL test_redirect, use_cache_file, callback_read, no_callback, test_abort; 192 static WCHAR cache_file_name[MAX_PATH]; 193 static BOOL only_check_prot_args = FALSE; 194 static BOOL invalid_cn_accepted = FALSE; 195 static BOOL abort_start = FALSE; 196 static BOOL abort_progress = FALSE; 197 static BOOL async_switch = FALSE; 198 static BOOL strict_bsc_qi; 199 static DWORD bindtest_flags; 200 static const char *test_file; 201 202 static WCHAR file_url[INTERNET_MAX_URL_LENGTH], current_url[INTERNET_MAX_URL_LENGTH]; 203 204 static enum { 205 HTTP_TEST, 206 ABOUT_TEST, 207 FILE_TEST, 208 ITS_TEST, 209 MK_TEST, 210 HTTPS_TEST, 211 FTP_TEST, 212 WINETEST_TEST, 213 WINETEST_SYNC_TEST 214 } test_protocol; 215 216 static enum { 217 BEFORE_DOWNLOAD, 218 DOWNLOADING, 219 END_DOWNLOAD 220 } download_state; 221 222 static BOOL proxy_active(void) 223 { 224 HKEY internet_settings; 225 DWORD proxy_enable; 226 DWORD size; 227 228 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 229 0, KEY_QUERY_VALUE, &internet_settings) != ERROR_SUCCESS) 230 return FALSE; 231 232 size = sizeof(DWORD); 233 if (RegQueryValueExA(internet_settings, "ProxyEnable", NULL, NULL, (LPBYTE) &proxy_enable, &size) != ERROR_SUCCESS) 234 proxy_enable = 0; 235 236 RegCloseKey(internet_settings); 237 238 return proxy_enable != 0; 239 } 240 241 static BOOL is_urlmon_protocol(int prot) 242 { 243 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST; 244 } 245 246 static void test_CreateURLMoniker(LPCWSTR url1, LPCWSTR url2) 247 { 248 HRESULT hr; 249 IMoniker *mon1 = NULL; 250 IMoniker *mon2 = NULL; 251 252 hr = CreateURLMoniker(NULL, NULL, NULL); 253 ok(hr == E_INVALIDARG, 254 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr); 255 256 mon1 = (IMoniker *)0xdeadbeef; 257 hr = CreateURLMoniker(NULL, NULL, &mon1); 258 ok(hr == E_INVALIDARG, 259 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr); 260 ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1); 261 262 hr = CreateURLMoniker(NULL, emptyW, NULL); 263 ok(hr == E_INVALIDARG, 264 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr); 265 266 hr = CreateURLMoniker(NULL, emptyW, &mon1); 267 ok(hr == S_OK || 268 broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */ 269 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr); 270 if(mon1) IMoniker_Release(mon1); 271 272 hr = CreateURLMoniker(NULL, url1, &mon1); 273 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr); 274 if(hr == S_OK) { 275 hr = CreateURLMoniker(mon1, url2, &mon2); 276 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr); 277 } 278 if(mon1) IMoniker_Release(mon1); 279 if(mon2) IMoniker_Release(mon2); 280 } 281 282 static void test_create(void) 283 { 284 static const WCHAR relativeW[] = {'a','/','b','.','t','x','t',0}; 285 IStream *stream; 286 IMoniker *mon; 287 IBindCtx *bctx; 288 HRESULT hr; 289 290 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','s','/','d','a','t','a','.','p','h','p',0}; 291 292 test_CreateURLMoniker(winetest_data_urlW, TEST_PART_URL_1); 293 294 mon = (void*)0xdeadbeef; 295 hr = CreateURLMoniker(NULL, relativeW, &mon); 296 ok(hr == S_OK, "got 0x%08x\n", hr); 297 298 hr = CreateBindCtx(0, &bctx); 299 ok(hr == S_OK, "got 0x%08x\n", hr); 300 301 stream = (void*)0xdeadbeef; 302 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&stream); 303 todo_wine ok(hr == INET_E_UNKNOWN_PROTOCOL, "got 0x%08x\n", hr); 304 ok(stream == NULL, "got %p\n", stream); 305 306 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL); 307 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); 308 309 stream = (void*)0xdeadbeef; 310 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream); 311 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); 312 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */, 313 "got %p\n", stream); 314 315 IMoniker_Release(mon); 316 317 mon = (void*)0xdaedbeef; 318 hr = CreateURLMoniker(NULL, winetest_data_urlW, &mon); 319 ok(hr == S_OK, "got 0x%08x\n", hr); 320 321 stream = (void*)0xdeadbeef; 322 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream); 323 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); 324 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */, 325 "got %p\n", stream); 326 327 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL); 328 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); 329 330 IMoniker_Release(mon); 331 IBindCtx_Release(bctx); 332 } 333 334 static HRESULT WINAPI Priority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv) 335 { 336 ok(0, "unexpected call\n"); 337 return E_NOINTERFACE; 338 } 339 340 static ULONG WINAPI Priority_AddRef(IInternetPriority *iface) 341 { 342 return 2; 343 } 344 345 static ULONG WINAPI Priority_Release(IInternetPriority *iface) 346 { 347 return 1; 348 } 349 350 static HRESULT WINAPI Priority_SetPriority(IInternetPriority *iface, LONG nPriority) 351 { 352 CHECK_EXPECT(SetPriority); 353 ok(!nPriority, "nPriority = %d\n", nPriority); 354 return S_OK; 355 } 356 357 static HRESULT WINAPI Priority_GetPriority(IInternetPriority *iface, LONG *pnPriority) 358 { 359 ok(0, "unexpected call\n"); 360 return S_OK; 361 } 362 363 static const IInternetPriorityVtbl InternetPriorityVtbl = { 364 Priority_QueryInterface, 365 Priority_AddRef, 366 Priority_Release, 367 Priority_SetPriority, 368 Priority_GetPriority 369 }; 370 371 static IInternetPriority InternetPriority = { &InternetPriorityVtbl }; 372 373 static HRESULT WINAPI Protocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv) 374 { 375 static const IID IID_undocumentedIE10 = {0x7daf9908,0x8415,0x4005,{0x95,0xae,0xbd,0x27,0xf6,0xe3,0xdc,0x00}}; 376 377 *ppv = NULL; 378 379 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) { 380 *ppv = iface; 381 return S_OK; 382 } 383 384 if(IsEqualGUID(&IID_IInternetPriority, riid)) { 385 if(!is_urlmon_protocol(test_protocol)) 386 return E_NOINTERFACE; 387 388 *ppv = &InternetPriority; 389 return S_OK; 390 } 391 392 if(IsEqualGUID(&IID_IInternetProtocolEx, riid)) 393 return E_NOINTERFACE; /* TODO */ 394 395 if(IsEqualGUID(&IID_undocumentedIE10, riid)) { 396 trace("QI(%s)\n", wine_dbgstr_guid(riid)); 397 return E_NOINTERFACE; /* TODO */ 398 } 399 400 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid)); 401 return E_NOINTERFACE; 402 } 403 404 static ULONG WINAPI Protocol_AddRef(IInternetProtocol *iface) 405 { 406 return 2; 407 } 408 409 static ULONG WINAPI Protocol_Release(IInternetProtocol *iface) 410 { 411 return 1; 412 } 413 414 static void test_switch_fail(void) 415 { 416 IInternetProtocolSink *binding_sink; 417 PROTOCOLDATA protocoldata = {0}; 418 HRESULT hres; 419 420 static BOOL tested_switch_fail; 421 422 if(tested_switch_fail) 423 return; 424 425 tested_switch_fail = TRUE; 426 427 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink); 428 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres); 429 if(SUCCEEDED(hres)) { 430 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata); 431 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres); 432 IInternetProtocolSink_Release(binding_sink); 433 } 434 } 435 436 static DWORD WINAPI thread_proc(PVOID arg) 437 { 438 PROTOCOLDATA protocoldata = {0}; 439 HRESULT hres; 440 441 if(!no_callback) { 442 if(bind_to_object) 443 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE); 444 else 445 SET_EXPECT(OnProgress_FINDINGRESOURCE); 446 } 447 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 448 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite); 449 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 450 if(!no_callback) { 451 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 452 if(bind_to_object) 453 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE); 454 else 455 CHECK_CALLED(OnProgress_FINDINGRESOURCE); 456 } 457 458 if(!no_callback) { 459 if(bind_to_object) 460 SET_EXPECT(Obj_OnProgress_CONNECTING); 461 else 462 SET_EXPECT(OnProgress_CONNECTING); 463 } 464 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 465 BINDSTATUS_CONNECTING, wszWineHQIP); 466 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 467 if(!no_callback) { 468 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 469 if(bind_to_object) 470 CHECK_CALLED(Obj_OnProgress_CONNECTING); 471 else 472 CHECK_CALLED(OnProgress_CONNECTING); 473 } 474 475 if(!no_callback) { 476 if(bind_to_object) 477 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST); 478 else 479 SET_EXPECT(OnProgress_SENDINGREQUEST); 480 } 481 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 482 BINDSTATUS_SENDINGREQUEST, NULL); 483 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 484 if(!no_callback) { 485 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 486 if(bind_to_object) 487 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST); 488 else 489 CHECK_CALLED(OnProgress_SENDINGREQUEST); 490 } 491 492 if(test_redirect) { 493 if(bind_to_object) 494 SET_EXPECT(Obj_OnProgress_REDIRECTING); 495 else 496 SET_EXPECT(OnProgress_REDIRECTING); 497 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_REDIRECTING, winetest_data_urlW); 498 ok(hres == S_OK, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres); 499 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 500 if(bind_to_object) 501 CHECK_CALLED(Obj_OnProgress_REDIRECTING); 502 else 503 CHECK_CALLED(OnProgress_REDIRECTING); 504 } 505 506 test_switch_fail(); 507 508 SET_EXPECT(Continue); 509 prot_state = 1; 510 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata); 511 ok(hres == S_OK, "Switch failed: %08x\n", hres); 512 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 513 514 CHECK_CALLED(Continue); 515 CHECK_CALLED(Read); 516 if(bind_to_object) { 517 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE); 518 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA); 519 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE); 520 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION); 521 CHECK_CALLED(CreateInstance); 522 CHECK_CALLED(PutProperty_MIMETYPEPROP); 523 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP); 524 CHECK_CALLED(Load); 525 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION); 526 CHECK_CALLED(OnObjectAvailable); 527 CHECK_CALLED(Obj_OnStopBinding); 528 }else if(!no_callback) { 529 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 530 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 531 CHECK_CALLED(OnDataAvailable); 532 }else { 533 CHECK_CALLED(LockRequest); 534 } 535 536 SET_EXPECT(Continue); 537 prot_state = 2; 538 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata); 539 ok(hres == S_OK, "Switch failed: %08x\n", hres); 540 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 541 CHECK_CALLED(Continue); 542 if(test_abort) { 543 CHECK_CALLED(OnProgress_DOWNLOADINGDATA); 544 CHECK_CALLED(OnStopBinding); 545 SetEvent(complete_event2); 546 return 0; 547 }else { 548 CHECK_CALLED(Read); 549 if(!no_callback) { 550 CHECK_CALLED(OnProgress_DOWNLOADINGDATA); 551 CHECK_CALLED(OnDataAvailable); 552 } 553 } 554 555 SET_EXPECT(Continue); 556 prot_state = 2; 557 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata); 558 ok(hres == S_OK, "Switch failed: %08x\n", hres); 559 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 560 CHECK_CALLED(Continue); 561 CHECK_CALLED(Read); 562 if(!no_callback) { 563 CHECK_CALLED(OnProgress_DOWNLOADINGDATA); 564 CHECK_CALLED(OnDataAvailable); 565 } 566 567 SET_EXPECT(Continue); 568 prot_state = 3; 569 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata); 570 ok(hres == S_OK, "Switch failed: %08x\n", hres); 571 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 572 CHECK_CALLED(Continue); 573 CHECK_CALLED(Read); 574 if(!no_callback) { 575 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA); 576 CHECK_CALLED(OnDataAvailable); 577 CHECK_CALLED(OnStopBinding); 578 } 579 580 SET_EXPECT(Read); 581 582 SetEvent(complete_event2); 583 return 0; 584 } 585 586 static HRESULT WINAPI Protocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, 587 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo, 588 DWORD grfPI, HANDLE_PTR dwReserved) 589 { 590 BINDINFO bindinfo; 591 DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION; 592 HRESULT hres; 593 594 static const STGMEDIUM stgmed_zero = {0}; 595 static const SECURITY_ATTRIBUTES sa_zero = {0}; 596 597 CHECK_EXPECT(Start); 598 599 read = 0; 600 601 reported_url = szUrl; 602 if(!filedwl_api) /* FIXME */ 603 ok(szUrl && !lstrcmpW(szUrl, current_url), "wrong url %s\n", wine_dbgstr_w(szUrl)); 604 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n"); 605 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n"); 606 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI); 607 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved); 608 609 if(!filedwl_api && binding_hres != S_OK) { 610 SET_EXPECT(OnStopBinding); 611 SET_EXPECT(Terminate); 612 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL); 613 ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 614 CHECK_CALLED(OnStopBinding); 615 CHECK_CALLED(Terminate); 616 617 return S_OK; 618 } 619 620 memset(&bindinfo, 0, sizeof(bindinfo)); 621 bindinfo.cbSize = 0; 622 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo); 623 ok(hres == E_INVALIDARG, "GetBindInfo returned: %08x, expected E_INVALIDARG\n", hres); 624 625 memset(&bindinfo, 0, sizeof(bindinfo)); 626 bindinfo.cbSize = sizeof(bindinfo); 627 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo); 628 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 629 630 ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n"); 631 632 if(filedwl_api || !is_urlmon_protocol(test_protocol) || tymed != TYMED_ISTREAM || 633 !(bindf&BINDF_ASYNCSTORAGE) || !(bindf&BINDF_PULLDATA)) 634 ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n"); 635 else if(test_protocol != MK_TEST) /* IE10 sets BINDF_NEEDFILE for mk: protocol */ 636 ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n"); 637 638 bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON); 639 if(filedwl_api || no_callback) 640 ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info); 641 else 642 ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n", 643 bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON))); 644 645 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize); 646 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo); 647 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n"); 648 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF); 649 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb); 650 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb); 651 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData); 652 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions); 653 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags); 654 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage); 655 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n"); 656 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n"); 657 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk); 658 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved); 659 660 if(only_check_prot_args) 661 return E_FAIL; 662 663 switch(test_protocol) { 664 case MK_TEST: 665 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, 666 BINDSTATUS_DIRECTBIND, NULL); 667 ok(hres == S_OK, 668 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres); 669 670 case FILE_TEST: 671 case ITS_TEST: 672 if(bind_to_object) 673 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST); 674 else 675 SET_EXPECT(OnProgress_SENDINGREQUEST); 676 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, 677 BINDSTATUS_SENDINGREQUEST, emptyW); 678 ok(hres == S_OK, 679 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres); 680 if(bind_to_object) 681 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST); 682 else 683 CHECK_CALLED(OnProgress_SENDINGREQUEST); 684 case WINETEST_SYNC_TEST: 685 IInternetProtocolSink_AddRef(pOIProtSink); 686 protocol_sink = pOIProtSink; 687 default: 688 break; 689 } 690 691 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) { 692 IServiceProvider *service_provider; 693 IHttpNegotiate *http_negotiate; 694 IHttpNegotiate2 *http_negotiate2; 695 IHttpSecurity *http_security; 696 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256]; 697 LPWSTR additional_headers = (LPWSTR)0xdeadbeef; 698 BYTE sec_id[100]; 699 DWORD fetched = 256, size = 100; 700 DWORD tid; 701 702 static const WCHAR wszMimes[] = {'*','/','*',0}; 703 704 SET_EXPECT(QueryService_IInternetBindInfo); 705 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT, 706 &ua, 1, &fetched); 707 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */ 708 709 ok(hres == E_NOINTERFACE, 710 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres); 711 ok(fetched == 256, "fetched = %d, expected 254\n", fetched); 712 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua); 713 714 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES, 715 accept_mimes, 256, &fetched); 716 ok(hres == S_OK, 717 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres); 718 ok(fetched == 1, "fetched = %d, expected 1\n", fetched); 719 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n"); 720 CoTaskMemFree(accept_mimes[0]); 721 722 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES, 723 NULL, 256, &fetched); 724 ok(hres == E_INVALIDARG, 725 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres); 726 727 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES, 728 accept_mimes, 256, NULL); 729 ok(hres == E_INVALIDARG, 730 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres); 731 732 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider, 733 (void**)&service_provider); 734 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres); 735 736 SET_EXPECT(QueryInterface_IHttpNegotiate); 737 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, 738 &IID_IHttpNegotiate, (void**)&http_negotiate); 739 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */ 740 ok(hres == S_OK, "QueryService failed: %08x\n", hres); 741 742 if(!no_callback) { 743 SET_EXPECT(BeginningTransaction); 744 SET_EXPECT(QueryInterface_IHttpNegotiate); 745 } 746 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, current_url, 747 NULL, 0, &additional_headers); 748 if(!no_callback) { 749 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); 750 CHECK_CALLED(BeginningTransaction); 751 } 752 IHttpNegotiate_Release(http_negotiate); 753 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres); 754 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers); 755 756 SET_EXPECT(QueryInterface_IHttpNegotiate2); 757 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2, 758 &IID_IHttpNegotiate2, (void**)&http_negotiate2); 759 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */ 760 ok(hres == S_OK, "QueryService failed: %08x\n", hres); 761 762 size = 512; 763 if(!no_callback) { 764 SET_EXPECT(QueryInterface_IHttpNegotiate2); 765 SET_EXPECT(GetRootSecurityId); 766 } 767 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0); 768 if(!no_callback) { 769 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); 770 CHECK_CALLED(GetRootSecurityId); 771 } 772 IHttpNegotiate2_Release(http_negotiate2); 773 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres); 774 ok(size == (no_callback ? 512 : 13), "size=%d\n", size); 775 776 if(!no_callback) { 777 SET_EXPECT(QueryService_IHttpSecurity); 778 SET_EXPECT(QueryInterface_IHttpSecurity); 779 } 780 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpSecurity, 781 &IID_IHttpSecurity, (void**)&http_security); 782 ok(hres == (no_callback ? E_NOINTERFACE : S_OK), "QueryService failed: 0x%08x\n", hres); 783 if(!no_callback) { 784 CHECK_CALLED(QueryService_IHttpSecurity); 785 CHECK_CALLED(QueryInterface_IHttpSecurity); 786 } 787 788 IServiceProvider_Release(service_provider); 789 790 IInternetProtocolSink_AddRef(pOIProtSink); 791 protocol_sink = pOIProtSink; 792 793 if(async_switch) { 794 PROTOCOLDATA data; 795 796 memset(&data, 0, sizeof(data)); 797 data.grfFlags = PI_FORCE_ASYNC; 798 prot_state = 0; 799 hres = IInternetProtocolSink_Switch(pOIProtSink, &data); 800 ok(hres == S_OK, "Switch failed: %08x\n", hres); 801 SET_EXPECT(Continue); 802 SetEvent(complete_event2); 803 return E_PENDING; 804 } else { 805 CreateThread(NULL, 0, thread_proc, NULL, 0, &tid); 806 return S_OK; 807 } 808 } 809 810 if(test_protocol == FILE_TEST) { 811 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, 812 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+7); 813 ok(hres == S_OK, 814 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres); 815 816 if(bind_to_object) 817 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE); 818 else 819 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 820 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, 821 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml); 822 ok(hres == S_OK, 823 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres); 824 if(bind_to_object) 825 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE); 826 else 827 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 828 }else if(test_protocol == WINETEST_SYNC_TEST) { 829 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 830 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml); 831 ok(hres == S_OK, 832 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres); 833 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 834 }else { 835 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml); 836 ok(hres == S_OK, 837 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres); 838 } 839 840 if(test_protocol == ABOUT_TEST) 841 bscf |= BSCF_DATAFULLYAVAILABLE; 842 if(test_protocol == ITS_TEST) 843 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE; 844 845 SET_EXPECT(Read); 846 if(bind_to_object) { 847 if(test_protocol != FILE_TEST && test_protocol != MK_TEST && test_protocol != WINETEST_SYNC_TEST) 848 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE); 849 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA); 850 if(test_protocol == FILE_TEST) 851 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 852 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA); 853 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE); 854 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION); 855 SET_EXPECT(CreateInstance); 856 SET_EXPECT(PutProperty_MIMETYPEPROP); 857 SET_EXPECT(PutProperty_CLASSIDPROP); 858 SET_EXPECT(Load); 859 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION); 860 SET_EXPECT(OnObjectAvailable); 861 SET_EXPECT(Obj_OnStopBinding); 862 }else { 863 if(test_protocol != FILE_TEST && test_protocol != MK_TEST) 864 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 865 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 866 if(test_protocol == FILE_TEST) 867 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE); 868 SET_EXPECT(OnProgress_ENDDOWNLOADDATA); 869 SET_EXPECT(LockRequest); 870 if(!filedwl_api) 871 SET_EXPECT(OnDataAvailable); 872 if(test_protocol != WINETEST_SYNC_TEST) /* Set in Read after ReportResult call */ 873 SET_EXPECT(OnStopBinding); 874 } 875 876 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13); 877 ok(hres == S_OK, "ReportData failed: %08x\n", hres); 878 879 CHECK_CALLED(Read); 880 if(bind_to_object) { 881 if(test_protocol != FILE_TEST && test_protocol != MK_TEST) 882 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE); 883 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA); 884 if(test_protocol == FILE_TEST) 885 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 886 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA); 887 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE); 888 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION); 889 CHECK_CALLED(CreateInstance); 890 CHECK_CALLED(PutProperty_MIMETYPEPROP); 891 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP); 892 CHECK_CALLED(Load); 893 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION); 894 CHECK_CALLED(OnObjectAvailable); 895 CHECK_CALLED(Obj_OnStopBinding); 896 }else { 897 if(test_protocol != FILE_TEST && test_protocol != MK_TEST && test_protocol != WINETEST_SYNC_TEST) 898 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 899 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 900 if(test_protocol == FILE_TEST) 901 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE); 902 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA); 903 CHECK_CALLED(LockRequest); 904 if(!filedwl_api) 905 CHECK_CALLED(OnDataAvailable); 906 CHECK_CALLED(OnStopBinding); 907 } 908 909 if(test_protocol == ITS_TEST) { 910 SET_EXPECT(Read); 911 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL); 912 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres); 913 CHECK_CALLED(Read); 914 }else if(!bind_to_object && test_protocol == FILE_TEST) { 915 SET_EXPECT(Read); 916 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13); 917 ok(hres == S_OK, "ReportData failed: %08x\n", hres); 918 CHECK_CALLED(Read); 919 } 920 921 if(test_protocol != WINETEST_SYNC_TEST) { 922 SET_EXPECT(Terminate); 923 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL); 924 ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 925 CHECK_CALLED(Terminate); 926 } 927 928 return S_OK; 929 } 930 931 static HRESULT WINAPI Protocol_Continue(IInternetProtocol *iface, 932 PROTOCOLDATA *pProtocolData) 933 { 934 DWORD bscf = 0; 935 HRESULT hres; 936 937 CHECK_EXPECT(Continue); 938 939 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 940 941 if(!bind_to_object) 942 ok(reported_url && !lstrcmpW(reported_url, current_url), "wrong url %s\n", wine_dbgstr_w(reported_url)); 943 944 ok(pProtocolData != NULL, "pProtocolData == NULL\n"); 945 if(!pProtocolData) 946 return S_OK; 947 948 switch(prot_state) { 949 case 0: 950 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 951 BINDSTATUS_SENDINGREQUEST, NULL); 952 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres); 953 954 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 955 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml); 956 ok(hres == S_OK, 957 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres); 958 959 bscf |= BSCF_FIRSTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION; 960 break; 961 case 1: { 962 IServiceProvider *service_provider; 963 IHttpNegotiate *http_negotiate; 964 static const WCHAR header[] = {'?',0}; 965 966 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider, 967 (void**)&service_provider); 968 ok(hres == S_OK, "Could not get IServiceProvicder\n"); 969 970 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate, 971 &IID_IHttpNegotiate, (void**)&http_negotiate); 972 ok(hres == S_OK, "Could not get IHttpNegotiate\n"); 973 974 if(!no_callback) { 975 SET_EXPECT(QueryInterface_IHttpNegotiate); 976 SET_EXPECT(OnResponse); 977 } 978 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL); 979 if(!no_callback) { 980 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); 981 CHECK_CALLED(OnResponse); 982 } 983 IHttpNegotiate_Release(http_negotiate); 984 ok(hres == S_OK, "OnResponse failed: %08x\n", hres); 985 986 if(test_protocol == HTTPS_TEST || test_redirect) { 987 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL); 988 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres); 989 } 990 991 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 992 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml); 993 ok(hres == S_OK, 994 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres); 995 996 hres = IInternetProtocolSink_ReportProgress(protocol_sink, 997 BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW); 998 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres); 999 1000 bscf |= BSCF_FIRSTDATANOTIFICATION; 1001 break; 1002 } 1003 case 2: 1004 case 3: 1005 bscf = BSCF_INTERMEDIATEDATANOTIFICATION; 1006 break; 1007 } 1008 1009 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400); 1010 ok(hres == S_OK, "ReportData failed: %08x\n", hres); 1011 1012 if(prot_state != 2 || !test_abort) 1013 SET_EXPECT(Read); 1014 switch(prot_state) { 1015 case 0: 1016 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL); 1017 ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1018 SET_EXPECT(OnProgress_SENDINGREQUEST); 1019 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 1020 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 1021 SET_EXPECT(LockRequest); 1022 SET_EXPECT(OnStopBinding); 1023 break; 1024 case 1: 1025 if(bind_to_object) { 1026 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE); 1027 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA); 1028 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE); 1029 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION); 1030 SET_EXPECT(CreateInstance); 1031 SET_EXPECT(PutProperty_MIMETYPEPROP); 1032 SET_EXPECT(PutProperty_CLASSIDPROP); 1033 SET_EXPECT(Load); 1034 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION); 1035 SET_EXPECT(OnObjectAvailable); 1036 SET_EXPECT(Obj_OnStopBinding); 1037 }else if(!no_callback) { 1038 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 1039 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 1040 SET_EXPECT(LockRequest); 1041 }else { 1042 SET_EXPECT(LockRequest); 1043 } 1044 break; 1045 case 2: 1046 if(!no_callback) 1047 SET_EXPECT(OnProgress_DOWNLOADINGDATA); 1048 break; 1049 case 3: 1050 SET_EXPECT(OnProgress_DOWNLOADINGDATA); 1051 SET_EXPECT(OnProgress_ENDDOWNLOADDATA); 1052 } 1053 if(!no_callback) { 1054 if((!bind_to_object || prot_state >= 2) && (!test_abort || prot_state != 2)) 1055 SET_EXPECT(OnDataAvailable); 1056 if(prot_state == 3 || (test_abort && prot_state == 2)) 1057 SET_EXPECT(OnStopBinding); 1058 } 1059 return S_OK; 1060 } 1061 1062 static HRESULT WINAPI Protocol_Abort(IInternetProtocol *iface, HRESULT hrReason, 1063 DWORD dwOptions) 1064 { 1065 HRESULT hres; 1066 1067 CHECK_EXPECT(Abort); 1068 1069 ok(hrReason == E_ABORT, "hrReason = %08x\n", hrReason); 1070 ok(!dwOptions, "dwOptions = %x\n", dwOptions); 1071 1072 hres = IInternetProtocolSink_ReportResult(protocol_sink, E_ABORT, ERROR_SUCCESS, NULL); 1073 ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1074 1075 return S_OK; 1076 } 1077 1078 static HRESULT WINAPI Protocol_Terminate(IInternetProtocol *iface, DWORD dwOptions) 1079 { 1080 CHECK_EXPECT(Terminate); 1081 1082 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions); 1083 1084 if(protocol_sink) { 1085 IInternetProtocolSink_Release(protocol_sink); 1086 protocol_sink = NULL; 1087 } 1088 1089 if(no_callback) 1090 SetEvent(complete_event); 1091 return S_OK; 1092 } 1093 1094 static HRESULT WINAPI Protocol_Suspend(IInternetProtocol *iface) 1095 { 1096 ok(0, "unexpected call\n"); 1097 return E_NOTIMPL; 1098 } 1099 1100 static HRESULT WINAPI Protocol_Resume(IInternetProtocol *iface) 1101 { 1102 ok(0, "unexpected call\n"); 1103 return E_NOTIMPL; 1104 } 1105 1106 static HRESULT WINAPI Protocol_Read(IInternetProtocol *iface, void *pv, 1107 ULONG cb, ULONG *pcbRead) 1108 { 1109 HRESULT hres; 1110 1111 static const char data[] = "<HTML></HTML>"; 1112 1113 CHECK_EXPECT2(Read); 1114 1115 ok(pv != NULL, "pv == NULL\n"); 1116 ok(cb != 0, "cb == 0\n"); 1117 ok(pcbRead != NULL, "pcbRead == NULL\n"); 1118 1119 if(async_switch) { 1120 if(prot_state++ > 1) { 1121 *pcbRead = 0; 1122 return S_FALSE; 1123 } else { 1124 memset(pv, '?', cb); 1125 *pcbRead = cb; 1126 return S_OK; 1127 } 1128 } 1129 1130 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) { 1131 static BOOL pending = TRUE; 1132 1133 pending = !pending; 1134 1135 switch(prot_state) { 1136 case 1: 1137 case 2: 1138 if(pending) { 1139 *pcbRead = 10; 1140 memset(pv, '?', 10); 1141 if(prot_state == 2 && no_callback) 1142 SetEvent(complete_event); 1143 return E_PENDING; 1144 }else { 1145 memset(pv, '?', cb); 1146 *pcbRead = cb; 1147 read++; 1148 return S_OK; 1149 } 1150 case 3: 1151 prot_state++; 1152 1153 *pcbRead = 0; 1154 1155 hres = IInternetProtocolSink_ReportData(protocol_sink, 1156 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000); 1157 ok(hres == S_OK, "ReportData failed: %08x\n", hres); 1158 1159 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL); 1160 ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1161 1162 return S_FALSE; 1163 case 4: 1164 *pcbRead = 0; 1165 return S_FALSE; 1166 } 1167 } 1168 1169 if(read) { 1170 *pcbRead = 0; 1171 return S_FALSE; 1172 } 1173 1174 if(test_protocol == WINETEST_SYNC_TEST) { 1175 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL); 1176 ok(hres == S_OK, "ReportResult failed: %08x\n", hres); 1177 1178 SET_EXPECT(OnStopBinding); 1179 } 1180 1181 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead); 1182 read += *pcbRead = sizeof(data)-1; 1183 memcpy(pv, data, sizeof(data)); 1184 return S_OK; 1185 } 1186 1187 static HRESULT WINAPI Protocol_Seek(IInternetProtocol *iface, 1188 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) 1189 { 1190 ok(0, "unexpected call\n"); 1191 return E_NOTIMPL; 1192 } 1193 1194 static HRESULT WINAPI Protocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions) 1195 { 1196 CHECK_EXPECT(LockRequest); 1197 if(no_callback) 1198 SetEvent(complete_event); 1199 return S_OK; 1200 } 1201 1202 static HRESULT WINAPI Protocol_UnlockRequest(IInternetProtocol *iface) 1203 { 1204 CHECK_EXPECT(UnlockRequest); 1205 return S_OK; 1206 } 1207 1208 static const IInternetProtocolVtbl ProtocolVtbl = { 1209 Protocol_QueryInterface, 1210 Protocol_AddRef, 1211 Protocol_Release, 1212 Protocol_Start, 1213 Protocol_Continue, 1214 Protocol_Abort, 1215 Protocol_Terminate, 1216 Protocol_Suspend, 1217 Protocol_Resume, 1218 Protocol_Read, 1219 Protocol_Seek, 1220 Protocol_LockRequest, 1221 Protocol_UnlockRequest 1222 }; 1223 1224 static IInternetProtocol Protocol = { &ProtocolVtbl }; 1225 1226 static HRESULT WINAPI HttpNegotiate_QueryInterface(IHttpNegotiate2 *iface, REFIID riid, void **ppv) 1227 { 1228 if(IsEqualGUID(&IID_IUnknown, riid) 1229 || IsEqualGUID(&IID_IHttpNegotiate, riid) 1230 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) { 1231 *ppv = iface; 1232 return S_OK; 1233 } 1234 1235 ok(0, "unexpected call\n"); 1236 return E_NOINTERFACE; 1237 } 1238 1239 static ULONG WINAPI HttpNegotiate_AddRef(IHttpNegotiate2 *iface) 1240 { 1241 return 2; 1242 } 1243 1244 static ULONG WINAPI HttpNegotiate_Release(IHttpNegotiate2 *iface) 1245 { 1246 return 1; 1247 } 1248 1249 static HRESULT WINAPI HttpNegotiate_BeginningTransaction(IHttpNegotiate2 *iface, LPCWSTR szURL, 1250 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders) 1251 { 1252 if(onsecurityproblem_hres == S_OK) 1253 CHECK_EXPECT2(BeginningTransaction); 1254 else 1255 CHECK_EXPECT(BeginningTransaction); 1256 1257 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1258 1259 ok(!lstrcmpW(szURL, current_url), "szURL != current_url\n"); 1260 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved); 1261 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n"); 1262 if(pszAdditionalHeaders) 1263 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n"); 1264 1265 return S_OK; 1266 } 1267 1268 static HRESULT WINAPI HttpNegotiate_OnResponse(IHttpNegotiate2 *iface, DWORD dwResponseCode, 1269 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders) 1270 { 1271 CHECK_EXPECT(OnResponse); 1272 1273 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1274 1275 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode); 1276 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n"); 1277 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n"); 1278 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */ 1279 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n"); 1280 if(pszAdditionalRequestHeaders) 1281 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n"); 1282 1283 return S_OK; 1284 } 1285 1286 static HRESULT WINAPI HttpNegotiate_GetRootSecurityId(IHttpNegotiate2 *iface, 1287 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved) 1288 { 1289 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0}; 1290 1291 CHECK_EXPECT(GetRootSecurityId); 1292 1293 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1294 1295 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved); 1296 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n"); 1297 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n"); 1298 1299 if(pbSecurityId == (void*)0xdeadbeef) 1300 return E_NOTIMPL; 1301 1302 if(pcbSecurityId) { 1303 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId); 1304 *pcbSecurityId = sizeof(sec_id); 1305 } 1306 1307 if(pbSecurityId) 1308 memcpy(pbSecurityId, sec_id, sizeof(sec_id)); 1309 1310 return E_FAIL; 1311 } 1312 1313 static IHttpNegotiate2Vtbl HttpNegotiateVtbl = { 1314 HttpNegotiate_QueryInterface, 1315 HttpNegotiate_AddRef, 1316 HttpNegotiate_Release, 1317 HttpNegotiate_BeginningTransaction, 1318 HttpNegotiate_OnResponse, 1319 HttpNegotiate_GetRootSecurityId 1320 }; 1321 1322 static IHttpNegotiate2 HttpNegotiate = { &HttpNegotiateVtbl }; 1323 1324 static HRESULT WINAPI HttpSecurity_QueryInterface(IHttpSecurity *iface, REFIID riid, void **ppv) 1325 { 1326 ok(0, "Unexpected call\n"); 1327 *ppv = NULL; 1328 if(IsEqualGUID(&IID_IHttpSecurity, riid) || 1329 IsEqualGUID(&IID_IWindowForBindingUI, riid) || 1330 IsEqualGUID(&IID_IUnknown, riid)) 1331 { 1332 *ppv = iface; 1333 return S_OK; 1334 } 1335 1336 ok(0, "Unexpected interface requested.\n"); 1337 1338 return E_NOINTERFACE; 1339 } 1340 1341 static ULONG WINAPI HttpSecurity_AddRef(IHttpSecurity *iface) 1342 { 1343 return 2; 1344 } 1345 1346 static ULONG WINAPI HttpSecurity_Release(IHttpSecurity *iface) 1347 { 1348 return 1; 1349 } 1350 1351 static HRESULT WINAPI HttpSecurity_GetWindow(IHttpSecurity *iface, REFGUID rguidReason, HWND *phwnd) 1352 { 1353 if(IsEqualGUID(rguidReason, &IID_IHttpSecurity)) 1354 CHECK_EXPECT(GetWindow_IHttpSecurity); 1355 else if(IsEqualGUID(rguidReason, &IID_IWindowForBindingUI)) 1356 CHECK_EXPECT2(GetWindow_IWindowForBindingUI); 1357 else if(IsEqualGUID(rguidReason, &IID_ICodeInstall)) 1358 CHECK_EXPECT(GetWindow_ICodeInstall); 1359 else 1360 ok(0, "Unexpected rguidReason: %s\n", wine_dbgstr_guid(rguidReason)); 1361 1362 *phwnd = NULL; 1363 return S_OK; 1364 } 1365 1366 static HRESULT WINAPI HttpSecurity_OnSecurityProblem(IHttpSecurity *iface, DWORD dwProblem) 1367 { 1368 CHECK_EXPECT(OnSecurityProblem); 1369 if(!security_problem) { 1370 ok(dwProblem == ERROR_INTERNET_SEC_CERT_CN_INVALID || 1371 broken(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) /* Some versions of IE6 */, 1372 "Got problem: %d\n", dwProblem); 1373 security_problem = dwProblem; 1374 1375 if(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) 1376 binding_hres = INET_E_SECURITY_PROBLEM; 1377 }else 1378 ok(dwProblem == security_problem, "Got problem: %d\n", dwProblem); 1379 1380 return onsecurityproblem_hres; 1381 } 1382 1383 static const IHttpSecurityVtbl HttpSecurityVtbl = { 1384 HttpSecurity_QueryInterface, 1385 HttpSecurity_AddRef, 1386 HttpSecurity_Release, 1387 HttpSecurity_GetWindow, 1388 HttpSecurity_OnSecurityProblem 1389 }; 1390 1391 static IHttpSecurity HttpSecurity = { &HttpSecurityVtbl }; 1392 1393 static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv) 1394 { 1395 ok(0, "unexpected call\n"); 1396 return E_NOINTERFACE; 1397 } 1398 1399 static ULONG WINAPI ServiceProvider_AddRef(IServiceProvider *iface) 1400 { 1401 return 2; 1402 } 1403 1404 static ULONG WINAPI ServiceProvider_Release(IServiceProvider *iface) 1405 { 1406 return 1; 1407 } 1408 1409 static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, 1410 REFGUID guidService, REFIID riid, void **ppv) 1411 { 1412 if(IsEqualGUID(&IID_IAuthenticate, guidService)) { 1413 CHECK_EXPECT(QueryService_IAuthenticate); 1414 return E_NOTIMPL; 1415 } 1416 1417 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) { 1418 CHECK_EXPECT2(QueryService_IInternetProtocol); 1419 return E_NOTIMPL; 1420 } 1421 1422 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) { 1423 CHECK_EXPECT(QueryService_IInternetBindInfo); 1424 return E_NOTIMPL; 1425 } 1426 1427 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) { 1428 CHECK_EXPECT2(QueryService_IWindowForBindingUI); 1429 *ppv = &HttpSecurity; 1430 return S_OK; 1431 } 1432 1433 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) { 1434 CHECK_EXPECT(QueryService_IHttpSecurity); 1435 *ppv = &HttpSecurity; 1436 return S_OK; 1437 } 1438 1439 if(IsEqualGUID(&IID_IGetBindHandle, guidService)) { 1440 trace("QueryService(IID_IGetBindHandle)\n"); 1441 *ppv = NULL; 1442 return E_NOINTERFACE; 1443 } 1444 1445 if(IsEqualGUID(&IID_undocumentedIE11, guidService)) { 1446 trace("QueryService(IID_undocumentedIE11)\n"); 1447 *ppv = NULL; 1448 return E_NOINTERFACE; 1449 } 1450 1451 ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService)); 1452 return E_NOINTERFACE; 1453 } 1454 1455 static IServiceProviderVtbl ServiceProviderVtbl = { 1456 ServiceProvider_QueryInterface, 1457 ServiceProvider_AddRef, 1458 ServiceProvider_Release, 1459 ServiceProvider_QueryService 1460 }; 1461 1462 static IServiceProvider ServiceProvider = { &ServiceProviderVtbl }; 1463 1464 static IBindStatusCallbackEx objbsc; 1465 1466 static void test_WinInetHttpInfo(IWinInetHttpInfo *http_info, DWORD progress) 1467 { 1468 DWORD status, size; 1469 HRESULT hres, expect; 1470 1471 /* QueryInfo changes its behavior during this request */ 1472 if(progress == BINDSTATUS_SENDINGREQUEST) 1473 return; 1474 1475 if(test_protocol==FTP_TEST && download_state==BEFORE_DOWNLOAD 1476 && progress!=BINDSTATUS_MIMETYPEAVAILABLE) 1477 expect = E_FAIL; 1478 else if(test_protocol == FTP_TEST) 1479 expect = S_FALSE; 1480 else 1481 expect = S_OK; 1482 1483 size = sizeof(DWORD); 1484 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER, 1485 &status, &size, NULL, NULL); 1486 ok(hres == expect || ((progress == BINDSTATUS_COOKIE_SENT || progress == BINDSTATUS_PROXYDETECTING) && hres == S_FALSE), 1487 "progress %u: hres = %x, expected %x\n", progress, hres, expect); 1488 if(hres == S_OK) { 1489 if(download_state == BEFORE_DOWNLOAD && progress != BINDSTATUS_MIMETYPEAVAILABLE && progress != BINDSTATUS_DECODING) 1490 ok(status == 0, "progress %u: status = %d\n", progress, status); 1491 else 1492 ok(status == HTTP_STATUS_OK, "progress %u: status = %d\n", progress, status); 1493 ok(size == sizeof(DWORD), "size = %d\n", size); 1494 } 1495 1496 size = sizeof(DWORD); 1497 hres = IWinInetHttpInfo_QueryOption(http_info, INTERNET_OPTION_HANDLE_TYPE, &status, &size); 1498 if(test_protocol == FTP_TEST) { 1499 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE) 1500 ok(hres == E_FAIL, "hres = %x\n", hres); 1501 else 1502 ok(hres == S_OK, "hres = %x\n", hres); 1503 1504 if(hres == S_OK) 1505 ok(status == INTERNET_HANDLE_TYPE_FTP_FILE, "status = %d\n", status); 1506 } else { 1507 ok(hres == S_OK, "hres = %x\n", hres); 1508 ok(status == INTERNET_HANDLE_TYPE_HTTP_REQUEST, "status = %d\n", status); 1509 } 1510 } 1511 1512 static HRESULT WINAPI statusclb_QueryInterface(IBindStatusCallbackEx *iface, REFIID riid, void **ppv) 1513 { 1514 static const IID IID_undocumentedIE10 = {0xf286fa56,0xc1fd,0x4270,{0x8e,0x67,0xb3,0xeb,0x79,0x0a,0x81,0xe8}}; 1515 1516 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1517 1518 if(IsEqualGUID(&IID_IInternetProtocol, riid)) { 1519 CHECK_EXPECT2(QueryInterface_IInternetProtocol); 1520 if(emulate_protocol) { 1521 *ppv = &Protocol; 1522 return S_OK; 1523 }else { 1524 return E_NOINTERFACE; 1525 } 1526 }else if (IsEqualGUID(&IID_IServiceProvider, riid)) { 1527 CHECK_EXPECT2(QueryInterface_IServiceProvider); 1528 *ppv = &ServiceProvider; 1529 return S_OK; 1530 }else if (IsEqualGUID(&IID_IHttpNegotiate, riid)) { 1531 CHECK_EXPECT2(QueryInterface_IHttpNegotiate); 1532 *ppv = &HttpNegotiate; 1533 return S_OK; 1534 }else if (IsEqualGUID(&IID_IHttpNegotiate2, riid)) { 1535 CHECK_EXPECT(QueryInterface_IHttpNegotiate2); 1536 *ppv = &HttpNegotiate; 1537 return S_OK; 1538 }else if (IsEqualGUID(&IID_IAuthenticate, riid)) { 1539 CHECK_EXPECT(QueryInterface_IAuthenticate); 1540 return E_NOINTERFACE; 1541 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) { 1542 if(strict_bsc_qi) 1543 CHECK_EXPECT2(QueryInterface_IBindStatusCallback); 1544 *ppv = iface; 1545 return S_OK; 1546 }else if(IsEqualGUID(&IID_IBindStatusCallbackHolder, riid)) { 1547 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder); 1548 return E_NOINTERFACE; 1549 }else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid)) { 1550 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx); 1551 if(!use_bscex) 1552 return E_NOINTERFACE; 1553 *ppv = iface; 1554 return S_OK; 1555 }else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) { 1556 /* TODO */ 1557 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) { 1558 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI); 1559 return E_NOINTERFACE; 1560 }else if(IsEqualGUID(&IID_IHttpSecurity, riid)) { 1561 CHECK_EXPECT2(QueryInterface_IHttpSecurity); 1562 return E_NOINTERFACE; 1563 }else if(IsEqualGUID(&IID_IGetBindHandle, riid)) { 1564 trace("QI(IID_IGetBindHandle)\n"); 1565 *ppv = NULL; 1566 return E_NOINTERFACE; 1567 }else if(IsEqualGUID(&IID_undocumentedIE10, riid)) { 1568 trace("QI(IID_undocumentedIE10)\n"); 1569 *ppv = NULL; 1570 return E_NOINTERFACE; 1571 }else if(IsEqualGUID(&IID_undocumentedIE11, riid)) { 1572 trace("QI(IID_undocumentedIE11)\n"); 1573 *ppv = NULL; 1574 return E_NOINTERFACE; 1575 }else { 1576 ok(0, "unexpected interface %s\n", wine_dbgstr_guid(riid)); 1577 } 1578 1579 return E_NOINTERFACE; 1580 } 1581 1582 static ULONG WINAPI statusclb_AddRef(IBindStatusCallbackEx *iface) 1583 { 1584 return 2; 1585 } 1586 1587 static ULONG WINAPI statusclb_Release(IBindStatusCallbackEx *iface) 1588 { 1589 return 1; 1590 } 1591 1592 static HRESULT WINAPI statusclb_OnStartBinding(IBindStatusCallbackEx *iface, DWORD dwReserved, 1593 IBinding *pib) 1594 { 1595 IWinInetHttpInfo *http_info; 1596 HRESULT hres; 1597 IMoniker *mon; 1598 DWORD res; 1599 CLSID clsid; 1600 LPOLESTR res_str; 1601 1602 if(iface == &objbsc) 1603 CHECK_EXPECT(Obj_OnStartBinding); 1604 else 1605 CHECK_EXPECT(OnStartBinding); 1606 1607 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1608 1609 ok(pib != NULL, "pib should not be NULL\n"); 1610 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved); 1611 1612 if(pib == (void*)0xdeadbeef) 1613 return S_OK; 1614 1615 current_binding = pib; 1616 1617 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon); 1618 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n"); 1619 if(SUCCEEDED(hres)) 1620 IMoniker_Release(mon); 1621 1622 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info); 1623 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres); 1624 1625 if(0) { /* crashes with native urlmon */ 1626 hres = IBinding_GetBindResult(pib, NULL, &res, &res_str, NULL); 1627 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres); 1628 } 1629 hres = IBinding_GetBindResult(pib, &clsid, NULL, &res_str, NULL); 1630 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres); 1631 hres = IBinding_GetBindResult(pib, &clsid, &res, NULL, NULL); 1632 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres); 1633 hres = IBinding_GetBindResult(pib, &clsid, &res, &res_str, (void*)0xdeadbeef); 1634 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres); 1635 1636 hres = IBinding_GetBindResult(pib, &clsid, &res, &res_str, NULL); 1637 ok(hres == S_OK, "GetBindResult failed: %08x, expected S_OK\n", hres); 1638 ok(IsEqualCLSID(&clsid, &CLSID_NULL), "incorrect clsid: %s\n", wine_dbgstr_guid(&clsid)); 1639 ok(!res, "incorrect res: %x\n", res); 1640 ok(!res_str, "incorrect res_str: %s\n", wine_dbgstr_w(res_str)); 1641 1642 if(abort_start) { 1643 binding_hres = abort_hres; 1644 return abort_hres; 1645 } 1646 1647 return S_OK; 1648 } 1649 1650 static HRESULT WINAPI statusclb_GetPriority(IBindStatusCallbackEx *iface, LONG *pnPriority) 1651 { 1652 ok(0, "unexpected call\n"); 1653 return E_NOTIMPL; 1654 } 1655 1656 static HRESULT WINAPI statusclb_OnLowResource(IBindStatusCallbackEx *iface, DWORD reserved) 1657 { 1658 ok(0, "unexpected call\n"); 1659 return E_NOTIMPL; 1660 } 1661 1662 static HRESULT WINAPI statusclb_OnProgress(IBindStatusCallbackEx *iface, ULONG ulProgress, 1663 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText) 1664 { 1665 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1666 1667 switch(ulStatusCode) { 1668 case BINDSTATUS_FINDINGRESOURCE: 1669 if(iface == &objbsc) 1670 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE); 1671 else if(test_protocol == FTP_TEST) 1672 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE); 1673 else if(test_protocol == HTTPS_TEST && !bindtest_flags) 1674 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE); 1675 else 1676 CHECK_EXPECT(OnProgress_FINDINGRESOURCE); 1677 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)) 1678 SetEvent(complete_event); 1679 break; 1680 case BINDSTATUS_CONNECTING: 1681 if(iface == &objbsc) 1682 CHECK_EXPECT(Obj_OnProgress_CONNECTING); 1683 else if(test_protocol == FTP_TEST) 1684 todo_wine CHECK_EXPECT(OnProgress_CONNECTING); 1685 else if(onsecurityproblem_hres == S_OK) 1686 CHECK_EXPECT2(OnProgress_CONNECTING); 1687 else 1688 CHECK_EXPECT(OnProgress_CONNECTING); 1689 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)) 1690 SetEvent(complete_event); 1691 break; 1692 case BINDSTATUS_REDIRECTING: 1693 if(iface == &objbsc) 1694 CHECK_EXPECT(Obj_OnProgress_REDIRECTING); 1695 else 1696 CHECK_EXPECT(OnProgress_REDIRECTING); 1697 ok(!lstrcmpW(szStatusText, winetest_data_urlW), "unexpected status text %s\n", 1698 wine_dbgstr_w(szStatusText)); 1699 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) 1700 && (!bind_to_object || iface == &objbsc)) 1701 SetEvent(complete_event); 1702 break; 1703 case BINDSTATUS_SENDINGREQUEST: 1704 if(iface == &objbsc) 1705 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST); 1706 else if(test_protocol == FTP_TEST) 1707 CHECK_EXPECT2(OnProgress_SENDINGREQUEST); 1708 else 1709 CHECK_EXPECT(OnProgress_SENDINGREQUEST); 1710 if(emulate_protocol && (test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST)) 1711 SetEvent(complete_event); 1712 1713 if(abort_progress) { 1714 if(filedwl_api) 1715 binding_hres = E_ABORT; 1716 return E_ABORT; 1717 } 1718 1719 break; 1720 case BINDSTATUS_MIMETYPEAVAILABLE: 1721 if(iface == &objbsc) 1722 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE); 1723 else 1724 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE); 1725 if(!bind_to_object) 1726 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n", 1727 download_state); 1728 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL); 1729 break; 1730 case BINDSTATUS_BEGINDOWNLOADDATA: 1731 if(iface == &objbsc) 1732 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA); 1733 else 1734 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA); 1735 ok(szStatusText != NULL, "szStatusText == NULL\n"); 1736 if(szStatusText) { 1737 if(filedwl_api) { 1738 /* FIXME */ 1739 }else { 1740 ok(!lstrcmpW(szStatusText, current_url), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText)); 1741 } 1742 } 1743 if(!bind_to_object) 1744 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n", 1745 download_state); 1746 download_state = DOWNLOADING; 1747 break; 1748 case BINDSTATUS_DOWNLOADINGDATA: 1749 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA); 1750 ok(iface != &objbsc, "unexpected call\n"); 1751 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n", 1752 download_state); 1753 if(test_abort) { 1754 HRESULT hres; 1755 1756 SET_EXPECT(Abort); 1757 hres = IBinding_Abort(current_binding); 1758 ok(hres == S_OK, "Abort failed: %08x\n", hres); 1759 CHECK_CALLED(Abort); 1760 1761 hres = IBinding_Abort(current_binding); 1762 ok(hres == E_FAIL, "Abort failed: %08x\n", hres); 1763 1764 binding_hres = E_ABORT; 1765 } 1766 break; 1767 case BINDSTATUS_ENDDOWNLOADDATA: 1768 if(iface == &objbsc) 1769 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA); 1770 else 1771 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA); 1772 ok(szStatusText != NULL, "szStatusText == NULL\n"); 1773 if(szStatusText) { 1774 if(filedwl_api) { 1775 /* FIXME */ 1776 }else { 1777 ok(!lstrcmpW(szStatusText, current_url), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText)); 1778 } 1779 } 1780 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n", 1781 download_state); 1782 download_state = END_DOWNLOAD; 1783 break; 1784 case BINDSTATUS_CACHEFILENAMEAVAILABLE: 1785 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST && test_protocol != WINETEST_TEST) { 1786 if(iface == &objbsc) 1787 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 1788 else 1789 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE); 1790 }else { /* FIXME */ 1791 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE); 1792 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 1793 } 1794 1795 ok(szStatusText != NULL, "szStatusText == NULL\n"); 1796 if(szStatusText && test_protocol == FILE_TEST) 1797 ok(!lstrcmpW(file_url+7, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText)); 1798 break; 1799 case BINDSTATUS_CLASSIDAVAILABLE: 1800 { 1801 CLSID clsid; 1802 HRESULT hr; 1803 if(iface != &objbsc) 1804 ok(0, "unexpected call\n"); 1805 else 1806 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE); 1807 hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid); 1808 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr); 1809 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument), 1810 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", wine_dbgstr_guid(&clsid)); 1811 break; 1812 } 1813 case BINDSTATUS_BEGINSYNCOPERATION: 1814 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION); 1815 if(iface != &objbsc) 1816 ok(0, "unexpected call\n"); 1817 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n"); 1818 break; 1819 case BINDSTATUS_ENDSYNCOPERATION: 1820 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION); 1821 if(iface != &objbsc) 1822 ok(0, "unexpected call\n"); 1823 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n"); 1824 break; 1825 case BINDSTATUS_PROXYDETECTING: 1826 trace("BINDSTATUS_PROXYDETECTING\n"); 1827 break; 1828 case BINDSTATUS_COOKIE_SENT: 1829 trace("BINDSTATUS_COOKIE_SENT\n"); 1830 break; 1831 case BINDSTATUS_DECODING: 1832 trace("BINDSTATUS_DECODING\n"); 1833 break; 1834 default: 1835 ok(0, "unexpected code %d\n", ulStatusCode); 1836 }; 1837 1838 if(current_binding) { 1839 IWinInetHttpInfo *http_info; 1840 HRESULT hres; 1841 1842 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info); 1843 if(!emulate_protocol && test_protocol != FILE_TEST && is_urlmon_protocol(test_protocol)) { 1844 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres); 1845 test_WinInetHttpInfo(http_info, ulStatusCode); 1846 } else 1847 ok(hres == E_NOINTERFACE, 1848 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres); 1849 if(SUCCEEDED(hres)) 1850 IWinInetHttpInfo_Release(http_info); 1851 } 1852 1853 return S_OK; 1854 } 1855 1856 static HRESULT WINAPI statusclb_OnStopBinding(IBindStatusCallbackEx *iface, HRESULT hresult, LPCWSTR szError) 1857 { 1858 if(iface == &objbsc) { 1859 CHECK_EXPECT(Obj_OnStopBinding); 1860 stopped_obj_binding = TRUE; 1861 }else { 1862 CHECK_EXPECT(OnStopBinding); 1863 stopped_binding = TRUE; 1864 } 1865 1866 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1867 1868 if(only_check_prot_args) { 1869 todo_wine ok(hresult == S_OK, "Got %08x\n", hresult); 1870 return S_OK; 1871 } 1872 1873 /* ignore DNS failure */ 1874 if (hresult == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED)) 1875 return S_OK; 1876 1877 if(filedwl_api) { 1878 if(!abort_progress && !abort_start) 1879 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult); 1880 else if(abort_start && abort_hres == E_NOTIMPL) 1881 todo_wine ok(hresult == S_FALSE, "binding failed: %08x, expected S_FALSE\n", hresult); 1882 else 1883 ok(hresult == E_ABORT, "binding failed: %08x, expected E_ABORT\n", hresult); 1884 } else 1885 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres); 1886 ok(szError == NULL, "szError should be NULL\n"); 1887 1888 if(current_binding) { 1889 CLSID clsid; 1890 DWORD res; 1891 LPOLESTR res_str; 1892 HRESULT hres; 1893 1894 hres = IBinding_GetBindResult(current_binding, &clsid, &res, &res_str, NULL); 1895 ok(hres == S_OK, "GetBindResult failed: %08x, expected S_OK\n", hres); 1896 ok(res == hresult, "res = %08x, expected %08x\n", res, binding_hres); 1897 ok(!res_str, "incorrect res_str = %s\n", wine_dbgstr_w(res_str)); 1898 1899 if(hresult==S_OK || (abort_start && hresult!=S_FALSE) || hresult == REGDB_E_CLASSNOTREG) { 1900 ok(IsEqualCLSID(&clsid, &CLSID_NULL), 1901 "incorrect protocol CLSID: %s, expected CLSID_NULL\n", 1902 wine_dbgstr_guid(&clsid)); 1903 }else if(emulate_protocol) { 1904 todo_wine ok(IsEqualCLSID(&clsid, &CLSID_FtpProtocol), 1905 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n", 1906 wine_dbgstr_guid(&clsid)); 1907 }else if(test_protocol == FTP_TEST) { 1908 ok(IsEqualCLSID(&clsid, &CLSID_FtpProtocol), 1909 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n", 1910 wine_dbgstr_guid(&clsid)); 1911 }else if(test_protocol == FILE_TEST) { 1912 ok(IsEqualCLSID(&clsid, &CLSID_FileProtocol), 1913 "incorrect protocol CLSID: %s, expected CLSID_FileProtocol\n", 1914 wine_dbgstr_guid(&clsid)); 1915 }else if(test_protocol == HTTP_TEST) { 1916 ok(IsEqualCLSID(&clsid, &CLSID_HttpProtocol), 1917 "incorrect protocol CLSID: %s, expected CLSID_HttpProtocol\n", 1918 wine_dbgstr_guid(&clsid)); 1919 }else if(test_protocol == HTTPS_TEST) { 1920 ok(IsEqualCLSID(&clsid, &CLSID_HttpSProtocol), 1921 "incorrect protocol CLSID: %s, expected CLSID_HttpSProtocol\n", 1922 wine_dbgstr_guid(&clsid)); 1923 }else if(test_protocol == ABOUT_TEST) { 1924 ok(IsEqualCLSID(&clsid, &CLSID_AboutProtocol), 1925 "incorrect protocol CLSID: %s, expected CLSID_AboutProtocol\n", 1926 wine_dbgstr_guid(&clsid)); 1927 }else { 1928 ok(0, "unexpected (%d)\n", test_protocol); 1929 } 1930 } 1931 1932 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) && emulate_protocol) { 1933 SetEvent(complete_event); 1934 if(iface != &objbsc) 1935 ok( WaitForSingleObject(complete_event2, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 1936 } 1937 1938 return S_OK; 1939 } 1940 1941 static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo) 1942 { 1943 DWORD cbSize; 1944 1945 if(iface == &objbsc) 1946 CHECK_EXPECT(Obj_GetBindInfo); 1947 else 1948 CHECK_EXPECT(GetBindInfo); 1949 1950 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1951 1952 *grfBINDF = bindf; 1953 cbSize = pbindinfo->cbSize; 1954 memset(pbindinfo, 0, cbSize); 1955 pbindinfo->cbSize = cbSize; 1956 1957 return S_OK; 1958 } 1959 1960 static void test_stream_seek(IStream *stream) 1961 { 1962 ULARGE_INTEGER new_pos; 1963 LARGE_INTEGER pos; 1964 HRESULT hres; 1965 1966 pos.QuadPart = 0; 1967 new_pos.QuadPart = 0xdeadbeef; 1968 hres = IStream_Seek(stream, pos, STREAM_SEEK_SET, &new_pos); 1969 ok(hres == S_OK, "Seek failed: %08x\n", hres); 1970 ok(!new_pos.QuadPart, "new_pos.QuadPart != 0\n"); 1971 1972 pos.QuadPart = 0; 1973 new_pos.QuadPart = 0xdeadbeef; 1974 hres = IStream_Seek(stream, pos, STREAM_SEEK_END, &new_pos); 1975 ok(hres == S_OK, "Seek failed: %08x\n", hres); 1976 ok(new_pos.QuadPart, "new_pos.QuadPart = 0\n"); 1977 1978 pos.QuadPart = 0; 1979 new_pos.QuadPart = 0xdeadbeef; 1980 hres = IStream_Seek(stream, pos, 100, &new_pos); 1981 ok(hres == E_FAIL, "Seek failed: %08x\n", hres); 1982 ok(new_pos.QuadPart == 0xdeadbeef, "unexpected new_pos.QuadPart\n"); 1983 } 1984 1985 static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallbackEx *iface, DWORD grfBSCF, 1986 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed) 1987 { 1988 HRESULT hres; 1989 DWORD readed; 1990 BYTE buf[512]; 1991 CHAR clipfmt[512]; 1992 1993 if(iface == &objbsc) 1994 ok(0, "unexpected call\n"); 1995 1996 CHECK_EXPECT2(OnDataAvailable); 1997 1998 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 1999 2000 ok(download_state == DOWNLOADING || download_state == END_DOWNLOAD, 2001 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n", 2002 download_state); 2003 data_available = TRUE; 2004 2005 if(bind_to_object && !is_async_prot) 2006 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), "grfBSCF = %x\n", grfBSCF); 2007 2008 ok(pformatetc != NULL, "pformatetx == NULL\n"); 2009 if(pformatetc) { 2010 if (mime_type[0]) { 2011 INT ret; 2012 clipfmt[0] = 0; 2013 ret = GetClipboardFormatNameA(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1); 2014 ok(ret, "GetClipboardFormatName failed, error %d\n", GetLastError()); 2015 ok(!strcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n", 2016 pformatetc->cfFormat, clipfmt, mime_type); 2017 } else { 2018 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat); 2019 } 2020 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd); 2021 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect); 2022 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex); 2023 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed); 2024 } 2025 2026 ok(pstgmed != NULL, "stgmeg == NULL\n"); 2027 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed); 2028 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n"); 2029 2030 switch(pstgmed->tymed) { 2031 case TYMED_ISTREAM: { 2032 IStream *stream = U(*pstgmed).pstm; 2033 2034 ok(stream != NULL, "U(*pstgmed).pstm == NULL\n"); 2035 2036 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) { 2037 STATSTG stat; 2038 2039 hres = IStream_Write(stream, buf, 10, NULL); 2040 ok(hres == STG_E_ACCESSDENIED, 2041 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres); 2042 2043 hres = IStream_Commit(stream, 0); 2044 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres); 2045 2046 hres = IStream_Revert(stream); 2047 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres); 2048 2049 hres = IStream_Stat(stream, NULL, STATFLAG_NONAME); 2050 ok(hres == E_FAIL, "hres = %x\n", hres); 2051 if(use_cache_file && emulate_protocol) { 2052 hres = IStream_Stat(stream, &stat, STATFLAG_DEFAULT); 2053 ok(hres == S_OK, "hres = %x\n", hres); 2054 ok(!lstrcmpW(stat.pwcsName, cache_file_name), 2055 "stat.pwcsName = %s, cache_file_name = %s\n", 2056 wine_dbgstr_w(stat.pwcsName), wine_dbgstr_w(cache_file_name)); 2057 CoTaskMemFree(stat.pwcsName); 2058 ok(U(stat.cbSize).LowPart == (bindf&BINDF_ASYNCHRONOUS?0:6500), 2059 "stat.cbSize.LowPart = %u\n", U(stat.cbSize).LowPart); 2060 } else { 2061 hres = IStream_Stat(stream, &stat, STATFLAG_NONAME); 2062 ok(hres == S_OK, "hres = %x\n", hres); 2063 ok(!stat.pwcsName || broken(stat.pwcsName!=NULL), 2064 "stat.pwcsName = %s\n", wine_dbgstr_w(stat.pwcsName)); 2065 } 2066 ok(stat.type == STGTY_STREAM, "stat.type = %x\n", stat.type); 2067 ok(U(stat.cbSize).HighPart == 0, "stat.cbSize.HighPart != 0\n"); 2068 ok(stat.grfMode == (U(stat.cbSize).LowPart?GENERIC_READ:0), "stat.grfMode = %x\n", stat.grfMode); 2069 ok(stat.grfLocksSupported == 0, "stat.grfLocksSupported = %x\n", stat.grfLocksSupported); 2070 ok(stat.grfStateBits == 0, "stat.grfStateBits = %x\n", stat.grfStateBits); 2071 ok(stat.reserved == 0, "stat.reserved = %x\n", stat.reserved); 2072 } 2073 2074 if(callback_read) { 2075 do { 2076 hres = IStream_Read(stream, buf, 512, &readed); 2077 if(test_protocol == HTTP_TEST && emulate_protocol && readed) 2078 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]); 2079 }while(hres == S_OK); 2080 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres); 2081 } 2082 2083 if(use_cache_file && (grfBSCF & BSCF_FIRSTDATANOTIFICATION) && !(bindf & BINDF_PULLDATA)) 2084 test_stream_seek(stream); 2085 break; 2086 } 2087 case TYMED_FILE: 2088 if(test_protocol == FILE_TEST) 2089 ok(!lstrcmpW(pstgmed->u.lpszFileName, file_url+7), 2090 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName)); 2091 else if(emulate_protocol) 2092 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW), 2093 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName)); 2094 else 2095 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n"); 2096 } 2097 2098 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) 2099 && emulate_protocol && prot_state < 4 && (!bind_to_object || prot_state > 1)) 2100 SetEvent(complete_event); 2101 2102 return S_OK; 2103 } 2104 2105 static HRESULT WINAPI statusclb_OnObjectAvailable(IBindStatusCallbackEx *iface, REFIID riid, IUnknown *punk) 2106 { 2107 CHECK_EXPECT(OnObjectAvailable); 2108 2109 if(iface != &objbsc) 2110 ok(0, "unexpected call\n"); 2111 2112 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", wine_dbgstr_guid(riid)); 2113 ok(punk != NULL, "punk == NULL\n"); 2114 2115 return S_OK; 2116 } 2117 2118 static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo, 2119 DWORD *grfBINDF2, DWORD *pdwReserved) 2120 { 2121 CHECK_EXPECT(GetBindInfoEx); 2122 2123 ok(grfBINDF != NULL, "grfBINDF == NULL\n"); 2124 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n"); 2125 ok(pbindinfo != NULL, "pbindinfo == NULL\n"); 2126 ok(pdwReserved != NULL, "dwReserved == NULL\n"); 2127 2128 return S_OK; 2129 } 2130 2131 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = { 2132 statusclb_QueryInterface, 2133 statusclb_AddRef, 2134 statusclb_Release, 2135 statusclb_OnStartBinding, 2136 statusclb_GetPriority, 2137 statusclb_OnLowResource, 2138 statusclb_OnProgress, 2139 statusclb_OnStopBinding, 2140 statusclb_GetBindInfo, 2141 statusclb_OnDataAvailable, 2142 statusclb_OnObjectAvailable, 2143 statusclb_GetBindInfoEx 2144 }; 2145 2146 static IBindStatusCallbackEx bsc = { &BindStatusCallbackVtbl }; 2147 static IBindStatusCallbackEx bsc2 = { &BindStatusCallbackVtbl }; 2148 static IBindStatusCallbackEx objbsc = { &BindStatusCallbackVtbl }; 2149 2150 static HRESULT WINAPI MonikerProp_QueryInterface(IMonikerProp *iface, REFIID riid, void **ppv) 2151 { 2152 *ppv = NULL; 2153 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2154 return E_NOINTERFACE; 2155 } 2156 2157 static ULONG WINAPI MonikerProp_AddRef(IMonikerProp *iface) 2158 { 2159 return 2; 2160 } 2161 2162 static ULONG WINAPI MonikerProp_Release(IMonikerProp *iface) 2163 { 2164 return 1; 2165 } 2166 2167 static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val) 2168 { 2169 switch(mkp) { 2170 case MIMETYPEPROP: 2171 CHECK_EXPECT(PutProperty_MIMETYPEPROP); 2172 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val)); 2173 break; 2174 case CLASSIDPROP: 2175 CHECK_EXPECT(PutProperty_CLASSIDPROP); 2176 break; 2177 default: 2178 break; 2179 } 2180 2181 return S_OK; 2182 } 2183 2184 static const IMonikerPropVtbl MonikerPropVtbl = { 2185 MonikerProp_QueryInterface, 2186 MonikerProp_AddRef, 2187 MonikerProp_Release, 2188 MonikerProp_PutProperty 2189 }; 2190 2191 static IMonikerProp MonikerProp = { &MonikerPropVtbl }; 2192 2193 static HRESULT WINAPI PersistMoniker_QueryInterface(IPersistMoniker *iface, REFIID riid, void **ppv) 2194 { 2195 *ppv = NULL; 2196 2197 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid)) 2198 *ppv = iface; 2199 else if(IsEqualGUID(&IID_IMonikerProp, riid)) 2200 *ppv = &MonikerProp; 2201 2202 if(*ppv) 2203 return S_OK; 2204 2205 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2206 return E_NOINTERFACE; 2207 } 2208 2209 static ULONG WINAPI PersistMoniker_AddRef(IPersistMoniker *iface) 2210 { 2211 return 2; 2212 } 2213 2214 static ULONG WINAPI PersistMoniker_Release(IPersistMoniker *iface) 2215 { 2216 return 1; 2217 } 2218 2219 static HRESULT WINAPI PersistMoniker_GetClassID(IPersistMoniker *iface, CLSID *pClassID) 2220 { 2221 ok(0, "unexpected call\n"); 2222 return E_NOTIMPL; 2223 } 2224 2225 static HRESULT WINAPI PersistMoniker_IsDirty(IPersistMoniker *iface) 2226 { 2227 ok(0, "unexpected call\n"); 2228 return E_NOTIMPL; 2229 } 2230 2231 static HRESULT WINAPI PersistMoniker_Load(IPersistMoniker *iface, BOOL fFullyAvailable, 2232 IMoniker *pimkName, LPBC pibc, DWORD grfMode) 2233 { 2234 IUnknown *unk; 2235 HRESULT hres; 2236 2237 static WCHAR cbinding_contextW[] = 2238 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0}; 2239 2240 CHECK_EXPECT(Load); 2241 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId()); 2242 2243 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 2244 ok(!fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable); 2245 else 2246 ok(fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable); 2247 ok(pimkName != NULL, "pimkName == NULL\n"); 2248 ok(pibc != NULL, "pibc == NULL\n"); 2249 ok(grfMode == 0x12, "grfMode = %x\n", grfMode); 2250 2251 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk); 2252 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres); 2253 if(SUCCEEDED(hres)) { 2254 IBinding *binding; 2255 2256 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding); 2257 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres); 2258 2259 IBinding_Release(binding); 2260 IUnknown_Release(unk); 2261 } 2262 2263 SET_EXPECT(QueryInterface_IServiceProvider); 2264 hres = RegisterBindStatusCallback(pibc, (IBindStatusCallback*)&bsc, NULL, 0); 2265 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres); 2266 CHECK_CALLED(QueryInterface_IServiceProvider); 2267 2268 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 2269 SET_EXPECT(GetBindInfo); 2270 SET_EXPECT(OnStartBinding); 2271 if(test_redirect) 2272 SET_EXPECT(OnProgress_REDIRECTING); 2273 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 2274 if(test_protocol == FILE_TEST) 2275 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE); 2276 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) 2277 SET_EXPECT(OnProgress_ENDDOWNLOADDATA); 2278 SET_EXPECT(LockRequest); 2279 SET_EXPECT(OnDataAvailable); 2280 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) 2281 SET_EXPECT(OnStopBinding); 2282 2283 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk); 2284 ok(hres == S_OK, "Load failed: %08x\n", hres); 2285 2286 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */ 2287 CHECK_CALLED(GetBindInfo); 2288 CHECK_CALLED(OnStartBinding); 2289 if(test_redirect) 2290 CHECK_CALLED(OnProgress_REDIRECTING); 2291 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 2292 if(test_protocol == FILE_TEST) 2293 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE); 2294 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) 2295 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA); 2296 CHECK_CALLED(LockRequest); 2297 CHECK_CALLED(OnDataAvailable); 2298 if(test_protocol != HTTP_TEST && test_protocol != HTTPS_TEST) 2299 CHECK_CALLED(OnStopBinding); 2300 2301 if(unk) 2302 IUnknown_Release(unk); 2303 2304 return S_OK; 2305 } 2306 2307 static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember) 2308 { 2309 ok(0, "unexpected call\n"); 2310 return E_NOTIMPL; 2311 } 2312 2313 static HRESULT WINAPI PersistMoniker_SaveCompleted(IPersistMoniker *iface, IMoniker *pimkName, LPBC pibc) 2314 { 2315 ok(0, "unexpected call\n"); 2316 return E_NOTIMPL; 2317 } 2318 2319 static HRESULT WINAPI PersistMoniker_GetCurMoniker(IPersistMoniker *iface, IMoniker **pimkName) 2320 { 2321 ok(0, "unexpected call\n"); 2322 return E_NOTIMPL; 2323 } 2324 2325 static const IPersistMonikerVtbl PersistMonikerVtbl = { 2326 PersistMoniker_QueryInterface, 2327 PersistMoniker_AddRef, 2328 PersistMoniker_Release, 2329 PersistMoniker_GetClassID, 2330 PersistMoniker_IsDirty, 2331 PersistMoniker_Load, 2332 PersistMoniker_Save, 2333 PersistMoniker_SaveCompleted, 2334 PersistMoniker_GetCurMoniker 2335 }; 2336 2337 static IPersistMoniker PersistMoniker = { &PersistMonikerVtbl }; 2338 2339 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) 2340 { 2341 *ppv = NULL; 2342 2343 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) { 2344 *ppv = iface; 2345 return S_OK; 2346 } 2347 2348 if(IsEqualGUID(&IID_IMarshal, riid)) 2349 return E_NOINTERFACE; 2350 if(IsEqualGUID(&CLSID_IdentityUnmarshal, riid)) 2351 return E_NOINTERFACE; 2352 2353 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2354 return E_NOTIMPL; 2355 } 2356 2357 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface) 2358 { 2359 return 2; 2360 } 2361 2362 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface) 2363 { 2364 return 1; 2365 } 2366 2367 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv) 2368 { 2369 CHECK_EXPECT(CreateInstance); 2370 ok(!outer, "outer = %p\n", outer); 2371 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2372 *ppv = &PersistMoniker; 2373 return S_OK; 2374 } 2375 2376 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock) 2377 { 2378 ok(0, "unexpected call\n"); 2379 return S_OK; 2380 } 2381 2382 static const IClassFactoryVtbl ClassFactoryVtbl = { 2383 ClassFactory_QueryInterface, 2384 ClassFactory_AddRef, 2385 ClassFactory_Release, 2386 ClassFactory_CreateInstance, 2387 ClassFactory_LockServer 2388 }; 2389 2390 static IClassFactory mime_cf = { &ClassFactoryVtbl }; 2391 2392 static HRESULT WINAPI ProtocolCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) 2393 { 2394 *ppv = NULL; 2395 2396 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IClassFactory, riid)) { 2397 *ppv = iface; 2398 return S_OK; 2399 } 2400 2401 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) 2402 return E_NOINTERFACE; 2403 2404 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2405 return E_NOTIMPL; 2406 } 2407 2408 static HRESULT WINAPI ProtocolCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv) 2409 { 2410 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) 2411 return E_NOINTERFACE; 2412 2413 todo_wine ok(outer != NULL, "outer == NULL\n"); 2414 todo_wine ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid)); 2415 *ppv = &Protocol; 2416 return S_OK; 2417 } 2418 2419 static const IClassFactoryVtbl ProtocolCFVtbl = { 2420 ProtocolCF_QueryInterface, 2421 ClassFactory_AddRef, 2422 ClassFactory_Release, 2423 ProtocolCF_CreateInstance, 2424 ClassFactory_LockServer 2425 }; 2426 2427 static IClassFactory protocol_cf = { &ProtocolCFVtbl }; 2428 2429 static void test_CreateAsyncBindCtx(void) 2430 { 2431 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0; 2432 IUnknown *unk; 2433 HRESULT hres; 2434 ULONG ref; 2435 BIND_OPTS bindopts; 2436 2437 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx); 2438 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres); 2439 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n"); 2440 2441 hres = CreateAsyncBindCtx(0, NULL, NULL, NULL); 2442 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres); 2443 2444 SET_EXPECT(QueryInterface_IServiceProvider); 2445 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx); 2446 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres); 2447 CHECK_CALLED(QueryInterface_IServiceProvider); 2448 2449 bindopts.cbStruct = sizeof(bindopts); 2450 hres = IBindCtx_GetBindOptions(bctx, &bindopts); 2451 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres); 2452 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER, 2453 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags); 2454 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE), 2455 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n", 2456 bindopts.grfMode); 2457 ok(bindopts.dwTickCountDeadline == 0, 2458 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline); 2459 2460 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk); 2461 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres); 2462 if(SUCCEEDED(hres)) 2463 IUnknown_Release(unk); 2464 2465 ref = IBindCtx_Release(bctx); 2466 ok(ref == 0, "bctx should be destroyed here\n"); 2467 } 2468 2469 static void test_CreateAsyncBindCtxEx(void) 2470 { 2471 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL; 2472 IUnknown *unk; 2473 BIND_OPTS bindopts; 2474 HRESULT hres; 2475 2476 static WCHAR testW[] = {'t','e','s','t',0}; 2477 2478 if (!pCreateAsyncBindCtxEx) { 2479 win_skip("CreateAsyncBindCtxEx not present\n"); 2480 return; 2481 } 2482 2483 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0); 2484 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres); 2485 2486 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0); 2487 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres); 2488 2489 if(SUCCEEDED(hres)) { 2490 bindopts.cbStruct = sizeof(bindopts); 2491 hres = IBindCtx_GetBindOptions(bctx, &bindopts); 2492 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres); 2493 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER, 2494 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags); 2495 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE), 2496 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n", 2497 bindopts.grfMode); 2498 ok(bindopts.dwTickCountDeadline == 0, 2499 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline); 2500 2501 IBindCtx_Release(bctx); 2502 } 2503 2504 CreateBindCtx(0, &bctx_arg); 2505 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0); 2506 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres); 2507 2508 if(SUCCEEDED(hres)) { 2509 bindopts.cbStruct = sizeof(bindopts); 2510 hres = IBindCtx_GetBindOptions(bctx, &bindopts); 2511 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres); 2512 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER, 2513 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags); 2514 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE), 2515 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n", 2516 bindopts.grfMode); 2517 ok(bindopts.dwTickCountDeadline == 0, 2518 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline); 2519 2520 IBindCtx_Release(bctx); 2521 } 2522 2523 IBindCtx_Release(bctx_arg); 2524 2525 SET_EXPECT(QueryInterface_IServiceProvider); 2526 hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0); 2527 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres); 2528 CHECK_CALLED(QueryInterface_IServiceProvider); 2529 2530 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk); 2531 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres); 2532 if(SUCCEEDED(hres)) 2533 IUnknown_Release(unk); 2534 2535 IBindCtx_Release(bctx); 2536 2537 hres = CreateBindCtx(0, &bctx2); 2538 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres); 2539 2540 hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0); 2541 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres); 2542 2543 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol); 2544 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres); 2545 2546 hres = IBindCtx_GetObjectParam(bctx, testW, &unk); 2547 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres); 2548 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk); 2549 2550 IBindCtx_Release(bctx); 2551 IBindCtx_Release(bctx2); 2552 } 2553 2554 static void test_GetBindInfoEx(IBindStatusCallback *holder) 2555 { 2556 IBindStatusCallbackEx *bscex; 2557 BINDINFO bindinfo = {sizeof(bindinfo)}; 2558 DWORD bindf, bindf2, dw; 2559 HRESULT hres; 2560 2561 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex); 2562 if(FAILED(hres)) { 2563 win_skip("IBindStatusCallbackEx not supported\n"); 2564 return; 2565 } 2566 2567 use_bscex = TRUE; 2568 2569 bindf = 0; 2570 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 2571 SET_EXPECT(GetBindInfoEx); 2572 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo); 2573 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 2574 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx); 2575 CHECK_CALLED(GetBindInfoEx); 2576 2577 bindf = bindf2 = dw = 0; 2578 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 2579 SET_EXPECT(GetBindInfoEx); 2580 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw); 2581 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 2582 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx); 2583 CHECK_CALLED(GetBindInfoEx); 2584 2585 use_bscex = FALSE; 2586 2587 bindf = bindf2 = dw = 0xdeadbeef; 2588 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 2589 SET_EXPECT(GetBindInfo); 2590 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw); 2591 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 2592 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx); 2593 CHECK_CALLED(GetBindInfo); 2594 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2); 2595 ok(dw == 0xdeadbeef, "dw = %x\n", dw); 2596 2597 IBindStatusCallbackEx_Release(bscex); 2598 } 2599 2600 static BOOL test_bscholder(IBindStatusCallback *holder) 2601 { 2602 IServiceProvider *serv_prov; 2603 IHttpNegotiate *http_negotiate, *http_negotiate_serv; 2604 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv; 2605 IAuthenticate *authenticate, *authenticate_serv; 2606 IInternetBindInfo *bind_info; 2607 IInternetProtocol *protocol; 2608 BINDINFO bindinfo = {sizeof(bindinfo)}; 2609 BOOL ret = TRUE; 2610 LPWSTR wstr; 2611 DWORD dw; 2612 HRESULT hres; 2613 2614 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov); 2615 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres); 2616 2617 dw = 0xdeadbeef; 2618 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 2619 SET_EXPECT(GetBindInfo); 2620 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo); 2621 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres); 2622 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */ 2623 CHECK_CALLED(GetBindInfo); 2624 2625 test_GetBindInfoEx(holder); 2626 2627 SET_EXPECT(OnStartBinding); 2628 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef); 2629 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres); 2630 CHECK_CALLED(OnStartBinding); 2631 2632 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate); 2633 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres); 2634 2635 SET_EXPECT(QueryInterface_IHttpNegotiate); 2636 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate, 2637 (void**)&http_negotiate_serv); 2638 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres); 2639 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */ 2640 2641 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n"); 2642 2643 wstr = (void*)0xdeadbeef; 2644 SET_EXPECT(QueryInterface_IHttpNegotiate); 2645 SET_EXPECT(BeginningTransaction); 2646 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, current_url, emptyW, 0, &wstr); 2647 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */ 2648 CHECK_CALLED(BeginningTransaction); 2649 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres); 2650 ok(wstr == NULL, "wstr = %p\n", wstr); 2651 2652 IHttpNegotiate_Release(http_negotiate_serv); 2653 2654 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate, 2655 (void**)&http_negotiate_serv); 2656 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres); 2657 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n"); 2658 IHttpNegotiate_Release(http_negotiate_serv); 2659 2660 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2); 2661 if(SUCCEEDED(hres)) { 2662 have_IHttpNegotiate2 = TRUE; 2663 2664 SET_EXPECT(QueryInterface_IHttpNegotiate2); 2665 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2, 2666 (void**)&http_negotiate2_serv); 2667 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres); 2668 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */ 2669 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n"); 2670 2671 SET_EXPECT(QueryInterface_IHttpNegotiate2); 2672 SET_EXPECT(GetRootSecurityId); 2673 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0); 2674 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres); 2675 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */ 2676 CHECK_CALLED(GetRootSecurityId); 2677 2678 IHttpNegotiate2_Release(http_negotiate2_serv); 2679 IHttpNegotiate2_Release(http_negotiate2); 2680 }else { 2681 skip("Could not get IHttpNegotiate2\n"); 2682 ret = FALSE; 2683 } 2684 2685 SET_EXPECT(OnProgress_FINDINGRESOURCE); 2686 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL); 2687 ok(hres == S_OK, "OnProgress failed: %08x\n", hres); 2688 CHECK_CALLED(OnProgress_FINDINGRESOURCE); 2689 2690 SET_EXPECT(QueryInterface_IHttpNegotiate); 2691 SET_EXPECT(OnResponse); 2692 wstr = (void*)0xdeadbeef; 2693 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL); 2694 ok(hres == S_OK, "OnResponse failed: %08x\n", hres); 2695 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */ 2696 CHECK_CALLED(OnResponse); 2697 2698 IHttpNegotiate_Release(http_negotiate); 2699 2700 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate); 2701 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres); 2702 2703 SET_EXPECT(QueryInterface_IAuthenticate); 2704 SET_EXPECT(QueryService_IAuthenticate); 2705 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate, 2706 (void**)&authenticate_serv); 2707 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres); 2708 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */ 2709 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */ 2710 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n"); 2711 IAuthenticate_Release(authenticate_serv); 2712 2713 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate, 2714 (void**)&authenticate_serv); 2715 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres); 2716 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n"); 2717 2718 IAuthenticate_Release(authenticate); 2719 IAuthenticate_Release(authenticate_serv); 2720 2721 hres = IBindStatusCallback_QueryInterface(holder, &IID_IInternetBindInfo, (void**)&bind_info); 2722 ok(hres == S_OK || broken(hres == E_NOINTERFACE /* win2k */), "Could not get IInternetBindInfo interface: %08x\n", hres); 2723 2724 if(SUCCEEDED(hres)) { 2725 hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_USER_AGENT, &wstr, 1, &dw); 2726 ok(hres == E_NOINTERFACE, "GetBindString(BINDSTRING_USER_AGENT) failed: %08x\n", hres); 2727 2728 IInternetBindInfo_Release(bind_info); 2729 } 2730 2731 SET_EXPECT(OnStopBinding); 2732 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL); 2733 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres); 2734 CHECK_CALLED(OnStopBinding); 2735 2736 SET_EXPECT(QueryInterface_IInternetProtocol); 2737 SET_EXPECT(QueryService_IInternetProtocol); 2738 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol, 2739 (void**)&protocol); 2740 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres); 2741 CHECK_CALLED(QueryInterface_IInternetProtocol); 2742 CHECK_CALLED(QueryService_IInternetProtocol); 2743 2744 IServiceProvider_Release(serv_prov); 2745 return ret; 2746 } 2747 2748 static BOOL test_RegisterBindStatusCallback(void) 2749 { 2750 IBindStatusCallback *prevbsc, *clb, *prev_clb; 2751 IBindCtx *bindctx; 2752 BOOL ret = TRUE; 2753 IUnknown *unk; 2754 HRESULT hres; 2755 2756 strict_bsc_qi = TRUE; 2757 2758 hres = CreateBindCtx(0, &bindctx); 2759 ok(hres == S_OK, "BindCtx failed: %08x\n", hres); 2760 2761 SET_EXPECT(QueryInterface_IServiceProvider); 2762 2763 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc); 2764 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres); 2765 2766 SET_EXPECT(QueryInterface_IBindStatusCallback); 2767 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder); 2768 prevbsc = (void*)0xdeadbeef; 2769 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0); 2770 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres); 2771 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc); 2772 CHECK_CALLED(QueryInterface_IBindStatusCallback); 2773 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder); 2774 2775 CHECK_CALLED(QueryInterface_IServiceProvider); 2776 2777 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk); 2778 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres); 2779 2780 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb); 2781 IUnknown_Release(unk); 2782 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres); 2783 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n"); 2784 2785 if(!test_bscholder(clb)) 2786 ret = FALSE; 2787 2788 IBindStatusCallback_Release(clb); 2789 2790 hres = RevokeBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc); 2791 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres); 2792 2793 unk = (void*)0xdeadbeef; 2794 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk); 2795 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres); 2796 ok(unk == NULL, "unk != NULL\n"); 2797 2798 if(unk) 2799 IUnknown_Release(unk); 2800 2801 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef); 2802 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres); 2803 2804 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef); 2805 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres); 2806 2807 hres = RevokeBindStatusCallback(bindctx, NULL); 2808 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres); 2809 2810 SET_EXPECT(QueryInterface_IServiceProvider); 2811 prevbsc = (void*)0xdeadbeef; 2812 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0); 2813 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres); 2814 ok(!prevbsc, "prevbsc=%p\n", prevbsc); 2815 CHECK_CALLED(QueryInterface_IServiceProvider); 2816 2817 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk); 2818 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres); 2819 2820 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&prev_clb); 2821 IUnknown_Release(unk); 2822 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres); 2823 ok(prev_clb != (IBindStatusCallback*)&bsc, "bsc == clb\n"); 2824 2825 SET_EXPECT(QueryInterface_IServiceProvider); 2826 prevbsc = (void*)0xdeadbeef; 2827 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc2, &prevbsc, 0); 2828 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres); 2829 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc != bsc\n"); 2830 CHECK_CALLED(QueryInterface_IServiceProvider); 2831 2832 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk); 2833 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres); 2834 2835 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb); 2836 IUnknown_Release(unk); 2837 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres); 2838 ok(prev_clb == clb, "bsc != clb\n"); 2839 2840 IBindStatusCallback_Release(clb); 2841 IBindStatusCallback_Release(prev_clb); 2842 2843 IBindCtx_Release(bindctx); 2844 2845 strict_bsc_qi = FALSE; 2846 return ret; 2847 } 2848 2849 #define BINDTEST_EMULATE 0x0001 2850 #define BINDTEST_TOOBJECT 0x0002 2851 #define BINDTEST_FILEDWLAPI 0x0004 2852 #define BINDTEST_HTTPRESPONSE 0x0008 2853 #define BINDTEST_REDIRECT 0x0010 2854 #define BINDTEST_USE_CACHE 0x0020 2855 #define BINDTEST_NO_CALLBACK_READ 0x0040 2856 #define BINDTEST_NO_CALLBACK 0x0080 2857 #define BINDTEST_ABORT 0x0100 2858 #define BINDTEST_INVALID_CN 0x0200 2859 #define BINDTEST_ABORT_START 0x0400 2860 #define BINDTEST_ABORT_PROGRESS 0x0800 2861 #define BINDTEST_ASYNC_SWITCH 0x1000 2862 #define BINDTEST_ALLOW_FINDINGRESOURCE 0x2000 2863 2864 static void init_bind_test(int protocol, DWORD flags, DWORD t) 2865 { 2866 const char *url_a = NULL; 2867 2868 test_protocol = protocol; 2869 bindtest_flags = flags; 2870 emulate_protocol = (flags & BINDTEST_EMULATE) != 0; 2871 download_state = BEFORE_DOWNLOAD; 2872 stopped_binding = FALSE; 2873 stopped_obj_binding = FALSE; 2874 data_available = FALSE; 2875 mime_type[0] = 0; 2876 binding_hres = S_OK; 2877 bind_to_object = (flags & BINDTEST_TOOBJECT) != 0; 2878 tymed = t; 2879 filedwl_api = (flags & BINDTEST_FILEDWLAPI) != 0; 2880 post_test = (flags & BINDTEST_HTTPRESPONSE) != 0; 2881 2882 switch(protocol) { 2883 case HTTP_TEST: 2884 if(post_test) 2885 url_a = "http://test.winehq.org/tests/post.php"; 2886 else 2887 lstrcpyW(current_url, winetest_data_urlW); 2888 break; 2889 case ABOUT_TEST: 2890 url_a = "about:blank"; 2891 break; 2892 case FILE_TEST: 2893 lstrcpyW(current_url, file_url); 2894 break; 2895 case MK_TEST: 2896 url_a = "mk:@MSITStore:test.chm::/blank.html"; 2897 break; 2898 case ITS_TEST: 2899 url_a = "its:test.chm::/blank.html"; 2900 break; 2901 case HTTPS_TEST: 2902 url_a = (flags & BINDTEST_INVALID_CN) ? "https://209.46.25.134/favicon.ico" : "https://test.winehq.org/tests/hello.html"; 2903 break; 2904 case FTP_TEST: 2905 url_a = "ftp://ftp.winehq.org/welcome.msg"; 2906 break; 2907 default: 2908 url_a = "winetest:test"; 2909 } 2910 2911 if(url_a) 2912 MultiByteToWideChar(CP_ACP, 0, url_a, -1, current_url, sizeof(current_url)/sizeof(*current_url)); 2913 2914 test_redirect = (flags & BINDTEST_REDIRECT) != 0; 2915 use_cache_file = (flags & BINDTEST_USE_CACHE) != 0; 2916 callback_read = !(flags & BINDTEST_NO_CALLBACK_READ); 2917 no_callback = (flags & BINDTEST_NO_CALLBACK) != 0; 2918 test_abort = (flags & BINDTEST_ABORT) != 0; 2919 abort_start = (flags & BINDTEST_ABORT_START) != 0; 2920 abort_progress = (flags & BINDTEST_ABORT_PROGRESS) != 0; 2921 async_switch = (flags & BINDTEST_ASYNC_SWITCH) != 0; 2922 is_async_prot = protocol == HTTP_TEST || protocol == HTTPS_TEST || protocol == FTP_TEST || protocol == WINETEST_TEST; 2923 prot_state = 0; 2924 ResetEvent(complete_event); 2925 2926 trace("URL: %s\n", wine_dbgstr_w(current_url)); 2927 } 2928 2929 static void test_BindToStorage(int protocol, DWORD flags, DWORD t) 2930 { 2931 IMoniker *mon; 2932 HRESULT hres; 2933 LPOLESTR display_name; 2934 IBindCtx *bctx = NULL; 2935 MSG msg; 2936 IBindStatusCallback *previousclb; 2937 IUnknown *unk = (IUnknown*)0x00ff00ff; 2938 BOOL allow_finding_resource; 2939 IBinding *bind; 2940 2941 init_bind_test(protocol, flags, t); 2942 allow_finding_resource = (flags & BINDTEST_ALLOW_FINDINGRESOURCE) != 0; 2943 2944 if(no_callback) { 2945 hres = CreateBindCtx(0, &bctx); 2946 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres); 2947 }else { 2948 SET_EXPECT(QueryInterface_IServiceProvider); 2949 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx); 2950 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres); 2951 CHECK_CALLED(QueryInterface_IServiceProvider); 2952 if(FAILED(hres)) 2953 return; 2954 2955 SET_EXPECT(QueryInterface_IServiceProvider); 2956 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0); 2957 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres); 2958 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc); 2959 CHECK_CALLED(QueryInterface_IServiceProvider); 2960 if(previousclb) 2961 IBindStatusCallback_Release(previousclb); 2962 } 2963 2964 hres = CreateURLMoniker(NULL, current_url, &mon); 2965 ok(hres == S_OK, "failed to create moniker: %08x\n", hres); 2966 if(FAILED(hres)) 2967 return; 2968 2969 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind); 2970 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n"); 2971 if(SUCCEEDED(hres)) 2972 IBinding_Release(bind); 2973 2974 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name); 2975 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres); 2976 ok(!lstrcmpW(display_name, current_url), "GetDisplayName got wrong name %s, expected %s\n", 2977 wine_dbgstr_w(display_name), wine_dbgstr_w(current_url)); 2978 CoTaskMemFree(display_name); 2979 2980 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST)) 2981 binding_hres = INET_E_DATA_NOT_AVAILABLE; 2982 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted && 2983 (onsecurityproblem_hres != S_OK || security_problem == ERROR_INTERNET_SEC_CERT_ERRORS)) { 2984 if(security_problem == ERROR_INTERNET_SEC_CERT_ERRORS) 2985 binding_hres = INET_E_SECURITY_PROBLEM; 2986 else 2987 binding_hres = INET_E_INVALID_CERTIFICATE; 2988 } 2989 2990 2991 if(only_check_prot_args) 2992 SET_EXPECT(OnStopBinding); 2993 if(!no_callback) { 2994 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 2995 SET_EXPECT(GetBindInfo); 2996 SET_EXPECT(QueryInterface_IInternetProtocol); 2997 if(!emulate_protocol) 2998 SET_EXPECT(QueryService_IInternetProtocol); 2999 SET_EXPECT(OnStartBinding); 3000 } 3001 if(emulate_protocol) { 3002 if(is_urlmon_protocol(test_protocol)) 3003 SET_EXPECT(SetPriority); 3004 SET_EXPECT(Start); 3005 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST 3006 || test_protocol == WINETEST_SYNC_TEST) 3007 SET_EXPECT(Terminate); 3008 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST)) 3009 SET_EXPECT(UnlockRequest); 3010 }else { 3011 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) { 3012 SET_EXPECT(QueryService_IInternetBindInfo); 3013 if(!abort_start) 3014 SET_EXPECT(QueryInterface_IHttpNegotiate); 3015 SET_EXPECT(QueryInterface_IWindowForBindingUI); 3016 SET_EXPECT(QueryService_IWindowForBindingUI); 3017 SET_EXPECT(GetWindow_IWindowForBindingUI); 3018 if(!abort_start) { 3019 SET_EXPECT(BeginningTransaction); 3020 SET_EXPECT(QueryInterface_IHttpNegotiate2); 3021 SET_EXPECT(GetRootSecurityId); 3022 if(http_is_first || allow_finding_resource) 3023 SET_EXPECT(OnProgress_FINDINGRESOURCE); 3024 SET_EXPECT(OnProgress_CONNECTING); 3025 } 3026 if(flags & BINDTEST_INVALID_CN) { 3027 SET_EXPECT(QueryInterface_IHttpSecurity); 3028 SET_EXPECT(QueryService_IHttpSecurity); 3029 SET_EXPECT(OnSecurityProblem); 3030 if(SUCCEEDED(onsecurityproblem_hres)) 3031 SET_EXPECT(GetWindow_IHttpSecurity); 3032 } 3033 } 3034 if(!no_callback) { 3035 if((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST 3036 || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) && !abort_start) 3037 SET_EXPECT(OnProgress_SENDINGREQUEST); 3038 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) { 3039 SET_EXPECT(QueryInterface_IHttpNegotiate); 3040 SET_EXPECT(OnResponse); 3041 } 3042 if(!abort_start) { 3043 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 3044 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 3045 } 3046 if(test_protocol == FILE_TEST) 3047 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE); 3048 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST) 3049 SET_EXPECT(OnProgress_DOWNLOADINGDATA); 3050 if(!abort_start) 3051 SET_EXPECT(OnProgress_ENDDOWNLOADDATA); 3052 if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start) 3053 SET_EXPECT(OnDataAvailable); 3054 SET_EXPECT(OnStopBinding); 3055 } 3056 } 3057 3058 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk); 3059 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3060 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED)) 3061 { 3062 skip("Network unreachable, skipping tests\n"); 3063 return; 3064 } 3065 3066 if(only_check_prot_args) { 3067 ok(hres == E_FAIL, "Got %08x\n", hres); 3068 CHECK_CALLED(OnStopBinding); 3069 } else if(abort_start) 3070 ok(hres == abort_hres, "IMoniker_BindToStorage failed: %08x, expected %08x\n", hres, abort_hres); 3071 else if(abort_progress) 3072 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres); 3073 else if(no_callback) { 3074 if(emulate_protocol) 3075 ok( WaitForSingleObject(complete_event2, 90000) == WAIT_OBJECT_0, "wait timed out\n" ); 3076 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres); 3077 ok(unk != NULL, "unk == NULL\n"); 3078 }else if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) { 3079 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres); 3080 ok(unk == NULL, "unk != NULL\n"); 3081 }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available) 3082 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) { 3083 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres); 3084 ok(unk == NULL, "istr should be NULL\n"); 3085 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) { 3086 ok(hres == INET_E_DATA_NOT_AVAILABLE, 3087 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres); 3088 ok(unk == NULL, "istr should be NULL\n"); 3089 }else if((flags & BINDTEST_INVALID_CN) && binding_hres != S_OK) { 3090 ok(hres == binding_hres, "Got %08x\n", hres); 3091 ok(unk == NULL, "Got %p\n", unk); 3092 }else if((flags & BINDTEST_INVALID_CN) && invalid_cn_accepted) { 3093 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres); 3094 ok(unk != NULL, "unk == NULL\n"); 3095 if(unk == NULL) { 3096 ok(0, "Expected security problem to be ignored.\n"); 3097 invalid_cn_accepted = FALSE; 3098 binding_hres = INET_E_INVALID_CERTIFICATE; 3099 } 3100 }else { 3101 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres); 3102 ok(unk != NULL, "unk == NULL\n"); 3103 } 3104 if(unk && callback_read && !no_callback) { 3105 IUnknown_Release(unk); 3106 unk = NULL; 3107 } 3108 3109 if(FAILED(hres) && !(flags & BINDTEST_INVALID_CN) && !(flags & BINDTEST_ABORT_START)) 3110 return; 3111 3112 if((bindf & BINDF_ASYNCHRONOUS) && !no_callback) { 3113 while(!stopped_binding && GetMessageA(&msg,NULL,0,0)) { 3114 TranslateMessage(&msg); 3115 DispatchMessageA(&msg); 3116 } 3117 } 3118 3119 if(async_switch) { 3120 CHECK_CALLED(OnProgress_SENDINGREQUEST); 3121 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 3122 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 3123 CHECK_CALLED(LockRequest); 3124 CHECK_CALLED(OnStopBinding); 3125 } 3126 if(!no_callback) { 3127 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */ 3128 CHECK_CALLED(GetBindInfo); 3129 todo_wine_if(abort_start) 3130 CHECK_CALLED(QueryInterface_IInternetProtocol); 3131 if(!emulate_protocol) { 3132 todo_wine_if(abort_start) 3133 CHECK_CALLED(QueryService_IInternetProtocol); 3134 } 3135 CHECK_CALLED(OnStartBinding); 3136 } 3137 if(emulate_protocol) { 3138 if(is_urlmon_protocol(test_protocol)) 3139 CLEAR_CALLED(SetPriority); /* Not called by IE11 */ 3140 CHECK_CALLED(Start); 3141 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST 3142 || test_protocol == WINETEST_SYNC_TEST) { 3143 if(tymed == TYMED_FILE) 3144 CLEAR_CALLED(Read); 3145 CHECK_CALLED(Terminate); 3146 } 3147 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST)) 3148 CHECK_CALLED(UnlockRequest); 3149 }else { 3150 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) { 3151 CLEAR_CALLED(QueryService_IInternetBindInfo); 3152 if(!abort_start) 3153 CHECK_CALLED(QueryInterface_IHttpNegotiate); 3154 CLEAR_CALLED(QueryInterface_IWindowForBindingUI); 3155 CLEAR_CALLED(QueryService_IWindowForBindingUI); 3156 CLEAR_CALLED(GetWindow_IWindowForBindingUI); 3157 if(!abort_start) 3158 CHECK_CALLED(BeginningTransaction); 3159 if (have_IHttpNegotiate2 && !abort_start) 3160 { 3161 CHECK_CALLED(QueryInterface_IHttpNegotiate2); 3162 CHECK_CALLED(GetRootSecurityId); 3163 } 3164 if(http_is_first) { 3165 if (! proxy_active()) 3166 { 3167 CHECK_CALLED(OnProgress_FINDINGRESOURCE); 3168 CHECK_CALLED(OnProgress_CONNECTING); 3169 } 3170 else 3171 { 3172 CLEAR_CALLED(OnProgress_FINDINGRESOURCE); 3173 CLEAR_CALLED(OnProgress_CONNECTING); 3174 } 3175 }else if(!abort_start) { 3176 if(allow_finding_resource) 3177 CLEAR_CALLED(OnProgress_FINDINGRESOURCE); 3178 /* IE7 does call this */ 3179 CLEAR_CALLED(OnProgress_CONNECTING); 3180 } 3181 if((flags & BINDTEST_INVALID_CN) && !invalid_cn_accepted) { 3182 CHECK_CALLED(QueryInterface_IHttpSecurity); 3183 CHECK_CALLED(QueryService_IHttpSecurity); 3184 CHECK_CALLED(OnSecurityProblem); 3185 }else { 3186 CHECK_NOT_CALLED(QueryInterface_IHttpSecurity); 3187 CHECK_NOT_CALLED(QueryService_IHttpSecurity); 3188 CHECK_NOT_CALLED(OnSecurityProblem); 3189 } 3190 } 3191 if(!no_callback) { 3192 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST || test_protocol == WINETEST_TEST) { 3193 if(flags & BINDTEST_INVALID_CN) 3194 CLEAR_CALLED(OnProgress_SENDINGREQUEST); 3195 else if(!abort_start) 3196 CHECK_CALLED(OnProgress_SENDINGREQUEST); 3197 } else if(test_protocol == FTP_TEST) 3198 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST); 3199 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == WINETEST_TEST) { 3200 CLEAR_CALLED(QueryInterface_IHttpNegotiate); 3201 if((!(flags & BINDTEST_INVALID_CN) || (binding_hres == S_OK)) && !abort_start) { 3202 CHECK_CALLED(OnResponse); 3203 } 3204 } 3205 if((!(flags & BINDTEST_INVALID_CN) || binding_hres == S_OK) && !abort_start) { 3206 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 3207 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 3208 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA); 3209 } 3210 if(test_protocol == FILE_TEST) 3211 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE); 3212 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FTP_TEST || test_protocol == WINETEST_TEST) 3213 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA); 3214 if((flags & BINDTEST_INVALID_CN)) { 3215 if(binding_hres == S_OK) 3216 CHECK_CALLED(OnDataAvailable); 3217 else 3218 CHECK_NOT_CALLED(OnDataAvailable); 3219 }else if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start) 3220 CHECK_CALLED(OnDataAvailable); 3221 CHECK_CALLED(OnStopBinding); 3222 } 3223 } 3224 3225 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n"); 3226 if(bctx) 3227 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n"); 3228 3229 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3230 http_is_first = FALSE; 3231 3232 if((flags & BINDTEST_INVALID_CN) && onsecurityproblem_hres == S_OK && security_problem != ERROR_INTERNET_SEC_CERT_ERRORS) 3233 invalid_cn_accepted = TRUE; 3234 3235 if(unk) { 3236 BYTE buf[512]; 3237 DWORD readed; 3238 IStream *stream; 3239 3240 hres = IUnknown_QueryInterface(unk, &IID_IStream, (void**)&stream); 3241 ok(hres == S_OK, "Could not get IStream iface: %08x\n", hres); 3242 IUnknown_Release(unk); 3243 3244 do { 3245 readed = 0xdeadbeef; 3246 hres = IStream_Read(stream, buf, sizeof(buf), &readed); 3247 ok(readed != 0xdeadbeef, "readed = 0xdeadbeef\n"); 3248 if(emulate_protocol && test_protocol == HTTP_TEST && readed) 3249 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]); 3250 }while(hres == S_OK); 3251 ok(hres == S_FALSE, "IStream_Read returned %08x\n", hres); 3252 ok(!readed, "readed = %d\n", readed); 3253 3254 IStream_Release(stream); 3255 } 3256 } 3257 3258 static void test_BindToObject(int protocol, DWORD flags, HRESULT exhres) 3259 { 3260 IMoniker *mon; 3261 HRESULT hres; 3262 LPOLESTR display_name; 3263 IBindCtx *bctx; 3264 DWORD regid; 3265 MSG msg; 3266 IUnknown *unk = (IUnknown*)0x00ff00ff; 3267 IBinding *bind; 3268 3269 init_bind_test(protocol, BINDTEST_TOOBJECT|flags, TYMED_ISTREAM); 3270 binding_hres = exhres; 3271 3272 if(emulate_protocol) 3273 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf, 3274 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, ®id); 3275 3276 SET_EXPECT(QueryInterface_IServiceProvider); 3277 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&objbsc, NULL, &bctx); 3278 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres); 3279 CHECK_CALLED(QueryInterface_IServiceProvider); 3280 if(FAILED(hres)) 3281 return; 3282 3283 hres = CreateURLMoniker(NULL, current_url, &mon); 3284 ok(hres == S_OK, "failed to create moniker: %08x\n", hres); 3285 if(FAILED(hres)) { 3286 IBindCtx_Release(bctx); 3287 return; 3288 } 3289 3290 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind); 3291 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n"); 3292 if(SUCCEEDED(hres)) 3293 IBinding_Release(bind); 3294 3295 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name); 3296 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres); 3297 ok(!lstrcmpW(display_name, current_url), "GetDisplayName got wrong name\n"); 3298 CoTaskMemFree(display_name); 3299 3300 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 3301 SET_EXPECT(Obj_GetBindInfo); 3302 SET_EXPECT(QueryInterface_IInternetProtocol); 3303 if(!emulate_protocol) 3304 SET_EXPECT(QueryService_IInternetProtocol); 3305 SET_EXPECT(Obj_OnStartBinding); 3306 if(emulate_protocol) { 3307 if(is_urlmon_protocol(test_protocol)) 3308 SET_EXPECT(SetPriority); 3309 SET_EXPECT(Start); 3310 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3311 SET_EXPECT(Terminate); 3312 if(test_protocol == FILE_TEST) 3313 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 3314 SET_EXPECT(UnlockRequest); 3315 }else { 3316 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3317 SET_EXPECT(QueryInterface_IHttpNegotiate); 3318 SET_EXPECT(BeginningTransaction); 3319 SET_EXPECT(QueryInterface_IHttpNegotiate2); 3320 SET_EXPECT(GetRootSecurityId); 3321 if(http_is_first) 3322 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE); 3323 SET_EXPECT(Obj_OnProgress_CONNECTING); 3324 SET_EXPECT(QueryInterface_IWindowForBindingUI); 3325 SET_EXPECT(QueryService_IWindowForBindingUI); 3326 SET_EXPECT(GetWindow_IWindowForBindingUI); 3327 } 3328 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) 3329 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST); 3330 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3331 SET_EXPECT(QueryInterface_IHttpNegotiate); 3332 SET_EXPECT(OnResponse); 3333 } 3334 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE); 3335 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA); 3336 if(test_protocol == FILE_TEST) 3337 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 3338 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3339 SET_EXPECT(OnProgress_DOWNLOADINGDATA); 3340 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA); 3341 if(SUCCEEDED(hres)) 3342 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE); 3343 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION); 3344 if(exhres == REGDB_E_CLASSNOTREG) { 3345 SET_EXPECT(QueryInterface_IWindowForBindingUI); 3346 SET_EXPECT(QueryService_IWindowForBindingUI); 3347 SET_EXPECT(GetWindow_ICodeInstall); 3348 } 3349 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION); 3350 if(SUCCEEDED(hres)) 3351 SET_EXPECT(OnObjectAvailable); 3352 SET_EXPECT(Obj_OnStopBinding); 3353 } 3354 3355 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk); 3356 3357 if ((test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3358 && hres == HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED)) 3359 { 3360 skip( "Network unreachable, skipping tests\n" ); 3361 return; 3362 } 3363 3364 if(FAILED(exhres)) { 3365 ok(hres == exhres, "BindToObject failed: %08x, expected %08x\n", hres, exhres); 3366 ok(!unk, "unk = %p, expected NULL\n", unk); 3367 }else if(bindf & BINDF_ASYNCHRONOUS) { 3368 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToObject failed: %08x\n", hres); 3369 ok(unk == NULL, "istr should be NULL\n"); 3370 }else { 3371 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres); 3372 ok(unk != NULL, "unk == NULL\n"); 3373 if(emulate_protocol) 3374 ok(unk == (IUnknown*)&PersistMoniker, "unk != PersistMoniker\n"); 3375 } 3376 if(unk) 3377 IUnknown_Release(unk); 3378 3379 while((bindf & BINDF_ASYNCHRONOUS) && 3380 !((!emulate_protocol || stopped_binding) && stopped_obj_binding) && GetMessageA(&msg,NULL,0,0)) { 3381 TranslateMessage(&msg); 3382 DispatchMessageA(&msg); 3383 } 3384 3385 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); 3386 CHECK_CALLED(Obj_GetBindInfo); 3387 CHECK_CALLED(QueryInterface_IInternetProtocol); 3388 if(!emulate_protocol) 3389 CHECK_CALLED(QueryService_IInternetProtocol); 3390 CHECK_CALLED(Obj_OnStartBinding); 3391 if(emulate_protocol) { 3392 if(is_urlmon_protocol(test_protocol)) 3393 CLEAR_CALLED(SetPriority); /* Not called by IE11 */ 3394 CHECK_CALLED(Start); 3395 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3396 CHECK_CALLED(Terminate); 3397 if(test_protocol == FILE_TEST) 3398 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */ 3399 CHECK_CALLED(UnlockRequest); 3400 }else { 3401 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3402 CHECK_CALLED(QueryInterface_IHttpNegotiate); 3403 CHECK_CALLED(BeginningTransaction); 3404 if (have_IHttpNegotiate2) 3405 { 3406 CHECK_CALLED(QueryInterface_IHttpNegotiate2); 3407 CHECK_CALLED(GetRootSecurityId); 3408 } 3409 if(http_is_first) { 3410 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE); 3411 CHECK_CALLED(Obj_OnProgress_CONNECTING); 3412 }else { 3413 /* IE7 does call this */ 3414 CLEAR_CALLED(Obj_OnProgress_CONNECTING); 3415 } 3416 CLEAR_CALLED(QueryInterface_IWindowForBindingUI); 3417 CLEAR_CALLED(QueryService_IWindowForBindingUI); 3418 CLEAR_CALLED(GetWindow_IWindowForBindingUI); 3419 } 3420 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) { 3421 if(post_test) 3422 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST); 3423 else 3424 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST); 3425 } 3426 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3427 CLEAR_CALLED(QueryInterface_IHttpNegotiate); 3428 CHECK_CALLED(OnResponse); 3429 } 3430 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE); 3431 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA); 3432 if(test_protocol == FILE_TEST) 3433 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE); 3434 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3435 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA); 3436 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA); 3437 if(SUCCEEDED(hres)) 3438 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE); 3439 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION); 3440 if(exhres == REGDB_E_CLASSNOTREG) { 3441 todo_wine CHECK_CALLED(QueryInterface_IWindowForBindingUI); 3442 todo_wine CHECK_CALLED(QueryService_IWindowForBindingUI); 3443 todo_wine CHECK_CALLED(GetWindow_ICodeInstall); 3444 } 3445 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION); 3446 if(SUCCEEDED(hres)) 3447 CHECK_CALLED(OnObjectAvailable); 3448 CHECK_CALLED(Obj_OnStopBinding); 3449 } 3450 3451 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n"); 3452 IBindCtx_Release(bctx); 3453 3454 if(emulate_protocol) 3455 CoRevokeClassObject(regid); 3456 3457 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3458 http_is_first = FALSE; 3459 } 3460 3461 static void test_URLDownloadToFile(DWORD prot, BOOL emul) 3462 { 3463 BOOL res; 3464 HRESULT hres; 3465 3466 init_bind_test(prot, BINDTEST_FILEDWLAPI | (emul ? BINDTEST_EMULATE : 0), TYMED_FILE); 3467 3468 SET_EXPECT(GetBindInfo); 3469 SET_EXPECT(QueryInterface_IInternetProtocol); 3470 SET_EXPECT(QueryInterface_IServiceProvider); 3471 if(!emulate_protocol) 3472 SET_EXPECT(QueryService_IInternetProtocol); 3473 SET_EXPECT(OnStartBinding); 3474 if(emulate_protocol) { 3475 if(is_urlmon_protocol(test_protocol)) 3476 SET_EXPECT(SetPriority); 3477 SET_EXPECT(Start); 3478 SET_EXPECT(UnlockRequest); 3479 }else { 3480 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3481 SET_EXPECT(QueryInterface_IHttpNegotiate); 3482 SET_EXPECT(BeginningTransaction); 3483 SET_EXPECT(QueryInterface_IHttpNegotiate2); 3484 SET_EXPECT(GetRootSecurityId); 3485 SET_EXPECT(QueryInterface_IWindowForBindingUI); 3486 SET_EXPECT(OnProgress_CONNECTING); 3487 } 3488 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST || test_protocol == FILE_TEST) 3489 SET_EXPECT(OnProgress_SENDINGREQUEST); 3490 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3491 SET_EXPECT(QueryInterface_IHttpNegotiate); 3492 SET_EXPECT(OnResponse); 3493 } 3494 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 3495 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 3496 if(test_protocol == FILE_TEST) 3497 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE); 3498 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3499 SET_EXPECT(OnProgress_DOWNLOADINGDATA); 3500 SET_EXPECT(OnProgress_ENDDOWNLOADDATA); 3501 SET_EXPECT(OnStopBinding); 3502 } 3503 3504 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc); 3505 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres); 3506 3507 CHECK_CALLED(GetBindInfo); 3508 CHECK_CALLED(QueryInterface_IInternetProtocol); 3509 if(!emulate_protocol) { 3510 CHECK_CALLED(QueryInterface_IServiceProvider); 3511 CHECK_CALLED(QueryService_IInternetProtocol); 3512 }else { 3513 CLEAR_CALLED(QueryInterface_IServiceProvider); 3514 } 3515 CHECK_CALLED(OnStartBinding); 3516 if(emulate_protocol) { 3517 if(is_urlmon_protocol(test_protocol)) 3518 CLEAR_CALLED(SetPriority); /* Not called by IE11 */ 3519 CHECK_CALLED(Start); 3520 CHECK_CALLED(UnlockRequest); 3521 }else { 3522 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3523 CHECK_CALLED(QueryInterface_IHttpNegotiate); 3524 CHECK_CALLED(BeginningTransaction); 3525 if (have_IHttpNegotiate2) 3526 { 3527 CHECK_CALLED(QueryInterface_IHttpNegotiate2); 3528 CHECK_CALLED(GetRootSecurityId); 3529 } 3530 CLEAR_CALLED(QueryInterface_IWindowForBindingUI); 3531 CLEAR_CALLED(OnProgress_CONNECTING); 3532 } 3533 if(test_protocol == FILE_TEST) 3534 CHECK_CALLED(OnProgress_SENDINGREQUEST); 3535 else if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3536 CLEAR_CALLED(OnProgress_SENDINGREQUEST); /* not called by IE7 */ 3537 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) { 3538 CLEAR_CALLED(QueryInterface_IHttpNegotiate); 3539 CHECK_CALLED(OnResponse); 3540 } 3541 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 3542 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 3543 if(test_protocol == FILE_TEST) 3544 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE); 3545 if(test_protocol == HTTP_TEST || test_protocol == HTTPS_TEST) 3546 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA); 3547 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA); 3548 CHECK_CALLED(OnStopBinding); 3549 } 3550 3551 res = DeleteFileA(dwl_htmlA); 3552 ok(res, "DeleteFile failed: %u\n", GetLastError()); 3553 3554 if(prot != FILE_TEST || emul) 3555 return; 3556 3557 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, NULL); 3558 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres); 3559 3560 res = DeleteFileA(dwl_htmlA); 3561 ok(res, "DeleteFile failed: %u\n", GetLastError()); 3562 } 3563 3564 static void test_URLDownloadToFile_abort(void) 3565 { 3566 HRESULT hres; 3567 3568 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_PROGRESS, TYMED_FILE); 3569 3570 SET_EXPECT(GetBindInfo); 3571 SET_EXPECT(QueryInterface_IInternetProtocol); 3572 SET_EXPECT(QueryInterface_IServiceProvider); 3573 SET_EXPECT(QueryService_IInternetProtocol); 3574 SET_EXPECT(OnStartBinding); 3575 SET_EXPECT(QueryInterface_IHttpNegotiate); 3576 SET_EXPECT(QueryInterface_IHttpNegotiate2); 3577 SET_EXPECT(BeginningTransaction); 3578 SET_EXPECT(GetRootSecurityId); 3579 SET_EXPECT(QueryInterface_IWindowForBindingUI); 3580 SET_EXPECT(OnProgress_CONNECTING); 3581 SET_EXPECT(OnProgress_SENDINGREQUEST); 3582 SET_EXPECT(OnStopBinding); 3583 3584 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc); 3585 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres); 3586 3587 CHECK_CALLED(GetBindInfo); 3588 CHECK_CALLED(QueryInterface_IInternetProtocol); 3589 CHECK_CALLED(QueryInterface_IServiceProvider); 3590 CHECK_CALLED(QueryService_IInternetProtocol); 3591 CHECK_CALLED(OnStartBinding); 3592 CHECK_CALLED(QueryInterface_IHttpNegotiate); 3593 CHECK_CALLED(QueryInterface_IHttpNegotiate2); 3594 CHECK_CALLED(BeginningTransaction); 3595 CHECK_CALLED(GetRootSecurityId); 3596 CLEAR_CALLED(QueryInterface_IWindowForBindingUI); 3597 CHECK_CALLED(OnProgress_SENDINGREQUEST); 3598 CLEAR_CALLED(OnProgress_CONNECTING); 3599 CHECK_CALLED(OnStopBinding); 3600 3601 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE); 3602 3603 SET_EXPECT(GetBindInfo); 3604 SET_EXPECT(QueryInterface_IInternetProtocol); 3605 SET_EXPECT(QueryInterface_IServiceProvider); 3606 SET_EXPECT(QueryService_IInternetProtocol); 3607 SET_EXPECT(OnStartBinding); 3608 SET_EXPECT(OnStopBinding); 3609 3610 abort_hres = E_ABORT; 3611 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc); 3612 ok(hres == E_ABORT, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres); 3613 3614 CHECK_CALLED(GetBindInfo); 3615 todo_wine CHECK_CALLED(QueryInterface_IInternetProtocol); 3616 todo_wine CHECK_CALLED(QueryInterface_IServiceProvider); 3617 todo_wine CHECK_CALLED(QueryService_IInternetProtocol); 3618 CHECK_CALLED(OnStartBinding); 3619 CHECK_CALLED(OnStopBinding); 3620 3621 init_bind_test(HTTP_TEST, BINDTEST_FILEDWLAPI|BINDTEST_ABORT_START, TYMED_FILE); 3622 3623 SET_EXPECT(GetBindInfo); 3624 SET_EXPECT(QueryInterface_IInternetProtocol); 3625 SET_EXPECT(QueryInterface_IServiceProvider); 3626 SET_EXPECT(QueryService_IInternetProtocol); 3627 SET_EXPECT(OnStartBinding); 3628 SET_EXPECT(QueryInterface_IHttpNegotiate); 3629 SET_EXPECT(QueryInterface_IHttpNegotiate2); 3630 SET_EXPECT(BeginningTransaction); 3631 SET_EXPECT(GetRootSecurityId); 3632 SET_EXPECT(QueryInterface_IWindowForBindingUI); 3633 SET_EXPECT(OnResponse); 3634 SET_EXPECT(OnProgress_CONNECTING); 3635 SET_EXPECT(OnProgress_SENDINGREQUEST); 3636 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE); 3637 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA); 3638 SET_EXPECT(OnProgress_DOWNLOADINGDATA); 3639 SET_EXPECT(OnProgress_ENDDOWNLOADDATA); 3640 SET_EXPECT(OnStopBinding); 3641 3642 /* URLDownloadToFile doesn't abort if E_NOTIMPL is returned from the 3643 * IBindStatusCallback's OnStartBinding function. 3644 */ 3645 abort_hres = E_NOTIMPL; 3646 hres = URLDownloadToFileW(NULL, current_url, dwl_htmlW, 0, (IBindStatusCallback*)&bsc); 3647 ok(hres == S_OK, "URLDownloadToFile failed: %08x\n", hres); 3648 3649 CHECK_CALLED(GetBindInfo); 3650 CHECK_CALLED(QueryInterface_IInternetProtocol); 3651 CHECK_CALLED(QueryInterface_IServiceProvider); 3652 CHECK_CALLED(QueryService_IInternetProtocol); 3653 CHECK_CALLED(OnStartBinding); 3654 CHECK_CALLED(QueryInterface_IHttpNegotiate); 3655 CHECK_CALLED(QueryInterface_IHttpNegotiate2); 3656 CHECK_CALLED(BeginningTransaction); 3657 CHECK_CALLED(GetRootSecurityId); 3658 CLEAR_CALLED(QueryInterface_IWindowForBindingUI); 3659 CHECK_CALLED(OnResponse); 3660 CLEAR_CALLED(OnProgress_CONNECTING); 3661 CHECK_CALLED(OnProgress_SENDINGREQUEST); 3662 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE); 3663 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA); 3664 CHECK_CALLED(OnProgress_DOWNLOADINGDATA); 3665 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA); 3666 CHECK_CALLED(OnStopBinding); 3667 3668 DeleteFileA(dwl_htmlA); 3669 } 3670 3671 static void set_file_url(char *path) 3672 { 3673 CHAR file_urlA[INTERNET_MAX_URL_LENGTH]; 3674 3675 lstrcpyA(file_urlA, "file://"); 3676 lstrcatA(file_urlA, path); 3677 MultiByteToWideChar(CP_ACP, 0, file_urlA, -1, file_url, INTERNET_MAX_URL_LENGTH); 3678 } 3679 3680 static void create_file(const char *file_name, const char *content) 3681 { 3682 HANDLE file; 3683 DWORD size; 3684 CHAR path[MAX_PATH]; 3685 3686 file = CreateFileA(file_name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 3687 FILE_ATTRIBUTE_NORMAL, NULL); 3688 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); 3689 if(file == INVALID_HANDLE_VALUE) 3690 return; 3691 3692 if(test_file) 3693 DeleteFileA(test_file); 3694 test_file = file_name; 3695 WriteFile(file, content, strlen(content), &size, NULL); 3696 CloseHandle(file); 3697 3698 GetCurrentDirectoryA(MAX_PATH, path); 3699 lstrcatA(path, "\\"); 3700 lstrcatA(path, file_name); 3701 set_file_url(path); 3702 } 3703 3704 static void create_html_file(void) 3705 { 3706 create_file(wszIndexHtmlA, "<HTML></HTML>"); 3707 } 3708 3709 static void create_cache_file(void) 3710 { 3711 char buf[6500], curdir[MAX_PATH]; 3712 HANDLE file; 3713 DWORD size; 3714 3715 file = CreateFileA(test_txtA, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 3716 FILE_ATTRIBUTE_NORMAL, NULL); 3717 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n"); 3718 if(file == INVALID_HANDLE_VALUE) 3719 return; 3720 3721 memset(buf, 'X', sizeof(buf)); 3722 WriteFile(file, buf, sizeof(buf), &size, NULL); 3723 CloseHandle(file); 3724 3725 memset(curdir, 0, sizeof(curdir)); 3726 GetCurrentDirectoryA(MAX_PATH, curdir); 3727 lstrcatA(curdir, "\\"); 3728 lstrcatA(curdir, test_txtA); 3729 3730 MultiByteToWideChar(CP_ACP, 0, curdir, -1, cache_file_name, MAX_PATH); 3731 } 3732 3733 static void test_ReportResult(HRESULT exhres) 3734 { 3735 IMoniker *mon = NULL; 3736 IBindCtx *bctx = NULL; 3737 IUnknown *unk = (void*)0xdeadbeef; 3738 HRESULT hres; 3739 3740 init_bind_test(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 3741 binding_hres = exhres; 3742 3743 hres = CreateURLMoniker(NULL, about_blankW, &mon); 3744 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres); 3745 3746 SET_EXPECT(QueryInterface_IServiceProvider); 3747 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx); 3748 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres); 3749 CHECK_CALLED(QueryInterface_IServiceProvider); 3750 3751 SET_EXPECT(QueryInterface_IBindStatusCallbackEx); 3752 SET_EXPECT(GetBindInfo); 3753 SET_EXPECT(QueryInterface_IInternetProtocol); 3754 SET_EXPECT(OnStartBinding); 3755 if(is_urlmon_protocol(test_protocol)) 3756 SET_EXPECT(SetPriority); 3757 SET_EXPECT(Start); 3758 3759 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk); 3760 if(SUCCEEDED(exhres)) 3761 ok(hres == S_OK || hres == MK_S_ASYNCHRONOUS, "BindToStorage failed: %08x\n", hres); 3762 else 3763 ok(hres == exhres || hres == MK_S_ASYNCHRONOUS, 3764 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres, exhres); 3765 3766 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */ 3767 CHECK_CALLED(GetBindInfo); 3768 CHECK_CALLED(QueryInterface_IInternetProtocol); 3769 CHECK_CALLED(OnStartBinding); 3770 if(is_urlmon_protocol(test_protocol)) 3771 CLEAR_CALLED(SetPriority); /* Not called by IE11 */ 3772 CHECK_CALLED(Start); 3773 3774 ok(unk == NULL, "unk=%p\n", unk); 3775 3776 IBindCtx_Release(bctx); 3777 IMoniker_Release(mon); 3778 } 3779 3780 static void test_BindToStorage_fail(void) 3781 { 3782 IMoniker *mon = NULL; 3783 IBindCtx *bctx = NULL; 3784 IUnknown *unk; 3785 HRESULT hres; 3786 3787 hres = CreateURLMoniker(NULL, about_blankW, &mon); 3788 ok(hres == S_OK, "CreateURLMoniker failed: %08x\n", hres); 3789 if(FAILED(hres)) 3790 return; 3791 3792 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0); 3793 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres); 3794 3795 unk = (void*)0xdeadbeef; 3796 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk); 3797 ok(hres == MK_E_SYNTAX || hres == INET_E_DATA_NOT_AVAILABLE, 3798 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres); 3799 ok(unk == NULL, "got %p\n", unk); 3800 3801 IBindCtx_Release(bctx); 3802 3803 IMoniker_Release(mon); 3804 3805 test_ReportResult(E_NOTIMPL); 3806 test_ReportResult(S_FALSE); 3807 } 3808 3809 static void test_StdURLMoniker(void) 3810 { 3811 IMoniker *mon, *async_mon; 3812 LPOLESTR display_name; 3813 IBindCtx *bctx; 3814 IUnknown *unk; 3815 HRESULT hres; 3816 3817 hres = CoCreateInstance(&IID_IInternet, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, 3818 &IID_IMoniker, (void**)&mon); 3819 ok(hres == S_OK, "Could not create IInternet instance: %08x\n", hres); 3820 if(FAILED(hres)) 3821 return; 3822 3823 hres = IMoniker_QueryInterface(mon, &IID_IAsyncMoniker, (void**)&async_mon); 3824 ok(hres == S_OK, "Could not get IAsyncMoniker iface: %08x\n", hres); 3825 ok(mon == async_mon, "mon != async_mon\n"); 3826 IMoniker_Release(async_mon); 3827 3828 hres = IMoniker_GetDisplayName(mon, NULL, NULL, &display_name); 3829 ok(hres == E_OUTOFMEMORY, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres); 3830 3831 if(pCreateUri) { 3832 IUriContainer *uri_container; 3833 IUri *uri; 3834 3835 hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container); 3836 ok(hres == S_OK, "Could not get IUriMoniker iface: %08x\n", hres); 3837 3838 3839 uri = (void*)0xdeadbeef; 3840 hres = IUriContainer_GetIUri(uri_container, &uri); 3841 ok(hres == S_FALSE, "GetIUri failed: %08x\n", hres); 3842 ok(!uri, "uri = %p, expected NULL\n", uri); 3843 3844 IUriContainer_Release(uri_container); 3845 } 3846 3847 SET_EXPECT(QueryInterface_IServiceProvider); 3848 hres = CreateAsyncBindCtx(0, (IBindStatusCallback*)&bsc, NULL, &bctx); 3849 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres); 3850 CHECK_CALLED(QueryInterface_IServiceProvider); 3851 3852 if(pCreateUri) { /* Skip these tests on old IEs */ 3853 unk = (void*)0xdeadbeef; 3854 hres = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&unk); 3855 ok(hres == MK_E_SYNTAX, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres); 3856 ok(!unk, "unk = %p\n", unk); 3857 3858 unk = (void*)0xdeadbeef; 3859 hres = IMoniker_BindToObject(mon, bctx, NULL, &IID_IUnknown, (void**)&unk); 3860 ok(hres == MK_E_SYNTAX, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres); 3861 ok(!unk, "unk = %p\n", unk); 3862 } 3863 3864 IMoniker_Release(mon); 3865 } 3866 3867 static void register_protocols(void) 3868 { 3869 IInternetSession *session; 3870 HRESULT hres; 3871 3872 static const WCHAR winetestW[] = {'w','i','n','e','t','e','s','t',0}; 3873 3874 hres = CoInternetGetSession(0, &session, 0); 3875 ok(hres == S_OK, "CoInternetGetSession failed: %08x\n", hres); 3876 if(FAILED(hres)) 3877 return; 3878 3879 hres = IInternetSession_RegisterNameSpace(session, &protocol_cf, &IID_NULL, 3880 winetestW, 0, NULL, 0); 3881 ok(hres == S_OK, "RegisterNameSpace failed: %08x\n", hres); 3882 3883 IInternetSession_Release(session); 3884 } 3885 3886 static BOOL can_do_https(void) 3887 { 3888 HINTERNET ses, con, req; 3889 BOOL ret; 3890 3891 ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); 3892 ok(ses != NULL, "InternetOpen failed\n"); 3893 3894 con = InternetConnectA(ses, "test.winehq.org", INTERNET_DEFAULT_HTTPS_PORT, 3895 NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); 3896 ok(con != NULL, "InternetConnect failed\n"); 3897 3898 req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL, 3899 INTERNET_FLAG_SECURE, 0); 3900 ok(req != NULL, "HttpOpenRequest failed\n"); 3901 3902 ret = HttpSendRequestA(req, NULL, 0, NULL, 0); 3903 ok(ret || broken(GetLastError() == ERROR_INTERNET_CANNOT_CONNECT), 3904 "request failed: %u\n", GetLastError()); 3905 3906 InternetCloseHandle(req); 3907 InternetCloseHandle(con); 3908 InternetCloseHandle(ses); 3909 return ret; 3910 } 3911 3912 START_TEST(url) 3913 { 3914 HMODULE hurlmon; 3915 3916 hurlmon = GetModuleHandleA("urlmon.dll"); 3917 pCreateAsyncBindCtxEx = (void*) GetProcAddress(hurlmon, "CreateAsyncBindCtxEx"); 3918 3919 if(!GetProcAddress(hurlmon, "CompareSecurityIds")) { 3920 win_skip("Too old IE\n"); 3921 return; 3922 } 3923 3924 pCreateUri = (void*) GetProcAddress(hurlmon, "CreateUri"); 3925 if(!pCreateUri) 3926 win_skip("IUri not supported\n"); 3927 3928 complete_event = CreateEventW(NULL, FALSE, FALSE, NULL); 3929 complete_event2 = CreateEventW(NULL, FALSE, FALSE, NULL); 3930 thread_id = GetCurrentThreadId(); 3931 create_html_file(); 3932 create_cache_file(); 3933 register_protocols(); 3934 3935 test_create(); 3936 3937 trace("test CreateAsyncBindCtx...\n"); 3938 test_CreateAsyncBindCtx(); 3939 3940 trace("test CreateAsyncBindCtxEx...\n"); 3941 test_CreateAsyncBindCtxEx(); 3942 3943 trace("test RegisterBindStatusCallback...\n"); 3944 if(test_RegisterBindStatusCallback()) { 3945 trace("test BindToStorage failures...\n"); 3946 test_BindToStorage_fail(); 3947 3948 trace("synchronous http test (COM not initialised)...\n"); 3949 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM); 3950 3951 CoInitialize(NULL); 3952 3953 trace("test StdURLMoniker...\n"); 3954 test_StdURLMoniker(); 3955 3956 trace("synchronous http test...\n"); 3957 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM); 3958 3959 trace("emulated synchronous http test (to file)...\n"); 3960 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE); 3961 3962 trace("synchronous http test (to object)...\n"); 3963 test_BindToObject(HTTP_TEST, 0, S_OK); 3964 3965 trace("emulated synchronous http test (with cache)...\n"); 3966 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM); 3967 3968 trace("emulated synchronous http test (with cache, no read)...\n"); 3969 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM); 3970 3971 trace("synchronous http test (with cache, no read)...\n"); 3972 test_BindToStorage(HTTP_TEST, BINDTEST_USE_CACHE|BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM); 3973 3974 trace("synchronous file test...\n"); 3975 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM); 3976 3977 trace("emulated synchronous file test (to file)...\n"); 3978 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE); 3979 3980 trace("synchronous file test (to object)...\n"); 3981 test_BindToObject(FILE_TEST, 0, S_OK); 3982 3983 trace("bind to an object of not registered MIME type...\n"); 3984 create_file("test.winetest", "\x01\x02\x03xxxxxxxxxxxxxxxxxxxxxxxxx"); 3985 test_BindToObject(FILE_TEST, 0, REGDB_E_CLASSNOTREG); 3986 create_html_file(); 3987 3988 trace("file test (no callback)...\n"); 3989 test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM); 3990 3991 if(can_do_https()) { 3992 trace("synchronous https test (invalid CN, dialog)\n"); 3993 onsecurityproblem_hres = S_FALSE; 3994 http_is_first = TRUE; 3995 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM); 3996 3997 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; 3998 3999 trace("asynchronous https test (invalid CN, fail)\n"); 4000 onsecurityproblem_hres = E_FAIL; 4001 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM); 4002 4003 trace("asynchronous https test (invalid CN, accept)\n"); 4004 onsecurityproblem_hres = S_OK; 4005 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM); 4006 4007 trace("asynchronous https test (invalid CN, dialog 2)\n"); 4008 onsecurityproblem_hres = S_FALSE; 4009 test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM); 4010 invalid_cn_accepted = FALSE; 4011 4012 trace("asynchronous https test...\n"); 4013 test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM); 4014 }else { 4015 win_skip("Skipping https testt\n"); 4016 } 4017 4018 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA; 4019 4020 trace("winetest test (async switch)...\n"); 4021 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_ASYNC_SWITCH, TYMED_ISTREAM); 4022 4023 trace("about test (no read)...\n"); 4024 test_BindToStorage(ABOUT_TEST, BINDTEST_NO_CALLBACK_READ, TYMED_ISTREAM); 4025 4026 trace("http test...\n"); 4027 test_BindToStorage(HTTP_TEST, 0, TYMED_ISTREAM); 4028 4029 trace("http test (to file)...\n"); 4030 test_BindToStorage(HTTP_TEST, 0, TYMED_FILE); 4031 4032 trace("http test (to object)...\n"); 4033 test_BindToObject(HTTP_TEST, 0, S_OK); 4034 4035 trace("http test (short response)...\n"); 4036 test_BindToStorage(HTTP_TEST, BINDTEST_HTTPRESPONSE|BINDTEST_ALLOW_FINDINGRESOURCE, TYMED_ISTREAM); 4037 4038 trace("http test (short response, to object)...\n"); 4039 test_BindToObject(HTTP_TEST, 0, S_OK); 4040 4041 trace("http test (abort start binding E_NOTIMPL)...\n"); 4042 abort_hres = E_NOTIMPL; 4043 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE); 4044 4045 trace("http test (abort start binding E_ABORT)...\n"); 4046 abort_hres = E_ABORT; 4047 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_START, TYMED_FILE); 4048 4049 trace("http test (abort progress)...\n"); 4050 test_BindToStorage(HTTP_TEST, BINDTEST_ABORT_PROGRESS|BINDTEST_ALLOW_FINDINGRESOURCE, TYMED_FILE); 4051 4052 trace("emulated http test...\n"); 4053 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4054 4055 trace("emulated http test (to object)...\n"); 4056 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE, S_OK); 4057 4058 trace("emulated http test (to object, redirect)...\n"); 4059 test_BindToObject(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, S_OK); 4060 4061 trace("emulated http test (to file)...\n"); 4062 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_FILE); 4063 4064 trace("emulated http test (redirect)...\n"); 4065 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_REDIRECT, TYMED_ISTREAM); 4066 4067 trace("emulated http test (with cache)...\n"); 4068 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_USE_CACHE, TYMED_ISTREAM); 4069 4070 trace("winetest test (no callback)...\n"); 4071 test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM); 4072 4073 trace("emulated https test...\n"); 4074 test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4075 4076 trace("about test...\n"); 4077 test_BindToStorage(ABOUT_TEST, 0, TYMED_ISTREAM); 4078 4079 trace("about test (to file)...\n"); 4080 test_BindToStorage(ABOUT_TEST, 0, TYMED_FILE); 4081 4082 trace("about test (to object)...\n"); 4083 test_BindToObject(ABOUT_TEST, 0, S_OK); 4084 4085 trace("emulated about test...\n"); 4086 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4087 4088 trace("emulated about test (to file)...\n"); 4089 test_BindToStorage(ABOUT_TEST, BINDTEST_EMULATE, TYMED_FILE); 4090 4091 trace("emulated about test (to object)...\n"); 4092 test_BindToObject(ABOUT_TEST, BINDTEST_EMULATE, S_OK); 4093 4094 trace("emulalated test reporting result in read...\n"); 4095 test_BindToStorage(WINETEST_SYNC_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4096 4097 trace("file test...\n"); 4098 test_BindToStorage(FILE_TEST, 0, TYMED_ISTREAM); 4099 4100 trace("file test (to file)...\n"); 4101 test_BindToStorage(FILE_TEST, 0, TYMED_FILE); 4102 4103 trace("file test (to object)...\n"); 4104 test_BindToObject(FILE_TEST, 0, S_OK); 4105 4106 trace("emulated file test...\n"); 4107 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4108 4109 trace("emulated file test (to file)...\n"); 4110 test_BindToStorage(FILE_TEST, BINDTEST_EMULATE, TYMED_FILE); 4111 4112 trace("emulated file test (to object)...\n"); 4113 test_BindToObject(FILE_TEST, BINDTEST_EMULATE, S_OK); 4114 4115 trace("emulated its test...\n"); 4116 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4117 4118 trace("emulated its test (to file)...\n"); 4119 test_BindToStorage(ITS_TEST, BINDTEST_EMULATE, TYMED_FILE); 4120 4121 trace("emulated mk test...\n"); 4122 test_BindToStorage(MK_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4123 4124 trace("test URLDownloadToFile for file protocol...\n"); 4125 test_URLDownloadToFile(FILE_TEST, FALSE); 4126 4127 trace("test URLDownloadToFile for emulated file protocol...\n"); 4128 test_URLDownloadToFile(FILE_TEST, TRUE); 4129 4130 trace("test URLDownloadToFile for http protocol...\n"); 4131 test_URLDownloadToFile(HTTP_TEST, FALSE); 4132 4133 trace("test URLDownloadToFile abort...\n"); 4134 test_URLDownloadToFile_abort(); 4135 4136 trace("test emulated http abort...\n"); 4137 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE|BINDTEST_ABORT, TYMED_ISTREAM); 4138 4139 bindf |= BINDF_NOWRITECACHE; 4140 4141 trace("ftp test...\n"); 4142 test_BindToStorage(FTP_TEST, 0, TYMED_ISTREAM); 4143 4144 trace("test failures...\n"); 4145 test_BindToStorage_fail(); 4146 4147 bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE; 4148 only_check_prot_args = TRUE; /* Fail after checking arguments to Protocol_Start */ 4149 4150 trace("check emulated http protocol arguments...\n"); 4151 test_BindToStorage(HTTP_TEST, BINDTEST_EMULATE, TYMED_ISTREAM); 4152 } 4153 4154 DeleteFileA(test_file); 4155 DeleteFileA(test_txtA); 4156 CloseHandle(complete_event); 4157 CloseHandle(complete_event2); 4158 CoUninitialize(); 4159 } 4160