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