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 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
168 ok((hinet != 0x0),"InternetOpen Failed\n");
170 SetLastError(0xdeadbeef);
171 retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
173 ok(retval == 0,"Got wrong return value %d\n",retval);
174 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
176 SetLastError(0xdeadbeef);
177 len=strlen(useragent)+1;
178 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
180 ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
181 ok(retval == 0,"Got wrong return value %d\n",retval);
182 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
184 SetLastError(0xdeadbeef);
185 len=strlen(useragent)+1;
186 buffer=HeapAlloc(GetProcessHeap(),0,len);
187 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
189 ok(retval == 1,"Got wrong return value %d\n",retval);
192 ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
193 ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
195 ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
196 HeapFree(GetProcessHeap(),0,buffer);
198 SetLastError(0xdeadbeef);
200 buffer=HeapAlloc(GetProcessHeap(),0,100);
201 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
203 ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
204 ok(!retval, "Got wrong return value %d\n", retval);
205 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
206 HeapFree(GetProcessHeap(),0,buffer);
208 hurl = InternetConnectA(hinet,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
210 SetLastError(0xdeadbeef);
212 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
214 ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
215 ok(retval == 0,"Got wrong return value %d\n",retval);
216 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
218 SetLastError(0xdeadbeef);
220 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
221 err = GetLastError();
222 ok(retval == 0,"Got wrong return value %d\n",retval);
223 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
224 ok(len == sizeof(DWORD), "len = %d\n", len);
226 SetLastError(0xdeadbeef);
228 retval = InternetQueryOptionA(NULL,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
229 err = GetLastError();
230 ok(retval == 0,"Got wrong return value %d\n",retval);
231 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
232 ok(!len, "len = %d\n", len);
234 InternetCloseHandle(hurl);
235 InternetCloseHandle(hinet);
237 hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
238 ok((hinet != 0x0),"InternetOpen Failed\n");
240 SetLastError(0xdeadbeef);
242 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
244 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
245 ok(retval == 0,"Got wrong return value %d\n",retval);
246 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
248 InternetCloseHandle(hinet);
251 res = InternetSetOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
252 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
255 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
256 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
257 ok(val == 12345, "val = %d\n", val);
258 ok(len == sizeof(val), "len = %d\n", len);
260 hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
261 ok((hinet != 0x0),"InternetOpen Failed\n");
262 SetLastError(0xdeadbeef);
264 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
266 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
267 ok(retval == 0,"Got wrong return value %d\n",retval);
268 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
272 res = InternetQueryOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
273 ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
274 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
277 res = InternetSetOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
278 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
279 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
282 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
283 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
284 ok(val == 12345, "val = %d\n", val);
285 ok(len == sizeof(val), "len = %d\n", len);
288 res = InternetSetOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
289 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
292 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
293 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
294 ok(val == 1, "val = %d\n", val);
295 ok(len == sizeof(val), "len = %d\n", len);
298 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
299 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
300 ok(val == 12345, "val = %d\n", val);
301 ok(len == sizeof(val), "len = %d\n", len);
303 InternetCloseHandle(hinet);
306 static void test_max_conns(void)
313 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
314 ok(res,"Got wrong return value %x\n", res);
315 ok(len == sizeof(val), "got %d\n", len);
316 ok(val == 2, "got %d\n", val);
320 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len);
321 ok(res,"Got wrong return value %x\n", res);
322 ok(len == sizeof(val), "got %d\n", len);
323 ok(val == 4, "got %d\n", val);
326 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
327 ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res);
331 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
332 ok(res,"Got wrong return value %x\n", res);
333 ok(len == sizeof(val), "got %d\n", len);
334 ok(val == 3, "got %d\n", val);
337 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
338 ok(!res || broken(res), /* <= w2k3 */
339 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
340 if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError());
343 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)-1);
344 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
345 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
348 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)+1);
349 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
350 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
353 static void test_get_cookie(void)
358 SetLastError(0xdeadbeef);
359 ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
360 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
361 "InternetGetCookie should have failed with %s and error %d\n",
362 ret ? "TRUE" : "FALSE", GetLastError());
366 static void test_complicated_cookie(void)
374 ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
375 ok(ret == TRUE,"InternetSetCookie failed\n");
376 ret = InternetSetCookie("http://www.example.com/bar",NULL,"C=D; domain=.example.com; path=/");
377 ok(ret == TRUE,"InternetSetCookie failed\n");
379 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
380 ret = InternetSetCookie("http://www.example.com",NULL,"E=F; domain=example.com");
381 ok(ret == TRUE,"InternetSetCookie failed\n");
382 ret = InternetSetCookie("http://www.example.com",NULL,"G=H; domain=.example.com; path=/foo");
383 ok(ret == TRUE,"InternetSetCookie failed\n");
384 ret = InternetSetCookie("http://www.example.com/bar.html",NULL,"I=J; domain=.example.com");
385 ok(ret == TRUE,"InternetSetCookie failed\n");
386 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"K=L; domain=.example.com");
387 ok(ret == TRUE,"InternetSetCookie failed\n");
388 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"M=N; domain=.example.com; path=/foo/");
389 ok(ret == TRUE,"InternetSetCookie failed\n");
390 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"O=P; secure; path=/bar");
391 ok(ret == TRUE,"InternetSetCookie failed\n");
394 ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
395 ok(ret == TRUE,"InternetGetCookie failed\n");
396 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
397 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
398 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
399 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
400 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
401 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
402 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
403 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
406 ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len);
407 ok(ret == TRUE,"InternetGetCookie failed\n");
408 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
409 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
410 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
411 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
412 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
413 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
414 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
415 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
418 ret = InternetGetCookie("http://testing.example.com/foobar/", NULL, buffer, &len);
419 ok(ret == TRUE,"InternetGetCookie failed\n");
420 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
421 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
422 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
423 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
424 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
425 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
426 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
427 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
430 ret = InternetGetCookie("http://testing.example.com/foo/bar", NULL, buffer, &len);
431 ok(ret == TRUE,"InternetGetCookie failed\n");
432 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
433 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
434 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
435 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
436 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
437 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
438 ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n");
439 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
442 ret = InternetGetCookie("http://testing.example.com/barfoo", NULL, buffer, &len);
443 ok(ret == TRUE,"InternetGetCookie failed\n");
444 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
445 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
446 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
447 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
448 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
449 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
450 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
451 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
454 ret = InternetGetCookie("http://testing.example.com/barfoo/", NULL, buffer, &len);
455 ok(ret == TRUE,"InternetGetCookie failed\n");
456 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
457 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
458 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
459 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
460 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
461 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
462 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
463 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
466 ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len);
467 ok(ret == TRUE,"InternetGetCookie failed\n");
468 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
469 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
470 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
471 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
472 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
473 ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
474 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
475 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
477 /* test persistent cookies */
478 ret = InternetSetCookie("http://testing.example.com", NULL, "A=B; expires=Fri, 01-Jan-2038 00:00:00 GMT");
479 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
482 ret = GetUserName(user, &len);
483 ok(ret, "GetUserName failed with error %d\n", GetLastError());
485 user[len-1] = tolower(user[len-1]);
487 sprintf(buffer, "Cookie:%s@testing.example.com/", user);
488 ret = GetUrlCacheEntryInfo(buffer, NULL, &len);
489 ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
490 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %d\n", GetLastError());
492 /* remove persistent cookie */
493 ret = InternetSetCookie("http://testing.example.com", NULL, "A=B");
494 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
496 ret = GetUrlCacheEntryInfo(buffer, NULL, &len);
497 ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
498 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n", GetLastError());
500 /* try setting cookie for different domain */
501 ret = InternetSetCookie("http://www.aaa.example.com/bar",NULL,"E=F; domain=different.com");
502 ok(!ret, "InternetSetCookie succeeded\n");
503 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %d\n", GetLastError());
504 ret = InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=example.com.pl");
505 ok(ret, "InternetSetCookie failed with error: %d\n", GetLastError());
506 ret = InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=com.pl");
507 todo_wine ok(!ret, "InternetSetCookie succeeded\n");
510 static void test_cookie_url(void)
517 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
520 res = InternetGetCookieA("about:blank", NULL, buf, &len);
521 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
522 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
524 len = sizeof(bufw)/sizeof(*bufw);
525 res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
526 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
527 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
530 res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
531 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
532 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
534 len = sizeof(bufw)/sizeof(*bufw);
535 res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
536 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
537 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
540 static void test_null(void)
543 static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
544 static const WCHAR szEmpty[] = { 0 };
545 static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
546 static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
547 static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
552 SetLastError(0xdeadbeef);
553 hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
554 if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
556 win_skip("Internet*W functions are not implemented\n");
559 ok(hi != NULL, "open failed\n");
561 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
562 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
563 ok(hc == NULL, "connect failed\n");
565 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
566 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
567 ok(hc == NULL, "connect failed\n");
569 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
570 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
571 ok(hc == NULL, "connect failed\n");
573 hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
574 ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
575 ok(hc == NULL, "connect failed\n");
577 hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
578 ok(GetLastError() == ERROR_INVALID_PARAMETER ||
579 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
580 ok(hc == NULL, "connect failed\n");
582 hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
583 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
584 ok(hc == NULL, "connect failed\n");
586 InternetCloseHandle(hi);
588 r = InternetSetCookieW(NULL, NULL, NULL);
589 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
590 ok(r == FALSE, "return wrong\n");
592 r = InternetSetCookieW(szServer, NULL, NULL);
593 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
594 ok(r == FALSE, "return wrong\n");
596 r = InternetSetCookieW(szUrl, szServer, NULL);
597 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
598 ok(r == FALSE, "return wrong\n");
600 r = InternetSetCookieW(szUrl, szServer, szServer);
601 ok(r == TRUE, "return wrong\n");
603 r = InternetSetCookieW(szUrl, NULL, szServer);
604 ok(r == TRUE, "return wrong\n");
606 r = InternetSetCookieW(szUrl, szServer, szEmpty);
607 ok(r == TRUE, "return wrong\n");
609 r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
610 ok(r == FALSE, "return wrong\n");
612 r = InternetSetCookieW(szServer, NULL, szServer);
614 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
616 ok(r == FALSE, "return wrong\n");
619 r = InternetGetCookieW(NULL, NULL, NULL, &sz);
620 ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
621 "wrong error %u\n", GetLastError());
622 ok( r == FALSE, "return wrong\n");
624 r = InternetGetCookieW(szServer, NULL, NULL, &sz);
626 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
628 ok( r == FALSE, "return wrong\n");
631 r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
632 ok( r == FALSE, "return wrong\n");
635 r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
636 ok( r == TRUE, "return wrong\n");
638 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
639 ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz);
642 memset(buffer, 0, sizeof buffer);
643 r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
644 ok( r == TRUE, "return wrong\n");
646 /* sz == lstrlenW(buffer) only in XP SP1 */
647 ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
649 /* before XP SP2, buffer is "server; server" */
650 ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
653 r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
654 ok(r == TRUE, "ret %d\n", r);
657 static void test_version(void)
659 INTERNET_VERSION_INFO version;
663 size = sizeof(version);
664 res = InternetQueryOptionA(NULL, INTERNET_OPTION_VERSION, &version, &size);
665 ok(res, "Could not get version: %u\n", GetLastError());
666 ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
667 ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
670 static void InternetTimeFromSystemTimeA_test(void)
673 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
674 char string[INTERNET_RFC1123_BUFSIZE];
675 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
678 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
679 ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
681 ok( !memcmp( string, expect, sizeof(expect) ),
682 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
684 /* test NULL time parameter */
685 SetLastError(0xdeadbeef);
686 ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
687 error = GetLastError();
688 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
689 ok( error == ERROR_INVALID_PARAMETER,
690 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
693 /* test NULL string parameter */
694 SetLastError(0xdeadbeef);
695 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
696 error = GetLastError();
697 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
698 ok( error == ERROR_INVALID_PARAMETER,
699 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
702 /* test invalid format parameter */
703 SetLastError(0xdeadbeef);
704 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
705 error = GetLastError();
706 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
707 ok( error == ERROR_INVALID_PARAMETER,
708 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
711 /* test too small buffer size */
712 SetLastError(0xdeadbeef);
713 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
714 error = GetLastError();
715 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
716 ok( error == ERROR_INSUFFICIENT_BUFFER,
717 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
721 static void InternetTimeFromSystemTimeW_test(void)
724 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
725 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
726 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
727 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
730 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
731 ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
733 ok( !memcmp( string, expect, sizeof(expect) ),
734 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
736 /* test NULL time parameter */
737 SetLastError(0xdeadbeef);
738 ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
739 error = GetLastError();
740 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
741 ok( error == ERROR_INVALID_PARAMETER,
742 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
745 /* test NULL string parameter */
746 SetLastError(0xdeadbeef);
747 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
748 error = GetLastError();
749 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
750 ok( error == ERROR_INVALID_PARAMETER,
751 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
754 /* test invalid format parameter */
755 SetLastError(0xdeadbeef);
756 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
757 error = GetLastError();
758 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
759 ok( error == ERROR_INVALID_PARAMETER,
760 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
763 /* test too small buffer size */
764 SetLastError(0xdeadbeef);
765 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
766 error = GetLastError();
767 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
768 ok( error == ERROR_INSUFFICIENT_BUFFER,
769 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
773 static void InternetTimeToSystemTimeA_test(void)
777 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
778 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
779 static const char string2[] = " fri 7 jan 2005 12 06 35";
781 ret = pInternetTimeToSystemTimeA( string, &time, 0 );
782 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
783 ok( !memcmp( &time, &expect, sizeof(expect) ),
784 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
786 ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
787 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
788 ok( !memcmp( &time, &expect, sizeof(expect) ),
789 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
792 static void InternetTimeToSystemTimeW_test(void)
796 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
797 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
798 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
799 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
800 '1','2',' ','0','6',' ','3','5',0 };
801 static const WCHAR string3[] = { 'F','r',0 };
803 ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
804 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
806 ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
807 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
809 ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
810 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
812 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
813 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
815 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
816 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
817 ok( !memcmp( &time, &expect, sizeof(expect) ),
818 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
820 ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
821 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
822 ok( !memcmp( &time, &expect, sizeof(expect) ),
823 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
825 ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
826 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
829 static void test_IsDomainLegalCookieDomainW(void)
833 static const WCHAR empty[] = {0};
834 static const WCHAR dot[] = {'.',0};
835 static const WCHAR uk[] = {'u','k',0};
836 static const WCHAR com[] = {'c','o','m',0};
837 static const WCHAR dot_com[] = {'.','c','o','m',0};
838 static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
839 static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
840 static const WCHAR www_gmail_com[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
841 static const WCHAR www_mail_gmail_com[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
842 static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
843 static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
844 static const WCHAR co_uk[] = {'c','o','.','u','k',0};
845 static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
847 SetLastError(0xdeadbeef);
848 ret = pIsDomainLegalCookieDomainW(NULL, NULL);
849 error = GetLastError();
850 if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
852 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
856 broken(ret), /* IE6 */
857 "IsDomainLegalCookieDomainW succeeded\n");
858 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
860 SetLastError(0xdeadbeef);
861 ret = pIsDomainLegalCookieDomainW(com, NULL);
862 error = GetLastError();
863 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
864 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
866 SetLastError(0xdeadbeef);
867 ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
868 error = GetLastError();
869 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
870 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
872 SetLastError(0xdeadbeef);
873 ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
874 error = GetLastError();
875 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
876 ok(error == ERROR_INVALID_NAME ||
877 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
878 "got %u expected ERROR_INVALID_NAME\n", error);
880 SetLastError(0xdeadbeef);
881 ret = pIsDomainLegalCookieDomainW(com, empty);
882 error = GetLastError();
883 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
884 ok(error == ERROR_INVALID_NAME ||
885 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
886 "got %u expected ERROR_INVALID_NAME\n", error);
888 SetLastError(0xdeadbeef);
889 ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
890 error = GetLastError();
891 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
892 ok(error == ERROR_INVALID_NAME ||
893 broken(error == 0xdeadbeef), /* IE6 */
894 "got %u expected ERROR_INVALID_NAME\n", error);
896 SetLastError(0xdeadbeef);
897 ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
898 error = GetLastError();
899 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
900 ok(error == ERROR_INVALID_NAME ||
901 broken(error == 0xdeadbeef), /* IE6 */
902 "got %u expected ERROR_INVALID_NAME\n", error);
904 SetLastError(0xdeadbeef);
905 ret = pIsDomainLegalCookieDomainW(com, com);
906 error = GetLastError();
907 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
908 ok(error == 0xdeadbeef, "got %u expected 0xdeadbeef\n", error);
910 SetLastError(0xdeadbeef);
911 ret = pIsDomainLegalCookieDomainW(com, dot_com);
912 error = GetLastError();
913 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
914 ok(error == ERROR_INVALID_NAME ||
915 broken(error == 0xdeadbeef), /* IE6 */
916 "got %u expected ERROR_INVALID_NAME\n", error);
918 SetLastError(0xdeadbeef);
919 ret = pIsDomainLegalCookieDomainW(dot_com, com);
920 error = GetLastError();
921 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
922 ok(error == ERROR_INVALID_NAME ||
923 broken(error == 0xdeadbeef), /* IE6 */
924 "got %u expected ERROR_INVALID_NAME\n", error);
926 SetLastError(0xdeadbeef);
927 ret = pIsDomainLegalCookieDomainW(com, gmail_com);
928 error = GetLastError();
929 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
930 ok(error == ERROR_SXS_KEY_NOT_FOUND ||
931 error == ERROR_SUCCESS || /* IE8 on W2K3 */
932 error == 0xdeadbeef, /* up to IE7 */
933 "unexpected error: %u\n", error);
935 ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
936 ok(ret, "IsDomainLegalCookieDomainW failed\n");
938 ret = pIsDomainLegalCookieDomainW(gmail_com, www_gmail_com);
939 ok(ret, "IsDomainLegalCookieDomainW failed\n");
941 ret = pIsDomainLegalCookieDomainW(gmail_com, www_mail_gmail_com);
942 ok(ret, "IsDomainLegalCookieDomainW failed\n");
944 SetLastError(0xdeadbeef);
945 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
946 error = GetLastError();
947 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
948 ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
949 error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
950 error == ERROR_SUCCESS || /* IE8 on W2K3 */
951 error == 0xdeadbeef, /* up to IE7 */
952 "unexpected error: %u\n", error);
954 ret = pIsDomainLegalCookieDomainW(uk, co_uk);
955 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
957 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
958 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
960 ret = pIsDomainLegalCookieDomainW(co_uk, gmail_co_uk);
961 todo_wine ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
963 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
964 ok(ret, "IsDomainLegalCookieDomainW failed\n");
966 ret = pIsDomainLegalCookieDomainW(gmail_com, com);
967 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
969 SetLastError(0xdeadbeef);
970 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
971 error = GetLastError();
972 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
973 ok(error == ERROR_INVALID_NAME ||
974 broken(error == 0xdeadbeef), /* IE6 */
975 "got %u expected ERROR_INVALID_NAME\n", error);
977 ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
978 ok(ret, "IsDomainLegalCookieDomainW failed\n");
980 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
981 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
983 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
984 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
986 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
987 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
989 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
990 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
993 static void test_PrivacyGetSetZonePreferenceW(void)
995 DWORD ret, zone, type, template, old_template;
999 ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
1000 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1003 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
1004 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1007 ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
1008 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1011 ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
1012 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1013 ok(template == 5, "expected template == 5, got %u\n", template);
1016 ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
1017 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1020 static void test_InternetSetOption(void)
1022 HINTERNET ses, con, req;
1027 ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1028 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1029 con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1030 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1031 req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1032 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1034 /* INTERNET_OPTION_POLICY tests */
1035 SetLastError(0xdeadbeef);
1036 ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
1037 ok(ret == FALSE, "InternetSetOption should've failed\n");
1038 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1039 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1041 SetLastError(0xdeadbeef);
1042 ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
1043 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1044 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1045 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1047 /* INTERNET_OPTION_ERROR_MASK tests */
1048 SetLastError(0xdeadbeef);
1049 size = sizeof(ulArg);
1050 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
1051 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1052 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1054 SetLastError(0xdeadbeef);
1056 ret = InternetSetOption(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1057 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1058 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1060 SetLastError(0xdeadbeef);
1062 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
1063 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1064 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
1066 SetLastError(0xdeadbeef);
1068 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1069 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1070 ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
1072 SetLastError(0xdeadbeef);
1074 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1075 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1076 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1078 SetLastError(0xdeadbeef);
1080 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1081 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1082 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1084 ret = InternetCloseHandle(req);
1085 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1086 ret = InternetCloseHandle(con);
1087 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1088 ret = InternetCloseHandle(ses);
1089 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1092 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1093 static void r_verifyProxyEnable(LONG l, DWORD exp)
1096 DWORD type, val, size = sizeof(DWORD);
1098 static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1099 static const CHAR szProxyEnable[] = "ProxyEnable";
1101 ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
1102 ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
1104 ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
1105 ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
1106 ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
1107 ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
1109 ret = RegCloseKey(hkey);
1110 ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
1113 static void test_Option_PerConnectionOption(void)
1116 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
1117 INTERNET_PER_CONN_OPTION_LISTW list = {size};
1118 INTERNET_PER_CONN_OPTIONW *orig_settings;
1119 static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1121 /* get the global IE proxy server info, to restore later */
1122 list.dwOptionCount = 2;
1123 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1125 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1126 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1128 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1130 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1131 orig_settings = list.pOptions;
1133 /* set the global IE proxy server */
1134 list.dwOptionCount = 2;
1135 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1137 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1138 list.pOptions[0].Value.pszValue = proxy_srvW;
1139 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1140 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1142 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1144 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1146 HeapFree(GetProcessHeap(), 0, list.pOptions);
1148 /* get & verify the global IE proxy server */
1149 list.dwOptionCount = 2;
1150 list.dwOptionError = 0;
1151 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1153 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1154 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1156 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1158 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1159 ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
1160 "Retrieved proxy server should've been %s, was: %s\n",
1161 wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
1162 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1163 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1164 list.pOptions[1].Value.dwValue);
1165 verifyProxyEnable(1);
1167 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1168 HeapFree(GetProcessHeap(), 0, list.pOptions);
1170 /* disable the proxy server */
1171 list.dwOptionCount = 1;
1172 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1174 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1175 list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1177 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1179 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1181 HeapFree(GetProcessHeap(), 0, list.pOptions);
1183 /* verify that the proxy is disabled */
1184 list.dwOptionCount = 1;
1185 list.dwOptionError = 0;
1186 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1188 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1190 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1192 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1193 ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1194 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1195 list.pOptions[0].Value.dwValue);
1196 verifyProxyEnable(0);
1198 HeapFree(GetProcessHeap(), 0, list.pOptions);
1200 /* set the proxy flags to 'invalid' value */
1201 list.dwOptionCount = 1;
1202 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1204 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1205 list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1207 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1209 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1211 HeapFree(GetProcessHeap(), 0, list.pOptions);
1213 /* verify that the proxy is enabled */
1214 list.dwOptionCount = 1;
1215 list.dwOptionError = 0;
1216 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1218 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1220 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1222 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1223 todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1224 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1225 list.pOptions[0].Value.dwValue);
1226 verifyProxyEnable(1);
1228 HeapFree(GetProcessHeap(), 0, list.pOptions);
1230 /* restore original settings */
1231 list.dwOptionCount = 2;
1232 list.pOptions = orig_settings;
1234 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1236 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1238 HeapFree(GetProcessHeap(), 0, list.pOptions);
1241 static void test_Option_PerConnectionOptionA(void)
1244 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
1245 INTERNET_PER_CONN_OPTION_LISTA list = {size};
1246 INTERNET_PER_CONN_OPTIONA *orig_settings;
1247 char proxy_srv[] = "proxy.example";
1249 /* get the global IE proxy server info, to restore later */
1250 list.dwOptionCount = 2;
1251 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1253 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1254 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1256 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1258 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1259 orig_settings = list.pOptions;
1261 /* set the global IE proxy server */
1262 list.dwOptionCount = 2;
1263 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1265 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1266 list.pOptions[0].Value.pszValue = proxy_srv;
1267 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1268 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1270 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1272 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1274 HeapFree(GetProcessHeap(), 0, list.pOptions);
1276 /* get & verify the global IE proxy server */
1277 list.dwOptionCount = 2;
1278 list.dwOptionError = 0;
1279 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1281 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1282 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1284 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1286 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1287 ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1288 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1289 proxy_srv, list.pOptions[0].Value.pszValue);
1290 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1291 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1292 list.pOptions[1].Value.dwValue);
1294 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1295 HeapFree(GetProcessHeap(), 0, list.pOptions);
1297 /* restore original settings */
1298 list.dwOptionCount = 2;
1299 list.pOptions = orig_settings;
1301 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1303 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1305 HeapFree(GetProcessHeap(), 0, list.pOptions);
1308 #define FLAG_TODO 0x1
1309 #define FLAG_NEEDREQ 0x2
1310 #define FLAG_UNIMPL 0x4
1312 static void test_InternetErrorDlg(void)
1314 HINTERNET ses, con, req;
1318 static const struct {
1323 { ERROR_INTERNET_INCORRECT_PASSWORD , ERROR_SUCCESS, FLAG_NEEDREQ },
1324 { ERROR_INTERNET_SEC_CERT_DATE_INVALID , ERROR_CANCELLED, 0 },
1325 { ERROR_INTERNET_SEC_CERT_CN_INVALID , ERROR_CANCELLED, 0 },
1326 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR , ERROR_SUCCESS, 0 },
1327 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR , ERROR_SUCCESS, FLAG_TODO },
1328 { ERROR_INTERNET_MIXED_SECURITY , ERROR_CANCELLED, FLAG_TODO },
1329 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE , ERROR_CANCELLED, FLAG_TODO },
1330 { ERROR_INTERNET_POST_IS_NON_SECURE , ERROR_SUCCESS, 0 },
1331 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, ERROR_CANCELLED, FLAG_NEEDREQ|FLAG_TODO },
1332 { ERROR_INTERNET_INVALID_CA , ERROR_CANCELLED, 0 },
1333 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO },
1334 { ERROR_INTERNET_INSERT_CDROM , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL },
1335 { ERROR_INTERNET_SEC_CERT_ERRORS , ERROR_CANCELLED, 0 },
1336 { ERROR_INTERNET_SEC_CERT_REV_FAILED , ERROR_CANCELLED, 0 },
1337 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO },
1338 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT , ERROR_CANCELLED, FLAG_TODO },
1339 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO },
1340 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION, ERROR_CANCELLED, FLAG_TODO },
1341 { ERROR_INTERNET_SEC_CERT_REVOKED , ERROR_CANCELLED, 0 },
1342 { 0, ERROR_NOT_SUPPORTED }
1347 res = InternetErrorDlg(NULL, NULL, 12055, flags, NULL);
1348 ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1350 ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1351 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1352 con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1353 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1354 req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1355 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1357 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1358 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1360 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1361 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1364 hwnd = GetDesktopWindow();
1365 ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1367 flags = FLAGS_ERROR_UI_FLAGS_NO_UI;
1368 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1370 DWORD expected, test_flags, j;
1372 for(j = 0; no_ui_res[j].error != 0; ++j)
1373 if(no_ui_res[j].error == i)
1376 test_flags = no_ui_res[j].test_flags;
1377 expected = no_ui_res[j].res;
1379 /* Try an invalid request handle */
1380 res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
1381 if(res == ERROR_CALL_NOT_IMPLEMENTED)
1383 ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1387 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1389 /* With a valid req */
1390 if(i == ERROR_INTERNET_NEED_UI)
1391 continue; /* Crashes on windows XP */
1393 if(i == ERROR_INTERNET_SEC_CERT_REVOKED)
1394 continue; /* Interactive (XP, Win7) */
1396 res = InternetErrorDlg(hwnd, req, i, flags, NULL);
1398 /* Handle some special cases */
1401 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
1402 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR:
1403 if(res == ERROR_CANCELLED)
1405 /* Some windows XP, w2k3 x64, W2K8 */
1406 win_skip("Skipping some tests for %d\n", i);
1410 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED:
1413 /* Windows XP, W2K3 */
1414 ok(res == NTE_PROV_TYPE_NOT_DEF, "Got %d\n", res);
1415 win_skip("Skipping some tests for %d\n", i);
1422 if(test_flags & FLAG_TODO)
1423 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1425 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1427 /* Same thing with NULL hwnd */
1428 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1429 if(test_flags & FLAG_TODO)
1430 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1432 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1435 /* With a null req */
1436 if(test_flags & FLAG_NEEDREQ)
1437 expected = ERROR_INVALID_PARAMETER;
1439 res = InternetErrorDlg(hwnd, NULL, i, flags, NULL);
1440 if( test_flags & FLAG_TODO || i == ERROR_INTERNET_INCORRECT_PASSWORD)
1441 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1443 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1446 res = InternetCloseHandle(req);
1447 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1448 res = InternetCloseHandle(con);
1449 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1450 res = InternetCloseHandle(ses);
1451 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1454 /* ############################### */
1456 START_TEST(internet)
1459 hdll = GetModuleHandleA("wininet.dll");
1461 pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1462 pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1463 pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1464 pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1465 pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1466 pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1467 pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1468 pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1469 pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1470 pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
1471 pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
1473 if(!pInternetGetCookieExW) {
1474 win_skip("Too old IE (older than 6.0)\n");
1478 test_InternetCanonicalizeUrlA();
1479 test_InternetQueryOptionA();
1481 test_complicated_cookie();
1485 test_Option_PerConnectionOption();
1486 test_Option_PerConnectionOptionA();
1487 test_InternetErrorDlg();
1490 if (!pInternetTimeFromSystemTimeA)
1491 win_skip("skipping the InternetTime tests\n");
1494 InternetTimeFromSystemTimeA_test();
1495 InternetTimeFromSystemTimeW_test();
1496 InternetTimeToSystemTimeA_test();
1497 InternetTimeToSystemTimeW_test();
1499 if (pIsDomainLegalCookieDomainW &&
1500 ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1501 (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1502 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1503 else if (!pIsDomainLegalCookieDomainW)
1504 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1506 test_IsDomainLegalCookieDomainW();
1508 if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1509 test_PrivacyGetSetZonePreferenceW();
1511 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1513 test_InternetSetOption();