2 * Wininet - internet tests
4 * Copyright 2005 Vijay Kiran Kamuju
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/test.h"
33 static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD, DWORD, DWORD, DWORD,
34 DWORD, DWORD, DWORD, DWORD);
35 static BOOL (WINAPI *pCreateUrlCacheContainerW)(DWORD, DWORD, DWORD, DWORD,
36 DWORD, DWORD, DWORD, DWORD);
37 static BOOL (WINAPI *pInternetTimeFromSystemTimeA)(CONST SYSTEMTIME *,DWORD ,LPSTR ,DWORD);
38 static BOOL (WINAPI *pInternetTimeFromSystemTimeW)(CONST SYSTEMTIME *,DWORD ,LPWSTR ,DWORD);
39 static BOOL (WINAPI *pInternetTimeToSystemTimeA)(LPCSTR ,SYSTEMTIME *,DWORD);
40 static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
41 static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
42 static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
43 static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
44 static BOOL (WINAPI *pInternetGetCookieExA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD,LPVOID);
45 static BOOL (WINAPI *pInternetGetCookieExW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD,LPVOID);
47 /* ############################### */
49 static void test_InternetCanonicalizeUrlA(void)
57 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
58 url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
59 urllen = lstrlenA(url);
61 memset(buffer, '#', sizeof(buffer)-1);
62 buffer[sizeof(buffer)-1] = '\0';
63 dwSize = 1; /* Acrobat Updater use this size */
64 SetLastError(0xdeadbeef);
65 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
66 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
67 "got %u and %u with size %u for '%s' (%d)\n",
68 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
71 /* buffer has no space for the terminating '\0' */
72 memset(buffer, '#', sizeof(buffer)-1);
73 buffer[sizeof(buffer)-1] = '\0';
75 SetLastError(0xdeadbeef);
76 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
77 /* dwSize is nr. of needed bytes with the terminating '\0' */
78 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
79 "got %u and %u with size %u for '%s' (%d)\n",
80 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
82 /* buffer has the required size */
83 memset(buffer, '#', sizeof(buffer)-1);
84 buffer[sizeof(buffer)-1] = '\0';
86 SetLastError(0xdeadbeef);
87 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
88 /* dwSize is nr. of copied bytes without the terminating '\0' */
89 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
90 "got %u and %u with size %u for '%s' (%d)\n",
91 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
93 memset(buffer, '#', sizeof(buffer)-1);
94 buffer[sizeof(buffer)-1] = '\0';
95 dwSize = sizeof(buffer);
96 SetLastError(0xdeadbeef);
97 res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
98 ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
99 ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
100 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
101 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
103 /* buffer is larger as the required size */
104 memset(buffer, '#', sizeof(buffer)-1);
105 buffer[sizeof(buffer)-1] = '\0';
107 SetLastError(0xdeadbeef);
108 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
109 /* dwSize is nr. of copied bytes without the terminating '\0' */
110 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
111 "got %u and %u with size %u for '%s' (%d)\n",
112 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
115 /* check NULL pointers */
116 memset(buffer, '#', urllen + 4);
117 buffer[urllen + 4] = '\0';
119 SetLastError(0xdeadbeef);
120 res = InternetCanonicalizeUrlA(NULL, buffer, &dwSize, 0);
121 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
122 "got %u and %u with size %u for '%s' (%d)\n",
123 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
125 memset(buffer, '#', urllen + 4);
126 buffer[urllen + 4] = '\0';
128 SetLastError(0xdeadbeef);
129 res = InternetCanonicalizeUrlA(url, NULL, &dwSize, 0);
130 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
131 "got %u and %u with size %u for '%s' (%d)\n",
132 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
134 memset(buffer, '#', urllen + 4);
135 buffer[urllen + 4] = '\0';
137 SetLastError(0xdeadbeef);
138 res = InternetCanonicalizeUrlA(url, buffer, NULL, 0);
139 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
140 "got %u and %u with size %u for '%s' (%d)\n",
141 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
143 /* test with trailing space */
145 res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
146 ok(res == 1, "InternetCanonicalizeUrlA failed\n");
147 ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
149 res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
150 ok(!res, "InternetSetOptionA succeeded\n");
151 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION,
152 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
155 /* ############################### */
157 static void test_InternetQueryOptionA(void)
159 HINTERNET hinet,hurl;
162 static const char useragent[] = {"Wininet Test"};
167 SetLastError(0xdeadbeef);
169 retval = InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, NULL, &len);
170 ok(!retval && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got wrong error %x(%u)\n", retval, GetLastError());
171 ok(len >= sizeof(INTERNET_PROXY_INFO) && len != 0xdeadbeef,"len = %u\n", len);
173 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
174 ok((hinet != 0x0),"InternetOpen Failed\n");
176 SetLastError(0xdeadbeef);
177 retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
179 ok(retval == 0,"Got wrong return value %d\n",retval);
180 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
182 SetLastError(0xdeadbeef);
183 len=strlen(useragent)+1;
184 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
186 ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
187 ok(retval == 0,"Got wrong return value %d\n",retval);
188 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
190 SetLastError(0xdeadbeef);
191 len=strlen(useragent)+1;
192 buffer=HeapAlloc(GetProcessHeap(),0,len);
193 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
195 ok(retval == 1,"Got wrong return value %d\n",retval);
198 ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
199 ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
201 ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
202 HeapFree(GetProcessHeap(),0,buffer);
204 SetLastError(0xdeadbeef);
206 buffer=HeapAlloc(GetProcessHeap(),0,100);
207 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
209 ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
210 ok(!retval, "Got wrong return value %d\n", retval);
211 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
212 HeapFree(GetProcessHeap(),0,buffer);
214 hurl = InternetConnectA(hinet,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
216 SetLastError(0xdeadbeef);
218 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
220 ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
221 ok(retval == 0,"Got wrong return value %d\n",retval);
222 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
224 SetLastError(0xdeadbeef);
226 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
227 err = GetLastError();
228 ok(retval == 0,"Got wrong return value %d\n",retval);
229 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
230 ok(len == sizeof(DWORD), "len = %d\n", len);
232 SetLastError(0xdeadbeef);
234 retval = InternetQueryOptionA(NULL,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
235 err = GetLastError();
236 ok(retval == 0,"Got wrong return value %d\n",retval);
237 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
238 ok(!len, "len = %d\n", len);
240 InternetCloseHandle(hurl);
241 InternetCloseHandle(hinet);
243 hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
244 ok((hinet != 0x0),"InternetOpen Failed\n");
246 SetLastError(0xdeadbeef);
248 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
250 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
251 ok(retval == 0,"Got wrong return value %d\n",retval);
252 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
254 InternetCloseHandle(hinet);
257 res = InternetSetOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
258 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
261 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
262 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
263 ok(val == 12345, "val = %d\n", val);
264 ok(len == sizeof(val), "len = %d\n", len);
266 hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
267 ok((hinet != 0x0),"InternetOpen Failed\n");
268 SetLastError(0xdeadbeef);
270 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
272 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
273 ok(retval == 0,"Got wrong return value %d\n",retval);
274 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
278 res = InternetQueryOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
279 ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
280 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
283 res = InternetSetOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
284 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
285 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
288 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
289 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
290 ok(val == 12345, "val = %d\n", val);
291 ok(len == sizeof(val), "len = %d\n", len);
294 res = InternetSetOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
295 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
298 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
299 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
300 ok(val == 1, "val = %d\n", val);
301 ok(len == sizeof(val), "len = %d\n", len);
304 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
305 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
306 ok(val == 12345, "val = %d\n", val);
307 ok(len == sizeof(val), "len = %d\n", len);
309 InternetCloseHandle(hinet);
312 static void test_max_conns(void)
319 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
320 ok(res,"Got wrong return value %x\n", res);
321 ok(len == sizeof(val), "got %d\n", len);
322 ok(val == 2, "got %d\n", val);
326 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len);
327 ok(res,"Got wrong return value %x\n", res);
328 ok(len == sizeof(val), "got %d\n", len);
329 ok(val == 4, "got %d\n", val);
332 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
333 ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res);
337 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
338 ok(res,"Got wrong return value %x\n", res);
339 ok(len == sizeof(val), "got %d\n", len);
340 ok(val == 3, "got %d\n", val);
343 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
344 ok(!res || broken(res), /* <= w2k3 */
345 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
346 if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError());
349 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)-1);
350 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
351 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
354 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)+1);
355 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
356 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
359 static void test_get_cookie(void)
364 SetLastError(0xdeadbeef);
365 ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
366 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
367 "InternetGetCookie should have failed with %s and error %d\n",
368 ret ? "TRUE" : "FALSE", GetLastError());
372 static void test_complicated_cookie(void)
381 static const WCHAR testing_example_comW[] =
382 {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.','e','x','a','m','p','l','e','.','c','o','m',0};
384 ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
385 ok(ret == TRUE,"InternetSetCookie failed\n");
386 ret = InternetSetCookie("http://www.example.com/bar",NULL,"C=D; domain=.example.com; path=/");
387 ok(ret == TRUE,"InternetSetCookie failed\n");
389 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
390 ret = InternetSetCookie("http://www.example.com",NULL,"E=F; domain=example.com");
391 ok(ret == TRUE,"InternetSetCookie failed\n");
392 ret = InternetSetCookie("http://www.example.com",NULL,"G=H; domain=.example.com; path=/foo");
393 ok(ret == TRUE,"InternetSetCookie failed\n");
394 ret = InternetSetCookie("http://www.example.com/bar.html",NULL,"I=J; domain=.example.com");
395 ok(ret == TRUE,"InternetSetCookie failed\n");
396 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"K=L; domain=.example.com");
397 ok(ret == TRUE,"InternetSetCookie failed\n");
398 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"M=N; domain=.example.com; path=/foo/");
399 ok(ret == TRUE,"InternetSetCookie failed\n");
400 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"O=P; secure; path=/bar");
401 ok(ret == TRUE,"InternetSetCookie failed\n");
404 ret = InternetGetCookie("http://testing.example.com", NULL, NULL, &len);
405 ok(ret == TRUE,"InternetGetCookie failed\n");
406 ok(len == 19, "len = %u\n", len);
409 memset(buffer, 0xac, sizeof(buffer));
410 ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
411 ok(ret == TRUE,"InternetGetCookie failed\n");
412 ok(len == 19, "len = %u\n", len);
413 ok(strlen(buffer) == 18, "strlen(buffer) = %u\n", lstrlenA(buffer));
414 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
415 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
416 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
417 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
418 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
419 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
420 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
421 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
424 memset(buffer, 0xac, sizeof(buffer));
425 ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
426 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
427 "InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
428 ok(len == 19, "len = %u\n", len);
431 ret = InternetGetCookieW(testing_example_comW, NULL, NULL, &len);
432 ok(ret == TRUE,"InternetGetCookieW failed\n");
433 ok(len == 38, "len = %u\n", len);
436 memset(wbuf, 0xac, sizeof(wbuf));
437 ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
438 ok(ret == TRUE,"InternetGetCookieW failed\n");
439 ok(len == 19, "len = %u\n", len);
440 ok(lstrlenW(wbuf) == 18, "strlenW(wbuf) = %u\n", lstrlenW(wbuf));
443 memset(wbuf, 0xac, sizeof(wbuf));
444 ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
445 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
446 "InternetGetCookieW returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
447 ok(len == 38, "len = %u\n", len);
450 ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len);
451 ok(ret == TRUE,"InternetGetCookie failed\n");
452 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
453 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
454 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
455 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
456 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
457 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
458 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
459 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
462 ret = InternetGetCookie("http://testing.example.com/foobar/", NULL, buffer, &len);
463 ok(ret == TRUE,"InternetGetCookie failed\n");
464 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
465 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
466 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
467 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
468 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
469 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
470 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
471 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
474 ret = InternetGetCookie("http://testing.example.com/foo/bar", NULL, buffer, &len);
475 ok(ret == TRUE,"InternetGetCookie failed\n");
476 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
477 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
478 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
479 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
480 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
481 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
482 ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n");
483 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
486 ret = InternetGetCookie("http://testing.example.com/barfoo", NULL, buffer, &len);
487 ok(ret == TRUE,"InternetGetCookie failed\n");
488 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
489 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
490 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
491 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
492 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
493 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
494 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
495 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
498 ret = InternetGetCookie("http://testing.example.com/barfoo/", NULL, buffer, &len);
499 ok(ret == TRUE,"InternetGetCookie failed\n");
500 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
501 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
502 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
503 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
504 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
505 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
506 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
507 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
510 ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len);
511 ok(ret == TRUE,"InternetGetCookie failed\n");
512 ok(len == 24, "len = %u\n", 24);
513 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
514 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
515 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
516 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
517 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
518 ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
519 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
520 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
522 /* Cookie name argument is not implemented */
524 ret = InternetGetCookie("http://testing.example.com/bar/foo", "A", buffer, &len);
525 ok(ret == TRUE,"InternetGetCookie failed\n");
526 ok(len == 24, "len = %u\n", 24);
528 /* test persistent cookies */
529 ret = InternetSetCookie("http://testing.example.com", NULL, "A=B; expires=Fri, 01-Jan-2038 00:00:00 GMT");
530 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
533 ret = GetUserName(user, &len);
534 ok(ret, "GetUserName failed with error %d\n", GetLastError());
536 user[len-1] = tolower(user[len-1]);
538 sprintf(buffer, "Cookie:%s@testing.example.com/", user);
539 ret = GetUrlCacheEntryInfo(buffer, NULL, &len);
540 ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
541 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %d\n", GetLastError());
543 /* remove persistent cookie */
544 ret = InternetSetCookie("http://testing.example.com", NULL, "A=B");
545 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
547 ret = GetUrlCacheEntryInfo(buffer, NULL, &len);
548 ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
549 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n", GetLastError());
551 /* try setting cookie for different domain */
552 ret = InternetSetCookie("http://www.aaa.example.com/bar",NULL,"E=F; domain=different.com");
553 ok(!ret, "InternetSetCookie succeeded\n");
554 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %d\n", GetLastError());
555 ret = InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=example.com.pl");
556 ok(ret, "InternetSetCookie failed with error: %d\n", GetLastError());
557 ret = InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=com.pl");
558 todo_wine ok(!ret, "InternetSetCookie succeeded\n");
561 static void test_cookie_url(void)
568 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
571 res = InternetGetCookieA("about:blank", NULL, buf, &len);
572 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
573 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
575 len = sizeof(bufw)/sizeof(*bufw);
576 res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
577 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
578 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
581 res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
582 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
583 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
585 len = sizeof(bufw)/sizeof(*bufw);
586 res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
587 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
588 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
591 static void test_null(void)
594 static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
595 static const WCHAR szEmpty[] = { 0 };
596 static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
597 static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
598 static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
603 SetLastError(0xdeadbeef);
604 hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
605 if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
607 win_skip("Internet*W functions are not implemented\n");
610 ok(hi != NULL, "open failed\n");
612 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
613 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
614 ok(hc == NULL, "connect failed\n");
616 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
617 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
618 ok(hc == NULL, "connect failed\n");
620 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
621 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
622 ok(hc == NULL, "connect failed\n");
624 hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
625 ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
626 ok(hc == NULL, "connect failed\n");
628 hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
629 ok(GetLastError() == ERROR_INVALID_PARAMETER ||
630 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
631 ok(hc == NULL, "connect failed\n");
633 hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
634 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
635 ok(hc == NULL, "connect failed\n");
637 InternetCloseHandle(hi);
639 r = InternetSetCookieW(NULL, NULL, NULL);
640 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
641 ok(r == FALSE, "return wrong\n");
643 r = InternetSetCookieW(szServer, NULL, NULL);
644 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
645 ok(r == FALSE, "return wrong\n");
647 r = InternetSetCookieW(szUrl, szServer, NULL);
648 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
649 ok(r == FALSE, "return wrong\n");
651 r = InternetSetCookieW(szUrl, szServer, szServer);
652 ok(r == TRUE, "return wrong\n");
654 r = InternetSetCookieW(szUrl, NULL, szServer);
655 ok(r == TRUE, "return wrong\n");
657 r = InternetSetCookieW(szUrl, szServer, szEmpty);
658 ok(r == TRUE, "return wrong\n");
660 r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
661 ok(r == FALSE, "return wrong\n");
663 r = InternetSetCookieW(szServer, NULL, szServer);
664 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
665 ok(r == FALSE, "return wrong\n");
668 r = InternetGetCookieW(NULL, NULL, NULL, &sz);
669 ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
670 "wrong error %u\n", GetLastError());
671 ok( r == FALSE, "return wrong\n");
673 r = InternetGetCookieW(szServer, NULL, NULL, &sz);
675 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
677 ok( r == FALSE, "return wrong\n");
680 r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
681 ok( r == FALSE, "return wrong\n");
684 r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
685 ok( r == TRUE, "return wrong\n");
687 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
688 ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz);
691 memset(buffer, 0, sizeof buffer);
692 r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
693 ok( r == TRUE, "return wrong\n");
695 /* sz == lstrlenW(buffer) only in XP SP1 */
696 ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
698 /* before XP SP2, buffer is "server; server" */
699 ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
702 r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
703 ok(r == TRUE, "ret %d\n", r);
706 static void test_version(void)
708 INTERNET_VERSION_INFO version;
712 size = sizeof(version);
713 res = InternetQueryOptionA(NULL, INTERNET_OPTION_VERSION, &version, &size);
714 ok(res, "Could not get version: %u\n", GetLastError());
715 ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
716 ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
719 static void InternetTimeFromSystemTimeA_test(void)
722 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
723 char string[INTERNET_RFC1123_BUFSIZE];
724 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
727 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
728 ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
730 ok( !memcmp( string, expect, sizeof(expect) ),
731 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
733 /* test NULL time parameter */
734 SetLastError(0xdeadbeef);
735 ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
736 error = GetLastError();
737 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
738 ok( error == ERROR_INVALID_PARAMETER,
739 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
742 /* test NULL string parameter */
743 SetLastError(0xdeadbeef);
744 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
745 error = GetLastError();
746 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
747 ok( error == ERROR_INVALID_PARAMETER,
748 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
751 /* test invalid format parameter */
752 SetLastError(0xdeadbeef);
753 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
754 error = GetLastError();
755 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
756 ok( error == ERROR_INVALID_PARAMETER,
757 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
760 /* test too small buffer size */
761 SetLastError(0xdeadbeef);
762 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
763 error = GetLastError();
764 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
765 ok( error == ERROR_INSUFFICIENT_BUFFER,
766 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
770 static void InternetTimeFromSystemTimeW_test(void)
773 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
774 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
775 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
776 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
779 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
780 ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
782 ok( !memcmp( string, expect, sizeof(expect) ),
783 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
785 /* test NULL time parameter */
786 SetLastError(0xdeadbeef);
787 ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
788 error = GetLastError();
789 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
790 ok( error == ERROR_INVALID_PARAMETER,
791 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
794 /* test NULL string parameter */
795 SetLastError(0xdeadbeef);
796 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
797 error = GetLastError();
798 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
799 ok( error == ERROR_INVALID_PARAMETER,
800 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
803 /* test invalid format parameter */
804 SetLastError(0xdeadbeef);
805 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
806 error = GetLastError();
807 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
808 ok( error == ERROR_INVALID_PARAMETER,
809 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
812 /* test too small buffer size */
813 SetLastError(0xdeadbeef);
814 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
815 error = GetLastError();
816 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
817 ok( error == ERROR_INSUFFICIENT_BUFFER,
818 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
822 static void InternetTimeToSystemTimeA_test(void)
826 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
827 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
828 static const char string2[] = " fri 7 jan 2005 12 06 35";
830 ret = pInternetTimeToSystemTimeA( string, &time, 0 );
831 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
832 ok( !memcmp( &time, &expect, sizeof(expect) ),
833 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
835 ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
836 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
837 ok( !memcmp( &time, &expect, sizeof(expect) ),
838 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
841 static void InternetTimeToSystemTimeW_test(void)
845 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
846 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
847 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
848 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
849 '1','2',' ','0','6',' ','3','5',0 };
850 static const WCHAR string3[] = { 'F','r',0 };
852 ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
853 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
855 ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
856 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
858 ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
859 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
861 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
862 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
864 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
865 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
866 ok( !memcmp( &time, &expect, sizeof(expect) ),
867 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
869 ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
870 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
871 ok( !memcmp( &time, &expect, sizeof(expect) ),
872 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
874 ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
875 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
878 static void test_IsDomainLegalCookieDomainW(void)
882 static const WCHAR empty[] = {0};
883 static const WCHAR dot[] = {'.',0};
884 static const WCHAR uk[] = {'u','k',0};
885 static const WCHAR com[] = {'c','o','m',0};
886 static const WCHAR dot_com[] = {'.','c','o','m',0};
887 static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
888 static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
889 static const WCHAR www_gmail_com[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
890 static const WCHAR www_mail_gmail_com[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
891 static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
892 static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
893 static const WCHAR co_uk[] = {'c','o','.','u','k',0};
894 static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
896 SetLastError(0xdeadbeef);
897 ret = pIsDomainLegalCookieDomainW(NULL, NULL);
898 error = GetLastError();
899 if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
901 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
905 broken(ret), /* IE6 */
906 "IsDomainLegalCookieDomainW succeeded\n");
907 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
909 SetLastError(0xdeadbeef);
910 ret = pIsDomainLegalCookieDomainW(com, NULL);
911 error = GetLastError();
912 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
913 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
915 SetLastError(0xdeadbeef);
916 ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
917 error = GetLastError();
918 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
919 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
921 SetLastError(0xdeadbeef);
922 ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
923 error = GetLastError();
924 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
925 ok(error == ERROR_INVALID_NAME ||
926 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
927 "got %u expected ERROR_INVALID_NAME\n", error);
929 SetLastError(0xdeadbeef);
930 ret = pIsDomainLegalCookieDomainW(com, empty);
931 error = GetLastError();
932 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
933 ok(error == ERROR_INVALID_NAME ||
934 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
935 "got %u expected ERROR_INVALID_NAME\n", error);
937 SetLastError(0xdeadbeef);
938 ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
939 error = GetLastError();
940 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
941 ok(error == ERROR_INVALID_NAME ||
942 broken(error == 0xdeadbeef), /* IE6 */
943 "got %u expected ERROR_INVALID_NAME\n", error);
945 SetLastError(0xdeadbeef);
946 ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
947 error = GetLastError();
948 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
949 ok(error == ERROR_INVALID_NAME ||
950 broken(error == 0xdeadbeef), /* IE6 */
951 "got %u expected ERROR_INVALID_NAME\n", error);
953 SetLastError(0xdeadbeef);
954 ret = pIsDomainLegalCookieDomainW(com, com);
955 error = GetLastError();
956 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
957 ok(error == 0xdeadbeef, "got %u expected 0xdeadbeef\n", error);
959 SetLastError(0xdeadbeef);
960 ret = pIsDomainLegalCookieDomainW(com, dot_com);
961 error = GetLastError();
962 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
963 ok(error == ERROR_INVALID_NAME ||
964 broken(error == 0xdeadbeef), /* IE6 */
965 "got %u expected ERROR_INVALID_NAME\n", error);
967 SetLastError(0xdeadbeef);
968 ret = pIsDomainLegalCookieDomainW(dot_com, com);
969 error = GetLastError();
970 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
971 ok(error == ERROR_INVALID_NAME ||
972 broken(error == 0xdeadbeef), /* IE6 */
973 "got %u expected ERROR_INVALID_NAME\n", error);
975 SetLastError(0xdeadbeef);
976 ret = pIsDomainLegalCookieDomainW(com, gmail_com);
977 error = GetLastError();
978 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
979 ok(error == ERROR_SXS_KEY_NOT_FOUND ||
980 error == ERROR_SUCCESS || /* IE8 on W2K3 */
981 error == 0xdeadbeef, /* up to IE7 */
982 "unexpected error: %u\n", error);
984 ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
985 ok(ret, "IsDomainLegalCookieDomainW failed\n");
987 ret = pIsDomainLegalCookieDomainW(gmail_com, www_gmail_com);
988 ok(ret, "IsDomainLegalCookieDomainW failed\n");
990 ret = pIsDomainLegalCookieDomainW(gmail_com, www_mail_gmail_com);
991 ok(ret, "IsDomainLegalCookieDomainW failed\n");
993 SetLastError(0xdeadbeef);
994 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
995 error = GetLastError();
996 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
997 ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
998 error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
999 error == ERROR_SUCCESS || /* IE8 on W2K3 */
1000 error == 0xdeadbeef, /* up to IE7 */
1001 "unexpected error: %u\n", error);
1003 ret = pIsDomainLegalCookieDomainW(uk, co_uk);
1004 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1006 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
1007 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1009 ret = pIsDomainLegalCookieDomainW(co_uk, gmail_co_uk);
1010 todo_wine ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1012 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
1013 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1015 ret = pIsDomainLegalCookieDomainW(gmail_com, com);
1016 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1018 SetLastError(0xdeadbeef);
1019 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1020 error = GetLastError();
1021 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1022 ok(error == ERROR_INVALID_NAME ||
1023 broken(error == 0xdeadbeef), /* IE6 */
1024 "got %u expected ERROR_INVALID_NAME\n", error);
1026 ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
1027 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1029 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
1030 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1032 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
1033 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1035 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1036 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1038 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
1039 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1042 static void test_PrivacyGetSetZonePreferenceW(void)
1044 DWORD ret, zone, type, template, old_template;
1048 ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
1049 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1052 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
1053 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1056 ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
1057 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1060 ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
1061 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1062 ok(template == 5, "expected template == 5, got %u\n", template);
1065 ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
1066 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1069 static void test_InternetSetOption(void)
1071 HINTERNET ses, con, req;
1076 ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1077 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1078 con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1079 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1080 req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1081 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1083 /* INTERNET_OPTION_POLICY tests */
1084 SetLastError(0xdeadbeef);
1085 ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
1086 ok(ret == FALSE, "InternetSetOption should've failed\n");
1087 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1088 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1090 SetLastError(0xdeadbeef);
1091 ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
1092 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1093 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1094 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1096 /* INTERNET_OPTION_ERROR_MASK tests */
1097 SetLastError(0xdeadbeef);
1098 size = sizeof(ulArg);
1099 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
1100 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1101 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1103 SetLastError(0xdeadbeef);
1105 ret = InternetSetOption(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1106 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1107 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1109 SetLastError(0xdeadbeef);
1111 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
1112 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1113 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
1115 SetLastError(0xdeadbeef);
1117 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1118 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1119 ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
1121 SetLastError(0xdeadbeef);
1123 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1124 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1125 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1127 SetLastError(0xdeadbeef);
1129 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1130 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1131 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1133 ret = InternetCloseHandle(req);
1134 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1135 ret = InternetCloseHandle(con);
1136 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1137 ret = InternetCloseHandle(ses);
1138 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1141 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1142 static void r_verifyProxyEnable(LONG l, DWORD exp)
1145 DWORD type, val, size = sizeof(DWORD);
1147 static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1148 static const CHAR szProxyEnable[] = "ProxyEnable";
1150 ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
1151 ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
1153 ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
1154 ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
1155 ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
1156 ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
1158 ret = RegCloseKey(hkey);
1159 ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
1162 static void test_Option_PerConnectionOption(void)
1165 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
1166 INTERNET_PER_CONN_OPTION_LISTW list = {size};
1167 INTERNET_PER_CONN_OPTIONW *orig_settings;
1168 static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1170 /* get the global IE proxy server info, to restore later */
1171 list.dwOptionCount = 2;
1172 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1174 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1175 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1177 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1179 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1180 orig_settings = list.pOptions;
1182 /* set the global IE proxy server */
1183 list.dwOptionCount = 2;
1184 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1186 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1187 list.pOptions[0].Value.pszValue = proxy_srvW;
1188 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1189 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1191 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1193 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1195 HeapFree(GetProcessHeap(), 0, list.pOptions);
1197 /* get & verify the global IE proxy server */
1198 list.dwOptionCount = 2;
1199 list.dwOptionError = 0;
1200 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1202 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1203 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1205 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1207 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1208 ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
1209 "Retrieved proxy server should've been %s, was: %s\n",
1210 wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
1211 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1212 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1213 list.pOptions[1].Value.dwValue);
1214 verifyProxyEnable(1);
1216 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1217 HeapFree(GetProcessHeap(), 0, list.pOptions);
1219 /* disable the proxy server */
1220 list.dwOptionCount = 1;
1221 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1223 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1224 list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1226 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1228 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1230 HeapFree(GetProcessHeap(), 0, list.pOptions);
1232 /* verify that the proxy is disabled */
1233 list.dwOptionCount = 1;
1234 list.dwOptionError = 0;
1235 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1237 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1239 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1241 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1242 ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1243 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1244 list.pOptions[0].Value.dwValue);
1245 verifyProxyEnable(0);
1247 HeapFree(GetProcessHeap(), 0, list.pOptions);
1249 /* set the proxy flags to 'invalid' value */
1250 list.dwOptionCount = 1;
1251 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1253 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1254 list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1256 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1258 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1260 HeapFree(GetProcessHeap(), 0, list.pOptions);
1262 /* verify that the proxy is enabled */
1263 list.dwOptionCount = 1;
1264 list.dwOptionError = 0;
1265 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1267 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1269 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1271 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1272 todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1273 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1274 list.pOptions[0].Value.dwValue);
1275 verifyProxyEnable(1);
1277 HeapFree(GetProcessHeap(), 0, list.pOptions);
1279 /* restore original settings */
1280 list.dwOptionCount = 2;
1281 list.pOptions = orig_settings;
1283 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1285 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1287 HeapFree(GetProcessHeap(), 0, list.pOptions);
1290 static void test_Option_PerConnectionOptionA(void)
1293 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
1294 INTERNET_PER_CONN_OPTION_LISTA list = {size};
1295 INTERNET_PER_CONN_OPTIONA *orig_settings;
1296 char proxy_srv[] = "proxy.example";
1298 /* get the global IE proxy server info, to restore later */
1299 list.dwOptionCount = 2;
1300 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1302 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1303 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1305 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1307 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1308 orig_settings = list.pOptions;
1310 /* set the global IE proxy server */
1311 list.dwOptionCount = 2;
1312 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1314 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1315 list.pOptions[0].Value.pszValue = proxy_srv;
1316 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1317 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1319 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1321 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1323 HeapFree(GetProcessHeap(), 0, list.pOptions);
1325 /* get & verify the global IE proxy server */
1326 list.dwOptionCount = 2;
1327 list.dwOptionError = 0;
1328 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1330 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1331 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1333 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1335 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1336 ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1337 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1338 proxy_srv, list.pOptions[0].Value.pszValue);
1339 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1340 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1341 list.pOptions[1].Value.dwValue);
1343 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1344 HeapFree(GetProcessHeap(), 0, list.pOptions);
1346 /* restore original settings */
1347 list.dwOptionCount = 2;
1348 list.pOptions = orig_settings;
1350 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1352 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1354 HeapFree(GetProcessHeap(), 0, list.pOptions);
1357 #define FLAG_TODO 0x1
1358 #define FLAG_NEEDREQ 0x2
1359 #define FLAG_UNIMPL 0x4
1361 static void test_InternetErrorDlg(void)
1363 HINTERNET ses, con, req;
1367 static const struct {
1372 { ERROR_INTERNET_INCORRECT_PASSWORD , ERROR_SUCCESS, FLAG_NEEDREQ },
1373 { ERROR_INTERNET_SEC_CERT_DATE_INVALID , ERROR_CANCELLED, 0 },
1374 { ERROR_INTERNET_SEC_CERT_CN_INVALID , ERROR_CANCELLED, 0 },
1375 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR , ERROR_SUCCESS, 0 },
1376 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR , ERROR_SUCCESS, FLAG_TODO },
1377 { ERROR_INTERNET_MIXED_SECURITY , ERROR_CANCELLED, FLAG_TODO },
1378 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE , ERROR_CANCELLED, FLAG_TODO },
1379 { ERROR_INTERNET_POST_IS_NON_SECURE , ERROR_SUCCESS, 0 },
1380 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, ERROR_CANCELLED, FLAG_NEEDREQ|FLAG_TODO },
1381 { ERROR_INTERNET_INVALID_CA , ERROR_CANCELLED, 0 },
1382 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO },
1383 { ERROR_INTERNET_INSERT_CDROM , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL },
1384 { ERROR_INTERNET_SEC_CERT_ERRORS , ERROR_CANCELLED, 0 },
1385 { ERROR_INTERNET_SEC_CERT_REV_FAILED , ERROR_CANCELLED, 0 },
1386 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO },
1387 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT , ERROR_CANCELLED, FLAG_TODO },
1388 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO },
1389 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION, ERROR_CANCELLED, FLAG_TODO },
1390 { ERROR_INTERNET_SEC_CERT_REVOKED , ERROR_CANCELLED, 0 },
1391 { 0, ERROR_NOT_SUPPORTED }
1396 res = InternetErrorDlg(NULL, NULL, 12055, flags, NULL);
1397 ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1399 ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1400 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1401 con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1402 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1403 req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1404 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1406 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1407 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1409 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1410 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1413 hwnd = GetDesktopWindow();
1414 ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1416 flags = FLAGS_ERROR_UI_FLAGS_NO_UI;
1417 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1419 DWORD expected, test_flags, j;
1421 for(j = 0; no_ui_res[j].error != 0; ++j)
1422 if(no_ui_res[j].error == i)
1425 test_flags = no_ui_res[j].test_flags;
1426 expected = no_ui_res[j].res;
1428 /* Try an invalid request handle */
1429 res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
1430 if(res == ERROR_CALL_NOT_IMPLEMENTED)
1432 ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1436 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1438 /* With a valid req */
1439 if(i == ERROR_INTERNET_NEED_UI)
1440 continue; /* Crashes on windows XP */
1442 if(i == ERROR_INTERNET_SEC_CERT_REVOKED)
1443 continue; /* Interactive (XP, Win7) */
1445 res = InternetErrorDlg(hwnd, req, i, flags, NULL);
1447 /* Handle some special cases */
1450 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
1451 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR:
1452 if(res == ERROR_CANCELLED)
1454 /* Some windows XP, w2k3 x64, W2K8 */
1455 win_skip("Skipping some tests for %d\n", i);
1459 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED:
1462 /* Windows XP, W2K3 */
1463 ok(res == NTE_PROV_TYPE_NOT_DEF, "Got %d\n", res);
1464 win_skip("Skipping some tests for %d\n", i);
1471 if(test_flags & FLAG_TODO)
1472 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1474 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1476 /* Same thing with NULL hwnd */
1477 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1478 if(test_flags & FLAG_TODO)
1479 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1481 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1484 /* With a null req */
1485 if(test_flags & FLAG_NEEDREQ)
1486 expected = ERROR_INVALID_PARAMETER;
1488 res = InternetErrorDlg(hwnd, NULL, i, flags, NULL);
1489 if( test_flags & FLAG_TODO || i == ERROR_INTERNET_INCORRECT_PASSWORD)
1490 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1492 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1495 res = InternetCloseHandle(req);
1496 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1497 res = InternetCloseHandle(con);
1498 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1499 res = InternetCloseHandle(ses);
1500 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1503 /* ############################### */
1505 START_TEST(internet)
1508 hdll = GetModuleHandleA("wininet.dll");
1510 pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1511 pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1512 pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1513 pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1514 pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1515 pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1516 pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1517 pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1518 pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1519 pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
1520 pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
1522 if(!pInternetGetCookieExW) {
1523 win_skip("Too old IE (older than 6.0)\n");
1527 test_InternetCanonicalizeUrlA();
1528 test_InternetQueryOptionA();
1530 test_complicated_cookie();
1534 test_Option_PerConnectionOption();
1535 test_Option_PerConnectionOptionA();
1536 test_InternetErrorDlg();
1539 if (!pInternetTimeFromSystemTimeA)
1540 win_skip("skipping the InternetTime tests\n");
1543 InternetTimeFromSystemTimeA_test();
1544 InternetTimeFromSystemTimeW_test();
1545 InternetTimeToSystemTimeA_test();
1546 InternetTimeToSystemTimeW_test();
1548 if (pIsDomainLegalCookieDomainW &&
1549 ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1550 (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1551 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1552 else if (!pIsDomainLegalCookieDomainW)
1553 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1555 test_IsDomainLegalCookieDomainW();
1557 if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1558 test_PrivacyGetSetZonePreferenceW();
1560 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1562 test_InternetSetOption();