Commit 68d18612 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

wininet: Fix up and test InternetSetCookie parameter checking.

parent 7b3cf21d
......@@ -402,9 +402,9 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
TRACE("(%s,%s,%s)\n", debugstr_w(lpszUrl),
debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
if (!lpCookieData || !strlenW(lpCookieData))
if (!lpCookieData)
{
TRACE("no cookie data, not adding\n");
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (!lpszCookieName)
......
......@@ -123,6 +123,9 @@ static void test_null(void)
{
HINTERNET hi, hc;
static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
static const WCHAR szEmpty[] = { 0 };
static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
BOOL r;
hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
ok(hi != NULL, "open failed\n");
......@@ -152,6 +155,35 @@ static void test_null(void)
ok(hc == NULL, "connect failed\n");
InternetCloseHandle(hi);
r = InternetSetCookieW(NULL, NULL, NULL);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
ok(r == FALSE, "return wrong\n");
r = InternetSetCookieW(szServer, NULL, NULL);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
ok(r == FALSE, "return wrong\n");
r = InternetSetCookieW(szUrl, szServer, NULL);
ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
ok(r == FALSE, "return wrong\n");
r = InternetSetCookieW(szUrl, szServer, szServer);
ok(r == TRUE, "return wrong\n");
todo_wine {
r = InternetSetCookieW(szUrl, NULL, szServer);
ok(r == TRUE, "return wrong\n");
}
r = InternetSetCookieW(szUrl, szServer, szEmpty);
ok(r == TRUE, "return wrong\n");
r = InternetSetCookieW(szServer, NULL, szServer);
todo_wine {
ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
}
ok(r == FALSE, "return wrong\n");
}
START_TEST(internet)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment