Release 1.4.1.
[wine] / dlls / wininet / tests / internet.c
1 /*
2  * Wininet - internet tests
3  *
4  * Copyright 2005 Vijay Kiran Kamuju
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22 #include <string.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wininet.h"
27 #include "winerror.h"
28 #include "winreg.h"
29
30 #include "wine/test.h"
31
32 static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD, DWORD, DWORD, DWORD,
33                                                 DWORD, DWORD, DWORD, DWORD);
34 static BOOL (WINAPI *pCreateUrlCacheContainerW)(DWORD, DWORD, DWORD, DWORD,
35                                                 DWORD, DWORD, DWORD, DWORD);
36 static BOOL (WINAPI *pInternetTimeFromSystemTimeA)(CONST SYSTEMTIME *,DWORD ,LPSTR ,DWORD);
37 static BOOL (WINAPI *pInternetTimeFromSystemTimeW)(CONST SYSTEMTIME *,DWORD ,LPWSTR ,DWORD);
38 static BOOL (WINAPI *pInternetTimeToSystemTimeA)(LPCSTR ,SYSTEMTIME *,DWORD);
39 static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
40 static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
41 static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
42 static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
43
44 /* ############################### */
45
46 static void test_InternetCanonicalizeUrlA(void)
47 {
48     CHAR    buffer[256];
49     LPCSTR  url;
50     DWORD   urllen;
51     DWORD   dwSize;
52     DWORD   res;
53
54     /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
55     url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
56     urllen = lstrlenA(url);
57
58     memset(buffer, '#', sizeof(buffer)-1);
59     buffer[sizeof(buffer)-1] = '\0';
60     dwSize = 1; /* Acrobat Updater use this size */
61     SetLastError(0xdeadbeef);
62     res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
63     ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
64         "got %u and %u with size %u for '%s' (%d)\n",
65         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
66
67
68     /* buffer has no space for the terminating '\0' */
69     memset(buffer, '#', sizeof(buffer)-1);
70     buffer[sizeof(buffer)-1] = '\0';
71     dwSize = urllen;
72     SetLastError(0xdeadbeef);
73     res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
74     /* dwSize is nr. of needed bytes with the terminating '\0' */
75     ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
76         "got %u and %u with size %u for '%s' (%d)\n",
77         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
78
79     /* buffer has the required size */
80     memset(buffer, '#', sizeof(buffer)-1);
81     buffer[sizeof(buffer)-1] = '\0';
82     dwSize = urllen+1;
83     SetLastError(0xdeadbeef);
84     res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
85     /* dwSize is nr. of copied bytes without the terminating '\0' */
86     ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
87         "got %u and %u with size %u for '%s' (%d)\n",
88         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
89
90     memset(buffer, '#', sizeof(buffer)-1);
91     buffer[sizeof(buffer)-1] = '\0';
92     dwSize = sizeof(buffer);
93     SetLastError(0xdeadbeef);
94     res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
95     ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
96     ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
97     ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
98        "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
99
100     /* buffer is larger as the required size */
101     memset(buffer, '#', sizeof(buffer)-1);
102     buffer[sizeof(buffer)-1] = '\0';
103     dwSize = urllen+2;
104     SetLastError(0xdeadbeef);
105     res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
106     /* dwSize is nr. of copied bytes without the terminating '\0' */
107     ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
108         "got %u and %u with size %u for '%s' (%d)\n",
109         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
110
111
112     /* check NULL pointers */
113     memset(buffer, '#', urllen + 4);
114     buffer[urllen + 4] = '\0';
115     dwSize = urllen+1;
116     SetLastError(0xdeadbeef);
117     res = InternetCanonicalizeUrlA(NULL, buffer, &dwSize, 0);
118     ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
119         "got %u and %u with size %u for '%s' (%d)\n",
120         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
121
122     memset(buffer, '#', urllen + 4);
123     buffer[urllen + 4] = '\0';
124     dwSize = urllen+1;
125     SetLastError(0xdeadbeef);
126     res = InternetCanonicalizeUrlA(url, NULL, &dwSize, 0);
127     ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
128         "got %u and %u with size %u for '%s' (%d)\n",
129         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
130
131     memset(buffer, '#', urllen + 4);
132     buffer[urllen + 4] = '\0';
133     dwSize = urllen+1;
134     SetLastError(0xdeadbeef);
135     res = InternetCanonicalizeUrlA(url, buffer, NULL, 0);
136     ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
137         "got %u and %u with size %u for '%s' (%d)\n",
138         res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
139
140     /* test with trailing space */
141     dwSize = 256;
142     res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
143     ok(res == 1, "InternetCanonicalizeUrlA failed\n");
144     ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
145
146     res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
147     ok(!res, "InternetSetOptionA succeeded\n");
148     ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION,
149        "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
150 }
151
152 /* ############################### */
153
154 static void test_InternetQueryOptionA(void)
155 {
156   HINTERNET hinet,hurl;
157   DWORD len, val;
158   DWORD err;
159   static const char useragent[] = {"Wininet Test"};
160   char *buffer;
161   int retval;
162
163   hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
164   ok((hinet != 0x0),"InternetOpen Failed\n");
165
166   SetLastError(0xdeadbeef);
167   retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
168   err=GetLastError();
169   ok(retval == 0,"Got wrong return value %d\n",retval);
170   ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
171
172   SetLastError(0xdeadbeef);
173   len=strlen(useragent)+1;
174   retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
175   err=GetLastError();
176   ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
177   ok(retval == 0,"Got wrong return value %d\n",retval);
178   ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
179
180   SetLastError(0xdeadbeef);
181   len=strlen(useragent)+1;
182   buffer=HeapAlloc(GetProcessHeap(),0,len);
183   retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
184   err=GetLastError();
185   ok(retval == 1,"Got wrong return value %d\n",retval);
186   if (retval)
187   {
188       ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
189       ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
190   }
191   ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
192   HeapFree(GetProcessHeap(),0,buffer);
193
194   SetLastError(0xdeadbeef);
195   len=0;
196   buffer=HeapAlloc(GetProcessHeap(),0,100);
197   retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
198   err=GetLastError();
199   ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
200   ok(!retval, "Got wrong return value %d\n", retval);
201   ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
202   HeapFree(GetProcessHeap(),0,buffer);
203
204   hurl = InternetConnectA(hinet,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
205
206   SetLastError(0xdeadbeef);
207   len=0;
208   retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
209   err=GetLastError();
210   ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
211   ok(retval == 0,"Got wrong return value %d\n",retval);
212   ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
213
214   InternetCloseHandle(hurl);
215   InternetCloseHandle(hinet);
216
217   hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
218   ok((hinet != 0x0),"InternetOpen Failed\n");
219
220   SetLastError(0xdeadbeef);
221   len=0;
222   retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
223   err=GetLastError();
224   ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
225   ok(retval == 0,"Got wrong return value %d\n",retval);
226   ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
227
228   InternetCloseHandle(hinet);
229
230   hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
231   ok((hinet != 0x0),"InternetOpen Failed\n");
232   SetLastError(0xdeadbeef);
233   len=0;
234   retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
235   err=GetLastError();
236   ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
237   ok(retval == 0,"Got wrong return value %d\n",retval);
238   ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
239
240   InternetCloseHandle(hinet);
241
242   len = sizeof(val);
243   retval = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
244   ok(retval == TRUE,"Got wrong return value %d\n", retval);
245   ok(len == sizeof(val), "got %d\n", len);
246   ok(val == 2, "got %d\n", val);
247
248   len = sizeof(val);
249   retval = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len);
250   ok(retval == TRUE,"Got wrong return value %d\n", retval);
251   ok(len == sizeof(val), "got %d\n", len);
252   ok(val == 4, "got %d\n", val);
253
254 }
255
256 static void test_get_cookie(void)
257 {
258   DWORD len;
259   BOOL ret;
260
261   SetLastError(0xdeadbeef);
262   ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
263   ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
264     "InternetGetCookie should have failed with %s and error %d\n",
265     ret ? "TRUE" : "FALSE", GetLastError());
266 }
267
268
269 static void test_complicated_cookie(void)
270 {
271   DWORD len;
272   BOOL ret;
273
274   CHAR buffer[1024];
275
276   ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
277   ok(ret == TRUE,"InternetSetCookie failed\n");
278   ret = InternetSetCookie("http://www.example.com/bar",NULL,"C=D; domain=.example.com; path=/");
279   ok(ret == TRUE,"InternetSetCookie failed\n");
280
281   /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
282   ret = InternetSetCookie("http://www.example.com",NULL,"E=F; domain=example.com");
283   ok(ret == TRUE,"InternetSetCookie failed\n");
284   ret = InternetSetCookie("http://www.example.com",NULL,"G=H; domain=.example.com; path=/foo");
285   ok(ret == TRUE,"InternetSetCookie failed\n");
286   ret = InternetSetCookie("http://www.example.com/bar.html",NULL,"I=J; domain=.example.com");
287   ok(ret == TRUE,"InternetSetCookie failed\n");
288   ret = InternetSetCookie("http://www.example.com/bar/",NULL,"K=L; domain=.example.com");
289   ok(ret == TRUE,"InternetSetCookie failed\n");
290   ret = InternetSetCookie("http://www.example.com/bar/",NULL,"M=N; domain=.example.com; path=/foo/");
291   ok(ret == TRUE,"InternetSetCookie failed\n");
292   ret = InternetSetCookie("http://www.example.com/bar/",NULL,"O=P; secure; path=/bar");
293   ok(ret == TRUE,"InternetSetCookie failed\n");
294
295   len = 1024;
296   ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
297   ok(ret == TRUE,"InternetGetCookie failed\n");
298   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
299   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
300   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
301   ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
302   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
303   ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
304   ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
305   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
306
307   len = 1024;
308   ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len);
309   ok(ret == TRUE,"InternetGetCookie failed\n");
310   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
311   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
312   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
313   ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
314   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
315   ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
316   ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
317   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
318
319   len = 1024;
320   ret = InternetGetCookie("http://testing.example.com/foobar/", NULL, buffer, &len);
321   ok(ret == TRUE,"InternetGetCookie failed\n");
322   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
323   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
324   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
325   ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
326   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
327   ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
328   ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
329   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
330
331   len = 1024;
332   ret = InternetGetCookie("http://testing.example.com/foo/bar", NULL, buffer, &len);
333   ok(ret == TRUE,"InternetGetCookie failed\n");
334   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
335   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
336   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
337   ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
338   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
339   ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
340   ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n");
341   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
342
343   len = 1024;
344   ret = InternetGetCookie("http://testing.example.com/barfoo", NULL, buffer, &len);
345   ok(ret == TRUE,"InternetGetCookie failed\n");
346   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
347   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
348   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
349   ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
350   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
351   ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
352   ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
353   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
354
355   len = 1024;
356   ret = InternetGetCookie("http://testing.example.com/barfoo/", NULL, buffer, &len);
357   ok(ret == TRUE,"InternetGetCookie failed\n");
358   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
359   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
360   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
361   ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
362   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
363   ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
364   ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
365   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
366
367   len = 1024;
368   ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len);
369   ok(ret == TRUE,"InternetGetCookie failed\n");
370   ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
371   ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
372   ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
373   ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
374   ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
375   ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
376   ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
377   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
378 }
379
380 static void test_null(void)
381 {
382   HINTERNET hi, hc;
383   static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
384   static const WCHAR szEmpty[] = { 0 };
385   static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
386   static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
387   static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
388   WCHAR buffer[0x20];
389   BOOL r;
390   DWORD sz;
391
392   SetLastError(0xdeadbeef);
393   hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
394   if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
395   {
396     win_skip("Internet*W functions are not implemented\n");
397     return;
398   }
399   ok(hi != NULL, "open failed\n");
400
401   hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
402   ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
403   ok(hc == NULL, "connect failed\n");
404
405   hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
406   ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
407   ok(hc == NULL, "connect failed\n");
408
409   hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
410   ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
411   ok(hc == NULL, "connect failed\n");
412
413   hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
414   ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
415   ok(hc == NULL, "connect failed\n");
416
417   hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
418   ok(GetLastError() == ERROR_INVALID_PARAMETER ||
419      GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
420   ok(hc == NULL, "connect failed\n");
421
422   hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
423   ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
424   ok(hc == NULL, "connect failed\n");
425
426   InternetCloseHandle(hi);
427
428   r = InternetSetCookieW(NULL, NULL, NULL);
429   ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
430   ok(r == FALSE, "return wrong\n");
431
432   r = InternetSetCookieW(szServer, NULL, NULL);
433   ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
434   ok(r == FALSE, "return wrong\n");
435
436   r = InternetSetCookieW(szUrl, szServer, NULL);
437   ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
438   ok(r == FALSE, "return wrong\n");
439
440   r = InternetSetCookieW(szUrl, szServer, szServer);
441   ok(r == TRUE, "return wrong\n");
442
443   r = InternetSetCookieW(szUrl, NULL, szServer);
444   ok(r == TRUE, "return wrong\n");
445
446   r = InternetSetCookieW(szUrl, szServer, szEmpty);
447   ok(r == TRUE, "return wrong\n");
448
449   r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
450   ok(r == FALSE, "return wrong\n");
451
452   r = InternetSetCookieW(szServer, NULL, szServer);
453   todo_wine {
454   ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
455   }
456   ok(r == FALSE, "return wrong\n");
457
458   sz = 0;
459   r = InternetGetCookieW(NULL, NULL, NULL, &sz);
460   ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
461      "wrong error %u\n", GetLastError());
462   ok( r == FALSE, "return wrong\n");
463
464   r = InternetGetCookieW(szServer, NULL, NULL, &sz);
465   todo_wine {
466   ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
467   }
468   ok( r == FALSE, "return wrong\n");
469
470   sz = 0;
471   r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
472   ok( r == FALSE, "return wrong\n");
473
474   sz = 0;
475   r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
476   ok( r == TRUE, "return wrong\n");
477
478   /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
479   ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz);
480
481   sz = 0x20;
482   memset(buffer, 0, sizeof buffer);
483   r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
484   ok( r == TRUE, "return wrong\n");
485
486   /* sz == lstrlenW(buffer) only in XP SP1 */
487   ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
488
489   /* before XP SP2, buffer is "server; server" */
490   ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
491
492   sz = sizeof(buffer);
493   r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
494   ok(r == TRUE, "ret %d\n", r);
495 }
496
497 static void test_version(void)
498 {
499     INTERNET_VERSION_INFO version;
500     DWORD size;
501     BOOL res;
502
503     size = sizeof(version);
504     res = InternetQueryOptionA(NULL, INTERNET_OPTION_VERSION, &version, &size);
505     ok(res, "Could not get version: %u\n", GetLastError());
506     ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
507     ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
508 }
509
510 static void InternetTimeFromSystemTimeA_test(void)
511 {
512     BOOL ret;
513     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
514     char string[INTERNET_RFC1123_BUFSIZE];
515     static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
516     DWORD error;
517
518     ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
519     ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
520
521     ok( !memcmp( string, expect, sizeof(expect) ),
522         "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
523
524     /* test NULL time parameter */
525     SetLastError(0xdeadbeef);
526     ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
527     error = GetLastError();
528     ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
529     ok( error == ERROR_INVALID_PARAMETER,
530         "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
531         error );
532
533     /* test NULL string parameter */
534     SetLastError(0xdeadbeef);
535     ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
536     error = GetLastError();
537     ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
538     ok( error == ERROR_INVALID_PARAMETER,
539         "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
540         error );
541
542     /* test invalid format parameter */
543     SetLastError(0xdeadbeef);
544     ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
545     error = GetLastError();
546     ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
547     ok( error == ERROR_INVALID_PARAMETER,
548         "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
549         error );
550
551     /* test too small buffer size */
552     SetLastError(0xdeadbeef);
553     ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
554     error = GetLastError();
555     ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
556     ok( error == ERROR_INSUFFICIENT_BUFFER,
557         "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
558         error );
559 }
560
561 static void InternetTimeFromSystemTimeW_test(void)
562 {
563     BOOL ret;
564     static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
565     WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
566     static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
567                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
568     DWORD error;
569
570     ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
571     ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
572
573     ok( !memcmp( string, expect, sizeof(expect) ),
574         "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
575
576     /* test NULL time parameter */
577     SetLastError(0xdeadbeef);
578     ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
579     error = GetLastError();
580     ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
581     ok( error == ERROR_INVALID_PARAMETER,
582         "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
583         error );
584
585     /* test NULL string parameter */
586     SetLastError(0xdeadbeef);
587     ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
588     error = GetLastError();
589     ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
590     ok( error == ERROR_INVALID_PARAMETER,
591         "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
592         error );
593
594     /* test invalid format parameter */
595     SetLastError(0xdeadbeef);
596     ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
597     error = GetLastError();
598     ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
599     ok( error == ERROR_INVALID_PARAMETER,
600         "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
601         error );
602
603     /* test too small buffer size */
604     SetLastError(0xdeadbeef);
605     ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
606     error = GetLastError();
607     ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
608     ok( error == ERROR_INSUFFICIENT_BUFFER,
609         "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
610         error );
611 }
612
613 static void InternetTimeToSystemTimeA_test(void)
614 {
615     BOOL ret;
616     SYSTEMTIME time;
617     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
618     static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
619     static const char string2[] = " fri 7 jan 2005 12 06 35";
620
621     ret = pInternetTimeToSystemTimeA( string, &time, 0 );
622     ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
623     ok( !memcmp( &time, &expect, sizeof(expect) ),
624         "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
625
626     ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
627     ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
628     ok( !memcmp( &time, &expect, sizeof(expect) ),
629         "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
630 }
631
632 static void InternetTimeToSystemTimeW_test(void)
633 {
634     BOOL ret;
635     SYSTEMTIME time;
636     static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
637     static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
638                                     '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
639     static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
640                                      '1','2',' ','0','6',' ','3','5',0 };
641     static const WCHAR string3[] = { 'F','r',0 };
642
643     ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
644     ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
645
646     ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
647     ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
648
649     ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
650     ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
651
652     ret = pInternetTimeToSystemTimeW( string, &time, 0 );
653     ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
654
655     ret = pInternetTimeToSystemTimeW( string, &time, 0 );
656     ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
657     ok( !memcmp( &time, &expect, sizeof(expect) ),
658         "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
659
660     ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
661     ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
662     ok( !memcmp( &time, &expect, sizeof(expect) ),
663         "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
664
665     ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
666     ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
667 }
668
669 static void test_IsDomainLegalCookieDomainW(void)
670 {
671     BOOL ret;
672     DWORD error;
673     static const WCHAR empty[]          = {0};
674     static const WCHAR dot[]            = {'.',0};
675     static const WCHAR uk[]             = {'u','k',0};
676     static const WCHAR com[]            = {'c','o','m',0};
677     static const WCHAR dot_com[]        = {'.','c','o','m',0};
678     static const WCHAR gmail_com[]      = {'g','m','a','i','l','.','c','o','m',0};
679     static const WCHAR dot_gmail_com[]  = {'.','g','m','a','i','l','.','c','o','m',0};
680     static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
681     static const WCHAR gmail_co_uk[]    = {'g','m','a','i','l','.','c','o','.','u','k',0};
682     static const WCHAR co_uk[]          = {'c','o','.','u','k',0};
683     static const WCHAR dot_co_uk[]      = {'.','c','o','.','u','k',0};
684
685     SetLastError(0xdeadbeef);
686     ret = pIsDomainLegalCookieDomainW(NULL, NULL);
687     error = GetLastError();
688     if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
689     {
690         win_skip("IsDomainLegalCookieDomainW is not implemented\n");
691         return;
692     }
693     ok(!ret ||
694         broken(ret), /* IE6 */
695         "IsDomainLegalCookieDomainW succeeded\n");
696     ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
697
698     SetLastError(0xdeadbeef);
699     ret = pIsDomainLegalCookieDomainW(com, NULL);
700     error = GetLastError();
701     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
702     ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
703
704     SetLastError(0xdeadbeef);
705     ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
706     error = GetLastError();
707     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
708     ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
709
710     SetLastError(0xdeadbeef);
711     ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
712     error = GetLastError();
713     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
714     ok(error == ERROR_INVALID_NAME ||
715         broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
716         "got %u expected ERROR_INVALID_NAME\n", error);
717
718     SetLastError(0xdeadbeef);
719     ret = pIsDomainLegalCookieDomainW(com, empty);
720     error = GetLastError();
721     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
722     ok(error == ERROR_INVALID_NAME ||
723         broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
724         "got %u expected ERROR_INVALID_NAME\n", error);
725
726     SetLastError(0xdeadbeef);
727     ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
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);
733
734     SetLastError(0xdeadbeef);
735     ret = pIsDomainLegalCookieDomainW(dot, gmail_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);
741
742     SetLastError(0xdeadbeef);
743     ret = pIsDomainLegalCookieDomainW(com, com);
744     error = GetLastError();
745     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
746     ok(error == 0xdeadbeef, "got %u expected 0xdeadbeef\n", error);
747
748     SetLastError(0xdeadbeef);
749     ret = pIsDomainLegalCookieDomainW(com, dot_com);
750     error = GetLastError();
751     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
752     ok(error == ERROR_INVALID_NAME ||
753         broken(error == 0xdeadbeef), /* IE6 */
754         "got %u expected ERROR_INVALID_NAME\n", error);
755
756     SetLastError(0xdeadbeef);
757     ret = pIsDomainLegalCookieDomainW(dot_com, com);
758     error = GetLastError();
759     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
760     ok(error == ERROR_INVALID_NAME ||
761         broken(error == 0xdeadbeef), /* IE6 */
762         "got %u expected ERROR_INVALID_NAME\n", error);
763
764     SetLastError(0xdeadbeef);
765     ret = pIsDomainLegalCookieDomainW(com, gmail_com);
766     error = GetLastError();
767     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
768     ok(error == ERROR_SXS_KEY_NOT_FOUND ||
769         error == ERROR_SUCCESS || /* IE8 on W2K3 */
770         error == 0xdeadbeef, /* up to IE7 */
771         "unexpected error: %u\n", error);
772
773     ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
774     ok(ret, "IsDomainLegalCookieDomainW failed\n");
775
776     SetLastError(0xdeadbeef);
777     ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
778     error = GetLastError();
779     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
780     ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
781         error == ERROR_FILE_NOT_FOUND ||   /* IE8 on Vista */
782         error == ERROR_SUCCESS || /* IE8 on W2K3 */
783         error == 0xdeadbeef, /* up to IE7 */
784         "unexpected error: %u\n", error);
785
786     ret = pIsDomainLegalCookieDomainW(uk, co_uk);
787     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
788
789     ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
790     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
791
792     ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
793     ok(ret, "IsDomainLegalCookieDomainW failed\n");
794
795     ret = pIsDomainLegalCookieDomainW(gmail_com, com);
796     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
797
798     SetLastError(0xdeadbeef);
799     ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
800     error = GetLastError();
801     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
802     ok(error == ERROR_INVALID_NAME ||
803         broken(error == 0xdeadbeef), /* IE6 */
804         "got %u expected ERROR_INVALID_NAME\n", error);
805
806     ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
807     ok(ret, "IsDomainLegalCookieDomainW failed\n");
808
809     ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
810     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
811
812     ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
813     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
814
815     ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
816     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
817
818     ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
819     ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
820 }
821
822 static void test_PrivacyGetSetZonePreferenceW(void)
823 {
824     DWORD ret, zone, type, template, old_template;
825
826     zone = 3;
827     type = 0;
828     ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
829     ok(ret == 0, "expected ret == 0, got %u\n", ret);
830
831     old_template = 0;
832     ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
833     ok(ret == 0, "expected ret == 0, got %u\n", ret);
834
835     template = 5;
836     ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
837     ok(ret == 0, "expected ret == 0, got %u\n", ret);
838
839     template = 0;
840     ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
841     ok(ret == 0, "expected ret == 0, got %u\n", ret);
842     ok(template == 5, "expected template == 5, got %u\n", template);
843
844     template = 5;
845     ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
846     ok(ret == 0, "expected ret == 0, got %u\n", ret);
847 }
848
849 static void test_InternetSetOption(void)
850 {
851     HINTERNET ses, con, req;
852     ULONG ulArg;
853     DWORD size;
854     BOOL ret;
855
856     ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
857     ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
858     con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
859     ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
860     req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
861     ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
862
863     /* INTERNET_OPTION_POLICY tests */
864     SetLastError(0xdeadbeef);
865     ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
866     ok(ret == FALSE, "InternetSetOption should've failed\n");
867     ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
868             "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
869
870     SetLastError(0xdeadbeef);
871     ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
872     ok(ret == FALSE, "InternetQueryOption should've failed\n");
873     ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
874             "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
875
876     /* INTERNET_OPTION_ERROR_MASK tests */
877     SetLastError(0xdeadbeef);
878     size = sizeof(ulArg);
879     ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
880     ok(ret == FALSE, "InternetQueryOption should've failed\n");
881     ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
882
883     SetLastError(0xdeadbeef);
884     ulArg = 11;
885     ret = InternetSetOption(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
886     ok(ret == FALSE, "InternetQueryOption should've failed\n");
887     ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
888
889     SetLastError(0xdeadbeef);
890     ulArg = 11;
891     ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
892     ok(ret == FALSE, "InternetQueryOption should've failed\n");
893     ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
894
895     SetLastError(0xdeadbeef);
896     ulArg = 11;
897     ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
898     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
899     ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
900
901     SetLastError(0xdeadbeef);
902     ulArg = 4;
903     ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
904     ok(ret == FALSE, "InternetQueryOption should've failed\n");
905     ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
906
907     SetLastError(0xdeadbeef);
908     ulArg = 16;
909     ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
910     ok(ret == FALSE, "InternetQueryOption should've failed\n");
911     ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
912
913     ret = InternetCloseHandle(req);
914     ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
915     ret = InternetCloseHandle(con);
916     ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
917     ret = InternetCloseHandle(ses);
918     ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
919 }
920
921 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
922 static void r_verifyProxyEnable(LONG l, DWORD exp)
923 {
924     HKEY hkey;
925     DWORD type, val, size = sizeof(DWORD);
926     LONG ret;
927     static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
928     static const CHAR szProxyEnable[] = "ProxyEnable";
929
930     ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
931     ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
932
933     ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
934     ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
935     ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
936     ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
937
938     ret = RegCloseKey(hkey);
939     ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
940 }
941
942 static void test_Option_PerConnectionOption(void)
943 {
944     BOOL ret;
945     DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
946     INTERNET_PER_CONN_OPTION_LISTW list = {size};
947     INTERNET_PER_CONN_OPTIONW *orig_settings;
948     static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
949
950     /* get the global IE proxy server info, to restore later */
951     list.dwOptionCount = 2;
952     list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
953
954     list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
955     list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
956
957     ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
958             &list, &size);
959     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
960     orig_settings = list.pOptions;
961
962     /* set the global IE proxy server */
963     list.dwOptionCount = 2;
964     list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
965
966     list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
967     list.pOptions[0].Value.pszValue = proxy_srvW;
968     list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
969     list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
970
971     ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
972             &list, size);
973     ok(ret == TRUE, "InternetSetOption should've succeeded\n");
974
975     HeapFree(GetProcessHeap(), 0, list.pOptions);
976
977     /* get & verify the global IE proxy server */
978     list.dwOptionCount = 2;
979     list.dwOptionError = 0;
980     list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
981
982     list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
983     list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
984
985     ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
986             &list, &size);
987     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
988     ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
989             "Retrieved proxy server should've been %s, was: %s\n",
990             wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
991     ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
992             "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
993             list.pOptions[1].Value.dwValue);
994     verifyProxyEnable(1);
995
996     HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
997     HeapFree(GetProcessHeap(), 0, list.pOptions);
998
999     /* disable the proxy server */
1000     list.dwOptionCount = 1;
1001     list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1002
1003     list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1004     list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1005
1006     ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1007             &list, size);
1008     ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1009
1010     HeapFree(GetProcessHeap(), 0, list.pOptions);
1011
1012     /* verify that the proxy is disabled */
1013     list.dwOptionCount = 1;
1014     list.dwOptionError = 0;
1015     list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1016
1017     list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1018
1019     ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1020             &list, &size);
1021     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1022     ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1023             "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1024             list.pOptions[0].Value.dwValue);
1025     verifyProxyEnable(0);
1026
1027     HeapFree(GetProcessHeap(), 0, list.pOptions);
1028
1029     /* set the proxy flags to 'invalid' value */
1030     list.dwOptionCount = 1;
1031     list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1032
1033     list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1034     list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1035
1036     ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1037             &list, size);
1038     ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1039
1040     HeapFree(GetProcessHeap(), 0, list.pOptions);
1041
1042     /* verify that the proxy is enabled */
1043     list.dwOptionCount = 1;
1044     list.dwOptionError = 0;
1045     list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1046
1047     list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1048
1049     ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1050             &list, &size);
1051     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1052     todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1053             "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1054             list.pOptions[0].Value.dwValue);
1055     verifyProxyEnable(1);
1056
1057     HeapFree(GetProcessHeap(), 0, list.pOptions);
1058
1059     /* restore original settings */
1060     list.dwOptionCount = 2;
1061     list.pOptions = orig_settings;
1062
1063     ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1064             &list, size);
1065     ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1066
1067     HeapFree(GetProcessHeap(), 0, list.pOptions);
1068 }
1069
1070 static void test_Option_PerConnectionOptionA(void)
1071 {
1072     BOOL ret;
1073     DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
1074     INTERNET_PER_CONN_OPTION_LISTA list = {size};
1075     INTERNET_PER_CONN_OPTIONA *orig_settings;
1076     char proxy_srv[] = "proxy.example";
1077
1078     /* get the global IE proxy server info, to restore later */
1079     list.dwOptionCount = 2;
1080     list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1081
1082     list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1083     list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1084
1085     ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1086             &list, &size);
1087     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1088     orig_settings = list.pOptions;
1089
1090     /* set the global IE proxy server */
1091     list.dwOptionCount = 2;
1092     list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1093
1094     list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1095     list.pOptions[0].Value.pszValue = proxy_srv;
1096     list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1097     list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1098
1099     ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1100             &list, size);
1101     ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1102
1103     HeapFree(GetProcessHeap(), 0, list.pOptions);
1104
1105     /* get & verify the global IE proxy server */
1106     list.dwOptionCount = 2;
1107     list.dwOptionError = 0;
1108     list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1109
1110     list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1111     list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1112
1113     ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1114             &list, &size);
1115     ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1116     ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1117             "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1118             proxy_srv, list.pOptions[0].Value.pszValue);
1119     ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1120             "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1121             list.pOptions[1].Value.dwValue);
1122
1123     HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1124     HeapFree(GetProcessHeap(), 0, list.pOptions);
1125
1126     /* restore original settings */
1127     list.dwOptionCount = 2;
1128     list.pOptions = orig_settings;
1129
1130     ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1131             &list, size);
1132     ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1133
1134     HeapFree(GetProcessHeap(), 0, list.pOptions);
1135 }
1136
1137 #define FLAG_TODO     0x1
1138 #define FLAG_NEEDREQ  0x2
1139 #define FLAG_UNIMPL   0x4
1140
1141 static void test_InternetErrorDlg(void)
1142 {
1143     HINTERNET ses, con, req;
1144     DWORD res, flags;
1145     HWND hwnd;
1146     ULONG i;
1147     static const struct {
1148         DWORD error;
1149         DWORD res;
1150         DWORD test_flags;
1151     } no_ui_res[] = {
1152         { ERROR_INTERNET_INCORRECT_PASSWORD     , ERROR_SUCCESS, FLAG_NEEDREQ },
1153         { ERROR_INTERNET_SEC_CERT_DATE_INVALID  , ERROR_CANCELLED, 0 },
1154         { ERROR_INTERNET_SEC_CERT_CN_INVALID    , ERROR_CANCELLED, 0 },
1155         { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR , ERROR_SUCCESS, 0 },
1156         { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR , ERROR_SUCCESS, FLAG_TODO },
1157         { ERROR_INTERNET_MIXED_SECURITY         , ERROR_CANCELLED, FLAG_TODO },
1158         { ERROR_INTERNET_CHG_POST_IS_NON_SECURE , ERROR_CANCELLED, FLAG_TODO },
1159         { ERROR_INTERNET_POST_IS_NON_SECURE     , ERROR_SUCCESS, 0 },
1160         { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, ERROR_CANCELLED, FLAG_NEEDREQ|FLAG_TODO },
1161         { ERROR_INTERNET_INVALID_CA             , ERROR_CANCELLED, 0 },
1162         { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO },
1163         { ERROR_INTERNET_INSERT_CDROM           , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL },
1164         { ERROR_INTERNET_SEC_CERT_ERRORS        , ERROR_CANCELLED, 0 },
1165         { ERROR_INTERNET_SEC_CERT_REV_FAILED    , ERROR_CANCELLED, FLAG_TODO },
1166         { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION  , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO },
1167         { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT  , ERROR_CANCELLED, FLAG_TODO },
1168         { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO },
1169         { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION, ERROR_CANCELLED, FLAG_TODO },
1170         { ERROR_INTERNET_SEC_CERT_REVOKED       , ERROR_CANCELLED, 0 },
1171         { 0, ERROR_NOT_SUPPORTED }
1172     };
1173
1174     flags = 0;
1175
1176     res = InternetErrorDlg(NULL, NULL, 12055, flags, NULL);
1177     ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1178
1179     ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1180     ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1181     con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1182     ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1183     req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1184     ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1185
1186     /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1187     for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1188     {
1189         res = InternetErrorDlg(NULL, req, i, flags, NULL);
1190         ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1191     }
1192
1193     hwnd = GetDesktopWindow();
1194     ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1195
1196     flags = FLAGS_ERROR_UI_FLAGS_NO_UI;
1197     for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1198     {
1199         DWORD expected, test_flags, j;
1200
1201         for(j = 0; no_ui_res[j].error != 0; ++j)
1202             if(no_ui_res[j].error == i)
1203                 break;
1204
1205         test_flags = no_ui_res[j].test_flags;
1206         expected = no_ui_res[j].res;
1207
1208         /* Try an invalid request handle */
1209         res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
1210         if(res == ERROR_CALL_NOT_IMPLEMENTED)
1211         {
1212             todo_wine ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1213             continue;
1214         }
1215         else
1216             todo_wine ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1217
1218         /* With a valid req */
1219         if(i == ERROR_INTERNET_NEED_UI)
1220             continue; /* Crashes on windows XP */
1221
1222         if(i == ERROR_INTERNET_SEC_CERT_REVOKED)
1223             continue; /* Interactive (XP, Win7) */
1224
1225         res = InternetErrorDlg(hwnd, req, i, flags, NULL);
1226
1227         /* Handle some special cases */
1228         switch(i)
1229         {
1230         case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
1231         case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR:
1232             if(res == ERROR_CANCELLED)
1233             {
1234                 /* Some windows XP, w2k3 x64, W2K8 */
1235                 win_skip("Skipping some tests for %d\n", i);
1236                 continue;
1237             }
1238             break;
1239         case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED:
1240             if(res != expected)
1241             {
1242                 /* Windows XP, W2K3 */
1243                 ok(res == NTE_PROV_TYPE_NOT_DEF, "Got %d\n", res);
1244                 win_skip("Skipping some tests for %d\n", i);
1245                 continue;
1246             }
1247             break;
1248         default: break;
1249         }
1250
1251         if(test_flags & FLAG_TODO)
1252             todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1253         else
1254             ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1255
1256         /* Same thing with NULL hwnd */
1257         res = InternetErrorDlg(NULL, req, i, flags, NULL);
1258         if(test_flags & FLAG_TODO)
1259             todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1260         else
1261             ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1262
1263
1264         /* With a null req */
1265         if(test_flags & FLAG_NEEDREQ)
1266             expected = ERROR_INVALID_PARAMETER;
1267
1268         res = InternetErrorDlg(hwnd, NULL, i, flags, NULL);
1269         if( test_flags & FLAG_TODO || i == ERROR_INTERNET_INCORRECT_PASSWORD)
1270             todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1271         else
1272             ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1273     }
1274
1275     res = InternetCloseHandle(req);
1276     ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1277     res = InternetCloseHandle(con);
1278     ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1279     res = InternetCloseHandle(ses);
1280     ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1281 }
1282
1283 /* ############################### */
1284
1285 START_TEST(internet)
1286 {
1287     HMODULE hdll;
1288     hdll = GetModuleHandleA("wininet.dll");
1289
1290     if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
1291         win_skip("Too old IE (older than 6.0)\n");
1292         return;
1293     }
1294
1295     pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1296     pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1297     pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1298     pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1299     pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1300     pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1301     pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1302     pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1303     pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1304
1305     test_InternetCanonicalizeUrlA();
1306     test_InternetQueryOptionA();
1307     test_get_cookie();
1308     test_complicated_cookie();
1309     test_version();
1310     test_null();
1311     test_Option_PerConnectionOption();
1312     test_Option_PerConnectionOptionA();
1313     test_InternetErrorDlg();
1314
1315     if (!pInternetTimeFromSystemTimeA)
1316         win_skip("skipping the InternetTime tests\n");
1317     else
1318     {
1319         InternetTimeFromSystemTimeA_test();
1320         InternetTimeFromSystemTimeW_test();
1321         InternetTimeToSystemTimeA_test();
1322         InternetTimeToSystemTimeW_test();
1323     }
1324     if (pIsDomainLegalCookieDomainW &&
1325         ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1326          (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1327         win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1328     else if (!pIsDomainLegalCookieDomainW)
1329         win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1330     else
1331         test_IsDomainLegalCookieDomainW();
1332
1333     if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1334         test_PrivacyGetSetZonePreferenceW();
1335     else
1336         win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1337
1338     test_InternetSetOption();
1339 }