TESTING -- override pthreads to fix gstreamer v5
[wine/multimedia.git] / dlls / wininet / tests / internet.c
blob5636d4b264f210a8fc85a05499513a1278b56b75
1 /*
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
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wininet.h"
28 #include "winerror.h"
29 #include "winreg.h"
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);
46 static BOOL (WINAPI *pInternetGetConnectedStateExA)(LPDWORD,LPSTR,DWORD,DWORD);
47 static BOOL (WINAPI *pInternetGetConnectedStateExW)(LPDWORD,LPWSTR,DWORD,DWORD);
49 /* ############################### */
51 static void test_InternetCanonicalizeUrlA(void)
53 CHAR buffer[256];
54 LPCSTR url;
55 DWORD urllen;
56 DWORD dwSize;
57 DWORD res;
59 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
60 url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
61 urllen = lstrlenA(url);
63 memset(buffer, '#', sizeof(buffer)-1);
64 buffer[sizeof(buffer)-1] = '\0';
65 dwSize = 1; /* Acrobat Updater use this size */
66 SetLastError(0xdeadbeef);
67 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
68 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
69 "got %u and %u with size %u for '%s' (%d)\n",
70 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
73 /* buffer has no space for the terminating '\0' */
74 memset(buffer, '#', sizeof(buffer)-1);
75 buffer[sizeof(buffer)-1] = '\0';
76 dwSize = urllen;
77 SetLastError(0xdeadbeef);
78 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
79 /* dwSize is nr. of needed bytes with the terminating '\0' */
80 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
81 "got %u and %u with size %u for '%s' (%d)\n",
82 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
84 /* buffer has the required size */
85 memset(buffer, '#', sizeof(buffer)-1);
86 buffer[sizeof(buffer)-1] = '\0';
87 dwSize = urllen+1;
88 SetLastError(0xdeadbeef);
89 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
90 /* dwSize is nr. of copied bytes without the terminating '\0' */
91 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
92 "got %u and %u with size %u for '%s' (%d)\n",
93 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
95 memset(buffer, '#', sizeof(buffer)-1);
96 buffer[sizeof(buffer)-1] = '\0';
97 dwSize = sizeof(buffer);
98 SetLastError(0xdeadbeef);
99 res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
100 ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
101 ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
102 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
103 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
105 /* buffer is larger as the required size */
106 memset(buffer, '#', sizeof(buffer)-1);
107 buffer[sizeof(buffer)-1] = '\0';
108 dwSize = urllen+2;
109 SetLastError(0xdeadbeef);
110 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
111 /* dwSize is nr. of copied bytes without the terminating '\0' */
112 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
113 "got %u and %u with size %u for '%s' (%d)\n",
114 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
117 /* check NULL pointers */
118 memset(buffer, '#', urllen + 4);
119 buffer[urllen + 4] = '\0';
120 dwSize = urllen+1;
121 SetLastError(0xdeadbeef);
122 res = InternetCanonicalizeUrlA(NULL, buffer, &dwSize, 0);
123 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
124 "got %u and %u with size %u for '%s' (%d)\n",
125 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
127 memset(buffer, '#', urllen + 4);
128 buffer[urllen + 4] = '\0';
129 dwSize = urllen+1;
130 SetLastError(0xdeadbeef);
131 res = InternetCanonicalizeUrlA(url, NULL, &dwSize, 0);
132 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
133 "got %u and %u with size %u for '%s' (%d)\n",
134 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
136 memset(buffer, '#', urllen + 4);
137 buffer[urllen + 4] = '\0';
138 dwSize = urllen+1;
139 SetLastError(0xdeadbeef);
140 res = InternetCanonicalizeUrlA(url, buffer, NULL, 0);
141 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
142 "got %u and %u with size %u for '%s' (%d)\n",
143 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
145 /* test with trailing space */
146 dwSize = 256;
147 res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
148 ok(res == 1, "InternetCanonicalizeUrlA failed\n");
149 ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
151 res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
152 ok(!res, "InternetSetOptionA succeeded\n");
153 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION,
154 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
157 /* ############################### */
159 static void test_InternetQueryOptionA(void)
161 HINTERNET hinet,hurl;
162 DWORD len, val;
163 DWORD err;
164 static const char useragent[] = {"Wininet Test"};
165 char *buffer;
166 int retval;
167 BOOL res;
169 SetLastError(0xdeadbeef);
170 len = 0xdeadbeef;
171 retval = InternetQueryOptionA(NULL, INTERNET_OPTION_PROXY, NULL, &len);
172 ok(!retval && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got wrong error %x(%u)\n", retval, GetLastError());
173 ok(len >= sizeof(INTERNET_PROXY_INFOA) && len != 0xdeadbeef,"len = %u\n", len);
175 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
176 ok((hinet != 0x0),"InternetOpen Failed\n");
178 SetLastError(0xdeadbeef);
179 retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
180 err=GetLastError();
181 ok(retval == 0,"Got wrong return value %d\n",retval);
182 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
184 SetLastError(0xdeadbeef);
185 len=strlen(useragent)+1;
186 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
187 err=GetLastError();
188 ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
189 ok(retval == 0,"Got wrong return value %d\n",retval);
190 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
192 len=strlen(useragent)+1;
193 buffer=HeapAlloc(GetProcessHeap(),0,len);
194 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
195 ok(retval == 1,"Got wrong return value %d\n",retval);
196 if (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 HeapFree(GetProcessHeap(),0,buffer);
203 SetLastError(0xdeadbeef);
204 len=0;
205 buffer=HeapAlloc(GetProcessHeap(),0,100);
206 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
207 err=GetLastError();
208 ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
209 ok(!retval, "Got wrong return value %d\n", retval);
210 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
211 HeapFree(GetProcessHeap(),0,buffer);
213 hurl = InternetConnectA(hinet,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
215 SetLastError(0xdeadbeef);
216 len=0;
217 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
218 err=GetLastError();
219 ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
220 ok(retval == 0,"Got wrong return value %d\n",retval);
221 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
223 SetLastError(0xdeadbeef);
224 len = sizeof(DWORD);
225 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
226 err = GetLastError();
227 ok(retval == 0,"Got wrong return value %d\n",retval);
228 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
229 ok(len == sizeof(DWORD), "len = %d\n", len);
231 SetLastError(0xdeadbeef);
232 len = sizeof(DWORD);
233 retval = InternetQueryOptionA(NULL,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
234 err = GetLastError();
235 ok(retval == 0,"Got wrong return value %d\n",retval);
236 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
237 ok(!len, "len = %d\n", len);
239 InternetCloseHandle(hurl);
240 InternetCloseHandle(hinet);
242 hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
243 ok((hinet != 0x0),"InternetOpen Failed\n");
245 SetLastError(0xdeadbeef);
246 len=0;
247 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
248 err=GetLastError();
249 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
250 ok(retval == 0,"Got wrong return value %d\n",retval);
251 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
253 InternetCloseHandle(hinet);
255 val = 12345;
256 res = InternetSetOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
257 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
259 len = sizeof(val);
260 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
261 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
262 ok(val == 12345, "val = %d\n", val);
263 ok(len == sizeof(val), "len = %d\n", len);
265 hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
266 ok((hinet != 0x0),"InternetOpen Failed\n");
267 SetLastError(0xdeadbeef);
268 len=0;
269 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
270 err=GetLastError();
271 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
272 ok(retval == 0,"Got wrong return value %d\n",retval);
273 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
275 len = sizeof(val);
276 val = 0xdeadbeef;
277 res = InternetQueryOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
278 ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
279 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
281 val = 2;
282 res = InternetSetOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
283 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
284 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
286 len = sizeof(val);
287 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
288 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
289 ok(val == 12345, "val = %d\n", val);
290 ok(len == sizeof(val), "len = %d\n", len);
292 val = 1;
293 res = InternetSetOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
294 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
296 len = sizeof(val);
297 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
298 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
299 ok(val == 1, "val = %d\n", val);
300 ok(len == sizeof(val), "len = %d\n", len);
302 len = sizeof(val);
303 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
304 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
305 ok(val == 12345, "val = %d\n", val);
306 ok(len == sizeof(val), "len = %d\n", len);
308 InternetCloseHandle(hinet);
311 static void test_max_conns(void)
313 DWORD len, val;
314 BOOL res;
316 len = sizeof(val);
317 val = 0xdeadbeef;
318 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
319 ok(res,"Got wrong return value %x\n", res);
320 ok(len == sizeof(val), "got %d\n", len);
321 trace("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", val);
323 len = sizeof(val);
324 val = 0xdeadbeef;
325 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len);
326 ok(res,"Got wrong return value %x\n", res);
327 ok(len == sizeof(val), "got %d\n", len);
328 trace("INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", val);
330 val = 3;
331 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
332 ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res);
334 len = sizeof(val);
335 val = 0xdeadbeef;
336 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
337 ok(res,"Got wrong return value %x\n", res);
338 ok(len == sizeof(val), "got %d\n", len);
339 ok(val == 3, "got %d\n", val);
341 val = 0;
342 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
343 ok(!res || broken(res), /* <= w2k3 */
344 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
345 if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError());
347 val = 2;
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());
352 val = 2;
353 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)+1);
354 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
355 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
358 static void test_get_cookie(void)
360 DWORD len;
361 BOOL ret;
363 SetLastError(0xdeadbeef);
364 ret = InternetGetCookieA("http://www.example.com", NULL, NULL, &len);
365 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
366 "InternetGetCookie should have failed with %s and error %d\n",
367 ret ? "TRUE" : "FALSE", GetLastError());
371 static void test_complicated_cookie(void)
373 DWORD len;
374 BOOL ret;
376 CHAR buffer[1024];
377 CHAR user[256];
378 WCHAR wbuf[1024];
380 static const WCHAR testing_example_comW[] =
381 {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.','e','x','a','m','p','l','e','.','c','o','m',0};
383 ret = InternetSetCookieA("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
384 ok(ret == TRUE,"InternetSetCookie failed\n");
385 ret = InternetSetCookieA("http://www.example.com/bar",NULL,"C=D; domain=.example.com; path=/");
386 ok(ret == TRUE,"InternetSetCookie failed\n");
388 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
389 ret = InternetSetCookieA("http://www.example.com",NULL,"E=F; domain=example.com");
390 ok(ret == TRUE,"InternetSetCookie failed\n");
391 ret = InternetSetCookieA("http://www.example.com",NULL,"G=H; domain=.example.com; path=/foo");
392 ok(ret == TRUE,"InternetSetCookie failed\n");
393 ret = InternetSetCookieA("http://www.example.com/bar.html",NULL,"I=J; domain=.example.com");
394 ok(ret == TRUE,"InternetSetCookie failed\n");
395 ret = InternetSetCookieA("http://www.example.com/bar/",NULL,"K=L; domain=.example.com");
396 ok(ret == TRUE,"InternetSetCookie failed\n");
397 ret = InternetSetCookieA("http://www.example.com/bar/",NULL,"M=N; domain=.example.com; path=/foo/");
398 ok(ret == TRUE,"InternetSetCookie failed\n");
399 ret = InternetSetCookieA("http://www.example.com/bar/",NULL,"O=P; secure; path=/bar");
400 ok(ret == TRUE,"InternetSetCookie failed\n");
402 len = 1024;
403 ret = InternetGetCookieA("http://testing.example.com", NULL, NULL, &len);
404 ok(ret == TRUE,"InternetGetCookie failed\n");
405 ok(len == 19, "len = %u\n", len);
407 len = 1024;
408 memset(buffer, 0xac, sizeof(buffer));
409 ret = InternetGetCookieA("http://testing.example.com", NULL, buffer, &len);
410 ok(ret == TRUE,"InternetGetCookie failed\n");
411 ok(len == 19, "len = %u\n", len);
412 ok(strlen(buffer) == 18, "strlen(buffer) = %u\n", lstrlenA(buffer));
413 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
414 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
415 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
416 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
417 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
418 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
419 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
420 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
422 len = 10;
423 memset(buffer, 0xac, sizeof(buffer));
424 ret = InternetGetCookieA("http://testing.example.com", NULL, buffer, &len);
425 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
426 "InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
427 ok(len == 19, "len = %u\n", len);
429 len = 1024;
430 ret = InternetGetCookieW(testing_example_comW, NULL, NULL, &len);
431 ok(ret == TRUE,"InternetGetCookieW failed\n");
432 ok(len == 38, "len = %u\n", len);
434 len = 1024;
435 memset(wbuf, 0xac, sizeof(wbuf));
436 ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
437 ok(ret == TRUE,"InternetGetCookieW failed\n");
438 ok(len == 19 || broken(len==18), "len = %u\n", len);
439 ok(lstrlenW(wbuf) == 18, "strlenW(wbuf) = %u\n", lstrlenW(wbuf));
441 len = 10;
442 memset(wbuf, 0xac, sizeof(wbuf));
443 ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
444 ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
445 "InternetGetCookieW returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
446 ok(len == 38, "len = %u\n", len);
448 len = 1024;
449 ret = InternetGetCookieA("http://testing.example.com/foobar", NULL, buffer, &len);
450 ok(ret == TRUE,"InternetGetCookie failed\n");
451 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
452 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
453 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
454 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
455 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
456 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
457 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
458 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
460 len = 1024;
461 ret = InternetGetCookieA("http://testing.example.com/foobar/", NULL, buffer, &len);
462 ok(ret == TRUE,"InternetGetCookie failed\n");
463 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
464 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
465 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
466 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
467 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
468 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
469 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
470 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
472 len = 1024;
473 ret = InternetGetCookieA("http://testing.example.com/foo/bar", NULL, buffer, &len);
474 ok(ret == TRUE,"InternetGetCookie failed\n");
475 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
476 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
477 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
478 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
479 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
480 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
481 ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n");
482 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
484 len = 1024;
485 ret = InternetGetCookieA("http://testing.example.com/barfoo", NULL, buffer, &len);
486 ok(ret == TRUE,"InternetGetCookie failed\n");
487 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
488 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
489 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
490 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
491 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
492 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
493 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
494 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
496 len = 1024;
497 ret = InternetGetCookieA("http://testing.example.com/barfoo/", NULL, buffer, &len);
498 ok(ret == TRUE,"InternetGetCookie failed\n");
499 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
500 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
501 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
502 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
503 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
504 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
505 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
506 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
508 len = 1024;
509 ret = InternetGetCookieA("http://testing.example.com/bar/foo", NULL, buffer, &len);
510 ok(ret == TRUE,"InternetGetCookie failed\n");
511 ok(len == 24, "len = %u\n", 24);
512 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
513 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
514 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
515 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
516 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
517 ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
518 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
519 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
521 /* Cookie name argument is not implemented */
522 len = 1024;
523 ret = InternetGetCookieA("http://testing.example.com/bar/foo", "A", buffer, &len);
524 ok(ret == TRUE,"InternetGetCookie failed\n");
525 ok(len == 24, "len = %u\n", 24);
527 /* test persistent cookies */
528 ret = InternetSetCookieA("http://testing.example.com", NULL, "A=B; expires=Fri, 01-Jan-2038 00:00:00 GMT");
529 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
531 len = sizeof(user);
532 ret = GetUserNameA(user, &len);
533 ok(ret, "GetUserName failed with error %d\n", GetLastError());
534 for(; len>0; len--)
535 user[len-1] = tolower(user[len-1]);
537 sprintf(buffer, "Cookie:%s@testing.example.com/", user);
538 ret = GetUrlCacheEntryInfoA(buffer, NULL, &len);
539 ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
540 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %d\n", GetLastError());
542 /* remove persistent cookie */
543 ret = InternetSetCookieA("http://testing.example.com", NULL, "A=B");
544 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
546 ret = GetUrlCacheEntryInfoA(buffer, NULL, &len);
547 ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
548 ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n", GetLastError());
550 /* try setting cookie for different domain */
551 ret = InternetSetCookieA("http://www.aaa.example.com/bar",NULL,"E=F; domain=different.com");
552 ok(!ret, "InternetSetCookie succeeded\n");
553 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %d\n", GetLastError());
554 ret = InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=example.com.pl");
555 ok(ret, "InternetSetCookie failed with error: %d\n", GetLastError());
556 ret = InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=com.pl");
557 todo_wine ok(!ret, "InternetSetCookie succeeded\n");
560 static void test_cookie_attrs(void)
562 char buf[100];
563 DWORD size, state;
564 BOOL ret;
566 if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "InternetGetSecurityInfoByURLA")) {
567 win_skip("Skipping cookie attributes tests. Too old IE.\n");
568 return;
571 ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=data; httponly");
572 ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
574 SetLastError(0xdeadbeef);
575 state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data; httponly", 0, 0);
576 ok(state == COOKIE_STATE_REJECT && GetLastError() == ERROR_INVALID_OPERATION,
577 "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
579 size = sizeof(buf);
580 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
581 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
583 state = InternetSetCookieExA("http://cookie.attrs.com/bar",NULL,"A=data; httponly", INTERNET_COOKIE_HTTPONLY, 0);
584 ok(state == COOKIE_STATE_ACCEPT,"InternetSetCookieEx failed: %u\n", GetLastError());
586 size = sizeof(buf);
587 ret = InternetGetCookieA("http://cookie.attrs.com/", NULL, buf, &size);
588 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned: %x (%u)\n", ret, GetLastError());
590 size = sizeof(buf);
591 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, 0, NULL);
592 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
594 size = sizeof(buf);
595 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
596 ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
597 ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
599 /* Try to override httponly cookie with non-httponly one */
600 ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=test");
601 ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
603 SetLastError(0xdeadbeef);
604 state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data", 0, 0);
605 ok(state == COOKIE_STATE_REJECT && GetLastError() == ERROR_INVALID_OPERATION,
606 "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
608 size = sizeof(buf);
609 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
610 ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
611 ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
615 static void test_cookie_url(void)
617 WCHAR bufw[512];
618 char buf[512];
619 DWORD len;
620 BOOL res;
622 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
624 len = sizeof(buf);
625 res = InternetGetCookieA("about:blank", NULL, buf, &len);
626 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
627 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
629 len = sizeof(bufw)/sizeof(*bufw);
630 res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
631 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
632 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
634 len = sizeof(buf);
635 res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
636 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
637 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
639 len = sizeof(bufw)/sizeof(*bufw);
640 res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
641 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
642 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
645 static void test_null(void)
647 HINTERNET hi, hc;
648 static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
649 static const WCHAR szServer2[] = { 's','e','r','v','e','r','=',0 };
650 static const WCHAR szEmpty[] = { 0 };
651 static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
652 static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
653 static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
654 WCHAR buffer[0x20];
655 BOOL r;
656 DWORD sz;
658 SetLastError(0xdeadbeef);
659 hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
660 if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
662 win_skip("Internet*W functions are not implemented\n");
663 return;
665 ok(hi != NULL, "open failed\n");
667 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
668 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
669 ok(hc == NULL, "connect failed\n");
671 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
672 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
673 ok(hc == NULL, "connect failed\n");
675 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
676 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
677 ok(hc == NULL, "connect failed\n");
679 hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
680 ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
681 ok(hc == NULL, "connect failed\n");
683 hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
684 ok(GetLastError() == ERROR_INVALID_PARAMETER ||
685 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
686 ok(hc == NULL, "connect failed\n");
688 hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
689 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
690 ok(hc == NULL, "connect failed\n");
692 InternetCloseHandle(hi);
694 r = InternetSetCookieW(NULL, NULL, NULL);
695 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
696 ok(r == FALSE, "return wrong\n");
698 r = InternetSetCookieW(szServer, NULL, NULL);
699 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
700 ok(r == FALSE, "return wrong\n");
702 r = InternetSetCookieW(szUrl, szServer, NULL);
703 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
704 ok(r == FALSE, "return wrong\n");
706 r = InternetSetCookieW(szUrl, szServer, szServer);
707 ok(r == TRUE, "return wrong\n");
709 r = InternetSetCookieW(szUrl, NULL, szServer);
710 ok(r == TRUE, "return wrong\n");
712 r = InternetSetCookieW(szUrl, szServer, szEmpty);
713 ok(r == TRUE, "return wrong\n");
715 r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
716 ok(r == FALSE, "return wrong\n");
718 r = InternetSetCookieW(szServer, NULL, szServer);
719 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
720 ok(r == FALSE, "return wrong\n");
722 sz = 0;
723 r = InternetGetCookieW(NULL, NULL, NULL, &sz);
724 ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
725 "wrong error %u\n", GetLastError());
726 ok( r == FALSE, "return wrong\n");
728 r = InternetGetCookieW(szServer, NULL, NULL, &sz);
729 todo_wine {
730 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
732 ok( r == FALSE, "return wrong\n");
734 sz = 0;
735 r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
736 ok( r == FALSE, "return wrong\n");
738 sz = 0;
739 r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
740 ok( r == TRUE, "return wrong\n");
742 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */
743 ok( sz == 14 || sz == 16 || sz == 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz);
745 sz = 0x20;
746 memset(buffer, 0, sizeof buffer);
747 r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
748 ok( r == TRUE, "return wrong\n");
750 /* sz == lstrlenW(buffer) only in XP SP1 */
751 ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
753 /* before XP SP2, buffer is "server; server" */
754 ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer) || !lstrcmpW(szServer2, buffer),
755 "cookie data wrong %s\n", wine_dbgstr_w(buffer));
757 sz = sizeof(buffer);
758 r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
759 ok(r == TRUE, "ret %d\n", r);
762 static void test_version(void)
764 INTERNET_VERSION_INFO version;
765 DWORD size;
766 BOOL res;
768 size = sizeof(version);
769 res = InternetQueryOptionA(NULL, INTERNET_OPTION_VERSION, &version, &size);
770 ok(res, "Could not get version: %u\n", GetLastError());
771 ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
772 ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
775 static void InternetTimeFromSystemTimeA_test(void)
777 BOOL ret;
778 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
779 char string[INTERNET_RFC1123_BUFSIZE];
780 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
781 DWORD error;
783 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
784 ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
786 ok( !memcmp( string, expect, sizeof(expect) ),
787 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
789 /* test NULL time parameter */
790 SetLastError(0xdeadbeef);
791 ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
792 error = GetLastError();
793 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
794 ok( error == ERROR_INVALID_PARAMETER,
795 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
796 error );
798 /* test NULL string parameter */
799 SetLastError(0xdeadbeef);
800 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
801 error = GetLastError();
802 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
803 ok( error == ERROR_INVALID_PARAMETER,
804 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
805 error );
807 /* test invalid format parameter */
808 SetLastError(0xdeadbeef);
809 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
810 error = GetLastError();
811 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
812 ok( error == ERROR_INVALID_PARAMETER,
813 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
814 error );
816 /* test too small buffer size */
817 SetLastError(0xdeadbeef);
818 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
819 error = GetLastError();
820 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
821 ok( error == ERROR_INSUFFICIENT_BUFFER,
822 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
823 error );
826 static void InternetTimeFromSystemTimeW_test(void)
828 BOOL ret;
829 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
830 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
831 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
832 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
833 DWORD error;
835 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
836 ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
838 ok( !memcmp( string, expect, sizeof(expect) ),
839 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
841 /* test NULL time parameter */
842 SetLastError(0xdeadbeef);
843 ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
844 error = GetLastError();
845 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
846 ok( error == ERROR_INVALID_PARAMETER,
847 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
848 error );
850 /* test NULL string parameter */
851 SetLastError(0xdeadbeef);
852 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
853 error = GetLastError();
854 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
855 ok( error == ERROR_INVALID_PARAMETER,
856 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
857 error );
859 /* test invalid format parameter */
860 SetLastError(0xdeadbeef);
861 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
862 error = GetLastError();
863 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
864 ok( error == ERROR_INVALID_PARAMETER,
865 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
866 error );
868 /* test too small buffer size */
869 SetLastError(0xdeadbeef);
870 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
871 error = GetLastError();
872 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
873 ok( error == ERROR_INSUFFICIENT_BUFFER,
874 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
875 error );
878 static void InternetTimeToSystemTimeA_test(void)
880 BOOL ret;
881 SYSTEMTIME time;
882 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
883 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
884 static const char string2[] = " fri 7 jan 2005 12 06 35";
886 ret = pInternetTimeToSystemTimeA( string, &time, 0 );
887 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
888 ok( !memcmp( &time, &expect, sizeof(expect) ),
889 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
891 ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
892 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
893 ok( !memcmp( &time, &expect, sizeof(expect) ),
894 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
897 static void InternetTimeToSystemTimeW_test(void)
899 BOOL ret;
900 SYSTEMTIME time;
901 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
902 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
903 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
904 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
905 '1','2',' ','0','6',' ','3','5',0 };
906 static const WCHAR string3[] = { 'F','r',0 };
908 ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
909 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
911 ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
912 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
914 ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
915 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
917 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
918 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
920 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
921 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
922 ok( !memcmp( &time, &expect, sizeof(expect) ),
923 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
925 ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
926 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
927 ok( !memcmp( &time, &expect, sizeof(expect) ),
928 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
930 ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
931 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
934 static void test_IsDomainLegalCookieDomainW(void)
936 BOOL ret;
937 static const WCHAR empty[] = {0};
938 static const WCHAR dot[] = {'.',0};
939 static const WCHAR uk[] = {'u','k',0};
940 static const WCHAR com[] = {'c','o','m',0};
941 static const WCHAR dot_com[] = {'.','c','o','m',0};
942 static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
943 static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
944 static const WCHAR www_gmail_com[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
945 static const WCHAR www_mail_gmail_com[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
946 static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
947 static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
948 static const WCHAR co_uk[] = {'c','o','.','u','k',0};
949 static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
951 SetLastError(0xdeadbeef);
952 ret = pIsDomainLegalCookieDomainW(NULL, NULL);
953 if (!ret && (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED))
955 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
956 return;
958 ok(!ret ||
959 broken(ret), /* IE6 */
960 "IsDomainLegalCookieDomainW succeeded\n");
962 SetLastError(0xdeadbeef);
963 ret = pIsDomainLegalCookieDomainW(com, NULL);
964 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
966 SetLastError(0xdeadbeef);
967 ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
968 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
970 SetLastError(0xdeadbeef);
971 ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
972 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
974 SetLastError(0xdeadbeef);
975 ret = pIsDomainLegalCookieDomainW(com, empty);
976 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
978 SetLastError(0xdeadbeef);
979 ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
980 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
982 SetLastError(0xdeadbeef);
983 ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
984 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
986 SetLastError(0xdeadbeef);
987 ret = pIsDomainLegalCookieDomainW(com, com);
988 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
990 SetLastError(0xdeadbeef);
991 ret = pIsDomainLegalCookieDomainW(com, dot_com);
992 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
994 SetLastError(0xdeadbeef);
995 ret = pIsDomainLegalCookieDomainW(dot_com, com);
996 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
998 SetLastError(0xdeadbeef);
999 ret = pIsDomainLegalCookieDomainW(com, gmail_com);
1000 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1002 ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
1003 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1005 ret = pIsDomainLegalCookieDomainW(gmail_com, www_gmail_com);
1006 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1008 ret = pIsDomainLegalCookieDomainW(gmail_com, www_mail_gmail_com);
1009 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1011 SetLastError(0xdeadbeef);
1012 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
1013 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1015 ret = pIsDomainLegalCookieDomainW(uk, co_uk);
1016 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1018 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
1019 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1021 ret = pIsDomainLegalCookieDomainW(co_uk, gmail_co_uk);
1022 todo_wine ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1024 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
1025 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1027 ret = pIsDomainLegalCookieDomainW(gmail_com, com);
1028 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1030 SetLastError(0xdeadbeef);
1031 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1032 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1034 ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
1035 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1037 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
1038 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1040 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
1041 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1043 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1044 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1046 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
1047 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1050 static void test_PrivacyGetSetZonePreferenceW(void)
1052 DWORD ret, zone, type, template, old_template;
1054 zone = 3;
1055 type = 0;
1056 ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
1057 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1059 old_template = 0;
1060 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
1061 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1063 template = 5;
1064 ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
1065 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1067 template = 0;
1068 ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
1069 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1070 ok(template == 5, "expected template == 5, got %u\n", template);
1072 template = 5;
1073 ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
1074 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1077 static void test_InternetSetOption(void)
1079 HINTERNET ses, con, req;
1080 ULONG ulArg;
1081 DWORD size;
1082 BOOL ret;
1084 ses = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1085 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1086 con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1087 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1088 req = HttpOpenRequestA(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1089 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1091 /* INTERNET_OPTION_POLICY tests */
1092 SetLastError(0xdeadbeef);
1093 ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
1094 ok(ret == FALSE, "InternetSetOption should've failed\n");
1095 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1096 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1098 SetLastError(0xdeadbeef);
1099 ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
1100 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1101 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1102 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1104 /* INTERNET_OPTION_ERROR_MASK tests */
1105 SetLastError(0xdeadbeef);
1106 size = sizeof(ulArg);
1107 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
1108 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1109 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1111 SetLastError(0xdeadbeef);
1112 ulArg = 11;
1113 ret = InternetSetOptionA(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1114 ok(ret == FALSE, "InternetSetOption should've failed\n");
1115 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1117 SetLastError(0xdeadbeef);
1118 ulArg = 11;
1119 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
1120 ok(ret == FALSE, "InternetSetOption should've failed\n");
1121 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
1123 ulArg = 11;
1124 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1125 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1127 SetLastError(0xdeadbeef);
1128 ulArg = 4;
1129 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1130 ok(ret == FALSE, "InternetSetOption should've failed\n");
1131 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1133 SetLastError(0xdeadbeef);
1134 ulArg = 16;
1135 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1136 ok(ret == FALSE, "InternetSetOption should've failed\n");
1137 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1139 ret = InternetCloseHandle(req);
1140 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1141 ret = InternetCloseHandle(con);
1142 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1143 ret = InternetCloseHandle(ses);
1144 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1147 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1148 static void r_verifyProxyEnable(LONG l, DWORD exp)
1150 HKEY hkey;
1151 DWORD type, val, size = sizeof(DWORD);
1152 LONG ret;
1153 static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1154 static const CHAR szProxyEnable[] = "ProxyEnable";
1156 ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
1157 ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
1159 ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
1160 ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
1161 ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
1162 ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
1164 ret = RegCloseKey(hkey);
1165 ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
1168 static void test_Option_PerConnectionOption(void)
1170 BOOL ret;
1171 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
1172 INTERNET_PER_CONN_OPTION_LISTW list = {size};
1173 INTERNET_PER_CONN_OPTIONW *orig_settings;
1174 static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1176 /* get the global IE proxy server info, to restore later */
1177 list.dwOptionCount = 2;
1178 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1180 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1181 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1183 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1184 &list, &size);
1185 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1186 orig_settings = list.pOptions;
1188 /* set the global IE proxy server */
1189 list.dwOptionCount = 2;
1190 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1192 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1193 list.pOptions[0].Value.pszValue = proxy_srvW;
1194 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1195 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1197 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1198 &list, size);
1199 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1201 HeapFree(GetProcessHeap(), 0, list.pOptions);
1203 /* get & verify the global IE proxy server */
1204 list.dwOptionCount = 2;
1205 list.dwOptionError = 0;
1206 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1208 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1209 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1211 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1212 &list, &size);
1213 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1214 ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
1215 "Retrieved proxy server should've been %s, was: %s\n",
1216 wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
1217 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1218 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1219 list.pOptions[1].Value.dwValue);
1220 verifyProxyEnable(1);
1222 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1223 HeapFree(GetProcessHeap(), 0, list.pOptions);
1225 /* disable the proxy server */
1226 list.dwOptionCount = 1;
1227 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1229 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1230 list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1232 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1233 &list, size);
1234 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1236 HeapFree(GetProcessHeap(), 0, list.pOptions);
1238 /* verify that the proxy is disabled */
1239 list.dwOptionCount = 1;
1240 list.dwOptionError = 0;
1241 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1243 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1245 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1246 &list, &size);
1247 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1248 ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1249 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1250 list.pOptions[0].Value.dwValue);
1251 verifyProxyEnable(0);
1253 HeapFree(GetProcessHeap(), 0, list.pOptions);
1255 /* set the proxy flags to 'invalid' value */
1256 list.dwOptionCount = 1;
1257 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1259 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1260 list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1262 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1263 &list, size);
1264 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1266 HeapFree(GetProcessHeap(), 0, list.pOptions);
1268 /* verify that the proxy is enabled */
1269 list.dwOptionCount = 1;
1270 list.dwOptionError = 0;
1271 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1273 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1275 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1276 &list, &size);
1277 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1278 todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1279 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1280 list.pOptions[0].Value.dwValue);
1281 verifyProxyEnable(1);
1283 HeapFree(GetProcessHeap(), 0, list.pOptions);
1285 /* restore original settings */
1286 list.dwOptionCount = 2;
1287 list.pOptions = orig_settings;
1289 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1290 &list, size);
1291 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1293 HeapFree(GetProcessHeap(), 0, list.pOptions);
1296 static void test_Option_PerConnectionOptionA(void)
1298 BOOL ret;
1299 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
1300 INTERNET_PER_CONN_OPTION_LISTA list = {size};
1301 INTERNET_PER_CONN_OPTIONA *orig_settings;
1302 char proxy_srv[] = "proxy.example";
1304 /* get the global IE proxy server info, to restore later */
1305 list.dwOptionCount = 2;
1306 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1308 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1309 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1311 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1312 &list, &size);
1313 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1314 orig_settings = list.pOptions;
1316 /* set the global IE proxy server */
1317 list.dwOptionCount = 2;
1318 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1320 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1321 list.pOptions[0].Value.pszValue = proxy_srv;
1322 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1323 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1325 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1326 &list, size);
1327 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1329 HeapFree(GetProcessHeap(), 0, list.pOptions);
1331 /* get & verify the global IE proxy server */
1332 list.dwOptionCount = 2;
1333 list.dwOptionError = 0;
1334 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1336 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1337 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1339 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1340 &list, &size);
1341 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1342 ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1343 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1344 proxy_srv, list.pOptions[0].Value.pszValue);
1345 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1346 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1347 list.pOptions[1].Value.dwValue);
1349 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1350 HeapFree(GetProcessHeap(), 0, list.pOptions);
1352 /* test with NULL as proxy server */
1353 list.dwOptionCount = 1;
1354 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
1355 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1356 list.pOptions[0].Value.pszValue = NULL;
1358 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
1359 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1361 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, size);
1362 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1364 HeapFree(GetProcessHeap(), 0, list.pOptions);
1366 /* get & verify the proxy server */
1367 list.dwOptionCount = 1;
1368 list.dwOptionError = 0;
1369 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
1370 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1372 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION, &list, &size);
1373 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1374 ok(!list.pOptions[0].Value.pszValue,
1375 "Retrieved proxy server should've been NULL, was: \"%s\"\n",
1376 list.pOptions[0].Value.pszValue);
1378 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1379 HeapFree(GetProcessHeap(), 0, list.pOptions);
1381 /* restore original settings */
1382 list.dwOptionCount = 2;
1383 list.pOptions = orig_settings;
1385 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1386 &list, size);
1387 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1389 HeapFree(GetProcessHeap(), 0, list.pOptions);
1392 #define FLAG_TODO 0x1
1393 #define FLAG_NEEDREQ 0x2
1394 #define FLAG_UNIMPL 0x4
1396 static void test_InternetErrorDlg(void)
1398 HINTERNET ses, con, req;
1399 DWORD res, flags;
1400 HWND hwnd;
1401 ULONG i;
1402 static const struct {
1403 DWORD error;
1404 DWORD res;
1405 DWORD test_flags;
1406 } no_ui_res[] = {
1407 { ERROR_INTERNET_INCORRECT_PASSWORD , ERROR_SUCCESS, FLAG_NEEDREQ },
1408 { ERROR_INTERNET_SEC_CERT_DATE_INVALID , ERROR_CANCELLED, 0 },
1409 { ERROR_INTERNET_SEC_CERT_CN_INVALID , ERROR_CANCELLED, 0 },
1410 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR , ERROR_SUCCESS, 0 },
1411 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR , ERROR_SUCCESS, FLAG_TODO },
1412 { ERROR_INTERNET_MIXED_SECURITY , ERROR_CANCELLED, FLAG_TODO },
1413 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE , ERROR_CANCELLED, FLAG_TODO },
1414 { ERROR_INTERNET_POST_IS_NON_SECURE , ERROR_SUCCESS, 0 },
1415 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, ERROR_CANCELLED, FLAG_NEEDREQ|FLAG_TODO },
1416 { ERROR_INTERNET_INVALID_CA , ERROR_CANCELLED, 0 },
1417 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO },
1418 { ERROR_INTERNET_INSERT_CDROM , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL },
1419 { ERROR_INTERNET_SEC_CERT_ERRORS , ERROR_CANCELLED, 0 },
1420 { ERROR_INTERNET_SEC_CERT_REV_FAILED , ERROR_CANCELLED, 0 },
1421 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO },
1422 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT , ERROR_CANCELLED, FLAG_TODO },
1423 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO },
1424 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION, ERROR_CANCELLED, FLAG_TODO },
1425 { ERROR_INTERNET_SEC_CERT_REVOKED , ERROR_CANCELLED, 0 },
1426 { 0, ERROR_NOT_SUPPORTED }
1429 flags = 0;
1431 res = InternetErrorDlg(NULL, NULL, 12055, flags, NULL);
1432 ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1434 ses = InternetOpenA(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1435 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1436 con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1437 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1438 req = HttpOpenRequestA(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1439 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1441 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1442 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1444 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1445 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1448 hwnd = GetDesktopWindow();
1449 ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1451 flags = FLAGS_ERROR_UI_FLAGS_NO_UI;
1452 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1454 DWORD expected, test_flags, j;
1456 for(j = 0; no_ui_res[j].error != 0; ++j)
1457 if(no_ui_res[j].error == i)
1458 break;
1460 test_flags = no_ui_res[j].test_flags;
1461 expected = no_ui_res[j].res;
1463 /* Try an invalid request handle */
1464 res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
1465 if(res == ERROR_CALL_NOT_IMPLEMENTED)
1467 ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1468 continue;
1470 else
1471 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1473 /* With a valid req */
1474 if(i == ERROR_INTERNET_NEED_UI)
1475 continue; /* Crashes on windows XP */
1477 if(i == ERROR_INTERNET_SEC_CERT_REVOKED)
1478 continue; /* Interactive (XP, Win7) */
1480 res = InternetErrorDlg(hwnd, req, i, flags, NULL);
1482 /* Handle some special cases */
1483 switch(i)
1485 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
1486 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR:
1487 if(res == ERROR_CANCELLED)
1489 /* Some windows XP, w2k3 x64, W2K8 */
1490 win_skip("Skipping some tests for %d\n", i);
1491 continue;
1493 break;
1494 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED:
1495 if(res != expected)
1497 /* Windows XP, W2K3 */
1498 ok(res == NTE_PROV_TYPE_NOT_DEF, "Got %d\n", res);
1499 win_skip("Skipping some tests for %d\n", i);
1500 continue;
1502 break;
1503 default: break;
1506 if(test_flags & FLAG_TODO)
1507 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1508 else
1509 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1511 /* Same thing with NULL hwnd */
1512 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1513 if(test_flags & FLAG_TODO)
1514 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1515 else
1516 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1519 /* With a null req */
1520 if(test_flags & FLAG_NEEDREQ)
1521 expected = ERROR_INVALID_PARAMETER;
1523 res = InternetErrorDlg(hwnd, NULL, i, flags, NULL);
1524 if( test_flags & FLAG_TODO || i == ERROR_INTERNET_INCORRECT_PASSWORD)
1525 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1526 else
1527 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1530 res = InternetCloseHandle(req);
1531 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1532 res = InternetCloseHandle(con);
1533 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1534 res = InternetCloseHandle(ses);
1535 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1538 static void test_InternetGetConnectedStateExA(void)
1540 BOOL res;
1541 CHAR buffer[256];
1542 DWORD flags, sz;
1544 if(!pInternetGetConnectedStateExA) {
1545 win_skip("InternetGetConnectedStateExA is not supported\n");
1546 return;
1549 res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0);
1550 if(!res) {
1551 win_skip("InternetGetConnectedStateExA tests require a valid connection\n");
1552 return;
1554 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer);
1556 res = pInternetGetConnectedStateExA(NULL, NULL, 0, 0);
1557 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1559 flags = 0;
1560 res = pInternetGetConnectedStateExA(&flags, NULL, 0, 0);
1561 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1562 ok(flags, "Expected at least one flag set\n");
1564 buffer[0] = 0;
1565 flags = 0;
1566 res = pInternetGetConnectedStateExA(&flags, buffer, 0, 0);
1567 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1568 ok(flags, "Expected at least one flag set\n");
1569 ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
1571 buffer[0] = 0;
1572 res = pInternetGetConnectedStateExA(NULL, buffer, sizeof(buffer), 0);
1573 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1574 sz = strlen(buffer);
1575 ok(sz > 0, "Expected a connection name\n");
1577 buffer[0] = 0;
1578 flags = 0;
1579 res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0);
1580 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1581 ok(flags, "Expected at least one flag set\n");
1582 sz = strlen(buffer);
1583 ok(sz > 0, "Expected a connection name\n");
1585 flags = 0;
1586 res = pInternetGetConnectedStateExA(&flags, NULL, sizeof(buffer), 0);
1587 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1588 ok(flags, "Expected at least one flag set\n");
1590 /* no space for complete string this time */
1591 buffer[0] = 0;
1592 flags = 0;
1593 res = pInternetGetConnectedStateExA(&flags, buffer, sz, 0);
1594 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1595 ok(flags, "Expected at least one flag set\n");
1596 ok(sz - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenA(buffer));
1598 buffer[0] = 0;
1599 flags = 0;
1600 res = pInternetGetConnectedStateExA(&flags, buffer, sz / 2, 0);
1601 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1602 ok(flags, "Expected at least one flag set\n");
1603 ok(sz / 2 - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenA(buffer));
1605 buffer[0] = 0;
1606 flags = 0;
1607 res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
1608 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1609 ok(flags, "Expected at least one flag set\n");
1610 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
1612 buffer[0] = 0;
1613 flags = 0;
1614 res = pInternetGetConnectedStateExA(&flags, buffer, 2, 0);
1615 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1616 ok(flags, "Expected at least one flag set\n");
1617 ok(strlen(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer));
1619 flags = 0;
1620 buffer[0] = 0xDE;
1621 res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
1622 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1623 ok(flags, "Expected at least one flag set\n");
1624 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
1627 static void test_InternetGetConnectedStateExW(void)
1629 BOOL res;
1630 WCHAR buffer[256];
1631 DWORD flags, sz;
1633 if(!pInternetGetConnectedStateExW) {
1634 win_skip("InternetGetConnectedStateExW is not supported\n");
1635 return;
1638 res = pInternetGetConnectedStateExW(&flags, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);
1639 if(!res) {
1640 win_skip("InternetGetConnectedStateExW tests require a valid connection\n");
1641 return;
1643 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer));
1645 res = pInternetGetConnectedStateExW(NULL, NULL, 0, 0);
1646 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1648 flags = 0;
1649 res = pInternetGetConnectedStateExW(&flags, NULL, 0, 0);
1650 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1651 ok(flags, "Expected at least one flag set\n");
1653 buffer[0] = 0;
1654 flags = 0;
1655 res = pInternetGetConnectedStateExW(&flags, buffer, 0, 0);
1656 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1657 ok(flags, "Expected at least one flag set\n");
1658 ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
1660 buffer[0] = 0;
1661 res = pInternetGetConnectedStateExW(NULL, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);
1662 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1663 sz = lstrlenW(buffer);
1664 ok(sz > 0, "Expected a connection name\n");
1666 buffer[0] = 0;
1667 flags = 0;
1668 res = pInternetGetConnectedStateExW(&flags, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);
1669 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1670 ok(flags, "Expected at least one flag set\n");
1671 sz = lstrlenW(buffer);
1672 ok(sz > 0, "Expected a connection name\n");
1674 flags = 0;
1675 res = pInternetGetConnectedStateExW(&flags, NULL, sizeof(buffer) / sizeof(buffer[0]), 0);
1676 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1677 ok(flags, "Expected at least one flag set\n");
1679 /* no space for complete string this time */
1680 buffer[0] = 0;
1681 flags = 0;
1682 res = pInternetGetConnectedStateExW(&flags, buffer, sz, 0);
1683 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1684 ok(flags, "Expected at least one flag set\n");
1685 ok(sz - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenW(buffer));
1687 buffer[0] = 0;
1688 flags = 0;
1689 res = pInternetGetConnectedStateExW(&flags, buffer, sz / 2, 0);
1690 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1691 ok(flags, "Expected at least one flag set\n");
1692 ok(sz / 2 - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenW(buffer));
1694 buffer[0] = 0;
1695 flags = 0;
1696 res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
1697 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1698 ok(flags, "Expected at least one flag set\n");
1699 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1701 buffer[0] = 0;
1702 flags = 0;
1703 res = pInternetGetConnectedStateExW(&flags, buffer, 2, 0);
1704 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1705 ok(flags, "Expected at least one flag set\n");
1706 ok(lstrlenW(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer));
1708 buffer[0] = 0xDEAD;
1709 flags = 0;
1710 res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
1711 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1712 ok(flags, "Expected at least one flag set\n");
1713 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1716 /* ############################### */
1718 START_TEST(internet)
1720 HMODULE hdll;
1721 hdll = GetModuleHandleA("wininet.dll");
1723 pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1724 pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1725 pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1726 pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1727 pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1728 pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1729 pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1730 pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1731 pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1732 pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
1733 pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
1734 pInternetGetConnectedStateExA = (void*)GetProcAddress(hdll, "InternetGetConnectedStateExA");
1735 pInternetGetConnectedStateExW = (void*)GetProcAddress(hdll, "InternetGetConnectedStateExW");
1737 if(!pInternetGetCookieExW) {
1738 win_skip("Too old IE (older than 6.0)\n");
1739 return;
1742 test_InternetCanonicalizeUrlA();
1743 test_InternetQueryOptionA();
1744 test_InternetGetConnectedStateExA();
1745 test_InternetGetConnectedStateExW();
1746 test_get_cookie();
1747 test_complicated_cookie();
1748 test_cookie_url();
1749 test_cookie_attrs();
1750 test_version();
1751 test_null();
1752 test_Option_PerConnectionOption();
1753 test_Option_PerConnectionOptionA();
1754 test_InternetErrorDlg();
1755 test_max_conns();
1757 if (!pInternetTimeFromSystemTimeA)
1758 win_skip("skipping the InternetTime tests\n");
1759 else
1761 InternetTimeFromSystemTimeA_test();
1762 InternetTimeFromSystemTimeW_test();
1763 InternetTimeToSystemTimeA_test();
1764 InternetTimeToSystemTimeW_test();
1766 if (pIsDomainLegalCookieDomainW &&
1767 ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1768 (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1769 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1770 else if (!pIsDomainLegalCookieDomainW)
1771 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1772 else
1773 test_IsDomainLegalCookieDomainW();
1775 if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1776 test_PrivacyGetSetZonePreferenceW();
1777 else
1778 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1780 test_InternetSetOption();