[WININET_WINETEST]

* Sync with Wine 1.5.26.

svn path=/trunk/; revision=59062
This commit is contained in:
Amine Khaldi 2013-05-20 21:42:42 +00:00
parent 7f2d1fc323
commit 57540beb53
8 changed files with 1234 additions and 319 deletions

View file

@ -1,8 +1,7 @@
remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502) remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502)
add_definitions( add_definitions(-D__ROS_LONG64__)
-D__ROS_LONG64__)
list(APPEND SOURCE list(APPEND SOURCE
ftp.c ftp.c
@ -16,5 +15,5 @@ list(APPEND SOURCE
add_executable(wininet_winetest ${SOURCE}) add_executable(wininet_winetest ${SOURCE})
target_link_libraries(wininet_winetest wine) target_link_libraries(wininet_winetest wine)
set_module_type(wininet_winetest win32cui) set_module_type(wininet_winetest win32cui)
add_importlibs(wininet_winetest wininet ws2_32 user32 advapi32 msvcrt kernel32 ntdll) add_importlibs(wininet_winetest wininet crypt32 ws2_32 user32 advapi32 msvcrt kernel32 ntdll)
add_cd_file(TARGET wininet_winetest DESTINATION reactos/bin FOR all) add_cd_file(TARGET wininet_winetest DESTINATION reactos/bin FOR all)

View file

@ -30,15 +30,18 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> //#include <stdio.h>
#include <stdlib.h> //#include <stdlib.h>
#include "windef.h" #define WIN32_NO_STATUS
#include "winbase.h" #define _INC_WINDOWS
#include "wininet.h"
#include "winsock.h"
#include "wine/test.h" #include <windef.h>
#include <winbase.h>
#include <wininet.h>
//#include "winsock.h"
#include <wine/test.h>
static BOOL (WINAPI *pFtpCommandA)(HINTERNET,BOOL,DWORD,LPCSTR,DWORD_PTR,HINTERNET*); static BOOL (WINAPI *pFtpCommandA)(HINTERNET,BOOL,DWORD,LPCSTR,DWORD_PTR,HINTERNET*);
@ -257,10 +260,8 @@ static void test_getfile(HINTERNET hFtp, HINTERNET hConnect)
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
/* Zero attributes */ /* Zero attributes */
SetLastError(0xdeadbeef);
bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_existing_non_deadbeef", FALSE, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0); bRet = FtpGetFileA(hFtp, "welcome.msg", "should_be_existing_non_deadbeef", FALSE, 0, FTP_TRANSFER_TYPE_UNKNOWN, 0);
ok ( bRet == TRUE, "Expected FtpGetFileA to succeed\n"); ok ( bRet == TRUE, "Expected FtpGetFileA to succeed\n");
ok (GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
ok (GetFileAttributesA("should_be_existing_non_deadbeef") != INVALID_FILE_ATTRIBUTES, ok (GetFileAttributesA("should_be_existing_non_deadbeef") != INVALID_FILE_ATTRIBUTES,
"Local file should have been created\n"); "Local file should have been created\n");
DeleteFileA("should_be_existing_non_deadbeef"); DeleteFileA("should_be_existing_non_deadbeef");

View file

@ -12,12 +12,12 @@
#define WINE_NOWINSOCK #define WINE_NOWINSOCK
#include <stdarg.h> #include <stdarg.h>
#include "windef.h" #include <windef.h>
#include "winbase.h" #include <winbase.h>
#include "wininet.h" #include <wininet.h>
#include "wininet_test.h" #include "wininet_test.h"
#include "wine/test.h" #include <wine/test.h>
/*********************************************************************** /***********************************************************************
* Compatibility macros * Compatibility macros

File diff suppressed because it is too large Load diff

View file

@ -19,15 +19,17 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <stdio.h>
#include "windef.h" //#include <string.h>
#include "winbase.h"
#include "winuser.h"
#include "wininet.h"
#include "winerror.h"
#include "winreg.h"
#include "wine/test.h" #include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <wininet.h>
//#include "winerror.h"
#include <winreg.h>
#include <wine/test.h>
static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD, DWORD, DWORD, DWORD, static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD, DWORD, DWORD, DWORD,
DWORD, DWORD, DWORD, DWORD); DWORD, DWORD, DWORD, DWORD);
@ -40,6 +42,8 @@ static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR); static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD); static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR); static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
static BOOL (WINAPI *pInternetGetCookieExA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD,LPVOID);
static BOOL (WINAPI *pInternetGetCookieExW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD,LPVOID);
/* ############################### */ /* ############################### */
@ -161,6 +165,12 @@ static void test_InternetQueryOptionA(void)
int retval; int retval;
BOOL res; BOOL res;
SetLastError(0xdeadbeef);
len = 0xdeadbeef;
retval = InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, NULL, &len);
ok(!retval && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got wrong error %x(%u)\n", retval, GetLastError());
ok(len >= sizeof(INTERNET_PROXY_INFO) && len != 0xdeadbeef,"len = %u\n", len);
hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0); hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
ok((hinet != 0x0),"InternetOpen Failed\n"); ok((hinet != 0x0),"InternetOpen Failed\n");
@ -212,6 +222,22 @@ static void test_InternetQueryOptionA(void)
ok(retval == 0,"Got wrong return value %d\n",retval); ok(retval == 0,"Got wrong return value %d\n",retval);
ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err); ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
SetLastError(0xdeadbeef);
len = sizeof(DWORD);
retval = InternetQueryOptionA(hurl,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
err = GetLastError();
ok(retval == 0,"Got wrong return value %d\n",retval);
ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
ok(len == sizeof(DWORD), "len = %d\n", len);
SetLastError(0xdeadbeef);
len = sizeof(DWORD);
retval = InternetQueryOptionA(NULL,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
err = GetLastError();
ok(retval == 0,"Got wrong return value %d\n",retval);
ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
ok(!len, "len = %d\n", len);
InternetCloseHandle(hurl); InternetCloseHandle(hurl);
InternetCloseHandle(hinet); InternetCloseHandle(hinet);
@ -228,6 +254,16 @@ static void test_InternetQueryOptionA(void)
InternetCloseHandle(hinet); InternetCloseHandle(hinet);
val = 12345;
res = InternetSetOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
len = sizeof(val);
res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
ok(val == 12345, "val = %d\n", val);
ok(len == sizeof(val), "len = %d\n", len);
hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0); hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
ok((hinet != 0x0),"InternetOpen Failed\n"); ok((hinet != 0x0),"InternetOpen Failed\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -249,6 +285,28 @@ static void test_InternetQueryOptionA(void)
ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n"); ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError()); ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
len = sizeof(val);
res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
ok(val == 12345, "val = %d\n", val);
ok(len == sizeof(val), "len = %d\n", len);
val = 1;
res = InternetSetOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
len = sizeof(val);
res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
ok(val == 1, "val = %d\n", val);
ok(len == sizeof(val), "len = %d\n", len);
len = sizeof(val);
res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
ok(val == 12345, "val = %d\n", val);
ok(len == sizeof(val), "len = %d\n", len);
InternetCloseHandle(hinet); InternetCloseHandle(hinet);
} }
@ -262,14 +320,14 @@ static void test_max_conns(void)
res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len); res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
ok(res,"Got wrong return value %x\n", res); ok(res,"Got wrong return value %x\n", res);
ok(len == sizeof(val), "got %d\n", len); ok(len == sizeof(val), "got %d\n", len);
ok(val == 2, "got %d\n", val); trace("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", val);
len = sizeof(val); len = sizeof(val);
val = 0xdeadbeef; val = 0xdeadbeef;
res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len); res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len);
ok(res,"Got wrong return value %x\n", res); ok(res,"Got wrong return value %x\n", res);
ok(len == sizeof(val), "got %d\n", len); ok(len == sizeof(val), "got %d\n", len);
ok(val == 4, "got %d\n", val); trace("INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", val);
val = 3; val = 3;
res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)); res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
@ -318,6 +376,11 @@ static void test_complicated_cookie(void)
BOOL ret; BOOL ret;
CHAR buffer[1024]; CHAR buffer[1024];
CHAR user[256];
WCHAR wbuf[1024];
static const WCHAR testing_example_comW[] =
{'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.','e','x','a','m','p','l','e','.','c','o','m',0};
ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com"); ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
ok(ret == TRUE,"InternetSetCookie failed\n"); ok(ret == TRUE,"InternetSetCookie failed\n");
@ -339,8 +402,16 @@ static void test_complicated_cookie(void)
ok(ret == TRUE,"InternetSetCookie failed\n"); ok(ret == TRUE,"InternetSetCookie failed\n");
len = 1024; len = 1024;
ret = InternetGetCookie("http://testing.example.com", NULL, NULL, &len);
ok(ret == TRUE,"InternetGetCookie failed\n");
ok(len == 19, "len = %u\n", len);
len = 1024;
memset(buffer, 0xac, sizeof(buffer));
ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len); ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
ok(ret == TRUE,"InternetGetCookie failed\n"); ok(ret == TRUE,"InternetGetCookie failed\n");
ok(len == 19, "len = %u\n", len);
ok(strlen(buffer) == 18, "strlen(buffer) = %u\n", lstrlenA(buffer));
ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
@ -350,6 +421,32 @@ static void test_complicated_cookie(void)
ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
ok(strstr(buffer,"O=P")==NULL,"O=P present\n"); ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
len = 10;
memset(buffer, 0xac, sizeof(buffer));
ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
ok(len == 19, "len = %u\n", len);
len = 1024;
ret = InternetGetCookieW(testing_example_comW, NULL, NULL, &len);
ok(ret == TRUE,"InternetGetCookieW failed\n");
ok(len == 38, "len = %u\n", len);
len = 1024;
memset(wbuf, 0xac, sizeof(wbuf));
ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
ok(ret == TRUE,"InternetGetCookieW failed\n");
ok(len == 19 || broken(len==18), "len = %u\n", len);
ok(lstrlenW(wbuf) == 18, "strlenW(wbuf) = %u\n", lstrlenW(wbuf));
len = 10;
memset(wbuf, 0xac, sizeof(wbuf));
ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"InternetGetCookieW returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
ok(len == 38, "len = %u\n", len);
len = 1024; len = 1024;
ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len); ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len);
ok(ret == TRUE,"InternetGetCookie failed\n"); ok(ret == TRUE,"InternetGetCookie failed\n");
@ -413,6 +510,7 @@ static void test_complicated_cookie(void)
len = 1024; len = 1024;
ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len); ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len);
ok(ret == TRUE,"InternetGetCookie failed\n"); ok(ret == TRUE,"InternetGetCookie failed\n");
ok(len == 24, "len = %u\n", 24);
ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n"); ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n"); ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n"); ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
@ -421,6 +519,74 @@ static void test_complicated_cookie(void)
ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n"); ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
ok(strstr(buffer,"M=N")==NULL,"M=N present\n"); ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
ok(strstr(buffer,"O=P")==NULL,"O=P present\n"); ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
/* Cookie name argument is not implemented */
len = 1024;
ret = InternetGetCookie("http://testing.example.com/bar/foo", "A", buffer, &len);
ok(ret == TRUE,"InternetGetCookie failed\n");
ok(len == 24, "len = %u\n", 24);
/* test persistent cookies */
ret = InternetSetCookie("http://testing.example.com", NULL, "A=B; expires=Fri, 01-Jan-2038 00:00:00 GMT");
ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
len = sizeof(user);
ret = GetUserName(user, &len);
ok(ret, "GetUserName failed with error %d\n", GetLastError());
for(; len>0; len--)
user[len-1] = tolower(user[len-1]);
sprintf(buffer, "Cookie:%s@testing.example.com/", user);
ret = GetUrlCacheEntryInfo(buffer, NULL, &len);
ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %d\n", GetLastError());
/* remove persistent cookie */
ret = InternetSetCookie("http://testing.example.com", NULL, "A=B");
ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
ret = GetUrlCacheEntryInfo(buffer, NULL, &len);
ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n", GetLastError());
/* try setting cookie for different domain */
ret = InternetSetCookie("http://www.aaa.example.com/bar",NULL,"E=F; domain=different.com");
ok(!ret, "InternetSetCookie succeeded\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %d\n", GetLastError());
ret = InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=example.com.pl");
ok(ret, "InternetSetCookie failed with error: %d\n", GetLastError());
ret = InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=com.pl");
todo_wine ok(!ret, "InternetSetCookie succeeded\n");
}
static void test_cookie_url(void)
{
WCHAR bufw[512];
char buf[512];
DWORD len;
BOOL res;
static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
len = sizeof(buf);
res = InternetGetCookieA("about:blank", NULL, buf, &len);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
len = sizeof(bufw)/sizeof(*bufw);
res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
len = sizeof(buf);
res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
len = sizeof(bufw)/sizeof(*bufw);
res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
"InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
} }
static void test_null(void) static void test_null(void)
@ -496,9 +662,7 @@ static void test_null(void)
ok(r == FALSE, "return wrong\n"); ok(r == FALSE, "return wrong\n");
r = InternetSetCookieW(szServer, NULL, szServer); r = InternetSetCookieW(szServer, NULL, szServer);
todo_wine {
ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n"); ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
}
ok(r == FALSE, "return wrong\n"); ok(r == FALSE, "return wrong\n");
sz = 0; sz = 0;
@ -715,7 +879,6 @@ static void InternetTimeToSystemTimeW_test(void)
static void test_IsDomainLegalCookieDomainW(void) static void test_IsDomainLegalCookieDomainW(void)
{ {
BOOL ret; BOOL ret;
DWORD error;
static const WCHAR empty[] = {0}; static const WCHAR empty[] = {0};
static const WCHAR dot[] = {'.',0}; static const WCHAR dot[] = {'.',0};
static const WCHAR uk[] = {'u','k',0}; static const WCHAR uk[] = {'u','k',0};
@ -723,6 +886,8 @@ static void test_IsDomainLegalCookieDomainW(void)
static const WCHAR dot_com[] = {'.','c','o','m',0}; static const WCHAR dot_com[] = {'.','c','o','m',0};
static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0}; static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0}; static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
static const WCHAR www_gmail_com[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
static const WCHAR www_mail_gmail_com[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0}; static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0}; static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
static const WCHAR co_uk[] = {'c','o','.','u','k',0}; static const WCHAR co_uk[] = {'c','o','.','u','k',0};
@ -730,8 +895,7 @@ static void test_IsDomainLegalCookieDomainW(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(NULL, NULL); ret = pIsDomainLegalCookieDomainW(NULL, NULL);
error = GetLastError(); if (!ret && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
{ {
win_skip("IsDomainLegalCookieDomainW is not implemented\n"); win_skip("IsDomainLegalCookieDomainW is not implemented\n");
return; return;
@ -739,95 +903,59 @@ static void test_IsDomainLegalCookieDomainW(void)
ok(!ret || ok(!ret ||
broken(ret), /* IE6 */ broken(ret), /* IE6 */
"IsDomainLegalCookieDomainW succeeded\n"); "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(com, NULL); ret = pIsDomainLegalCookieDomainW(com, NULL);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(NULL, gmail_com); ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(empty, gmail_com); ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(com, empty); ret = pIsDomainLegalCookieDomainW(com, empty);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(gmail_com, dot); ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == 0xdeadbeef), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(dot, gmail_com); ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == 0xdeadbeef), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(com, com); ret = pIsDomainLegalCookieDomainW(com, com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == 0xdeadbeef, "got %u expected 0xdeadbeef\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(com, dot_com); ret = pIsDomainLegalCookieDomainW(com, dot_com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == 0xdeadbeef), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(dot_com, com); ret = pIsDomainLegalCookieDomainW(dot_com, com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == 0xdeadbeef), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(com, gmail_com); ret = pIsDomainLegalCookieDomainW(com, gmail_com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_SXS_KEY_NOT_FOUND ||
error == ERROR_SUCCESS || /* IE8 on W2K3 */
error == 0xdeadbeef, /* up to IE7 */
"unexpected error: %u\n", error);
ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com); ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
ok(ret, "IsDomainLegalCookieDomainW failed\n"); ok(ret, "IsDomainLegalCookieDomainW failed\n");
ret = pIsDomainLegalCookieDomainW(gmail_com, www_gmail_com);
ok(ret, "IsDomainLegalCookieDomainW failed\n");
ret = pIsDomainLegalCookieDomainW(gmail_com, www_mail_gmail_com);
ok(ret, "IsDomainLegalCookieDomainW failed\n");
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk); ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
error == ERROR_SUCCESS || /* IE8 on W2K3 */
error == 0xdeadbeef, /* up to IE7 */
"unexpected error: %u\n", error);
ret = pIsDomainLegalCookieDomainW(uk, co_uk); ret = pIsDomainLegalCookieDomainW(uk, co_uk);
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
@ -835,6 +963,9 @@ static void test_IsDomainLegalCookieDomainW(void)
ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk); ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ret = pIsDomainLegalCookieDomainW(co_uk, gmail_co_uk);
todo_wine ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk); ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
ok(ret, "IsDomainLegalCookieDomainW failed\n"); ok(ret, "IsDomainLegalCookieDomainW failed\n");
@ -843,11 +974,7 @@ static void test_IsDomainLegalCookieDomainW(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com); ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
error = GetLastError();
ok(!ret, "IsDomainLegalCookieDomainW succeeded\n"); ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
ok(error == ERROR_INVALID_NAME ||
broken(error == 0xdeadbeef), /* IE6 */
"got %u expected ERROR_INVALID_NAME\n", error);
ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com); ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
ok(ret, "IsDomainLegalCookieDomainW failed\n"); ok(ret, "IsDomainLegalCookieDomainW failed\n");
@ -1208,7 +1335,7 @@ static void test_InternetErrorDlg(void)
{ ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO }, { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO },
{ ERROR_INTERNET_INSERT_CDROM , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL }, { ERROR_INTERNET_INSERT_CDROM , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL },
{ ERROR_INTERNET_SEC_CERT_ERRORS , ERROR_CANCELLED, 0 }, { ERROR_INTERNET_SEC_CERT_ERRORS , ERROR_CANCELLED, 0 },
{ ERROR_INTERNET_SEC_CERT_REV_FAILED , ERROR_CANCELLED, FLAG_TODO }, { ERROR_INTERNET_SEC_CERT_REV_FAILED , ERROR_CANCELLED, 0 },
{ ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO }, { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO },
{ ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT , ERROR_CANCELLED, FLAG_TODO }, { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT , ERROR_CANCELLED, FLAG_TODO },
{ ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO }, { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO },
@ -1255,11 +1382,11 @@ static void test_InternetErrorDlg(void)
res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL); res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
if(res == ERROR_CALL_NOT_IMPLEMENTED) if(res == ERROR_CALL_NOT_IMPLEMENTED)
{ {
todo_wine ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i); ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
continue; continue;
} }
else else
todo_wine ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i); ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
/* With a valid req */ /* With a valid req */
if(i == ERROR_INTERNET_NEED_UI) if(i == ERROR_INTERNET_NEED_UI)
@ -1333,11 +1460,6 @@ START_TEST(internet)
HMODULE hdll; HMODULE hdll;
hdll = GetModuleHandleA("wininet.dll"); hdll = GetModuleHandleA("wininet.dll");
if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
win_skip("Too old IE (older than 6.0)\n");
return;
}
pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA"); pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW"); pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA"); pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
@ -1347,11 +1469,19 @@ START_TEST(internet)
pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117); pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW"); pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW"); pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
if(!pInternetGetCookieExW) {
win_skip("Too old IE (older than 6.0)\n");
return;
}
test_InternetCanonicalizeUrlA(); test_InternetCanonicalizeUrlA();
test_InternetQueryOptionA(); test_InternetQueryOptionA();
test_get_cookie(); test_get_cookie();
test_complicated_cookie(); test_complicated_cookie();
test_cookie_url();
test_version(); test_version();
test_null(); test_null();
test_Option_PerConnectionOption(); test_Option_PerConnectionOption();

