[URLMON_WINETEST] Sync with Wine Staging 1.7.47. CORE-9924

svn path=/trunk/; revision=68534
This commit is contained in:
Amine Khaldi 2015-07-22 00:37:31 +00:00
parent f8adfa6715
commit 558f064f89
2 changed files with 101 additions and 28 deletions

View file

@ -158,7 +158,7 @@ static PROTOCOLDATA protocoldata, *pdata, continue_protdata;
static DWORD prot_read, filter_state, http_post_test, thread_id;
static BOOL security_problem, test_async_req, impl_protex;
static BOOL async_read_pending, mimefilter_test, direct_read, wait_for_switch, emulate_prot, short_read, test_abort;
static BOOL empty_file, no_mime, bind_from_cache;
static BOOL empty_file, no_mime, bind_from_cache, file_with_hash;
enum {
STATE_CONNECTING,
@ -585,7 +585,8 @@ static void call_continue(PROTOCOLDATA *protocol_data)
{
HRESULT hres;
trace("continue in state %d\n", state);
if (winetest_debug > 1)
trace("continue in state %d\n", state);
if(state == STATE_CONNECTING) {
if(tested_protocol == HTTP_TEST || tested_protocol == HTTPS_TEST || tested_protocol == FTP_TEST) {
@ -766,10 +767,13 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
'0','0','0','0','-','0','0','0','0','-','0','0','0','0','0','0','0','0','0','0','0','0','}',0};
static const WCHAR text_plain[] = {'t','e','x','t','/','p','l','a','i','n',0};
if (ulStatusCode < sizeof(status_names)/sizeof(status_names[0]))
trace( "progress: %s %s\n", status_names[ulStatusCode], wine_dbgstr_w(szStatusText) );
else
trace( "progress: %u %s\n", ulStatusCode, wine_dbgstr_w(szStatusText) );
if (winetest_debug > 1)
{
if (ulStatusCode < sizeof(status_names)/sizeof(status_names[0]))
trace( "progress: %s %s\n", status_names[ulStatusCode], wine_dbgstr_w(szStatusText) );
else
trace( "progress: %u %s\n", ulStatusCode, wine_dbgstr_w(szStatusText) );
}
switch(ulStatusCode) {
case BINDSTATUS_MIMETYPEAVAILABLE:
@ -908,7 +912,8 @@ static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWOR
ok(ulProgress == ulProgressMax, "ulProgress (%d) != ulProgressMax (%d)\n",
ulProgress, ulProgressMax);
ok(ulProgressMax == 13, "ulProgressMax=%d, expected 13\n", ulProgressMax);
if(!file_with_hash)
ok(ulProgressMax == 13, "ulProgressMax=%d, expected 13\n", ulProgressMax);
/* BSCF_SKIPDRAINDATAFORFILEURLS added in IE8 */
if(tested_protocol == FILE_TEST)
ok((grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION)) ||
@ -2397,6 +2402,7 @@ static void init_test(int prot, DWORD flags)
impl_protex = (flags & TEST_IMPLPROTEX) != 0;
empty_file = (flags & TEST_EMPTY) != 0;
bind_from_cache = (flags & TEST_FROMCACHE) != 0;
file_with_hash = FALSE;
register_filter(mimefilter_test);
}
@ -2531,6 +2537,8 @@ static void test_file_protocol_url(LPCWSTR url)
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08x\n", hres);
ok(cb == 2, "cb=%u expected 2\n", cb);
buf[2] = 0;
ok(!memcmp(buf, file_with_hash ? "XX" : "<H", 2), "Unexpected data %s\n", buf);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
ok(hres == S_FALSE, "Read failed: %08x\n", hres);
hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
@ -2565,7 +2573,10 @@ static void test_file_protocol_url(LPCWSTR url)
hres = IInternetProtocol_UnlockRequest(protocol);
ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
ok(hres == S_OK, "Read failed: %08x\n", hres);
if(file_with_hash) /* FIXME: An effect of UnlockRequest call? */
todo_wine ok(hres == S_OK, "Read failed: %08x\n", hres);
else
ok(hres == S_OK, "Read failed: %08x\n", hres);
hres = IInternetProtocol_Terminate(protocol, 0);
ok(hres == S_OK, "Terminate failed: %08x\n", hres);
}
@ -2718,6 +2729,7 @@ static void test_file_protocol(void) {
static const WCHAR wszFile3[] = {'f','i','l','e',':','/','/','/',0};
static const WCHAR wszFile4[] = {'f','i','l','e',':','\\','\\',0};
static const char html_doc[] = "<HTML></HTML>";
static const WCHAR fragmentW[] = {'#','f','r','a','g',0};
trace("Testing file protocol...\n");
init_test(FILE_TEST, 0);
@ -2791,7 +2803,25 @@ static void test_file_protocol(void) {
buf[sizeof(wszFile4)/sizeof(WCHAR)] = '|';
test_file_protocol_url(buf);
/* Fragment part of URL is skipped if the file doesn't exist. */
lstrcatW(buf, fragmentW);
test_file_protocol_url(buf);
/* Fragment part is considered a part of the file name, if the file exsists. */
len = lstrlenW(file_name_buf);
lstrcpyW(file_name_buf+len, fragmentW);
file = CreateFileW(wszIndexHtml, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed\n");
WriteFile(file, "XXX", 3, &size, NULL);
CloseHandle(file);
file_name_buf[len] = 0;
file_with_hash = TRUE;
test_file_protocol_url(buf);
DeleteFileW(wszIndexHtml);
DeleteFileW(file_name_buf);
bindf = 0;
test_file_protocol_fail();

View file

@ -2572,6 +2572,7 @@ static BOOL test_bscholder(IBindStatusCallback *holder)
IHttpNegotiate *http_negotiate, *http_negotiate_serv;
IHttpNegotiate2 *http_negotiate2, *http_negotiate2_serv;
IAuthenticate *authenticate, *authenticate_serv;
IInternetBindInfo *bind_info;
IInternetProtocol *protocol;
BINDINFO bindinfo = {sizeof(bindinfo)};
BOOL ret = TRUE;
@ -2686,6 +2687,16 @@ static BOOL test_bscholder(IBindStatusCallback *holder)
IAuthenticate_Release(authenticate);
IAuthenticate_Release(authenticate_serv);
hres = IBindStatusCallback_QueryInterface(holder, &IID_IInternetBindInfo, (void**)&bind_info);
ok(hres == S_OK || broken(hres == E_NOINTERFACE /* win2k */), "Could not get IInternetBindInfo interface: %08x\n", hres);
if(SUCCEEDED(hres)) {
hres = IInternetBindInfo_GetBindString(bind_info, BINDSTRING_USER_AGENT, &wstr, 1, &dw);
ok(hres == E_NOINTERFACE, "GetBindString(BINDSTRING_USER_AGENT) failed: %08x\n", hres);
IInternetBindInfo_Release(bind_info);
}
SET_EXPECT(OnStopBinding);
hres = IBindStatusCallback_OnStopBinding(holder, S_OK, NULL);
ok(hres == S_OK, "OnStopBinding failed: %08x\n", hres);
@ -3848,6 +3859,32 @@ static void register_protocols(void)
IInternetSession_Release(session);
}
static BOOL can_do_https(void)
{
HINTERNET ses, con, req;
BOOL ret;
ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
ok(ses != NULL, "InternetOpen failed\n");
con = InternetConnectA(ses, "test.winehq.org", INTERNET_DEFAULT_HTTPS_PORT,
NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
ok(con != NULL, "InternetConnect failed\n");
req = HttpOpenRequestA(con, "GET", "/tests/hello.html", NULL, NULL, NULL,
INTERNET_FLAG_SECURE, 0);
ok(req != NULL, "HttpOpenRequest failed\n");
ret = HttpSendRequestA(req, NULL, 0, NULL, 0);
ok(ret || broken(GetLastError() == ERROR_INTERNET_CANNOT_CONNECT),
"request failed: %u\n", GetLastError());
InternetCloseHandle(req);
InternetCloseHandle(con);
InternetCloseHandle(ses);
return ret;
}
START_TEST(url)
{
HMODULE hurlmon;
@ -3927,26 +3964,35 @@ START_TEST(url)
trace("file test (no callback)...\n");
test_BindToStorage(FILE_TEST, BINDTEST_NO_CALLBACK, TYMED_ISTREAM);
trace("synchronous https test (invalid CN, dialog)\n");
onsecurityproblem_hres = S_FALSE;
http_is_first = TRUE;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
if(can_do_https()) {
trace("synchronous https test (invalid CN, dialog)\n");
onsecurityproblem_hres = S_FALSE;
http_is_first = TRUE;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
trace("asynchronous https test (invalid CN, fail)\n");
onsecurityproblem_hres = E_FAIL;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
trace("asynchronous https test (invalid CN, accept)\n");
onsecurityproblem_hres = S_OK;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
trace("asynchronous https test (invalid CN, dialog 2)\n");
onsecurityproblem_hres = S_FALSE;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
invalid_cn_accepted = FALSE;
trace("asynchronous https test...\n");
test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
}else {
win_skip("Skipping https testt\n");
}
bindf = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA;
trace("asynchronous https test (invalid CN, fail)\n");
onsecurityproblem_hres = E_FAIL;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
trace("asynchronous https test (invalid CN, accept)\n");
onsecurityproblem_hres = S_OK;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
trace("asynchronous https test (invalid CN, dialog 2)\n");
onsecurityproblem_hres = S_FALSE;
test_BindToStorage(HTTPS_TEST, BINDTEST_INVALID_CN, TYMED_ISTREAM);
invalid_cn_accepted = FALSE;
trace("winetest test (async switch)...\n");
test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_ASYNC_SWITCH, TYMED_ISTREAM);
@ -4000,9 +4046,6 @@ START_TEST(url)
trace("winetest test (no callback)...\n");
test_BindToStorage(WINETEST_TEST, BINDTEST_EMULATE|BINDTEST_NO_CALLBACK|BINDTEST_USE_CACHE, TYMED_ISTREAM);
trace("asynchronous https test...\n");
test_BindToStorage(HTTPS_TEST, 0, TYMED_ISTREAM);
trace("emulated https test...\n");
test_BindToStorage(HTTPS_TEST, BINDTEST_EMULATE, TYMED_ISTREAM);