wininet: Implement PER_CONN_PROXY_SERVER option.
[wine/multimedia.git] / dlls / wininet / tests / internet.c
blob2dc1fd90e7487eb2fc43e03930f4a6eb22256d28
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 <string.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "wininet.h"
26 #include "winerror.h"
28 #include "wine/test.h"
30 static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD, DWORD, DWORD, DWORD,
31 DWORD, DWORD, DWORD, DWORD);
32 static BOOL (WINAPI *pCreateUrlCacheContainerW)(DWORD, DWORD, DWORD, DWORD,
33 DWORD, DWORD, DWORD, DWORD);
34 static BOOL (WINAPI *pInternetTimeFromSystemTimeA)(CONST SYSTEMTIME *,DWORD ,LPSTR ,DWORD);
35 static BOOL (WINAPI *pInternetTimeFromSystemTimeW)(CONST SYSTEMTIME *,DWORD ,LPWSTR ,DWORD);
36 static BOOL (WINAPI *pInternetTimeToSystemTimeA)(LPCSTR ,SYSTEMTIME *,DWORD);
37 static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
38 static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
39 static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
40 static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
42 /* ############################### */
44 static void test_InternetCanonicalizeUrlA(void)
46 CHAR buffer[256];
47 LPCSTR url;
48 DWORD urllen;
49 DWORD dwSize;
50 DWORD res;
52 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
53 url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
54 urllen = lstrlenA(url);
56 memset(buffer, '#', sizeof(buffer)-1);
57 buffer[sizeof(buffer)-1] = '\0';
58 dwSize = 1; /* Acrobat Updater use this size */
59 SetLastError(0xdeadbeef);
60 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
61 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
62 "got %u and %u with size %u for '%s' (%d)\n",
63 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
66 /* buffer has no space for the terminating '\0' */
67 memset(buffer, '#', sizeof(buffer)-1);
68 buffer[sizeof(buffer)-1] = '\0';
69 dwSize = urllen;
70 SetLastError(0xdeadbeef);
71 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
72 /* dwSize is nr. of needed bytes with the terminating '\0' */
73 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
74 "got %u and %u with size %u for '%s' (%d)\n",
75 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
77 /* buffer has the required size */
78 memset(buffer, '#', sizeof(buffer)-1);
79 buffer[sizeof(buffer)-1] = '\0';
80 dwSize = urllen+1;
81 SetLastError(0xdeadbeef);
82 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
83 /* dwSize is nr. of copied bytes without the terminating '\0' */
84 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
85 "got %u and %u with size %u for '%s' (%d)\n",
86 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
88 memset(buffer, '#', sizeof(buffer)-1);
89 buffer[sizeof(buffer)-1] = '\0';
90 dwSize = sizeof(buffer);
91 SetLastError(0xdeadbeef);
92 res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
93 ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
94 ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
95 todo_wine ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
96 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
98 /* buffer is larger as the required size */
99 memset(buffer, '#', sizeof(buffer)-1);
100 buffer[sizeof(buffer)-1] = '\0';
101 dwSize = urllen+2;
102 SetLastError(0xdeadbeef);
103 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
104 /* dwSize is nr. of copied bytes without the terminating '\0' */
105 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
106 "got %u and %u with size %u for '%s' (%d)\n",
107 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
110 /* check NULL pointers */
111 memset(buffer, '#', urllen + 4);
112 buffer[urllen + 4] = '\0';
113 dwSize = urllen+1;
114 SetLastError(0xdeadbeef);
115 res = InternetCanonicalizeUrlA(NULL, buffer, &dwSize, 0);
116 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
117 "got %u and %u with size %u for '%s' (%d)\n",
118 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
120 memset(buffer, '#', urllen + 4);
121 buffer[urllen + 4] = '\0';
122 dwSize = urllen+1;
123 SetLastError(0xdeadbeef);
124 res = InternetCanonicalizeUrlA(url, NULL, &dwSize, 0);
125 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
126 "got %u and %u with size %u for '%s' (%d)\n",
127 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
129 memset(buffer, '#', urllen + 4);
130 buffer[urllen + 4] = '\0';
131 dwSize = urllen+1;
132 SetLastError(0xdeadbeef);
133 res = InternetCanonicalizeUrlA(url, buffer, NULL, 0);
134 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
135 "got %u and %u with size %u for '%s' (%d)\n",
136 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
138 /* test with trailing space */
139 dwSize = 256;
140 res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
141 ok(res == 1, "InternetCanonicalizeUrlA failed\n");
142 ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
144 res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
145 ok(!res, "InternetSetOptionA succeeded\n");
146 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION,
147 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
150 /* ############################### */
152 static void test_InternetQueryOptionA(void)
154 HINTERNET hinet,hurl;
155 DWORD len;
156 DWORD err;
157 static const char useragent[] = {"Wininet Test"};
158 char *buffer;
159 int retval;
161 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
162 ok((hinet != 0x0),"InternetOpen Failed\n");
164 SetLastError(0xdeadbeef);
165 retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
166 err=GetLastError();
167 ok(retval == 0,"Got wrong return value %d\n",retval);
168 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
170 SetLastError(0xdeadbeef);
171 len=strlen(useragent)+1;
172 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
173 err=GetLastError();
174 ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
175 ok(retval == 0,"Got wrong return value %d\n",retval);
176 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
178 SetLastError(0xdeadbeef);
179 len=strlen(useragent)+1;
180 buffer=HeapAlloc(GetProcessHeap(),0,len);
181 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
182 err=GetLastError();
183 ok(retval == 1,"Got wrong return value %d\n",retval);
184 if (retval)
186 ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
187 ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
189 ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
190 HeapFree(GetProcessHeap(),0,buffer);
192 SetLastError(0xdeadbeef);
193 len=0;
194 buffer=HeapAlloc(GetProcessHeap(),0,100);
195 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
196 err=GetLastError();
197 ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
198 ok(!retval, "Got wrong return value %d\n", retval);
199 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
200 HeapFree(GetProcessHeap(),0,buffer);
202 hurl = InternetConnectA(hinet,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
204 SetLastError(0xdeadbeef);
205 len=0;
206 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
207 err=GetLastError();
208 ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
209 ok(retval == 0,"Got wrong return value %d\n",retval);
210 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
212 InternetCloseHandle(hurl);
213 InternetCloseHandle(hinet);
215 hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
216 ok((hinet != 0x0),"InternetOpen Failed\n");
218 SetLastError(0xdeadbeef);
219 len=0;
220 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
221 err=GetLastError();
222 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
223 ok(retval == 0,"Got wrong return value %d\n",retval);
224 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
226 InternetCloseHandle(hinet);
228 hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
229 ok((hinet != 0x0),"InternetOpen Failed\n");
230 SetLastError(0xdeadbeef);
231 len=0;
232 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
233 err=GetLastError();
234 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
235 ok(retval == 0,"Got wrong return value %d\n",retval);
236 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
238 InternetCloseHandle(hinet);
241 static void test_get_cookie(void)
243 DWORD len;
244 BOOL ret;
246 SetLastError(0xdeadbeef);
247 ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
248 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
249 "InternetGetCookie should have failed with %s and error %d\n",
250 ret ? "TRUE" : "FALSE", GetLastError());
254 static void test_complicated_cookie(void)
256 DWORD len;
257 BOOL ret;
259 CHAR buffer[1024];
261 ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
262 ok(ret == TRUE,"InternetSetCookie failed\n");
263 ret = InternetSetCookie("http://www.example.com/bar",NULL,"C=D; domain=.example.com; path=/");
264 ok(ret == TRUE,"InternetSetCookie failed\n");
266 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
267 ret = InternetSetCookie("http://www.example.com",NULL,"E=F; domain=example.com");
268 ok(ret == TRUE,"InternetSetCookie failed\n");
269 ret = InternetSetCookie("http://www.example.com",NULL,"G=H; domain=.example.com; path=/foo");
270 ok(ret == TRUE,"InternetSetCookie failed\n");
271 ret = InternetSetCookie("http://www.example.com/bar.html",NULL,"I=J; domain=.example.com");
272 ok(ret == TRUE,"InternetSetCookie failed\n");
273 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"K=L; domain=.example.com");
274 ok(ret == TRUE,"InternetSetCookie failed\n");
275 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"M=N; domain=.example.com; path=/foo/");
276 ok(ret == TRUE,"InternetSetCookie failed\n");
277 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"O=P; secure; path=/bar");
278 ok(ret == TRUE,"InternetSetCookie failed\n");
280 len = 1024;
281 ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
282 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
283 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
284 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
285 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
286 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
287 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
288 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
289 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
291 len = 1024;
292 ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len);
293 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
294 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
295 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
296 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
297 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
298 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
299 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
300 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
302 len = 1024;
303 ret = InternetGetCookie("http://testing.example.com/foobar/", NULL, buffer, &len);
304 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
305 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
306 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
307 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
308 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
309 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
310 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
311 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
313 len = 1024;
314 ret = InternetGetCookie("http://testing.example.com/foo/bar", NULL, buffer, &len);
315 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
316 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
317 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
318 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
319 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
320 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
321 ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n");
322 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
324 len = 1024;
325 ret = InternetGetCookie("http://testing.example.com/barfoo", NULL, buffer, &len);
326 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
327 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
328 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
329 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
330 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
331 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
332 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
333 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
335 len = 1024;
336 ret = InternetGetCookie("http://testing.example.com/barfoo/", NULL, buffer, &len);
337 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
338 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
339 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
340 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
341 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
342 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
343 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
344 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
346 len = 1024;
347 ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len);
348 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
349 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
350 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
351 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
352 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
353 ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
354 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
355 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
358 static void test_null(void)
360 HINTERNET hi, hc;
361 static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
362 static const WCHAR szEmpty[] = { 0 };
363 static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
364 static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
365 static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
366 WCHAR buffer[0x20];
367 BOOL r;
368 DWORD sz;
370 SetLastError(0xdeadbeef);
371 hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
372 if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
374 win_skip("Internet*W functions are not implemented\n");
375 return;
377 ok(hi != NULL, "open failed\n");
379 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
380 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
381 ok(hc == NULL, "connect failed\n");
383 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
384 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
385 ok(hc == NULL, "connect failed\n");
387 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
388 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
389 ok(hc == NULL, "connect failed\n");
391 hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
392 ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
393 ok(hc == NULL, "connect failed\n");
395 hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
396 ok(GetLastError() == ERROR_INVALID_PARAMETER ||
397 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
398 ok(hc == NULL, "connect failed\n");
400 hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
401 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
402 ok(hc == NULL, "connect failed\n");
404 InternetCloseHandle(hi);
406 r = InternetSetCookieW(NULL, NULL, NULL);
407 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
408 ok(r == FALSE, "return wrong\n");
410 r = InternetSetCookieW(szServer, NULL, NULL);
411 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
412 ok(r == FALSE, "return wrong\n");
414 r = InternetSetCookieW(szUrl, szServer, NULL);
415 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
416 ok(r == FALSE, "return wrong\n");
418 r = InternetSetCookieW(szUrl, szServer, szServer);
419 ok(r == TRUE, "return wrong\n");
421 r = InternetSetCookieW(szUrl, NULL, szServer);
422 ok(r == TRUE, "return wrong\n");
424 r = InternetSetCookieW(szUrl, szServer, szEmpty);
425 ok(r == TRUE, "return wrong\n");
427 r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
428 ok(r == FALSE, "return wrong\n");
430 r = InternetSetCookieW(szServer, NULL, szServer);
431 todo_wine {
432 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
434 ok(r == FALSE, "return wrong\n");
436 sz = 0;
437 r = InternetGetCookieW(NULL, NULL, NULL, &sz);
438 ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
439 "wrong error %u\n", GetLastError());
440 ok( r == FALSE, "return wrong\n");
442 r = InternetGetCookieW(szServer, NULL, NULL, &sz);
443 todo_wine {
444 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
446 ok( r == FALSE, "return wrong\n");
448 sz = 0;
449 r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
450 ok( r == FALSE, "return wrong\n");
452 sz = 0;
453 r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
454 ok( r == TRUE, "return wrong\n");
456 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
457 ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz);
459 sz = 0x20;
460 memset(buffer, 0, sizeof buffer);
461 r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
462 ok( r == TRUE, "return wrong\n");
464 /* sz == lstrlenW(buffer) only in XP SP1 */
465 ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
467 /* before XP SP2, buffer is "server; server" */
468 ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
470 sz = sizeof(buffer);
471 r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
472 ok(r == TRUE, "ret %d\n", r);
475 static void test_version(void)
477 INTERNET_VERSION_INFO version;
478 DWORD size;
479 BOOL res;
481 size = sizeof(version);
482 res = InternetQueryOptionA(NULL, INTERNET_OPTION_VERSION, &version, &size);
483 ok(res, "Could not get version: %u\n", GetLastError());
484 ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
485 ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
488 static void InternetTimeFromSystemTimeA_test(void)
490 BOOL ret;
491 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
492 char string[INTERNET_RFC1123_BUFSIZE];
493 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
494 DWORD error;
496 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
497 ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
499 ok( !memcmp( string, expect, sizeof(expect) ),
500 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
502 /* test NULL time parameter */
503 SetLastError(0xdeadbeef);
504 ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
505 error = GetLastError();
506 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
507 ok( error == ERROR_INVALID_PARAMETER,
508 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
509 error );
511 /* test NULL string parameter */
512 SetLastError(0xdeadbeef);
513 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
514 error = GetLastError();
515 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
516 ok( error == ERROR_INVALID_PARAMETER,
517 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
518 error );
520 /* test invalid format parameter */
521 SetLastError(0xdeadbeef);
522 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
523 error = GetLastError();
524 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
525 ok( error == ERROR_INVALID_PARAMETER,
526 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
527 error );
529 /* test too small buffer size */
530 SetLastError(0xdeadbeef);
531 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
532 error = GetLastError();
533 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
534 ok( error == ERROR_INSUFFICIENT_BUFFER,
535 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
536 error );
539 static void InternetTimeFromSystemTimeW_test(void)
541 BOOL ret;
542 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
543 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
544 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
545 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
546 DWORD error;
548 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
549 ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
551 ok( !memcmp( string, expect, sizeof(expect) ),
552 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
554 /* test NULL time parameter */
555 SetLastError(0xdeadbeef);
556 ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
557 error = GetLastError();
558 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
559 ok( error == ERROR_INVALID_PARAMETER,
560 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
561 error );
563 /* test NULL string parameter */
564 SetLastError(0xdeadbeef);
565 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
566 error = GetLastError();
567 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
568 ok( error == ERROR_INVALID_PARAMETER,
569 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
570 error );
572 /* test invalid format parameter */
573 SetLastError(0xdeadbeef);
574 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
575 error = GetLastError();
576 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
577 ok( error == ERROR_INVALID_PARAMETER,
578 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
579 error );
581 /* test too small buffer size */
582 SetLastError(0xdeadbeef);
583 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
584 error = GetLastError();
585 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
586 ok( error == ERROR_INSUFFICIENT_BUFFER,
587 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
588 error );
591 static void InternetTimeToSystemTimeA_test(void)
593 BOOL ret;
594 SYSTEMTIME time;
595 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
596 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
597 static const char string2[] = " fri 7 jan 2005 12 06 35";
599 ret = pInternetTimeToSystemTimeA( string, &time, 0 );
600 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
601 ok( !memcmp( &time, &expect, sizeof(expect) ),
602 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
604 ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
605 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
606 ok( !memcmp( &time, &expect, sizeof(expect) ),
607 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
610 static void InternetTimeToSystemTimeW_test(void)
612 BOOL ret;
613 SYSTEMTIME time;
614 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
615 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
616 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
617 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
618 '1','2',' ','0','6',' ','3','5',0 };
619 static const WCHAR string3[] = { 'F','r',0 };
621 ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
622 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
624 ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
625 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
627 ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
628 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
630 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
631 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
633 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
634 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
635 ok( !memcmp( &time, &expect, sizeof(expect) ),
636 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
638 ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
639 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
640 ok( !memcmp( &time, &expect, sizeof(expect) ),
641 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
643 ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
644 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
647 static void test_IsDomainLegalCookieDomainW(void)
649 BOOL ret;
650 DWORD error;
651 static const WCHAR empty[] = {0};
652 static const WCHAR dot[] = {'.',0};
653 static const WCHAR uk[] = {'u','k',0};
654 static const WCHAR com[] = {'c','o','m',0};
655 static const WCHAR dot_com[] = {'.','c','o','m',0};
656 static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
657 static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
658 static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
659 static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
660 static const WCHAR co_uk[] = {'c','o','.','u','k',0};
661 static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
663 SetLastError(0xdeadbeef);
664 ret = pIsDomainLegalCookieDomainW(NULL, NULL);
665 error = GetLastError();
666 if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
668 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
669 return;
671 ok(!ret ||
672 broken(ret), /* IE6 */
673 "IsDomainLegalCookieDomainW succeeded\n");
674 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
676 SetLastError(0xdeadbeef);
677 ret = pIsDomainLegalCookieDomainW(com, NULL);
678 error = GetLastError();
679 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
680 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
682 SetLastError(0xdeadbeef);
683 ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
684 error = GetLastError();
685 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
686 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
688 SetLastError(0xdeadbeef);
689 ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
690 error = GetLastError();
691 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
692 ok(error == ERROR_INVALID_NAME ||
693 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
694 "got %u expected ERROR_INVALID_NAME\n", error);
696 SetLastError(0xdeadbeef);
697 ret = pIsDomainLegalCookieDomainW(com, empty);
698 error = GetLastError();
699 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
700 ok(error == ERROR_INVALID_NAME ||
701 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
702 "got %u expected ERROR_INVALID_NAME\n", error);
704 SetLastError(0xdeadbeef);
705 ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
706 error = GetLastError();
707 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
708 ok(error == ERROR_INVALID_NAME ||
709 broken(error == 0xdeadbeef), /* IE6 */
710 "got %u expected ERROR_INVALID_NAME\n", error);
712 SetLastError(0xdeadbeef);
713 ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
714 error = GetLastError();
715 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
716 ok(error == ERROR_INVALID_NAME ||
717 broken(error == 0xdeadbeef), /* IE6 */
718 "got %u expected ERROR_INVALID_NAME\n", error);
720 SetLastError(0xdeadbeef);
721 ret = pIsDomainLegalCookieDomainW(com, com);
722 error = GetLastError();
723 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
724 ok(error == 0xdeadbeef, "got %u expected 0xdeadbeef\n", error);
726 SetLastError(0xdeadbeef);
727 ret = pIsDomainLegalCookieDomainW(com, dot_com);
728 error = GetLastError();
729 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
730 ok(error == ERROR_INVALID_NAME ||
731 broken(error == 0xdeadbeef), /* IE6 */
732 "got %u expected ERROR_INVALID_NAME\n", error);
734 SetLastError(0xdeadbeef);
735 ret = pIsDomainLegalCookieDomainW(dot_com, com);
736 error = GetLastError();
737 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
738 ok(error == ERROR_INVALID_NAME ||
739 broken(error == 0xdeadbeef), /* IE6 */
740 "got %u expected ERROR_INVALID_NAME\n", error);
742 SetLastError(0xdeadbeef);
743 ret = pIsDomainLegalCookieDomainW(com, gmail_com);
744 error = GetLastError();
745 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
746 ok(error == ERROR_SXS_KEY_NOT_FOUND ||
747 error == ERROR_SUCCESS || /* IE8 on W2K3 */
748 error == 0xdeadbeef, /* up to IE7 */
749 "unexpected error: %u\n", error);
751 ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
752 ok(ret, "IsDomainLegalCookieDomainW failed\n");
754 SetLastError(0xdeadbeef);
755 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
756 error = GetLastError();
757 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
758 ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
759 error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
760 error == ERROR_SUCCESS || /* IE8 on W2K3 */
761 error == 0xdeadbeef, /* up to IE7 */
762 "unexpected error: %u\n", error);
764 ret = pIsDomainLegalCookieDomainW(uk, co_uk);
765 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
767 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
768 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
770 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
771 ok(ret, "IsDomainLegalCookieDomainW failed\n");
773 ret = pIsDomainLegalCookieDomainW(gmail_com, com);
774 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
776 SetLastError(0xdeadbeef);
777 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
778 error = GetLastError();
779 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
780 ok(error == ERROR_INVALID_NAME ||
781 broken(error == 0xdeadbeef), /* IE6 */
782 "got %u expected ERROR_INVALID_NAME\n", error);
784 ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
785 ok(ret, "IsDomainLegalCookieDomainW failed\n");
787 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
788 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
790 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
791 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
793 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
794 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
796 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
797 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
800 static void test_PrivacyGetSetZonePreferenceW(void)
802 DWORD ret, zone, type, template, old_template;
804 zone = 3;
805 type = 0;
806 ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
807 ok(ret == 0, "expected ret == 0, got %u\n", ret);
809 old_template = 0;
810 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
811 ok(ret == 0, "expected ret == 0, got %u\n", ret);
813 template = 5;
814 ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
815 ok(ret == 0, "expected ret == 0, got %u\n", ret);
817 template = 0;
818 ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
819 ok(ret == 0, "expected ret == 0, got %u\n", ret);
820 ok(template == 5, "expected template == 5, got %u\n", template);
822 template = 5;
823 ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
824 ok(ret == 0, "expected ret == 0, got %u\n", ret);
827 static void test_Option_Policy(void)
829 HINTERNET hinet;
830 BOOL ret;
832 hinet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
833 ok(hinet != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
835 SetLastError(0xdeadbeef);
836 ret = InternetSetOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
837 ok(ret == FALSE, "InternetSetOption should've failed\n");
838 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
839 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
841 SetLastError(0xdeadbeef);
842 ret = InternetQueryOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
843 ok(ret == FALSE, "InternetQueryOption should've failed\n");
844 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
845 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
847 ret = InternetCloseHandle(hinet);
848 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
851 static void test_Option_PerConnectionOption(void)
853 BOOL ret;
854 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
855 INTERNET_PER_CONN_OPTION_LISTW list = {size};
856 INTERNET_PER_CONN_OPTIONW *orig_settings;
857 static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
859 /* get the global IE proxy server info, to restore later */
860 list.dwOptionCount = 1;
861 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
863 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
865 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
866 &list, &size);
867 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
868 orig_settings = list.pOptions;
870 /* set the global IE proxy server */
871 list.dwOptionCount = 1;
872 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
874 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
875 list.pOptions[0].Value.pszValue = proxy_srvW;
877 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
878 &list, size);
879 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
881 HeapFree(GetProcessHeap(), 0, list.pOptions);
883 /* get & verify the global IE proxy server */
884 list.dwOptionCount = 1;
885 list.dwOptionError = 0;
886 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
888 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
890 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
891 &list, &size);
892 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
893 ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
894 "Retrieved proxy server should've been %s, was: %s\n",
895 wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
897 HeapFree(GetProcessHeap(), 0, list.pOptions);
899 /* restore original settings */
900 list.dwOptionCount = 1;
901 list.pOptions = orig_settings;
903 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
904 &list, size);
905 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
907 HeapFree(GetProcessHeap(), 0, list.pOptions);
910 static void test_Option_PerConnectionOptionA(void)
912 BOOL ret;
913 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
914 INTERNET_PER_CONN_OPTION_LISTA list = {size};
915 INTERNET_PER_CONN_OPTIONA *orig_settings;
916 char proxy_srv[] = "proxy.example";
918 /* get the global IE proxy server info, to restore later */
919 list.dwOptionCount = 1;
920 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
922 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
924 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
925 &list, &size);
926 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
927 orig_settings = list.pOptions;
929 /* set the global IE proxy server */
930 list.dwOptionCount = 1;
931 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
933 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
934 list.pOptions[0].Value.pszValue = proxy_srv;
936 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
937 &list, size);
938 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
940 HeapFree(GetProcessHeap(), 0, list.pOptions);
942 /* get & verify the global IE proxy server */
943 list.dwOptionCount = 1;
944 list.dwOptionError = 0;
945 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
947 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
949 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
950 &list, &size);
951 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
952 ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
953 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
954 proxy_srv, list.pOptions[0].Value.pszValue);
956 HeapFree(GetProcessHeap(), 0, list.pOptions);
958 /* restore original settings */
959 list.dwOptionCount = 1;
960 list.pOptions = orig_settings;
962 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
963 &list, size);
964 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
966 HeapFree(GetProcessHeap(), 0, list.pOptions);
969 /* ############################### */
971 START_TEST(internet)
973 HMODULE hdll;
974 hdll = GetModuleHandleA("wininet.dll");
975 pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
976 pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
977 pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
978 pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
979 pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
980 pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
981 pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
982 pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
983 pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
985 test_InternetCanonicalizeUrlA();
986 test_InternetQueryOptionA();
987 test_get_cookie();
988 test_complicated_cookie();
989 test_version();
990 test_null();
991 test_Option_Policy();
992 test_Option_PerConnectionOption();
993 test_Option_PerConnectionOptionA();
995 if (!pInternetTimeFromSystemTimeA)
996 win_skip("skipping the InternetTime tests\n");
997 else
999 InternetTimeFromSystemTimeA_test();
1000 InternetTimeFromSystemTimeW_test();
1001 InternetTimeToSystemTimeA_test();
1002 InternetTimeToSystemTimeW_test();
1004 if (pIsDomainLegalCookieDomainW &&
1005 ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1006 (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1007 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1008 else if (!pIsDomainLegalCookieDomainW)
1009 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1010 else
1011 test_IsDomainLegalCookieDomainW();
1013 if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1014 test_PrivacyGetSetZonePreferenceW();
1015 else
1016 win_skip("Privacy[SG]etZonePreferenceW are not available\n");