4 * Copyright 2004 Kevin Koltzau
5 * Copyright 2004-2007 Jacek Caban for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #define NONAMELESSUNION
37 #include "wine/test.h"
39 static HRESULT (WINAPI
*pCreateAsyncBindCtxEx
)(IBindCtx
*, DWORD
,
40 IBindStatusCallback
*, IEnumFORMATETC
*, IBindCtx
**, DWORD
);
41 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
43 DEFINE_OLEGUID(CLSID_CompositeMoniker
, 0x309, 0, 0 );
44 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
45 DEFINE_GUID(CLSID_IdentityUnmarshal
,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
46 DEFINE_GUID(IID_IBindStatusCallbackHolder
,0x79eac9cc,0xbaf9,0x11ce,0x8c,0x82,0x00,0xaa,0x00,0x4b,0xa9,0x0b);
47 extern CLSID CLSID_AboutProtocol
;
49 #define DEFINE_EXPECT(func) \
50 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
52 #define SET_EXPECT(func) \
53 do { called_ ## func = FALSE; expect_ ## func = TRUE; } while(0)
55 #define CHECK_EXPECT2(func) \
57 ok(expect_ ##func, "unexpected call " #func "\n"); \
58 called_ ## func = TRUE; \
61 #define CHECK_EXPECT(func) \
63 CHECK_EXPECT2(func); \
64 expect_ ## func = FALSE; \
67 #define CHECK_CALLED(func) \
69 ok(called_ ## func, "expected " #func "\n"); \
70 expect_ ## func = called_ ## func = FALSE; \
73 #define CHECK_NOT_CALLED(func) \
75 ok(!called_ ## func, "unexpected " #func "\n"); \
76 expect_ ## func = called_ ## func = FALSE; \
79 #define CHECK_CALLED_BROKEN(func) \
81 ok(called_ ## func || broken(!called_ ## func), "expected " #func "\n"); \
82 expect_ ## func = called_ ## func = FALSE; \
85 #define CLEAR_CALLED(func) \
86 expect_ ## func = called_ ## func = FALSE
88 DEFINE_EXPECT(QueryInterface_IServiceProvider
);
89 DEFINE_EXPECT(QueryInterface_IHttpNegotiate
);
90 DEFINE_EXPECT(QueryInterface_IBindStatusCallback
);
91 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackEx
);
92 DEFINE_EXPECT(QueryInterface_IBindStatusCallbackHolder
);
93 DEFINE_EXPECT(QueryInterface_IAuthenticate
);
94 DEFINE_EXPECT(QueryInterface_IInternetProtocol
);
95 DEFINE_EXPECT(QueryInterface_IWindowForBindingUI
);
96 DEFINE_EXPECT(QueryInterface_IHttpSecurity
);
97 DEFINE_EXPECT(QueryService_IAuthenticate
);
98 DEFINE_EXPECT(QueryService_IInternetProtocol
);
99 DEFINE_EXPECT(QueryService_IInternetBindInfo
);
100 DEFINE_EXPECT(QueryService_IWindowForBindingUI
);
101 DEFINE_EXPECT(QueryService_IHttpSecurity
);
102 DEFINE_EXPECT(BeginningTransaction
);
103 DEFINE_EXPECT(OnResponse
);
104 DEFINE_EXPECT(QueryInterface_IHttpNegotiate2
);
105 DEFINE_EXPECT(GetRootSecurityId
);
106 DEFINE_EXPECT(GetBindInfo
);
107 DEFINE_EXPECT(GetBindInfoEx
);
108 DEFINE_EXPECT(OnStartBinding
);
109 DEFINE_EXPECT(OnProgress_FINDINGRESOURCE
);
110 DEFINE_EXPECT(OnProgress_CONNECTING
);
111 DEFINE_EXPECT(OnProgress_REDIRECTING
);
112 DEFINE_EXPECT(OnProgress_SENDINGREQUEST
);
113 DEFINE_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
114 DEFINE_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
115 DEFINE_EXPECT(OnProgress_DOWNLOADINGDATA
);
116 DEFINE_EXPECT(OnProgress_ENDDOWNLOADDATA
);
117 DEFINE_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
118 DEFINE_EXPECT(OnStopBinding
);
119 DEFINE_EXPECT(OnDataAvailable
);
120 DEFINE_EXPECT(OnObjectAvailable
);
121 DEFINE_EXPECT(Obj_OnStartBinding
);
122 DEFINE_EXPECT(Obj_OnStopBinding
);
123 DEFINE_EXPECT(Obj_GetBindInfo
);
124 DEFINE_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
125 DEFINE_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
126 DEFINE_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
127 DEFINE_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
128 DEFINE_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
129 DEFINE_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
130 DEFINE_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
131 DEFINE_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
132 DEFINE_EXPECT(Obj_OnProgress_CONNECTING
);
133 DEFINE_EXPECT(Obj_OnProgress_REDIRECTING
);
134 DEFINE_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
135 DEFINE_EXPECT(Start
);
137 DEFINE_EXPECT(LockRequest
);
138 DEFINE_EXPECT(Terminate
);
139 DEFINE_EXPECT(UnlockRequest
);
140 DEFINE_EXPECT(Continue
);
141 DEFINE_EXPECT(Abort
);
142 DEFINE_EXPECT(CreateInstance
);
144 DEFINE_EXPECT(PutProperty_MIMETYPEPROP
);
145 DEFINE_EXPECT(PutProperty_CLASSIDPROP
);
146 DEFINE_EXPECT(SetPriority
);
147 DEFINE_EXPECT(GetWindow_IHttpSecurity
);
148 DEFINE_EXPECT(GetWindow_IWindowForBindingUI
);
149 DEFINE_EXPECT(GetWindow_ICodeInstall
);
150 DEFINE_EXPECT(OnSecurityProblem
);
152 static 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};
155 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
157 static const WCHAR wszTextHtml
[] = {'t','e','x','t','/','h','t','m','l',0};
159 static WCHAR BSCBHolder
[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
161 #define WINEHQ_IP "4.4.81.124"
162 static const WCHAR wszWineHQSite
[] = L
"www.winehq.org";
163 static const WCHAR wszWineHQIP
[] = L
"" WINEHQ_IP
;
164 static const CHAR wszIndexHtmlA
[] = "index.html";
165 static const WCHAR cache_fileW
[] = {'c',':','\\','c','a','c','h','e','.','h','t','m',0};
166 static const CHAR dwl_htmlA
[] = "dwl.html";
167 static const WCHAR dwl_htmlW
[] = {'d','w','l','.','h','t','m','l',0};
168 static const CHAR test_txtA
[] = "test.txt";
169 static const WCHAR emptyW
[] = {0};
171 static BOOL stopped_binding
= FALSE
, stopped_obj_binding
= FALSE
, emulate_protocol
= FALSE
,
172 data_available
= FALSE
, http_is_first
= TRUE
, bind_to_object
= FALSE
, filedwl_api
, post_test
;
173 static DWORD read
= 0, bindf
= 0, prot_state
= 0, thread_id
, tymed
, security_problem
;
174 static const WCHAR
*reported_url
;
175 static CHAR mime_type
[512];
176 static IInternetProtocolSink
*protocol_sink
= NULL
;
177 static IBinding
*current_binding
;
178 static HANDLE complete_event
, complete_event2
;
179 static HRESULT binding_hres
;
180 static HRESULT onsecurityproblem_hres
;
181 static HRESULT abort_hres
;
182 static BOOL have_IHttpNegotiate2
, use_bscex
, is_async_prot
;
183 static BOOL test_redirect
, use_cache_file
, callback_read
, no_callback
, test_abort
;
184 static WCHAR cache_file_name
[MAX_PATH
];
185 static WCHAR http_cache_file
[MAX_PATH
];
186 static BOOL only_check_prot_args
= FALSE
;
187 static BOOL invalid_cn_accepted
= FALSE
;
188 static BOOL abort_start
= FALSE
;
189 static BOOL abort_progress
= FALSE
;
190 static BOOL async_switch
= FALSE
;
191 static BOOL strict_bsc_qi
;
192 static DWORD bindtest_flags
;
193 static const char *test_file
;
195 static WCHAR file_url
[INTERNET_MAX_URL_LENGTH
], current_url
[INTERNET_MAX_URL_LENGTH
];
215 static BOOL
proxy_active(void)
217 HKEY internet_settings
;
221 if (RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
222 0, KEY_QUERY_VALUE
, &internet_settings
) != ERROR_SUCCESS
)
225 size
= sizeof(DWORD
);
226 if (RegQueryValueExA(internet_settings
, "ProxyEnable", NULL
, NULL
, (LPBYTE
) &proxy_enable
, &size
) != ERROR_SUCCESS
)
229 RegCloseKey(internet_settings
);
231 return proxy_enable
!= 0;
234 static BOOL
is_urlmon_protocol(int prot
)
236 return prot
== FILE_TEST
|| prot
== HTTP_TEST
|| prot
== HTTPS_TEST
|| prot
== FTP_TEST
|| prot
== MK_TEST
;
239 static void test_CreateURLMoniker(LPCWSTR url1
, LPCWSTR url2
)
242 IMoniker
*mon1
= NULL
;
243 IMoniker
*mon2
= NULL
;
245 hr
= CreateURLMoniker(NULL
, NULL
, NULL
);
246 ok(hr
== E_INVALIDARG
,
247 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr
);
249 mon1
= (IMoniker
*)0xdeadbeef;
250 hr
= CreateURLMoniker(NULL
, NULL
, &mon1
);
251 ok(hr
== E_INVALIDARG
,
252 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr
);
253 ok(mon1
== NULL
, "Expected the output pointer to be NULL, got %p\n", mon1
);
255 hr
= CreateURLMoniker(NULL
, emptyW
, NULL
);
256 ok(hr
== E_INVALIDARG
,
257 "Expected CreateURLMoniker to return E_INVALIDARG, got 0x%08x\n", hr
);
259 hr
= CreateURLMoniker(NULL
, emptyW
, &mon1
);
261 broken(hr
== MK_E_SYNTAX
), /* IE5/IE5.01/IE6 SP2 */
262 "Expected CreateURLMoniker to return S_OK, got 0x%08x\n", hr
);
263 if(mon1
) IMoniker_Release(mon1
);
265 hr
= CreateURLMoniker(NULL
, url1
, &mon1
);
266 ok(hr
== S_OK
, "failed to create moniker: 0x%08x\n", hr
);
268 hr
= CreateURLMoniker(mon1
, url2
, &mon2
);
269 ok(hr
== S_OK
, "failed to create moniker: 0x%08x\n", hr
);
271 if(mon1
) IMoniker_Release(mon1
);
272 if(mon2
) IMoniker_Release(mon2
);
275 static void test_create(void)
277 static const WCHAR relativeW
[] = {'a','/','b','.','t','x','t',0};
283 static const WCHAR TEST_PART_URL_1
[] = {'/','t','e','s','t','s','/','d','a','t','a','.','p','h','p',0};
285 test_CreateURLMoniker(winetest_data_urlW
, TEST_PART_URL_1
);
287 mon
= (void*)0xdeadbeef;
288 hr
= CreateURLMoniker(NULL
, relativeW
, &mon
);
289 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
291 hr
= CreateBindCtx(0, &bctx
);
292 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
294 stream
= (void*)0xdeadbeef;
295 hr
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&stream
);
296 todo_wine
ok(hr
== INET_E_UNKNOWN_PROTOCOL
, "got 0x%08x\n", hr
);
297 ok(stream
== NULL
, "got %p\n", stream
);
299 hr
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, NULL
);
300 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
302 stream
= (void*)0xdeadbeef;
303 hr
= IMoniker_BindToStorage(mon
, NULL
, NULL
, &IID_IStream
, (void**)&stream
);
304 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
305 ok(stream
== NULL
|| broken(stream
== (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
308 IMoniker_Release(mon
);
310 mon
= (void*)0xdaedbeef;
311 hr
= CreateURLMoniker(NULL
, winetest_data_urlW
, &mon
);
312 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
314 stream
= (void*)0xdeadbeef;
315 hr
= IMoniker_BindToStorage(mon
, NULL
, NULL
, &IID_IStream
, (void**)&stream
);
316 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
317 ok(stream
== NULL
|| broken(stream
== (void*)0xdeadbeef) /* starting XP SP3 it's set to null */,
320 hr
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, NULL
);
321 ok(hr
== E_INVALIDARG
, "got 0x%08x\n", hr
);
323 IMoniker_Release(mon
);
324 IBindCtx_Release(bctx
);
327 static HRESULT WINAPI
Priority_QueryInterface(IInternetPriority
*iface
, REFIID riid
, void **ppv
)
329 ok(0, "unexpected call\n");
330 return E_NOINTERFACE
;
333 static ULONG WINAPI
Priority_AddRef(IInternetPriority
*iface
)
338 static ULONG WINAPI
Priority_Release(IInternetPriority
*iface
)
343 static HRESULT WINAPI
Priority_SetPriority(IInternetPriority
*iface
, LONG nPriority
)
345 CHECK_EXPECT(SetPriority
);
346 ok(!nPriority
, "nPriority = %d\n", nPriority
);
350 static HRESULT WINAPI
Priority_GetPriority(IInternetPriority
*iface
, LONG
*pnPriority
)
352 ok(0, "unexpected call\n");
356 static const IInternetPriorityVtbl InternetPriorityVtbl
= {
357 Priority_QueryInterface
,
360 Priority_SetPriority
,
364 static IInternetPriority InternetPriority
= { &InternetPriorityVtbl
};
366 static HRESULT WINAPI
Protocol_QueryInterface(IInternetProtocol
*iface
, REFIID riid
, void **ppv
)
368 if (winetest_debug
> 1) trace("IInternetProtocol::QueryInterface(%s)\n", debugstr_guid(riid
));
372 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
377 if(IsEqualGUID(&IID_IInternetPriority
, riid
)) {
378 if(!is_urlmon_protocol(test_protocol
))
379 return E_NOINTERFACE
;
381 *ppv
= &InternetPriority
;
385 return E_NOINTERFACE
;
388 static ULONG WINAPI
Protocol_AddRef(IInternetProtocol
*iface
)
393 static ULONG WINAPI
Protocol_Release(IInternetProtocol
*iface
)
398 static void test_switch_fail(void)
400 IInternetProtocolSink
*binding_sink
;
401 PROTOCOLDATA protocoldata
= {0};
404 static BOOL tested_switch_fail
;
406 if(tested_switch_fail
)
409 tested_switch_fail
= TRUE
;
411 hres
= IBinding_QueryInterface(current_binding
, &IID_IInternetProtocolSink
, (void**)&binding_sink
);
412 ok(hres
== S_OK
, "Could not get IInternetProtocolSink iface: %08x\n", hres
);
413 if(SUCCEEDED(hres
)) {
414 hres
= IInternetProtocolSink_Switch(binding_sink
, &protocoldata
);
415 ok(hres
== E_FAIL
, "Switch failed: %08x, expected E_FAIL\n", hres
);
416 IInternetProtocolSink_Release(binding_sink
);
420 static DWORD WINAPI
thread_proc(PVOID arg
)
422 PROTOCOLDATA protocoldata
= {0};
427 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
429 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
431 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
432 BINDSTATUS_FINDINGRESOURCE
, wszWineHQSite
);
433 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
435 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
437 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
439 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
444 SET_EXPECT(Obj_OnProgress_CONNECTING
);
446 SET_EXPECT(OnProgress_CONNECTING
);
448 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
449 BINDSTATUS_CONNECTING
, wszWineHQIP
);
450 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
452 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
454 CHECK_CALLED(Obj_OnProgress_CONNECTING
);
456 CHECK_CALLED(OnProgress_CONNECTING
);
461 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
463 SET_EXPECT(OnProgress_SENDINGREQUEST
);
465 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
466 BINDSTATUS_SENDINGREQUEST
, NULL
);
467 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
469 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
471 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
473 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
478 SET_EXPECT(Obj_OnProgress_REDIRECTING
);
480 SET_EXPECT(OnProgress_REDIRECTING
);
481 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
, BINDSTATUS_REDIRECTING
, winetest_data_urlW
);
482 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_REFIRECTING) failed: %08x\n", hres
);
483 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
485 CHECK_CALLED(Obj_OnProgress_REDIRECTING
);
487 CHECK_CALLED(OnProgress_REDIRECTING
);
492 SET_EXPECT(Continue
);
494 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
495 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
496 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
498 CHECK_CALLED(Continue
);
501 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
502 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
503 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
504 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
505 CHECK_CALLED(CreateInstance
);
506 CHECK_CALLED(PutProperty_MIMETYPEPROP
);
507 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP
);
509 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
510 CHECK_CALLED(OnObjectAvailable
);
511 CHECK_CALLED(Obj_OnStopBinding
);
512 }else if(!no_callback
) {
513 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
514 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
515 CHECK_CALLED(OnDataAvailable
);
517 CHECK_CALLED(LockRequest
);
520 SET_EXPECT(Continue
);
522 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
523 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
524 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
525 CHECK_CALLED(Continue
);
527 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
528 CHECK_CALLED(OnStopBinding
);
529 SetEvent(complete_event2
);
534 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
535 CHECK_CALLED(OnDataAvailable
);
539 SET_EXPECT(Continue
);
541 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
542 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
543 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
544 CHECK_CALLED(Continue
);
547 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
548 CHECK_CALLED(OnDataAvailable
);
551 SET_EXPECT(Continue
);
553 hres
= IInternetProtocolSink_Switch(protocol_sink
, &protocoldata
);
554 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
555 ok( WaitForSingleObject(complete_event
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
556 CHECK_CALLED(Continue
);
559 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
560 CHECK_CALLED(OnDataAvailable
);
561 CHECK_CALLED(OnStopBinding
);
566 SetEvent(complete_event2
);
570 static HRESULT WINAPI
Protocol_Start(IInternetProtocol
*iface
, LPCWSTR szUrl
,
571 IInternetProtocolSink
*pOIProtSink
, IInternetBindInfo
*pOIBindInfo
,
572 DWORD grfPI
, HANDLE_PTR dwReserved
)
575 DWORD bind_info
, bscf
= BSCF_FIRSTDATANOTIFICATION
| BSCF_LASTDATANOTIFICATION
;
578 static const STGMEDIUM stgmed_zero
= {0};
579 static const SECURITY_ATTRIBUTES sa_zero
= {0};
585 reported_url
= szUrl
;
586 if(!filedwl_api
) /* FIXME */
587 ok(szUrl
&& !lstrcmpW(szUrl
, current_url
), "wrong url %s\n", wine_dbgstr_w(szUrl
));
588 ok(pOIProtSink
!= NULL
, "pOIProtSink == NULL\n");
589 ok(pOIBindInfo
!= NULL
, "pOIBindInfo == NULL\n");
590 ok(grfPI
== 0, "grfPI=%d, expected 0\n", grfPI
);
591 ok(dwReserved
== 0, "dwReserved=%lx, expected 0\n", dwReserved
);
593 if(!filedwl_api
&& binding_hres
!= S_OK
) {
594 SET_EXPECT(OnStopBinding
);
595 SET_EXPECT(Terminate
);
596 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, binding_hres
, 0, NULL
);
597 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
598 CHECK_CALLED(OnStopBinding
);
599 CHECK_CALLED(Terminate
);
604 memset(&bindinfo
, 0, sizeof(bindinfo
));
606 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &bind_info
, &bindinfo
);
607 ok(hres
== E_INVALIDARG
, "GetBindInfo returned: %08x, expected E_INVALIDARG\n", hres
);
609 memset(&bindinfo
, 0, sizeof(bindinfo
));
610 bindinfo
.cbSize
= sizeof(bindinfo
);
611 hres
= IInternetBindInfo_GetBindInfo(pOIBindInfo
, &bind_info
, &bindinfo
);
612 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
614 ok(bind_info
& BINDF_FROMURLMON
, "BINDF_FROMURLMON is not set\n");
616 if(filedwl_api
|| !is_urlmon_protocol(test_protocol
) || tymed
!= TYMED_ISTREAM
||
617 !(bindf
&BINDF_ASYNCSTORAGE
) || !(bindf
&BINDF_PULLDATA
))
618 ok(bind_info
& BINDF_NEEDFILE
, "BINDF_NEEDFILE is not set\n");
619 else if(test_protocol
!= MK_TEST
) /* IE10 sets BINDF_NEEDFILE for mk: protocol */
620 ok(!(bind_info
& BINDF_NEEDFILE
), "BINDF_NEEDFILE is set\n");
622 bind_info
&= ~(BINDF_NEEDFILE
|BINDF_FROMURLMON
);
623 if(filedwl_api
|| no_callback
)
624 ok(bind_info
== BINDF_PULLDATA
, "bind_info = %x, expected BINDF_PULLDATA\n", bind_info
);
626 ok(bind_info
== (bindf
& ~(BINDF_NEEDFILE
|BINDF_FROMURLMON
)), "bind_info = %x, expected %x\n",
627 bind_info
, (bindf
& ~(BINDF_NEEDFILE
|BINDF_FROMURLMON
)));
629 ok(bindinfo
.cbSize
== sizeof(bindinfo
), "bindinfo.cbSize = %d\n", bindinfo
.cbSize
);
630 ok(!bindinfo
.szExtraInfo
, "bindinfo.szExtraInfo = %p\n", bindinfo
.szExtraInfo
);
631 ok(!memcmp(&bindinfo
.stgmedData
, &stgmed_zero
, sizeof(STGMEDIUM
)), "wrong stgmedData\n");
632 ok(!bindinfo
.grfBindInfoF
, "bindinfo.grfBindInfoF = %d\n", bindinfo
.grfBindInfoF
);
633 ok(!bindinfo
.dwBindVerb
, "bindinfo.dwBindVerb = %d\n", bindinfo
.dwBindVerb
);
634 ok(!bindinfo
.szCustomVerb
, "bindinfo.szCustomVerb = %p\n", bindinfo
.szCustomVerb
);
635 ok(!bindinfo
.cbstgmedData
, "bindinfo.cbstgmedData = %d\n", bindinfo
.cbstgmedData
);
636 ok(bindinfo
.dwOptions
== (bind_to_object
? 0x100000 : 0), "bindinfo.dwOptions = %x\n", bindinfo
.dwOptions
);
637 ok(!bindinfo
.dwOptionsFlags
, "bindinfo.dwOptionsFlags = %d\n", bindinfo
.dwOptionsFlags
);
638 ok(!bindinfo
.dwCodePage
, "bindinfo.dwCodePage = %d\n", bindinfo
.dwCodePage
);
639 ok(!memcmp(&bindinfo
.securityAttributes
, &sa_zero
, sizeof(sa_zero
)), "wrong bindinfo.securityAttributes\n");
640 ok(IsEqualGUID(&bindinfo
.iid
, &IID_NULL
), "wrong bindinfo.iid\n");
641 ok(!bindinfo
.pUnk
, "bindinfo.pUnk = %p\n", bindinfo
.pUnk
);
642 ok(!bindinfo
.dwReserved
, "bindinfo.dwReserved = %d\n", bindinfo
.dwReserved
);
644 if(only_check_prot_args
)
647 switch(test_protocol
) {
649 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
650 BINDSTATUS_DIRECTBIND
, NULL
);
652 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
657 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
659 SET_EXPECT(OnProgress_SENDINGREQUEST
);
660 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
661 BINDSTATUS_SENDINGREQUEST
, emptyW
);
663 "ReportProgress(BINDSTATUS_SENDINGREQUEST) failed: %08x\n", hres
);
665 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
667 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
668 case WINETEST_SYNC_TEST
:
669 IInternetProtocolSink_AddRef(pOIProtSink
);
670 protocol_sink
= pOIProtSink
;
675 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) {
676 IServiceProvider
*service_provider
;
677 IHttpNegotiate
*http_negotiate
;
678 IHttpNegotiate2
*http_negotiate2
;
679 IHttpSecurity
*http_security
;
680 LPWSTR ua
= (LPWSTR
)0xdeadbeef, accept_mimes
[256];
681 LPWSTR additional_headers
= (LPWSTR
)0xdeadbeef;
683 DWORD fetched
= 256, size
= 100;
686 static const WCHAR wszMimes
[] = {'*','/','*',0};
688 SET_EXPECT(QueryService_IInternetBindInfo
);
689 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_USER_AGENT
,
691 CLEAR_CALLED(QueryService_IInternetBindInfo
); /* IE <8 */
693 ok(hres
== E_NOINTERFACE
,
694 "GetBindString(BINDSTRING_USER_AGETNT) failed: %08x\n", hres
);
695 ok(fetched
== 256, "fetched = %d, expected 254\n", fetched
);
696 ok(ua
== (LPWSTR
)0xdeadbeef, "ua = %p\n", ua
);
698 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
699 accept_mimes
, 256, &fetched
);
701 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
702 ok(fetched
== 1, "fetched = %d, expected 1\n", fetched
);
703 ok(!lstrcmpW(wszMimes
, accept_mimes
[0]), "unexpected mimes\n");
704 CoTaskMemFree(accept_mimes
[0]);
706 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
707 NULL
, 256, &fetched
);
708 ok(hres
== E_INVALIDARG
,
709 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
711 hres
= IInternetBindInfo_GetBindString(pOIBindInfo
, BINDSTRING_ACCEPT_MIMES
,
712 accept_mimes
, 256, NULL
);
713 ok(hres
== E_INVALIDARG
,
714 "GetBindString(BINDSTRING_ACCEPT_MIMES) failed: %08x\n", hres
);
716 hres
= IInternetBindInfo_QueryInterface(pOIBindInfo
, &IID_IServiceProvider
,
717 (void**)&service_provider
);
718 ok(hres
== S_OK
, "QueryInterface failed: %08x\n", hres
);
720 SET_EXPECT(QueryInterface_IHttpNegotiate
);
721 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
722 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
723 CLEAR_CALLED(QueryInterface_IHttpNegotiate
); /* IE <8 */
724 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
727 SET_EXPECT(BeginningTransaction
);
728 SET_EXPECT(QueryInterface_IHttpNegotiate
);
730 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate
, current_url
,
731 NULL
, 0, &additional_headers
);
733 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate
);
734 CHECK_CALLED(BeginningTransaction
);
736 IHttpNegotiate_Release(http_negotiate
);
737 ok(hres
== S_OK
, "BeginningTransction failed: %08x\n", hres
);
738 ok(additional_headers
== NULL
, "additional_headers=%p\n", additional_headers
);
740 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
741 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate2
,
742 &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
743 CLEAR_CALLED(QueryInterface_IHttpNegotiate2
); /* IE <8 */
744 ok(hres
== S_OK
, "QueryService failed: %08x\n", hres
);
748 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
749 SET_EXPECT(GetRootSecurityId
);
751 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, sec_id
, &size
, 0);
753 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2
);
754 CHECK_CALLED(GetRootSecurityId
);
756 IHttpNegotiate2_Release(http_negotiate2
);
757 ok(hres
== E_FAIL
, "GetRootSecurityId failed: %08x, expected E_FAIL\n", hres
);
758 ok(size
== (no_callback
? 512 : 13), "size=%d\n", size
);
761 SET_EXPECT(QueryService_IHttpSecurity
);
762 SET_EXPECT(QueryInterface_IHttpSecurity
);
764 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpSecurity
,
765 &IID_IHttpSecurity
, (void**)&http_security
);
766 ok(hres
== (no_callback
? E_NOINTERFACE
: S_OK
), "QueryService failed: 0x%08x\n", hres
);
768 CHECK_CALLED(QueryService_IHttpSecurity
);
769 CHECK_CALLED(QueryInterface_IHttpSecurity
);
772 IServiceProvider_Release(service_provider
);
774 IInternetProtocolSink_AddRef(pOIProtSink
);
775 protocol_sink
= pOIProtSink
;
780 memset(&data
, 0, sizeof(data
));
781 data
.grfFlags
= PI_FORCE_ASYNC
;
783 hres
= IInternetProtocolSink_Switch(pOIProtSink
, &data
);
784 ok(hres
== S_OK
, "Switch failed: %08x\n", hres
);
785 SET_EXPECT(Continue
);
786 SetEvent(complete_event2
);
789 CreateThread(NULL
, 0, thread_proc
, NULL
, 0, &tid
);
794 if(test_protocol
== FILE_TEST
) {
795 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
796 BINDSTATUS_CACHEFILENAMEAVAILABLE
, file_url
+7);
798 "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
801 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
803 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
804 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
,
805 BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, wszTextHtml
);
807 "ReportProgress(BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE) failed: %08x\n", hres
);
809 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
811 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
812 }else if(test_protocol
== WINETEST_SYNC_TEST
) {
813 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
814 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE
, wszTextHtml
);
816 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
817 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
819 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
821 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
824 if(test_protocol
== ABOUT_TEST
)
825 bscf
|= BSCF_DATAFULLYAVAILABLE
;
826 if(test_protocol
== ITS_TEST
)
827 bscf
= BSCF_FIRSTDATANOTIFICATION
|BSCF_DATAFULLYAVAILABLE
;
831 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
&& test_protocol
!= WINETEST_SYNC_TEST
)
832 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
833 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
834 if(test_protocol
== FILE_TEST
)
835 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
836 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
837 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
838 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
839 SET_EXPECT(CreateInstance
);
840 SET_EXPECT(PutProperty_MIMETYPEPROP
);
841 SET_EXPECT(PutProperty_CLASSIDPROP
);
843 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
844 SET_EXPECT(OnObjectAvailable
);
845 SET_EXPECT(Obj_OnStopBinding
);
847 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
848 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
849 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
850 if(test_protocol
== FILE_TEST
)
851 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
852 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
853 SET_EXPECT(LockRequest
);
855 SET_EXPECT(OnDataAvailable
);
856 if(test_protocol
!= WINETEST_SYNC_TEST
) /* Set in Read after ReportResult call */
857 SET_EXPECT(OnStopBinding
);
860 hres
= IInternetProtocolSink_ReportData(pOIProtSink
, bscf
, 13, 13);
861 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
865 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
)
866 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
867 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
868 if(test_protocol
== FILE_TEST
)
869 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
870 CHECK_CALLED(Obj_OnProgress_ENDDOWNLOADDATA
);
871 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
872 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
873 CHECK_CALLED(CreateInstance
);
874 CHECK_CALLED(PutProperty_MIMETYPEPROP
);
875 CHECK_CALLED_BROKEN(PutProperty_CLASSIDPROP
);
877 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
878 CHECK_CALLED(OnObjectAvailable
);
879 CHECK_CALLED(Obj_OnStopBinding
);
881 if(test_protocol
!= FILE_TEST
&& test_protocol
!= MK_TEST
&& test_protocol
!= WINETEST_SYNC_TEST
)
882 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
883 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
884 if(test_protocol
== FILE_TEST
)
885 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
886 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
887 CHECK_CALLED(LockRequest
);
889 CHECK_CALLED(OnDataAvailable
);
890 CHECK_CALLED(OnStopBinding
);
893 if(test_protocol
== ITS_TEST
) {
895 hres
= IInternetProtocolSink_ReportProgress(pOIProtSink
, BINDSTATUS_BEGINDOWNLOADDATA
, NULL
);
896 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_BEGINDOWNLOADDATA) failed: %08x\n", hres
);
898 }else if(!bind_to_object
&& test_protocol
== FILE_TEST
) {
900 hres
= IInternetProtocolSink_ReportData(pOIProtSink
, bscf
, 13, 13);
901 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
905 if(test_protocol
!= WINETEST_SYNC_TEST
) {
906 SET_EXPECT(Terminate
);
907 hres
= IInternetProtocolSink_ReportResult(pOIProtSink
, S_OK
, 0, NULL
);
908 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
909 CHECK_CALLED(Terminate
);
915 static HRESULT WINAPI
Protocol_Continue(IInternetProtocol
*iface
,
916 PROTOCOLDATA
*pProtocolData
)
921 CHECK_EXPECT(Continue
);
923 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
926 ok(reported_url
&& !lstrcmpW(reported_url
, current_url
), "wrong url %s\n", wine_dbgstr_w(reported_url
));
928 ok(pProtocolData
!= NULL
, "pProtocolData == NULL\n");
934 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
935 BINDSTATUS_SENDINGREQUEST
, NULL
);
936 ok(hres
== S_OK
, "ReportProgress failed: %08x\n", hres
);
938 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
939 BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
941 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
943 bscf
|= BSCF_FIRSTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
;
946 IServiceProvider
*service_provider
;
947 IHttpNegotiate
*http_negotiate
;
948 static const WCHAR header
[] = {'?',0};
950 hres
= IInternetProtocolSink_QueryInterface(protocol_sink
, &IID_IServiceProvider
,
951 (void**)&service_provider
);
952 ok(hres
== S_OK
, "Could not get IServiceProvicder\n");
954 hres
= IServiceProvider_QueryService(service_provider
, &IID_IHttpNegotiate
,
955 &IID_IHttpNegotiate
, (void**)&http_negotiate
);
956 ok(hres
== S_OK
, "Could not get IHttpNegotiate\n");
959 SET_EXPECT(QueryInterface_IHttpNegotiate
);
960 SET_EXPECT(OnResponse
);
962 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, header
, NULL
, NULL
);
964 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate
);
965 CHECK_CALLED(OnResponse
);
967 IHttpNegotiate_Release(http_negotiate
);
968 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
970 if(test_protocol
== HTTPS_TEST
|| test_redirect
) {
971 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
, BINDSTATUS_ACCEPTRANGES
, NULL
);
972 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_ACCEPTRANGES) failed: %08x\n", hres
);
975 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
976 BINDSTATUS_MIMETYPEAVAILABLE
, wszTextHtml
);
978 "ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE) failed: %08x\n", hres
);
980 hres
= IInternetProtocolSink_ReportProgress(protocol_sink
,
981 BINDSTATUS_CACHEFILENAMEAVAILABLE
, use_cache_file
? cache_file_name
: cache_fileW
);
982 ok(hres
== S_OK
, "ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE) failed: %08x\n", hres
);
984 bscf
|= BSCF_FIRSTDATANOTIFICATION
;
989 bscf
= BSCF_INTERMEDIATEDATANOTIFICATION
;
993 hres
= IInternetProtocolSink_ReportData(protocol_sink
, bscf
, 100, 400);
994 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
996 if(prot_state
!= 2 || !test_abort
)
1000 hres
= IInternetProtocolSink_ReportResult(protocol_sink
, S_OK
, 0, NULL
);
1001 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1002 SET_EXPECT(OnProgress_SENDINGREQUEST
);
1003 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
1004 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1005 SET_EXPECT(LockRequest
);
1006 SET_EXPECT(OnStopBinding
);
1009 if(bind_to_object
) {
1010 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
1011 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
1012 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
1013 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
1014 SET_EXPECT(CreateInstance
);
1015 SET_EXPECT(PutProperty_MIMETYPEPROP
);
1016 SET_EXPECT(PutProperty_CLASSIDPROP
);
1018 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
1019 SET_EXPECT(OnObjectAvailable
);
1020 SET_EXPECT(Obj_OnStopBinding
);
1021 }else if(!no_callback
) {
1022 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
1023 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1024 SET_EXPECT(LockRequest
);
1026 SET_EXPECT(LockRequest
);
1031 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
1034 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
1035 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
1038 if((!bind_to_object
|| prot_state
>= 2) && (!test_abort
|| prot_state
!= 2))
1039 SET_EXPECT(OnDataAvailable
);
1040 if(prot_state
== 3 || (test_abort
&& prot_state
== 2))
1041 SET_EXPECT(OnStopBinding
);
1046 static HRESULT WINAPI
Protocol_Abort(IInternetProtocol
*iface
, HRESULT hrReason
,
1051 CHECK_EXPECT(Abort
);
1053 ok(hrReason
== E_ABORT
, "hrReason = %08x\n", hrReason
);
1054 ok(!dwOptions
, "dwOptions = %x\n", dwOptions
);
1056 hres
= IInternetProtocolSink_ReportResult(protocol_sink
, E_ABORT
, ERROR_SUCCESS
, NULL
);
1057 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1062 static HRESULT WINAPI
Protocol_Terminate(IInternetProtocol
*iface
, DWORD dwOptions
)
1064 CHECK_EXPECT(Terminate
);
1066 ok(dwOptions
== 0, "dwOptions=%d, expected 0\n", dwOptions
);
1069 IInternetProtocolSink_Release(protocol_sink
);
1070 protocol_sink
= NULL
;
1074 SetEvent(complete_event
);
1078 static HRESULT WINAPI
Protocol_Suspend(IInternetProtocol
*iface
)
1080 ok(0, "unexpected call\n");
1084 static HRESULT WINAPI
Protocol_Resume(IInternetProtocol
*iface
)
1086 ok(0, "unexpected call\n");
1090 static HRESULT WINAPI
Protocol_Read(IInternetProtocol
*iface
, void *pv
,
1091 ULONG cb
, ULONG
*pcbRead
)
1095 static const char data
[] = "<HTML></HTML>";
1097 CHECK_EXPECT2(Read
);
1099 ok(pv
!= NULL
, "pv == NULL\n");
1100 ok(cb
!= 0, "cb == 0\n");
1101 ok(pcbRead
!= NULL
, "pcbRead == NULL\n");
1104 if(prot_state
++ > 1) {
1108 memset(pv
, '?', cb
);
1114 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) {
1115 static BOOL pending
= TRUE
;
1119 switch(prot_state
) {
1124 memset(pv
, '?', 10);
1125 if(prot_state
== 2 && no_callback
)
1126 SetEvent(complete_event
);
1129 memset(pv
, '?', cb
);
1139 hres
= IInternetProtocolSink_ReportData(protocol_sink
,
1140 BSCF_LASTDATANOTIFICATION
|BSCF_INTERMEDIATEDATANOTIFICATION
, 2000, 2000);
1141 ok(hres
== S_OK
, "ReportData failed: %08x\n", hres
);
1143 hres
= IInternetProtocolSink_ReportResult(protocol_sink
, S_OK
, 0, NULL
);
1144 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1158 if(test_protocol
== WINETEST_SYNC_TEST
) {
1159 hres
= IInternetProtocolSink_ReportResult(protocol_sink
, S_OK
, 0, NULL
);
1160 ok(hres
== S_OK
, "ReportResult failed: %08x\n", hres
);
1162 SET_EXPECT(OnStopBinding
);
1165 ok(*pcbRead
== 0, "*pcbRead=%d, expected 0\n", *pcbRead
);
1166 read
+= *pcbRead
= sizeof(data
)-1;
1167 memcpy(pv
, data
, sizeof(data
));
1171 static HRESULT WINAPI
Protocol_Seek(IInternetProtocol
*iface
,
1172 LARGE_INTEGER dlibMove
, DWORD dwOrigin
, ULARGE_INTEGER
*plibNewPosition
)
1174 ok(0, "unexpected call\n");
1178 static HRESULT WINAPI
Protocol_LockRequest(IInternetProtocol
*iface
, DWORD dwOptions
)
1180 CHECK_EXPECT(LockRequest
);
1182 SetEvent(complete_event
);
1186 static HRESULT WINAPI
Protocol_UnlockRequest(IInternetProtocol
*iface
)
1188 CHECK_EXPECT(UnlockRequest
);
1192 static const IInternetProtocolVtbl ProtocolVtbl
= {
1193 Protocol_QueryInterface
,
1204 Protocol_LockRequest
,
1205 Protocol_UnlockRequest
1208 static IInternetProtocol Protocol
= { &ProtocolVtbl
};
1210 static HRESULT WINAPI
HttpNegotiate_QueryInterface(IHttpNegotiate2
*iface
, REFIID riid
, void **ppv
)
1212 if(IsEqualGUID(&IID_IUnknown
, riid
)
1213 || IsEqualGUID(&IID_IHttpNegotiate
, riid
)
1214 || IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
1219 ok(0, "unexpected call\n");
1220 return E_NOINTERFACE
;
1223 static ULONG WINAPI
HttpNegotiate_AddRef(IHttpNegotiate2
*iface
)
1228 static ULONG WINAPI
HttpNegotiate_Release(IHttpNegotiate2
*iface
)
1233 static HRESULT WINAPI
HttpNegotiate_BeginningTransaction(IHttpNegotiate2
*iface
, LPCWSTR szURL
,
1234 LPCWSTR szHeaders
, DWORD dwReserved
, LPWSTR
*pszAdditionalHeaders
)
1236 if(onsecurityproblem_hres
== S_OK
)
1237 CHECK_EXPECT2(BeginningTransaction
);
1239 CHECK_EXPECT(BeginningTransaction
);
1241 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1243 ok(!lstrcmpW(szURL
, current_url
), "szURL != current_url\n");
1244 ok(!dwReserved
, "dwReserved=%d, expected 0\n", dwReserved
);
1245 ok(pszAdditionalHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
1246 if(pszAdditionalHeaders
)
1247 ok(*pszAdditionalHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
1252 static HRESULT WINAPI
HttpNegotiate_OnResponse(IHttpNegotiate2
*iface
, DWORD dwResponseCode
,
1253 LPCWSTR szResponseHeaders
, LPCWSTR szRequestHeaders
, LPWSTR
*pszAdditionalRequestHeaders
)
1255 CHECK_EXPECT(OnResponse
);
1257 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1259 ok(dwResponseCode
== 200, "dwResponseCode=%d, expected 200\n", dwResponseCode
);
1260 ok(szResponseHeaders
!= NULL
, "szResponseHeaders == NULL\n");
1261 ok(szRequestHeaders
== NULL
, "szRequestHeaders != NULL\n");
1262 /* Note: in protocol.c tests, OnResponse pszAdditionalRequestHeaders _is_ NULL */
1263 ok(pszAdditionalRequestHeaders
!= NULL
, "pszAdditionalHeaders == NULL\n");
1264 if(pszAdditionalRequestHeaders
)
1265 ok(*pszAdditionalRequestHeaders
== NULL
, "*pszAdditionalHeaders != NULL\n");
1270 static HRESULT WINAPI
HttpNegotiate_GetRootSecurityId(IHttpNegotiate2
*iface
,
1271 BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
1273 static const BYTE sec_id
[] = {'h','t','t','p',':','t','e','s','t',1,0,0,0};
1275 CHECK_EXPECT(GetRootSecurityId
);
1277 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1279 ok(!dwReserved
, "dwReserved=%ld, expected 0\n", dwReserved
);
1280 ok(pbSecurityId
!= NULL
, "pbSecurityId == NULL\n");
1281 ok(pcbSecurityId
!= NULL
, "pcbSecurityId == NULL\n");
1283 if(pbSecurityId
== (void*)0xdeadbeef)
1287 ok(*pcbSecurityId
== 512, "*pcbSecurityId=%d, expected 512\n", *pcbSecurityId
);
1288 *pcbSecurityId
= sizeof(sec_id
);
1292 memcpy(pbSecurityId
, sec_id
, sizeof(sec_id
));
1297 static IHttpNegotiate2Vtbl HttpNegotiateVtbl
= {
1298 HttpNegotiate_QueryInterface
,
1299 HttpNegotiate_AddRef
,
1300 HttpNegotiate_Release
,
1301 HttpNegotiate_BeginningTransaction
,
1302 HttpNegotiate_OnResponse
,
1303 HttpNegotiate_GetRootSecurityId
1306 static IHttpNegotiate2 HttpNegotiate
= { &HttpNegotiateVtbl
};
1308 static HRESULT WINAPI
HttpSecurity_QueryInterface(IHttpSecurity
*iface
, REFIID riid
, void **ppv
)
1310 ok(0, "Unexpected call\n");
1312 if(IsEqualGUID(&IID_IHttpSecurity
, riid
) ||
1313 IsEqualGUID(&IID_IWindowForBindingUI
, riid
) ||
1314 IsEqualGUID(&IID_IUnknown
, riid
))
1320 ok(0, "Unexpected interface requested.\n");
1322 return E_NOINTERFACE
;
1325 static ULONG WINAPI
HttpSecurity_AddRef(IHttpSecurity
*iface
)
1330 static ULONG WINAPI
HttpSecurity_Release(IHttpSecurity
*iface
)
1335 static HRESULT WINAPI
HttpSecurity_GetWindow(IHttpSecurity
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
1337 if(IsEqualGUID(rguidReason
, &IID_IHttpSecurity
))
1338 CHECK_EXPECT(GetWindow_IHttpSecurity
);
1339 else if(IsEqualGUID(rguidReason
, &IID_IWindowForBindingUI
))
1340 CHECK_EXPECT2(GetWindow_IWindowForBindingUI
);
1341 else if(IsEqualGUID(rguidReason
, &IID_ICodeInstall
))
1342 CHECK_EXPECT(GetWindow_ICodeInstall
);
1344 ok(0, "Unexpected rguidReason: %s\n", wine_dbgstr_guid(rguidReason
));
1350 static HRESULT WINAPI
HttpSecurity_OnSecurityProblem(IHttpSecurity
*iface
, DWORD dwProblem
)
1352 CHECK_EXPECT(OnSecurityProblem
);
1353 if(!security_problem
) {
1354 ok(dwProblem
== ERROR_INTERNET_SEC_CERT_CN_INVALID
||
1355 broken(dwProblem
== ERROR_INTERNET_SEC_CERT_ERRORS
) /* Some versions of IE6 */,
1356 "Got problem: %d\n", dwProblem
);
1357 security_problem
= dwProblem
;
1359 if(dwProblem
== ERROR_INTERNET_SEC_CERT_ERRORS
)
1360 binding_hres
= INET_E_SECURITY_PROBLEM
;
1362 ok(dwProblem
== security_problem
, "Got problem: %d\n", dwProblem
);
1364 return onsecurityproblem_hres
;
1367 static const IHttpSecurityVtbl HttpSecurityVtbl
= {
1368 HttpSecurity_QueryInterface
,
1369 HttpSecurity_AddRef
,
1370 HttpSecurity_Release
,
1371 HttpSecurity_GetWindow
,
1372 HttpSecurity_OnSecurityProblem
1375 static IHttpSecurity HttpSecurity
= { &HttpSecurityVtbl
};
1377 static HRESULT WINAPI
ServiceProvider_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
1379 ok(0, "unexpected call\n");
1380 return E_NOINTERFACE
;
1383 static ULONG WINAPI
ServiceProvider_AddRef(IServiceProvider
*iface
)
1388 static ULONG WINAPI
ServiceProvider_Release(IServiceProvider
*iface
)
1393 static HRESULT WINAPI
ServiceProvider_QueryService(IServiceProvider
*iface
,
1394 REFGUID guidService
, REFIID riid
, void **ppv
)
1396 if (winetest_debug
> 1)
1397 trace("IServiceProvider::QueryService(service %s, iid %s)\n",
1398 debugstr_guid(guidService
), debugstr_guid(riid
));
1400 if(IsEqualGUID(&IID_IAuthenticate
, guidService
)) {
1401 CHECK_EXPECT(QueryService_IAuthenticate
);
1405 if(IsEqualGUID(&IID_IInternetProtocol
, guidService
)) {
1406 CHECK_EXPECT2(QueryService_IInternetProtocol
);
1410 if(IsEqualGUID(&IID_IInternetBindInfo
, guidService
)) {
1411 CHECK_EXPECT(QueryService_IInternetBindInfo
);
1415 if(IsEqualGUID(&IID_IWindowForBindingUI
, guidService
)) {
1416 CHECK_EXPECT2(QueryService_IWindowForBindingUI
);
1417 *ppv
= &HttpSecurity
;
1421 if(IsEqualGUID(&IID_IHttpSecurity
, guidService
)) {
1422 CHECK_EXPECT(QueryService_IHttpSecurity
);
1423 *ppv
= &HttpSecurity
;
1428 return E_NOINTERFACE
;
1431 static IServiceProviderVtbl ServiceProviderVtbl
= {
1432 ServiceProvider_QueryInterface
,
1433 ServiceProvider_AddRef
,
1434 ServiceProvider_Release
,
1435 ServiceProvider_QueryService
1438 static IServiceProvider ServiceProvider
= { &ServiceProviderVtbl
};
1440 static IBindStatusCallbackEx objbsc
;
1442 static void test_WinInetHttpInfo(IWinInetHttpInfo
*http_info
, DWORD progress
)
1445 HRESULT hres
, expect
;
1447 /* QueryInfo changes its behavior during this request */
1448 if(progress
== BINDSTATUS_SENDINGREQUEST
)
1451 if(test_protocol
==FTP_TEST
&& download_state
==BEFORE_DOWNLOAD
1452 && progress
!=BINDSTATUS_MIMETYPEAVAILABLE
)
1454 else if(test_protocol
== FTP_TEST
)
1459 size
= sizeof(DWORD
);
1460 hres
= IWinInetHttpInfo_QueryInfo(http_info
, HTTP_QUERY_STATUS_CODE
|HTTP_QUERY_FLAG_NUMBER
,
1461 &status
, &size
, NULL
, NULL
);
1462 ok(hres
== expect
|| ((progress
== BINDSTATUS_COOKIE_SENT
|| progress
== BINDSTATUS_PROXYDETECTING
) && hres
== S_FALSE
),
1463 "progress %u: hres = %x, expected %x\n", progress
, hres
, expect
);
1465 if(download_state
== BEFORE_DOWNLOAD
&& progress
!= BINDSTATUS_MIMETYPEAVAILABLE
&& progress
!= BINDSTATUS_DECODING
)
1466 ok(status
== 0, "progress %u: status = %d\n", progress
, status
);
1468 ok(status
== HTTP_STATUS_OK
, "progress %u: status = %d\n", progress
, status
);
1469 ok(size
== sizeof(DWORD
), "size = %d\n", size
);
1472 size
= sizeof(DWORD
);
1473 hres
= IWinInetHttpInfo_QueryOption(http_info
, INTERNET_OPTION_HANDLE_TYPE
, &status
, &size
);
1474 if(test_protocol
== FTP_TEST
) {
1475 if(download_state
==BEFORE_DOWNLOAD
&& progress
!=BINDSTATUS_MIMETYPEAVAILABLE
)
1476 ok(hres
== E_FAIL
, "hres = %x\n", hres
);
1478 ok(hres
== S_OK
, "hres = %x\n", hres
);
1481 ok(status
== INTERNET_HANDLE_TYPE_FTP_FILE
, "status = %d\n", status
);
1483 ok(hres
== S_OK
, "hres = %x\n", hres
);
1484 ok(status
== INTERNET_HANDLE_TYPE_HTTP_REQUEST
, "status = %d\n", status
);
1488 static HRESULT WINAPI
statusclb_QueryInterface(IBindStatusCallbackEx
*iface
, REFIID riid
, void **ppv
)
1490 if (winetest_debug
> 1) trace("IBindStatusCallback::QueryInterface(%s)\n", debugstr_guid(riid
));
1492 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1494 if(IsEqualGUID(&IID_IInternetProtocol
, riid
)) {
1495 CHECK_EXPECT2(QueryInterface_IInternetProtocol
);
1496 if(emulate_protocol
) {
1500 return E_NOINTERFACE
;
1502 }else if (IsEqualGUID(&IID_IServiceProvider
, riid
)) {
1503 CHECK_EXPECT2(QueryInterface_IServiceProvider
);
1504 *ppv
= &ServiceProvider
;
1506 }else if (IsEqualGUID(&IID_IHttpNegotiate
, riid
)) {
1507 CHECK_EXPECT2(QueryInterface_IHttpNegotiate
);
1508 *ppv
= &HttpNegotiate
;
1510 }else if (IsEqualGUID(&IID_IHttpNegotiate2
, riid
)) {
1511 CHECK_EXPECT(QueryInterface_IHttpNegotiate2
);
1512 *ppv
= &HttpNegotiate
;
1514 }else if (IsEqualGUID(&IID_IAuthenticate
, riid
)) {
1515 CHECK_EXPECT(QueryInterface_IAuthenticate
);
1516 return E_NOINTERFACE
;
1517 }else if(IsEqualGUID(&IID_IBindStatusCallback
, riid
)) {
1519 CHECK_EXPECT2(QueryInterface_IBindStatusCallback
);
1522 }else if(IsEqualGUID(&IID_IBindStatusCallbackHolder
, riid
)) {
1523 CHECK_EXPECT2(QueryInterface_IBindStatusCallbackHolder
);
1524 return E_NOINTERFACE
;
1525 }else if(IsEqualGUID(&IID_IBindStatusCallbackEx
, riid
)) {
1526 CHECK_EXPECT(QueryInterface_IBindStatusCallbackEx
);
1528 return E_NOINTERFACE
;
1531 }else if(IsEqualGUID(&IID_IInternetBindInfo
, riid
)) {
1533 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
1534 CHECK_EXPECT2(QueryInterface_IWindowForBindingUI
);
1535 return E_NOINTERFACE
;
1536 }else if(IsEqualGUID(&IID_IHttpSecurity
, riid
)) {
1537 CHECK_EXPECT2(QueryInterface_IHttpSecurity
);
1538 return E_NOINTERFACE
;
1541 return E_NOINTERFACE
;
1544 static ULONG WINAPI
statusclb_AddRef(IBindStatusCallbackEx
*iface
)
1549 static ULONG WINAPI
statusclb_Release(IBindStatusCallbackEx
*iface
)
1554 static HRESULT WINAPI
statusclb_OnStartBinding(IBindStatusCallbackEx
*iface
, DWORD dwReserved
,
1557 IWinInetHttpInfo
*http_info
;
1564 if(iface
== &objbsc
)
1565 CHECK_EXPECT(Obj_OnStartBinding
);
1567 CHECK_EXPECT(OnStartBinding
);
1569 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1571 ok(pib
!= NULL
, "pib should not be NULL\n");
1572 ok(dwReserved
== 0xff, "dwReserved=%x\n", dwReserved
);
1574 if(pib
== (void*)0xdeadbeef)
1577 current_binding
= pib
;
1579 hres
= IBinding_QueryInterface(pib
, &IID_IMoniker
, (void**)&mon
);
1580 ok(hres
== E_NOINTERFACE
, "IBinding should not have IMoniker interface\n");
1582 IMoniker_Release(mon
);
1584 hres
= IBinding_QueryInterface(pib
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
1585 ok(hres
== E_NOINTERFACE
, "Could not get IID_IWinInetHttpInfo: %08x\n", hres
);
1587 if(0) { /* crashes with native urlmon */
1588 hres
= IBinding_GetBindResult(pib
, NULL
, &res
, &res_str
, NULL
);
1589 ok(hres
== E_INVALIDARG
, "GetBindResult failed: %08x\n", hres
);
1591 hres
= IBinding_GetBindResult(pib
, &clsid
, NULL
, &res_str
, NULL
);
1592 ok(hres
== E_INVALIDARG
, "GetBindResult failed: %08x\n", hres
);
1593 hres
= IBinding_GetBindResult(pib
, &clsid
, &res
, NULL
, NULL
);
1594 ok(hres
== E_INVALIDARG
, "GetBindResult failed: %08x\n", hres
);
1595 hres
= IBinding_GetBindResult(pib
, &clsid
, &res
, &res_str
, (void*)0xdeadbeef);
1596 ok(hres
== E_INVALIDARG
, "GetBindResult failed: %08x\n", hres
);
1598 hres
= IBinding_GetBindResult(pib
, &clsid
, &res
, &res_str
, NULL
);
1599 ok(hres
== S_OK
, "GetBindResult failed: %08x, expected S_OK\n", hres
);
1600 ok(IsEqualCLSID(&clsid
, &CLSID_NULL
), "incorrect clsid: %s\n", wine_dbgstr_guid(&clsid
));
1601 ok(!res
, "incorrect res: %x\n", res
);
1602 ok(!res_str
, "incorrect res_str: %s\n", wine_dbgstr_w(res_str
));
1605 binding_hres
= abort_hres
;
1612 static HRESULT WINAPI
statusclb_GetPriority(IBindStatusCallbackEx
*iface
, LONG
*pnPriority
)
1614 ok(0, "unexpected call\n");
1618 static HRESULT WINAPI
statusclb_OnLowResource(IBindStatusCallbackEx
*iface
, DWORD reserved
)
1620 ok(0, "unexpected call\n");
1624 static HRESULT WINAPI
statusclb_OnProgress(IBindStatusCallbackEx
*iface
, ULONG ulProgress
,
1625 ULONG ulProgressMax
, ULONG ulStatusCode
, LPCWSTR szStatusText
)
1627 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1629 if (winetest_debug
> 1)
1630 trace("IBindStatusCallbackEx::OnProgress(progress %u/%u, code %u, text %s)\n",
1631 ulProgress
, ulProgressMax
, ulStatusCode
, debugstr_w(szStatusText
));
1633 switch(ulStatusCode
) {
1634 case BINDSTATUS_FINDINGRESOURCE
:
1635 if(iface
== &objbsc
)
1636 CHECK_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
1637 else if(test_protocol
== FTP_TEST
)
1638 todo_wine
CHECK_EXPECT(OnProgress_FINDINGRESOURCE
);
1639 else if(test_protocol
== HTTPS_TEST
&& !bindtest_flags
)
1640 todo_wine
CHECK_EXPECT(OnProgress_FINDINGRESOURCE
);
1642 CHECK_EXPECT(OnProgress_FINDINGRESOURCE
);
1643 if(emulate_protocol
&& (test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
))
1644 SetEvent(complete_event
);
1646 case BINDSTATUS_CONNECTING
:
1647 if(iface
== &objbsc
)
1648 CHECK_EXPECT(Obj_OnProgress_CONNECTING
);
1649 else if(test_protocol
== FTP_TEST
)
1650 todo_wine
CHECK_EXPECT(OnProgress_CONNECTING
);
1651 else if(onsecurityproblem_hres
== S_OK
)
1652 CHECK_EXPECT2(OnProgress_CONNECTING
);
1654 CHECK_EXPECT(OnProgress_CONNECTING
);
1655 if(emulate_protocol
&& (test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
))
1656 SetEvent(complete_event
);
1658 case BINDSTATUS_REDIRECTING
:
1659 if(iface
== &objbsc
)
1660 CHECK_EXPECT(Obj_OnProgress_REDIRECTING
);
1662 CHECK_EXPECT(OnProgress_REDIRECTING
);
1663 ok(!lstrcmpW(szStatusText
, winetest_data_urlW
), "unexpected status text %s\n",
1664 wine_dbgstr_w(szStatusText
));
1665 if(emulate_protocol
&& (test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
)
1666 && (!bind_to_object
|| iface
== &objbsc
))
1667 SetEvent(complete_event
);
1669 case BINDSTATUS_SENDINGREQUEST
:
1670 if(iface
== &objbsc
)
1671 CHECK_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
1672 else if(test_protocol
== FTP_TEST
)
1673 CHECK_EXPECT2(OnProgress_SENDINGREQUEST
);
1675 CHECK_EXPECT(OnProgress_SENDINGREQUEST
);
1676 if(emulate_protocol
&& (test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
))
1677 SetEvent(complete_event
);
1679 if(abort_progress
) {
1681 binding_hres
= E_ABORT
;
1686 case BINDSTATUS_MIMETYPEAVAILABLE
:
1687 if(iface
== &objbsc
)
1688 CHECK_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
1690 CHECK_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
1692 ok(download_state
== BEFORE_DOWNLOAD
, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1694 WideCharToMultiByte(CP_ACP
, 0, szStatusText
, -1, mime_type
, sizeof(mime_type
)-1, NULL
, NULL
);
1696 case BINDSTATUS_BEGINDOWNLOADDATA
:
1697 if(iface
== &objbsc
)
1698 CHECK_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
1700 CHECK_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
1701 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1706 ok(!lstrcmpW(szStatusText
, current_url
), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText
));
1710 ok(download_state
== BEFORE_DOWNLOAD
, "Download state was %d, expected BEFORE_DOWNLOAD\n",
1712 download_state
= DOWNLOADING
;
1714 case BINDSTATUS_DOWNLOADINGDATA
:
1715 CHECK_EXPECT2(OnProgress_DOWNLOADINGDATA
);
1716 ok(iface
!= &objbsc
, "unexpected call\n");
1717 ok(download_state
== DOWNLOADING
, "Download state was %d, expected DOWNLOADING\n",
1723 hres
= IBinding_Abort(current_binding
);
1724 ok(hres
== S_OK
, "Abort failed: %08x\n", hres
);
1725 CHECK_CALLED(Abort
);
1727 hres
= IBinding_Abort(current_binding
);
1728 ok(hres
== E_FAIL
, "Abort failed: %08x\n", hres
);
1730 binding_hres
= E_ABORT
;
1733 case BINDSTATUS_ENDDOWNLOADDATA
:
1734 if(iface
== &objbsc
)
1735 CHECK_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
1737 CHECK_EXPECT(OnProgress_ENDDOWNLOADDATA
);
1738 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1743 ok(!lstrcmpW(szStatusText
, current_url
), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText
));
1746 ok(download_state
== DOWNLOADING
, "Download state was %d, expected DOWNLOADING\n",
1748 download_state
= END_DOWNLOAD
;
1750 case BINDSTATUS_CACHEFILENAMEAVAILABLE
:
1751 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
&& test_protocol
!= WINETEST_TEST
) {
1752 if(iface
== &objbsc
)
1753 CHECK_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
1755 CHECK_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
1757 CLEAR_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
1758 CLEAR_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
1761 ok(szStatusText
!= NULL
, "szStatusText == NULL\n");
1762 if(szStatusText
&& test_protocol
== FILE_TEST
)
1763 ok(!lstrcmpW(file_url
+7, szStatusText
), "wrong szStatusText %s\n", wine_dbgstr_w(szStatusText
));
1765 case BINDSTATUS_CLASSIDAVAILABLE
:
1769 if(iface
!= &objbsc
)
1770 ok(0, "unexpected call\n");
1772 CHECK_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
1773 hr
= CLSIDFromString((LPCOLESTR
)szStatusText
, &clsid
);
1774 ok(hr
== S_OK
, "CLSIDFromString failed with error 0x%08x\n", hr
);
1775 ok(IsEqualCLSID(&clsid
, &CLSID_HTMLDocument
),
1776 "Expected clsid to be CLSID_HTMLDocument instead of %s\n", wine_dbgstr_guid(&clsid
));
1779 case BINDSTATUS_BEGINSYNCOPERATION
:
1780 CHECK_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
1781 if(iface
!= &objbsc
)
1782 ok(0, "unexpected call\n");
1783 ok(szStatusText
== NULL
, "Expected szStatusText to be NULL\n");
1785 case BINDSTATUS_ENDSYNCOPERATION
:
1786 CHECK_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
1787 if(iface
!= &objbsc
)
1788 ok(0, "unexpected call\n");
1789 ok(szStatusText
== NULL
, "Expected szStatusText to be NULL\n");
1791 case BINDSTATUS_PROXYDETECTING
:
1792 case BINDSTATUS_COOKIE_SENT
:
1793 case BINDSTATUS_DECODING
:
1796 ok(0, "unexpected code %d\n", ulStatusCode
);
1799 if(current_binding
) {
1800 IWinInetHttpInfo
*http_info
;
1803 hres
= IBinding_QueryInterface(current_binding
, &IID_IWinInetHttpInfo
, (void**)&http_info
);
1804 if(!emulate_protocol
&& test_protocol
!= FILE_TEST
&& is_urlmon_protocol(test_protocol
)) {
1805 ok(hres
== S_OK
, "Could not get IWinInetHttpInfo iface: %08x\n", hres
);
1806 test_WinInetHttpInfo(http_info
, ulStatusCode
);
1808 ok(hres
== E_NOINTERFACE
,
1809 "QueryInterface(IID_IWinInetHttpInfo) returned: %08x, expected E_NOINTERFACE\n", hres
);
1811 IWinInetHttpInfo_Release(http_info
);
1817 static HRESULT WINAPI
statusclb_OnStopBinding(IBindStatusCallbackEx
*iface
, HRESULT hresult
, LPCWSTR szError
)
1819 if(iface
== &objbsc
) {
1820 CHECK_EXPECT(Obj_OnStopBinding
);
1821 stopped_obj_binding
= TRUE
;
1823 CHECK_EXPECT(OnStopBinding
);
1824 stopped_binding
= TRUE
;
1827 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1829 if(only_check_prot_args
) {
1830 todo_wine
ok(hresult
== S_OK
, "Got %08x\n", hresult
);
1834 /* ignore DNS failure */
1835 if (hresult
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
1839 if(!abort_progress
&& !abort_start
)
1840 ok(SUCCEEDED(hresult
), "binding failed: %08x\n", hresult
);
1841 else if(abort_start
&& abort_hres
== E_NOTIMPL
)
1842 todo_wine
ok(hresult
== S_FALSE
, "binding failed: %08x, expected S_FALSE\n", hresult
);
1844 ok(hresult
== E_ABORT
, "binding failed: %08x, expected E_ABORT\n", hresult
);
1846 ok(hresult
== binding_hres
, "binding failed: %08x, expected %08x\n", hresult
, binding_hres
);
1847 ok(szError
== NULL
, "szError should be NULL\n");
1849 if(current_binding
) {
1855 hres
= IBinding_GetBindResult(current_binding
, &clsid
, &res
, &res_str
, NULL
);
1856 ok(hres
== S_OK
, "GetBindResult failed: %08x, expected S_OK\n", hres
);
1857 ok(res
== hresult
, "res = %08x, expected %08x\n", res
, binding_hres
);
1858 ok(!res_str
, "incorrect res_str = %s\n", wine_dbgstr_w(res_str
));
1860 if(hresult
==S_OK
|| (abort_start
&& hresult
!=S_FALSE
) || hresult
== REGDB_E_CLASSNOTREG
) {
1861 ok(IsEqualCLSID(&clsid
, &CLSID_NULL
),
1862 "incorrect protocol CLSID: %s, expected CLSID_NULL\n",
1863 wine_dbgstr_guid(&clsid
));
1864 }else if(emulate_protocol
) {
1865 todo_wine
ok(IsEqualCLSID(&clsid
, &CLSID_FtpProtocol
),
1866 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n",
1867 wine_dbgstr_guid(&clsid
));
1868 }else if(test_protocol
== FTP_TEST
) {
1869 ok(IsEqualCLSID(&clsid
, &CLSID_FtpProtocol
),
1870 "incorrect protocol CLSID: %s, expected CLSID_FtpProtocol\n",
1871 wine_dbgstr_guid(&clsid
));
1872 }else if(test_protocol
== FILE_TEST
) {
1873 ok(IsEqualCLSID(&clsid
, &CLSID_FileProtocol
),
1874 "incorrect protocol CLSID: %s, expected CLSID_FileProtocol\n",
1875 wine_dbgstr_guid(&clsid
));
1876 }else if(test_protocol
== HTTP_TEST
) {
1877 ok(IsEqualCLSID(&clsid
, &CLSID_HttpProtocol
),
1878 "incorrect protocol CLSID: %s, expected CLSID_HttpProtocol\n",
1879 wine_dbgstr_guid(&clsid
));
1880 }else if(test_protocol
== HTTPS_TEST
) {
1881 ok(IsEqualCLSID(&clsid
, &CLSID_HttpSProtocol
),
1882 "incorrect protocol CLSID: %s, expected CLSID_HttpSProtocol\n",
1883 wine_dbgstr_guid(&clsid
));
1884 }else if(test_protocol
== ABOUT_TEST
) {
1885 ok(IsEqualCLSID(&clsid
, &CLSID_AboutProtocol
),
1886 "incorrect protocol CLSID: %s, expected CLSID_AboutProtocol\n",
1887 wine_dbgstr_guid(&clsid
));
1889 ok(0, "unexpected (%d)\n", test_protocol
);
1893 if((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) && emulate_protocol
) {
1894 SetEvent(complete_event
);
1895 if(iface
!= &objbsc
)
1896 ok( WaitForSingleObject(complete_event2
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
1899 if(test_protocol
== HTTP_TEST
&& !emulate_protocol
&& http_cache_file
[0]) {
1900 HANDLE file
= CreateFileW(http_cache_file
, DELETE
, FILE_SHARE_READ
| FILE_SHARE_WRITE
| FILE_SHARE_DELETE
,
1901 NULL
, OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
1902 ok(file
== INVALID_HANDLE_VALUE
, "expected INVALID_HANDLE_VALUE, got %p\n", file
);
1903 ok(GetLastError() == ERROR_SHARING_VIOLATION
, "expected ERROR_SHARING_VIOLATION, got %u\n", GetLastError());
1904 http_cache_file
[0] = 0;
1910 static HRESULT WINAPI
statusclb_GetBindInfo(IBindStatusCallbackEx
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
)
1914 if(iface
== &objbsc
)
1915 CHECK_EXPECT(Obj_GetBindInfo
);
1917 CHECK_EXPECT(GetBindInfo
);
1919 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1922 cbSize
= pbindinfo
->cbSize
;
1923 memset(pbindinfo
, 0, cbSize
);
1924 pbindinfo
->cbSize
= cbSize
;
1929 static void test_stream_seek(IStream
*stream
)
1931 ULARGE_INTEGER new_pos
;
1936 new_pos
.QuadPart
= 0xdeadbeef;
1937 hres
= IStream_Seek(stream
, pos
, STREAM_SEEK_SET
, &new_pos
);
1938 ok(hres
== S_OK
, "Seek failed: %08x\n", hres
);
1939 ok(!new_pos
.QuadPart
, "new_pos.QuadPart != 0\n");
1942 new_pos
.QuadPart
= 0xdeadbeef;
1943 hres
= IStream_Seek(stream
, pos
, STREAM_SEEK_END
, &new_pos
);
1944 ok(hres
== S_OK
, "Seek failed: %08x\n", hres
);
1945 ok(new_pos
.QuadPart
, "new_pos.QuadPart = 0\n");
1948 new_pos
.QuadPart
= 0xdeadbeef;
1949 hres
= IStream_Seek(stream
, pos
, 100, &new_pos
);
1950 ok(hres
== E_FAIL
, "Seek failed: %08x\n", hres
);
1951 ok(new_pos
.QuadPart
== 0xdeadbeef, "unexpected new_pos.QuadPart\n");
1954 static HRESULT WINAPI
statusclb_OnDataAvailable(IBindStatusCallbackEx
*iface
, DWORD grfBSCF
,
1955 DWORD dwSize
, FORMATETC
* pformatetc
, STGMEDIUM
* pstgmed
)
1962 if(iface
== &objbsc
)
1963 ok(0, "unexpected call\n");
1965 CHECK_EXPECT2(OnDataAvailable
);
1967 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
1969 ok(download_state
== DOWNLOADING
|| download_state
== END_DOWNLOAD
,
1970 "Download state was %d, expected DOWNLOADING or END_DOWNLOAD\n",
1972 data_available
= TRUE
;
1974 if(bind_to_object
&& !is_async_prot
)
1975 ok(grfBSCF
== (BSCF_FIRSTDATANOTIFICATION
|BSCF_LASTDATANOTIFICATION
), "grfBSCF = %x\n", grfBSCF
);
1977 ok(pformatetc
!= NULL
, "pformatetc == NULL\n");
1982 ret
= GetClipboardFormatNameA(pformatetc
->cfFormat
, clipfmt
, sizeof(clipfmt
)-1);
1983 ok(ret
, "GetClipboardFormatName failed, error %d\n", GetLastError());
1984 ok(!strcmp(clipfmt
, mime_type
), "clipformat %x != mime_type, \"%s\" != \"%s\"\n",
1985 pformatetc
->cfFormat
, clipfmt
, mime_type
);
1987 ok(pformatetc
->cfFormat
== 0, "clipformat=%x\n", pformatetc
->cfFormat
);
1989 ok(pformatetc
->ptd
== NULL
, "ptd = %p\n", pformatetc
->ptd
);
1990 ok(pformatetc
->dwAspect
== 1, "dwAspect=%u\n", pformatetc
->dwAspect
);
1991 ok(pformatetc
->lindex
== -1, "lindex=%d\n", pformatetc
->lindex
);
1992 ok(pformatetc
->tymed
== tymed
, "tymed=%u, expected %u\n", pformatetc
->tymed
, tymed
);
1995 ok(pstgmed
!= NULL
, "stgmeg == NULL\n");
1996 ok(pstgmed
->tymed
== tymed
, "tymed=%u, expected %u\n", pstgmed
->tymed
, tymed
);
1997 ok(pstgmed
->pUnkForRelease
!= NULL
, "pUnkForRelease == NULL\n");
1999 switch(pstgmed
->tymed
) {
2000 case TYMED_ISTREAM
: {
2001 IStream
*stream
= U(*pstgmed
).pstm
;
2003 ok(stream
!= NULL
, "U(*pstgmed).pstm == NULL\n");
2005 if(grfBSCF
& BSCF_FIRSTDATANOTIFICATION
) {
2008 hres
= IStream_Write(stream
, buf
, 10, NULL
);
2009 ok(hres
== STG_E_ACCESSDENIED
,
2010 "Write failed: %08x, expected STG_E_ACCESSDENIED\n", hres
);
2012 hres
= IStream_Commit(stream
, 0);
2013 ok(hres
== E_NOTIMPL
, "Commit failed: %08x, expected E_NOTIMPL\n", hres
);
2015 hres
= IStream_Revert(stream
);
2016 ok(hres
== E_NOTIMPL
, "Revert failed: %08x, expected E_NOTIMPL\n", hres
);
2018 hres
= IStream_Stat(stream
, NULL
, STATFLAG_NONAME
);
2019 ok(hres
== E_FAIL
, "hres = %x\n", hres
);
2020 if(use_cache_file
&& emulate_protocol
) {
2021 hres
= IStream_Stat(stream
, &stat
, STATFLAG_DEFAULT
);
2022 ok(hres
== S_OK
, "hres = %x\n", hres
);
2023 ok(!lstrcmpW(stat
.pwcsName
, cache_file_name
),
2024 "stat.pwcsName = %s, cache_file_name = %s\n",
2025 wine_dbgstr_w(stat
.pwcsName
), wine_dbgstr_w(cache_file_name
));
2026 CoTaskMemFree(stat
.pwcsName
);
2027 ok(U(stat
.cbSize
).LowPart
== (bindf
&BINDF_ASYNCHRONOUS
?0:6500),
2028 "stat.cbSize.LowPart = %u\n", U(stat
.cbSize
).LowPart
);
2030 hres
= IStream_Stat(stream
, &stat
, STATFLAG_NONAME
);
2031 ok(hres
== S_OK
, "hres = %x\n", hres
);
2032 ok(!stat
.pwcsName
|| broken(stat
.pwcsName
!=NULL
),
2033 "stat.pwcsName = %s\n", wine_dbgstr_w(stat
.pwcsName
));
2035 ok(stat
.type
== STGTY_STREAM
, "stat.type = %x\n", stat
.type
);
2036 ok(U(stat
.cbSize
).HighPart
== 0, "stat.cbSize.HighPart != 0\n");
2037 ok(stat
.grfMode
== (U(stat
.cbSize
).LowPart
?GENERIC_READ
:0), "stat.grfMode = %x\n", stat
.grfMode
);
2038 ok(stat
.grfLocksSupported
== 0, "stat.grfLocksSupported = %x\n", stat
.grfLocksSupported
);
2039 ok(stat
.grfStateBits
== 0, "stat.grfStateBits = %x\n", stat
.grfStateBits
);
2040 ok(stat
.reserved
== 0, "stat.reserved = %x\n", stat
.reserved
);
2045 hres
= IStream_Read(stream
, buf
, 512, &read
);
2046 if(test_protocol
== HTTP_TEST
&& emulate_protocol
&& read
)
2047 ok(buf
[0] == (use_cache_file
&& !(bindf
&BINDF_ASYNCHRONOUS
) ? 'X' : '?'), "buf[0] = '%c'\n", buf
[0]);
2048 }while(hres
== S_OK
);
2049 ok(hres
== S_FALSE
|| hres
== E_PENDING
, "IStream_Read returned %08x\n", hres
);
2052 if(use_cache_file
&& (grfBSCF
& BSCF_FIRSTDATANOTIFICATION
) && !(bindf
& BINDF_PULLDATA
))
2053 test_stream_seek(stream
);
2057 if(test_protocol
== FILE_TEST
)
2058 ok(!lstrcmpW(pstgmed
->u
.lpszFileName
, file_url
+7),
2059 "unexpected file name %s\n", wine_dbgstr_w(pstgmed
->u
.lpszFileName
));
2060 else if(emulate_protocol
)
2061 ok(!lstrcmpW(pstgmed
->u
.lpszFileName
, cache_fileW
),
2062 "unexpected file name %s\n", wine_dbgstr_w(pstgmed
->u
.lpszFileName
));
2063 else if(test_protocol
== HTTP_TEST
)
2064 lstrcpyW(http_cache_file
, pstgmed
->u
.lpszFileName
);
2066 ok(pstgmed
->u
.lpszFileName
!= NULL
, "lpszFileName == NULL\n");
2069 if((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
)
2070 && emulate_protocol
&& prot_state
< 4 && (!bind_to_object
|| prot_state
> 1))
2071 SetEvent(complete_event
);
2076 static HRESULT WINAPI
statusclb_OnObjectAvailable(IBindStatusCallbackEx
*iface
, REFIID riid
, IUnknown
*punk
)
2078 CHECK_EXPECT(OnObjectAvailable
);
2080 if(iface
!= &objbsc
)
2081 ok(0, "unexpected call\n");
2083 ok(IsEqualGUID(&IID_IUnknown
, riid
), "riid = %s\n", wine_dbgstr_guid(riid
));
2084 ok(punk
!= NULL
, "punk == NULL\n");
2089 static HRESULT WINAPI
statusclb_GetBindInfoEx(IBindStatusCallbackEx
*iface
, DWORD
*grfBINDF
, BINDINFO
*pbindinfo
,
2090 DWORD
*grfBINDF2
, DWORD
*pdwReserved
)
2092 CHECK_EXPECT(GetBindInfoEx
);
2094 ok(grfBINDF
!= NULL
, "grfBINDF == NULL\n");
2095 ok(grfBINDF2
!= NULL
, "grfBINDF2 == NULL\n");
2096 ok(pbindinfo
!= NULL
, "pbindinfo == NULL\n");
2097 ok(pdwReserved
!= NULL
, "dwReserved == NULL\n");
2102 static const IBindStatusCallbackExVtbl BindStatusCallbackVtbl
= {
2103 statusclb_QueryInterface
,
2106 statusclb_OnStartBinding
,
2107 statusclb_GetPriority
,
2108 statusclb_OnLowResource
,
2109 statusclb_OnProgress
,
2110 statusclb_OnStopBinding
,
2111 statusclb_GetBindInfo
,
2112 statusclb_OnDataAvailable
,
2113 statusclb_OnObjectAvailable
,
2114 statusclb_GetBindInfoEx
2117 static IBindStatusCallbackEx bsc
= { &BindStatusCallbackVtbl
};
2118 static IBindStatusCallbackEx bsc2
= { &BindStatusCallbackVtbl
};
2119 static IBindStatusCallbackEx objbsc
= { &BindStatusCallbackVtbl
};
2121 static HRESULT WINAPI
MonikerProp_QueryInterface(IMonikerProp
*iface
, REFIID riid
, void **ppv
)
2124 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2125 return E_NOINTERFACE
;
2128 static ULONG WINAPI
MonikerProp_AddRef(IMonikerProp
*iface
)
2133 static ULONG WINAPI
MonikerProp_Release(IMonikerProp
*iface
)
2138 static HRESULT WINAPI
MonikerProp_PutProperty(IMonikerProp
*iface
, MONIKERPROPERTY mkp
, LPCWSTR val
)
2142 CHECK_EXPECT(PutProperty_MIMETYPEPROP
);
2143 ok(!lstrcmpW(val
, wszTextHtml
), "val = %s\n", wine_dbgstr_w(val
));
2146 CHECK_EXPECT(PutProperty_CLASSIDPROP
);
2155 static const IMonikerPropVtbl MonikerPropVtbl
= {
2156 MonikerProp_QueryInterface
,
2158 MonikerProp_Release
,
2159 MonikerProp_PutProperty
2162 static IMonikerProp MonikerProp
= { &MonikerPropVtbl
};
2164 static HRESULT WINAPI
PersistMoniker_QueryInterface(IPersistMoniker
*iface
, REFIID riid
, void **ppv
)
2168 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IPersistMoniker
, riid
))
2170 else if(IsEqualGUID(&IID_IMonikerProp
, riid
))
2171 *ppv
= &MonikerProp
;
2176 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2177 return E_NOINTERFACE
;
2180 static ULONG WINAPI
PersistMoniker_AddRef(IPersistMoniker
*iface
)
2185 static ULONG WINAPI
PersistMoniker_Release(IPersistMoniker
*iface
)
2190 static HRESULT WINAPI
PersistMoniker_GetClassID(IPersistMoniker
*iface
, CLSID
*pClassID
)
2192 ok(0, "unexpected call\n");
2196 static HRESULT WINAPI
PersistMoniker_IsDirty(IPersistMoniker
*iface
)
2198 ok(0, "unexpected call\n");
2202 static HRESULT WINAPI
PersistMoniker_Load(IPersistMoniker
*iface
, BOOL fFullyAvailable
,
2203 IMoniker
*pimkName
, LPBC pibc
, DWORD grfMode
)
2208 static WCHAR cbinding_contextW
[] =
2209 {'C','B','i','n','d','i','n','g',' ','C','o','n','t','e','x','t',0};
2212 ok(GetCurrentThreadId() == thread_id
, "wrong thread %d\n", GetCurrentThreadId());
2214 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
2215 ok(!fFullyAvailable
, "fFullyAvailable = %x\n", fFullyAvailable
);
2217 ok(fFullyAvailable
, "fFullyAvailable = %x\n", fFullyAvailable
);
2218 ok(pimkName
!= NULL
, "pimkName == NULL\n");
2219 ok(pibc
!= NULL
, "pibc == NULL\n");
2220 ok(grfMode
== 0x12, "grfMode = %x\n", grfMode
);
2222 hres
= IBindCtx_GetObjectParam(pibc
, cbinding_contextW
, &unk
);
2223 ok(hres
== S_OK
, "GetObjectParam(CBinding Context) failed: %08x\n", hres
);
2224 if(SUCCEEDED(hres
)) {
2227 hres
= IUnknown_QueryInterface(unk
, &IID_IBinding
, (void**)&binding
);
2228 ok(hres
== S_OK
, "Could not get IBinding: %08x\n", hres
);
2230 IBinding_Release(binding
);
2231 IUnknown_Release(unk
);
2234 SET_EXPECT(QueryInterface_IServiceProvider
);
2235 hres
= RegisterBindStatusCallback(pibc
, (IBindStatusCallback
*)&bsc
, NULL
, 0);
2236 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
2237 CHECK_CALLED(QueryInterface_IServiceProvider
);
2239 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
2240 SET_EXPECT(GetBindInfo
);
2241 SET_EXPECT(OnStartBinding
);
2243 SET_EXPECT(OnProgress_REDIRECTING
);
2244 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
2245 if(test_protocol
== FILE_TEST
)
2246 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
2247 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
2248 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
2249 SET_EXPECT(LockRequest
);
2250 SET_EXPECT(OnDataAvailable
);
2251 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
2252 SET_EXPECT(OnStopBinding
);
2254 hres
= IMoniker_BindToStorage(pimkName
, pibc
, NULL
, &IID_IStream
, (void**)&unk
);
2255 ok(hres
== S_OK
, "Load failed: %08x\n", hres
);
2257 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx
); /* IE 8 */
2258 CHECK_CALLED(GetBindInfo
);
2259 CHECK_CALLED(OnStartBinding
);
2261 CHECK_CALLED(OnProgress_REDIRECTING
);
2262 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
2263 if(test_protocol
== FILE_TEST
)
2264 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
2265 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
2266 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
2267 CHECK_CALLED(LockRequest
);
2268 CHECK_CALLED(OnDataAvailable
);
2269 if(test_protocol
!= HTTP_TEST
&& test_protocol
!= HTTPS_TEST
)
2270 CHECK_CALLED(OnStopBinding
);
2273 IUnknown_Release(unk
);
2278 static HRESULT WINAPI
PersistMoniker_Save(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pbc
, BOOL fRemember
)
2280 ok(0, "unexpected call\n");
2284 static HRESULT WINAPI
PersistMoniker_SaveCompleted(IPersistMoniker
*iface
, IMoniker
*pimkName
, LPBC pibc
)
2286 ok(0, "unexpected call\n");
2290 static HRESULT WINAPI
PersistMoniker_GetCurMoniker(IPersistMoniker
*iface
, IMoniker
**pimkName
)
2292 ok(0, "unexpected call\n");
2296 static const IPersistMonikerVtbl PersistMonikerVtbl
= {
2297 PersistMoniker_QueryInterface
,
2298 PersistMoniker_AddRef
,
2299 PersistMoniker_Release
,
2300 PersistMoniker_GetClassID
,
2301 PersistMoniker_IsDirty
,
2302 PersistMoniker_Load
,
2303 PersistMoniker_Save
,
2304 PersistMoniker_SaveCompleted
,
2305 PersistMoniker_GetCurMoniker
2308 static IPersistMoniker PersistMoniker
= { &PersistMonikerVtbl
};
2310 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
2314 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
2319 if(IsEqualGUID(&IID_IMarshal
, riid
))
2320 return E_NOINTERFACE
;
2321 if(IsEqualGUID(&CLSID_IdentityUnmarshal
, riid
))
2322 return E_NOINTERFACE
;
2324 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2328 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
2333 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
2338 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
2340 CHECK_EXPECT(CreateInstance
);
2341 ok(!outer
, "outer = %p\n", outer
);
2342 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2343 *ppv
= &PersistMoniker
;
2347 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
2349 ok(0, "unexpected call\n");
2353 static const IClassFactoryVtbl ClassFactoryVtbl
= {
2354 ClassFactory_QueryInterface
,
2355 ClassFactory_AddRef
,
2356 ClassFactory_Release
,
2357 ClassFactory_CreateInstance
,
2358 ClassFactory_LockServer
2361 static IClassFactory mime_cf
= { &ClassFactoryVtbl
};
2363 static HRESULT WINAPI
ProtocolCF_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
2367 if(IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
)) {
2372 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
))
2373 return E_NOINTERFACE
;
2375 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2379 static HRESULT WINAPI
ProtocolCF_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
2381 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
))
2382 return E_NOINTERFACE
;
2384 ok(outer
!= NULL
, "outer == NULL\n");
2385 ok(IsEqualGUID(&IID_IUnknown
, riid
), "unexpected riid %s\n", wine_dbgstr_guid(riid
));
2390 static const IClassFactoryVtbl ProtocolCFVtbl
= {
2391 ProtocolCF_QueryInterface
,
2392 ClassFactory_AddRef
,
2393 ClassFactory_Release
,
2394 ProtocolCF_CreateInstance
,
2395 ClassFactory_LockServer
2398 static IClassFactory protocol_cf
= { &ProtocolCFVtbl
};
2400 static void test_CreateAsyncBindCtx(void)
2402 IBindCtx
*bctx
= (IBindCtx
*)0x0ff00ff0;
2408 hres
= CreateAsyncBindCtx(0, NULL
, NULL
, &bctx
);
2409 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres
);
2410 ok(bctx
== (IBindCtx
*)0x0ff00ff0, "bctx should not be changed\n");
2412 hres
= CreateAsyncBindCtx(0, NULL
, NULL
, NULL
);
2413 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed. expected: E_INVALIDARG, got: %08x\n", hres
);
2415 SET_EXPECT(QueryInterface_IServiceProvider
);
2416 hres
= CreateAsyncBindCtx(0, (IBindStatusCallback
*)&bsc
, NULL
, &bctx
);
2417 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n", hres
);
2418 CHECK_CALLED(QueryInterface_IServiceProvider
);
2420 bindopts
.cbStruct
= sizeof(bindopts
);
2421 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
2422 ok(hres
== S_OK
, "IBindCtx_GetBindOptions failed: %08x\n", hres
);
2423 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
2424 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
2425 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
2426 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2428 ok(bindopts
.dwTickCountDeadline
== 0,
2429 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
2431 hres
= IBindCtx_QueryInterface(bctx
, &IID_IAsyncBindCtx
, (void**)&unk
);
2432 ok(hres
== E_NOINTERFACE
, "QueryInterface(IID_IAsyncBindCtx) failed: %08x, expected E_NOINTERFACE\n", hres
);
2434 IUnknown_Release(unk
);
2436 ref
= IBindCtx_Release(bctx
);
2437 ok(ref
== 0, "bctx should be destroyed here\n");
2440 static void test_CreateAsyncBindCtxEx(void)
2442 IBindCtx
*bctx
= NULL
, *bctx2
= NULL
, *bctx_arg
= NULL
;
2447 static WCHAR testW
[] = {'t','e','s','t',0};
2449 if (!pCreateAsyncBindCtxEx
) {
2450 win_skip("CreateAsyncBindCtxEx not present\n");
2454 hres
= pCreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, NULL
, 0);
2455 ok(hres
== E_INVALIDARG
, "CreateAsyncBindCtx failed: %08x, expected E_INVALIDARG\n", hres
);
2457 hres
= pCreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
2458 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
2460 if(SUCCEEDED(hres
)) {
2461 bindopts
.cbStruct
= sizeof(bindopts
);
2462 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
2463 ok(hres
== S_OK
, "IBindCtx_GetBindOptions failed: %08x\n", hres
);
2464 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
2465 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
2466 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
2467 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2469 ok(bindopts
.dwTickCountDeadline
== 0,
2470 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
2472 IBindCtx_Release(bctx
);
2475 CreateBindCtx(0, &bctx_arg
);
2476 hres
= pCreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
2477 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
2479 if(SUCCEEDED(hres
)) {
2480 bindopts
.cbStruct
= sizeof(bindopts
);
2481 hres
= IBindCtx_GetBindOptions(bctx
, &bindopts
);
2482 ok(hres
== S_OK
, "IBindCtx_GetBindOptions failed: %08x\n", hres
);
2483 ok(bindopts
.grfFlags
== BIND_MAYBOTHERUSER
,
2484 "bindopts.grfFlags = %08x, expected: BIND_MAYBOTHERUSER\n", bindopts
.grfFlags
);
2485 ok(bindopts
.grfMode
== (STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
),
2486 "bindopts.grfMode = %08x, expected: STGM_READWRITE | STGM_SHARE_EXCLUSIVE\n",
2488 ok(bindopts
.dwTickCountDeadline
== 0,
2489 "bindopts.dwTickCountDeadline = %08x, expected: 0\n", bindopts
.dwTickCountDeadline
);
2491 IBindCtx_Release(bctx
);
2494 IBindCtx_Release(bctx_arg
);
2496 SET_EXPECT(QueryInterface_IServiceProvider
);
2497 hres
= pCreateAsyncBindCtxEx(NULL
, 0, (IBindStatusCallback
*)&bsc
, NULL
, &bctx
, 0);
2498 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
2499 CHECK_CALLED(QueryInterface_IServiceProvider
);
2501 hres
= IBindCtx_QueryInterface(bctx
, &IID_IAsyncBindCtx
, (void**)&unk
);
2502 ok(hres
== S_OK
, "QueryInterface(IID_IAsyncBindCtx) failed: %08x\n", hres
);
2504 IUnknown_Release(unk
);
2506 IBindCtx_Release(bctx
);
2508 hres
= CreateBindCtx(0, &bctx2
);
2509 ok(hres
== S_OK
, "CreateBindCtx failed: %08x\n", hres
);
2511 hres
= pCreateAsyncBindCtxEx(bctx2
, 0, NULL
, NULL
, &bctx
, 0);
2512 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
2514 hres
= IBindCtx_RegisterObjectParam(bctx2
, testW
, (IUnknown
*)&Protocol
);
2515 ok(hres
== S_OK
, "RegisterObjectParam failed: %08x\n", hres
);
2517 hres
= IBindCtx_GetObjectParam(bctx
, testW
, &unk
);
2518 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
2519 ok(unk
== (IUnknown
*)&Protocol
, "unexpected unk %p\n", unk
);
2521 IBindCtx_Release(bctx
);
2522 IBindCtx_Release(bctx2
);
2525 static void test_GetBindInfoEx(IBindStatusCallback
*holder
)
2527 IBindStatusCallbackEx
*bscex
;
2528 BINDINFO bindinfo
= {sizeof(bindinfo
)};
2529 DWORD bindf
, bindf2
, dw
;
2532 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IBindStatusCallbackEx
, (void**)&bscex
);
2534 win_skip("IBindStatusCallbackEx not supported\n");
2541 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
2542 SET_EXPECT(GetBindInfoEx
);
2543 hres
= IBindStatusCallback_GetBindInfo(holder
, &bindf
, &bindinfo
);
2544 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
2545 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx
);
2546 CHECK_CALLED(GetBindInfoEx
);
2548 bindf
= bindf2
= dw
= 0;
2549 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
2550 SET_EXPECT(GetBindInfoEx
);
2551 hres
= IBindStatusCallbackEx_GetBindInfoEx(bscex
, &bindf
, &bindinfo
, &bindf2
, &dw
);
2552 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
2553 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx
);
2554 CHECK_CALLED(GetBindInfoEx
);
2558 bindf
= bindf2
= dw
= 0xdeadbeef;
2559 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
2560 SET_EXPECT(GetBindInfo
);
2561 hres
= IBindStatusCallbackEx_GetBindInfoEx(bscex
, &bindf
, &bindinfo
, &bindf2
, &dw
);
2562 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
2563 CHECK_CALLED(QueryInterface_IBindStatusCallbackEx
);
2564 CHECK_CALLED(GetBindInfo
);
2565 ok(bindf2
== 0xdeadbeef, "bindf2 = %x\n", bindf2
);
2566 ok(dw
== 0xdeadbeef, "dw = %x\n", dw
);
2568 IBindStatusCallbackEx_Release(bscex
);
2571 static BOOL
test_bscholder(IBindStatusCallback
*holder
)
2573 IServiceProvider
*serv_prov
;
2574 IHttpNegotiate
*http_negotiate
, *http_negotiate_serv
;
2575 IHttpNegotiate2
*http_negotiate2
, *http_negotiate2_serv
;
2576 IAuthenticate
*authenticate
, *authenticate_serv
;
2577 IInternetBindInfo
*bind_info
;
2578 IInternetProtocol
*protocol
;
2579 BINDINFO bindinfo
= {sizeof(bindinfo
)};
2585 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IServiceProvider
, (void**)&serv_prov
);
2586 ok(hres
== S_OK
, "Could not get IServiceProvider interface: %08x\n", hres
);
2589 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
2590 SET_EXPECT(GetBindInfo
);
2591 hres
= IBindStatusCallback_GetBindInfo(holder
, &dw
, &bindinfo
);
2592 ok(hres
== S_OK
, "GetBindInfo failed: %08x\n", hres
);
2593 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx
); /* IE 8 */
2594 CHECK_CALLED(GetBindInfo
);
2596 test_GetBindInfoEx(holder
);
2598 SET_EXPECT(OnStartBinding
);
2599 hres
= IBindStatusCallback_OnStartBinding(holder
, 0, (void*)0xdeadbeef);
2600 ok(hres
== S_OK
, "OnStartBinding failed: %08x\n", hres
);
2601 CHECK_CALLED(OnStartBinding
);
2603 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IHttpNegotiate
, (void**)&http_negotiate
);
2604 ok(hres
== S_OK
, "Could not get IHttpNegotiate interface: %08x\n", hres
);
2606 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2607 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
,
2608 (void**)&http_negotiate_serv
);
2609 ok(hres
== S_OK
, "Could not get IHttpNegotiate service: %08x\n", hres
);
2610 CLEAR_CALLED(QueryInterface_IHttpNegotiate
); /* IE <8 */
2612 ok(http_negotiate
== http_negotiate_serv
, "http_negotiate != http_negotiate_serv\n");
2614 wstr
= (void*)0xdeadbeef;
2615 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2616 SET_EXPECT(BeginningTransaction
);
2617 hres
= IHttpNegotiate_BeginningTransaction(http_negotiate_serv
, current_url
, emptyW
, 0, &wstr
);
2618 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate
); /* IE8 */
2619 CHECK_CALLED(BeginningTransaction
);
2620 ok(hres
== S_OK
, "BeginningTransaction failed: %08x\n", hres
);
2621 ok(wstr
== NULL
, "wstr = %p\n", wstr
);
2623 IHttpNegotiate_Release(http_negotiate_serv
);
2625 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate
, &IID_IHttpNegotiate
,
2626 (void**)&http_negotiate_serv
);
2627 ok(hres
== S_OK
, "Could not get IHttpNegotiate service: %08x\n", hres
);
2628 ok(http_negotiate
== http_negotiate_serv
, "http_negotiate != http_negotiate_serv\n");
2629 IHttpNegotiate_Release(http_negotiate_serv
);
2631 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IHttpNegotiate2
, (void**)&http_negotiate2
);
2632 if(SUCCEEDED(hres
)) {
2633 have_IHttpNegotiate2
= TRUE
;
2635 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2636 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IHttpNegotiate2
, &IID_IHttpNegotiate2
,
2637 (void**)&http_negotiate2_serv
);
2638 ok(hres
== S_OK
, "Could not get IHttpNegotiate2 service: %08x\n", hres
);
2639 CLEAR_CALLED(QueryInterface_IHttpNegotiate2
); /* IE <8 */
2640 ok(http_negotiate2
== http_negotiate2_serv
, "http_negotiate != http_negotiate_serv\n");
2642 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
2643 SET_EXPECT(GetRootSecurityId
);
2644 hres
= IHttpNegotiate2_GetRootSecurityId(http_negotiate2
, (void*)0xdeadbeef, (void*)0xdeadbeef, 0);
2645 ok(hres
== E_NOTIMPL
, "GetRootSecurityId failed: %08x\n", hres
);
2646 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate2
); /* IE8 */
2647 CHECK_CALLED(GetRootSecurityId
);
2649 IHttpNegotiate2_Release(http_negotiate2_serv
);
2650 IHttpNegotiate2_Release(http_negotiate2
);
2652 skip("Could not get IHttpNegotiate2\n");
2656 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
2657 hres
= IBindStatusCallback_OnProgress(holder
, 0, 0, BINDSTATUS_FINDINGRESOURCE
, NULL
);
2658 ok(hres
== S_OK
, "OnProgress failed: %08x\n", hres
);
2659 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
2661 SET_EXPECT(QueryInterface_IHttpNegotiate
);
2662 SET_EXPECT(OnResponse
);
2663 wstr
= (void*)0xdeadbeef;
2664 hres
= IHttpNegotiate_OnResponse(http_negotiate
, 200, emptyW
, NULL
, NULL
);
2665 ok(hres
== S_OK
, "OnResponse failed: %08x\n", hres
);
2666 CHECK_CALLED_BROKEN(QueryInterface_IHttpNegotiate
); /* IE8 */
2667 CHECK_CALLED(OnResponse
);
2669 IHttpNegotiate_Release(http_negotiate
);
2671 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IAuthenticate
, (void**)&authenticate
);
2672 ok(hres
== S_OK
, "Could not get IAuthenticate interface: %08x\n", hres
);
2674 SET_EXPECT(QueryInterface_IAuthenticate
);
2675 SET_EXPECT(QueryService_IAuthenticate
);
2676 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IAuthenticate
, &IID_IAuthenticate
,
2677 (void**)&authenticate_serv
);
2678 ok(hres
== S_OK
, "Could not get IAuthenticate service: %08x\n", hres
);
2679 CLEAR_CALLED(QueryInterface_IAuthenticate
); /* IE <8 */
2680 CLEAR_CALLED(QueryService_IAuthenticate
); /* IE <8 */
2681 ok(authenticate
== authenticate_serv
, "authenticate != authenticate_serv\n");
2682 IAuthenticate_Release(authenticate_serv
);
2684 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IAuthenticate
, &IID_IAuthenticate
,
2685 (void**)&authenticate_serv
);
2686 ok(hres
== S_OK
, "Could not get IAuthenticate service: %08x\n", hres
);
2687 ok(authenticate
== authenticate_serv
, "authenticate != authenticate_serv\n");
2689 IAuthenticate_Release(authenticate
);
2690 IAuthenticate_Release(authenticate_serv
);
2692 hres
= IBindStatusCallback_QueryInterface(holder
, &IID_IInternetBindInfo
, (void**)&bind_info
);
2693 ok(hres
== S_OK
|| broken(hres
== E_NOINTERFACE
/* win2k */), "Could not get IInternetBindInfo interface: %08x\n", hres
);
2695 if(SUCCEEDED(hres
)) {
2696 hres
= IInternetBindInfo_GetBindString(bind_info
, BINDSTRING_USER_AGENT
, &wstr
, 1, &dw
);
2697 ok(hres
== E_NOINTERFACE
, "GetBindString(BINDSTRING_USER_AGENT) failed: %08x\n", hres
);
2699 IInternetBindInfo_Release(bind_info
);
2702 SET_EXPECT(OnStopBinding
);
2703 hres
= IBindStatusCallback_OnStopBinding(holder
, S_OK
, NULL
);
2704 ok(hres
== S_OK
, "OnStopBinding failed: %08x\n", hres
);
2705 CHECK_CALLED(OnStopBinding
);
2707 SET_EXPECT(QueryInterface_IInternetProtocol
);
2708 SET_EXPECT(QueryService_IInternetProtocol
);
2709 hres
= IServiceProvider_QueryService(serv_prov
, &IID_IInternetProtocol
, &IID_IInternetProtocol
,
2711 ok(hres
== E_NOINTERFACE
, "QueryService(IInternetProtocol) failed: %08x\n", hres
);
2712 CHECK_CALLED(QueryInterface_IInternetProtocol
);
2713 CHECK_CALLED(QueryService_IInternetProtocol
);
2715 IServiceProvider_Release(serv_prov
);
2719 static BOOL
test_RegisterBindStatusCallback(void)
2721 IBindStatusCallback
*prevbsc
, *clb
, *prev_clb
;
2727 strict_bsc_qi
= TRUE
;
2729 hres
= CreateBindCtx(0, &bindctx
);
2730 ok(hres
== S_OK
, "BindCtx failed: %08x\n", hres
);
2732 SET_EXPECT(QueryInterface_IServiceProvider
);
2734 hres
= IBindCtx_RegisterObjectParam(bindctx
, BSCBHolder
, (IUnknown
*)&bsc
);
2735 ok(hres
== S_OK
, "RegisterObjectParam failed: %08x\n", hres
);
2737 SET_EXPECT(QueryInterface_IBindStatusCallback
);
2738 SET_EXPECT(QueryInterface_IBindStatusCallbackHolder
);
2739 prevbsc
= (void*)0xdeadbeef;
2740 hres
= RegisterBindStatusCallback(bindctx
, (IBindStatusCallback
*)&bsc
, &prevbsc
, 0);
2741 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
2742 ok(prevbsc
== (IBindStatusCallback
*)&bsc
, "prevbsc=%p\n", prevbsc
);
2743 CHECK_CALLED(QueryInterface_IBindStatusCallback
);
2744 CHECK_CALLED(QueryInterface_IBindStatusCallbackHolder
);
2746 CHECK_CALLED(QueryInterface_IServiceProvider
);
2748 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
2749 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
2751 hres
= IUnknown_QueryInterface(unk
, &IID_IBindStatusCallback
, (void**)&clb
);
2752 IUnknown_Release(unk
);
2753 ok(hres
== S_OK
, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres
);
2754 ok(clb
!= (IBindStatusCallback
*)&bsc
, "bsc == clb\n");
2756 if(!test_bscholder(clb
))
2759 IBindStatusCallback_Release(clb
);
2761 hres
= RevokeBindStatusCallback(bindctx
, (IBindStatusCallback
*)&bsc
);
2762 ok(hres
== S_OK
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2764 unk
= (void*)0xdeadbeef;
2765 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
2766 ok(hres
== E_FAIL
, "GetObjectParam failed: %08x\n", hres
);
2767 ok(unk
== NULL
, "unk != NULL\n");
2770 IUnknown_Release(unk
);
2772 hres
= RevokeBindStatusCallback(bindctx
, (void*)0xdeadbeef);
2773 ok(hres
== S_OK
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2775 hres
= RevokeBindStatusCallback(NULL
, (void*)0xdeadbeef);
2776 ok(hres
== E_INVALIDARG
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2778 hres
= RevokeBindStatusCallback(bindctx
, NULL
);
2779 ok(hres
== E_INVALIDARG
, "RevokeBindStatusCallback failed: %08x\n", hres
);
2781 SET_EXPECT(QueryInterface_IServiceProvider
);
2782 prevbsc
= (void*)0xdeadbeef;
2783 hres
= RegisterBindStatusCallback(bindctx
, (IBindStatusCallback
*)&bsc
, &prevbsc
, 0);
2784 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
2785 ok(!prevbsc
, "prevbsc=%p\n", prevbsc
);
2786 CHECK_CALLED(QueryInterface_IServiceProvider
);
2788 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
2789 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
2791 hres
= IUnknown_QueryInterface(unk
, &IID_IBindStatusCallback
, (void**)&prev_clb
);
2792 IUnknown_Release(unk
);
2793 ok(hres
== S_OK
, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres
);
2794 ok(prev_clb
!= (IBindStatusCallback
*)&bsc
, "bsc == clb\n");
2796 SET_EXPECT(QueryInterface_IServiceProvider
);
2797 prevbsc
= (void*)0xdeadbeef;
2798 hres
= RegisterBindStatusCallback(bindctx
, (IBindStatusCallback
*)&bsc2
, &prevbsc
, 0);
2799 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
2800 ok(prevbsc
== (IBindStatusCallback
*)&bsc
, "prevbsc != bsc\n");
2801 CHECK_CALLED(QueryInterface_IServiceProvider
);
2803 hres
= IBindCtx_GetObjectParam(bindctx
, BSCBHolder
, &unk
);
2804 ok(hres
== S_OK
, "GetObjectParam failed: %08x\n", hres
);
2806 hres
= IUnknown_QueryInterface(unk
, &IID_IBindStatusCallback
, (void**)&clb
);
2807 IUnknown_Release(unk
);
2808 ok(hres
== S_OK
, "QueryInterface(IID_IBindStatusCallback) failed: %08x\n", hres
);
2809 ok(prev_clb
== clb
, "bsc != clb\n");
2811 IBindStatusCallback_Release(clb
);
2812 IBindStatusCallback_Release(prev_clb
);
2814 IBindCtx_Release(bindctx
);
2816 strict_bsc_qi
= FALSE
;
2820 #define BINDTEST_EMULATE 0x0001
2821 #define BINDTEST_TOOBJECT 0x0002
2822 #define BINDTEST_FILEDWLAPI 0x0004
2823 #define BINDTEST_HTTPRESPONSE 0x0008
2824 #define BINDTEST_REDIRECT 0x0010
2825 #define BINDTEST_USE_CACHE 0x0020
2826 #define BINDTEST_NO_CALLBACK_READ 0x0040
2827 #define BINDTEST_NO_CALLBACK 0x0080
2828 #define BINDTEST_ABORT 0x0100
2829 #define BINDTEST_INVALID_CN 0x0200
2830 #define BINDTEST_ABORT_START 0x0400
2831 #define BINDTEST_ABORT_PROGRESS 0x0800
2832 #define BINDTEST_ASYNC_SWITCH 0x1000
2833 #define BINDTEST_ALLOW_FINDINGRESOURCE 0x2000
2835 static void init_bind_test(int protocol
, DWORD flags
, DWORD t
)
2837 const char *url_a
= NULL
;
2839 test_protocol
= protocol
;
2840 bindtest_flags
= flags
;
2841 emulate_protocol
= (flags
& BINDTEST_EMULATE
) != 0;
2842 download_state
= BEFORE_DOWNLOAD
;
2843 stopped_binding
= FALSE
;
2844 stopped_obj_binding
= FALSE
;
2845 data_available
= FALSE
;
2847 binding_hres
= S_OK
;
2848 bind_to_object
= (flags
& BINDTEST_TOOBJECT
) != 0;
2850 filedwl_api
= (flags
& BINDTEST_FILEDWLAPI
) != 0;
2851 post_test
= (flags
& BINDTEST_HTTPRESPONSE
) != 0;
2856 url_a
= "http://test.winehq.org/tests/post.php";
2858 lstrcpyW(current_url
, winetest_data_urlW
);
2861 url_a
= "about:blank";
2864 lstrcpyW(current_url
, file_url
);
2867 url_a
= "mk:@MSITStore:test.chm::/blank.html";
2870 url_a
= "its:test.chm::/blank.html";
2873 url_a
= (flags
& BINDTEST_INVALID_CN
) ? "https://" WINEHQ_IP
"/favicon.ico" : "https://test.winehq.org/tests/hello.html";
2876 url_a
= "ftp://ftp.winehq.org/welcome%2emsg";
2879 url_a
= "winetest:test";
2883 MultiByteToWideChar(CP_ACP
, 0, url_a
, -1, current_url
, ARRAY_SIZE(current_url
));
2885 test_redirect
= (flags
& BINDTEST_REDIRECT
) != 0;
2886 use_cache_file
= (flags
& BINDTEST_USE_CACHE
) != 0;
2887 callback_read
= !(flags
& BINDTEST_NO_CALLBACK_READ
);
2888 no_callback
= (flags
& BINDTEST_NO_CALLBACK
) != 0;
2889 test_abort
= (flags
& BINDTEST_ABORT
) != 0;
2890 abort_start
= (flags
& BINDTEST_ABORT_START
) != 0;
2891 abort_progress
= (flags
& BINDTEST_ABORT_PROGRESS
) != 0;
2892 async_switch
= (flags
& BINDTEST_ASYNC_SWITCH
) != 0;
2893 is_async_prot
= protocol
== HTTP_TEST
|| protocol
== HTTPS_TEST
|| protocol
== FTP_TEST
|| protocol
== WINETEST_TEST
;
2895 ResetEvent(complete_event
);
2897 if (winetest_debug
> 1) trace("URL: %s\n", wine_dbgstr_w(current_url
));
2900 static void test_MonikerComposeWith(void)
2902 static const struct test_data
2904 const WCHAR
*l
, *r
, *expected
;
2907 {L
"https://test.winehq.org/", L
"/tests/hello.html", L
"https://test.winehq.org/tests/hello.html"},
2908 {L
"url1", L
"url2", L
"url2"},
2909 {L
"http://", L
"tests.winehq.org", L
"http:///tests.winehq.org"},
2910 {L
"http://a/b/c/d;p?q#f", L
"g", L
"http://a/b/c/g"},
2911 {L
"http://a/b/c/d;p?q#f", L
"./g", L
"http://a/b/c/g"},
2912 {L
"http://a/b/c/d;p?q#f", L
"g/", L
"http://a/b/c/g/"},
2913 {L
"http://a/b/c/d;p?q#f", L
"/g", L
"http://a/g"},
2914 {L
"http://a/b/c/d;p?q#f", L
"//g", L
"http://g/"},
2915 {L
"http://a/b/c/d;p?q#f", L
"?y", L
"http://a/b/c/d;p?y"},
2916 {L
"http://a/b/c/d;p?q#f", L
"g?y", L
"http://a/b/c/g?y"},
2917 {L
"http://a/b/c/d;p?q#f", L
"g?y/./x", L
"http://a/b/c/g?y/./x"},
2918 {L
"http://a/b/c/d;p?q#f", L
"#s", L
"http://a/b/c/d;p?q#s"},
2919 {L
"http://a/b/c/d;p?q#f", L
"g#s", L
"http://a/b/c/g#s"},
2920 {L
"http://a/b/c/d;p?q#f", L
"g#s/./x", L
"http://a/b/c/g#s/./x"},
2921 {L
"http://a/b/c/d;p?q#f", L
"g?y#s", L
"http://a/b/c/g?y#s"},
2922 {L
"http://a/b/c/d;p?q#f", L
";x", L
"http://a/b/c/;x"},
2923 {L
"http://a/b/c/d;p?q#f", L
"g;x", L
"http://a/b/c/g;x"},
2924 {L
"http://a/b/c/d;p?q#f", L
"g;x?y#s", L
"http://a/b/c/g;x?y#s"},
2925 {L
"http://a/b/c/d;p?q#f", L
".", L
"http://a/b/c/"},
2926 {L
"http://a/b/c/d;p?q#f", L
"./", L
"http://a/b/c/"},
2927 {L
"http://a/b/c/d;p?q#f", L
"..", L
"http://a/b/"},
2928 {L
"http://a/b/c/d;p?q#f", L
"../", L
"http://a/b/"},
2929 {L
"http://a/b/c/d;p?q#f", L
"../g", L
"http://a/b/g"},
2930 {L
"http://a/b/c/d;p?q#f", L
"../..", L
"http://a/"},
2931 {L
"http://a/b/c/d;p?q#f", L
"../../", L
"http://a/"},
2932 {L
"http://a/b/c/d;p?q#f", L
"../../g", L
"http://a/g"},
2933 {L
"http://a/b/c/d;p?q#f", L
"../../../g", L
"http://a/g"},
2934 {L
"http://a/b/c/d;p?q#f", L
"../../../../g", L
"http://a/g"},
2935 {L
"http://a/b/c/d;p?q#f", L
"/./g", L
"http://a/g"},
2936 {L
"http://a/b/c/d;p?q#f", L
"/../g", L
"http://a/g"},
2937 {L
"http://a/b/c/d;p?q#f", L
"g.", L
"http://a/b/c/g."},
2938 {L
"http://a/b/c/d;p?q#f", L
".g", L
"http://a/b/c/.g"},
2939 {L
"http://a/b/c/d;p?q#f", L
"g..", L
"http://a/b/c/g.."},
2940 {L
"http://a/b/c/d;p?q#f", L
"..g", L
"http://a/b/c/..g"},
2941 {L
"http://a/b/c/d;p?q#f", L
"./../g", L
"http://a/b/g"},
2942 {L
"http://a/b/c/d;p?q#f", L
"./g/.", L
"http://a/b/c/g/"},
2943 {L
"http://a/b/c/d;p?q#f", L
"g/./h", L
"http://a/b/c/g/h"},
2944 {L
"http://a/b/c/d;p?q#f", L
"g/../h", L
"http://a/b/c/h"},
2945 {L
"file://a/b/c/d;p?q#f", L
"http:g", L
"http:g"},
2946 {L
"http://a/b/c/d;p?q#f", L
"http://g/h", L
"http://g/h"},
2948 IMoniker
*lmon
, *rmon
, *outmon
, *filemon
;
2955 CreateBindCtx(0, &bind
);
2956 for(i
= 0; i
< ARRAY_SIZE( data
); i
++){
2957 hres
= CreateURLMoniker(NULL
, data
[i
].l
, &lmon
);
2958 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
2959 hres
= CreateURLMoniker(NULL
, data
[i
].r
, &rmon
);
2960 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
2962 hres
= IMoniker_ComposeWith(lmon
, rmon
, FALSE
, &outmon
);
2964 "ComposeWith failed: l: %s, r: %s, ret: %08x\n", wine_dbgstr_w(data
[i
].l
), wine_dbgstr_w(data
[i
].r
), hres
);
2966 IMoniker_GetClassID(outmon
, &clsid
);
2967 ok(IsEqualCLSID(&clsid
, &CLSID_StdURLMoniker
),
2968 "ComposeWith error: expected URL CLSID, got %s\n", wine_dbgstr_guid(&clsid
));
2969 IMoniker_GetDisplayName(outmon
, bind
, NULL
, &urlpath
);
2970 ok(lstrcmpW(data
[i
].expected
, urlpath
) == S_OK
,
2971 "ComposeWith expected %s got %s\n", wine_dbgstr_w(data
[i
].expected
), wine_dbgstr_w(urlpath
));
2973 IMoniker_Release(lmon
);
2974 IMoniker_Release(rmon
);
2975 IMoniker_Release(outmon
);
2976 CoTaskMemFree(urlpath
);
2978 IBindCtx_Release(bind
);
2980 hres
= CreateURLMoniker(NULL
, data
[0].l
, &lmon
);
2981 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
2982 hres
= CreateURLMoniker(NULL
, data
[0].r
, &rmon
);
2983 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
2984 hres
= CreateFileMoniker(L
"/a/b", &filemon
);
2985 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
2987 hres
= IMoniker_ComposeWith(lmon
, NULL
, FALSE
, &outmon
);
2988 ok(hres
== E_INVALIDARG
, "ComposeWith error: %08x\n", hres
);
2990 hres
= IMoniker_ComposeWith(lmon
, rmon
, FALSE
, NULL
);
2991 ok(hres
== E_INVALIDARG
, "ComposeWith error: %08x\n", hres
);
2993 hres
= IMoniker_ComposeWith(lmon
, filemon
, TRUE
, &outmon
);
2994 ok(hres
== MK_E_NEEDGENERIC
, "ComposeWith error: %08x\n", hres
);
2995 hres
= IMoniker_ComposeWith(lmon
, filemon
, FALSE
, &outmon
);
2996 ok(hres
== S_OK
, "ComposeWith error: %08x\n", hres
);
2998 IMoniker_GetClassID(outmon
, &clsid
);
2999 ok(IsEqualCLSID(&clsid
, &CLSID_CompositeMoniker
),
3000 "ComposeWith: got CLSID %s, not generic\n", wine_dbgstr_guid(&clsid
));
3002 IMoniker_Release(lmon
);
3003 IMoniker_Release(rmon
);
3004 IMoniker_Release(filemon
);
3005 IMoniker_Release(outmon
);
3008 static void test_BindToStorage(int protocol
, DWORD flags
, DWORD t
)
3012 LPOLESTR display_name
;
3013 IBindCtx
*bctx
= NULL
;
3015 IBindStatusCallback
*previousclb
;
3016 IUnknown
*unk
= (IUnknown
*)0x00ff00ff;
3017 BOOL allow_finding_resource
;
3020 init_bind_test(protocol
, flags
, t
);
3021 allow_finding_resource
= (flags
& BINDTEST_ALLOW_FINDINGRESOURCE
) != 0;
3024 hres
= CreateBindCtx(0, &bctx
);
3025 ok(hres
== S_OK
, "CreateBindCtx failed: %08x\n", hres
);
3027 SET_EXPECT(QueryInterface_IServiceProvider
);
3028 hres
= CreateAsyncBindCtx(0, (IBindStatusCallback
*)&bsc
, NULL
, &bctx
);
3029 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
3030 CHECK_CALLED(QueryInterface_IServiceProvider
);
3034 SET_EXPECT(QueryInterface_IServiceProvider
);
3035 hres
= RegisterBindStatusCallback(bctx
, (IBindStatusCallback
*)&bsc
, &previousclb
, 0);
3036 ok(hres
== S_OK
, "RegisterBindStatusCallback failed: %08x\n", hres
);
3037 ok(previousclb
== (IBindStatusCallback
*)&bsc
, "previousclb(%p) != sclb(%p)\n", previousclb
, &bsc
);
3038 CHECK_CALLED(QueryInterface_IServiceProvider
);
3040 IBindStatusCallback_Release(previousclb
);
3043 hres
= CreateURLMoniker(NULL
, current_url
, &mon
);
3044 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
3048 if(protocol
== FTP_TEST
)
3050 /* FTP urls don't have any escape characters so convert the url to what is expected */
3052 UrlUnescapeW(current_url
, NULL
, &size
, URL_UNESCAPE_INPLACE
);
3055 hres
= IMoniker_QueryInterface(mon
, &IID_IBinding
, (void**)&bind
);
3056 ok(hres
== E_NOINTERFACE
, "IMoniker should not have IBinding interface\n");
3058 IBinding_Release(bind
);
3060 hres
= IMoniker_GetDisplayName(mon
, bctx
, NULL
, &display_name
);
3061 ok(hres
== S_OK
, "GetDisplayName failed %08x\n", hres
);
3062 ok(!lstrcmpW(display_name
, current_url
), "GetDisplayName got wrong name %s, expected %s\n",
3063 wine_dbgstr_w(display_name
), wine_dbgstr_w(current_url
));
3064 CoTaskMemFree(display_name
);
3066 if(tymed
== TYMED_FILE
&& (test_protocol
== ABOUT_TEST
|| test_protocol
== ITS_TEST
))
3067 binding_hres
= INET_E_DATA_NOT_AVAILABLE
;
3068 if((flags
& BINDTEST_INVALID_CN
) && !invalid_cn_accepted
&&
3069 (onsecurityproblem_hres
!= S_OK
|| security_problem
== ERROR_INTERNET_SEC_CERT_ERRORS
)) {
3070 if(security_problem
== ERROR_INTERNET_SEC_CERT_ERRORS
)
3071 binding_hres
= INET_E_SECURITY_PROBLEM
;
3073 binding_hres
= INET_E_INVALID_CERTIFICATE
;
3077 if(only_check_prot_args
)
3078 SET_EXPECT(OnStopBinding
);
3080 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
3081 SET_EXPECT(GetBindInfo
);
3082 SET_EXPECT(QueryInterface_IInternetProtocol
);
3083 if(!emulate_protocol
)
3084 SET_EXPECT(QueryService_IInternetProtocol
);
3085 SET_EXPECT(OnStartBinding
);
3087 if(emulate_protocol
) {
3088 if(is_urlmon_protocol(test_protocol
))
3089 SET_EXPECT(SetPriority
);
3091 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
3092 || test_protocol
== WINETEST_SYNC_TEST
)
3093 SET_EXPECT(Terminate
);
3094 if(tymed
!= TYMED_FILE
|| (test_protocol
!= ABOUT_TEST
&& test_protocol
!= ITS_TEST
))
3095 SET_EXPECT(UnlockRequest
);
3097 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) {
3098 SET_EXPECT(QueryService_IInternetBindInfo
);
3100 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3101 SET_EXPECT(QueryInterface_IWindowForBindingUI
);
3102 SET_EXPECT(QueryService_IWindowForBindingUI
);
3103 SET_EXPECT(GetWindow_IWindowForBindingUI
);
3105 SET_EXPECT(BeginningTransaction
);
3106 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
3107 SET_EXPECT(GetRootSecurityId
);
3108 if(http_is_first
|| allow_finding_resource
)
3109 SET_EXPECT(OnProgress_FINDINGRESOURCE
);
3110 SET_EXPECT(OnProgress_CONNECTING
);
3112 if(flags
& BINDTEST_INVALID_CN
) {
3113 SET_EXPECT(QueryInterface_IHttpSecurity
);
3114 SET_EXPECT(QueryService_IHttpSecurity
);
3115 SET_EXPECT(OnSecurityProblem
);
3116 if(SUCCEEDED(onsecurityproblem_hres
))
3117 SET_EXPECT(GetWindow_IHttpSecurity
);
3121 if((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FTP_TEST
3122 || test_protocol
== FILE_TEST
|| test_protocol
== WINETEST_TEST
) && !abort_start
)
3123 SET_EXPECT(OnProgress_SENDINGREQUEST
);
3124 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) {
3125 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3126 SET_EXPECT(OnResponse
);
3129 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
3130 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
3132 if(test_protocol
== FILE_TEST
)
3133 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
3134 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FTP_TEST
|| test_protocol
== WINETEST_TEST
)
3135 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
3137 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
3138 if((tymed
!= TYMED_FILE
|| test_protocol
!= ABOUT_TEST
) && !abort_start
)
3139 SET_EXPECT(OnDataAvailable
);
3140 SET_EXPECT(OnStopBinding
);
3144 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, tymed
== TYMED_ISTREAM
? &IID_IStream
: &IID_IUnknown
, (void**)&unk
);
3145 if ((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3146 && hres
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
3148 skip("Network unreachable, skipping tests\n");
3152 if(only_check_prot_args
) {
3153 ok(hres
== E_FAIL
, "Got %08x\n", hres
);
3154 CHECK_CALLED(OnStopBinding
);
3155 } else if(abort_start
)
3156 ok(hres
== abort_hres
, "IMoniker_BindToStorage failed: %08x, expected %08x\n", hres
, abort_hres
);
3157 else if(abort_progress
)
3158 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3159 else if(no_callback
) {
3160 if(emulate_protocol
)
3161 ok( WaitForSingleObject(complete_event2
, 90000) == WAIT_OBJECT_0
, "wait timed out\n" );
3162 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3163 ok(unk
!= NULL
, "unk == NULL\n");
3164 }else if(!(bindf
& BINDF_ASYNCHRONOUS
) && tymed
== TYMED_FILE
) {
3165 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3166 ok(unk
== NULL
, "unk != NULL\n");
3167 }else if(((bindf
& BINDF_ASYNCHRONOUS
) && !data_available
)
3168 || (tymed
== TYMED_FILE
&& test_protocol
== FILE_TEST
)) {
3169 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3170 ok(unk
== NULL
, "istr should be NULL\n");
3171 }else if(tymed
== TYMED_FILE
&& test_protocol
== ABOUT_TEST
) {
3172 ok(hres
== INET_E_DATA_NOT_AVAILABLE
,
3173 "IMoniker_BindToStorage failed: %08x, expected INET_E_DATA_NOT_AVAILABLE\n", hres
);
3174 ok(unk
== NULL
, "istr should be NULL\n");
3175 }else if((flags
& BINDTEST_INVALID_CN
) && binding_hres
!= S_OK
) {
3176 ok(hres
== binding_hres
, "Got %08x\n", hres
);
3177 ok(unk
== NULL
, "Got %p\n", unk
);
3178 }else if((flags
& BINDTEST_INVALID_CN
) && invalid_cn_accepted
) {
3179 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3180 ok(unk
!= NULL
, "unk == NULL\n");
3182 ok(0, "Expected security problem to be ignored.\n");
3183 invalid_cn_accepted
= FALSE
;
3184 binding_hres
= INET_E_INVALID_CERTIFICATE
;
3187 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3188 ok(unk
!= NULL
, "unk == NULL\n");
3190 if(unk
&& callback_read
&& !no_callback
) {
3191 IUnknown_Release(unk
);
3195 if(FAILED(hres
) && !(flags
& BINDTEST_INVALID_CN
) && !(flags
& BINDTEST_ABORT_START
))
3198 if((bindf
& BINDF_ASYNCHRONOUS
) && !no_callback
) {
3199 while(!stopped_binding
&& GetMessageA(&msg
,NULL
,0,0)) {
3200 TranslateMessage(&msg
);
3201 DispatchMessageA(&msg
);
3206 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
3207 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
3208 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
3209 CHECK_CALLED(LockRequest
);
3210 CHECK_CALLED(OnStopBinding
);
3213 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx
); /* IE 8 */
3214 CHECK_CALLED(GetBindInfo
);
3215 todo_wine_if(abort_start
)
3216 CHECK_CALLED(QueryInterface_IInternetProtocol
);
3217 if(!emulate_protocol
) {
3218 todo_wine_if(abort_start
)
3219 CHECK_CALLED(QueryService_IInternetProtocol
);
3221 CHECK_CALLED(OnStartBinding
);
3223 if(emulate_protocol
) {
3224 if(is_urlmon_protocol(test_protocol
))
3225 CLEAR_CALLED(SetPriority
); /* Not called by IE11 */
3226 CHECK_CALLED(Start
);
3227 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
3228 || test_protocol
== WINETEST_SYNC_TEST
) {
3229 if(tymed
== TYMED_FILE
)
3231 CHECK_CALLED(Terminate
);
3233 if(tymed
!= TYMED_FILE
|| (test_protocol
!= ABOUT_TEST
&& test_protocol
!= ITS_TEST
))
3234 CHECK_CALLED(UnlockRequest
);
3236 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) {
3237 CLEAR_CALLED(QueryService_IInternetBindInfo
);
3239 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
3240 CLEAR_CALLED(QueryInterface_IWindowForBindingUI
);
3241 CLEAR_CALLED(QueryService_IWindowForBindingUI
);
3242 CLEAR_CALLED(GetWindow_IWindowForBindingUI
);
3244 CHECK_CALLED(BeginningTransaction
);
3245 if (have_IHttpNegotiate2
&& !abort_start
)
3247 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
3248 CHECK_CALLED(GetRootSecurityId
);
3251 if (! proxy_active())
3253 CHECK_CALLED(OnProgress_FINDINGRESOURCE
);
3254 CHECK_CALLED(OnProgress_CONNECTING
);
3258 CLEAR_CALLED(OnProgress_FINDINGRESOURCE
);
3259 CLEAR_CALLED(OnProgress_CONNECTING
);
3261 }else if(!abort_start
) {
3262 if(allow_finding_resource
)
3263 CLEAR_CALLED(OnProgress_FINDINGRESOURCE
);
3264 /* IE7 does call this */
3265 CLEAR_CALLED(OnProgress_CONNECTING
);
3267 if((flags
& BINDTEST_INVALID_CN
) && !invalid_cn_accepted
) {
3268 CHECK_CALLED(QueryInterface_IHttpSecurity
);
3269 CHECK_CALLED(QueryService_IHttpSecurity
);
3270 CHECK_CALLED(OnSecurityProblem
);
3272 CHECK_NOT_CALLED(QueryInterface_IHttpSecurity
);
3273 CHECK_NOT_CALLED(QueryService_IHttpSecurity
);
3274 CHECK_NOT_CALLED(OnSecurityProblem
);
3278 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
|| test_protocol
== WINETEST_TEST
) {
3279 if(flags
& BINDTEST_INVALID_CN
)
3280 CLEAR_CALLED(OnProgress_SENDINGREQUEST
);
3281 else if(!abort_start
)
3282 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
3283 } else if(test_protocol
== FTP_TEST
)
3284 todo_wine
CHECK_CALLED(OnProgress_SENDINGREQUEST
);
3285 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== WINETEST_TEST
) {
3286 CLEAR_CALLED(QueryInterface_IHttpNegotiate
);
3287 if((!(flags
& BINDTEST_INVALID_CN
) || (binding_hres
== S_OK
)) && !abort_start
) {
3288 CHECK_CALLED(OnResponse
);
3291 if((!(flags
& BINDTEST_INVALID_CN
) || binding_hres
== S_OK
) && !abort_start
) {
3292 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
3293 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
3294 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
3296 if(test_protocol
== FILE_TEST
)
3297 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
3298 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FTP_TEST
|| test_protocol
== WINETEST_TEST
)
3299 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
3300 if((flags
& BINDTEST_INVALID_CN
)) {
3301 if(binding_hres
== S_OK
)
3302 CHECK_CALLED(OnDataAvailable
);
3304 CHECK_NOT_CALLED(OnDataAvailable
);
3305 }else if((tymed
!= TYMED_FILE
|| test_protocol
!= ABOUT_TEST
) && !abort_start
)
3306 CHECK_CALLED(OnDataAvailable
);
3307 CHECK_CALLED(OnStopBinding
);
3311 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
3313 ok(IBindCtx_Release(bctx
) == 0, "bctx should be destroyed here\n");
3315 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3316 http_is_first
= FALSE
;
3318 if((flags
& BINDTEST_INVALID_CN
) && onsecurityproblem_hres
== S_OK
&& security_problem
!= ERROR_INTERNET_SEC_CERT_ERRORS
)
3319 invalid_cn_accepted
= TRUE
;
3326 hres
= IUnknown_QueryInterface(unk
, &IID_IStream
, (void**)&stream
);
3327 ok(hres
== S_OK
, "Could not get IStream iface: %08x\n", hres
);
3328 IUnknown_Release(unk
);
3332 hres
= IStream_Read(stream
, buf
, sizeof(buf
), &read
);
3333 ok(read
!= 0xdeadbeef, "read = 0xdeadbeef\n");
3334 if(emulate_protocol
&& test_protocol
== HTTP_TEST
&& read
)
3335 ok(buf
[0] == (use_cache_file
&& !(bindf
&BINDF_ASYNCHRONOUS
) ? 'X' : '?'), "buf[0] = '%c'\n", buf
[0]);
3336 }while(hres
== S_OK
);
3337 ok(hres
== S_FALSE
, "IStream_Read returned %08x\n", hres
);
3338 ok(!read
, "read = %d\n", read
);
3340 IStream_Release(stream
);
3344 static void test_BindToObject(int protocol
, DWORD flags
, HRESULT exhres
)
3348 LPOLESTR display_name
;
3352 IUnknown
*unk
= (IUnknown
*)0x00ff00ff;
3355 init_bind_test(protocol
, BINDTEST_TOOBJECT
|flags
, TYMED_ISTREAM
);
3356 binding_hres
= exhres
;
3358 if(emulate_protocol
)
3359 CoRegisterClassObject(&CLSID_HTMLDocument
, (IUnknown
*)&mime_cf
,
3360 CLSCTX_INPROC_SERVER
, REGCLS_MULTIPLEUSE
, ®id
);
3362 SET_EXPECT(QueryInterface_IServiceProvider
);
3363 hres
= CreateAsyncBindCtx(0, (IBindStatusCallback
*)&objbsc
, NULL
, &bctx
);
3364 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
3365 CHECK_CALLED(QueryInterface_IServiceProvider
);
3369 hres
= CreateURLMoniker(NULL
, current_url
, &mon
);
3370 ok(hres
== S_OK
, "failed to create moniker: %08x\n", hres
);
3372 IBindCtx_Release(bctx
);
3376 hres
= IMoniker_QueryInterface(mon
, &IID_IBinding
, (void**)&bind
);
3377 ok(hres
== E_NOINTERFACE
, "IMoniker should not have IBinding interface\n");
3379 IBinding_Release(bind
);
3381 hres
= IMoniker_GetDisplayName(mon
, bctx
, NULL
, &display_name
);
3382 ok(hres
== S_OK
, "GetDisplayName failed %08x\n", hres
);
3383 ok(!lstrcmpW(display_name
, current_url
), "GetDisplayName got wrong name\n");
3384 CoTaskMemFree(display_name
);
3386 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
3387 SET_EXPECT(Obj_GetBindInfo
);
3388 SET_EXPECT(QueryInterface_IInternetProtocol
);
3389 if(!emulate_protocol
)
3390 SET_EXPECT(QueryService_IInternetProtocol
);
3391 SET_EXPECT(Obj_OnStartBinding
);
3392 if(emulate_protocol
) {
3393 if(is_urlmon_protocol(test_protocol
))
3394 SET_EXPECT(SetPriority
);
3396 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3397 SET_EXPECT(Terminate
);
3398 if(test_protocol
== FILE_TEST
)
3399 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
3400 SET_EXPECT(UnlockRequest
);
3402 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3403 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3404 SET_EXPECT(BeginningTransaction
);
3405 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
3406 SET_EXPECT(GetRootSecurityId
);
3408 SET_EXPECT(Obj_OnProgress_FINDINGRESOURCE
);
3409 SET_EXPECT(Obj_OnProgress_CONNECTING
);
3410 SET_EXPECT(QueryInterface_IWindowForBindingUI
);
3411 SET_EXPECT(QueryService_IWindowForBindingUI
);
3412 SET_EXPECT(GetWindow_IWindowForBindingUI
);
3414 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
)
3415 SET_EXPECT(Obj_OnProgress_SENDINGREQUEST
);
3416 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3417 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3418 SET_EXPECT(OnResponse
);
3420 SET_EXPECT(Obj_OnProgress_MIMETYPEAVAILABLE
);
3421 SET_EXPECT(Obj_OnProgress_BEGINDOWNLOADDATA
);
3422 if(test_protocol
== FILE_TEST
)
3423 SET_EXPECT(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
3424 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3425 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
3426 SET_EXPECT(Obj_OnProgress_ENDDOWNLOADDATA
);
3428 SET_EXPECT(Obj_OnProgress_CLASSIDAVAILABLE
);
3429 SET_EXPECT(Obj_OnProgress_BEGINSYNCOPERATION
);
3430 if(exhres
== REGDB_E_CLASSNOTREG
) {
3431 SET_EXPECT(QueryInterface_IWindowForBindingUI
);
3432 SET_EXPECT(QueryService_IWindowForBindingUI
);
3433 SET_EXPECT(GetWindow_ICodeInstall
);
3435 SET_EXPECT(Obj_OnProgress_ENDSYNCOPERATION
);
3437 SET_EXPECT(OnObjectAvailable
);
3438 SET_EXPECT(Obj_OnStopBinding
);
3441 hres
= IMoniker_BindToObject(mon
, bctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
3443 if ((test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3444 && hres
== HRESULT_FROM_WIN32(ERROR_INTERNET_NAME_NOT_RESOLVED
))
3446 skip( "Network unreachable, skipping tests\n" );
3450 if(FAILED(exhres
)) {
3451 ok(hres
== exhres
, "BindToObject failed: %08x, expected %08x\n", hres
, exhres
);
3452 ok(!unk
, "unk = %p, expected NULL\n", unk
);
3453 }else if(bindf
& BINDF_ASYNCHRONOUS
) {
3454 ok(hres
== MK_S_ASYNCHRONOUS
, "IMoniker_BindToObject failed: %08x\n", hres
);
3455 ok(unk
== NULL
, "istr should be NULL\n");
3457 ok(hres
== S_OK
, "IMoniker_BindToStorage failed: %08x\n", hres
);
3458 ok(unk
!= NULL
, "unk == NULL\n");
3459 if(emulate_protocol
)
3460 ok(unk
== (IUnknown
*)&PersistMoniker
, "unk != PersistMoniker\n");
3463 IUnknown_Release(unk
);
3465 while((bindf
& BINDF_ASYNCHRONOUS
) &&
3466 !((!emulate_protocol
|| stopped_binding
) && stopped_obj_binding
) && GetMessageA(&msg
,NULL
,0,0)) {
3467 TranslateMessage(&msg
);
3468 DispatchMessageA(&msg
);
3471 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx
);
3472 CHECK_CALLED(Obj_GetBindInfo
);
3473 CHECK_CALLED(QueryInterface_IInternetProtocol
);
3474 if(!emulate_protocol
)
3475 CHECK_CALLED(QueryService_IInternetProtocol
);
3476 CHECK_CALLED(Obj_OnStartBinding
);
3477 if(emulate_protocol
) {
3478 if(is_urlmon_protocol(test_protocol
))
3479 CLEAR_CALLED(SetPriority
); /* Not called by IE11 */
3480 CHECK_CALLED(Start
);
3481 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3482 CHECK_CALLED(Terminate
);
3483 if(test_protocol
== FILE_TEST
)
3484 CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE
); /* not called in IE7 */
3485 CHECK_CALLED(UnlockRequest
);
3487 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3488 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
3489 CHECK_CALLED(BeginningTransaction
);
3490 if (have_IHttpNegotiate2
)
3492 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
3493 CHECK_CALLED(GetRootSecurityId
);
3496 CHECK_CALLED(Obj_OnProgress_FINDINGRESOURCE
);
3497 CHECK_CALLED(Obj_OnProgress_CONNECTING
);
3499 /* IE7 does call this */
3500 CLEAR_CALLED(Obj_OnProgress_CONNECTING
);
3502 CLEAR_CALLED(QueryInterface_IWindowForBindingUI
);
3503 CLEAR_CALLED(QueryService_IWindowForBindingUI
);
3504 CLEAR_CALLED(GetWindow_IWindowForBindingUI
);
3506 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
) {
3508 CLEAR_CALLED(Obj_OnProgress_SENDINGREQUEST
);
3510 CHECK_CALLED(Obj_OnProgress_SENDINGREQUEST
);
3512 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3513 CLEAR_CALLED(QueryInterface_IHttpNegotiate
);
3514 CHECK_CALLED(OnResponse
);
3516 CHECK_CALLED(Obj_OnProgress_MIMETYPEAVAILABLE
);
3517 CHECK_CALLED(Obj_OnProgress_BEGINDOWNLOADDATA
);
3518 if(test_protocol
== FILE_TEST
)
3519 CHECK_CALLED(Obj_OnProgress_CACHEFILENAMEAVAILABLE
);
3520 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3521 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
3522 CLEAR_CALLED(Obj_OnProgress_ENDDOWNLOADDATA
);
3524 CHECK_CALLED(Obj_OnProgress_CLASSIDAVAILABLE
);
3525 CHECK_CALLED(Obj_OnProgress_BEGINSYNCOPERATION
);
3526 if(exhres
== REGDB_E_CLASSNOTREG
) {
3527 todo_wine
CHECK_CALLED(QueryInterface_IWindowForBindingUI
);
3528 todo_wine
CHECK_CALLED(QueryService_IWindowForBindingUI
);
3529 todo_wine
CHECK_CALLED(GetWindow_ICodeInstall
);
3531 CHECK_CALLED(Obj_OnProgress_ENDSYNCOPERATION
);
3533 CHECK_CALLED(OnObjectAvailable
);
3534 CHECK_CALLED(Obj_OnStopBinding
);
3537 ok(IMoniker_Release(mon
) == 0, "mon should be destroyed here\n");
3538 IBindCtx_Release(bctx
);
3540 if(emulate_protocol
)
3541 CoRevokeClassObject(regid
);
3543 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3544 http_is_first
= FALSE
;
3547 static void test_URLDownloadToFile(DWORD prot
, BOOL emul
)
3552 init_bind_test(prot
, BINDTEST_FILEDWLAPI
| (emul
? BINDTEST_EMULATE
: 0), TYMED_FILE
);
3554 SET_EXPECT(GetBindInfo
);
3555 SET_EXPECT(QueryInterface_IInternetProtocol
);
3556 SET_EXPECT(QueryInterface_IServiceProvider
);
3557 if(!emulate_protocol
)
3558 SET_EXPECT(QueryService_IInternetProtocol
);
3559 SET_EXPECT(OnStartBinding
);
3560 if(emulate_protocol
) {
3561 if(is_urlmon_protocol(test_protocol
))
3562 SET_EXPECT(SetPriority
);
3564 SET_EXPECT(UnlockRequest
);
3566 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3567 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3568 SET_EXPECT(BeginningTransaction
);
3569 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
3570 SET_EXPECT(GetRootSecurityId
);
3571 SET_EXPECT(QueryInterface_IWindowForBindingUI
);
3572 SET_EXPECT(OnProgress_CONNECTING
);
3574 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
|| test_protocol
== FILE_TEST
)
3575 SET_EXPECT(OnProgress_SENDINGREQUEST
);
3576 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3577 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3578 SET_EXPECT(OnResponse
);
3580 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
3581 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
3582 if(test_protocol
== FILE_TEST
)
3583 SET_EXPECT(OnProgress_CACHEFILENAMEAVAILABLE
);
3584 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3585 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
3586 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
3587 SET_EXPECT(OnStopBinding
);
3590 hres
= URLDownloadToFileW(NULL
, current_url
, dwl_htmlW
, 0, (IBindStatusCallback
*)&bsc
);
3591 ok(hres
== S_OK
, "URLDownloadToFile failed: %08x\n", hres
);
3593 CHECK_CALLED(GetBindInfo
);
3594 CHECK_CALLED(QueryInterface_IInternetProtocol
);
3595 if(!emulate_protocol
) {
3596 CHECK_CALLED(QueryInterface_IServiceProvider
);
3597 CHECK_CALLED(QueryService_IInternetProtocol
);
3599 CLEAR_CALLED(QueryInterface_IServiceProvider
);
3601 CHECK_CALLED(OnStartBinding
);
3602 if(emulate_protocol
) {
3603 if(is_urlmon_protocol(test_protocol
))
3604 CLEAR_CALLED(SetPriority
); /* Not called by IE11 */
3605 CHECK_CALLED(Start
);
3606 CHECK_CALLED(UnlockRequest
);
3608 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3609 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
3610 CHECK_CALLED(BeginningTransaction
);
3611 if (have_IHttpNegotiate2
)
3613 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
3614 CHECK_CALLED(GetRootSecurityId
);
3616 CLEAR_CALLED(QueryInterface_IWindowForBindingUI
);
3617 CLEAR_CALLED(OnProgress_CONNECTING
);
3619 if(test_protocol
== FILE_TEST
)
3620 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
3621 else if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3622 CLEAR_CALLED(OnProgress_SENDINGREQUEST
); /* not called by IE7 */
3623 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
) {
3624 CLEAR_CALLED(QueryInterface_IHttpNegotiate
);
3625 CHECK_CALLED(OnResponse
);
3627 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
3628 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
3629 if(test_protocol
== FILE_TEST
)
3630 CHECK_CALLED(OnProgress_CACHEFILENAMEAVAILABLE
);
3631 if(test_protocol
== HTTP_TEST
|| test_protocol
== HTTPS_TEST
)
3632 CLEAR_CALLED(OnProgress_DOWNLOADINGDATA
);
3633 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
3634 CHECK_CALLED(OnStopBinding
);
3637 res
= DeleteFileA(dwl_htmlA
);
3638 ok(res
, "DeleteFile failed: %u\n", GetLastError());
3640 if(prot
!= FILE_TEST
|| emul
)
3643 hres
= URLDownloadToFileW(NULL
, current_url
, dwl_htmlW
, 0, NULL
);
3644 ok(hres
== S_OK
, "URLDownloadToFile failed: %08x\n", hres
);
3646 res
= DeleteFileA(dwl_htmlA
);
3647 ok(res
, "DeleteFile failed: %u\n", GetLastError());
3650 static void test_URLDownloadToFile_abort(void)
3654 init_bind_test(HTTP_TEST
, BINDTEST_FILEDWLAPI
|BINDTEST_ABORT_PROGRESS
, TYMED_FILE
);
3656 SET_EXPECT(GetBindInfo
);
3657 SET_EXPECT(QueryInterface_IInternetProtocol
);
3658 SET_EXPECT(QueryInterface_IServiceProvider
);
3659 SET_EXPECT(QueryService_IInternetProtocol
);
3660 SET_EXPECT(OnStartBinding
);
3661 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3662 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
3663 SET_EXPECT(BeginningTransaction
);
3664 SET_EXPECT(GetRootSecurityId
);
3665 SET_EXPECT(QueryInterface_IWindowForBindingUI
);
3666 SET_EXPECT(OnProgress_CONNECTING
);
3667 SET_EXPECT(OnProgress_SENDINGREQUEST
);
3668 SET_EXPECT(OnStopBinding
);
3670 hres
= URLDownloadToFileW(NULL
, current_url
, dwl_htmlW
, 0, (IBindStatusCallback
*)&bsc
);
3671 ok(hres
== E_ABORT
, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres
);
3673 CHECK_CALLED(GetBindInfo
);
3674 CHECK_CALLED(QueryInterface_IInternetProtocol
);
3675 CHECK_CALLED(QueryInterface_IServiceProvider
);
3676 CHECK_CALLED(QueryService_IInternetProtocol
);
3677 CHECK_CALLED(OnStartBinding
);
3678 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
3679 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
3680 CHECK_CALLED(BeginningTransaction
);
3681 CHECK_CALLED(GetRootSecurityId
);
3682 CLEAR_CALLED(QueryInterface_IWindowForBindingUI
);
3683 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
3684 CLEAR_CALLED(OnProgress_CONNECTING
);
3685 CHECK_CALLED(OnStopBinding
);
3687 init_bind_test(HTTP_TEST
, BINDTEST_FILEDWLAPI
|BINDTEST_ABORT_START
, TYMED_FILE
);
3689 SET_EXPECT(GetBindInfo
);
3690 SET_EXPECT(QueryInterface_IInternetProtocol
);
3691 SET_EXPECT(QueryInterface_IServiceProvider
);
3692 SET_EXPECT(QueryService_IInternetProtocol
);
3693 SET_EXPECT(OnStartBinding
);
3694 SET_EXPECT(OnStopBinding
);
3696 abort_hres
= E_ABORT
;
3697 hres
= URLDownloadToFileW(NULL
, current_url
, dwl_htmlW
, 0, (IBindStatusCallback
*)&bsc
);
3698 ok(hres
== E_ABORT
, "URLDownloadToFile failed: %08x, expected E_ABORT\n", hres
);
3700 CHECK_CALLED(GetBindInfo
);
3701 todo_wine
CHECK_CALLED(QueryInterface_IInternetProtocol
);
3702 todo_wine
CHECK_CALLED(QueryInterface_IServiceProvider
);
3703 todo_wine
CHECK_CALLED(QueryService_IInternetProtocol
);
3704 CHECK_CALLED(OnStartBinding
);
3705 CHECK_CALLED(OnStopBinding
);
3707 init_bind_test(HTTP_TEST
, BINDTEST_FILEDWLAPI
|BINDTEST_ABORT_START
, TYMED_FILE
);
3709 SET_EXPECT(GetBindInfo
);
3710 SET_EXPECT(QueryInterface_IInternetProtocol
);
3711 SET_EXPECT(QueryInterface_IServiceProvider
);
3712 SET_EXPECT(QueryService_IInternetProtocol
);
3713 SET_EXPECT(OnStartBinding
);
3714 SET_EXPECT(QueryInterface_IHttpNegotiate
);
3715 SET_EXPECT(QueryInterface_IHttpNegotiate2
);
3716 SET_EXPECT(BeginningTransaction
);
3717 SET_EXPECT(GetRootSecurityId
);
3718 SET_EXPECT(QueryInterface_IWindowForBindingUI
);
3719 SET_EXPECT(OnResponse
);
3720 SET_EXPECT(OnProgress_CONNECTING
);
3721 SET_EXPECT(OnProgress_SENDINGREQUEST
);
3722 SET_EXPECT(OnProgress_MIMETYPEAVAILABLE
);
3723 SET_EXPECT(OnProgress_BEGINDOWNLOADDATA
);
3724 SET_EXPECT(OnProgress_DOWNLOADINGDATA
);
3725 SET_EXPECT(OnProgress_ENDDOWNLOADDATA
);
3726 SET_EXPECT(OnStopBinding
);
3728 /* URLDownloadToFile doesn't abort if E_NOTIMPL is returned from the
3729 * IBindStatusCallback's OnStartBinding function.
3731 abort_hres
= E_NOTIMPL
;
3732 hres
= URLDownloadToFileW(NULL
, current_url
, dwl_htmlW
, 0, (IBindStatusCallback
*)&bsc
);
3733 ok(hres
== S_OK
, "URLDownloadToFile failed: %08x\n", hres
);
3735 CHECK_CALLED(GetBindInfo
);
3736 CHECK_CALLED(QueryInterface_IInternetProtocol
);
3737 CHECK_CALLED(QueryInterface_IServiceProvider
);
3738 CHECK_CALLED(QueryService_IInternetProtocol
);
3739 CHECK_CALLED(OnStartBinding
);
3740 CHECK_CALLED(QueryInterface_IHttpNegotiate
);
3741 CHECK_CALLED(QueryInterface_IHttpNegotiate2
);
3742 CHECK_CALLED(BeginningTransaction
);
3743 CHECK_CALLED(GetRootSecurityId
);
3744 CLEAR_CALLED(QueryInterface_IWindowForBindingUI
);
3745 CHECK_CALLED(OnResponse
);
3746 CLEAR_CALLED(OnProgress_CONNECTING
);
3747 CHECK_CALLED(OnProgress_SENDINGREQUEST
);
3748 CHECK_CALLED(OnProgress_MIMETYPEAVAILABLE
);
3749 CHECK_CALLED(OnProgress_BEGINDOWNLOADDATA
);
3750 CHECK_CALLED(OnProgress_DOWNLOADINGDATA
);
3751 CHECK_CALLED(OnProgress_ENDDOWNLOADDATA
);
3752 CHECK_CALLED(OnStopBinding
);
3754 DeleteFileA(dwl_htmlA
);
3757 static void set_file_url(char *path
)
3759 CHAR file_urlA
[INTERNET_MAX_URL_LENGTH
];
3761 lstrcpyA(file_urlA
, "file://");
3762 lstrcatA(file_urlA
, path
);
3763 MultiByteToWideChar(CP_ACP
, 0, file_urlA
, -1, file_url
, INTERNET_MAX_URL_LENGTH
);
3766 static void create_file(const char *file_name
, const char *content
)
3770 CHAR path
[MAX_PATH
];
3772 file
= CreateFileA(file_name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
3773 FILE_ATTRIBUTE_NORMAL
, NULL
);
3774 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
3775 if(file
== INVALID_HANDLE_VALUE
)
3779 DeleteFileA(test_file
);
3780 test_file
= file_name
;
3781 WriteFile(file
, content
, strlen(content
), &size
, NULL
);
3784 GetCurrentDirectoryA(MAX_PATH
, path
);
3785 lstrcatA(path
, "\\");
3786 lstrcatA(path
, file_name
);
3790 static void create_html_file(void)
3792 create_file(wszIndexHtmlA
, "<HTML></HTML>");
3795 static void create_cache_file(void)
3797 char buf
[6500], curdir
[MAX_PATH
];
3801 file
= CreateFileA(test_txtA
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
3802 FILE_ATTRIBUTE_NORMAL
, NULL
);
3803 ok(file
!= INVALID_HANDLE_VALUE
, "CreateFile failed\n");
3804 if(file
== INVALID_HANDLE_VALUE
)
3807 memset(buf
, 'X', sizeof(buf
));
3808 WriteFile(file
, buf
, sizeof(buf
), &size
, NULL
);
3811 memset(curdir
, 0, sizeof(curdir
));
3812 GetCurrentDirectoryA(MAX_PATH
, curdir
);
3813 lstrcatA(curdir
, "\\");
3814 lstrcatA(curdir
, test_txtA
);
3816 MultiByteToWideChar(CP_ACP
, 0, curdir
, -1, cache_file_name
, MAX_PATH
);
3819 static void test_ReportResult(HRESULT exhres
)
3821 IMoniker
*mon
= NULL
;
3822 IBindCtx
*bctx
= NULL
;
3823 IUnknown
*unk
= (void*)0xdeadbeef;
3826 init_bind_test(ABOUT_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
3827 binding_hres
= exhres
;
3829 hres
= CreateURLMoniker(NULL
, about_blankW
, &mon
);
3830 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
3832 SET_EXPECT(QueryInterface_IServiceProvider
);
3833 hres
= CreateAsyncBindCtx(0, (IBindStatusCallback
*)&bsc
, NULL
, &bctx
);
3834 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
3835 CHECK_CALLED(QueryInterface_IServiceProvider
);
3837 SET_EXPECT(QueryInterface_IBindStatusCallbackEx
);
3838 SET_EXPECT(GetBindInfo
);
3839 SET_EXPECT(QueryInterface_IInternetProtocol
);
3840 SET_EXPECT(OnStartBinding
);
3841 if(is_urlmon_protocol(test_protocol
))
3842 SET_EXPECT(SetPriority
);
3845 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
3846 if(SUCCEEDED(exhres
))
3847 ok(hres
== S_OK
|| hres
== MK_S_ASYNCHRONOUS
, "BindToStorage failed: %08x\n", hres
);
3849 ok(hres
== exhres
|| hres
== MK_S_ASYNCHRONOUS
,
3850 "BindToStorage failed: %08x, expected %08x or MK_S_ASYNCHRONOUS\n", hres
, exhres
);
3852 CLEAR_CALLED(QueryInterface_IBindStatusCallbackEx
); /* IE 8 */
3853 CHECK_CALLED(GetBindInfo
);
3854 CHECK_CALLED(QueryInterface_IInternetProtocol
);
3855 CHECK_CALLED(OnStartBinding
);
3856 if(is_urlmon_protocol(test_protocol
))
3857 CLEAR_CALLED(SetPriority
); /* Not called by IE11 */
3858 CHECK_CALLED(Start
);
3860 ok(unk
== NULL
, "unk=%p\n", unk
);
3862 IBindCtx_Release(bctx
);
3863 IMoniker_Release(mon
);
3866 static void test_BindToStorage_fail(void)
3868 IMoniker
*mon
= NULL
;
3869 IBindCtx
*bctx
= NULL
;
3873 hres
= CreateURLMoniker(NULL
, about_blankW
, &mon
);
3874 ok(hres
== S_OK
, "CreateURLMoniker failed: %08x\n", hres
);
3878 hres
= pCreateAsyncBindCtxEx(NULL
, 0, NULL
, NULL
, &bctx
, 0);
3879 ok(hres
== S_OK
, "CreateAsyncBindCtxEx failed: %08x\n", hres
);
3881 unk
= (void*)0xdeadbeef;
3882 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
3883 ok(hres
== MK_E_SYNTAX
|| hres
== INET_E_DATA_NOT_AVAILABLE
,
3884 "hres=%08x, expected MK_E_SYNTAX or INET_E_DATA_NOT_AVAILABLE\n", hres
);
3885 ok(unk
== NULL
, "got %p\n", unk
);
3887 IBindCtx_Release(bctx
);
3889 IMoniker_Release(mon
);
3891 test_ReportResult(E_NOTIMPL
);
3892 test_ReportResult(S_FALSE
);
3895 static void test_StdURLMoniker(void)
3897 IMoniker
*mon
, *async_mon
;
3898 LPOLESTR display_name
;
3903 hres
= CoCreateInstance(&IID_IInternet
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
3904 &IID_IMoniker
, (void**)&mon
);
3905 ok(hres
== S_OK
, "Could not create IInternet instance: %08x\n", hres
);
3909 hres
= IMoniker_QueryInterface(mon
, &IID_IAsyncMoniker
, (void**)&async_mon
);
3910 ok(hres
== S_OK
, "Could not get IAsyncMoniker iface: %08x\n", hres
);
3911 ok(mon
== async_mon
, "mon != async_mon\n");
3912 IMoniker_Release(async_mon
);
3914 hres
= IMoniker_GetDisplayName(mon
, NULL
, NULL
, &display_name
);
3915 ok(hres
== E_OUTOFMEMORY
, "GetDisplayName failed: %08x, expected E_OUTOFMEMORY\n", hres
);
3918 IUriContainer
*uri_container
;
3921 hres
= IMoniker_QueryInterface(mon
, &IID_IUriContainer
, (void**)&uri_container
);
3922 ok(hres
== S_OK
, "Could not get IUriMoniker iface: %08x\n", hres
);
3925 uri
= (void*)0xdeadbeef;
3926 hres
= IUriContainer_GetIUri(uri_container
, &uri
);
3927 ok(hres
== S_FALSE
, "GetIUri failed: %08x\n", hres
);
3928 ok(!uri
, "uri = %p, expected NULL\n", uri
);
3930 IUriContainer_Release(uri_container
);
3933 SET_EXPECT(QueryInterface_IServiceProvider
);
3934 hres
= CreateAsyncBindCtx(0, (IBindStatusCallback
*)&bsc
, NULL
, &bctx
);
3935 ok(hres
== S_OK
, "CreateAsyncBindCtx failed: %08x\n\n", hres
);
3936 CHECK_CALLED(QueryInterface_IServiceProvider
);
3938 if(pCreateUri
) { /* Skip these tests on old IEs */
3939 unk
= (void*)0xdeadbeef;
3940 hres
= IMoniker_BindToStorage(mon
, bctx
, NULL
, &IID_IStream
, (void**)&unk
);
3941 ok(hres
== MK_E_SYNTAX
, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres
);
3942 ok(!unk
, "unk = %p\n", unk
);
3944 unk
= (void*)0xdeadbeef;
3945 hres
= IMoniker_BindToObject(mon
, bctx
, NULL
, &IID_IUnknown
, (void**)&unk
);
3946 ok(hres
== MK_E_SYNTAX
, "BindToStorage failed: %08x, expected MK_E_SYNTAX\n", hres
);
3947 ok(!unk
, "unk = %p\n", unk
);
3950 IMoniker_Release(mon
);
3953 static void register_protocols(void)
3955 IInternetSession
*session
;
3958 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
3960 hres
= CoInternetGetSession(0, &session
, 0);
3961 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
3965 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
3966 winetestW
, 0, NULL
, 0);
3967 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
3969 IInternetSession_Release(session
);
3972 static BOOL
can_do_https(void)
3974 HINTERNET ses
, con
, req
;
3977 ses
= InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG
, NULL
, NULL
, 0);
3978 ok(ses
!= NULL
, "InternetOpen failed\n");
3980 con
= InternetConnectA(ses
, "test.winehq.org", INTERNET_DEFAULT_HTTPS_PORT
,
3981 NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
3982 ok(con
!= NULL
, "InternetConnect failed\n");
3984 req
= HttpOpenRequestA(con
, "GET", "/tests/hello.html", NULL
, NULL
, NULL
,
3985 INTERNET_FLAG_SECURE
, 0);
3986 ok(req
!= NULL
, "HttpOpenRequest failed\n");
3988 ret
= HttpSendRequestA(req
, NULL
, 0, NULL
, 0);
3989 ok(ret
|| broken(GetLastError() == ERROR_INTERNET_CANNOT_CONNECT
)
3990 || broken(GetLastError() == ERROR_INTERNET_SECURITY_CHANNEL_ERROR
) /* WinXP */,
3991 "request failed: %u\n", GetLastError());
3993 InternetCloseHandle(req
);
3994 InternetCloseHandle(con
);
3995 InternetCloseHandle(ses
);
4003 hurlmon
= GetModuleHandleA("urlmon.dll");
4004 pCreateAsyncBindCtxEx
= (void*) GetProcAddress(hurlmon
, "CreateAsyncBindCtxEx");
4006 if(!GetProcAddress(hurlmon
, "CompareSecurityIds")) {
4007 win_skip("Too old IE\n");
4011 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
4013 win_skip("IUri not supported\n");
4015 complete_event
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
4016 complete_event2
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
4017 thread_id
= GetCurrentThreadId();
4019 create_cache_file();
4020 register_protocols();
4024 trace("test CreateAsyncBindCtx...\n");
4025 test_CreateAsyncBindCtx();
4027 trace("test CreateAsyncBindCtxEx...\n");
4028 test_CreateAsyncBindCtxEx();
4030 trace("test RegisterBindStatusCallback...\n");
4031 if(test_RegisterBindStatusCallback()) {
4032 trace("test BindToStorage failures...\n");
4033 test_BindToStorage_fail();
4035 trace("synchronous http test (COM not initialised)...\n");
4036 test_BindToStorage(HTTP_TEST
, 0, TYMED_ISTREAM
);
4040 trace("test StdURLMoniker...\n");
4041 test_StdURLMoniker();
4043 trace("test URLMonikerComposeWith...\n");
4044 test_MonikerComposeWith();
4046 trace("synchronous http test...\n");
4047 test_BindToStorage(HTTP_TEST
, 0, TYMED_ISTREAM
);
4049 trace("emulated synchronous http test (to file)...\n");
4050 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
, TYMED_FILE
);
4052 trace("synchronous http test (to object)...\n");
4053 test_BindToObject(HTTP_TEST
, 0, S_OK
);
4055 trace("emulated synchronous http test (with cache)...\n");
4056 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
|BINDTEST_USE_CACHE
, TYMED_ISTREAM
);
4058 trace("emulated synchronous http test (with cache, no read)...\n");
4059 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
|BINDTEST_USE_CACHE
|BINDTEST_NO_CALLBACK_READ
, TYMED_ISTREAM
);
4061 trace("synchronous http test (with cache, no read)...\n");
4062 test_BindToStorage(HTTP_TEST
, BINDTEST_USE_CACHE
|BINDTEST_NO_CALLBACK_READ
, TYMED_ISTREAM
);
4064 trace("synchronous file test...\n");
4065 test_BindToStorage(FILE_TEST
, 0, TYMED_ISTREAM
);
4067 trace("emulated synchronous file test (to file)...\n");
4068 test_BindToStorage(FILE_TEST
, BINDTEST_EMULATE
, TYMED_FILE
);
4070 trace("synchronous file test (to object)...\n");
4071 test_BindToObject(FILE_TEST
, 0, S_OK
);
4073 trace("bind to an object of not registered MIME type...\n");
4074 create_file("test.winetest", "\x01\x02\x03xxxxxxxxxxxxxxxxxxxxxxxxx");
4075 test_BindToObject(FILE_TEST
, 0, REGDB_E_CLASSNOTREG
);
4078 trace("file test (no callback)...\n");
4079 test_BindToStorage(FILE_TEST
, BINDTEST_NO_CALLBACK
, TYMED_ISTREAM
);
4081 if(can_do_https()) {
4082 trace("synchronous https test (invalid CN, dialog)\n");
4083 onsecurityproblem_hres
= S_FALSE
;
4084 http_is_first
= TRUE
;
4085 test_BindToStorage(HTTPS_TEST
, BINDTEST_INVALID_CN
, TYMED_ISTREAM
);
4087 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
4089 trace("asynchronous https test (invalid CN, fail)\n");
4090 onsecurityproblem_hres
= E_FAIL
;
4091 test_BindToStorage(HTTPS_TEST
, BINDTEST_INVALID_CN
, TYMED_ISTREAM
);
4093 trace("asynchronous https test (invalid CN, accept)\n");
4094 onsecurityproblem_hres
= S_OK
;
4095 test_BindToStorage(HTTPS_TEST
, BINDTEST_INVALID_CN
, TYMED_ISTREAM
);
4097 trace("asynchronous https test (invalid CN, dialog 2)\n");
4098 onsecurityproblem_hres
= S_FALSE
;
4099 test_BindToStorage(HTTPS_TEST
, BINDTEST_INVALID_CN
, TYMED_ISTREAM
);
4100 invalid_cn_accepted
= FALSE
;
4102 trace("asynchronous https test...\n");
4103 test_BindToStorage(HTTPS_TEST
, 0, TYMED_ISTREAM
);
4105 win_skip("Skipping https testt\n");
4108 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
| BINDF_PULLDATA
;
4110 trace("winetest test (async switch)...\n");
4111 test_BindToStorage(WINETEST_TEST
, BINDTEST_EMULATE
|BINDTEST_ASYNC_SWITCH
, TYMED_ISTREAM
);
4113 trace("about test (no read)...\n");
4114 test_BindToStorage(ABOUT_TEST
, BINDTEST_NO_CALLBACK_READ
, TYMED_ISTREAM
);
4116 trace("http test...\n");
4117 test_BindToStorage(HTTP_TEST
, 0, TYMED_ISTREAM
);
4119 trace("http test (to file)...\n");
4120 test_BindToStorage(HTTP_TEST
, 0, TYMED_FILE
);
4122 trace("http test (to object)...\n");
4123 test_BindToObject(HTTP_TEST
, 0, S_OK
);
4125 trace("http test (short response)...\n");
4126 test_BindToStorage(HTTP_TEST
, BINDTEST_HTTPRESPONSE
|BINDTEST_ALLOW_FINDINGRESOURCE
, TYMED_ISTREAM
);
4128 trace("http test (short response, to object)...\n");
4129 test_BindToObject(HTTP_TEST
, 0, S_OK
);
4131 trace("http test (abort start binding E_NOTIMPL)...\n");
4132 abort_hres
= E_NOTIMPL
;
4133 test_BindToStorage(HTTP_TEST
, BINDTEST_ABORT_START
, TYMED_FILE
);
4135 trace("http test (abort start binding E_ABORT)...\n");
4136 abort_hres
= E_ABORT
;
4137 test_BindToStorage(HTTP_TEST
, BINDTEST_ABORT_START
, TYMED_FILE
);
4139 trace("http test (abort progress)...\n");
4140 test_BindToStorage(HTTP_TEST
, BINDTEST_ABORT_PROGRESS
|BINDTEST_ALLOW_FINDINGRESOURCE
, TYMED_FILE
);
4142 trace("emulated http test...\n");
4143 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4145 trace("emulated http test (to object)...\n");
4146 test_BindToObject(HTTP_TEST
, BINDTEST_EMULATE
, S_OK
);
4148 trace("emulated http test (to object, redirect)...\n");
4149 test_BindToObject(HTTP_TEST
, BINDTEST_EMULATE
|BINDTEST_REDIRECT
, S_OK
);
4151 trace("emulated http test (to file)...\n");
4152 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
, TYMED_FILE
);
4154 trace("emulated http test (redirect)...\n");
4155 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
|BINDTEST_REDIRECT
, TYMED_ISTREAM
);
4157 trace("emulated http test (with cache)...\n");
4158 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
|BINDTEST_USE_CACHE
, TYMED_ISTREAM
);
4160 trace("winetest test (no callback)...\n");
4161 test_BindToStorage(WINETEST_TEST
, BINDTEST_EMULATE
|BINDTEST_NO_CALLBACK
|BINDTEST_USE_CACHE
, TYMED_ISTREAM
);
4163 trace("emulated https test...\n");
4164 test_BindToStorage(HTTPS_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4166 trace("about test...\n");
4167 test_BindToStorage(ABOUT_TEST
, 0, TYMED_ISTREAM
);
4169 trace("about test (to file)...\n");
4170 test_BindToStorage(ABOUT_TEST
, 0, TYMED_FILE
);
4172 trace("about test (to object)...\n");
4173 test_BindToObject(ABOUT_TEST
, 0, S_OK
);
4175 trace("emulated about test...\n");
4176 test_BindToStorage(ABOUT_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4178 trace("emulated about test (to file)...\n");
4179 test_BindToStorage(ABOUT_TEST
, BINDTEST_EMULATE
, TYMED_FILE
);
4181 trace("emulated about test (to object)...\n");
4182 test_BindToObject(ABOUT_TEST
, BINDTEST_EMULATE
, S_OK
);
4184 trace("emulalated test reporting result in read...\n");
4185 test_BindToStorage(WINETEST_SYNC_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4187 trace("file test...\n");
4188 test_BindToStorage(FILE_TEST
, 0, TYMED_ISTREAM
);
4190 trace("file test (to file)...\n");
4191 test_BindToStorage(FILE_TEST
, 0, TYMED_FILE
);
4193 trace("file test (to object)...\n");
4194 test_BindToObject(FILE_TEST
, 0, S_OK
);
4196 trace("emulated file test...\n");
4197 test_BindToStorage(FILE_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4199 trace("emulated file test (to file)...\n");
4200 test_BindToStorage(FILE_TEST
, BINDTEST_EMULATE
, TYMED_FILE
);
4202 trace("emulated file test (to object)...\n");
4203 test_BindToObject(FILE_TEST
, BINDTEST_EMULATE
, S_OK
);
4205 trace("emulated its test...\n");
4206 test_BindToStorage(ITS_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4208 trace("emulated its test (to file)...\n");
4209 test_BindToStorage(ITS_TEST
, BINDTEST_EMULATE
, TYMED_FILE
);
4211 trace("emulated mk test...\n");
4212 test_BindToStorage(MK_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4214 trace("test URLDownloadToFile for file protocol...\n");
4215 test_URLDownloadToFile(FILE_TEST
, FALSE
);
4217 trace("test URLDownloadToFile for emulated file protocol...\n");
4218 test_URLDownloadToFile(FILE_TEST
, TRUE
);
4220 trace("test URLDownloadToFile for http protocol...\n");
4221 test_URLDownloadToFile(HTTP_TEST
, FALSE
);
4223 trace("test URLDownloadToFile abort...\n");
4224 test_URLDownloadToFile_abort();
4226 trace("test emulated http abort...\n");
4227 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
|BINDTEST_ABORT
, TYMED_ISTREAM
);
4229 bindf
|= BINDF_NOWRITECACHE
;
4231 trace("ftp test...\n");
4232 test_BindToStorage(FTP_TEST
, 0, TYMED_ISTREAM
);
4234 trace("test failures...\n");
4235 test_BindToStorage_fail();
4237 bindf
= BINDF_ASYNCHRONOUS
| BINDF_ASYNCSTORAGE
;
4238 only_check_prot_args
= TRUE
; /* Fail after checking arguments to Protocol_Start */
4240 trace("check emulated http protocol arguments...\n");
4241 test_BindToStorage(HTTP_TEST
, BINDTEST_EMULATE
, TYMED_ISTREAM
);
4244 DeleteFileA(test_file
);
4245 DeleteFileA(test_txtA
);
4246 CloseHandle(complete_event
);
4247 CloseHandle(complete_event2
);