Author: akhaldi
Date: Sun Sep 17 22:58:07 2017
New Revision: 75903
URL:
http://svn.reactos.org/svn/reactos?rev=75903&view=rev
Log:
[URLMON_WINETEST] Sync with Wine Staging 2.16. CORE-13762
Modified:
trunk/rostests/winetests/urlmon/protocol.c
Modified: trunk/rostests/winetests/urlmon/protocol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/urlmon/protocol…
==============================================================================
--- trunk/rostests/winetests/urlmon/protocol.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/urlmon/protocol.c [iso-8859-1] Sun Sep 17 22:58:07 2017
@@ -99,6 +99,7 @@
DEFINE_EXPECT(QueryService_HttpNegotiate);
DEFINE_EXPECT(QueryService_InternetProtocol);
DEFINE_EXPECT(QueryService_HttpSecurity);
+DEFINE_EXPECT(QueryService_IBindCallbackRedirect);
DEFINE_EXPECT(QueryInterface_IWinInetInfo);
DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo);
DEFINE_EXPECT(BeginningTransaction);
@@ -128,6 +129,7 @@
DEFINE_EXPECT(MimeFilter_Continue);
DEFINE_EXPECT(Stream_Seek);
DEFINE_EXPECT(Stream_Read);
+DEFINE_EXPECT(Redirect);
static const WCHAR wszIndexHtml[] =
{'i','n','d','e','x','.','h','t','m','l',0};
static const WCHAR index_url[] =
@@ -145,9 +147,9 @@
static HRESULT expect_hrResult;
static LPCWSTR file_name, http_url, expect_wsz;
static IInternetProtocol *async_protocol = NULL;
-static BOOL first_data_notif, http_is_first, test_redirect;
+static BOOL first_data_notif, http_is_first, test_redirect, redirect_on_continue;
static int prot_state, read_report_data, post_stream_read;
-static DWORD bindf, ex_priority , pi;
+static DWORD bindf, ex_priority , pi, bindinfo_options;
static IInternetProtocol *binding_protocol, *filtered_protocol;
static IInternetBindInfo *prot_bind_info;
static IInternetProtocolSink *binding_sink, *filtered_sink;
@@ -372,6 +374,39 @@
static IHttpNegotiate2 http_negotiate = { &HttpNegotiateVtbl };
+static HRESULT WINAPI BindCallbackRedirect_QueryInterface(IBindCallbackRedirect *iface,
REFIID riid, void **ppv)
+{
+ ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
+ *ppv = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI BindCallbackRedirect_AddRef(IBindCallbackRedirect *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI BindCallbackRedirect_Release(IBindCallbackRedirect *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI BindCallbackRedirect_Redirect(IBindCallbackRedirect *iface, const
WCHAR *url, VARIANT_BOOL *cancel)
+{
+ CHECK_EXPECT(Redirect);
+ *cancel = VARIANT_FALSE;
+ return S_OK;
+}
+
+static const IBindCallbackRedirectVtbl BindCallbackRedirectVtbl = {
+ BindCallbackRedirect_QueryInterface,
+ BindCallbackRedirect_AddRef,
+ BindCallbackRedirect_Release,
+ BindCallbackRedirect_Redirect
+};
+
+static IBindCallbackRedirect redirect_callback = { &BindCallbackRedirectVtbl };
+
static HRESULT QueryInterface(REFIID,void**);
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID
riid, void **ppv)
@@ -407,6 +442,13 @@
ok(IsEqualGUID(&IID_IHttpSecurity, riid), "unexpected riid\n");
CHECK_EXPECT(QueryService_HttpSecurity);
return IHttpSecurity_QueryInterface(&http_security, riid, ppv);
+ }
+
+ if(IsEqualGUID(&IID_IBindCallbackRedirect, guidService)) {
+ CHECK_EXPECT(QueryService_IBindCallbackRedirect);
+ ok(IsEqualGUID(&IID_IBindCallbackRedirect, riid), "riid = %s\n",
wine_dbgstr_guid(riid));
+ *ppv = &redirect_callback;
+ return S_OK;
}
if(IsEqualGUID(&IID_IGetBindHandle, guidService)) {
@@ -600,7 +642,7 @@
todo_wine CHECK_CALLED(ReportProgress_SENDINGREQUEST);
else if (tested_protocol != HTTPS_TEST)
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
- if(test_redirect)
+ if(test_redirect && !(bindinfo_options &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))
CHECK_CALLED(ReportProgress_REDIRECTING);
state = test_async_req ? STATE_SENDINGREQUEST : STATE_STARTDOWNLOADING;
}
@@ -611,7 +653,8 @@
SET_EXPECT(ReportProgress_SENDINGREQUEST);
break;
case STATE_STARTDOWNLOADING:
- if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
+ if((tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST)
+ && (!test_redirect || !(bindinfo_options &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))) {
SET_EXPECT(OnResponse);
if(tested_protocol == HTTPS_TEST || test_redirect || test_abort ||
empty_file)
SET_EXPECT(ReportProgress_ACCEPTRANGES);
@@ -624,13 +667,13 @@
break;
}
- if(state != STATE_SENDINGREQUEST)
+ if(state != STATE_SENDINGREQUEST && (!test_redirect || !(bindinfo_options
& BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)))
SET_EXPECT(ReportData);
hres = IInternetProtocol_Continue(async_protocol, protocol_data);
ok(hres == S_OK, "Continue failed: %08x\n", hres);
if(tested_protocol == FTP_TEST || security_problem)
CLEAR_CALLED(ReportData);
- else if(state != STATE_SENDINGREQUEST)
+ else if(state != STATE_SENDINGREQUEST && (!test_redirect ||
!(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)))
CHECK_CALLED(ReportData);
switch(state) {
@@ -640,10 +683,10 @@
state = STATE_STARTDOWNLOADING;
break;
case STATE_STARTDOWNLOADING:
- if (! security_problem)
- {
+ if(!security_problem) {
state = STATE_DOWNLOADING;
- if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST) {
+ if((tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST)
+ && (!test_redirect || !(bindinfo_options &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))) {
CHECK_CALLED(OnResponse);
if(tested_protocol == HTTPS_TEST || empty_file)
CHECK_CALLED(ReportProgress_ACCEPTRANGES);
@@ -1093,13 +1136,17 @@
exit(1);
}
#endif
- if(SUCCEEDED(hrResult) || tested_protocol == FTP_TEST || test_abort)
+ if(SUCCEEDED(hrResult) || tested_protocol == FTP_TEST || test_abort || hrResult ==
INET_E_REDIRECT_FAILED)
ok(dwError == ERROR_SUCCESS, "dwError = %d, expected ERROR_SUCCESS\n",
dwError);
else
ok(dwError != ERROR_SUCCESS ||
broken(tested_protocol == MK_TEST), /* WinME and NT4 */
"dwError == ERROR_SUCCESS\n");
- ok(!szResult, "szResult != NULL\n");
+
+ if(hrResult == INET_E_REDIRECT_FAILED)
+ ok(!strcmp_wa(szResult, "http://test.winehq.org/tests/hello.html"),
"szResult = %s\n", wine_dbgstr_w(szResult));
+ else
+ ok(!szResult, "szResult = %s\n", wine_dbgstr_w(szResult));
if(direct_read)
SET_EXPECT(ReportData); /* checked after main loop */
@@ -1328,6 +1375,7 @@
cbSize = pbindinfo->cbSize;
memset(pbindinfo, 0, cbSize);
pbindinfo->cbSize = cbSize;
+ pbindinfo->dwOptions = bindinfo_options;
if(http_post_test)
{
@@ -1343,21 +1391,6 @@
memcpy(data, post_data, sizeof(post_data));
U(pbindinfo->stgmedData).hGlobal = data;
}else {
- IStream *post_stream;
- HGLOBAL data;
- HRESULT hres;
-
- if(0) {
- /* Must be GMEM_FIXED, GMEM_MOVABLE does not work properly */
- data = GlobalAlloc(GPTR, sizeof(post_data));
- memcpy(data, post_data, sizeof(post_data));
- U(pbindinfo->stgmedData).hGlobal = data;
-
- hres = CreateStreamOnHGlobal(data, FALSE, &post_stream);
- ok(hres == S_OK, "CreateStreamOnHGlobal failed: %08x\n", hres);
-
- U(pbindinfo->stgmedData).pstm =post_stream;/* &Stream; */
- }
U(pbindinfo->stgmedData).pstm = &Stream;
}
}
@@ -1567,6 +1600,7 @@
static DWORD WINAPI thread_proc(PVOID arg)
{
+ BOOL redirect_only = redirect_on_continue;
HRESULT hres;
memset(&protocoldata, -1, sizeof(protocoldata));
@@ -1596,6 +1630,11 @@
hres = IInternetProtocolSink_Switch(binding_sink, &protocoldata);
CHECK_CALLED(Switch);
ok(hres == S_OK, "Switch failed: %08x\n", hres);
+
+ if(redirect_only) {
+ prot_state = 0;
+ return 0;
+ }
if(!short_read) {
prot_state = 2;
@@ -1663,8 +1702,14 @@
memset(&bindinfo, 0, sizeof(bindinfo));
bindinfo.cbSize = sizeof(bindinfo);
memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo));
+ if(test_redirect)
+ exp_bindinfo.dwOptions = bindinfo_options;
SET_EXPECT(GetBindInfo);
+ if(redirect_on_continue && (bindinfo_options &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))
+ SET_EXPECT(QueryService_IBindCallbackRedirect);
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo);
+ if(redirect_on_continue && (bindinfo_options &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))
+ CHECK_CALLED(QueryService_IBindCallbackRedirect);
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
CHECK_CALLED(GetBindInfo);
ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n",
@@ -1848,6 +1893,35 @@
IServiceProvider *service_provider;
IHttpNegotiate *http_negotiate;
static const WCHAR header[] = {'?',0};
+ static const WCHAR redirect_urlW[] =
{'h','t','t','p',':','/','/','t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',
+
'/','t','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0};
+
+ if(redirect_on_continue) {
+ redirect_on_continue = FALSE;
+
+ if(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)
+ SET_EXPECT(Redirect);
+ SET_EXPECT(ReportProgress_REDIRECTING);
+ SET_EXPECT(Terminate);
+ SET_EXPECT(QueryService_InternetProtocol);
+ SET_EXPECT(CreateInstance);
+ SET_EXPECT(ReportProgress_PROTOCOLCLASSID);
+ SET_EXPECT(SetPriority);
+ SET_EXPECT(Start);
+ hres = IInternetProtocolSink_ReportResult(binding_sink,
INET_E_REDIRECT_FAILED, ERROR_SUCCESS, redirect_urlW);
+ ok(hres == S_OK, "ReportResult failed: %08x\n", hres);
+ if(bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS)
+ CHECK_CALLED(Redirect);
+ CHECK_CALLED(ReportProgress_REDIRECTING);
+ CHECK_CALLED(Terminate);
+ CHECK_CALLED(QueryService_InternetProtocol);
+ CHECK_CALLED(CreateInstance);
+ CHECK_CALLED(ReportProgress_PROTOCOLCLASSID);
+ todo_wine CHECK_NOT_CALLED(SetPriority);
+ CHECK_CALLED(Start);
+
+ return S_OK;
+ }
hres = IInternetProtocolSink_QueryInterface(binding_sink,
&IID_IServiceProvider,
(void**)&service_provider);
@@ -2283,9 +2357,73 @@
static IInternetProtocolEx MimeProtocol = { &MimeProtocolVtbl };
+static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface,
REFIID riid, void **ppv)
+{
+ ok(0, "unexpected call\n");
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
+{
+ return 2;
+}
+
+static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
+{
+ return 1;
+}
+
+static HRESULT WINAPI InternetProtocolInfo_ParseUrl(IInternetProtocolInfo *iface, LPCWSTR
pwzUrl,
+ PARSEACTION ParseAction, DWORD dwParseFlags, LPWSTR pwzResult, DWORD cchResult,
+ DWORD *pcchResult, DWORD dwReserved)
+{
+ ok(0, "unexpected call %d\n", ParseAction);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InternetProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
+ LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
+ LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InternetProtocolInfo_CompareUrl(IInternetProtocolInfo *iface,
+ LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI InternetProtocolInfo_QueryInfo(IInternetProtocolInfo *iface,
+ LPCWSTR pwzUrl, QUERYOPTION OueryOption, DWORD dwQueryFlags, LPVOID pBuffer,
+ DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved)
+{
+ ok(0, "unexpected call\n");
+ return E_NOTIMPL;
+}
+
+static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl = {
+ InternetProtocolInfo_QueryInterface,
+ InternetProtocolInfo_AddRef,
+ InternetProtocolInfo_Release,
+ InternetProtocolInfo_ParseUrl,
+ InternetProtocolInfo_CombineUrl,
+ InternetProtocolInfo_CompareUrl,
+ InternetProtocolInfo_QueryInfo
+};
+
+static IInternetProtocolInfo protocol_info = { &InternetProtocolInfoVtbl };
+
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void
**ppv)
{
- ok(0, "unexpected call\n");
+ if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
+ *ppv = &protocol_info;
+ return S_OK;
+ }
+
+ ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
return E_NOINTERFACE;
}
@@ -2364,6 +2502,7 @@
#define TEST_EMPTY 0x1000
#define TEST_NOMIME 0x2000
#define TEST_FROMCACHE 0x4000
+#define TEST_DISABLEAUTOREDIRECT 0x8000
static void register_filter(BOOL do_register)
{
@@ -2415,12 +2554,16 @@
wait_for_switch = TRUE;
short_read = (flags & TEST_SHORT_READ) != 0;
http_post_test = TYMED_NULL;
- test_redirect = (flags & TEST_REDIRECT) != 0;
+ redirect_on_continue = test_redirect = (flags & TEST_REDIRECT) != 0;
test_abort = (flags & TEST_ABORT) != 0;
impl_protex = (flags & TEST_IMPLPROTEX) != 0;
empty_file = (flags & TEST_EMPTY) != 0;
bind_from_cache = (flags & TEST_FROMCACHE) != 0;
file_with_hash = FALSE;
+
+ bindinfo_options = 0;
+ if(flags & TEST_DISABLEAUTOREDIRECT)
+ bindinfo_options |= BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS;
register_filter(mimefilter_test);
}
@@ -3022,7 +3165,6 @@
init_test(prot, flags);
http_url = url;
http_post_test = tymed;
-
if(flags & TEST_FROMCACHE)
create_cache_entry(url);
@@ -3060,7 +3202,7 @@
SET_EXPECT(ReportProgress_CONNECTING);
}
SET_EXPECT(ReportProgress_SENDINGREQUEST);
- if(test_redirect)
+ if(test_redirect && !(bindinfo_options &
BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))
SET_EXPECT(ReportProgress_REDIRECTING);
SET_EXPECT(ReportProgress_PROXYDETECTING);
if(prot == HTTP_TEST)
@@ -3083,7 +3225,13 @@
if(!direct_read && !test_abort && !bind_from_cache)
SET_EXPECT(ReportResult);
- expect_hrResult = test_abort ? E_ABORT : S_OK;
+
+ if(flags & TEST_DISABLEAUTOREDIRECT)
+ expect_hrResult = INET_E_REDIRECT_FAILED;
+ else if(test_abort)
+ expect_hrResult = E_ABORT;
+ else
+ expect_hrResult = S_OK;
if(direct_read) {
SET_EXPECT(Switch);
@@ -3233,6 +3381,10 @@
trace("Testing http protocol (redirected)...\n");
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON |
BINDF_NOWRITECACHE;
test_http_protocol_url(redirect_url, HTTP_TEST, TEST_REDIRECT, TYMED_NULL);
+
+ trace("Testing http protocol (redirected, disable auto redirect)...\n");
+ bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON |
BINDF_NOWRITECACHE;
+ test_http_protocol_url(redirect_url, HTTP_TEST, TEST_REDIRECT |
TEST_DISABLEAUTOREDIRECT, TYMED_NULL);
trace("Testing http protocol empty file...\n");
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON |
BINDF_NOWRITECACHE;
@@ -3837,6 +3989,10 @@
test_binding(ITS_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
trace("Testing http binding (mime verification, emulate prot, short read, direct
read)...\n");
test_binding(HTTP_TEST, PI_MIMEVERIFICATION,
TEST_EMULATEPROT|TEST_SHORT_READ|TEST_DIRECT_READ);
+ trace("Testing http binding (mime verification, redirect, emulate
prot)...\n");
+ test_binding(HTTP_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_REDIRECT);
+ trace("Testing http binding (mime verification, redirect, disable auto redirect,
emulate prot)...\n");
+ test_binding(HTTP_TEST, PI_MIMEVERIFICATION,
TEST_EMULATEPROT|TEST_REDIRECT|TEST_DISABLEAUTOREDIRECT);
trace("Testing file binding (mime verification, emulate prot, mime
filter)...\n");
test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER);
trace("Testing http binding (mime verification, emulate prot, mime
filter)...\n");