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
31 #include "wine/test.h"
33 static BOOL (WINAPI
*pCreateUrlCacheContainerA
)(DWORD
, DWORD
, DWORD
, DWORD
,
34 DWORD
, DWORD
, DWORD
, DWORD
);
35 static BOOL (WINAPI
*pCreateUrlCacheContainerW
)(DWORD
, DWORD
, DWORD
, DWORD
,
36 DWORD
, DWORD
, DWORD
, DWORD
);
37 static BOOL (WINAPI
*pInternetTimeFromSystemTimeA
)(CONST SYSTEMTIME
*,DWORD
,LPSTR
,DWORD
);
38 static BOOL (WINAPI
*pInternetTimeFromSystemTimeW
)(CONST SYSTEMTIME
*,DWORD
,LPWSTR
,DWORD
);
39 static BOOL (WINAPI
*pInternetTimeToSystemTimeA
)(LPCSTR
,SYSTEMTIME
*,DWORD
);
40 static BOOL (WINAPI
*pInternetTimeToSystemTimeW
)(LPCWSTR
,SYSTEMTIME
*,DWORD
);
41 static BOOL (WINAPI
*pIsDomainLegalCookieDomainW
)(LPCWSTR
, LPCWSTR
);
42 static DWORD (WINAPI
*pPrivacyGetZonePreferenceW
)(DWORD
, DWORD
, LPDWORD
, LPWSTR
, LPDWORD
);
43 static DWORD (WINAPI
*pPrivacySetZonePreferenceW
)(DWORD
, DWORD
, DWORD
, LPCWSTR
);
44 static BOOL (WINAPI
*pInternetGetCookieExA
)(LPCSTR
,LPCSTR
,LPSTR
,LPDWORD
,DWORD
,LPVOID
);
45 static BOOL (WINAPI
*pInternetGetCookieExW
)(LPCWSTR
,LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
,LPVOID
);
47 /* ############################### */
49 static void test_InternetCanonicalizeUrlA(void)
57 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
58 url
= "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
59 urllen
= lstrlenA(url
);
61 memset(buffer
, '#', sizeof(buffer
)-1);
62 buffer
[sizeof(buffer
)-1] = '\0';
63 dwSize
= 1; /* Acrobat Updater use this size */
64 SetLastError(0xdeadbeef);
65 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
66 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
67 "got %u and %u with size %u for '%s' (%d)\n",
68 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
71 /* buffer has no space for the terminating '\0' */
72 memset(buffer
, '#', sizeof(buffer
)-1);
73 buffer
[sizeof(buffer
)-1] = '\0';
75 SetLastError(0xdeadbeef);
76 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
77 /* dwSize is nr. of needed bytes with the terminating '\0' */
78 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
79 "got %u and %u with size %u for '%s' (%d)\n",
80 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
82 /* buffer has the required size */
83 memset(buffer
, '#', sizeof(buffer
)-1);
84 buffer
[sizeof(buffer
)-1] = '\0';
86 SetLastError(0xdeadbeef);
87 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
88 /* dwSize is nr. of copied bytes without the terminating '\0' */
89 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
90 "got %u and %u with size %u for '%s' (%d)\n",
91 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
93 memset(buffer
, '#', sizeof(buffer
)-1);
94 buffer
[sizeof(buffer
)-1] = '\0';
95 dwSize
= sizeof(buffer
);
96 SetLastError(0xdeadbeef);
97 res
= InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer
, &dwSize
, ICU_DECODE
| ICU_NO_ENCODE
);
98 ok(res
, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
99 ok(dwSize
== lstrlenA(buffer
), "got %d expected %d\n", dwSize
, lstrlenA(buffer
));
100 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer
),
101 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer
);
103 /* buffer is larger as the required size */
104 memset(buffer
, '#', sizeof(buffer
)-1);
105 buffer
[sizeof(buffer
)-1] = '\0';
107 SetLastError(0xdeadbeef);
108 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
109 /* dwSize is nr. of copied bytes without the terminating '\0' */
110 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
111 "got %u and %u with size %u for '%s' (%d)\n",
112 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
115 /* check NULL pointers */
116 memset(buffer
, '#', urllen
+ 4);
117 buffer
[urllen
+ 4] = '\0';
119 SetLastError(0xdeadbeef);
120 res
= InternetCanonicalizeUrlA(NULL
, buffer
, &dwSize
, 0);
121 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
122 "got %u and %u with size %u for '%s' (%d)\n",
123 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
125 memset(buffer
, '#', urllen
+ 4);
126 buffer
[urllen
+ 4] = '\0';
128 SetLastError(0xdeadbeef);
129 res
= InternetCanonicalizeUrlA(url
, NULL
, &dwSize
, 0);
130 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
131 "got %u and %u with size %u for '%s' (%d)\n",
132 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
134 memset(buffer
, '#', urllen
+ 4);
135 buffer
[urllen
+ 4] = '\0';
137 SetLastError(0xdeadbeef);
138 res
= InternetCanonicalizeUrlA(url
, buffer
, NULL
, 0);
139 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
140 "got %u and %u with size %u for '%s' (%d)\n",
141 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
143 /* test with trailing space */
145 res
= InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer
, &dwSize
, ICU_BROWSER_MODE
);
146 ok(res
== 1, "InternetCanonicalizeUrlA failed\n");
147 ok(!strcmp(buffer
, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer
);
149 res
= InternetSetOptionA(NULL
, 0xdeadbeef, buffer
, sizeof(buffer
));
150 ok(!res
, "InternetSetOptionA succeeded\n");
151 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION
,
152 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
155 /* ############################### */
157 static void test_InternetQueryOptionA(void)
159 HINTERNET hinet
,hurl
;
162 static const char useragent
[] = {"Wininet Test"};
167 hinet
= InternetOpenA(useragent
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
168 ok((hinet
!= 0x0),"InternetOpen Failed\n");
170 SetLastError(0xdeadbeef);
171 retval
=InternetQueryOptionA(NULL
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
173 ok(retval
== 0,"Got wrong return value %d\n",retval
);
174 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code%d\n",err
);
176 SetLastError(0xdeadbeef);
177 len
=strlen(useragent
)+1;
178 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
180 ok(len
== strlen(useragent
)+1,"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
181 ok(retval
== 0,"Got wrong return value %d\n",retval
);
182 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n",err
);
184 SetLastError(0xdeadbeef);
185 len
=strlen(useragent
)+1;
186 buffer
=HeapAlloc(GetProcessHeap(),0,len
);
187 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
189 ok(retval
== 1,"Got wrong return value %d\n",retval
);
192 ok(!strcmp(useragent
,buffer
),"Got wrong user agent string %s instead of %s\n",buffer
,useragent
);
193 ok(len
== strlen(useragent
),"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
195 ok(err
== 0xdeadbeef, "Got wrong error code %d\n",err
);
196 HeapFree(GetProcessHeap(),0,buffer
);
198 SetLastError(0xdeadbeef);
200 buffer
=HeapAlloc(GetProcessHeap(),0,100);
201 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
203 ok(len
== strlen(useragent
) + 1,"Got wrong user agent length %d instead of %d\n", len
, lstrlenA(useragent
) + 1);
204 ok(!retval
, "Got wrong return value %d\n", retval
);
205 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n", err
);
206 HeapFree(GetProcessHeap(),0,buffer
);
208 hurl
= InternetConnectA(hinet
,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT
,NULL
,NULL
,INTERNET_SERVICE_HTTP
,0,0);
210 SetLastError(0xdeadbeef);
212 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
214 ok(len
== 0,"Got wrong user agent length %d instead of 0\n",len
);
215 ok(retval
== 0,"Got wrong return value %d\n",retval
);
216 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
218 SetLastError(0xdeadbeef);
220 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_REQUEST_FLAGS
,NULL
,&len
);
221 err
= GetLastError();
222 ok(retval
== 0,"Got wrong return value %d\n",retval
);
223 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
224 ok(len
== sizeof(DWORD
), "len = %d\n", len
);
226 SetLastError(0xdeadbeef);
228 retval
= InternetQueryOptionA(NULL
,INTERNET_OPTION_REQUEST_FLAGS
,NULL
,&len
);
229 err
= GetLastError();
230 ok(retval
== 0,"Got wrong return value %d\n",retval
);
231 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
232 ok(!len
, "len = %d\n", len
);
234 InternetCloseHandle(hurl
);
235 InternetCloseHandle(hinet
);
237 hinet
= InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
238 ok((hinet
!= 0x0),"InternetOpen Failed\n");
240 SetLastError(0xdeadbeef);
242 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
244 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
245 ok(retval
== 0,"Got wrong return value %d\n",retval
);
246 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
248 InternetCloseHandle(hinet
);
251 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
252 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
255 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
256 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
257 ok(val
== 12345, "val = %d\n", val
);
258 ok(len
== sizeof(val
), "len = %d\n", len
);
260 hinet
= InternetOpenA(NULL
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
261 ok((hinet
!= 0x0),"InternetOpen Failed\n");
262 SetLastError(0xdeadbeef);
264 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
266 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
267 ok(retval
== 0,"Got wrong return value %d\n",retval
);
268 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
272 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
273 ok(!res
, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
274 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
277 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
278 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
279 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
282 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
283 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
284 ok(val
== 12345, "val = %d\n", val
);
285 ok(len
== sizeof(val
), "len = %d\n", len
);
288 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
289 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
292 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
293 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
294 ok(val
== 1, "val = %d\n", val
);
295 ok(len
== sizeof(val
), "len = %d\n", len
);
298 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
299 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
300 ok(val
== 12345, "val = %d\n", val
);
301 ok(len
== sizeof(val
), "len = %d\n", len
);
303 InternetCloseHandle(hinet
);
306 static void test_max_conns(void)
313 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
314 ok(res
,"Got wrong return value %x\n", res
);
315 ok(len
== sizeof(val
), "got %d\n", len
);
316 ok(val
== 2, "got %d\n", val
);
320 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
, &val
, &len
);
321 ok(res
,"Got wrong return value %x\n", res
);
322 ok(len
== sizeof(val
), "got %d\n", len
);
323 ok(val
== 4, "got %d\n", val
);
326 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
327 ok(res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res
);
331 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
332 ok(res
,"Got wrong return value %x\n", res
);
333 ok(len
== sizeof(val
), "got %d\n", len
);
334 ok(val
== 3, "got %d\n", val
);
337 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
338 ok(!res
|| broken(res
), /* <= w2k3 */
339 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
340 if (!res
) ok(GetLastError() == ERROR_BAD_ARGUMENTS
, "GetLastError() = %u\n", GetLastError());
343 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)-1);
344 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
345 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
348 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)+1);
349 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
350 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
353 static void test_get_cookie(void)
358 SetLastError(0xdeadbeef);
359 ret
= InternetGetCookie("http://www.example.com", NULL
, NULL
, &len
);
360 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
,
361 "InternetGetCookie should have failed with %s and error %d\n",
362 ret
? "TRUE" : "FALSE", GetLastError());
366 static void test_complicated_cookie(void)
375 static const WCHAR testing_example_comW
[] =
376 {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.','e','x','a','m','p','l','e','.','c','o','m',0};
378 ret
= InternetSetCookie("http://www.example.com/bar",NULL
,"A=B; domain=.example.com");
379 ok(ret
== TRUE
,"InternetSetCookie failed\n");
380 ret
= InternetSetCookie("http://www.example.com/bar",NULL
,"C=D; domain=.example.com; path=/");
381 ok(ret
== TRUE
,"InternetSetCookie failed\n");
383 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
384 ret
= InternetSetCookie("http://www.example.com",NULL
,"E=F; domain=example.com");
385 ok(ret
== TRUE
,"InternetSetCookie failed\n");
386 ret
= InternetSetCookie("http://www.example.com",NULL
,"G=H; domain=.example.com; path=/foo");
387 ok(ret
== TRUE
,"InternetSetCookie failed\n");
388 ret
= InternetSetCookie("http://www.example.com/bar.html",NULL
,"I=J; domain=.example.com");
389 ok(ret
== TRUE
,"InternetSetCookie failed\n");
390 ret
= InternetSetCookie("http://www.example.com/bar/",NULL
,"K=L; domain=.example.com");
391 ok(ret
== TRUE
,"InternetSetCookie failed\n");
392 ret
= InternetSetCookie("http://www.example.com/bar/",NULL
,"M=N; domain=.example.com; path=/foo/");
393 ok(ret
== TRUE
,"InternetSetCookie failed\n");
394 ret
= InternetSetCookie("http://www.example.com/bar/",NULL
,"O=P; secure; path=/bar");
395 ok(ret
== TRUE
,"InternetSetCookie failed\n");
398 ret
= InternetGetCookie("http://testing.example.com", NULL
, NULL
, &len
);
399 ok(ret
== TRUE
,"InternetGetCookie failed\n");
400 ok(len
== 19, "len = %u\n", len
);
403 memset(buffer
, 0xac, sizeof(buffer
));
404 ret
= InternetGetCookie("http://testing.example.com", NULL
, buffer
, &len
);
405 ok(ret
== TRUE
,"InternetGetCookie failed\n");
406 ok(len
== 19, "len = %u\n", len
);
407 ok(strlen(buffer
) == 18, "strlen(buffer) = %u\n", lstrlenA(buffer
));
408 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
409 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
410 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
411 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
412 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
413 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
414 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
415 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
418 memset(buffer
, 0xac, sizeof(buffer
));
419 ret
= InternetGetCookie("http://testing.example.com", NULL
, buffer
, &len
);
420 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
421 "InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret
, GetLastError());
422 ok(len
== 19, "len = %u\n", len
);
425 ret
= InternetGetCookieW(testing_example_comW
, NULL
, NULL
, &len
);
426 ok(ret
== TRUE
,"InternetGetCookieW failed\n");
427 ok(len
== 38, "len = %u\n", len
);
430 memset(wbuf
, 0xac, sizeof(wbuf
));
431 ret
= InternetGetCookieW(testing_example_comW
, NULL
, wbuf
, &len
);
432 ok(ret
== TRUE
,"InternetGetCookieW failed\n");
433 ok(len
== 19, "len = %u\n", len
);
434 ok(lstrlenW(wbuf
) == 18, "strlenW(wbuf) = %u\n", lstrlenW(wbuf
));
437 memset(wbuf
, 0xac, sizeof(wbuf
));
438 ret
= InternetGetCookieW(testing_example_comW
, NULL
, wbuf
, &len
);
439 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
440 "InternetGetCookieW returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret
, GetLastError());
441 ok(len
== 38, "len = %u\n", len
);
444 ret
= InternetGetCookie("http://testing.example.com/foobar", NULL
, buffer
, &len
);
445 ok(ret
== TRUE
,"InternetGetCookie failed\n");
446 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
447 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
448 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
449 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
450 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
451 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
452 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
453 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
456 ret
= InternetGetCookie("http://testing.example.com/foobar/", NULL
, buffer
, &len
);
457 ok(ret
== TRUE
,"InternetGetCookie failed\n");
458 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
459 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
460 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
461 ok(strstr(buffer
,"G=H")!=NULL
,"G=H missing\n");
462 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
463 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
464 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
465 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
468 ret
= InternetGetCookie("http://testing.example.com/foo/bar", NULL
, buffer
, &len
);
469 ok(ret
== TRUE
,"InternetGetCookie failed\n");
470 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
471 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
472 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
473 ok(strstr(buffer
,"G=H")!=NULL
,"G=H missing\n");
474 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
475 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
476 ok(strstr(buffer
,"M=N")!=NULL
,"M=N missing\n");
477 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
480 ret
= InternetGetCookie("http://testing.example.com/barfoo", NULL
, buffer
, &len
);
481 ok(ret
== TRUE
,"InternetGetCookie failed\n");
482 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
483 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
484 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
485 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
486 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
487 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
488 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
489 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
492 ret
= InternetGetCookie("http://testing.example.com/barfoo/", NULL
, buffer
, &len
);
493 ok(ret
== TRUE
,"InternetGetCookie failed\n");
494 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
495 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
496 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
497 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
498 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
499 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
500 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
501 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
504 ret
= InternetGetCookie("http://testing.example.com/bar/foo", NULL
, buffer
, &len
);
505 ok(ret
== TRUE
,"InternetGetCookie failed\n");
506 ok(len
== 24, "len = %u\n", 24);
507 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
508 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
509 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
510 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
511 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
512 ok(strstr(buffer
,"K=L")!=NULL
,"K=L missing\n");
513 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
514 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
516 /* Cookie name argument is not implemented */
518 ret
= InternetGetCookie("http://testing.example.com/bar/foo", "A", buffer
, &len
);
519 ok(ret
== TRUE
,"InternetGetCookie failed\n");
520 ok(len
== 24, "len = %u\n", 24);
522 /* test persistent cookies */
523 ret
= InternetSetCookie("http://testing.example.com", NULL
, "A=B; expires=Fri, 01-Jan-2038 00:00:00 GMT");
524 ok(ret
, "InternetSetCookie failed with error %d\n", GetLastError());
527 ret
= GetUserName(user
, &len
);
528 ok(ret
, "GetUserName failed with error %d\n", GetLastError());
530 user
[len
-1] = tolower(user
[len
-1]);
532 sprintf(buffer
, "Cookie:%s@testing.example.com/", user
);
533 ret
= GetUrlCacheEntryInfo(buffer
, NULL
, &len
);
534 ok(!ret
, "GetUrlCacheEntryInfo succeeded\n");
535 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %d\n", GetLastError());
537 /* remove persistent cookie */
538 ret
= InternetSetCookie("http://testing.example.com", NULL
, "A=B");
539 ok(ret
, "InternetSetCookie failed with error %d\n", GetLastError());
541 ret
= GetUrlCacheEntryInfo(buffer
, NULL
, &len
);
542 ok(!ret
, "GetUrlCacheEntryInfo succeeded\n");
543 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError() = %d\n", GetLastError());
545 /* try setting cookie for different domain */
546 ret
= InternetSetCookie("http://www.aaa.example.com/bar",NULL
,"E=F; domain=different.com");
547 ok(!ret
, "InternetSetCookie succeeded\n");
548 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %d\n", GetLastError());
549 ret
= InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL
,"E=F; domain=example.com.pl");
550 ok(ret
, "InternetSetCookie failed with error: %d\n", GetLastError());
551 ret
= InternetSetCookie("http://www.aaa.example.com.pl/bar",NULL
,"E=F; domain=com.pl");
552 todo_wine
ok(!ret
, "InternetSetCookie succeeded\n");
555 static void test_cookie_url(void)
562 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
565 res
= InternetGetCookieA("about:blank", NULL
, buf
, &len
);
566 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
567 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
569 len
= sizeof(bufw
)/sizeof(*bufw
);
570 res
= InternetGetCookieW(about_blankW
, NULL
, bufw
, &len
);
571 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
572 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
575 res
= pInternetGetCookieExA("about:blank", NULL
, buf
, &len
, 0, NULL
);
576 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
577 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
579 len
= sizeof(bufw
)/sizeof(*bufw
);
580 res
= pInternetGetCookieExW(about_blankW
, NULL
, bufw
, &len
, 0, NULL
);
581 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
582 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
585 static void test_null(void)
588 static const WCHAR szServer
[] = { 's','e','r','v','e','r',0 };
589 static const WCHAR szEmpty
[] = { 0 };
590 static const WCHAR szUrl
[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
591 static const WCHAR szUrlEmpty
[] = { 'h','t','t','p',':','/','/',0 };
592 static const WCHAR szExpect
[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
597 SetLastError(0xdeadbeef);
598 hi
= InternetOpenW(NULL
, 0, NULL
, NULL
, 0);
599 if (hi
== NULL
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
601 win_skip("Internet*W functions are not implemented\n");
604 ok(hi
!= NULL
, "open failed\n");
606 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, 0, 0, 0);
607 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
608 ok(hc
== NULL
, "connect failed\n");
610 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
611 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
612 ok(hc
== NULL
, "connect failed\n");
614 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
615 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
616 ok(hc
== NULL
, "connect failed\n");
618 hc
= InternetConnectW(NULL
, szServer
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
619 ok(GetLastError() == ERROR_INVALID_HANDLE
, "wrong error\n");
620 ok(hc
== NULL
, "connect failed\n");
622 hc
= InternetOpenUrlW(hi
, NULL
, NULL
, 0, 0, 0);
623 ok(GetLastError() == ERROR_INVALID_PARAMETER
||
624 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
625 ok(hc
== NULL
, "connect failed\n");
627 hc
= InternetOpenUrlW(hi
, szServer
, NULL
, 0, 0, 0);
628 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
629 ok(hc
== NULL
, "connect failed\n");
631 InternetCloseHandle(hi
);
633 r
= InternetSetCookieW(NULL
, NULL
, NULL
);
634 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
635 ok(r
== FALSE
, "return wrong\n");
637 r
= InternetSetCookieW(szServer
, NULL
, NULL
);
638 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
639 ok(r
== FALSE
, "return wrong\n");
641 r
= InternetSetCookieW(szUrl
, szServer
, NULL
);
642 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
643 ok(r
== FALSE
, "return wrong\n");
645 r
= InternetSetCookieW(szUrl
, szServer
, szServer
);
646 ok(r
== TRUE
, "return wrong\n");
648 r
= InternetSetCookieW(szUrl
, NULL
, szServer
);
649 ok(r
== TRUE
, "return wrong\n");
651 r
= InternetSetCookieW(szUrl
, szServer
, szEmpty
);
652 ok(r
== TRUE
, "return wrong\n");
654 r
= InternetSetCookieW(szUrlEmpty
, szServer
, szServer
);
655 ok(r
== FALSE
, "return wrong\n");
657 r
= InternetSetCookieW(szServer
, NULL
, szServer
);
658 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
659 ok(r
== FALSE
, "return wrong\n");
662 r
= InternetGetCookieW(NULL
, NULL
, NULL
, &sz
);
663 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
664 "wrong error %u\n", GetLastError());
665 ok( r
== FALSE
, "return wrong\n");
667 r
= InternetGetCookieW(szServer
, NULL
, NULL
, &sz
);
669 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
671 ok( r
== FALSE
, "return wrong\n");
674 r
= InternetGetCookieW(szUrlEmpty
, szServer
, NULL
, &sz
);
675 ok( r
== FALSE
, "return wrong\n");
678 r
= InternetGetCookieW(szUrl
, szServer
, NULL
, &sz
);
679 ok( r
== TRUE
, "return wrong\n");
681 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
682 ok( sz
== 14 || sz
== 30, "sz wrong, got %u, expected 14 or 30\n", sz
);
685 memset(buffer
, 0, sizeof buffer
);
686 r
= InternetGetCookieW(szUrl
, szServer
, buffer
, &sz
);
687 ok( r
== TRUE
, "return wrong\n");
689 /* sz == lstrlenW(buffer) only in XP SP1 */
690 ok( sz
== 1 + lstrlenW(buffer
) || sz
== lstrlenW(buffer
), "sz wrong %d\n", sz
);
692 /* before XP SP2, buffer is "server; server" */
693 ok( !lstrcmpW(szExpect
, buffer
) || !lstrcmpW(szServer
, buffer
), "cookie data wrong\n");
696 r
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECTED_STATE
, buffer
, &sz
);
697 ok(r
== TRUE
, "ret %d\n", r
);
700 static void test_version(void)
702 INTERNET_VERSION_INFO version
;
706 size
= sizeof(version
);
707 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_VERSION
, &version
, &size
);
708 ok(res
, "Could not get version: %u\n", GetLastError());
709 ok(version
.dwMajorVersion
== 1, "dwMajorVersion=%d, expected 1\n", version
.dwMajorVersion
);
710 ok(version
.dwMinorVersion
== 2, "dwMinorVersion=%d, expected 2\n", version
.dwMinorVersion
);
713 static void InternetTimeFromSystemTimeA_test(void)
716 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
717 char string
[INTERNET_RFC1123_BUFSIZE
];
718 static const char expect
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
721 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
722 ok( ret
, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
724 ok( !memcmp( string
, expect
, sizeof(expect
) ),
725 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
727 /* test NULL time parameter */
728 SetLastError(0xdeadbeef);
729 ret
= pInternetTimeFromSystemTimeA( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
730 error
= GetLastError();
731 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
732 ok( error
== ERROR_INVALID_PARAMETER
,
733 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
736 /* test NULL string parameter */
737 SetLastError(0xdeadbeef);
738 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
739 error
= GetLastError();
740 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
741 ok( error
== ERROR_INVALID_PARAMETER
,
742 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
745 /* test invalid format parameter */
746 SetLastError(0xdeadbeef);
747 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
748 error
= GetLastError();
749 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
750 ok( error
== ERROR_INVALID_PARAMETER
,
751 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
754 /* test too small buffer size */
755 SetLastError(0xdeadbeef);
756 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, 0 );
757 error
= GetLastError();
758 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
759 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
760 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
764 static void InternetTimeFromSystemTimeW_test(void)
767 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
768 WCHAR string
[INTERNET_RFC1123_BUFSIZE
+ 1];
769 static const WCHAR expect
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
770 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
773 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
774 ok( ret
, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
776 ok( !memcmp( string
, expect
, sizeof(expect
) ),
777 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
779 /* test NULL time parameter */
780 SetLastError(0xdeadbeef);
781 ret
= pInternetTimeFromSystemTimeW( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
782 error
= GetLastError();
783 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
784 ok( error
== ERROR_INVALID_PARAMETER
,
785 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
788 /* test NULL string parameter */
789 SetLastError(0xdeadbeef);
790 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
791 error
= GetLastError();
792 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
793 ok( error
== ERROR_INVALID_PARAMETER
,
794 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
797 /* test invalid format parameter */
798 SetLastError(0xdeadbeef);
799 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
800 error
= GetLastError();
801 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
802 ok( error
== ERROR_INVALID_PARAMETER
,
803 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
806 /* test too small buffer size */
807 SetLastError(0xdeadbeef);
808 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
)/sizeof(string
[0]) );
809 error
= GetLastError();
810 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
811 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
812 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
816 static void InternetTimeToSystemTimeA_test(void)
820 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
821 static const char string
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
822 static const char string2
[] = " fri 7 jan 2005 12 06 35";
824 ret
= pInternetTimeToSystemTimeA( string
, &time
, 0 );
825 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
826 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
827 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
829 ret
= pInternetTimeToSystemTimeA( string2
, &time
, 0 );
830 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
831 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
832 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
835 static void InternetTimeToSystemTimeW_test(void)
839 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
840 static const WCHAR string
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
841 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
842 static const WCHAR string2
[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
843 '1','2',' ','0','6',' ','3','5',0 };
844 static const WCHAR string3
[] = { 'F','r',0 };
846 ret
= pInternetTimeToSystemTimeW( NULL
, NULL
, 0 );
847 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
849 ret
= pInternetTimeToSystemTimeW( NULL
, &time
, 0 );
850 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
852 ret
= pInternetTimeToSystemTimeW( string
, NULL
, 0 );
853 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
855 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
856 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
858 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
859 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
860 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
861 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
863 ret
= pInternetTimeToSystemTimeW( string2
, &time
, 0 );
864 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
865 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
866 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
868 ret
= pInternetTimeToSystemTimeW( string3
, &time
, 0 );
869 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
872 static void test_IsDomainLegalCookieDomainW(void)
876 static const WCHAR empty
[] = {0};
877 static const WCHAR dot
[] = {'.',0};
878 static const WCHAR uk
[] = {'u','k',0};
879 static const WCHAR com
[] = {'c','o','m',0};
880 static const WCHAR dot_com
[] = {'.','c','o','m',0};
881 static const WCHAR gmail_com
[] = {'g','m','a','i','l','.','c','o','m',0};
882 static const WCHAR dot_gmail_com
[] = {'.','g','m','a','i','l','.','c','o','m',0};
883 static const WCHAR www_gmail_com
[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
884 static const WCHAR www_mail_gmail_com
[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
885 static const WCHAR mail_gmail_com
[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
886 static const WCHAR gmail_co_uk
[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
887 static const WCHAR co_uk
[] = {'c','o','.','u','k',0};
888 static const WCHAR dot_co_uk
[] = {'.','c','o','.','u','k',0};
890 SetLastError(0xdeadbeef);
891 ret
= pIsDomainLegalCookieDomainW(NULL
, NULL
);
892 error
= GetLastError();
893 if (!ret
&& error
== ERROR_CALL_NOT_IMPLEMENTED
)
895 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
899 broken(ret
), /* IE6 */
900 "IsDomainLegalCookieDomainW succeeded\n");
901 ok(error
== ERROR_INVALID_PARAMETER
, "got %u expected ERROR_INVALID_PARAMETER\n", error
);
903 SetLastError(0xdeadbeef);
904 ret
= pIsDomainLegalCookieDomainW(com
, NULL
);
905 error
= GetLastError();
906 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
907 ok(error
== ERROR_INVALID_PARAMETER
, "got %u expected ERROR_INVALID_PARAMETER\n", error
);
909 SetLastError(0xdeadbeef);
910 ret
= pIsDomainLegalCookieDomainW(NULL
, gmail_com
);
911 error
= GetLastError();
912 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
913 ok(error
== ERROR_INVALID_PARAMETER
, "got %u expected ERROR_INVALID_PARAMETER\n", error
);
915 SetLastError(0xdeadbeef);
916 ret
= pIsDomainLegalCookieDomainW(empty
, gmail_com
);
917 error
= GetLastError();
918 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
919 ok(error
== ERROR_INVALID_NAME
||
920 broken(error
== ERROR_INVALID_PARAMETER
), /* IE6 */
921 "got %u expected ERROR_INVALID_NAME\n", error
);
923 SetLastError(0xdeadbeef);
924 ret
= pIsDomainLegalCookieDomainW(com
, empty
);
925 error
= GetLastError();
926 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
927 ok(error
== ERROR_INVALID_NAME
||
928 broken(error
== ERROR_INVALID_PARAMETER
), /* IE6 */
929 "got %u expected ERROR_INVALID_NAME\n", error
);
931 SetLastError(0xdeadbeef);
932 ret
= pIsDomainLegalCookieDomainW(gmail_com
, dot
);
933 error
= GetLastError();
934 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
935 ok(error
== ERROR_INVALID_NAME
||
936 broken(error
== 0xdeadbeef), /* IE6 */
937 "got %u expected ERROR_INVALID_NAME\n", error
);
939 SetLastError(0xdeadbeef);
940 ret
= pIsDomainLegalCookieDomainW(dot
, gmail_com
);
941 error
= GetLastError();
942 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
943 ok(error
== ERROR_INVALID_NAME
||
944 broken(error
== 0xdeadbeef), /* IE6 */
945 "got %u expected ERROR_INVALID_NAME\n", error
);
947 SetLastError(0xdeadbeef);
948 ret
= pIsDomainLegalCookieDomainW(com
, com
);
949 error
= GetLastError();
950 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
951 ok(error
== 0xdeadbeef, "got %u expected 0xdeadbeef\n", error
);
953 SetLastError(0xdeadbeef);
954 ret
= pIsDomainLegalCookieDomainW(com
, dot_com
);
955 error
= GetLastError();
956 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
957 ok(error
== ERROR_INVALID_NAME
||
958 broken(error
== 0xdeadbeef), /* IE6 */
959 "got %u expected ERROR_INVALID_NAME\n", error
);
961 SetLastError(0xdeadbeef);
962 ret
= pIsDomainLegalCookieDomainW(dot_com
, com
);
963 error
= GetLastError();
964 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
965 ok(error
== ERROR_INVALID_NAME
||
966 broken(error
== 0xdeadbeef), /* IE6 */
967 "got %u expected ERROR_INVALID_NAME\n", error
);
969 SetLastError(0xdeadbeef);
970 ret
= pIsDomainLegalCookieDomainW(com
, gmail_com
);
971 error
= GetLastError();
972 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
973 ok(error
== ERROR_SXS_KEY_NOT_FOUND
||
974 error
== ERROR_SUCCESS
|| /* IE8 on W2K3 */
975 error
== 0xdeadbeef, /* up to IE7 */
976 "unexpected error: %u\n", error
);
978 ret
= pIsDomainLegalCookieDomainW(gmail_com
, gmail_com
);
979 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
981 ret
= pIsDomainLegalCookieDomainW(gmail_com
, www_gmail_com
);
982 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
984 ret
= pIsDomainLegalCookieDomainW(gmail_com
, www_mail_gmail_com
);
985 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
987 SetLastError(0xdeadbeef);
988 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, co_uk
);
989 error
= GetLastError();
990 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
991 ok(error
== ERROR_SXS_KEY_NOT_FOUND
|| /* IE8 on XP */
992 error
== ERROR_FILE_NOT_FOUND
|| /* IE8 on Vista */
993 error
== ERROR_SUCCESS
|| /* IE8 on W2K3 */
994 error
== 0xdeadbeef, /* up to IE7 */
995 "unexpected error: %u\n", error
);
997 ret
= pIsDomainLegalCookieDomainW(uk
, co_uk
);
998 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1000 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, dot_co_uk
);
1001 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1003 ret
= pIsDomainLegalCookieDomainW(co_uk
, gmail_co_uk
);
1004 todo_wine
ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1006 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, gmail_co_uk
);
1007 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1009 ret
= pIsDomainLegalCookieDomainW(gmail_com
, com
);
1010 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1012 SetLastError(0xdeadbeef);
1013 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
1014 error
= GetLastError();
1015 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1016 ok(error
== ERROR_INVALID_NAME
||
1017 broken(error
== 0xdeadbeef), /* IE6 */
1018 "got %u expected ERROR_INVALID_NAME\n", error
);
1020 ret
= pIsDomainLegalCookieDomainW(gmail_com
, mail_gmail_com
);
1021 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1023 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, gmail_com
);
1024 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1026 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, com
);
1027 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1029 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
1030 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1032 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, dot_gmail_com
);
1033 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1036 static void test_PrivacyGetSetZonePreferenceW(void)
1038 DWORD ret
, zone
, type
, template, old_template
;
1042 ret
= pPrivacyGetZonePreferenceW(zone
, type
, NULL
, NULL
, NULL
);
1043 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1046 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &old_template
, NULL
, NULL
);
1047 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1050 ret
= pPrivacySetZonePreferenceW(zone
, type
, template, NULL
);
1051 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1054 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &template, NULL
, NULL
);
1055 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1056 ok(template == 5, "expected template == 5, got %u\n", template);
1059 ret
= pPrivacySetZonePreferenceW(zone
, type
, old_template
, NULL
);
1060 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1063 static void test_InternetSetOption(void)
1065 HINTERNET ses
, con
, req
;
1070 ses
= InternetOpen(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1071 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1072 con
= InternetConnect(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1073 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1074 req
= HttpOpenRequest(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1075 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1077 /* INTERNET_OPTION_POLICY tests */
1078 SetLastError(0xdeadbeef);
1079 ret
= InternetSetOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
1080 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1081 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
1082 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1084 SetLastError(0xdeadbeef);
1085 ret
= InternetQueryOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
1086 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1087 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
1088 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1090 /* INTERNET_OPTION_ERROR_MASK tests */
1091 SetLastError(0xdeadbeef);
1092 size
= sizeof(ulArg
);
1093 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, &size
);
1094 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1095 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1097 SetLastError(0xdeadbeef);
1099 ret
= InternetSetOption(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1100 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1101 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1103 SetLastError(0xdeadbeef);
1105 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, 20);
1106 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1107 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %d\n", GetLastError());
1109 SetLastError(0xdeadbeef);
1111 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1112 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1113 ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
1115 SetLastError(0xdeadbeef);
1117 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1118 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1119 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
1121 SetLastError(0xdeadbeef);
1123 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1124 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1125 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
1127 ret
= InternetCloseHandle(req
);
1128 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1129 ret
= InternetCloseHandle(con
);
1130 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1131 ret
= InternetCloseHandle(ses
);
1132 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1135 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1136 static void r_verifyProxyEnable(LONG l
, DWORD exp
)
1139 DWORD type
, val
, size
= sizeof(DWORD
);
1141 static const CHAR szInternetSettings
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1142 static const CHAR szProxyEnable
[] = "ProxyEnable";
1144 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, szInternetSettings
, &hkey
);
1145 ok_(__FILE__
,l
) (!ret
, "RegOpenKeyA failed: 0x%08x\n", ret
);
1147 ret
= RegQueryValueExA(hkey
, szProxyEnable
, 0, &type
, (BYTE
*)&val
, &size
);
1148 ok_(__FILE__
,l
) (!ret
, "RegQueryValueExA failed: 0x%08x\n", ret
);
1149 ok_(__FILE__
,l
) (type
== REG_DWORD
, "Expected regtype to be REG_DWORD, was: %d\n", type
);
1150 ok_(__FILE__
,l
) (val
== exp
, "Expected ProxyEnabled to be %d, got: %d\n", exp
, val
);
1152 ret
= RegCloseKey(hkey
);
1153 ok_(__FILE__
,l
) (!ret
, "RegCloseKey failed: 0x%08x\n", ret
);
1156 static void test_Option_PerConnectionOption(void)
1159 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
1160 INTERNET_PER_CONN_OPTION_LISTW list
= {size
};
1161 INTERNET_PER_CONN_OPTIONW
*orig_settings
;
1162 static WCHAR proxy_srvW
[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1164 /* get the global IE proxy server info, to restore later */
1165 list
.dwOptionCount
= 2;
1166 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1168 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1169 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1171 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1173 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1174 orig_settings
= list
.pOptions
;
1176 /* set the global IE proxy server */
1177 list
.dwOptionCount
= 2;
1178 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1180 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1181 list
.pOptions
[0].Value
.pszValue
= proxy_srvW
;
1182 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1183 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1185 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1187 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1189 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1191 /* get & verify the global IE proxy server */
1192 list
.dwOptionCount
= 2;
1193 list
.dwOptionError
= 0;
1194 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1196 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1197 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1199 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1201 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1202 ok(!lstrcmpW(list
.pOptions
[0].Value
.pszValue
, proxy_srvW
),
1203 "Retrieved proxy server should've been %s, was: %s\n",
1204 wine_dbgstr_w(proxy_srvW
), wine_dbgstr_w(list
.pOptions
[0].Value
.pszValue
));
1205 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1206 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1207 list
.pOptions
[1].Value
.dwValue
);
1208 verifyProxyEnable(1);
1210 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1211 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1213 /* disable the proxy server */
1214 list
.dwOptionCount
= 1;
1215 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1217 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1218 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_DIRECT
;
1220 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1222 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1224 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1226 /* verify that the proxy is disabled */
1227 list
.dwOptionCount
= 1;
1228 list
.dwOptionError
= 0;
1229 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1231 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1233 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1235 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1236 ok(list
.pOptions
[0].Value
.dwValue
== PROXY_TYPE_DIRECT
,
1237 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1238 list
.pOptions
[0].Value
.dwValue
);
1239 verifyProxyEnable(0);
1241 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1243 /* set the proxy flags to 'invalid' value */
1244 list
.dwOptionCount
= 1;
1245 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1247 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1248 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
;
1250 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1252 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1254 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1256 /* verify that the proxy is enabled */
1257 list
.dwOptionCount
= 1;
1258 list
.dwOptionError
= 0;
1259 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1261 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1263 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1265 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1266 todo_wine
ok(list
.pOptions
[0].Value
.dwValue
== (PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
),
1267 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1268 list
.pOptions
[0].Value
.dwValue
);
1269 verifyProxyEnable(1);
1271 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1273 /* restore original settings */
1274 list
.dwOptionCount
= 2;
1275 list
.pOptions
= orig_settings
;
1277 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1279 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1281 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1284 static void test_Option_PerConnectionOptionA(void)
1287 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTA
);
1288 INTERNET_PER_CONN_OPTION_LISTA list
= {size
};
1289 INTERNET_PER_CONN_OPTIONA
*orig_settings
;
1290 char proxy_srv
[] = "proxy.example";
1292 /* get the global IE proxy server info, to restore later */
1293 list
.dwOptionCount
= 2;
1294 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1296 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1297 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1299 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1301 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1302 orig_settings
= list
.pOptions
;
1304 /* set the global IE proxy server */
1305 list
.dwOptionCount
= 2;
1306 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1308 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1309 list
.pOptions
[0].Value
.pszValue
= proxy_srv
;
1310 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1311 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1313 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1315 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1317 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1319 /* get & verify the global IE proxy server */
1320 list
.dwOptionCount
= 2;
1321 list
.dwOptionError
= 0;
1322 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1324 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1325 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1327 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1329 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1330 ok(!lstrcmpA(list
.pOptions
[0].Value
.pszValue
, "proxy.example"),
1331 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1332 proxy_srv
, list
.pOptions
[0].Value
.pszValue
);
1333 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1334 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1335 list
.pOptions
[1].Value
.dwValue
);
1337 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1338 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1340 /* restore original settings */
1341 list
.dwOptionCount
= 2;
1342 list
.pOptions
= orig_settings
;
1344 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1346 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1348 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1351 #define FLAG_TODO 0x1
1352 #define FLAG_NEEDREQ 0x2
1353 #define FLAG_UNIMPL 0x4
1355 static void test_InternetErrorDlg(void)
1357 HINTERNET ses
, con
, req
;
1361 static const struct {
1366 { ERROR_INTERNET_INCORRECT_PASSWORD
, ERROR_SUCCESS
, FLAG_NEEDREQ
},
1367 { ERROR_INTERNET_SEC_CERT_DATE_INVALID
, ERROR_CANCELLED
, 0 },
1368 { ERROR_INTERNET_SEC_CERT_CN_INVALID
, ERROR_CANCELLED
, 0 },
1369 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
, ERROR_SUCCESS
, 0 },
1370 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
, ERROR_SUCCESS
, FLAG_TODO
},
1371 { ERROR_INTERNET_MIXED_SECURITY
, ERROR_CANCELLED
, FLAG_TODO
},
1372 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE
, ERROR_CANCELLED
, FLAG_TODO
},
1373 { ERROR_INTERNET_POST_IS_NON_SECURE
, ERROR_SUCCESS
, 0 },
1374 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
, ERROR_CANCELLED
, FLAG_NEEDREQ
|FLAG_TODO
},
1375 { ERROR_INTERNET_INVALID_CA
, ERROR_CANCELLED
, 0 },
1376 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
, ERROR_CANCELLED
, FLAG_TODO
},
1377 { ERROR_INTERNET_INSERT_CDROM
, ERROR_CANCELLED
, FLAG_TODO
|FLAG_NEEDREQ
|FLAG_UNIMPL
},
1378 { ERROR_INTERNET_SEC_CERT_ERRORS
, ERROR_CANCELLED
, 0 },
1379 { ERROR_INTERNET_SEC_CERT_REV_FAILED
, ERROR_CANCELLED
, 0 },
1380 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
, ERROR_HTTP_COOKIE_DECLINED
, FLAG_TODO
},
1381 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1382 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1383 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
, ERROR_CANCELLED
, FLAG_TODO
},
1384 { ERROR_INTERNET_SEC_CERT_REVOKED
, ERROR_CANCELLED
, 0 },
1385 { 0, ERROR_NOT_SUPPORTED
}
1390 res
= InternetErrorDlg(NULL
, NULL
, 12055, flags
, NULL
);
1391 ok(res
== ERROR_INVALID_HANDLE
, "Got %d\n", res
);
1393 ses
= InternetOpen(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1394 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1395 con
= InternetConnect(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1396 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1397 req
= HttpOpenRequest(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1398 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1400 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1401 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1403 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1404 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1407 hwnd
= GetDesktopWindow();
1408 ok(hwnd
!= NULL
, "GetDesktopWindow failed (%d)\n", GetLastError());
1410 flags
= FLAGS_ERROR_UI_FLAGS_NO_UI
;
1411 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1413 DWORD expected
, test_flags
, j
;
1415 for(j
= 0; no_ui_res
[j
].error
!= 0; ++j
)
1416 if(no_ui_res
[j
].error
== i
)
1419 test_flags
= no_ui_res
[j
].test_flags
;
1420 expected
= no_ui_res
[j
].res
;
1422 /* Try an invalid request handle */
1423 res
= InternetErrorDlg(hwnd
, (HANDLE
)0xdeadbeef, i
, flags
, NULL
);
1424 if(res
== ERROR_CALL_NOT_IMPLEMENTED
)
1426 ok(test_flags
& FLAG_UNIMPL
, "%i is unexpectedly unimplemented.\n", i
);
1430 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1432 /* With a valid req */
1433 if(i
== ERROR_INTERNET_NEED_UI
)
1434 continue; /* Crashes on windows XP */
1436 if(i
== ERROR_INTERNET_SEC_CERT_REVOKED
)
1437 continue; /* Interactive (XP, Win7) */
1439 res
= InternetErrorDlg(hwnd
, req
, i
, flags
, NULL
);
1441 /* Handle some special cases */
1444 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
:
1445 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
:
1446 if(res
== ERROR_CANCELLED
)
1448 /* Some windows XP, w2k3 x64, W2K8 */
1449 win_skip("Skipping some tests for %d\n", i
);
1453 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
:
1456 /* Windows XP, W2K3 */
1457 ok(res
== NTE_PROV_TYPE_NOT_DEF
, "Got %d\n", res
);
1458 win_skip("Skipping some tests for %d\n", i
);
1465 if(test_flags
& FLAG_TODO
)
1466 todo_wine
ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1468 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1470 /* Same thing with NULL hwnd */
1471 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1472 if(test_flags
& FLAG_TODO
)
1473 todo_wine
ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1475 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1478 /* With a null req */
1479 if(test_flags
& FLAG_NEEDREQ
)
1480 expected
= ERROR_INVALID_PARAMETER
;
1482 res
= InternetErrorDlg(hwnd
, NULL
, i
, flags
, NULL
);
1483 if( test_flags
& FLAG_TODO
|| i
== ERROR_INTERNET_INCORRECT_PASSWORD
)
1484 todo_wine
ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1486 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1489 res
= InternetCloseHandle(req
);
1490 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1491 res
= InternetCloseHandle(con
);
1492 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1493 res
= InternetCloseHandle(ses
);
1494 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1497 /* ############################### */
1499 START_TEST(internet
)
1502 hdll
= GetModuleHandleA("wininet.dll");
1504 pCreateUrlCacheContainerA
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerA");
1505 pCreateUrlCacheContainerW
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerW");
1506 pInternetTimeFromSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeA");
1507 pInternetTimeFromSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeW");
1508 pInternetTimeToSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeA");
1509 pInternetTimeToSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeW");
1510 pIsDomainLegalCookieDomainW
= (void*)GetProcAddress(hdll
, (LPCSTR
)117);
1511 pPrivacyGetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacyGetZonePreferenceW");
1512 pPrivacySetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacySetZonePreferenceW");
1513 pInternetGetCookieExA
= (void*)GetProcAddress(hdll
, "InternetGetCookieExA");
1514 pInternetGetCookieExW
= (void*)GetProcAddress(hdll
, "InternetGetCookieExW");
1516 if(!pInternetGetCookieExW
) {
1517 win_skip("Too old IE (older than 6.0)\n");
1521 test_InternetCanonicalizeUrlA();
1522 test_InternetQueryOptionA();
1524 test_complicated_cookie();
1528 test_Option_PerConnectionOption();
1529 test_Option_PerConnectionOptionA();
1530 test_InternetErrorDlg();
1533 if (!pInternetTimeFromSystemTimeA
)
1534 win_skip("skipping the InternetTime tests\n");
1537 InternetTimeFromSystemTimeA_test();
1538 InternetTimeFromSystemTimeW_test();
1539 InternetTimeToSystemTimeA_test();
1540 InternetTimeToSystemTimeW_test();
1542 if (pIsDomainLegalCookieDomainW
&&
1543 ((void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerA
||
1544 (void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerW
))
1545 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1546 else if (!pIsDomainLegalCookieDomainW
)
1547 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1549 test_IsDomainLegalCookieDomainW();
1551 if (pPrivacyGetZonePreferenceW
&& pPrivacySetZonePreferenceW
)
1552 test_PrivacyGetSetZonePreferenceW();
1554 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1556 test_InternetSetOption();