ReactOS 0.4.15-dev-8131-g4988de4
url.c
Go to the documentation of this file.
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#include <stdarg.h>
23#include <stdio.h>
24
25#define COBJMACROS
26#define NONAMELESSUNION
27#define CONST_VTABLE
28
29#include "windef.h"
30#include "winbase.h"
31#include "initguid.h"
32#include "urlmon.h"
33#include "wininet.h"
34#include "mshtml.h"
35#include "shlwapi.h"
36
37#include "wine/test.h"
38
39static HRESULT (WINAPI *pCreateAsyncBindCtxEx)(IBindCtx *, DWORD,
41static HRESULT (WINAPI *pCreateUri)(LPCWSTR, DWORD, DWORD_PTR, IUri**);
42
43DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
45DEFINE_GUID(IID_IBindStatusCallbackHolder,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
46static const IID IID_undocumentedIE11 = {0xd5ae15f6,0x2032,0x488e,{0x8f,0x96,0xf9,0x24,0x06,0xd8,0xd8,0xb4}};
48
49#define DEFINE_EXPECT(func) \
50 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
51
52#define SET_EXPECT(func) \
53 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
54
55#define CHECK_EXPECT2(func) \
56 do { \
57 ok(expect_ ##func, "unexpected call " #func "\n"); \
58 called_ ## func = TRUE; \
59 }while(0)
60
61#define CHECK_EXPECT(func) \
62 do { \
63 CHECK_EXPECT2(func); \
64 expect_ ## func = FALSE; \
65 }while(0)
66
67#define CHECK_CALLED(func) \
68 do { \
69 ok(called_ ## func, "expected " #func "\n"); \
70 expect_ ## func = called_ ## func = FALSE; \
71 }while(0)
72
73#define CHECK_NOT_CALLED(func) \
74 do { \
75 ok(!called_ ## func, "unexpected " #func "\n"); \
76 expect_ ## func = called_ ## func = FALSE; \
77 }while(0)
78
79#define CHECK_CALLED_BROKEN(func) \
80 do { \
81 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
82 expect_ ## func = called_ ## func = FALSE; \
83 }while(0)
84
85#define CLEAR_CALLED(func) \
86 expect_ ## func = called_ ## func = FALSE
87
88DEFINE_EXPECT(QueryInterface_IServiceProvider);
89DEFINE_EXPECT(QueryInterface_IHttpNegotiate);
90DEFINE_EXPECT(QueryInterface_IBindStatusCallback);
91DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx);
92DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder);
93DEFINE_EXPECT(QueryInterface_IAuthenticate);
94DEFINE_EXPECT(QueryInterface_IInternetProtocol);
95DEFINE_EXPECT(QueryInterface_IWindowForBindingUI);
96DEFINE_EXPECT(QueryInterface_IHttpSecurity);
97DEFINE_EXPECT(QueryService_IAuthenticate);
98DEFINE_EXPECT(QueryService_IInternetProtocol);
99DEFINE_EXPECT(QueryService_IInternetBindInfo);
100DEFINE_EXPECT(QueryService_IWindowForBindingUI);
101DEFINE_EXPECT(QueryService_IHttpSecurity);
102DEFINE_EXPECT(BeginningTransaction);
103DEFINE_EXPECT(OnResponse);
104DEFINE_EXPECT(QueryInterface_IHttpNegotiate2);
105DEFINE_EXPECT(GetRootSecurityId);
106DEFINE_EXPECT(GetBindInfo);
107DEFINE_EXPECT(GetBindInfoEx);
108DEFINE_EXPECT(OnStartBinding);
109DEFINE_EXPECT(OnProgress_FINDINGRESOURCE);
110DEFINE_EXPECT(OnProgress_CONNECTING);
111DEFINE_EXPECT(OnProgress_REDIRECTING);
112DEFINE_EXPECT(OnProgress_SENDINGREQUEST);
113DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE);
114DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA);
115DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA);
116DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA);
117DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
118DEFINE_EXPECT(OnStopBinding);
119DEFINE_EXPECT(OnDataAvailable);
120DEFINE_EXPECT(OnObjectAvailable);
121DEFINE_EXPECT(Obj_OnStartBinding);
122DEFINE_EXPECT(Obj_OnStopBinding);
123DEFINE_EXPECT(Obj_GetBindInfo);
124DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
125DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
126DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST);
127DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
128DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
129DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
130DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
131DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
132DEFINE_EXPECT(Obj_OnProgress_CONNECTING);
133DEFINE_EXPECT(Obj_OnProgress_REDIRECTING);
134DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
138DEFINE_EXPECT(Terminate);
142DEFINE_EXPECT(CreateInstance);
144DEFINE_EXPECT(PutProperty_MIMETYPEPROP);
145DEFINE_EXPECT(PutProperty_CLASSIDPROP);
147DEFINE_EXPECT(GetWindow_IHttpSecurity);
148DEFINE_EXPECT(GetWindow_IWindowForBindingUI);
149DEFINE_EXPECT(GetWindow_ICodeInstall);
150DEFINE_EXPECT(OnSecurityProblem);
151
152static const WCHAR winetest_data_urlW[] =
153 {'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g','/',
154 't','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
155static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
156
157static const WCHAR wszTextHtml[] = {'t','e','x','t','/','h','t','m','l',0};
158
159static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
160
161static const WCHAR wszWineHQSite[] =
162 {'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
163static const WCHAR wszWineHQIP[] =
164 {'4','.','1','5','.','1','8','4','.','7','7',0};
165static const CHAR wszIndexHtmlA[] = "index.html";
166static const WCHAR cache_fileW[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
167static const CHAR dwl_htmlA[] = "dwl.html";
168static const WCHAR dwl_htmlW[] = {'d','w','l','.','h','t','m','l',0};
169static const CHAR test_txtA[] = "test.txt";
170static const WCHAR emptyW[] = {0};
171
175static const WCHAR *reported_url;
176static CHAR mime_type[512];
194static const char *test_file;
195
197
198static enum {
209
210static enum {
215
216static BOOL proxy_active(void)
217{
220 DWORD size;
221
222 if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
224 return FALSE;
225
226 size = sizeof(DWORD);
228 proxy_enable = 0;
229
231
232 return proxy_enable != 0;
233}
234
235static BOOL is_urlmon_protocol(int prot)
236{
237 return prot == FILE_TEST || prot == HTTP_TEST || prot == HTTPS_TEST || prot == FTP_TEST || prot == MK_TEST;
238}
239
241{
242 HRESULT hr;
243 IMoniker *mon1 = NULL;
244 IMoniker *mon2 = NULL;
245
247 ok(hr == E_INVALIDARG,
248 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
249
250 mon1 = (IMoniker *)0xdeadbeef;
251 hr = CreateURLMoniker(NULL, NULL, &mon1);
252 ok(hr == E_INVALIDARG,
253 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
254 ok(mon1 == NULL, "Expected the output pointer to be NULL, got %p\n", mon1);
255
257 ok(hr == E_INVALIDARG,
258 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr);
259
260 hr = CreateURLMoniker(NULL, emptyW, &mon1);
261 ok(hr == S_OK ||
262 broken(hr == MK_E_SYNTAX), /* IE5/IE5.01/IE6 SP2 */
263 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr);
264 if(mon1) IMoniker_Release(mon1);
265
266 hr = CreateURLMoniker(NULL, url1, &mon1);
267 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
268 if(hr == S_OK) {
269 hr = CreateURLMoniker(mon1, url2, &mon2);
270 ok(hr == S_OK, "failed to create moniker: 0x%08x\n", hr);
271 }
272 if(mon1) IMoniker_Release(mon1);
273 if(mon2) IMoniker_Release(mon2);
274}
275
276static void test_create(void)
277{
278 static const WCHAR relativeW[] = {'a','/','b','.','t','x','t',0};
280 IMoniker *mon;
281 IBindCtx *bctx;
282 HRESULT hr;
283
284 static const WCHAR TEST_PART_URL_1[] = {'/','t','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
285
287
288 mon = (void*)0xdeadbeef;
289 hr = CreateURLMoniker(NULL, relativeW, &mon);
290 ok(hr == S_OK, "got 0x%08x\n", hr);
291
292 hr = CreateBindCtx(0, &bctx);
293 ok(hr == S_OK, "got 0x%08x\n", hr);
294
295 stream = (void*)0xdeadbeef;
296 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, (void**)&stream);
297 todo_wine ok(hr == INET_E_UNKNOWN_PROTOCOL, "got 0x%08x\n", hr);
298 ok(stream == NULL, "got %p\n", stream);
299
300 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
301 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
302
303 stream = (void*)0xdeadbeef;
304 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
305 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
306 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
307 "got %p\n", stream);
308
309 IMoniker_Release(mon);
310
311 mon = (void*)0xdaedbeef;
313 ok(hr == S_OK, "got 0x%08x\n", hr);
314
315 stream = (void*)0xdeadbeef;
316 hr = IMoniker_BindToStorage(mon, NULL, NULL, &IID_IStream, (void**)&stream);
317 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
318 ok(stream == NULL || broken(stream == (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
319 "got %p\n", stream);
320
321 hr = IMoniker_BindToStorage(mon, bctx, NULL, &IID_IStream, NULL);
322 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
323
324 IMoniker_Release(mon);
325 IBindCtx_Release(bctx);
326}
327
329{
330 ok(0, "unexpected call\n");
331 return E_NOINTERFACE;
332}
333
335{
336 return 2;
337}
338
340{
341 return 1;
342}
343
345{
347 ok(!nPriority, "nPriority = %d\n", nPriority);
348 return S_OK;
349}
350
352{
353 ok(0, "unexpected call\n");
354 return S_OK;
355}
356
357static const IInternetPriorityVtbl InternetPriorityVtbl = {
363};
364
366
368{
369 static const IID IID_undocumentedIE10 = {0x7daf9908,0x8415,0x4005,{0x95,0xae,0xbd,0x27,0xf6,0xe3,0xdc,0x00}};
370
371 *ppv = NULL;
372
373 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocol, riid)) {
374 *ppv = iface;
375 return S_OK;
376 }
377
378 if(IsEqualGUID(&IID_IInternetPriority, riid)) {
380 return E_NOINTERFACE;
381
383 return S_OK;
384 }
385
386 if(IsEqualGUID(&IID_IInternetProtocolEx, riid))
387 return E_NOINTERFACE; /* TODO */
388
389 if(IsEqualGUID(&IID_undocumentedIE10, riid)) {
390 trace("QI(%s)\n", wine_dbgstr_guid(riid));
391 return E_NOINTERFACE; /* TODO */
392 }
393
394 ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
395 return E_NOINTERFACE;
396}
397
399{
400 return 2;
401}
402
404{
405 return 1;
406}
407
408static void test_switch_fail(void)
409{
411 PROTOCOLDATA protocoldata = {0};
413
414 static BOOL tested_switch_fail;
415
416 if(tested_switch_fail)
417 return;
418
419 tested_switch_fail = TRUE;
420
421 hres = IBinding_QueryInterface(current_binding, &IID_IInternetProtocolSink, (void**)&binding_sink);
422 ok(hres == S_OK, "Could not get IInternetProtocolSink iface: %08x\n", hres);
423 if(SUCCEEDED(hres)) {
424 hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
425 ok(hres == E_FAIL, "Switch failed: %08x, expected E_FAIL\n", hres);
426 IInternetProtocolSink_Release(binding_sink);
427 }
428}
429
431{
432 PROTOCOLDATA protocoldata = {0};
434
435 if(!no_callback) {
437 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
438 else
439 SET_EXPECT(OnProgress_FINDINGRESOURCE);
440 }
441 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
442 BINDSTATUS_FINDINGRESOURCE, wszWineHQSite);
443 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
444 if(!no_callback) {
445 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
447 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE);
448 else
449 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
450 }
451
452 if(!no_callback) {
454 SET_EXPECT(Obj_OnProgress_CONNECTING);
455 else
456 SET_EXPECT(OnProgress_CONNECTING);
457 }
458 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
459 BINDSTATUS_CONNECTING, wszWineHQIP);
460 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
461 if(!no_callback) {
462 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
464 CHECK_CALLED(Obj_OnProgress_CONNECTING);
465 else
466 CHECK_CALLED(OnProgress_CONNECTING);
467 }
468
469 if(!no_callback) {
471 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
472 else
473 SET_EXPECT(OnProgress_SENDINGREQUEST);
474 }
475 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
476 BINDSTATUS_SENDINGREQUEST, NULL);
477 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
478 if(!no_callback) {
479 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
481 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
482 else
483 CHECK_CALLED(OnProgress_SENDINGREQUEST);
484 }
485
486 if(test_redirect) {
488 SET_EXPECT(Obj_OnProgress_REDIRECTING);
489 else
490 SET_EXPECT(OnProgress_REDIRECTING);
491 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_REDIRECTING, winetest_data_urlW);
492 ok(hres == S_OK, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres);
493 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
495 CHECK_CALLED(Obj_OnProgress_REDIRECTING);
496 else
497 CHECK_CALLED(OnProgress_REDIRECTING);
498 }
499
501
502 SET_EXPECT(Continue);
503 prot_state = 1;
504 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
505 ok(hres == S_OK, "Switch failed: %08x\n", hres);
506 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
507
508 CHECK_CALLED(Continue);
510 if(bind_to_object) {
511 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
512 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
513 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
514 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
515 CHECK_CALLED(CreateInstance);
516 CHECK_CALLED(PutProperty_MIMETYPEPROP);
517 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
518 CHECK_CALLED(Load);
519 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
520 CHECK_CALLED(OnObjectAvailable);
521 CHECK_CALLED(Obj_OnStopBinding);
522 }else if(!no_callback) {
523 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
524 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
525 CHECK_CALLED(OnDataAvailable);
526 }else {
528 }
529
530 SET_EXPECT(Continue);
531 prot_state = 2;
532 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
533 ok(hres == S_OK, "Switch failed: %08x\n", hres);
534 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
535 CHECK_CALLED(Continue);
536 if(test_abort) {
537 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
538 CHECK_CALLED(OnStopBinding);
540 return 0;
541 }else {
543 if(!no_callback) {
544 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
545 CHECK_CALLED(OnDataAvailable);
546 }
547 }
548
549 SET_EXPECT(Continue);
550 prot_state = 2;
551 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
552 ok(hres == S_OK, "Switch failed: %08x\n", hres);
553 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
554 CHECK_CALLED(Continue);
556 if(!no_callback) {
557 CHECK_CALLED(OnProgress_DOWNLOADINGDATA);
558 CHECK_CALLED(OnDataAvailable);
559 }
560
561 SET_EXPECT(Continue);
562 prot_state = 3;
563 hres = IInternetProtocolSink_Switch(protocol_sink, &protocoldata);
564 ok(hres == S_OK, "Switch failed: %08x\n", hres);
565 ok( WaitForSingleObject(complete_event, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
566 CHECK_CALLED(Continue);
568 if(!no_callback) {
569 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
570 CHECK_CALLED(OnDataAvailable);
571 CHECK_CALLED(OnStopBinding);
572 }
573
575
577 return 0;
578}
579
581 IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
583{
584 BINDINFO bindinfo;
585 DWORD bind_info, bscf = BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION;
587
588 static const STGMEDIUM stgmed_zero = {0};
589 static const SECURITY_ATTRIBUTES sa_zero = {0};
590
592
593 read = 0;
594
595 reported_url = szUrl;
596 if(!filedwl_api) /* FIXME */
597 ok(szUrl && !lstrcmpW(szUrl, current_url), "wrong url %s\n", wine_dbgstr_w(szUrl));
598 ok(pOIProtSink != NULL, "pOIProtSink == NULL\n");
599 ok(pOIBindInfo != NULL, "pOIBindInfo == NULL\n");
600 ok(grfPI == 0, "grfPI=%d, expected 0\n", grfPI);
601 ok(dwReserved == 0, "dwReserved=%lx, expected 0\n", dwReserved);
602
603 if(!filedwl_api && binding_hres != S_OK) {
604 SET_EXPECT(OnStopBinding);
605 SET_EXPECT(Terminate);
606 hres = IInternetProtocolSink_ReportResult(pOIProtSink, binding_hres, 0, NULL);
607 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
608 CHECK_CALLED(OnStopBinding);
609 CHECK_CALLED(Terminate);
610
611 return S_OK;
612 }
613
614 memset(&bindinfo, 0, sizeof(bindinfo));
615 bindinfo.cbSize = 0;
616 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
617 ok(hres == E_INVALIDARG, "GetBindInfo returned: %08x, expected E_INVALIDARG\n", hres);
618
619 memset(&bindinfo, 0, sizeof(bindinfo));
620 bindinfo.cbSize = sizeof(bindinfo);
621 hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &bind_info, &bindinfo);
622 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
623
624 ok(bind_info & BINDF_FROMURLMON, "BINDF_FROMURLMON is not set\n");
625
626 if(filedwl_api || !is_urlmon_protocol(test_protocol) || tymed != TYMED_ISTREAM ||
627 !(bindf&BINDF_ASYNCSTORAGE) || !(bindf&BINDF_PULLDATA))
628 ok(bind_info & BINDF_NEEDFILE, "BINDF_NEEDFILE is not set\n");
629 else if(test_protocol != MK_TEST) /* IE10 sets BINDF_NEEDFILE for mk: protocol */
630 ok(!(bind_info & BINDF_NEEDFILE), "BINDF_NEEDFILE is set\n");
631
632 bind_info &= ~(BINDF_NEEDFILE|BINDF_FROMURLMON);
634 ok(bind_info == BINDF_PULLDATA, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info);
635 else
636 ok(bind_info == (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)), "bind_info = %x, expected %x\n",
637 bind_info, (bindf & ~(BINDF_NEEDFILE|BINDF_FROMURLMON)));
638
639 ok(bindinfo.cbSize == sizeof(bindinfo), "bindinfo.cbSize = %d\n", bindinfo.cbSize);
640 ok(!bindinfo.szExtraInfo, "bindinfo.szExtraInfo = %p\n", bindinfo.szExtraInfo);
641 ok(!memcmp(&bindinfo.stgmedData, &stgmed_zero, sizeof(STGMEDIUM)), "wrong stgmedData\n");
642 ok(!bindinfo.grfBindInfoF, "bindinfo.grfBindInfoF = %d\n", bindinfo.grfBindInfoF);
643 ok(!bindinfo.dwBindVerb, "bindinfo.dwBindVerb = %d\n", bindinfo.dwBindVerb);
644 ok(!bindinfo.szCustomVerb, "bindinfo.szCustomVerb = %p\n", bindinfo.szCustomVerb);
645 ok(!bindinfo.cbstgmedData, "bindinfo.cbstgmedData = %d\n", bindinfo.cbstgmedData);
646 ok(bindinfo.dwOptions == (bind_to_object ? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo.dwOptions);
647 ok(!bindinfo.dwOptionsFlags, "bindinfo.dwOptionsFlags = %d\n", bindinfo.dwOptionsFlags);
648 ok(!bindinfo.dwCodePage, "bindinfo.dwCodePage = %d\n", bindinfo.dwCodePage);
649 ok(!memcmp(&bindinfo.securityAttributes, &sa_zero, sizeof(sa_zero)), "wrong bindinfo.securityAttributes\n");
650 ok(IsEqualGUID(&bindinfo.iid, &IID_NULL), "wrong bindinfo.iid\n");
651 ok(!bindinfo.pUnk, "bindinfo.pUnk = %p\n", bindinfo.pUnk);
652 ok(!bindinfo.dwReserved, "bindinfo.dwReserved = %d\n", bindinfo.dwReserved);
653
655 return E_FAIL;
656
657 switch(test_protocol) {
658 case MK_TEST:
659 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
660 BINDSTATUS_DIRECTBIND, NULL);
661 ok(hres == S_OK,
662 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
663
664 case FILE_TEST:
665 case ITS_TEST:
667 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST);
668 else
669 SET_EXPECT(OnProgress_SENDINGREQUEST);
670 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
671 BINDSTATUS_SENDINGREQUEST, emptyW);
672 ok(hres == S_OK,
673 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres);
675 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST);
676 else
677 CHECK_CALLED(OnProgress_SENDINGREQUEST);
679 IInternetProtocolSink_AddRef(pOIProtSink);
680 protocol_sink = pOIProtSink;
681 default:
682 break;
683 }
684
688 IHttpNegotiate2 *http_negotiate2;
690 LPWSTR ua = (LPWSTR)0xdeadbeef, accept_mimes[256];
691 LPWSTR additional_headers = (LPWSTR)0xdeadbeef;
692 BYTE sec_id[100];
693 DWORD fetched = 256, size = 100;
694 DWORD tid;
695
696 static const WCHAR wszMimes[] = {'*','/','*',0};
697
698 SET_EXPECT(QueryService_IInternetBindInfo);
699 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_USER_AGENT,
700 &ua, 1, &fetched);
701 CLEAR_CALLED(QueryService_IInternetBindInfo); /* IE <8 */
702
704 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres);
705 ok(fetched == 256, "fetched = %d, expected 254\n", fetched);
706 ok(ua == (LPWSTR)0xdeadbeef, "ua = %p\n", ua);
707
708 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
709 accept_mimes, 256, &fetched);
710 ok(hres == S_OK,
711 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
712 ok(fetched == 1, "fetched = %d, expected 1\n", fetched);
713 ok(!lstrcmpW(wszMimes, accept_mimes[0]), "unexpected mimes\n");
714 CoTaskMemFree(accept_mimes[0]);
715
716 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
717 NULL, 256, &fetched);
719 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
720
721 hres = IInternetBindInfo_GetBindString(pOIBindInfo, BINDSTRING_ACCEPT_MIMES,
722 accept_mimes, 256, NULL);
724 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres);
725
726 hres = IInternetBindInfo_QueryInterface(pOIBindInfo, &IID_IServiceProvider,
727 (void**)&service_provider);
728 ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
729
730 SET_EXPECT(QueryInterface_IHttpNegotiate);
731 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
732 &IID_IHttpNegotiate, (void**)&http_negotiate);
733 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
734 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
735
736 if(!no_callback) {
737 SET_EXPECT(BeginningTransaction);
738 SET_EXPECT(QueryInterface_IHttpNegotiate);
739 }
740 hres = IHttpNegotiate_BeginningTransaction(http_negotiate, current_url,
741 NULL, 0, &additional_headers);
742 if(!no_callback) {
743 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
744 CHECK_CALLED(BeginningTransaction);
745 }
746 IHttpNegotiate_Release(http_negotiate);
747 ok(hres == S_OK, "BeginningTransction failed: %08x\n", hres);
748 ok(additional_headers == NULL, "additional_headers=%p\n", additional_headers);
749
750 SET_EXPECT(QueryInterface_IHttpNegotiate2);
751 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate2,
752 &IID_IHttpNegotiate2, (void**)&http_negotiate2);
753 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
754 ok(hres == S_OK, "QueryService failed: %08x\n", hres);
755
756 size = 512;
757 if(!no_callback) {
758 SET_EXPECT(QueryInterface_IHttpNegotiate2);
759 SET_EXPECT(GetRootSecurityId);
760 }
761 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, sec_id, &size, 0);
762 if(!no_callback) {
763 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2);
764 CHECK_CALLED(GetRootSecurityId);
765 }
766 IHttpNegotiate2_Release(http_negotiate2);
767 ok(hres == E_FAIL, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres);
768 ok(size == (no_callback ? 512 : 13), "size=%d\n", size);
769
770 if(!no_callback) {
771 SET_EXPECT(QueryService_IHttpSecurity);
772 SET_EXPECT(QueryInterface_IHttpSecurity);
773 }
774 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpSecurity,
775 &IID_IHttpSecurity, (void**)&http_security);
776 ok(hres == (no_callback ? E_NOINTERFACE : S_OK), "QueryService failed: 0x%08x\n", hres);
777 if(!no_callback) {
778 CHECK_CALLED(QueryService_IHttpSecurity);
779 CHECK_CALLED(QueryInterface_IHttpSecurity);
780 }
781
782 IServiceProvider_Release(service_provider);
783
784 IInternetProtocolSink_AddRef(pOIProtSink);
785 protocol_sink = pOIProtSink;
786
787 if(async_switch) {
788 PROTOCOLDATA data;
789
790 memset(&data, 0, sizeof(data));
791 data.grfFlags = PI_FORCE_ASYNC;
792 prot_state = 0;
793 hres = IInternetProtocolSink_Switch(pOIProtSink, &data);
794 ok(hres == S_OK, "Switch failed: %08x\n", hres);
795 SET_EXPECT(Continue);
797 return E_PENDING;
798 } else {
800 return S_OK;
801 }
802 }
803
804 if(test_protocol == FILE_TEST) {
805 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
806 BINDSTATUS_CACHEFILENAMEAVAILABLE, file_url+7);
807 ok(hres == S_OK,
808 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
809
811 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
812 else
813 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
814 hres = IInternetProtocolSink_ReportProgress(pOIProtSink,
815 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
816 ok(hres == S_OK,
817 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres);
819 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
820 else
821 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
822 }else if(test_protocol == WINETEST_SYNC_TEST) {
823 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
824 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE, wszTextHtml);
825 ok(hres == S_OK,
826 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
827 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
828 }else {
829 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
830 ok(hres == S_OK,
831 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
832 }
833
835 bscf |= BSCF_DATAFULLYAVAILABLE;
837 bscf = BSCF_FIRSTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE;
838
840 if(bind_to_object) {
842 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
843 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
845 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
846 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
847 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
848 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
849 SET_EXPECT(CreateInstance);
850 SET_EXPECT(PutProperty_MIMETYPEPROP);
851 SET_EXPECT(PutProperty_CLASSIDPROP);
852 SET_EXPECT(Load);
853 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
854 SET_EXPECT(OnObjectAvailable);
855 SET_EXPECT(Obj_OnStopBinding);
856 }else {
858 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
859 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
861 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
862 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
864 if(!filedwl_api)
865 SET_EXPECT(OnDataAvailable);
866 if(test_protocol != WINETEST_SYNC_TEST) /* Set in Read after ReportResult call */
867 SET_EXPECT(OnStopBinding);
868 }
869
870 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
871 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
872
874 if(bind_to_object) {
876 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE);
877 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA);
879 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
880 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA);
881 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE);
882 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION);
883 CHECK_CALLED(CreateInstance);
884 CHECK_CALLED(PutProperty_MIMETYPEPROP);
885 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP);
886 CHECK_CALLED(Load);
887 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION);
888 CHECK_CALLED(OnObjectAvailable);
889 CHECK_CALLED(Obj_OnStopBinding);
890 }else {
892 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
893 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
895 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
896 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
898 if(!filedwl_api)
899 CHECK_CALLED(OnDataAvailable);
900 CHECK_CALLED(OnStopBinding);
901 }
902
903 if(test_protocol == ITS_TEST) {
905 hres = IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_BEGINDOWNLOADDATA, NULL);
906 ok(hres == S_OK, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres);
908 }else if(!bind_to_object && test_protocol == FILE_TEST) {
910 hres = IInternetProtocolSink_ReportData(pOIProtSink, bscf, 13, 13);
911 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
913 }
914
916 SET_EXPECT(Terminate);
917 hres = IInternetProtocolSink_ReportResult(pOIProtSink, S_OK, 0, NULL);
918 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
919 CHECK_CALLED(Terminate);
920 }
921
922 return S_OK;
923}
924
926 PROTOCOLDATA *pProtocolData)
927{
928 DWORD bscf = 0;
930
931 CHECK_EXPECT(Continue);
932
933 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
934
935 if(!bind_to_object)
937
938 ok(pProtocolData != NULL, "pProtocolData == NULL\n");
939 if(!pProtocolData)
940 return S_OK;
941
942 switch(prot_state) {
943 case 0:
944 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
945 BINDSTATUS_SENDINGREQUEST, NULL);
946 ok(hres == S_OK, "ReportProgress failed: %08x\n", hres);
947
948 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
949 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
950 ok(hres == S_OK,
951 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
952
953 bscf |= BSCF_FIRSTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION;
954 break;
955 case 1: {
958 static const WCHAR header[] = {'?',0};
959
960 hres = IInternetProtocolSink_QueryInterface(protocol_sink, &IID_IServiceProvider,
961 (void**)&service_provider);
962 ok(hres == S_OK, "Could not get IServiceProvicder\n");
963
964 hres = IServiceProvider_QueryService(service_provider, &IID_IHttpNegotiate,
965 &IID_IHttpNegotiate, (void**)&http_negotiate);
966 ok(hres == S_OK, "Could not get IHttpNegotiate\n");
967
968 if(!no_callback) {
969 SET_EXPECT(QueryInterface_IHttpNegotiate);
970 SET_EXPECT(OnResponse);
971 }
972 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, header, NULL, NULL);
973 if(!no_callback) {
974 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate);
975 CHECK_CALLED(OnResponse);
976 }
977 IHttpNegotiate_Release(http_negotiate);
978 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
979
981 hres = IInternetProtocolSink_ReportProgress(protocol_sink, BINDSTATUS_ACCEPTRANGES, NULL);
982 ok(hres == S_OK, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres);
983 }
984
985 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
986 BINDSTATUS_MIMETYPEAVAILABLE, wszTextHtml);
987 ok(hres == S_OK,
988 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres);
989
990 hres = IInternetProtocolSink_ReportProgress(protocol_sink,
991 BINDSTATUS_CACHEFILENAMEAVAILABLE, use_cache_file ? cache_file_name : cache_fileW);
992 ok(hres == S_OK, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres);
993
994 bscf |= BSCF_FIRSTDATANOTIFICATION;
995 break;
996 }
997 case 2:
998 case 3:
999 bscf = BSCF_INTERMEDIATEDATANOTIFICATION;
1000 break;
1001 }
1002
1003 hres = IInternetProtocolSink_ReportData(protocol_sink, bscf, 100, 400);
1004 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1005
1006 if(prot_state != 2 || !test_abort)
1008 switch(prot_state) {
1009 case 0:
1010 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1011 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1012 SET_EXPECT(OnProgress_SENDINGREQUEST);
1013 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1014 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1016 SET_EXPECT(OnStopBinding);
1017 break;
1018 case 1:
1019 if(bind_to_object) {
1020 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1021 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1022 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1023 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1024 SET_EXPECT(CreateInstance);
1025 SET_EXPECT(PutProperty_MIMETYPEPROP);
1026 SET_EXPECT(PutProperty_CLASSIDPROP);
1027 SET_EXPECT(Load);
1028 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
1029 SET_EXPECT(OnObjectAvailable);
1030 SET_EXPECT(Obj_OnStopBinding);
1031 }else if(!no_callback) {
1032 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1033 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1035 }else {
1037 }
1038 break;
1039 case 2:
1040 if(!no_callback)
1041 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1042 break;
1043 case 3:
1044 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
1045 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
1046 }
1047 if(!no_callback) {
1048 if((!bind_to_object || prot_state >= 2) && (!test_abort || prot_state != 2))
1049 SET_EXPECT(OnDataAvailable);
1050 if(prot_state == 3 || (test_abort && prot_state == 2))
1051 SET_EXPECT(OnStopBinding);
1052 }
1053 return S_OK;
1054}
1055
1058{
1059 HRESULT hres;
1060
1061 CHECK_EXPECT(Abort);
1062
1063 ok(hrReason == E_ABORT, "hrReason = %08x\n", hrReason);
1064 ok(!dwOptions, "dwOptions = %x\n", dwOptions);
1065
1066 hres = IInternetProtocolSink_ReportResult(protocol_sink, E_ABORT, ERROR_SUCCESS, NULL);
1067 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1068
1069 return S_OK;
1070}
1071
1073{
1074 CHECK_EXPECT(Terminate);
1075
1076 ok(dwOptions == 0, "dwOptions=%d, expected 0\n", dwOptions);
1077
1078 if(protocol_sink) {
1079 IInternetProtocolSink_Release(protocol_sink);
1081 }
1082
1083 if(no_callback)
1085 return S_OK;
1086}
1087
1089{
1090 ok(0, "unexpected call\n");
1091 return E_NOTIMPL;
1092}
1093
1095{
1096 ok(0, "unexpected call\n");
1097 return E_NOTIMPL;
1098}
1099
1101 ULONG cb, ULONG *pcbRead)
1102{
1103 HRESULT hres;
1104
1105 static const char data[] = "<HTML></HTML>";
1106
1108
1109 ok(pv != NULL, "pv == NULL\n");
1110 ok(cb != 0, "cb == 0\n");
1111 ok(pcbRead != NULL, "pcbRead == NULL\n");
1112
1113 if(async_switch) {
1114 if(prot_state++ > 1) {
1115 *pcbRead = 0;
1116 return S_FALSE;
1117 } else {
1118 memset(pv, '?', cb);
1119 *pcbRead = cb;
1120 return S_OK;
1121 }
1122 }
1123
1125 static BOOL pending = TRUE;
1126
1127 pending = !pending;
1128
1129 switch(prot_state) {
1130 case 1:
1131 case 2:
1132 if(pending) {
1133 *pcbRead = 10;
1134 memset(pv, '?', 10);
1135 if(prot_state == 2 && no_callback)
1137 return E_PENDING;
1138 }else {
1139 memset(pv, '?', cb);
1140 *pcbRead = cb;
1141 read++;
1142 return S_OK;
1143 }
1144 case 3:
1145 prot_state++;
1146
1147 *pcbRead = 0;
1148
1149 hres = IInternetProtocolSink_ReportData(protocol_sink,
1150 BSCF_LASTDATANOTIFICATION|BSCF_INTERMEDIATEDATANOTIFICATION, 2000, 2000);
1151 ok(hres == S_OK, "ReportData failed: %08x\n", hres);
1152
1153 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1154 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1155
1156 return S_FALSE;
1157 case 4:
1158 *pcbRead = 0;
1159 return S_FALSE;
1160 }
1161 }
1162
1163 if(read) {
1164 *pcbRead = 0;
1165 return S_FALSE;
1166 }
1167
1169 hres = IInternetProtocolSink_ReportResult(protocol_sink, S_OK, 0, NULL);
1170 ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
1171
1172 SET_EXPECT(OnStopBinding);
1173 }
1174
1175 ok(*pcbRead == 0, "*pcbRead=%d, expected 0\n", *pcbRead);
1176 read += *pcbRead = sizeof(data)-1;
1177 memcpy(pv, data, sizeof(data));
1178 return S_OK;
1179}
1180
1182 LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
1183{
1184 ok(0, "unexpected call\n");
1185 return E_NOTIMPL;
1186}
1187
1189{
1191 if(no_callback)
1193 return S_OK;
1194}
1195
1197{
1199 return S_OK;
1200}
1201
1202static const IInternetProtocolVtbl ProtocolVtbl = {
1216};
1217
1219
1221{
1223 || IsEqualGUID(&IID_IHttpNegotiate, riid)
1224 || IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1225 *ppv = iface;
1226 return S_OK;
1227 }
1228
1229 ok(0, "unexpected call\n");
1230 return E_NOINTERFACE;
1231}
1232
1234{
1235 return 2;
1236}
1237
1239{
1240 return 1;
1241}
1242
1244 LPCWSTR szHeaders, DWORD dwReserved, LPWSTR *pszAdditionalHeaders)
1245{
1247 CHECK_EXPECT2(BeginningTransaction);
1248 else
1249 CHECK_EXPECT(BeginningTransaction);
1250
1251 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1252
1253 ok(!lstrcmpW(szURL, current_url), "szURL != current_url\n");
1254 ok(!dwReserved, "dwReserved=%d, expected 0\n", dwReserved);
1255 ok(pszAdditionalHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1256 if(pszAdditionalHeaders)
1257 ok(*pszAdditionalHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1258
1259 return S_OK;
1260}
1261
1263 LPCWSTR szResponseHeaders, LPCWSTR szRequestHeaders, LPWSTR *pszAdditionalRequestHeaders)
1264{
1265 CHECK_EXPECT(OnResponse);
1266
1267 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1268
1269 ok(dwResponseCode == 200, "dwResponseCode=%d, expected 200\n", dwResponseCode);
1270 ok(szResponseHeaders != NULL, "szResponseHeaders == NULL\n");
1271 ok(szRequestHeaders == NULL, "szRequestHeaders != NULL\n");
1272 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1273 ok(pszAdditionalRequestHeaders != NULL, "pszAdditionalHeaders == NULL\n");
1274 if(pszAdditionalRequestHeaders)
1275 ok(*pszAdditionalRequestHeaders == NULL, "*pszAdditionalHeaders != NULL\n");
1276
1277 return S_OK;
1278}
1279
1281 BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
1282{
1283 static const BYTE sec_id[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1284
1285 CHECK_EXPECT(GetRootSecurityId);
1286
1287 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1288
1289 ok(!dwReserved, "dwReserved=%ld, expected 0\n", dwReserved);
1290 ok(pbSecurityId != NULL, "pbSecurityId == NULL\n");
1291 ok(pcbSecurityId != NULL, "pcbSecurityId == NULL\n");
1292
1293 if(pbSecurityId == (void*)0xdeadbeef)
1294 return E_NOTIMPL;
1295
1296 if(pcbSecurityId) {
1297 ok(*pcbSecurityId == 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId);
1298 *pcbSecurityId = sizeof(sec_id);
1299 }
1300
1301 if(pbSecurityId)
1302 memcpy(pbSecurityId, sec_id, sizeof(sec_id));
1303
1304 return E_FAIL;
1305}
1306
1307static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
1314};
1315
1317
1319{
1320 ok(0, "Unexpected call\n");
1321 *ppv = NULL;
1322 if(IsEqualGUID(&IID_IHttpSecurity, riid) ||
1323 IsEqualGUID(&IID_IWindowForBindingUI, riid) ||
1325 {
1326 *ppv = iface;
1327 return S_OK;
1328 }
1329
1330 ok(0, "Unexpected interface requested.\n");
1331
1332 return E_NOINTERFACE;
1333}
1334
1336{
1337 return 2;
1338}
1339
1341{
1342 return 1;
1343}
1344
1346{
1347 if(IsEqualGUID(rguidReason, &IID_IHttpSecurity))
1348 CHECK_EXPECT(GetWindow_IHttpSecurity);
1349 else if(IsEqualGUID(rguidReason, &IID_IWindowForBindingUI))
1350 CHECK_EXPECT2(GetWindow_IWindowForBindingUI);
1351 else if(IsEqualGUID(rguidReason, &IID_ICodeInstall))
1352 CHECK_EXPECT(GetWindow_ICodeInstall);
1353 else
1354 ok(0, "Unexpected rguidReason: %s\n", wine_dbgstr_guid(rguidReason));
1355
1356 *phwnd = NULL;
1357 return S_OK;
1358}
1359
1361{
1362 CHECK_EXPECT(OnSecurityProblem);
1363 if(!security_problem) {
1365 broken(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS) /* Some versions of IE6 */,
1366 "Got problem: %d\n", dwProblem);
1367 security_problem = dwProblem;
1368
1369 if(dwProblem == ERROR_INTERNET_SEC_CERT_ERRORS)
1370 binding_hres = INET_E_SECURITY_PROBLEM;
1371 }else
1372 ok(dwProblem == security_problem, "Got problem: %d\n", dwProblem);
1373
1375}
1376
1377static const IHttpSecurityVtbl HttpSecurityVtbl = {
1383};
1384
1386
1388{
1389 ok(0, "unexpected call\n");
1390 return E_NOINTERFACE;
1391}
1392
1394{
1395 return 2;
1396}
1397
1399{
1400 return 1;
1401}
1402
1404 REFGUID guidService, REFIID riid, void **ppv)
1405{
1406 if(IsEqualGUID(&IID_IAuthenticate, guidService)) {
1407 CHECK_EXPECT(QueryService_IAuthenticate);
1408 return E_NOTIMPL;
1409 }
1410
1411 if(IsEqualGUID(&IID_IInternetProtocol, guidService)) {
1412 CHECK_EXPECT2(QueryService_IInternetProtocol);
1413 return E_NOTIMPL;
1414 }
1415
1416 if(IsEqualGUID(&IID_IInternetBindInfo, guidService)) {
1417 CHECK_EXPECT(QueryService_IInternetBindInfo);
1418 return E_NOTIMPL;
1419 }
1420
1421 if(IsEqualGUID(&IID_IWindowForBindingUI, guidService)) {
1422 CHECK_EXPECT2(QueryService_IWindowForBindingUI);
1423 *ppv = &HttpSecurity;
1424 return S_OK;
1425 }
1426
1427 if(IsEqualGUID(&IID_IHttpSecurity, guidService)) {
1428 CHECK_EXPECT(QueryService_IHttpSecurity);
1429 *ppv = &HttpSecurity;
1430 return S_OK;
1431 }
1432
1433 if(IsEqualGUID(&IID_IGetBindHandle, guidService)) {
1434 trace("QueryService(IID_IGetBindHandle)\n");
1435 *ppv = NULL;
1436 return E_NOINTERFACE;
1437 }
1438
1439 if(IsEqualGUID(&IID_undocumentedIE11, guidService)) {
1440 trace("QueryService(IID_undocumentedIE11)\n");
1441 *ppv = NULL;
1442 return E_NOINTERFACE;
1443 }
1444
1445 ok(0, "unexpected service %s\n", wine_dbgstr_guid(guidService));
1446 return E_NOINTERFACE;
1447}
1448
1449static IServiceProviderVtbl ServiceProviderVtbl = {
1454};
1455
1457
1459
1461{
1462 DWORD status, size;
1464
1465 /* QueryInfo changes its behavior during this request */
1466 if(progress == BINDSTATUS_SENDINGREQUEST)
1467 return;
1468
1470 && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1471 expect = E_FAIL;
1472 else if(test_protocol == FTP_TEST)
1473 expect = S_FALSE;
1474 else
1475 expect = S_OK;
1476
1477 size = sizeof(DWORD);
1478 hres = IWinInetHttpInfo_QueryInfo(http_info, HTTP_QUERY_STATUS_CODE|HTTP_QUERY_FLAG_NUMBER,
1479 &status, &size, NULL, NULL);
1480 ok(hres == expect || ((progress == BINDSTATUS_COOKIE_SENT || progress == BINDSTATUS_PROXYDETECTING) && hres == S_FALSE),
1481 "progress %u: hres = %x, expected %x\n", progress, hres, expect);
1482 if(hres == S_OK) {
1483 if(download_state == BEFORE_DOWNLOAD && progress != BINDSTATUS_MIMETYPEAVAILABLE && progress != BINDSTATUS_DECODING)
1484 ok(status == 0, "progress %u: status = %d\n", progress, status);
1485 else
1486 ok(status == HTTP_STATUS_OK, "progress %u: status = %d\n", progress, status);
1487 ok(size == sizeof(DWORD), "size = %d\n", size);
1488 }
1489
1490 size = sizeof(DWORD);
1491 hres = IWinInetHttpInfo_QueryOption(http_info, INTERNET_OPTION_HANDLE_TYPE, &status, &size);
1492 if(test_protocol == FTP_TEST) {
1493 if(download_state==BEFORE_DOWNLOAD && progress!=BINDSTATUS_MIMETYPEAVAILABLE)
1494 ok(hres == E_FAIL, "hres = %x\n", hres);
1495 else
1496 ok(hres == S_OK, "hres = %x\n", hres);
1497
1498 if(hres == S_OK)
1499 ok(status == INTERNET_HANDLE_TYPE_FTP_FILE, "status = %d\n", status);
1500 } else {
1501 ok(hres == S_OK, "hres = %x\n", hres);
1502 ok(status == INTERNET_HANDLE_TYPE_HTTP_REQUEST, "status = %d\n", status);
1503 }
1504}
1505
1507{
1508 static const IID IID_undocumentedIE10 = {0xf286fa56,0xc1fd,0x4270,{0x8e,0x67,0xb3,0xeb,0x79,0x0a,0x81,0xe8}};
1509
1510 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1511
1512 if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
1513 CHECK_EXPECT2(QueryInterface_IInternetProtocol);
1514 if(emulate_protocol) {
1515 *ppv = &Protocol;
1516 return S_OK;
1517 }else {
1518 return E_NOINTERFACE;
1519 }
1520 }else if (IsEqualGUID(&IID_IServiceProvider, riid)) {
1521 CHECK_EXPECT2(QueryInterface_IServiceProvider);
1522 *ppv = &ServiceProvider;
1523 return S_OK;
1524 }else if (IsEqualGUID(&IID_IHttpNegotiate, riid)) {
1525 CHECK_EXPECT2(QueryInterface_IHttpNegotiate);
1526 *ppv = &HttpNegotiate;
1527 return S_OK;
1528 }else if (IsEqualGUID(&IID_IHttpNegotiate2, riid)) {
1529 CHECK_EXPECT(QueryInterface_IHttpNegotiate2);
1530 *ppv = &HttpNegotiate;
1531 return S_OK;
1532 }else if (IsEqualGUID(&IID_IAuthenticate, riid)) {
1533 CHECK_EXPECT(QueryInterface_IAuthenticate);
1534 return E_NOINTERFACE;
1535 }else if(IsEqualGUID(&IID_IBindStatusCallback, riid)) {
1536 if(strict_bsc_qi)
1537 CHECK_EXPECT2(QueryInterface_IBindStatusCallback);
1538 *ppv = iface;
1539 return S_OK;
1541 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder);
1542 return E_NOINTERFACE;
1543 }else if(IsEqualGUID(&IID_IBindStatusCallbackEx, riid)) {
1544 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx);
1545 if(!use_bscex)
1546 return E_NOINTERFACE;
1547 *ppv = iface;
1548 return S_OK;
1549 }else if(IsEqualGUID(&IID_IInternetBindInfo, riid)) {
1550 /* TODO */
1551 }else if(IsEqualGUID(&IID_IWindowForBindingUI, riid)) {
1552 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI);
1553 return E_NOINTERFACE;
1554 }else if(IsEqualGUID(&IID_IHttpSecurity, riid)) {
1555 CHECK_EXPECT2(QueryInterface_IHttpSecurity);
1556 return E_NOINTERFACE;
1557 }else if(IsEqualGUID(&IID_IGetBindHandle, riid)) {
1558 trace("QI(IID_IGetBindHandle)\n");
1559 *ppv = NULL;
1560 return E_NOINTERFACE;
1561 }else if(IsEqualGUID(&IID_undocumentedIE10, riid)) {
1562 trace("QI(IID_undocumentedIE10)\n");
1563 *ppv = NULL;
1564 return E_NOINTERFACE;
1566 trace("QI(IID_undocumentedIE11)\n");
1567 *ppv = NULL;
1568 return E_NOINTERFACE;
1569 }else {
1570 ok(0, "unexpected interface %s\n", wine_dbgstr_guid(riid));
1571 }
1572
1573 return E_NOINTERFACE;
1574}
1575
1577{
1578 return 2;
1579}
1580
1582{
1583 return 1;
1584}
1585
1587 IBinding *pib)
1588{
1589 IWinInetHttpInfo *http_info;
1590 HRESULT hres;
1591 IMoniker *mon;
1592 DWORD res;
1593 CLSID clsid;
1594 LPOLESTR res_str;
1595
1596 if(iface == &objbsc)
1597 CHECK_EXPECT(Obj_OnStartBinding);
1598 else
1599 CHECK_EXPECT(OnStartBinding);
1600
1601 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1602
1603 ok(pib != NULL, "pib should not be NULL\n");
1604 ok(dwReserved == 0xff, "dwReserved=%x\n", dwReserved);
1605
1606 if(pib == (void*)0xdeadbeef)
1607 return S_OK;
1608
1609 current_binding = pib;
1610
1611 hres = IBinding_QueryInterface(pib, &IID_IMoniker, (void**)&mon);
1612 ok(hres == E_NOINTERFACE, "IBinding should not have IMoniker interface\n");
1613 if(SUCCEEDED(hres))
1614 IMoniker_Release(mon);
1615
1616 hres = IBinding_QueryInterface(pib, &IID_IWinInetHttpInfo, (void**)&http_info);
1617 ok(hres == E_NOINTERFACE, "Could not get IID_IWinInetHttpInfo: %08x\n", hres);
1618
1619 if(0) { /* crashes with native urlmon */
1620 hres = IBinding_GetBindResult(pib, NULL, &res, &res_str, NULL);
1621 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1622 }
1623 hres = IBinding_GetBindResult(pib, &clsid, NULL, &res_str, NULL);
1624 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1625 hres = IBinding_GetBindResult(pib, &clsid, &res, NULL, NULL);
1626 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1627 hres = IBinding_GetBindResult(pib, &clsid, &res, &res_str, (void*)0xdeadbeef);
1628 ok(hres == E_INVALIDARG, "GetBindResult failed: %08x\n", hres);
1629
1630 hres = IBinding_GetBindResult(pib, &clsid, &res, &res_str, NULL);
1631 ok(hres == S_OK, "GetBindResult failed: %08x, expected S_OK\n", hres);
1632 ok(IsEqualCLSID(&clsid, &CLSID_NULL), "incorrect clsid: %s\n", wine_dbgstr_guid(&clsid));
1633 ok(!res, "incorrect res: %x\n", res);
1634 ok(!res_str, "incorrect res_str: %s\n", wine_dbgstr_w(res_str));
1635
1636 if(abort_start) {
1638 return abort_hres;
1639 }
1640
1641 return S_OK;
1642}
1643
1645{
1646 ok(0, "unexpected call\n");
1647 return E_NOTIMPL;
1648}
1649
1651{
1652 ok(0, "unexpected call\n");
1653 return E_NOTIMPL;
1654}
1655
1657 ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
1658{
1659 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1660
1661 switch(ulStatusCode) {
1662 case BINDSTATUS_FINDINGRESOURCE:
1663 if(iface == &objbsc)
1664 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE);
1665 else if(test_protocol == FTP_TEST)
1666 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1668 todo_wine CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1669 else
1670 CHECK_EXPECT(OnProgress_FINDINGRESOURCE);
1673 break;
1674 case BINDSTATUS_CONNECTING:
1675 if(iface == &objbsc)
1676 CHECK_EXPECT(Obj_OnProgress_CONNECTING);
1677 else if(test_protocol == FTP_TEST)
1678 todo_wine CHECK_EXPECT(OnProgress_CONNECTING);
1679 else if(onsecurityproblem_hres == S_OK)
1680 CHECK_EXPECT2(OnProgress_CONNECTING);
1681 else
1682 CHECK_EXPECT(OnProgress_CONNECTING);
1685 break;
1686 case BINDSTATUS_REDIRECTING:
1687 if(iface == &objbsc)
1688 CHECK_EXPECT(Obj_OnProgress_REDIRECTING);
1689 else
1690 CHECK_EXPECT(OnProgress_REDIRECTING);
1691 ok(!lstrcmpW(szStatusText, winetest_data_urlW), "unexpected status text %s\n",
1692 wine_dbgstr_w(szStatusText));
1694 && (!bind_to_object || iface == &objbsc))
1696 break;
1697 case BINDSTATUS_SENDINGREQUEST:
1698 if(iface == &objbsc)
1699 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST);
1700 else if(test_protocol == FTP_TEST)
1701 CHECK_EXPECT2(OnProgress_SENDINGREQUEST);
1702 else
1703 CHECK_EXPECT(OnProgress_SENDINGREQUEST);
1706
1707 if(abort_progress) {
1708 if(filedwl_api)
1710 return E_ABORT;
1711 }
1712
1713 break;
1714 case BINDSTATUS_MIMETYPEAVAILABLE:
1715 if(iface == &objbsc)
1716 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE);
1717 else
1718 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE);
1719 if(!bind_to_object)
1720 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1722 WideCharToMultiByte(CP_ACP, 0, szStatusText, -1, mime_type, sizeof(mime_type)-1, NULL, NULL);
1723 break;
1724 case BINDSTATUS_BEGINDOWNLOADDATA:
1725 if(iface == &objbsc)
1726 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA);
1727 else
1728 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA);
1729 ok(szStatusText != NULL, "szStatusText == NULL\n");
1730 if(szStatusText) {
1731 if(filedwl_api) {
1732 /* FIXME */
1733 }else {
1734 ok(!lstrcmpW(szStatusText, current_url), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1735 }
1736 }
1737 if(!bind_to_object)
1738 ok(download_state == BEFORE_DOWNLOAD, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1741 break;
1742 case BINDSTATUS_DOWNLOADINGDATA:
1743 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA);
1744 ok(iface != &objbsc, "unexpected call\n");
1745 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1747 if(test_abort) {
1748 HRESULT hres;
1749
1750 SET_EXPECT(Abort);
1751 hres = IBinding_Abort(current_binding);
1752 ok(hres == S_OK, "Abort failed: %08x\n", hres);
1753 CHECK_CALLED(Abort);
1754
1755 hres = IBinding_Abort(current_binding);
1756 ok(hres == E_FAIL, "Abort failed: %08x\n", hres);
1757
1759 }
1760 break;
1761 case BINDSTATUS_ENDDOWNLOADDATA:
1762 if(iface == &objbsc)
1763 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA);
1764 else
1765 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA);
1766 ok(szStatusText != NULL, "szStatusText == NULL\n");
1767 if(szStatusText) {
1768 if(filedwl_api) {
1769 /* FIXME */
1770 }else {
1771 ok(!lstrcmpW(szStatusText, current_url), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1772 }
1773 }
1774 ok(download_state == DOWNLOADING, "Download state was %d, expected DOWNLOADING\n",
1777 break;
1778 case BINDSTATUS_CACHEFILENAMEAVAILABLE:
1780 if(iface == &objbsc)
1781 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1782 else
1783 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
1784 }else { /* FIXME */
1785 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
1786 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE);
1787 }
1788
1789 ok(szStatusText != NULL, "szStatusText == NULL\n");
1790 if(szStatusText && test_protocol == FILE_TEST)
1791 ok(!lstrcmpW(file_url+7, szStatusText), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText));
1792 break;
1793 case BINDSTATUS_CLASSIDAVAILABLE:
1794 {
1795 CLSID clsid;
1796 HRESULT hr;
1797 if(iface != &objbsc)
1798 ok(0, "unexpected call\n");
1799 else
1800 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE);
1801 hr = CLSIDFromString((LPCOLESTR)szStatusText, &clsid);
1802 ok(hr == S_OK, "CLSIDFromString failed with error 0x%08x\n", hr);
1803 ok(IsEqualCLSID(&clsid, &CLSID_HTMLDocument),
1804 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", wine_dbgstr_guid(&clsid));
1805 break;
1806 }
1807 case BINDSTATUS_BEGINSYNCOPERATION:
1808 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION);
1809 if(iface != &objbsc)
1810 ok(0, "unexpected call\n");
1811 ok(szStatusText == NULL, "Expected szStatusText to be NULL\n");
1812 break;
1813 case BINDSTATUS_ENDSYNCOPERATION:
1814 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION);
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_PROXYDETECTING:
1820 trace("BINDSTATUS_PROXYDETECTING\n");
1821 break;
1822 case BINDSTATUS_COOKIE_SENT:
1823 trace("BINDSTATUS_COOKIE_SENT\n");
1824 break;
1825 case BINDSTATUS_DECODING:
1826 trace("BINDSTATUS_DECODING\n");
1827 break;
1828 default:
1829 ok(0, "unexpected code %d\n", ulStatusCode);
1830 };
1831
1832 if(current_binding) {
1833 IWinInetHttpInfo *http_info;
1834 HRESULT hres;
1835
1836 hres = IBinding_QueryInterface(current_binding, &IID_IWinInetHttpInfo, (void**)&http_info);
1838 ok(hres == S_OK, "Could not get IWinInetHttpInfo iface: %08x\n", hres);
1839 test_WinInetHttpInfo(http_info, ulStatusCode);
1840 } else
1842 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres);
1843 if(SUCCEEDED(hres))
1844 IWinInetHttpInfo_Release(http_info);
1845 }
1846
1847 return S_OK;
1848}
1849
1851{
1852 if(iface == &objbsc) {
1853 CHECK_EXPECT(Obj_OnStopBinding);
1855 }else {
1856 CHECK_EXPECT(OnStopBinding);
1858 }
1859
1860 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1861
1863 todo_wine ok(hresult == S_OK, "Got %08x\n", hresult);
1864 return S_OK;
1865 }
1866
1867 /* ignore DNS failure */
1869 return S_OK;
1870
1871 if(filedwl_api) {
1873 ok(SUCCEEDED(hresult), "binding failed: %08x\n", hresult);
1874 else if(abort_start && abort_hres == E_NOTIMPL)
1875 todo_wine ok(hresult == S_FALSE, "binding failed: %08x, expected S_FALSE\n", hresult);
1876 else
1877 ok(hresult == E_ABORT, "binding failed: %08x, expected E_ABORT\n", hresult);
1878 } else
1879 ok(hresult == binding_hres, "binding failed: %08x, expected %08x\n", hresult, binding_hres);
1880 ok(szError == NULL, "szError should be NULL\n");
1881
1882 if(current_binding) {
1883 CLSID clsid;
1884 DWORD res;
1885 LPOLESTR res_str;
1886 HRESULT hres;
1887
1888 hres = IBinding_GetBindResult(current_binding, &clsid, &res, &res_str, NULL);
1889 ok(hres == S_OK, "GetBindResult failed: %08x, expected S_OK\n", hres);
1890 ok(res == hresult, "res = %08x, expected %08x\n", res, binding_hres);
1891 ok(!res_str, "incorrect res_str = %s\n", wine_dbgstr_w(res_str));
1892
1893 if(hresult==S_OK || (abort_start && hresult!=S_FALSE) || hresult == REGDB_E_CLASSNOTREG) {
1895 "incorrect protocol CLSID: %s, expected CLSID_NULL\n",
1897 }else if(emulate_protocol) {
1898 todo_wine ok(IsEqualCLSID(&clsid, &CLSID_FtpProtocol),
1899 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n",
1901 }else if(test_protocol == FTP_TEST) {
1902 ok(IsEqualCLSID(&clsid, &CLSID_FtpProtocol),
1903 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n",
1905 }else if(test_protocol == FILE_TEST) {
1906 ok(IsEqualCLSID(&clsid, &CLSID_FileProtocol),
1907 "incorrect protocol CLSID: %s, expected CLSID_FileProtocol\n",
1909 }else if(test_protocol == HTTP_TEST) {
1910 ok(IsEqualCLSID(&clsid, &CLSID_HttpProtocol),
1911 "incorrect protocol CLSID: %s, expected CLSID_HttpProtocol\n",
1913 }else if(test_protocol == HTTPS_TEST) {
1914 ok(IsEqualCLSID(&clsid, &CLSID_HttpSProtocol),
1915 "incorrect protocol CLSID: %s, expected CLSID_HttpSProtocol\n",
1917 }else if(test_protocol == ABOUT_TEST) {
1919 "incorrect protocol CLSID: %s, expected CLSID_AboutProtocol\n",
1921 }else {
1922 ok(0, "unexpected (%d)\n", test_protocol);
1923 }
1924 }
1925
1928 if(iface != &objbsc)
1929 ok( WaitForSingleObject(complete_event2, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
1930 }
1931
1935 ok(file == INVALID_HANDLE_VALUE, "expected INVALID_HANDLE_VALUE, got %p\n", file);
1936 ok(GetLastError() == ERROR_SHARING_VIOLATION, "expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
1937 http_cache_file[0] = 0;
1938 }
1939
1940 return S_OK;
1941}
1942
1943static HRESULT WINAPI statusclb_GetBindInfo(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
1944{
1945 DWORD cbSize;
1946
1947 if(iface == &objbsc)
1948 CHECK_EXPECT(Obj_GetBindInfo);
1949 else
1950 CHECK_EXPECT(GetBindInfo);
1951
1952 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
1953
1954 *grfBINDF = bindf;
1955 cbSize = pbindinfo->cbSize;
1956 memset(pbindinfo, 0, cbSize);
1957 pbindinfo->cbSize = cbSize;
1958
1959 return S_OK;
1960}
1961
1963{
1964 ULARGE_INTEGER new_pos;
1966 HRESULT hres;
1967
1968 pos.QuadPart = 0;
1969 new_pos.QuadPart = 0xdeadbeef;
1970 hres = IStream_Seek(stream, pos, STREAM_SEEK_SET, &new_pos);
1971 ok(hres == S_OK, "Seek failed: %08x\n", hres);
1972 ok(!new_pos.QuadPart, "new_pos.QuadPart != 0\n");
1973
1974 pos.QuadPart = 0;
1975 new_pos.QuadPart = 0xdeadbeef;
1976 hres = IStream_Seek(stream, pos, STREAM_SEEK_END, &new_pos);
1977 ok(hres == S_OK, "Seek failed: %08x\n", hres);
1978 ok(new_pos.QuadPart, "new_pos.QuadPart = 0\n");
1979
1980 pos.QuadPart = 0;
1981 new_pos.QuadPart = 0xdeadbeef;
1982 hres = IStream_Seek(stream, pos, 100, &new_pos);
1983 ok(hres == E_FAIL, "Seek failed: %08x\n", hres);
1984 ok(new_pos.QuadPart == 0xdeadbeef, "unexpected new_pos.QuadPart\n");
1985}
1986
1988 DWORD dwSize, FORMATETC* pformatetc, STGMEDIUM* pstgmed)
1989{
1990 HRESULT hres;
1991 DWORD readed;
1992 BYTE buf[512];
1993 CHAR clipfmt[512];
1994
1995 if(iface == &objbsc)
1996 ok(0, "unexpected call\n");
1997
1998 CHECK_EXPECT2(OnDataAvailable);
1999
2000 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
2001
2003 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
2006
2008 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION|BSCF_LASTDATANOTIFICATION), "grfBSCF = %x\n", grfBSCF);
2009
2010 ok(pformatetc != NULL, "pformatetx == NULL\n");
2011 if(pformatetc) {
2012 if (mime_type[0]) {
2013 INT ret;
2014 clipfmt[0] = 0;
2015 ret = GetClipboardFormatNameA(pformatetc->cfFormat, clipfmt, sizeof(clipfmt)-1);
2016 ok(ret, "GetClipboardFormatName failed, error %d\n", GetLastError());
2017 ok(!strcmp(clipfmt, mime_type), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
2018 pformatetc->cfFormat, clipfmt, mime_type);
2019 } else {
2020 ok(pformatetc->cfFormat == 0, "clipformat=%x\n", pformatetc->cfFormat);
2021 }
2022 ok(pformatetc->ptd == NULL, "ptd = %p\n", pformatetc->ptd);
2023 ok(pformatetc->dwAspect == 1, "dwAspect=%u\n", pformatetc->dwAspect);
2024 ok(pformatetc->lindex == -1, "lindex=%d\n", pformatetc->lindex);
2025 ok(pformatetc->tymed == tymed, "tymed=%u, expected %u\n", pformatetc->tymed, tymed);
2026 }
2027
2028 ok(pstgmed != NULL, "stgmeg == NULL\n");
2029 ok(pstgmed->tymed == tymed, "tymed=%u, expected %u\n", pstgmed->tymed, tymed);
2030 ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
2031
2032 switch(pstgmed->tymed) {
2033 case TYMED_ISTREAM: {
2034 IStream *stream = U(*pstgmed).pstm;
2035
2036 ok(stream != NULL, "U(*pstgmed).pstm == NULL\n");
2037
2038 if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
2039 STATSTG stat;
2040
2041 hres = IStream_Write(stream, buf, 10, NULL);
2043 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres);
2044
2045 hres = IStream_Commit(stream, 0);
2046 ok(hres == E_NOTIMPL, "Commit failed: %08x, expected E_NOTIMPL\n", hres);
2047
2048 hres = IStream_Revert(stream);
2049 ok(hres == E_NOTIMPL, "Revert failed: %08x, expected E_NOTIMPL\n", hres);
2050
2051 hres = IStream_Stat(stream, NULL, STATFLAG_NONAME);
2052 ok(hres == E_FAIL, "hres = %x\n", hres);
2054 hres = IStream_Stat(stream, &stat, STATFLAG_DEFAULT);
2055 ok(hres == S_OK, "hres = %x\n", hres);
2056 ok(!lstrcmpW(stat.pwcsName, cache_file_name),
2057 "stat.pwcsName = %s, cache_file_name = %s\n",
2059 CoTaskMemFree(stat.pwcsName);
2060 ok(U(stat.cbSize).LowPart == (bindf&BINDF_ASYNCHRONOUS?0:6500),
2061 "stat.cbSize.LowPart = %u\n", U(stat.cbSize).LowPart);
2062 } else {
2063 hres = IStream_Stat(stream, &stat, STATFLAG_NONAME);
2064 ok(hres == S_OK, "hres = %x\n", hres);
2065 ok(!stat.pwcsName || broken(stat.pwcsName!=NULL),
2066 "stat.pwcsName = %s\n", wine_dbgstr_w(stat.pwcsName));
2067 }
2068 ok(stat.type == STGTY_STREAM, "stat.type = %x\n", stat.type);
2069 ok(U(stat.cbSize).HighPart == 0, "stat.cbSize.HighPart != 0\n");
2070 ok(stat.grfMode == (U(stat.cbSize).LowPart?GENERIC_READ:0), "stat.grfMode = %x\n", stat.grfMode);
2071 ok(stat.grfLocksSupported == 0, "stat.grfLocksSupported = %x\n", stat.grfLocksSupported);
2072 ok(stat.grfStateBits == 0, "stat.grfStateBits = %x\n", stat.grfStateBits);
2073 ok(stat.reserved == 0, "stat.reserved = %x\n", stat.reserved);
2074 }
2075
2076 if(callback_read) {
2077 do {
2078 hres = IStream_Read(stream, buf, 512, &readed);
2079 if(test_protocol == HTTP_TEST && emulate_protocol && readed)
2080 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
2081 }while(hres == S_OK);
2082 ok(hres == S_FALSE || hres == E_PENDING, "IStream_Read returned %08x\n", hres);
2083 }
2084
2085 if(use_cache_file && (grfBSCF & BSCF_FIRSTDATANOTIFICATION) && !(bindf & BINDF_PULLDATA))
2087 break;
2088 }
2089 case TYMED_FILE:
2091 ok(!lstrcmpW(pstgmed->u.lpszFileName, file_url+7),
2092 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
2093 else if(emulate_protocol)
2094 ok(!lstrcmpW(pstgmed->u.lpszFileName, cache_fileW),
2095 "unexpected file name %s\n", wine_dbgstr_w(pstgmed->u.lpszFileName));
2096 else if(test_protocol == HTTP_TEST)
2097 lstrcpyW(http_cache_file, pstgmed->u.lpszFileName);
2098 else
2099 ok(pstgmed->u.lpszFileName != NULL, "lpszFileName == NULL\n");
2100 }
2101
2105
2106 return S_OK;
2107}
2108
2110{
2111 CHECK_EXPECT(OnObjectAvailable);
2112
2113 if(iface != &objbsc)
2114 ok(0, "unexpected call\n");
2115
2116 ok(IsEqualGUID(&IID_IUnknown, riid), "riid = %s\n", wine_dbgstr_guid(riid));
2117 ok(punk != NULL, "punk == NULL\n");
2118
2119 return S_OK;
2120}
2121
2122static HRESULT WINAPI statusclb_GetBindInfoEx(IBindStatusCallbackEx *iface, DWORD *grfBINDF, BINDINFO *pbindinfo,
2123 DWORD *grfBINDF2, DWORD *pdwReserved)
2124{
2125 CHECK_EXPECT(GetBindInfoEx);
2126
2127 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
2128 ok(grfBINDF2 != NULL, "grfBINDF2 == NULL\n");
2129 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
2130 ok(pdwReserved != NULL, "dwReserved == NULL\n");
2131
2132 return S_OK;
2133}
2134
2135static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl = {
2148};
2149
2153
2155{
2156 *ppv = NULL;
2157 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2158 return E_NOINTERFACE;
2159}
2160
2162{
2163 return 2;
2164}
2165
2167{
2168 return 1;
2169}
2170
2171static HRESULT WINAPI MonikerProp_PutProperty(IMonikerProp *iface, MONIKERPROPERTY mkp, LPCWSTR val)
2172{
2173 switch(mkp) {
2174 case MIMETYPEPROP:
2175 CHECK_EXPECT(PutProperty_MIMETYPEPROP);
2176 ok(!lstrcmpW(val, wszTextHtml), "val = %s\n", wine_dbgstr_w(val));
2177 break;
2178 case CLASSIDPROP:
2179 CHECK_EXPECT(PutProperty_CLASSIDPROP);
2180 break;
2181 default:
2182 break;
2183 }
2184
2185 return S_OK;
2186}
2187
2188static const IMonikerPropVtbl MonikerPropVtbl = {
2193};
2194
2196
2198{
2199 *ppv = NULL;
2200
2201 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IPersistMoniker, riid))
2202 *ppv = iface;
2203 else if(IsEqualGUID(&IID_IMonikerProp, riid))
2204 *ppv = &MonikerProp;
2205
2206 if(*ppv)
2207 return S_OK;
2208
2209 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2210 return E_NOINTERFACE;
2211}
2212
2214{
2215 return 2;
2216}
2217
2219{
2220 return 1;
2221}
2222
2224{
2225 ok(0, "unexpected call\n");
2226 return E_NOTIMPL;
2227}
2228
2230{
2231 ok(0, "unexpected call\n");
2232 return E_NOTIMPL;
2233}
2234
2236 IMoniker *pimkName, LPBC pibc, DWORD grfMode)
2237{
2238 IUnknown *unk;
2239 HRESULT hres;
2240
2241 static WCHAR cbinding_contextW[] =
2242 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
2243
2244 CHECK_EXPECT(Load);
2245 ok(GetCurrentThreadId() == thread_id, "wrong thread %d\n", GetCurrentThreadId());
2246
2248 ok(!fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable);
2249 else
2250 ok(fFullyAvailable, "fFullyAvailable = %x\n", fFullyAvailable);
2251 ok(pimkName != NULL, "pimkName == NULL\n");
2252 ok(pibc != NULL, "pibc == NULL\n");
2253 ok(grfMode == 0x12, "grfMode = %x\n", grfMode);
2254
2255 hres = IBindCtx_GetObjectParam(pibc, cbinding_contextW, &unk);
2256 ok(hres == S_OK, "GetObjectParam(CBinding Context) failed: %08x\n", hres);
2257 if(SUCCEEDED(hres)) {
2258 IBinding *binding;
2259
2260 hres = IUnknown_QueryInterface(unk, &IID_IBinding, (void**)&binding);
2261 ok(hres == S_OK, "Could not get IBinding: %08x\n", hres);
2262
2263 IBinding_Release(binding);
2264 IUnknown_Release(unk);
2265 }
2266
2267 SET_EXPECT(QueryInterface_IServiceProvider);
2269 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2270 CHECK_CALLED(QueryInterface_IServiceProvider);
2271
2272 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2273 SET_EXPECT(GetBindInfo);
2274 SET_EXPECT(OnStartBinding);
2275 if(test_redirect)
2276 SET_EXPECT(OnProgress_REDIRECTING);
2277 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
2279 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
2281 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
2283 SET_EXPECT(OnDataAvailable);
2285 SET_EXPECT(OnStopBinding);
2286
2287 hres = IMoniker_BindToStorage(pimkName, pibc, NULL, &IID_IStream, (void**)&unk);
2288 ok(hres == S_OK, "Load failed: %08x\n", hres);
2289
2290 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2291 CHECK_CALLED(GetBindInfo);
2292 CHECK_CALLED(OnStartBinding);
2293 if(test_redirect)
2294 CHECK_CALLED(OnProgress_REDIRECTING);
2295 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
2297 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
2299 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
2301 CHECK_CALLED(OnDataAvailable);
2303 CHECK_CALLED(OnStopBinding);
2304
2305 if(unk)
2306 IUnknown_Release(unk);
2307
2308 return S_OK;
2309}
2310
2311static HRESULT WINAPI PersistMoniker_Save(IPersistMoniker *iface, IMoniker *pimkName, LPBC pbc, BOOL fRemember)
2312{
2313 ok(0, "unexpected call\n");
2314 return E_NOTIMPL;
2315}
2316
2318{
2319 ok(0, "unexpected call\n");
2320 return E_NOTIMPL;
2321}
2322
2324{
2325 ok(0, "unexpected call\n");
2326 return E_NOTIMPL;
2327}
2328
2329static const IPersistMonikerVtbl PersistMonikerVtbl = {
2339};
2340
2342
2344{
2345 *ppv = NULL;
2346
2348 *ppv = iface;
2349 return S_OK;
2350 }
2351
2352 if(IsEqualGUID(&IID_IMarshal, riid))
2353 return E_NOINTERFACE;
2355 return E_NOINTERFACE;
2356
2357 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2358 return E_NOTIMPL;
2359}
2360
2362{
2363 return 2;
2364}
2365
2367{
2368 return 1;
2369}
2370
2372{
2373 CHECK_EXPECT(CreateInstance);
2374 ok(!outer, "outer = %p\n", outer);
2375 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
2376 *ppv = &PersistMoniker;
2377 return S_OK;
2378}
2379
2381{
2382 ok(0, "unexpected call\n");
2383 return S_OK;
2384}
2385
2386static const IClassFactoryVtbl ClassFactoryVtbl = {
2392};
2393
2395
2397{
2398 *ppv = NULL;
2399
2401 *ppv = iface;
2402 return S_OK;
2403 }
2404
2405 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2406 return E_NOINTERFACE;
2407
2408 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
2409 return E_NOTIMPL;
2410}
2411
2413{
2414 if(IsEqualGUID(&IID_IInternetProtocolInfo, riid))
2415 return E_NOINTERFACE;
2416
2417 ok(outer != NULL, "outer == NULL\n");
2418 ok(IsEqualGUID(&IID_IUnknown, riid), "unexpected riid %s\n", wine_dbgstr_guid(riid));
2419 *ppv = &Protocol;
2420 return S_OK;
2421}
2422
2423static const IClassFactoryVtbl ProtocolCFVtbl = {
2429};
2430
2432
2434{
2435 IBindCtx *bctx = (IBindCtx*)0x0ff00ff0;
2436 IUnknown *unk;
2437 HRESULT hres;
2438 ULONG ref;
2439 BIND_OPTS bindopts;
2440
2441 hres = CreateAsyncBindCtx(0, NULL, NULL, &bctx);
2442 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2443 ok(bctx == (IBindCtx*)0x0ff00ff0, "bctx should not be changed\n");
2444
2446 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres);
2447
2448 SET_EXPECT(QueryInterface_IServiceProvider);
2450 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n", hres);
2451 CHECK_CALLED(QueryInterface_IServiceProvider);
2452
2453 bindopts.cbStruct = sizeof(bindopts);
2454 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2455 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2456 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2457 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2458 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2459 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2460 bindopts.grfMode);
2461 ok(bindopts.dwTickCountDeadline == 0,
2462 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2463
2464 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2465 ok(hres == E_NOINTERFACE, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres);
2466 if(SUCCEEDED(hres))
2467 IUnknown_Release(unk);
2468
2469 ref = IBindCtx_Release(bctx);
2470 ok(ref == 0, "bctx should be destroyed here\n");
2471}
2472
2474{
2475 IBindCtx *bctx = NULL, *bctx2 = NULL, *bctx_arg = NULL;
2476 IUnknown *unk;
2477 BIND_OPTS bindopts;
2478 HRESULT hres;
2479
2480 static WCHAR testW[] = {'t','e','s','t',0};
2481
2482 if (!pCreateAsyncBindCtxEx) {
2483 win_skip("CreateAsyncBindCtxEx not present\n");
2484 return;
2485 }
2486
2487 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, NULL, 0);
2488 ok(hres == E_INVALIDARG, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres);
2489
2490 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2491 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2492
2493 if(SUCCEEDED(hres)) {
2494 bindopts.cbStruct = sizeof(bindopts);
2495 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2496 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2497 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2498 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2499 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2500 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2501 bindopts.grfMode);
2502 ok(bindopts.dwTickCountDeadline == 0,
2503 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2504
2505 IBindCtx_Release(bctx);
2506 }
2507
2508 CreateBindCtx(0, &bctx_arg);
2509 hres = pCreateAsyncBindCtxEx(NULL, 0, NULL, NULL, &bctx, 0);
2510 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2511
2512 if(SUCCEEDED(hres)) {
2513 bindopts.cbStruct = sizeof(bindopts);
2514 hres = IBindCtx_GetBindOptions(bctx, &bindopts);
2515 ok(hres == S_OK, "IBindCtx_GetBindOptions failed: %08x\n", hres);
2516 ok(bindopts.grfFlags == BIND_MAYBOTHERUSER,
2517 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts.grfFlags);
2518 ok(bindopts.grfMode == (STGM_READWRITE | STGM_SHARE_EXCLUSIVE),
2519 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2520 bindopts.grfMode);
2521 ok(bindopts.dwTickCountDeadline == 0,
2522 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts.dwTickCountDeadline);
2523
2524 IBindCtx_Release(bctx);
2525 }
2526
2527 IBindCtx_Release(bctx_arg);
2528
2529 SET_EXPECT(QueryInterface_IServiceProvider);
2530 hres = pCreateAsyncBindCtxEx(NULL, 0, (IBindStatusCallback*)&bsc, NULL, &bctx, 0);
2531 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2532 CHECK_CALLED(QueryInterface_IServiceProvider);
2533
2534 hres = IBindCtx_QueryInterface(bctx, &IID_IAsyncBindCtx, (void**)&unk);
2535 ok(hres == S_OK, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres);
2536 if(SUCCEEDED(hres))
2537 IUnknown_Release(unk);
2538
2539 IBindCtx_Release(bctx);
2540
2541 hres = CreateBindCtx(0, &bctx2);
2542 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2543
2544 hres = pCreateAsyncBindCtxEx(bctx2, 0, NULL, NULL, &bctx, 0);
2545 ok(hres == S_OK, "CreateAsyncBindCtxEx failed: %08x\n", hres);
2546
2547 hres = IBindCtx_RegisterObjectParam(bctx2, testW, (IUnknown*)&Protocol);
2548 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2549
2550 hres = IBindCtx_GetObjectParam(bctx, testW, &unk);
2551 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2552 ok(unk == (IUnknown*)&Protocol, "unexpected unk %p\n", unk);
2553
2554 IBindCtx_Release(bctx);
2555 IBindCtx_Release(bctx2);
2556}
2557
2559{
2560 IBindStatusCallbackEx *bscex;
2561 BINDINFO bindinfo = {sizeof(bindinfo)};
2562 DWORD bindf, bindf2, dw;
2563 HRESULT hres;
2564
2565 hres = IBindStatusCallback_QueryInterface(holder, &IID_IBindStatusCallbackEx, (void**)&bscex);
2566 if(FAILED(hres)) {
2567 win_skip("IBindStatusCallbackEx not supported\n");
2568 return;
2569 }
2570
2571 use_bscex = TRUE;
2572
2573 bindf = 0;
2574 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2575 SET_EXPECT(GetBindInfoEx);
2576 hres = IBindStatusCallback_GetBindInfo(holder, &bindf, &bindinfo);
2577 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2578 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2579 CHECK_CALLED(GetBindInfoEx);
2580
2581 bindf = bindf2 = dw = 0;
2582 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2583 SET_EXPECT(GetBindInfoEx);
2584 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2585 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2586 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2587 CHECK_CALLED(GetBindInfoEx);
2588
2589 use_bscex = FALSE;
2590
2591 bindf = bindf2 = dw = 0xdeadbeef;
2592 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2593 SET_EXPECT(GetBindInfo);
2594 hres = IBindStatusCallbackEx_GetBindInfoEx(bscex, &bindf, &bindinfo, &bindf2, &dw);
2595 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2596 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx);
2597 CHECK_CALLED(GetBindInfo);
2598 ok(bindf2 == 0xdeadbeef, "bindf2 = %x\n", bindf2);
2599 ok(dw == 0xdeadbeef, "dw = %x\n", dw);
2600
2601 IBindStatusCallbackEx_Release(bscex);
2602}
2603
2605{
2606 IServiceProvider *serv_prov;
2607 IHttpNegotiate *http_negotiate, *http_negotiate_serv;
2608 IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
2609 IAuthenticate *authenticate, *authenticate_serv;
2612 BINDINFO bindinfo = {sizeof(bindinfo)};
2613 BOOL ret = TRUE;
2614 LPWSTR wstr;
2615 DWORD dw;
2616 HRESULT hres;
2617
2618 hres = IBindStatusCallback_QueryInterface(holder, &IID_IServiceProvider, (void**)&serv_prov);
2619 ok(hres == S_OK, "Could not get IServiceProvider interface: %08x\n", hres);
2620
2621 dw = 0xdeadbeef;
2622 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
2623 SET_EXPECT(GetBindInfo);
2624 hres = IBindStatusCallback_GetBindInfo(holder, &dw, &bindinfo);
2625 ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
2626 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
2627 CHECK_CALLED(GetBindInfo);
2628
2629 test_GetBindInfoEx(holder);
2630
2631 SET_EXPECT(OnStartBinding);
2632 hres = IBindStatusCallback_OnStartBinding(holder, 0, (void*)0xdeadbeef);
2633 ok(hres == S_OK, "OnStartBinding failed: %08x\n", hres);
2634 CHECK_CALLED(OnStartBinding);
2635
2636 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate, (void**)&http_negotiate);
2637 ok(hres == S_OK, "Could not get IHttpNegotiate interface: %08x\n", hres);
2638
2639 SET_EXPECT(QueryInterface_IHttpNegotiate);
2640 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2641 (void**)&http_negotiate_serv);
2642 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2643 CLEAR_CALLED(QueryInterface_IHttpNegotiate); /* IE <8 */
2644
2645 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2646
2647 wstr = (void*)0xdeadbeef;
2648 SET_EXPECT(QueryInterface_IHttpNegotiate);
2649 SET_EXPECT(BeginningTransaction);
2650 hres = IHttpNegotiate_BeginningTransaction(http_negotiate_serv, current_url, emptyW, 0, &wstr);
2651 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2652 CHECK_CALLED(BeginningTransaction);
2653 ok(hres == S_OK, "BeginningTransaction failed: %08x\n", hres);
2654 ok(wstr == NULL, "wstr = %p\n", wstr);
2655
2656 IHttpNegotiate_Release(http_negotiate_serv);
2657
2658 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate, &IID_IHttpNegotiate,
2659 (void**)&http_negotiate_serv);
2660 ok(hres == S_OK, "Could not get IHttpNegotiate service: %08x\n", hres);
2661 ok(http_negotiate == http_negotiate_serv, "http_negotiate != http_negotiate_serv\n");
2662 IHttpNegotiate_Release(http_negotiate_serv);
2663
2664 hres = IBindStatusCallback_QueryInterface(holder, &IID_IHttpNegotiate2, (void**)&http_negotiate2);
2665 if(SUCCEEDED(hres)) {
2667
2668 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2669 hres = IServiceProvider_QueryService(serv_prov, &IID_IHttpNegotiate2, &IID_IHttpNegotiate2,
2670 (void**)&http_negotiate2_serv);
2671 ok(hres == S_OK, "Could not get IHttpNegotiate2 service: %08x\n", hres);
2672 CLEAR_CALLED(QueryInterface_IHttpNegotiate2); /* IE <8 */
2673 ok(http_negotiate2 == http_negotiate2_serv, "http_negotiate != http_negotiate_serv\n");
2674
2675 SET_EXPECT(QueryInterface_IHttpNegotiate2);
2676 SET_EXPECT(GetRootSecurityId);
2677 hres = IHttpNegotiate2_GetRootSecurityId(http_negotiate2, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2678 ok(hres == E_NOTIMPL, "GetRootSecurityId failed: %08x\n", hres);
2679 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2); /* IE8 */
2680 CHECK_CALLED(GetRootSecurityId);
2681
2682 IHttpNegotiate2_Release(http_negotiate2_serv);
2683 IHttpNegotiate2_Release(http_negotiate2);
2684 }else {
2685 skip("Could not get IHttpNegotiate2\n");
2686 ret = FALSE;
2687 }
2688
2689 SET_EXPECT(OnProgress_FINDINGRESOURCE);
2690 hres = IBindStatusCallback_OnProgress(holder, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
2691 ok(hres == S_OK, "OnProgress failed: %08x\n", hres);
2692 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
2693
2694 SET_EXPECT(QueryInterface_IHttpNegotiate);
2695 SET_EXPECT(OnResponse);
2696 wstr = (void*)0xdeadbeef;
2697 hres = IHttpNegotiate_OnResponse(http_negotiate, 200, emptyW, NULL, NULL);
2698 ok(hres == S_OK, "OnResponse failed: %08x\n", hres);
2699 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate); /* IE8 */
2700 CHECK_CALLED(OnResponse);
2701
2702 IHttpNegotiate_Release(http_negotiate);
2703
2704 hres = IBindStatusCallback_QueryInterface(holder, &IID_IAuthenticate, (void**)&authenticate);
2705 ok(hres == S_OK, "Could not get IAuthenticate interface: %08x\n", hres);
2706
2707 SET_EXPECT(QueryInterface_IAuthenticate);
2708 SET_EXPECT(QueryService_IAuthenticate);
2709 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2710 (void**)&authenticate_serv);
2711 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2712 CLEAR_CALLED(QueryInterface_IAuthenticate); /* IE <8 */
2713 CLEAR_CALLED(QueryService_IAuthenticate); /* IE <8 */
2714 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2715 IAuthenticate_Release(authenticate_serv);
2716
2717 hres = IServiceProvider_QueryService(serv_prov, &IID_IAuthenticate, &IID_IAuthenticate,
2718 (void**)&authenticate_serv);
2719 ok(hres == S_OK, "Could not get IAuthenticate service: %08x\n", hres);
2720 ok(authenticate == authenticate_serv, "authenticate != authenticate_serv\n");
2721
2722 IAuthenticate_Release(authenticate);
2723 IAuthenticate_Release(authenticate_serv);
2724
2725 hres = IBindStatusCallback_QueryInterface(holder, &IID_IInternetBindInfo, (void**)&bind_info);
2726 ok(hres == S_OK || broken(hres == E_NOINTERFACE /* win2k */), "Could not get IInternetBindInfo interface: %08x\n", hres);
2727
2728 if(SUCCEEDED(hres)) {
2729 hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_USER_AGENT, &wstr, 1, &dw);
2730 ok(hres == E_NOINTERFACE, "GetBindString(BINDSTRING_USER_AGENT) failed: %08x\n", hres);
2731
2732 IInternetBindInfo_Release(bind_info);
2733 }
2734
2735 SET_EXPECT(OnStopBinding);
2736 hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
2737 ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
2738 CHECK_CALLED(OnStopBinding);
2739
2740 SET_EXPECT(QueryInterface_IInternetProtocol);
2741 SET_EXPECT(QueryService_IInternetProtocol);
2742 hres = IServiceProvider_QueryService(serv_prov, &IID_IInternetProtocol, &IID_IInternetProtocol,
2743 (void**)&protocol);
2744 ok(hres == E_NOINTERFACE, "QueryService(IInternetProtocol) failed: %08x\n", hres);
2745 CHECK_CALLED(QueryInterface_IInternetProtocol);
2746 CHECK_CALLED(QueryService_IInternetProtocol);
2747
2748 IServiceProvider_Release(serv_prov);
2749 return ret;
2750}
2751
2753{
2754 IBindStatusCallback *prevbsc, *clb, *prev_clb;
2755 IBindCtx *bindctx;
2756 BOOL ret = TRUE;
2757 IUnknown *unk;
2758 HRESULT hres;
2759
2761
2762 hres = CreateBindCtx(0, &bindctx);
2763 ok(hres == S_OK, "BindCtx failed: %08x\n", hres);
2764
2765 SET_EXPECT(QueryInterface_IServiceProvider);
2766
2767 hres = IBindCtx_RegisterObjectParam(bindctx, BSCBHolder, (IUnknown*)&bsc);
2768 ok(hres == S_OK, "RegisterObjectParam failed: %08x\n", hres);
2769
2770 SET_EXPECT(QueryInterface_IBindStatusCallback);
2771 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder);
2772 prevbsc = (void*)0xdeadbeef;
2773 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2774 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2775 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc=%p\n", prevbsc);
2776 CHECK_CALLED(QueryInterface_IBindStatusCallback);
2777 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder);
2778
2779 CHECK_CALLED(QueryInterface_IServiceProvider);
2780
2781 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2782 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2783
2784 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2785 IUnknown_Release(unk);
2786 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2787 ok(clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2788
2789 if(!test_bscholder(clb))
2790 ret = FALSE;
2791
2792 IBindStatusCallback_Release(clb);
2793
2795 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2796
2797 unk = (void*)0xdeadbeef;
2798 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2799 ok(hres == E_FAIL, "GetObjectParam failed: %08x\n", hres);
2800 ok(unk == NULL, "unk != NULL\n");
2801
2802 if(unk)
2803 IUnknown_Release(unk);
2804
2805 hres = RevokeBindStatusCallback(bindctx, (void*)0xdeadbeef);
2806 ok(hres == S_OK, "RevokeBindStatusCallback failed: %08x\n", hres);
2807
2808 hres = RevokeBindStatusCallback(NULL, (void*)0xdeadbeef);
2809 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2810
2812 ok(hres == E_INVALIDARG, "RevokeBindStatusCallback failed: %08x\n", hres);
2813
2814 SET_EXPECT(QueryInterface_IServiceProvider);
2815 prevbsc = (void*)0xdeadbeef;
2816 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc, &prevbsc, 0);
2817 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2818 ok(!prevbsc, "prevbsc=%p\n", prevbsc);
2819 CHECK_CALLED(QueryInterface_IServiceProvider);
2820
2821 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2822 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2823
2824 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&prev_clb);
2825 IUnknown_Release(unk);
2826 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2827 ok(prev_clb != (IBindStatusCallback*)&bsc, "bsc == clb\n");
2828
2829 SET_EXPECT(QueryInterface_IServiceProvider);
2830 prevbsc = (void*)0xdeadbeef;
2831 hres = RegisterBindStatusCallback(bindctx, (IBindStatusCallback*)&bsc2, &prevbsc, 0);
2832 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2833 ok(prevbsc == (IBindStatusCallback*)&bsc, "prevbsc != bsc\n");
2834 CHECK_CALLED(QueryInterface_IServiceProvider);
2835
2836 hres = IBindCtx_GetObjectParam(bindctx, BSCBHolder, &unk);
2837 ok(hres == S_OK, "GetObjectParam failed: %08x\n", hres);
2838
2839 hres = IUnknown_QueryInterface(unk, &IID_IBindStatusCallback, (void**)&clb);
2840 IUnknown_Release(unk);
2841 ok(hres == S_OK, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres);
2842 ok(prev_clb == clb, "bsc != clb\n");
2843
2844 IBindStatusCallback_Release(clb);
2845 IBindStatusCallback_Release(prev_clb);
2846
2847 IBindCtx_Release(bindctx);
2848
2850 return ret;
2851}
2852
2853#define BINDTEST_EMULATE 0x0001
2854#define BINDTEST_TOOBJECT 0x0002
2855#define BINDTEST_FILEDWLAPI 0x0004
2856#define BINDTEST_HTTPRESPONSE 0x0008
2857#define BINDTEST_REDIRECT 0x0010
2858#define BINDTEST_USE_CACHE 0x0020
2859#define BINDTEST_NO_CALLBACK_READ 0x0040
2860#define BINDTEST_NO_CALLBACK 0x0080
2861#define BINDTEST_ABORT 0x0100
2862#define BINDTEST_INVALID_CN 0x0200
2863#define BINDTEST_ABORT_START 0x0400
2864#define BINDTEST_ABORT_PROGRESS 0x0800
2865#define BINDTEST_ASYNC_SWITCH 0x1000
2866#define BINDTEST_ALLOW_FINDINGRESOURCE 0x2000
2867
2869{
2870 const char *url_a = NULL;
2871
2879 mime_type[0] = 0;
2882 tymed = t;
2885
2886 switch(protocol) {
2887 case HTTP_TEST:
2888 if(post_test)
2889 url_a = "http://test.winehq.org/tests/post.php";
2890 else
2892 break;
2893 case ABOUT_TEST:
2894 url_a = "about:blank";
2895 break;
2896 case FILE_TEST:
2898 break;
2899 case MK_TEST:
2900 url_a = "mk:@MSITStore:test.chm::/blank.html";
2901 break;
2902 case ITS_TEST:
2903 url_a = "its:test.chm::/blank.html";
2904 break;
2905 case HTTPS_TEST:
2906 url_a = (flags & BINDTEST_INVALID_CN) ? "https://4.15.184.77/favicon.ico" : "https://test.winehq.org/tests/hello.html";
2907 break;
2908 case FTP_TEST:
2909 url_a = "ftp://ftp.winehq.org/welcome%2emsg";
2910 break;
2911 default:
2912 url_a = "winetest:test";
2913 }
2914
2915 if(url_a)
2917
2922 test_abort = (flags & BINDTEST_ABORT) != 0;
2927 prot_state = 0;
2929
2930 trace("URL: %s\n", wine_dbgstr_w(current_url));
2931}
2932
2934{
2935 IMoniker *mon;
2936 HRESULT hres;
2937 LPOLESTR display_name;
2938 IBindCtx *bctx = NULL;
2939 MSG msg;
2940 IBindStatusCallback *previousclb;
2941 IUnknown *unk = (IUnknown*)0x00ff00ff;
2942 BOOL allow_finding_resource;
2943 IBinding *bind;
2944
2946 allow_finding_resource = (flags & BINDTEST_ALLOW_FINDINGRESOURCE) != 0;
2947
2948 if(no_callback) {
2949 hres = CreateBindCtx(0, &bctx);
2950 ok(hres == S_OK, "CreateBindCtx failed: %08x\n", hres);
2951 }else {
2952 SET_EXPECT(QueryInterface_IServiceProvider);
2954 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
2955 CHECK_CALLED(QueryInterface_IServiceProvider);
2956 if(FAILED(hres))
2957 return;
2958
2959 SET_EXPECT(QueryInterface_IServiceProvider);
2960 hres = RegisterBindStatusCallback(bctx, (IBindStatusCallback*)&bsc, &previousclb, 0);
2961 ok(hres == S_OK, "RegisterBindStatusCallback failed: %08x\n", hres);
2962 ok(previousclb == (IBindStatusCallback*)&bsc, "previousclb(%p) != sclb(%p)\n", previousclb, &bsc);
2963 CHECK_CALLED(QueryInterface_IServiceProvider);
2964 if(previousclb)
2965 IBindStatusCallback_Release(previousclb);
2966 }
2967
2969 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
2970 if(FAILED(hres))
2971 return;
2972
2973 if(protocol == FTP_TEST)
2974 {
2975 /* FTP urls don't have any escape characters so convert the url to what is expected */
2976 DWORD size = 0;
2978 }
2979
2980 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
2981 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
2982 if(SUCCEEDED(hres))
2983 IBinding_Release(bind);
2984
2985 hres = IMoniker_GetDisplayName(mon, bctx, NULL, &display_name);
2986 ok(hres == S_OK, "GetDisplayName failed %08x\n", hres);
2987 ok(!lstrcmpW(display_name, current_url), "GetDisplayName got wrong name %s, expected %s\n",
2988 wine_dbgstr_w(display_name), wine_dbgstr_w(current_url));
2989 CoTaskMemFree(display_name);
2990
2991 if(tymed == TYMED_FILE && (test_protocol == ABOUT_TEST || test_protocol == ITS_TEST))
2992 binding_hres = INET_E_DATA_NOT_AVAILABLE;
2996 binding_hres = INET_E_SECURITY_PROBLEM;
2997 else
2998 binding_hres = INET_E_INVALID_CERTIFICATE;
2999 }
3000
3001
3003 SET_EXPECT(OnStopBinding);
3004 if(!no_callback) {
3005 SET_EXPECT(QueryInterface_IBindStatusCallbackEx);
3006 SET_EXPECT(GetBindInfo);
3007 SET_EXPECT(QueryInterface_IInternetProtocol);
3008 if(!emulate_protocol)
3009 SET_EXPECT(QueryService_IInternetProtocol);
3010 SET_EXPECT(OnStartBinding);
3011 }
3012 if(emulate_protocol) {
3018 SET_EXPECT(Terminate);
3019 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
3021 }else {
3023 SET_EXPECT(QueryService_IInternetBindInfo);
3024 if(!abort_start)
3025 SET_EXPECT(QueryInterface_IHttpNegotiate);
3026 SET_EXPECT(QueryInterface_IWindowForBindingUI);
3027 SET_EXPECT(QueryService_IWindowForBindingUI);
3028 SET_EXPECT(GetWindow_IWindowForBindingUI);
3029 if(!abort_start) {
3030 SET_EXPECT(BeginningTransaction);
3031 SET_EXPECT(QueryInterface_IHttpNegotiate2);
3032 SET_EXPECT(GetRootSecurityId);
3033 if(http_is_first || allow_finding_resource)
3034 SET_EXPECT(OnProgress_FINDINGRESOURCE);
3035 SET_EXPECT(OnProgress_CONNECTING);
3036 }
3038 SET_EXPECT(QueryInterface_IHttpSecurity);
3039 SET_EXPECT(QueryService_IHttpSecurity);
3040 SET_EXPECT(OnSecurityProblem);
3042 SET_EXPECT(GetWindow_IHttpSecurity);
3043 }
3044 }
3045 if(!no_callback) {
3048 SET_EXPECT(OnProgress_SENDINGREQUEST);
3050 SET_EXPECT(QueryInterface_IHttpNegotiate);
3051 SET_EXPECT(OnResponse);
3052 }
3053 if(!abort_start) {
3054 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
3055 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA);
3056 }
3058 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE);
3060 SET_EXPECT(OnProgress_DOWNLOADINGDATA);
3061 if(!abort_start)
3062 SET_EXPECT(OnProgress_ENDDOWNLOADDATA);
3063 if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
3064 SET_EXPECT(OnDataAvailable);
3065 SET_EXPECT(OnStopBinding);
3066 }
3067 }
3068
3069 hres = IMoniker_BindToStorage(mon, bctx, NULL, tymed == TYMED_ISTREAM ? &IID_IStream : &IID_IUnknown, (void**)&unk);
3072 {
3073 skip("Network unreachable, skipping tests\n");
3074 return;
3075 }
3076
3078 ok(hres == E_FAIL, "Got %08x\n", hres);
3079 CHECK_CALLED(OnStopBinding);
3080 } else if(abort_start)
3081 ok(hres == abort_hres, "IMoniker_BindToStorage failed: %08x, expected %08x\n", hres, abort_hres);
3082 else if(abort_progress)
3083 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
3084 else if(no_callback) {
3086 ok( WaitForSingleObject(complete_event2, 90000) == WAIT_OBJECT_0, "wait timed out\n" );
3087 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3088 ok(unk != NULL, "unk == NULL\n");
3089 }else if(!(bindf & BINDF_ASYNCHRONOUS) && tymed == TYMED_FILE) {
3090 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3091 ok(unk == NULL, "unk != NULL\n");
3092 }else if(((bindf & BINDF_ASYNCHRONOUS) && !data_available)
3093 || (tymed == TYMED_FILE && test_protocol == FILE_TEST)) {
3094 ok(hres == MK_S_ASYNCHRONOUS, "IMoniker_BindToStorage failed: %08x\n", hres);
3095 ok(unk == NULL, "istr should be NULL\n");
3096 }else if(tymed == TYMED_FILE && test_protocol == ABOUT_TEST) {
3097 ok(hres == INET_E_DATA_NOT_AVAILABLE,
3098 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres);
3099 ok(unk == NULL, "istr should be NULL\n");
3100 }else if((flags & BINDTEST_INVALID_CN) && binding_hres != S_OK) {
3101 ok(hres == binding_hres, "Got %08x\n", hres);
3102 ok(unk == NULL, "Got %p\n", unk);
3104 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3105 ok(unk != NULL, "unk == NULL\n");
3106 if(unk == NULL) {
3107 ok(0, "Expected security problem to be ignored.\n");
3109 binding_hres = INET_E_INVALID_CERTIFICATE;
3110 }
3111 }else {
3112 ok(hres == S_OK, "IMoniker_BindToStorage failed: %08x\n", hres);
3113 ok(unk != NULL, "unk == NULL\n");
3114 }
3115 if(unk && callback_read && !no_callback) {
3116 IUnknown_Release(unk);
3117 unk = NULL;
3118 }
3119
3121 return;
3122
3123 if((bindf & BINDF_ASYNCHRONOUS) && !no_callback) {
3124 while(!stopped_binding && GetMessageA(&msg,NULL,0,0)) {
3127 }
3128 }
3129
3130 if(async_switch) {
3131 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3132 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3133 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3135 CHECK_CALLED(OnStopBinding);
3136 }
3137 if(!no_callback) {
3138 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx); /* IE 8 */
3139 CHECK_CALLED(GetBindInfo);
3141 CHECK_CALLED(QueryInterface_IInternetProtocol);
3142 if(!emulate_protocol) {
3144 CHECK_CALLED(QueryService_IInternetProtocol);
3145 }
3146 CHECK_CALLED(OnStartBinding);
3147 }
3148 if(emulate_protocol) {
3150 CLEAR_CALLED(SetPriority); /* Not called by IE11 */
3154 if(tymed == TYMED_FILE)
3156 CHECK_CALLED(Terminate);
3157 }
3158 if(tymed != TYMED_FILE || (test_protocol != ABOUT_TEST && test_protocol != ITS_TEST))
3160 }else {
3162 CLEAR_CALLED(QueryService_IInternetBindInfo);
3163 if(!abort_start)
3164 CHECK_CALLED(QueryInterface_IHttpNegotiate);
3165 CLEAR_CALLED(QueryInterface_IWindowForBindingUI);
3166 CLEAR_CALLED(QueryService_IWindowForBindingUI);
3167 CLEAR_CALLED(GetWindow_IWindowForBindingUI);
3168 if(!abort_start)
3169 CHECK_CALLED(BeginningTransaction);
3171 {
3172 CHECK_CALLED(QueryInterface_IHttpNegotiate2);
3173 CHECK_CALLED(GetRootSecurityId);
3174 }
3175 if(http_is_first) {
3176 if (! proxy_active())
3177 {
3178 CHECK_CALLED(OnProgress_FINDINGRESOURCE);
3179 CHECK_CALLED(OnProgress_CONNECTING);
3180 }
3181 else
3182 {
3183 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
3184 CLEAR_CALLED(OnProgress_CONNECTING);
3185 }
3186 }else if(!abort_start) {
3187 if(allow_finding_resource)
3188 CLEAR_CALLED(OnProgress_FINDINGRESOURCE);
3189 /* IE7 does call this */
3190 CLEAR_CALLED(OnProgress_CONNECTING);
3191 }
3193 CHECK_CALLED(QueryInterface_IHttpSecurity);
3194 CHECK_CALLED(QueryService_IHttpSecurity);
3195 CHECK_CALLED(OnSecurityProblem);
3196 }else {
3197 CHECK_NOT_CALLED(QueryInterface_IHttpSecurity);
3198 CHECK_NOT_CALLED(QueryService_IHttpSecurity);
3199 CHECK_NOT_CALLED(OnSecurityProblem);
3200 }
3201 }
3202 if(!no_callback) {
3205 CLEAR_CALLED(OnProgress_SENDINGREQUEST);
3206 else if(!abort_start)
3207 CHECK_CALLED(OnProgress_SENDINGREQUEST);
3208 } else if(test_protocol == FTP_TEST)
3209 todo_wine CHECK_CALLED(OnProgress_SENDINGREQUEST);
3211 CLEAR_CALLED(QueryInterface_IHttpNegotiate);
3212 if((!(flags & BINDTEST_INVALID_CN) || (binding_hres == S_OK)) && !abort_start) {
3213 CHECK_CALLED(OnResponse);
3214 }
3215 }
3217 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE);
3218 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA);
3219 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA);
3220 }
3222 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE);
3224 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA);
3225 if((flags & BINDTEST_INVALID_CN)) {
3226 if(binding_hres == S_OK)
3227 CHECK_CALLED(OnDataAvailable);
3228 else
3229 CHECK_NOT_CALLED(OnDataAvailable);
3230 }else if((tymed != TYMED_FILE || test_protocol != ABOUT_TEST) && !abort_start)
3231 CHECK_CALLED(OnDataAvailable);
3232 CHECK_CALLED(OnStopBinding);
3233 }
3234 }
3235
3236 ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
3237 if(bctx)
3238 ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
3239
3242
3245
3246 if(unk) {
3247 BYTE buf[512];
3248 DWORD readed;
3249 IStream *stream;
3250
3251 hres = IUnknown_QueryInterface(unk, &IID_IStream, (void**)&stream);
3252 ok(hres == S_OK, "Could not get IStream iface: %08x\n", hres);
3253 IUnknown_Release(unk);
3254
3255 do {
3256 readed = 0xdeadbeef;
3257 hres = IStream_Read(stream, buf, sizeof(buf), &readed);
3258 ok(readed != 0xdeadbeef, "readed = 0xdeadbeef\n");
3259 if(emulate_protocol && test_protocol == HTTP_TEST && readed)
3260 ok(buf[0] == (use_cache_file && !(bindf&BINDF_ASYNCHRONOUS) ? 'X' : '?'), "buf[0] = '%c'\n", buf[0]);
3261 }while(hres == S_OK);
3262 ok(hres == S_FALSE, "IStream_Read returned %08x\n", hres);
3263 ok(!readed, "readed = %d\n", readed);
3264
3265 IStream_Release(stream);
3266 }
3267}
3268
3270{
3271 IMoniker *mon;
3272 HRESULT hres;
3273 LPOLESTR display_name;
3274 IBindCtx *bctx;
3275 DWORD regid;
3276 MSG msg;
3277 IUnknown *unk = (IUnknown*)0x00ff00ff;
3278 IBinding *bind;
3279
3281 binding_hres = exhres;
3282
3284 CoRegisterClassObject(&CLSID_HTMLDocument, (IUnknown *)&mime_cf,
3285 CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &regid);
3286
3287 SET_EXPECT(QueryInterface_IServiceProvider);
3289 ok(hres == S_OK, "CreateAsyncBindCtx failed: %08x\n\n", hres);
3290 CHECK_CALLED(QueryInterface_IServiceProvider);
3291 if(FAILED(hres))
3292 return;
3293
3295 ok(hres == S_OK, "failed to create moniker: %08x\n", hres);
3296 if(FAILED(hres)) {
3297 IBindCtx_Release(bctx);
3298 return;
3299 }
3300
3301 hres = IMoniker_QueryInterface(mon, &IID_IBinding, (void**)&bind);
3302 ok(hres == E_NOINTERFACE, "IMoniker should not have IBinding interface\n");
3303 if(SUCCEEDED(hres))
3304 IBinding_Release(bind</