mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 12:00:45 +00:00
urlmon/tests: Added BindProtocol redirection handling tests.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
be285af54f
commit
86f7c4c8f8
|
@ -94,6 +94,7 @@ DEFINE_EXPECT(GetBindString_ROOTDOC_URL);
|
||||||
DEFINE_EXPECT(QueryService_HttpNegotiate);
|
DEFINE_EXPECT(QueryService_HttpNegotiate);
|
||||||
DEFINE_EXPECT(QueryService_InternetProtocol);
|
DEFINE_EXPECT(QueryService_InternetProtocol);
|
||||||
DEFINE_EXPECT(QueryService_HttpSecurity);
|
DEFINE_EXPECT(QueryService_HttpSecurity);
|
||||||
|
DEFINE_EXPECT(QueryService_IBindCallbackRedirect);
|
||||||
DEFINE_EXPECT(QueryInterface_IWinInetInfo);
|
DEFINE_EXPECT(QueryInterface_IWinInetInfo);
|
||||||
DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo);
|
DEFINE_EXPECT(QueryInterface_IWinInetHttpInfo);
|
||||||
DEFINE_EXPECT(BeginningTransaction);
|
DEFINE_EXPECT(BeginningTransaction);
|
||||||
|
@ -123,6 +124,7 @@ DEFINE_EXPECT(MimeFilter_Switch);
|
||||||
DEFINE_EXPECT(MimeFilter_Continue);
|
DEFINE_EXPECT(MimeFilter_Continue);
|
||||||
DEFINE_EXPECT(Stream_Seek);
|
DEFINE_EXPECT(Stream_Seek);
|
||||||
DEFINE_EXPECT(Stream_Read);
|
DEFINE_EXPECT(Stream_Read);
|
||||||
|
DEFINE_EXPECT(Redirect);
|
||||||
|
|
||||||
static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
|
static const WCHAR wszIndexHtml[] = {'i','n','d','e','x','.','h','t','m','l',0};
|
||||||
static const WCHAR index_url[] =
|
static const WCHAR index_url[] =
|
||||||
|
@ -140,7 +142,7 @@ static const WCHAR gifW[] = {'i','m','a','g','e','/','g','i','f',0};
|
||||||
static HRESULT expect_hrResult;
|
static HRESULT expect_hrResult;
|
||||||
static LPCWSTR file_name, http_url, expect_wsz;
|
static LPCWSTR file_name, http_url, expect_wsz;
|
||||||
static IInternetProtocol *async_protocol = NULL;
|
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 int prot_state, read_report_data, post_stream_read;
|
||||||
static DWORD bindf, ex_priority , pi, bindinfo_options;
|
static DWORD bindf, ex_priority , pi, bindinfo_options;
|
||||||
static IInternetProtocol *binding_protocol, *filtered_protocol;
|
static IInternetProtocol *binding_protocol, *filtered_protocol;
|
||||||
|
@ -367,6 +369,39 @@ static IHttpNegotiate2Vtbl HttpNegotiateVtbl = {
|
||||||
|
|
||||||
static IHttpNegotiate2 http_negotiate = { &HttpNegotiateVtbl };
|
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 QueryInterface(REFIID,void**);
|
||||||
|
|
||||||
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
|
static HRESULT WINAPI ServiceProvider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
|
||||||
|
@ -404,6 +439,13 @@ static HRESULT WINAPI ServiceProvider_QueryService(IServiceProvider *iface, REFG
|
||||||
return IHttpSecurity_QueryInterface(&http_security, riid, ppv);
|
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)) {
|
if(IsEqualGUID(&IID_IGetBindHandle, guidService)) {
|
||||||
trace("QueryService(IID_IGetBindHandle)\n");
|
trace("QueryService(IID_IGetBindHandle)\n");
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
|
@ -1547,6 +1589,7 @@ static HRESULT WINAPI ProtocolEmul_QueryInterface(IInternetProtocolEx *iface, RE
|
||||||
|
|
||||||
static DWORD WINAPI thread_proc(PVOID arg)
|
static DWORD WINAPI thread_proc(PVOID arg)
|
||||||
{
|
{
|
||||||
|
BOOL redirect_only = redirect_on_continue;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
memset(&protocoldata, -1, sizeof(protocoldata));
|
memset(&protocoldata, -1, sizeof(protocoldata));
|
||||||
|
@ -1577,6 +1620,11 @@ static DWORD WINAPI thread_proc(PVOID arg)
|
||||||
CHECK_CALLED(Switch);
|
CHECK_CALLED(Switch);
|
||||||
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
ok(hres == S_OK, "Switch failed: %08x\n", hres);
|
||||||
|
|
||||||
|
if(redirect_only) {
|
||||||
|
prot_state = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(!short_read) {
|
if(!short_read) {
|
||||||
prot_state = 2;
|
prot_state = 2;
|
||||||
if(mimefilter_test)
|
if(mimefilter_test)
|
||||||
|
@ -1643,8 +1691,14 @@ static void protocol_start(IInternetProtocolSink *pOIProtSink, IInternetBindInfo
|
||||||
memset(&bindinfo, 0, sizeof(bindinfo));
|
memset(&bindinfo, 0, sizeof(bindinfo));
|
||||||
bindinfo.cbSize = sizeof(bindinfo);
|
bindinfo.cbSize = sizeof(bindinfo);
|
||||||
memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo));
|
memcpy(&exp_bindinfo, &bindinfo, sizeof(bindinfo));
|
||||||
|
if(test_redirect)
|
||||||
|
exp_bindinfo.dwOptions = bindinfo_options;
|
||||||
SET_EXPECT(GetBindInfo);
|
SET_EXPECT(GetBindInfo);
|
||||||
|
if(redirect_on_continue && (bindinfo_options & BINDINFO_OPTIONS_DISABLEAUTOREDIRECTS))
|
||||||
|
SET_EXPECT(QueryService_IBindCallbackRedirect);
|
||||||
hres = IInternetBindInfo_GetBindInfo(pOIBindInfo, &cbindf, &bindinfo);
|
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);
|
ok(hres == S_OK, "GetBindInfo failed: %08x\n", hres);
|
||||||
CHECK_CALLED(GetBindInfo);
|
CHECK_CALLED(GetBindInfo);
|
||||||
ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n",
|
ok(cbindf == (bindf|BINDF_FROMURLMON), "bindf = %x, expected %x\n",
|
||||||
|
@ -1828,6 +1882,35 @@ static HRESULT WINAPI ProtocolEmul_Continue(IInternetProtocolEx *iface,
|
||||||
IServiceProvider *service_provider;
|
IServiceProvider *service_provider;
|
||||||
IHttpNegotiate *http_negotiate;
|
IHttpNegotiate *http_negotiate;
|
||||||
static const WCHAR header[] = {'?',0};
|
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,
|
hres = IInternetProtocolSink_QueryInterface(binding_sink, &IID_IServiceProvider,
|
||||||
(void**)&service_provider);
|
(void**)&service_provider);
|
||||||
|
@ -2263,12 +2346,76 @@ static const IInternetProtocolExVtbl MimeProtocolVtbl = {
|
||||||
|
|
||||||
static IInternetProtocolEx MimeProtocol = { &MimeProtocolVtbl };
|
static IInternetProtocolEx MimeProtocol = { &MimeProtocolVtbl };
|
||||||
|
|
||||||
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
|
static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
|
||||||
{
|
{
|
||||||
ok(0, "unexpected call\n");
|
ok(0, "unexpected call\n");
|
||||||
return E_NOINTERFACE;
|
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)
|
||||||
|
{
|
||||||
|
if(IsEqualGUID(&IID_IInternetProtocolInfo, riid)) {
|
||||||
|
*ppv = &protocol_info;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok(0, "unexpected call %s\n", wine_dbgstr_guid(riid));
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -2396,7 +2543,7 @@ static void init_test(int prot, DWORD flags)
|
||||||
wait_for_switch = TRUE;
|
wait_for_switch = TRUE;
|
||||||
short_read = (flags & TEST_SHORT_READ) != 0;
|
short_read = (flags & TEST_SHORT_READ) != 0;
|
||||||
http_post_test = TYMED_NULL;
|
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;
|
test_abort = (flags & TEST_ABORT) != 0;
|
||||||
impl_protex = (flags & TEST_IMPLPROTEX) != 0;
|
impl_protex = (flags & TEST_IMPLPROTEX) != 0;
|
||||||
empty_file = (flags & TEST_EMPTY) != 0;
|
empty_file = (flags & TEST_EMPTY) != 0;
|
||||||
|
@ -3831,6 +3978,10 @@ START_TEST(protocol)
|
||||||
test_binding(ITS_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
|
test_binding(ITS_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT);
|
||||||
trace("Testing http binding (mime verification, emulate prot, short read, direct read)...\n");
|
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);
|
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");
|
trace("Testing file binding (mime verification, emulate prot, mime filter)...\n");
|
||||||
test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER);
|
test_binding(FILE_TEST, PI_MIMEVERIFICATION, TEST_EMULATEPROT|TEST_FILTER);
|
||||||
trace("Testing http binding (mime verification, emulate prot, mime filter)...\n");
|
trace("Testing http binding (mime verification, emulate prot, mime filter)...\n");
|
||||||
|
|
Loading…
Reference in a new issue