View file

@ -1,8 +1,5 @@
/* Automatically generated file; DO NOT EDIT!! */ /* Automatically generated file; DO NOT EDIT!! */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define STANDALONE #define STANDALONE
#include "wine/test.h" #include "wine/test.h"

View file

@ -21,16 +21,16 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> //#include <stdio.h>
#include <stdlib.h> //#include <stdlib.h>
#include <string.h> //#include <string.h>
#include "windef.h" #include <windef.h>
#include "winbase.h" #include <winbase.h>
#include "winnls.h" #include <winnls.h>
#include "wininet.h" #include <wininet.h>
#include "wine/test.h" #include <wine/test.h>
#define TEST_URL "http://www.winehq.org/site/about#hi" #define TEST_URL "http://www.winehq.org/site/about#hi"
#define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml" #define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
@ -124,6 +124,9 @@ static const crack_url_test_t crack_url_tests[] = {
{"http://www.winehq.org?test=123", {"http://www.winehq.org?test=123",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 0, 21, 9, 0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 0, 21, 9,
"http", "www.winehq.org", "", "", "", "?test=123"}, "http", "www.winehq.org", "", "", "", "?test=123"},
{"http://www.winehq.org/myscript.php;test=123",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 22, -1, 0,
"http", "www.winehq.org", "", "", "/myscript.php;test=123", ""},
{"file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", {"file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0, 0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0,
"file", "", "", "", "C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", ""}, "file", "", "", "", "C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", ""},
@ -157,6 +160,9 @@ static const crack_url_test_t crack_url_tests[] = {
{"file:///C:/Program%20Files/Atmel/./Asdf.xml", {"file:///C:/Program%20Files/Atmel/./Asdf.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 36, -1, 0, 0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 36, -1, 0,
"file", "", "", "", "C:\\Program Files\\Atmel\\.\\Asdf.xml", ""}, "file", "", "", "", "C:\\Program Files\\Atmel\\.\\Asdf.xml", ""},
{"C:\\file.txt",
0, 1, INTERNET_SCHEME_UNKNOWN, -1, 0, -1, 0, -1, 0, -1, 0, 2, 9, -1, 0,
"C", "", "", "", "\\file.txt", ""}
}; };
static const WCHAR *w_str_of(const char *str) static const WCHAR *w_str_of(const char *str)
@ -538,6 +544,7 @@ static void InternetCrackUrl_test(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
urlComponents.dwStructSize = 0; urlComponents.dwStructSize = 0;
ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents); ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
@ -548,8 +555,25 @@ static void InternetCrackUrl_test(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
urlComponents.dwStructSize = sizeof(urlComponents) + 1; urlComponents.dwStructSize = sizeof(urlComponents) + 1;
ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents); ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n"); ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n"); ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
SetLastError(0xdeadbeef);
memset(&urlComponents, 0, sizeof(urlComponents));
urlComponents.dwStructSize = sizeof(urlComponents);
ret = InternetCrackUrlA("file.txt", 0, 0, &urlComponents);
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n");
SetLastError(0xdeadbeef);
memset(&urlComponents, 0, sizeof(urlComponents));
urlComponents.dwStructSize = sizeof(urlComponents);
ret = InternetCrackUrlA("www.winehq.org", 0, 0, &urlComponents);
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "Expected GLE to represent a failure\n");
} }
static void InternetCrackUrlW_test(void) static void InternetCrackUrlW_test(void)
@ -687,12 +711,10 @@ static void InternetCrackUrlW_test(void)
comp.dwExtraInfoLength = sizeof(extra)/sizeof(extra[0]); comp.dwExtraInfoLength = sizeof(extra)/sizeof(extra[0]);
r = InternetCrackUrlW(url2, 0, 0, &comp); r = InternetCrackUrlW(url2, 0, 0, &comp);
todo_wine {
ok(!r, "InternetCrackUrl should have failed\n"); ok(!r, "InternetCrackUrl should have failed\n");
ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
"InternetCrackUrl should have failed with error ERROR_INTERNET_UNRECOGNIZED_SCHEME instead of error %d\n", "InternetCrackUrl should have failed with error ERROR_INTERNET_UNRECOGNIZED_SCHEME instead of error %d\n",
GetLastError()); GetLastError());
}
/* Test to see whether cracking a URL without a filename initializes urlpart */ /* Test to see whether cracking a URL without a filename initializes urlpart */
urlpart[0]=0xba; urlpart[0]=0xba;
@ -792,7 +814,6 @@ static void InternetCreateUrlA_test(void)
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
ok(len == -1, "Expected len -1, got %d\n", len);
/* test valid lpUrlComponents, empty szUrl /* test valid lpUrlComponents, empty szUrl
* lpdwUrlLength is size of buffer required on exit, including * lpdwUrlLength is size of buffer required on exit, including
@ -1099,6 +1120,47 @@ static void InternetCreateUrlA_test(void)
HeapFree(GetProcessHeap(), 0, szUrl); HeapFree(GetProcessHeap(), 0, szUrl);
} }
static void InternetCanonicalizeUrl_test(void)
{
char src[] = "http://www.winehq.org/%27/ /./>/#> ";
char dst[64];
DWORD dstlen;
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, 0);
ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
/* despite what MSDN says, ICU_BROWSER_MODE seems to be ignored */
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_BROWSER_MODE);
ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
/* ICU_ESCAPE is supposed to be ignored */
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_ESCAPE);
ok(strcmp(dst, "http://www.winehq.org/%27/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_DECODE);
ok(strcmp(dst, "http://www.winehq.org/'/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_ENCODE_PERCENT);
ok(strcmp(dst, "http://www.winehq.org/%2527/%20/%3E/#>") == 0, "Got \"%s\"\n", dst);
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_ENCODE_SPACES_ONLY);
ok(strcmp(dst, "http://www.winehq.org/%27/%20/>/#>") == 0, "Got \"%s\"\n", dst);
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_NO_ENCODE);
ok(strcmp(dst, "http://www.winehq.org/%27/ />/#>") == 0, "Got \"%s\"\n", dst);
dstlen = sizeof(dst);
InternetCanonicalizeUrlA(src, dst, &dstlen, ICU_NO_META);
ok(strcmp(dst, "http://www.winehq.org/%27/%20/./%3E/#>") == 0, "Got \"%s\"\n", dst);
}
START_TEST(url) START_TEST(url)
{ {
int i; int i;
@ -1114,4 +1176,5 @@ START_TEST(url)
InternetCrackUrl_test(); InternetCrackUrl_test();
InternetCrackUrlW_test(); InternetCrackUrlW_test();
InternetCreateUrlA_test(); InternetCreateUrlA_test();
InternetCanonicalizeUrl_test();
} }

View file

@ -19,29 +19,34 @@
*/ */
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> //#include <stdio.h>
#include <stdlib.h> //#include <stdlib.h>
#include "windef.h" #include <windef.h>
#include "winbase.h" #include <winbase.h>
#include "wininet.h" #include <wininet.h>
#include "winineti.h" #include <winineti.h>
#include "wine/test.h" #include <wine/test.h>
#define TEST_URL "http://urlcachetest.winehq.org/index.html" static const char test_url[] = "http://urlcachetest.winehq.org/index.html";
#define TEST_URL1 "Visited: user@http://urlcachetest.winehq.org/index.html" static const WCHAR test_urlW[] = {'h','t','t','p',':','/','/','u','r','l','c','a','c','h','e','t','e','s','t','.',
'w','i','n','e','h','q','.','o','r','g','/','i','n','d','e','x','.','h','t','m','l',0};
static const char test_url1[] = "Visited: user@http://urlcachetest.winehq.org/index.html";
static const char test_hash_collisions1[] = "Visited: http://winehq.org/doc0.html";
static const char test_hash_collisions2[] = "Visited: http://winehq.org/doc75651909.html";
static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR); static BOOL (WINAPI *pDeleteUrlCacheEntryA)(LPCSTR);
static BOOL (WINAPI *pUnlockUrlCacheEntryFileA)(LPCSTR,DWORD); static BOOL (WINAPI *pUnlockUrlCacheEntryFileA)(LPCSTR,DWORD);
static char filenameA[MAX_PATH + 1]; static char filenameA[MAX_PATH + 1];
static char filenameA1[MAX_PATH + 1]; static char filenameA1[MAX_PATH + 1];
static BOOL old_ie = FALSE;
static void check_cache_entry_infoA(const char *returnedfrom, LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo) static void check_cache_entry_infoA(const char *returnedfrom, LPINTERNET_CACHE_ENTRY_INFO lpCacheEntryInfo)
{ {
ok(lpCacheEntryInfo->dwStructSize == sizeof(*lpCacheEntryInfo), "%s: dwStructSize was %d\n", returnedfrom, lpCacheEntryInfo->dwStructSize); ok(lpCacheEntryInfo->dwStructSize == sizeof(*lpCacheEntryInfo), "%s: dwStructSize was %d\n", returnedfrom, lpCacheEntryInfo->dwStructSize);
ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_URL), "%s: lpszSourceUrlName should be %s instead of %s\n", returnedfrom, TEST_URL, lpCacheEntryInfo->lpszSourceUrlName); ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url), "%s: lpszSourceUrlName should be %s instead of %s\n", returnedfrom, test_url, lpCacheEntryInfo->lpszSourceUrlName);
ok(!strcmp(lpCacheEntryInfo->lpszLocalFileName, filenameA), "%s: lpszLocalFileName should be %s instead of %s\n", returnedfrom, filenameA, lpCacheEntryInfo->lpszLocalFileName); ok(!strcmp(lpCacheEntryInfo->lpszLocalFileName, filenameA), "%s: lpszLocalFileName should be %s instead of %s\n", returnedfrom, filenameA, lpCacheEntryInfo->lpszLocalFileName);
ok(!strcmp(lpCacheEntryInfo->lpszFileExtension, "html"), "%s: lpszFileExtension should be html instead of %s\n", returnedfrom, lpCacheEntryInfo->lpszFileExtension); ok(!strcmp(lpCacheEntryInfo->lpszFileExtension, "html"), "%s: lpszFileExtension should be html instead of %s\n", returnedfrom, lpCacheEntryInfo->lpszFileExtension);
} }
@ -66,7 +71,7 @@ static void test_find_url_cache_entriesA(void)
ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %d\n", GetLastError()); ok(hEnumHandle != NULL, "FindFirstUrlCacheEntry failed with error %d\n", GetLastError());
while (TRUE) while (TRUE)
{ {
if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, TEST_URL)) if (!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_url))
{ {
found = TRUE; found = TRUE;
ret = TRUE; ret = TRUE;
@ -113,12 +118,12 @@ static void test_GetUrlCacheEntryInfoExA(void)
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError()); "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, NULL, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, NULL, NULL, 0);
ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfoEx with NULL args failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n"); ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
@ -126,19 +131,31 @@ static void test_GetUrlCacheEntryInfoExA(void)
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0x200); ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
ok(!ret, "GetUrlCacheEntryInfoEx succeeded\n"); ok(!ret, "GetUrlCacheEntryInfoEx succeeded\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError()); "GetUrlCacheEntryInfoEx should have set last error to ERROR_FILE_NOT_FOUND instead of %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0); /* Unicode version of function seems to ignore 0x200 flag */
ret = GetUrlCacheEntryInfoExW(test_urlW, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
ok(ret || broken(old_ie && !ret), "GetUrlCacheEntryInfoExW failed with error %d\n", GetLastError());
ret = GetUrlCacheEntryInfoEx(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo); if (ret) check_cache_entry_infoA("GetUrlCacheEntryInfoEx", lpCacheEntryInfo);
lpCacheEntryInfo->CacheEntryType |= 0x10000000; /* INSTALLED_CACHE_ENTRY */
ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo, CACHE_ENTRY_ATTRIBUTE_FC);
ok(ret, "SetUrlCacheEntryInfoA failed with error %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, NULL, NULL, 0x200 /*GET_INSTALLED_ENTRY*/);
ok(ret, "GetUrlCacheEntryInfoEx failed with error %d\n", GetLastError());
cbCacheEntryInfo = 100000; cbCacheEntryInfo = 100000;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, &cbCacheEntryInfo, NULL, NULL, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n"); ok(!ret, "GetUrlCacheEntryInfoEx with zero-length buffer should fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetUrlCacheEntryInfoEx should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
@ -146,12 +163,12 @@ static void test_GetUrlCacheEntryInfoExA(void)
/* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */ /* Querying the redirect URL fails with ERROR_INVALID_PARAMETER */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, NULL, NULL, &cbRedirectUrl, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n"); ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfoEx(TEST_URL, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0); ret = GetUrlCacheEntryInfoEx(test_url, NULL, &cbCacheEntryInfo, NULL, &cbRedirectUrl, NULL, 0);
ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n"); ok(!ret, "GetUrlCacheEntryInfoEx should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
@ -172,7 +189,7 @@ static void test_RetrieveUrlCacheEntryA(void)
{ {
/* Crashes on Win9x, NT4 and W2K */ /* Crashes on Win9x, NT4 and W2K */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, NULL, 0); ret = RetrieveUrlCacheEntryFile(test_url, NULL, NULL, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError()); ok(GetLastError() == ERROR_INVALID_PARAMETER, "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_PARAMETER instead of %d\n", GetLastError());
} }
@ -206,7 +223,7 @@ static void test_IsUrlCacheEntryExpiredA(void)
ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d, ok(ft.dwLowDateTime == 0xdeadbeef && ft.dwHighDateTime == 0xbaadf00d,
"expected time to be unchanged, got (%u,%u)\n", "expected time to be unchanged, got (%u,%u)\n",
ft.dwLowDateTime, ft.dwHighDateTime); ft.dwLowDateTime, ft.dwHighDateTime);
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, NULL); ret = IsUrlCacheEntryExpiredA(test_url, 0, NULL);
ok(ret, "expected TRUE\n"); ok(ret, "expected TRUE\n");
/* The return value should indicate whether the URL is expired, /* The return value should indicate whether the URL is expired,
@ -215,7 +232,7 @@ static void test_IsUrlCacheEntryExpiredA(void)
*/ */
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
"expected time (0,0), got (%u,%u)\n", "expected time (0,0), got (%u,%u)\n",
@ -224,19 +241,19 @@ static void test_IsUrlCacheEntryExpiredA(void)
/* Same behavior with bogus flags. */ /* Same behavior with bogus flags. */
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0xffffffff, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0xffffffff, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
"expected time (0,0), got (%u,%u)\n", "expected time (0,0), got (%u,%u)\n",
ft.dwLowDateTime, ft.dwHighDateTime); ft.dwLowDateTime, ft.dwHighDateTime);
/* Set the expire time to a point in the past.. */ /* Set the expire time to a point in the past.. */
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &size); ret = GetUrlCacheEntryInfo(test_url, NULL, &size);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
info = HeapAlloc(GetProcessHeap(), 0, size); info = HeapAlloc(GetProcessHeap(), 0, size);
ret = GetUrlCacheEntryInfo(TEST_URL, info, &size); ret = GetUrlCacheEntryInfo(test_url, info, &size);
ok(ret, "GetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed: %d\n", GetLastError());
GetSystemTimeAsFileTime(&info->ExpireTime); GetSystemTimeAsFileTime(&info->ExpireTime);
exp_time.u.LowPart = info->ExpireTime.dwLowDateTime; exp_time.u.LowPart = info->ExpireTime.dwLowDateTime;
@ -244,12 +261,12 @@ static void test_IsUrlCacheEntryExpiredA(void)
exp_time.QuadPart -= 10 * 60 * (ULONGLONG)10000000; exp_time.QuadPart -= 10 * 60 * (ULONGLONG)10000000;
info->ExpireTime.dwLowDateTime = exp_time.u.LowPart; info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
info->ExpireTime.dwHighDateTime = exp_time.u.HighPart; info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
ret = SetUrlCacheEntryInfo(TEST_URL, info, CACHE_ENTRY_EXPTIME_FC); ret = SetUrlCacheEntryInfo(test_url, info, CACHE_ENTRY_EXPTIME_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
/* and the entry should be expired. */ /* and the entry should be expired. */
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(ret, "expected TRUE\n"); ok(ret, "expected TRUE\n");
/* The modified time returned is 0. */ /* The modified time returned is 0. */
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
@ -259,12 +276,12 @@ static void test_IsUrlCacheEntryExpiredA(void)
exp_time.QuadPart += 20 * 60 * (ULONGLONG)10000000; exp_time.QuadPart += 20 * 60 * (ULONGLONG)10000000;
info->ExpireTime.dwLowDateTime = exp_time.u.LowPart; info->ExpireTime.dwLowDateTime = exp_time.u.LowPart;
info->ExpireTime.dwHighDateTime = exp_time.u.HighPart; info->ExpireTime.dwHighDateTime = exp_time.u.HighPart;
ret = SetUrlCacheEntryInfo(TEST_URL, info, CACHE_ENTRY_EXPTIME_FC); ret = SetUrlCacheEntryInfo(test_url, info, CACHE_ENTRY_EXPTIME_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ft.dwLowDateTime = 0xdeadbeef; ft.dwLowDateTime = 0xdeadbeef;
ft.dwHighDateTime = 0xbaadf00d; ft.dwHighDateTime = 0xbaadf00d;
/* and the entry should no longer be expired. */ /* and the entry should no longer be expired. */
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
/* The modified time returned is still 0. */ /* The modified time returned is still 0. */
ok(!ft.dwLowDateTime && !ft.dwHighDateTime, ok(!ft.dwLowDateTime && !ft.dwHighDateTime,
@ -272,10 +289,10 @@ static void test_IsUrlCacheEntryExpiredA(void)
ft.dwLowDateTime, ft.dwHighDateTime); ft.dwLowDateTime, ft.dwHighDateTime);
/* Set the modified time... */ /* Set the modified time... */
GetSystemTimeAsFileTime(&info->LastModifiedTime); GetSystemTimeAsFileTime(&info->LastModifiedTime);
ret = SetUrlCacheEntryInfo(TEST_URL, info, CACHE_ENTRY_MODTIME_FC); ret = SetUrlCacheEntryInfo(test_url, info, CACHE_ENTRY_MODTIME_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
/* and the entry should still be unexpired.. */ /* and the entry should still be unexpired.. */
ret = IsUrlCacheEntryExpiredA(TEST_URL, 0, &ft); ret = IsUrlCacheEntryExpiredA(test_url, 0, &ft);
ok(!ret, "expected FALSE\n"); ok(!ret, "expected FALSE\n");
/* but the modified time returned is the last modified time just set. */ /* but the modified time returned is the last modified time just set. */
ok(ft.dwLowDateTime == info->LastModifiedTime.dwLowDateTime && ok(ft.dwLowDateTime == info->LastModifiedTime.dwLowDateTime &&
@ -353,25 +370,27 @@ static void test_urlcacheA(void)
static const FILETIME filetime_zero; static const FILETIME filetime_zero;
FILETIME now; FILETIME now;
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
check_file_exists(filenameA1);
DeleteFileA(filenameA1);
ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n"); ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, NULL, 0, "html", NULL); ret = CommitUrlCacheEntry(test_url1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"GetUrlCacheEntryInfo should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); "GetUrlCacheEntryInfo should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)), ok(!memcmp(&lpCacheEntryInfo->ExpireTime, &filetime_zero, sizeof(FILETIME)),
"expected zero ExpireTime\n"); "expected zero ExpireTime\n");
@ -389,22 +408,20 @@ static void test_urlcacheA(void)
/* A subsequent commit with a different time/type doesn't change most of the entry */ /* A subsequent commit with a different time/type doesn't change most of the entry */
GetSystemTimeAsFileTime(&now); GetSystemTimeAsFileTime(&now);
ret = CommitUrlCacheEntry(TEST_URL1, NULL, now, now, NORMAL_CACHE_ENTRY, ret = CommitUrlCacheEntry(test_url1, NULL, now, now, NORMAL_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), NULL, NULL); (LPBYTE)ok_header, strlen(ok_header), NULL, NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(TEST_URL1, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo2 = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL1, lpCacheEntryInfo2, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url1, lpCacheEntryInfo2, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
/* but it does change the time.. */ /* but it does change the time.. */
todo_wine
ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)), ok(memcmp(&lpCacheEntryInfo2->ExpireTime, &filetime_zero, sizeof(FILETIME)),
"expected positive ExpireTime\n"); "expected positive ExpireTime\n");
todo_wine
ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)), ok(memcmp(&lpCacheEntryInfo2->LastModifiedTime, &filetime_zero, sizeof(FILETIME)),
"expected positive LastModifiedTime\n"); "expected positive LastModifiedTime\n");
ok(lpCacheEntryInfo2->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) || ok(lpCacheEntryInfo2->CacheEntryType == (NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY) ||
@ -412,39 +429,35 @@ static void test_urlcacheA(void)
"expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n", "expected type NORMAL_CACHE_ENTRY|URLHISTORY_CACHE_ENTRY, got %08x\n",
lpCacheEntryInfo2->CacheEntryType); lpCacheEntryInfo2->CacheEntryType);
/* and set the headers. */ /* and set the headers. */
todo_wine
ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19, ok(lpCacheEntryInfo2->dwHeaderInfoSize == 19,
"expected headers size 19, got %d\n", "expected headers size 19, got %d\n",
lpCacheEntryInfo2->dwHeaderInfoSize); lpCacheEntryInfo2->dwHeaderInfoSize);
/* Hit rate gets incremented by 1 */ /* Hit rate gets incremented by 1 */
todo_wine
ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate, ok((lpCacheEntryInfo->dwHitRate + 1) == lpCacheEntryInfo2->dwHitRate,
"HitRate not incremented by one on commit\n"); "HitRate not incremented by one on commit\n");
/* Last access time should be updated */ /* Last access time should be updated */
todo_wine
ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime && ok(!(lpCacheEntryInfo->LastAccessTime.dwHighDateTime == lpCacheEntryInfo2->LastAccessTime.dwHighDateTime &&
lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime), lpCacheEntryInfo->LastAccessTime.dwLowDateTime == lpCacheEntryInfo2->LastAccessTime.dwLowDateTime),
"Last accessed time was not updated by commit\n"); "Last accessed time was not updated by commit\n");
/* File extension should be unset */ /* File extension should be unset */
todo_wine
ok(lpCacheEntryInfo2->lpszFileExtension == NULL, ok(lpCacheEntryInfo2->lpszFileExtension == NULL,
"Fileextension isn't unset: %s\n", "Fileextension isn't unset: %s\n",
lpCacheEntryInfo2->lpszFileExtension); lpCacheEntryInfo2->lpszFileExtension);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo2);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError()); "RetrieveUrlCacheEntryFile should have set last error to ERROR_INSUFFICIENT_BUFFER instead of %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url, lpCacheEntryInfo, &cbCacheEntryInfo, 0);
ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError()); ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo); if (ret) check_cache_entry_infoA("RetrieveUrlCacheEntryFile", lpCacheEntryInfo);
@ -453,14 +466,14 @@ static void test_urlcacheA(void)
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL1, NULL, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url1, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INVALID_DATA, ok(GetLastError() == ERROR_INVALID_DATA,
"RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError()); "RetrieveUrlCacheEntryFile should have set last error to ERROR_INVALID_DATA instead of %d\n", GetLastError());
if (pUnlockUrlCacheEntryFileA) if (pUnlockUrlCacheEntryFileA)
{ {
ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0); ret = pUnlockUrlCacheEntryFileA(test_url, 0);
ok(ret, "UnlockUrlCacheEntryFileA failed with error %d\n", GetLastError()); ok(ret, "UnlockUrlCacheEntryFileA failed with error %d\n", GetLastError());
} }
@ -473,22 +486,21 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
ret = pDeleteUrlCacheEntryA(TEST_URL1); ret = pDeleteUrlCacheEntryA(test_url1);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
} }
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = DeleteFile(filenameA); ret = DeleteFile(filenameA);
todo_wine
ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n"); ok(!ret && GetLastError() == ERROR_FILE_NOT_FOUND, "local file should no longer exist\n");
/* Creating two entries with the same URL */ /* Creating two entries with the same URL */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n"); ok(lstrcmpiA(filenameA, filenameA1), "expected a different file name\n");
@ -498,13 +510,13 @@ static void test_urlcacheA(void)
check_file_exists(filenameA); check_file_exists(filenameA);
check_file_exists(filenameA1); check_file_exists(filenameA1);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero,
filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header, filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
strlen(ok_header), "html", NULL); strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
check_file_exists(filenameA); check_file_exists(filenameA);
check_file_exists(filenameA1); check_file_exists(filenameA1);
ret = CommitUrlCacheEntry(TEST_URL, filenameA1, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA1, filetime_zero,
filetime_zero, COOKIE_CACHE_ENTRY, NULL, 0, "html", NULL); filetime_zero, COOKIE_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
/* By committing the same URL a second time, the prior entry is /* By committing the same URL a second time, the prior entry is
@ -512,34 +524,30 @@ static void test_urlcacheA(void)
*/ */
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
/* with the previous entry type retained.. */ /* with the previous entry type retained.. */
ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY, ok(lpCacheEntryInfo->CacheEntryType & NORMAL_CACHE_ENTRY,
"expected cache entry type NORMAL_CACHE_ENTRY, got %d (0x%08x)\n", "expected cache entry type NORMAL_CACHE_ENTRY, got %d (0x%08x)\n",
lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType); lpCacheEntryInfo->CacheEntryType, lpCacheEntryInfo->CacheEntryType);
/* and the headers overwritten.. */ /* and the headers overwritten.. */
todo_wine
ok(!lpCacheEntryInfo->dwHeaderInfoSize, "expected headers size 0, got %d\n", ok(!lpCacheEntryInfo->dwHeaderInfoSize, "expected headers size 0, got %d\n",
lpCacheEntryInfo->dwHeaderInfoSize); lpCacheEntryInfo->dwHeaderInfoSize);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
/* and the previous filename shouldn't exist. */ /* and the previous filename shouldn't exist. */
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
check_file_exists(filenameA1); check_file_exists(filenameA1);
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
todo_wine
check_file_not_exists(filenameA1); check_file_not_exists(filenameA1);
/* Just in case, clean up files */ /* Just in case, clean up files */
DeleteFileA(filenameA1); DeleteFileA(filenameA1);
@ -549,21 +557,21 @@ static void test_urlcacheA(void)
/* Check whether a retrieved cache entry can be deleted before it's /* Check whether a retrieved cache entry can be deleted before it's
* unlocked: * unlocked:
*/ */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL); NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = RetrieveUrlCacheEntryFile(TEST_URL, NULL, &cbCacheEntryInfo, 0); ret = RetrieveUrlCacheEntryFile(test_url, NULL, &cbCacheEntryInfo, 0);
ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n"); ok(!ret, "RetrieveUrlCacheEntryFile should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = RetrieveUrlCacheEntryFile(TEST_URL, lpCacheEntryInfo, ret = RetrieveUrlCacheEntryFile(test_url, lpCacheEntryInfo,
&cbCacheEntryInfo, 0); &cbCacheEntryInfo, 0);
ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError()); ok(ret, "RetrieveUrlCacheEntryFile failed with error %d\n", GetLastError());
@ -571,7 +579,7 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_SHARING_VIOLATION, ok(GetLastError() == ERROR_SHARING_VIOLATION,
"Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError()); "Expected ERROR_SHARING_VIOLATION, got %d\n", GetLastError());
@ -580,22 +588,21 @@ static void test_urlcacheA(void)
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
memset(lpCacheEntryInfo, 0, cbCacheEntryInfo); memset(lpCacheEntryInfo, 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(lpCacheEntryInfo->CacheEntryType & DELETED_CACHE_ENTRY, ok(lpCacheEntryInfo->CacheEntryType & 0x400000,
"CacheEntryType hasn't DELETED_CACHE_ENTRY set, (flags %08x)\n", "CacheEntryType hasn't PENDING_DELETE_CACHE_ENTRY set, (flags %08x)\n",
lpCacheEntryInfo->CacheEntryType); lpCacheEntryInfo->CacheEntryType);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
if (pUnlockUrlCacheEntryFileA) if (pUnlockUrlCacheEntryFileA)
{ {
check_file_exists(filenameA); check_file_exists(filenameA);
ret = pUnlockUrlCacheEntryFileA(TEST_URL, 0); ret = pUnlockUrlCacheEntryFileA(test_url, 0);
ok(ret, "UnlockUrlCacheEntryFileA failed: %d\n", GetLastError()); ok(ret, "UnlockUrlCacheEntryFileA failed: %d\n", GetLastError());
/* By unlocking the already-deleted cache entry, the file associated /* By unlocking the already-deleted cache entry, the file associated
* with it is deleted.. * with it is deleted..
*/ */
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
/* (just in case, delete file) */ /* (just in case, delete file) */
DeleteFileA(filenameA); DeleteFileA(filenameA);
@ -603,7 +610,7 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
/* and a subsequent deletion should fail. */ /* and a subsequent deletion should fail. */
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
@ -612,13 +619,13 @@ static void test_urlcacheA(void)
/* Test whether preventing a file from being deleted causes /* Test whether preventing a file from being deleted causes
* DeleteUrlCacheEntryA to fail. * DeleteUrlCacheEntryA to fail.
*/ */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
check_file_exists(filenameA); check_file_exists(filenameA);
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero,
filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header, filetime_zero, NORMAL_CACHE_ENTRY, (LPBYTE)ok_header,
strlen(ok_header), "html", NULL); strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
@ -630,14 +637,14 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
/* DeleteUrlCacheEntryA should succeed.. */ /* DeleteUrlCacheEntryA should succeed.. */
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
} }
CloseHandle(hFile); CloseHandle(hFile);
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
/* and a subsequent deletion should fail.. */ /* and a subsequent deletion should fail.. */
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(!ret, "Expected failure\n"); ok(!ret, "Expected failure\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); "expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
@ -650,35 +657,35 @@ static void test_urlcacheA(void)
* must have been set already. * must have been set already.
*/ */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CommitUrlCacheEntry(TEST_URL, NULL, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, NULL, filetime_zero, filetime_zero,
STICKY_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), "html", STICKY_CACHE_ENTRY, (LPBYTE)ok_header, strlen(ok_header), "html",
NULL); NULL);
ok(!ret, "expected failure\n"); ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = CommitUrlCacheEntry(TEST_URL, NULL, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, NULL, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(!ret, "expected failure\n"); ok(!ret, "expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, ok(GetLastError() == ERROR_INVALID_PARAMETER,
"expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY), ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY),
"expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
@ -689,28 +696,27 @@ static void test_urlcacheA(void)
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo); HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
/* When explicitly deleting the cache entry, the file is also deleted */ /* When explicitly deleting the cache entry, the file is also deleted */
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
} }
/* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */ /* Test once again, setting the exempt delta via SetUrlCacheEntryInfo */
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL, filenameA, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0; cbCacheEntryInfo = 0;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = GetUrlCacheEntryInfo(TEST_URL, NULL, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n"); ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo); lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY), ok(lpCacheEntryInfo->CacheEntryType & (NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY),
"expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n", "expected cache entry type NORMAL_CACHE_ENTRY | STICKY_CACHE_ENTRY, got %d (0x%08x)\n",
@ -719,10 +725,10 @@ static void test_urlcacheA(void)
"expected dwExemptDelta 86400, got %d\n", "expected dwExemptDelta 86400, got %d\n",
U(*lpCacheEntryInfo).dwExemptDelta); U(*lpCacheEntryInfo).dwExemptDelta);
U(*lpCacheEntryInfo).dwExemptDelta = 0; U(*lpCacheEntryInfo).dwExemptDelta = 0;
ret = SetUrlCacheEntryInfoA(TEST_URL, lpCacheEntryInfo, ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
CACHE_ENTRY_EXEMPT_DELTA_FC); CACHE_ENTRY_EXEMPT_DELTA_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n", ok(!U(*lpCacheEntryInfo).dwExemptDelta, "expected dwExemptDelta 0, got %d\n",
U(*lpCacheEntryInfo).dwExemptDelta); U(*lpCacheEntryInfo).dwExemptDelta);
@ -735,20 +741,20 @@ static void test_urlcacheA(void)
/* Recommit of Url entry keeps dwExemptDelta */ /* Recommit of Url entry keeps dwExemptDelta */
U(*lpCacheEntryInfo).dwExemptDelta = 8600; U(*lpCacheEntryInfo).dwExemptDelta = 8600;
ret = SetUrlCacheEntryInfoA(TEST_URL, lpCacheEntryInfo, ret = SetUrlCacheEntryInfoA(test_url, lpCacheEntryInfo,
CACHE_ENTRY_EXEMPT_DELTA_FC); CACHE_ENTRY_EXEMPT_DELTA_FC);
ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError()); ok(ret, "SetUrlCacheEntryInfo failed: %d\n", GetLastError());
ret = CreateUrlCacheEntry(TEST_URL, 0, "html", filenameA1, 0); ret = CreateUrlCacheEntry(test_url, 0, "html", filenameA1, 0);
ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CreateUrlCacheEntry failed with error %d\n", GetLastError());
create_and_write_file(filenameA1, &zero_byte, sizeof(zero_byte)); create_and_write_file(filenameA1, &zero_byte, sizeof(zero_byte));
ret = CommitUrlCacheEntry(TEST_URL, filenameA1, filetime_zero, filetime_zero, ret = CommitUrlCacheEntry(test_url, filenameA1, filetime_zero, filetime_zero,
NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY, NORMAL_CACHE_ENTRY|STICKY_CACHE_ENTRY,
(LPBYTE)ok_header, strlen(ok_header), "html", NULL); (LPBYTE)ok_header, strlen(ok_header), "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError()); ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ret = GetUrlCacheEntryInfo(TEST_URL, lpCacheEntryInfo, &cbCacheEntryInfo); ret = GetUrlCacheEntryInfo(test_url, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError()); ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(U(*lpCacheEntryInfo).dwExemptDelta == 8600, ok(U(*lpCacheEntryInfo).dwExemptDelta == 8600,
"expected dwExemptDelta 8600, got %d\n", "expected dwExemptDelta 8600, got %d\n",
@ -758,11 +764,47 @@ static void test_urlcacheA(void)
if (pDeleteUrlCacheEntryA) if (pDeleteUrlCacheEntryA)
{ {
ret = pDeleteUrlCacheEntryA(TEST_URL); ret = pDeleteUrlCacheEntryA(test_url);
ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError()); ok(ret, "DeleteUrlCacheEntryA failed with error %d\n", GetLastError());
todo_wine
check_file_not_exists(filenameA); check_file_not_exists(filenameA);
} }
/* Test if files with identical hash keys are handled correctly */
ret = CommitUrlCacheEntryA(test_hash_collisions1, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
ret = CommitUrlCacheEntryA(test_hash_collisions2, NULL, filetime_zero, filetime_zero, NORMAL_CACHE_ENTRY, NULL, 0, "html", NULL);
ok(ret, "CommitUrlCacheEntry failed with error %d\n", GetLastError());
cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(test_hash_collisions1, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(test_hash_collisions1, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_hash_collisions1),
"got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
cbCacheEntryInfo = 0;
ret = GetUrlCacheEntryInfo(test_hash_collisions2, NULL, &cbCacheEntryInfo);
ok(!ret, "GetUrlCacheEntryInfo should have failed\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
lpCacheEntryInfo = HeapAlloc(GetProcessHeap(), 0, cbCacheEntryInfo);
ret = GetUrlCacheEntryInfo(test_hash_collisions2, lpCacheEntryInfo, &cbCacheEntryInfo);
ok(ret, "GetUrlCacheEntryInfo failed with error %d\n", GetLastError());
ok(!strcmp(lpCacheEntryInfo->lpszSourceUrlName, test_hash_collisions2),
"got incorrect entry: %s\n", lpCacheEntryInfo->lpszSourceUrlName);
HeapFree(GetProcessHeap(), 0, lpCacheEntryInfo);
if (pDeleteUrlCacheEntryA) {
ret = pDeleteUrlCacheEntryA(test_hash_collisions1);
ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
ret = pDeleteUrlCacheEntryA(test_hash_collisions2);
ok(ret, "DeleteUrlCacheEntry failed: %d\n", GetLastError());
}
} }
static void test_FindCloseUrlCache(void) static void test_FindCloseUrlCache(void)
@ -804,10 +846,10 @@ static void test_GetDiskInfoA(void)
ret = GetDiskInfoA(path, NULL, NULL, NULL); ret = GetDiskInfoA(path, NULL, NULL, NULL);
error = GetLastError(); error = GetLastError();
ok(!ret || ok(!ret ||
broken(ret), /* < IE7 */ broken(old_ie && ret), /* < IE7 */
"GetDiskInfoA succeeded\n"); "GetDiskInfoA succeeded\n");
ok(error == ERROR_PATH_NOT_FOUND || ok(error == ERROR_PATH_NOT_FOUND ||
broken(error == 0xdeadbeef), /* < IE7 */ broken(old_ie && error == 0xdeadbeef), /* < IE7 */
"got %u expected ERROR_PATH_NOT_FOUND\n", error); "got %u expected ERROR_PATH_NOT_FOUND\n", error);
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -826,6 +868,8 @@ START_TEST(urlcache)
win_skip("Too old IE (older than 6.0)\n"); win_skip("Too old IE (older than 6.0)\n");
return; return;
} }
if(!GetProcAddress(hdll, "InternetGetSecurityInfoByURL")) /* < IE7 */
old_ie = TRUE;
pDeleteUrlCacheEntryA = (void*)GetProcAddress(hdll, "DeleteUrlCacheEntryA"); pDeleteUrlCacheEntryA = (void*)GetProcAddress(hdll, "DeleteUrlCacheEntryA");
pUnlockUrlCacheEntryFileA = (void*)GetProcAddress(hdll, "UnlockUrlCacheEntryFileA"); pUnlockUrlCacheEntryFileA = (void*)GetProcAddress(hdll, "UnlockUrlCacheEntryFileA");