2 * Wininet - internet tests
4 * Copyright 2005 Vijay Kiran Kamuju
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
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 static BOOL (WINAPI *pInternetGetCookieExA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD,LPVOID);
44 static BOOL (WINAPI *pInternetGetCookieExW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD,LPVOID);
46 /* ############################### */
48 static void test_InternetCanonicalizeUrlA(void)
56 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
57 url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
58 urllen = lstrlenA(url);
60 memset(buffer, '#', sizeof(buffer)-1);
61 buffer[sizeof(buffer)-1] = '\0';
62 dwSize = 1; /* Acrobat Updater use this size */
63 SetLastError(0xdeadbeef);
64 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
65 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
66 "got %u and %u with size %u for '%s' (%d)\n",
67 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
70 /* buffer has no space for the terminating '\0' */
71 memset(buffer, '#', sizeof(buffer)-1);
72 buffer[sizeof(buffer)-1] = '\0';
74 SetLastError(0xdeadbeef);
75 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
76 /* dwSize is nr. of needed bytes with the terminating '\0' */
77 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
78 "got %u and %u with size %u for '%s' (%d)\n",
79 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
81 /* buffer has the required size */
82 memset(buffer, '#', sizeof(buffer)-1);
83 buffer[sizeof(buffer)-1] = '\0';
85 SetLastError(0xdeadbeef);
86 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
87 /* dwSize is nr. of copied bytes without the terminating '\0' */
88 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
89 "got %u and %u with size %u for '%s' (%d)\n",
90 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
92 memset(buffer, '#', sizeof(buffer)-1);
93 buffer[sizeof(buffer)-1] = '\0';
94 dwSize = sizeof(buffer);
95 SetLastError(0xdeadbeef);
96 res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
97 ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
98 ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
99 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
100 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
102 /* buffer is larger as the required size */
103 memset(buffer, '#', sizeof(buffer)-1);
104 buffer[sizeof(buffer)-1] = '\0';
106 SetLastError(0xdeadbeef);
107 res = InternetCanonicalizeUrlA(url, buffer, &dwSize, 0);
108 /* dwSize is nr. of copied bytes without the terminating '\0' */
109 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
110 "got %u and %u with size %u for '%s' (%d)\n",
111 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
114 /* check NULL pointers */
115 memset(buffer, '#', urllen + 4);
116 buffer[urllen + 4] = '\0';
118 SetLastError(0xdeadbeef);
119 res = InternetCanonicalizeUrlA(NULL, buffer, &dwSize, 0);
120 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
121 "got %u and %u with size %u for '%s' (%d)\n",
122 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
124 memset(buffer, '#', urllen + 4);
125 buffer[urllen + 4] = '\0';
127 SetLastError(0xdeadbeef);
128 res = InternetCanonicalizeUrlA(url, NULL, &dwSize, 0);
129 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
130 "got %u and %u with size %u for '%s' (%d)\n",
131 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
133 memset(buffer, '#', urllen + 4);
134 buffer[urllen + 4] = '\0';
136 SetLastError(0xdeadbeef);
137 res = InternetCanonicalizeUrlA(url, buffer, NULL, 0);
138 ok( !res && (GetLastError() == ERROR_INVALID_PARAMETER),
139 "got %u and %u with size %u for '%s' (%d)\n",
140 res, GetLastError(), dwSize, buffer, lstrlenA(buffer));
142 /* test with trailing space */
144 res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
145 ok(res == 1, "InternetCanonicalizeUrlA failed\n");
146 ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
148 res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
149 ok(!res, "InternetSetOptionA succeeded\n");
150 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION,
151 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
154 /* ############################### */
156 static void test_InternetQueryOptionA(void)
158 HINTERNET hinet,hurl;
161 static const char useragent[] = {"Wininet Test"};
166 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
167 ok((hinet != 0x0),"InternetOpen Failed\n");
169 SetLastError(0xdeadbeef);
170 retval=InternetQueryOptionA(NULL,INTERNET_OPTION_USER_AGENT,NULL,&len);
172 ok(retval == 0,"Got wrong return value %d\n",retval);
173 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
175 SetLastError(0xdeadbeef);
176 len=strlen(useragent)+1;
177 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
179 ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
180 ok(retval == 0,"Got wrong return value %d\n",retval);
181 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
183 SetLastError(0xdeadbeef);
184 len=strlen(useragent)+1;
185 buffer=HeapAlloc(GetProcessHeap(),0,len);
186 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
188 ok(retval == 1,"Got wrong return value %d\n",retval);
191 ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
192 ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
194 ok(err == 0xdeadbeef, "Got wrong error code %d\n",err);
195 HeapFree(GetProcessHeap(),0,buffer);
197 SetLastError(0xdeadbeef);
199 buffer=HeapAlloc(GetProcessHeap(),0,100);
200 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,buffer,&len);
202 ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
203 ok(!retval, "Got wrong return value %d\n", retval);
204 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
205 HeapFree(GetProcessHeap(),0,buffer);
207 hurl = InternetConnectA(hinet,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0);
209 SetLastError(0xdeadbeef);
211 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_USER_AGENT,NULL,&len);
213 ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
214 ok(retval == 0,"Got wrong return value %d\n",retval);
215 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
217 SetLastError(0xdeadbeef);
219 retval = InternetQueryOptionA(hurl,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
220 err = GetLastError();
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 ok(len == sizeof(DWORD), "len = %d\n", len);
225 SetLastError(0xdeadbeef);
227 retval = InternetQueryOptionA(NULL,INTERNET_OPTION_REQUEST_FLAGS,NULL,&len);
228 err = GetLastError();
229 ok(retval == 0,"Got wrong return value %d\n",retval);
230 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
231 ok(!len, "len = %d\n", len);
233 InternetCloseHandle(hurl);
234 InternetCloseHandle(hinet);
236 hinet = InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
237 ok((hinet != 0x0),"InternetOpen Failed\n");
239 SetLastError(0xdeadbeef);
241 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
243 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
244 ok(retval == 0,"Got wrong return value %d\n",retval);
245 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
247 InternetCloseHandle(hinet);
250 res = InternetSetOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
251 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
254 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
255 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
256 ok(val == 12345, "val = %d\n", val);
257 ok(len == sizeof(val), "len = %d\n", len);
259 hinet = InternetOpenA(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
260 ok((hinet != 0x0),"InternetOpen Failed\n");
261 SetLastError(0xdeadbeef);
263 retval=InternetQueryOptionA(hinet,INTERNET_OPTION_USER_AGENT,NULL,&len);
265 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
266 ok(retval == 0,"Got wrong return value %d\n",retval);
267 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
271 res = InternetQueryOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
272 ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
273 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
276 res = InternetSetOptionA(hinet, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
277 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
278 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
281 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
282 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
283 ok(val == 12345, "val = %d\n", val);
284 ok(len == sizeof(val), "len = %d\n", len);
287 res = InternetSetOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, sizeof(val));
288 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
291 res = InternetQueryOptionA(hinet, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
292 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
293 ok(val == 1, "val = %d\n", val);
294 ok(len == sizeof(val), "len = %d\n", len);
297 res = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECT_TIMEOUT, &val, &len);
298 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
299 ok(val == 12345, "val = %d\n", val);
300 ok(len == sizeof(val), "len = %d\n", len);
302 InternetCloseHandle(hinet);
305 static void test_max_conns(void)
312 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
313 ok(res,"Got wrong return value %x\n", res);
314 ok(len == sizeof(val), "got %d\n", len);
315 ok(val == 2, "got %d\n", val);
319 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER, &val, &len);
320 ok(res,"Got wrong return value %x\n", res);
321 ok(len == sizeof(val), "got %d\n", len);
322 ok(val == 4, "got %d\n", val);
325 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
326 ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res);
330 res = InternetQueryOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, &len);
331 ok(res,"Got wrong return value %x\n", res);
332 ok(len == sizeof(val), "got %d\n", len);
333 ok(val == 3, "got %d\n", val);
336 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val));
337 ok(!res || broken(res), /* <= w2k3 */
338 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
339 if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError());
342 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)-1);
343 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
344 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
347 res = InternetSetOptionA(NULL, INTERNET_OPTION_MAX_CONNS_PER_SERVER, &val, sizeof(val)+1);
348 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
349 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
352 static void test_get_cookie(void)
357 SetLastError(0xdeadbeef);
358 ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
359 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
360 "InternetGetCookie should have failed with %s and error %d\n",
361 ret ? "TRUE" : "FALSE", GetLastError());
365 static void test_complicated_cookie(void)
372 ret = InternetSetCookie("http://www.example.com/bar",NULL,"A=B; domain=.example.com");
373 ok(ret == TRUE,"InternetSetCookie failed\n");
374 ret = InternetSetCookie("http://www.example.com/bar",NULL,"C=D; domain=.example.com; path=/");
375 ok(ret == TRUE,"InternetSetCookie failed\n");
377 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
378 ret = InternetSetCookie("http://www.example.com",NULL,"E=F; domain=example.com");
379 ok(ret == TRUE,"InternetSetCookie failed\n");
380 ret = InternetSetCookie("http://www.example.com",NULL,"G=H; domain=.example.com; path=/foo");
381 ok(ret == TRUE,"InternetSetCookie failed\n");
382 ret = InternetSetCookie("http://www.example.com/bar.html",NULL,"I=J; domain=.example.com");
383 ok(ret == TRUE,"InternetSetCookie failed\n");
384 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"K=L; domain=.example.com");
385 ok(ret == TRUE,"InternetSetCookie failed\n");
386 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"M=N; domain=.example.com; path=/foo/");
387 ok(ret == TRUE,"InternetSetCookie failed\n");
388 ret = InternetSetCookie("http://www.example.com/bar/",NULL,"O=P; secure; path=/bar");
389 ok(ret == TRUE,"InternetSetCookie failed\n");
392 ret = InternetGetCookie("http://testing.example.com", NULL, buffer, &len);
393 ok(ret == TRUE,"InternetGetCookie failed\n");
394 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
395 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
396 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
397 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
398 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
399 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
400 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
401 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
404 ret = InternetGetCookie("http://testing.example.com/foobar", NULL, buffer, &len);
405 ok(ret == TRUE,"InternetGetCookie failed\n");
406 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
407 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
408 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
409 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
410 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
411 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
412 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
413 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
416 ret = InternetGetCookie("http://testing.example.com/foobar/", NULL, buffer, &len);
417 ok(ret == TRUE,"InternetGetCookie failed\n");
418 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
419 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
420 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
421 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
422 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
423 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
424 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
425 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
428 ret = InternetGetCookie("http://testing.example.com/foo/bar", NULL, buffer, &len);
429 ok(ret == TRUE,"InternetGetCookie failed\n");
430 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
431 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
432 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
433 ok(strstr(buffer,"G=H")!=NULL,"G=H missing\n");
434 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
435 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
436 ok(strstr(buffer,"M=N")!=NULL,"M=N missing\n");
437 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
440 ret = InternetGetCookie("http://testing.example.com/barfoo", NULL, buffer, &len);
441 ok(ret == TRUE,"InternetGetCookie failed\n");
442 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
443 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
444 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
445 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
446 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
447 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
448 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
449 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
452 ret = InternetGetCookie("http://testing.example.com/barfoo/", NULL, buffer, &len);
453 ok(ret == TRUE,"InternetGetCookie failed\n");
454 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
455 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
456 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
457 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
458 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
459 ok(strstr(buffer,"K=L")==NULL,"K=L present\n");
460 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
461 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
464 ret = InternetGetCookie("http://testing.example.com/bar/foo", NULL, buffer, &len);
465 ok(ret == TRUE,"InternetGetCookie failed\n");
466 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
467 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
468 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
469 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
470 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
471 ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
472 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
473 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
476 static void test_cookie_url(void)
483 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
486 res = InternetGetCookieA("about:blank", NULL, buf, &len);
487 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
488 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
490 len = sizeof(bufw)/sizeof(*bufw);
491 res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
492 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
493 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
496 res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
497 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
498 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
500 len = sizeof(bufw)/sizeof(*bufw);
501 res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
502 ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
503 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
506 static void test_null(void)
509 static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
510 static const WCHAR szEmpty[] = { 0 };
511 static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
512 static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
513 static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
518 SetLastError(0xdeadbeef);
519 hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
520 if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
522 win_skip("Internet*W functions are not implemented\n");
525 ok(hi != NULL, "open failed\n");
527 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
528 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
529 ok(hc == NULL, "connect failed\n");
531 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
532 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
533 ok(hc == NULL, "connect failed\n");
535 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
536 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
537 ok(hc == NULL, "connect failed\n");
539 hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
540 ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
541 ok(hc == NULL, "connect failed\n");
543 hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
544 ok(GetLastError() == ERROR_INVALID_PARAMETER ||
545 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
546 ok(hc == NULL, "connect failed\n");
548 hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
549 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
550 ok(hc == NULL, "connect failed\n");
552 InternetCloseHandle(hi);
554 r = InternetSetCookieW(NULL, NULL, NULL);
555 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
556 ok(r == FALSE, "return wrong\n");
558 r = InternetSetCookieW(szServer, NULL, NULL);
559 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
560 ok(r == FALSE, "return wrong\n");
562 r = InternetSetCookieW(szUrl, szServer, NULL);
563 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
564 ok(r == FALSE, "return wrong\n");
566 r = InternetSetCookieW(szUrl, szServer, szServer);
567 ok(r == TRUE, "return wrong\n");
569 r = InternetSetCookieW(szUrl, NULL, szServer);
570 ok(r == TRUE, "return wrong\n");
572 r = InternetSetCookieW(szUrl, szServer, szEmpty);
573 ok(r == TRUE, "return wrong\n");
575 r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
576 ok(r == FALSE, "return wrong\n");
578 r = InternetSetCookieW(szServer, NULL, szServer);
580 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
582 ok(r == FALSE, "return wrong\n");
585 r = InternetGetCookieW(NULL, NULL, NULL, &sz);
586 ok(GetLastError() == ERROR_INVALID_PARAMETER || GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME,
587 "wrong error %u\n", GetLastError());
588 ok( r == FALSE, "return wrong\n");
590 r = InternetGetCookieW(szServer, NULL, NULL, &sz);
592 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
594 ok( r == FALSE, "return wrong\n");
597 r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
598 ok( r == FALSE, "return wrong\n");
601 r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
602 ok( r == TRUE, "return wrong\n");
604 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
605 ok( sz == 14 || sz == 30, "sz wrong, got %u, expected 14 or 30\n", sz);
608 memset(buffer, 0, sizeof buffer);
609 r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
610 ok( r == TRUE, "return wrong\n");
612 /* sz == lstrlenW(buffer) only in XP SP1 */
613 ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
615 /* before XP SP2, buffer is "server; server" */
616 ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer), "cookie data wrong\n");
619 r = InternetQueryOptionA(NULL, INTERNET_OPTION_CONNECTED_STATE, buffer, &sz);
620 ok(r == TRUE, "ret %d\n", r);
623 static void test_version(void)
625 INTERNET_VERSION_INFO version;
629 size = sizeof(version);
630 res = InternetQueryOptionA(NULL, INTERNET_OPTION_VERSION, &version, &size);
631 ok(res, "Could not get version: %u\n", GetLastError());
632 ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
633 ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
636 static void InternetTimeFromSystemTimeA_test(void)
639 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
640 char string[INTERNET_RFC1123_BUFSIZE];
641 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
644 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
645 ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
647 ok( !memcmp( string, expect, sizeof(expect) ),
648 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
650 /* test NULL time parameter */
651 SetLastError(0xdeadbeef);
652 ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
653 error = GetLastError();
654 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
655 ok( error == ERROR_INVALID_PARAMETER,
656 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
659 /* test NULL string parameter */
660 SetLastError(0xdeadbeef);
661 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
662 error = GetLastError();
663 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
664 ok( error == ERROR_INVALID_PARAMETER,
665 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
668 /* test invalid format parameter */
669 SetLastError(0xdeadbeef);
670 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
671 error = GetLastError();
672 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
673 ok( error == ERROR_INVALID_PARAMETER,
674 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
677 /* test too small buffer size */
678 SetLastError(0xdeadbeef);
679 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
680 error = GetLastError();
681 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
682 ok( error == ERROR_INSUFFICIENT_BUFFER,
683 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
687 static void InternetTimeFromSystemTimeW_test(void)
690 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
691 WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
692 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
693 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
696 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
697 ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
699 ok( !memcmp( string, expect, sizeof(expect) ),
700 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
702 /* test NULL time parameter */
703 SetLastError(0xdeadbeef);
704 ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
705 error = GetLastError();
706 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
707 ok( error == ERROR_INVALID_PARAMETER,
708 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
711 /* test NULL string parameter */
712 SetLastError(0xdeadbeef);
713 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
714 error = GetLastError();
715 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
716 ok( error == ERROR_INVALID_PARAMETER,
717 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
720 /* test invalid format parameter */
721 SetLastError(0xdeadbeef);
722 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
723 error = GetLastError();
724 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
725 ok( error == ERROR_INVALID_PARAMETER,
726 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
729 /* test too small buffer size */
730 SetLastError(0xdeadbeef);
731 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
732 error = GetLastError();
733 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
734 ok( error == ERROR_INSUFFICIENT_BUFFER,
735 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
739 static void InternetTimeToSystemTimeA_test(void)
743 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
744 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
745 static const char string2[] = " fri 7 jan 2005 12 06 35";
747 ret = pInternetTimeToSystemTimeA( string, &time, 0 );
748 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
749 ok( !memcmp( &time, &expect, sizeof(expect) ),
750 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
752 ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
753 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
754 ok( !memcmp( &time, &expect, sizeof(expect) ),
755 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
758 static void InternetTimeToSystemTimeW_test(void)
762 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
763 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
764 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
765 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
766 '1','2',' ','0','6',' ','3','5',0 };
767 static const WCHAR string3[] = { 'F','r',0 };
769 ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
770 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
772 ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
773 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
775 ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
776 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
778 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
779 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
781 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
782 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
783 ok( !memcmp( &time, &expect, sizeof(expect) ),
784 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
786 ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
787 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
788 ok( !memcmp( &time, &expect, sizeof(expect) ),
789 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
791 ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
792 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
795 static void test_IsDomainLegalCookieDomainW(void)
799 static const WCHAR empty[] = {0};
800 static const WCHAR dot[] = {'.',0};
801 static const WCHAR uk[] = {'u','k',0};
802 static const WCHAR com[] = {'c','o','m',0};
803 static const WCHAR dot_com[] = {'.','c','o','m',0};
804 static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
805 static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
806 static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
807 static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
808 static const WCHAR co_uk[] = {'c','o','.','u','k',0};
809 static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
811 SetLastError(0xdeadbeef);
812 ret = pIsDomainLegalCookieDomainW(NULL, NULL);
813 error = GetLastError();
814 if (!ret && error == ERROR_CALL_NOT_IMPLEMENTED)
816 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
820 broken(ret), /* IE6 */
821 "IsDomainLegalCookieDomainW succeeded\n");
822 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
824 SetLastError(0xdeadbeef);
825 ret = pIsDomainLegalCookieDomainW(com, NULL);
826 error = GetLastError();
827 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
828 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
830 SetLastError(0xdeadbeef);
831 ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
832 error = GetLastError();
833 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
834 ok(error == ERROR_INVALID_PARAMETER, "got %u expected ERROR_INVALID_PARAMETER\n", error);
836 SetLastError(0xdeadbeef);
837 ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
838 error = GetLastError();
839 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
840 ok(error == ERROR_INVALID_NAME ||
841 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
842 "got %u expected ERROR_INVALID_NAME\n", error);
844 SetLastError(0xdeadbeef);
845 ret = pIsDomainLegalCookieDomainW(com, empty);
846 error = GetLastError();
847 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
848 ok(error == ERROR_INVALID_NAME ||
849 broken(error == ERROR_INVALID_PARAMETER), /* IE6 */
850 "got %u expected ERROR_INVALID_NAME\n", error);
852 SetLastError(0xdeadbeef);
853 ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
854 error = GetLastError();
855 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
856 ok(error == ERROR_INVALID_NAME ||
857 broken(error == 0xdeadbeef), /* IE6 */
858 "got %u expected ERROR_INVALID_NAME\n", error);
860 SetLastError(0xdeadbeef);
861 ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
862 error = GetLastError();
863 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
864 ok(error == ERROR_INVALID_NAME ||
865 broken(error == 0xdeadbeef), /* IE6 */
866 "got %u expected ERROR_INVALID_NAME\n", error);
868 SetLastError(0xdeadbeef);
869 ret = pIsDomainLegalCookieDomainW(com, com);
870 error = GetLastError();
871 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
872 ok(error == 0xdeadbeef, "got %u expected 0xdeadbeef\n", error);
874 SetLastError(0xdeadbeef);
875 ret = pIsDomainLegalCookieDomainW(com, dot_com);
876 error = GetLastError();
877 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
878 ok(error == ERROR_INVALID_NAME ||
879 broken(error == 0xdeadbeef), /* IE6 */
880 "got %u expected ERROR_INVALID_NAME\n", error);
882 SetLastError(0xdeadbeef);
883 ret = pIsDomainLegalCookieDomainW(dot_com, com);
884 error = GetLastError();
885 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
886 ok(error == ERROR_INVALID_NAME ||
887 broken(error == 0xdeadbeef), /* IE6 */
888 "got %u expected ERROR_INVALID_NAME\n", error);
890 SetLastError(0xdeadbeef);
891 ret = pIsDomainLegalCookieDomainW(com, gmail_com);
892 error = GetLastError();
893 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
894 ok(error == ERROR_SXS_KEY_NOT_FOUND ||
895 error == ERROR_SUCCESS || /* IE8 on W2K3 */
896 error == 0xdeadbeef, /* up to IE7 */
897 "unexpected error: %u\n", error);
899 ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
900 ok(ret, "IsDomainLegalCookieDomainW failed\n");
902 SetLastError(0xdeadbeef);
903 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
904 error = GetLastError();
905 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
906 ok(error == ERROR_SXS_KEY_NOT_FOUND || /* IE8 on XP */
907 error == ERROR_FILE_NOT_FOUND || /* IE8 on Vista */
908 error == ERROR_SUCCESS || /* IE8 on W2K3 */
909 error == 0xdeadbeef, /* up to IE7 */
910 "unexpected error: %u\n", error);
912 ret = pIsDomainLegalCookieDomainW(uk, co_uk);
913 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
915 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
916 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
918 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
919 ok(ret, "IsDomainLegalCookieDomainW failed\n");
921 ret = pIsDomainLegalCookieDomainW(gmail_com, com);
922 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
924 SetLastError(0xdeadbeef);
925 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
926 error = GetLastError();
927 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
928 ok(error == ERROR_INVALID_NAME ||
929 broken(error == 0xdeadbeef), /* IE6 */
930 "got %u expected ERROR_INVALID_NAME\n", error);
932 ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
933 ok(ret, "IsDomainLegalCookieDomainW failed\n");
935 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
936 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
938 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
939 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
941 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
942 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
944 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
945 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
948 static void test_PrivacyGetSetZonePreferenceW(void)
950 DWORD ret, zone, type, template, old_template;
954 ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
955 ok(ret == 0, "expected ret == 0, got %u\n", ret);
958 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
959 ok(ret == 0, "expected ret == 0, got %u\n", ret);
962 ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
963 ok(ret == 0, "expected ret == 0, got %u\n", ret);
966 ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
967 ok(ret == 0, "expected ret == 0, got %u\n", ret);
968 ok(template == 5, "expected template == 5, got %u\n", template);
971 ret = pPrivacySetZonePreferenceW(zone, type, old_template, NULL);
972 ok(ret == 0, "expected ret == 0, got %u\n", ret);
975 static void test_InternetSetOption(void)
977 HINTERNET ses, con, req;
982 ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
983 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
984 con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
985 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
986 req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
987 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
989 /* INTERNET_OPTION_POLICY tests */
990 SetLastError(0xdeadbeef);
991 ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
992 ok(ret == FALSE, "InternetSetOption should've failed\n");
993 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
994 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
996 SetLastError(0xdeadbeef);
997 ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
998 ok(ret == FALSE, "InternetQueryOption should've failed\n");
999 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1000 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1002 /* INTERNET_OPTION_ERROR_MASK tests */
1003 SetLastError(0xdeadbeef);
1004 size = sizeof(ulArg);
1005 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
1006 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1007 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1009 SetLastError(0xdeadbeef);
1011 ret = InternetSetOption(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1012 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1013 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1015 SetLastError(0xdeadbeef);
1017 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
1018 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1019 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
1021 SetLastError(0xdeadbeef);
1023 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1024 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1025 ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
1027 SetLastError(0xdeadbeef);
1029 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1030 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1031 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1033 SetLastError(0xdeadbeef);
1035 ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1036 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1037 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1039 ret = InternetCloseHandle(req);
1040 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1041 ret = InternetCloseHandle(con);
1042 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1043 ret = InternetCloseHandle(ses);
1044 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1047 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1048 static void r_verifyProxyEnable(LONG l, DWORD exp)
1051 DWORD type, val, size = sizeof(DWORD);
1053 static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1054 static const CHAR szProxyEnable[] = "ProxyEnable";
1056 ret = RegOpenKeyA(HKEY_CURRENT_USER, szInternetSettings, &hkey);
1057 ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
1059 ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
1060 ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
1061 ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
1062 ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
1064 ret = RegCloseKey(hkey);
1065 ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
1068 static void test_Option_PerConnectionOption(void)
1071 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTW);
1072 INTERNET_PER_CONN_OPTION_LISTW list = {size};
1073 INTERNET_PER_CONN_OPTIONW *orig_settings;
1074 static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1076 /* get the global IE proxy server info, to restore later */
1077 list.dwOptionCount = 2;
1078 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1080 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1081 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1083 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1085 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1086 orig_settings = list.pOptions;
1088 /* set the global IE proxy server */
1089 list.dwOptionCount = 2;
1090 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1092 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1093 list.pOptions[0].Value.pszValue = proxy_srvW;
1094 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1095 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1097 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1099 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1101 HeapFree(GetProcessHeap(), 0, list.pOptions);
1103 /* get & verify the global IE proxy server */
1104 list.dwOptionCount = 2;
1105 list.dwOptionError = 0;
1106 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1108 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1109 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1111 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1113 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1114 ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
1115 "Retrieved proxy server should've been %s, was: %s\n",
1116 wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
1117 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1118 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1119 list.pOptions[1].Value.dwValue);
1120 verifyProxyEnable(1);
1122 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1123 HeapFree(GetProcessHeap(), 0, list.pOptions);
1125 /* disable the proxy server */
1126 list.dwOptionCount = 1;
1127 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1129 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1130 list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1132 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1134 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1136 HeapFree(GetProcessHeap(), 0, list.pOptions);
1138 /* verify that the proxy is disabled */
1139 list.dwOptionCount = 1;
1140 list.dwOptionError = 0;
1141 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1143 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1145 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1147 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1148 ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1149 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1150 list.pOptions[0].Value.dwValue);
1151 verifyProxyEnable(0);
1153 HeapFree(GetProcessHeap(), 0, list.pOptions);
1155 /* set the proxy flags to 'invalid' value */
1156 list.dwOptionCount = 1;
1157 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1159 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1160 list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1162 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1164 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1166 HeapFree(GetProcessHeap(), 0, list.pOptions);
1168 /* verify that the proxy is enabled */
1169 list.dwOptionCount = 1;
1170 list.dwOptionError = 0;
1171 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1173 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1175 ret = InternetQueryOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1177 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1178 todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1179 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1180 list.pOptions[0].Value.dwValue);
1181 verifyProxyEnable(1);
1183 HeapFree(GetProcessHeap(), 0, list.pOptions);
1185 /* restore original settings */
1186 list.dwOptionCount = 2;
1187 list.pOptions = orig_settings;
1189 ret = InternetSetOptionW(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1191 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1193 HeapFree(GetProcessHeap(), 0, list.pOptions);
1196 static void test_Option_PerConnectionOptionA(void)
1199 DWORD size = sizeof(INTERNET_PER_CONN_OPTION_LISTA);
1200 INTERNET_PER_CONN_OPTION_LISTA list = {size};
1201 INTERNET_PER_CONN_OPTIONA *orig_settings;
1202 char proxy_srv[] = "proxy.example";
1204 /* get the global IE proxy server info, to restore later */
1205 list.dwOptionCount = 2;
1206 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1208 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1209 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1211 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1213 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1214 orig_settings = list.pOptions;
1216 /* set the global IE proxy server */
1217 list.dwOptionCount = 2;
1218 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1220 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1221 list.pOptions[0].Value.pszValue = proxy_srv;
1222 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1223 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1225 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1227 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1229 HeapFree(GetProcessHeap(), 0, list.pOptions);
1231 /* get & verify the global IE proxy server */
1232 list.dwOptionCount = 2;
1233 list.dwOptionError = 0;
1234 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1236 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1237 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1239 ret = InternetQueryOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1241 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1242 ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1243 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1244 proxy_srv, list.pOptions[0].Value.pszValue);
1245 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1246 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1247 list.pOptions[1].Value.dwValue);
1249 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1250 HeapFree(GetProcessHeap(), 0, list.pOptions);
1252 /* restore original settings */
1253 list.dwOptionCount = 2;
1254 list.pOptions = orig_settings;
1256 ret = InternetSetOptionA(NULL, INTERNET_OPTION_PER_CONNECTION_OPTION,
1258 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1260 HeapFree(GetProcessHeap(), 0, list.pOptions);
1263 #define FLAG_TODO 0x1
1264 #define FLAG_NEEDREQ 0x2
1265 #define FLAG_UNIMPL 0x4
1267 static void test_InternetErrorDlg(void)
1269 HINTERNET ses, con, req;
1273 static const struct {
1278 { ERROR_INTERNET_INCORRECT_PASSWORD , ERROR_SUCCESS, FLAG_NEEDREQ },
1279 { ERROR_INTERNET_SEC_CERT_DATE_INVALID , ERROR_CANCELLED, 0 },
1280 { ERROR_INTERNET_SEC_CERT_CN_INVALID , ERROR_CANCELLED, 0 },
1281 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR , ERROR_SUCCESS, 0 },
1282 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR , ERROR_SUCCESS, FLAG_TODO },
1283 { ERROR_INTERNET_MIXED_SECURITY , ERROR_CANCELLED, FLAG_TODO },
1284 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE , ERROR_CANCELLED, FLAG_TODO },
1285 { ERROR_INTERNET_POST_IS_NON_SECURE , ERROR_SUCCESS, 0 },
1286 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, ERROR_CANCELLED, FLAG_NEEDREQ|FLAG_TODO },
1287 { ERROR_INTERNET_INVALID_CA , ERROR_CANCELLED, 0 },
1288 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR, ERROR_CANCELLED, FLAG_TODO },
1289 { ERROR_INTERNET_INSERT_CDROM , ERROR_CANCELLED, FLAG_TODO|FLAG_NEEDREQ|FLAG_UNIMPL },
1290 { ERROR_INTERNET_SEC_CERT_ERRORS , ERROR_CANCELLED, 0 },
1291 { ERROR_INTERNET_SEC_CERT_REV_FAILED , ERROR_CANCELLED, 0 },
1292 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION , ERROR_HTTP_COOKIE_DECLINED, FLAG_TODO },
1293 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT , ERROR_CANCELLED, FLAG_TODO },
1294 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT, ERROR_CANCELLED, FLAG_TODO },
1295 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION, ERROR_CANCELLED, FLAG_TODO },
1296 { ERROR_INTERNET_SEC_CERT_REVOKED , ERROR_CANCELLED, 0 },
1297 { 0, ERROR_NOT_SUPPORTED }
1302 res = InternetErrorDlg(NULL, NULL, 12055, flags, NULL);
1303 ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1305 ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
1306 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1307 con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1308 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1309 req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1310 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1312 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1313 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1315 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1316 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1319 hwnd = GetDesktopWindow();
1320 ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1322 flags = FLAGS_ERROR_UI_FLAGS_NO_UI;
1323 for(i = INTERNET_ERROR_BASE; i < INTERNET_ERROR_LAST; i++)
1325 DWORD expected, test_flags, j;
1327 for(j = 0; no_ui_res[j].error != 0; ++j)
1328 if(no_ui_res[j].error == i)
1331 test_flags = no_ui_res[j].test_flags;
1332 expected = no_ui_res[j].res;
1334 /* Try an invalid request handle */
1335 res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
1336 if(res == ERROR_CALL_NOT_IMPLEMENTED)
1338 ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1342 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1344 /* With a valid req */
1345 if(i == ERROR_INTERNET_NEED_UI)
1346 continue; /* Crashes on windows XP */
1348 if(i == ERROR_INTERNET_SEC_CERT_REVOKED)
1349 continue; /* Interactive (XP, Win7) */
1351 res = InternetErrorDlg(hwnd, req, i, flags, NULL);
1353 /* Handle some special cases */
1356 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
1357 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR:
1358 if(res == ERROR_CANCELLED)
1360 /* Some windows XP, w2k3 x64, W2K8 */
1361 win_skip("Skipping some tests for %d\n", i);
1365 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED:
1368 /* Windows XP, W2K3 */
1369 ok(res == NTE_PROV_TYPE_NOT_DEF, "Got %d\n", res);
1370 win_skip("Skipping some tests for %d\n", i);
1377 if(test_flags & FLAG_TODO)
1378 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1380 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1382 /* Same thing with NULL hwnd */
1383 res = InternetErrorDlg(NULL, req, i, flags, NULL);
1384 if(test_flags & FLAG_TODO)
1385 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1387 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1390 /* With a null req */
1391 if(test_flags & FLAG_NEEDREQ)
1392 expected = ERROR_INVALID_PARAMETER;
1394 res = InternetErrorDlg(hwnd, NULL, i, flags, NULL);
1395 if( test_flags & FLAG_TODO || i == ERROR_INTERNET_INCORRECT_PASSWORD)
1396 todo_wine ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1398 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1401 res = InternetCloseHandle(req);
1402 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1403 res = InternetCloseHandle(con);
1404 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1405 res = InternetCloseHandle(ses);
1406 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1409 /* ############################### */
1411 START_TEST(internet)
1414 hdll = GetModuleHandleA("wininet.dll");
1416 pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1417 pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1418 pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1419 pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1420 pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1421 pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1422 pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1423 pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1424 pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1425 pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
1426 pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
1428 if(!pInternetGetCookieExW) {
1429 win_skip("Too old IE (older than 6.0)\n");
1433 test_InternetCanonicalizeUrlA();
1434 test_InternetQueryOptionA();
1436 test_complicated_cookie();
1440 test_Option_PerConnectionOption();
1441 test_Option_PerConnectionOptionA();
1442 test_InternetErrorDlg();
1445 if (!pInternetTimeFromSystemTimeA)
1446 win_skip("skipping the InternetTime tests\n");
1449 InternetTimeFromSystemTimeA_test();
1450 InternetTimeFromSystemTimeW_test();
1451 InternetTimeToSystemTimeA_test();
1452 InternetTimeToSystemTimeW_test();
1454 if (pIsDomainLegalCookieDomainW &&
1455 ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1456 (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1457 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1458 else if (!pIsDomainLegalCookieDomainW)
1459 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1461 test_IsDomainLegalCookieDomainW();
1463 if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1464 test_PrivacyGetSetZonePreferenceW();
1466 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1468 test_InternetSetOption();