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