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
);
46 static BOOL (WINAPI
*pInternetGetConnectedStateExA
)(LPDWORD
,LPSTR
,DWORD
,DWORD
);
47 static BOOL (WINAPI
*pInternetGetConnectedStateExW
)(LPDWORD
,LPWSTR
,DWORD
,DWORD
);
49 /* ############################### */
51 static void test_InternetCanonicalizeUrlA(void)
59 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
60 url
= "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
61 urllen
= lstrlenA(url
);
63 memset(buffer
, '#', sizeof(buffer
)-1);
64 buffer
[sizeof(buffer
)-1] = '\0';
65 dwSize
= 1; /* Acrobat Updater use this size */
66 SetLastError(0xdeadbeef);
67 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
68 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
69 "got %u and %u with size %u for '%s' (%d)\n",
70 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
73 /* buffer has no space for the terminating '\0' */
74 memset(buffer
, '#', sizeof(buffer
)-1);
75 buffer
[sizeof(buffer
)-1] = '\0';
77 SetLastError(0xdeadbeef);
78 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
79 /* dwSize is nr. of needed bytes with the terminating '\0' */
80 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
81 "got %u and %u with size %u for '%s' (%d)\n",
82 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
84 /* buffer has the required size */
85 memset(buffer
, '#', sizeof(buffer
)-1);
86 buffer
[sizeof(buffer
)-1] = '\0';
88 SetLastError(0xdeadbeef);
89 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
90 /* dwSize is nr. of copied bytes without the terminating '\0' */
91 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
92 "got %u and %u with size %u for '%s' (%d)\n",
93 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
95 memset(buffer
, '#', sizeof(buffer
)-1);
96 buffer
[sizeof(buffer
)-1] = '\0';
97 dwSize
= sizeof(buffer
);
98 SetLastError(0xdeadbeef);
99 res
= InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer
, &dwSize
, ICU_DECODE
| ICU_NO_ENCODE
);
100 ok(res
, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
101 ok(dwSize
== lstrlenA(buffer
), "got %d expected %d\n", dwSize
, lstrlenA(buffer
));
102 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer
),
103 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer
);
105 /* buffer is larger as the required size */
106 memset(buffer
, '#', sizeof(buffer
)-1);
107 buffer
[sizeof(buffer
)-1] = '\0';
109 SetLastError(0xdeadbeef);
110 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
111 /* dwSize is nr. of copied bytes without the terminating '\0' */
112 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
113 "got %u and %u with size %u for '%s' (%d)\n",
114 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
117 /* check NULL pointers */
118 memset(buffer
, '#', urllen
+ 4);
119 buffer
[urllen
+ 4] = '\0';
121 SetLastError(0xdeadbeef);
122 res
= InternetCanonicalizeUrlA(NULL
, buffer
, &dwSize
, 0);
123 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
124 "got %u and %u with size %u for '%s' (%d)\n",
125 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
127 memset(buffer
, '#', urllen
+ 4);
128 buffer
[urllen
+ 4] = '\0';
130 SetLastError(0xdeadbeef);
131 res
= InternetCanonicalizeUrlA(url
, NULL
, &dwSize
, 0);
132 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
133 "got %u and %u with size %u for '%s' (%d)\n",
134 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
136 memset(buffer
, '#', urllen
+ 4);
137 buffer
[urllen
+ 4] = '\0';
139 SetLastError(0xdeadbeef);
140 res
= InternetCanonicalizeUrlA(url
, buffer
, NULL
, 0);
141 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
142 "got %u and %u with size %u for '%s' (%d)\n",
143 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
145 /* test with trailing space */
147 res
= InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer
, &dwSize
, ICU_BROWSER_MODE
);
148 ok(res
== 1, "InternetCanonicalizeUrlA failed\n");
149 ok(!strcmp(buffer
, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer
);
151 res
= InternetSetOptionA(NULL
, 0xdeadbeef, buffer
, sizeof(buffer
));
152 ok(!res
, "InternetSetOptionA succeeded\n");
153 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION
,
154 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
157 /* ############################### */
159 static void test_InternetQueryOptionA(void)
161 HINTERNET hinet
,hurl
;
164 static const char useragent
[] = {"Wininet Test"};
169 SetLastError(0xdeadbeef);
171 retval
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PROXY
, NULL
, &len
);
172 ok(!retval
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "Got wrong error %x(%u)\n", retval
, GetLastError());
173 ok(len
>= sizeof(INTERNET_PROXY_INFOA
) && len
!= 0xdeadbeef,"len = %u\n", len
);
175 hinet
= InternetOpenA(useragent
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
176 ok((hinet
!= 0x0),"InternetOpen Failed\n");
178 SetLastError(0xdeadbeef);
179 retval
=InternetQueryOptionA(NULL
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
181 ok(retval
== 0,"Got wrong return value %d\n",retval
);
182 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code%d\n",err
);
184 SetLastError(0xdeadbeef);
185 len
=strlen(useragent
)+1;
186 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
188 ok(len
== strlen(useragent
)+1,"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
189 ok(retval
== 0,"Got wrong return value %d\n",retval
);
190 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n",err
);
192 len
=strlen(useragent
)+1;
193 buffer
=HeapAlloc(GetProcessHeap(),0,len
);
194 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
195 ok(retval
== 1,"Got wrong return value %d\n",retval
);
198 ok(!strcmp(useragent
,buffer
),"Got wrong user agent string %s instead of %s\n",buffer
,useragent
);
199 ok(len
== strlen(useragent
),"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
201 HeapFree(GetProcessHeap(),0,buffer
);
203 SetLastError(0xdeadbeef);
205 buffer
=HeapAlloc(GetProcessHeap(),0,100);
206 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
208 ok(len
== strlen(useragent
) + 1,"Got wrong user agent length %d instead of %d\n", len
, lstrlenA(useragent
) + 1);
209 ok(!retval
, "Got wrong return value %d\n", retval
);
210 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n", err
);
211 HeapFree(GetProcessHeap(),0,buffer
);
213 hurl
= InternetConnectA(hinet
,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT
,NULL
,NULL
,INTERNET_SERVICE_HTTP
,0,0);
215 SetLastError(0xdeadbeef);
217 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
219 ok(len
== 0,"Got wrong user agent length %d instead of 0\n",len
);
220 ok(retval
== 0,"Got wrong return value %d\n",retval
);
221 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
223 SetLastError(0xdeadbeef);
225 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_REQUEST_FLAGS
,NULL
,&len
);
226 err
= GetLastError();
227 ok(retval
== 0,"Got wrong return value %d\n",retval
);
228 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
229 ok(len
== sizeof(DWORD
), "len = %d\n", len
);
231 SetLastError(0xdeadbeef);
233 retval
= InternetQueryOptionA(NULL
,INTERNET_OPTION_REQUEST_FLAGS
,NULL
,&len
);
234 err
= GetLastError();
235 ok(retval
== 0,"Got wrong return value %d\n",retval
);
236 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
237 ok(!len
, "len = %d\n", len
);
239 InternetCloseHandle(hurl
);
240 InternetCloseHandle(hinet
);
242 hinet
= InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
243 ok((hinet
!= 0x0),"InternetOpen Failed\n");
245 SetLastError(0xdeadbeef);
247 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
249 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
250 ok(retval
== 0,"Got wrong return value %d\n",retval
);
251 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
253 InternetCloseHandle(hinet
);
256 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
257 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
260 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
261 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
262 ok(val
== 12345, "val = %d\n", val
);
263 ok(len
== sizeof(val
), "len = %d\n", len
);
265 hinet
= InternetOpenA(NULL
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
266 ok((hinet
!= 0x0),"InternetOpen Failed\n");
267 SetLastError(0xdeadbeef);
269 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
271 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
272 ok(retval
== 0,"Got wrong return value %d\n",retval
);
273 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
277 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
278 ok(!res
, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
279 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
282 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
283 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
284 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
287 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
288 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
289 ok(val
== 12345, "val = %d\n", val
);
290 ok(len
== sizeof(val
), "len = %d\n", len
);
293 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
294 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
297 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
298 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
299 ok(val
== 1, "val = %d\n", val
);
300 ok(len
== sizeof(val
), "len = %d\n", len
);
303 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
304 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
305 ok(val
== 12345, "val = %d\n", val
);
306 ok(len
== sizeof(val
), "len = %d\n", len
);
308 InternetCloseHandle(hinet
);
311 static void test_max_conns(void)
318 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
319 ok(res
,"Got wrong return value %x\n", res
);
320 ok(len
== sizeof(val
), "got %d\n", len
);
321 trace("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", val
);
325 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
, &val
, &len
);
326 ok(res
,"Got wrong return value %x\n", res
);
327 ok(len
== sizeof(val
), "got %d\n", len
);
328 trace("INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", val
);
331 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
332 ok(res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res
);
336 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
337 ok(res
,"Got wrong return value %x\n", res
);
338 ok(len
== sizeof(val
), "got %d\n", len
);
339 ok(val
== 3, "got %d\n", val
);
342 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
343 ok(!res
|| broken(res
), /* <= w2k3 */
344 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
345 if (!res
) ok(GetLastError() == ERROR_BAD_ARGUMENTS
, "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 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)+1);
354 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
355 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
358 static void test_get_cookie(void)
364 SetLastError(0xdeadbeef);
365 ret
= InternetGetCookieA("http://www.example.com", NULL
, NULL
, &len
);
366 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
,
367 "InternetGetCookie should have failed with %s and error %d\n",
368 ret
? "TRUE" : "FALSE", GetLastError());
369 ok(!len
, "len = %u\n", len
);
373 static void test_complicated_cookie(void)
382 static const WCHAR testing_example_comW
[] =
383 {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.','e','x','a','m','p','l','e','.','c','o','m',0};
385 ret
= InternetSetCookieA("http://www.example.com/bar",NULL
,"A=B; domain=.example.com");
386 ok(ret
== TRUE
,"InternetSetCookie failed\n");
387 ret
= InternetSetCookieA("http://www.example.com/bar",NULL
,"C=D; domain=.example.com; path=/");
388 ok(ret
== TRUE
,"InternetSetCookie failed\n");
390 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
391 ret
= InternetSetCookieA("http://www.example.com",NULL
,"E=F; domain=example.com");
392 ok(ret
== TRUE
,"InternetSetCookie failed\n");
393 ret
= InternetSetCookieA("http://www.example.com",NULL
,"G=H; domain=.example.com; invalid=attr; path=/foo");
394 ok(ret
== TRUE
,"InternetSetCookie failed\n");
395 ret
= InternetSetCookieA("http://www.example.com/bar.html",NULL
,"I=J; domain=.example.com");
396 ok(ret
== TRUE
,"InternetSetCookie failed\n");
397 ret
= InternetSetCookieA("http://www.example.com/bar/",NULL
,"K=L; domain=.example.com");
398 ok(ret
== TRUE
,"InternetSetCookie failed\n");
399 ret
= InternetSetCookieA("http://www.example.com/bar/",NULL
,"M=N; domain=.example.com; path=/foo/");
400 ok(ret
== TRUE
,"InternetSetCookie failed\n");
401 ret
= InternetSetCookieA("http://www.example.com/bar/",NULL
,"O=P; secure; path=/bar");
402 ok(ret
== TRUE
,"InternetSetCookie failed\n");
405 ret
= InternetGetCookieA("http://testing.example.com", NULL
, NULL
, &len
);
406 ok(ret
== TRUE
,"InternetGetCookie failed\n");
407 ok(len
== 19, "len = %u\n", len
);
410 memset(buffer
, 0xac, sizeof(buffer
));
411 ret
= InternetGetCookieA("http://testing.example.com", NULL
, buffer
, &len
);
412 ok(ret
== TRUE
,"InternetGetCookie failed\n");
413 ok(len
== 19, "len = %u\n", len
);
414 ok(strlen(buffer
) == 18, "strlen(buffer) = %u\n", lstrlenA(buffer
));
415 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
416 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
417 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
418 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
419 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
420 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
421 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
422 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
425 memset(buffer
, 0xac, sizeof(buffer
));
426 ret
= InternetGetCookieA("http://testing.example.com", NULL
, buffer
, &len
);
427 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
428 "InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret
, GetLastError());
429 ok(len
== 19, "len = %u\n", len
);
432 ret
= InternetGetCookieW(testing_example_comW
, NULL
, NULL
, &len
);
433 ok(ret
== TRUE
,"InternetGetCookieW failed\n");
434 ok(len
== 38, "len = %u\n", len
);
437 memset(wbuf
, 0xac, sizeof(wbuf
));
438 ret
= InternetGetCookieW(testing_example_comW
, NULL
, wbuf
, &len
);
439 ok(ret
== TRUE
,"InternetGetCookieW failed\n");
440 ok(len
== 19 || broken(len
==18), "len = %u\n", len
);
441 ok(lstrlenW(wbuf
) == 18, "strlenW(wbuf) = %u\n", lstrlenW(wbuf
));
444 memset(wbuf
, 0xac, sizeof(wbuf
));
445 ret
= InternetGetCookieW(testing_example_comW
, NULL
, wbuf
, &len
);
446 ok(!ret
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
,
447 "InternetGetCookieW returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret
, GetLastError());
448 ok(len
== 38, "len = %u\n", len
);
451 ret
= InternetGetCookieA("http://testing.example.com/foobar", NULL
, buffer
, &len
);
452 ok(ret
== TRUE
,"InternetGetCookie failed\n");
453 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
454 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
455 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
456 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
457 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
458 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
459 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
460 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
463 ret
= InternetGetCookieA("http://testing.example.com/foobar/", NULL
, buffer
, &len
);
464 ok(ret
== TRUE
,"InternetGetCookie failed\n");
465 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
466 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
467 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
468 ok(strstr(buffer
,"G=H")!=NULL
,"G=H missing\n");
469 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
470 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
471 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
472 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
475 ret
= InternetGetCookieA("http://testing.example.com/foo/bar", NULL
, buffer
, &len
);
476 ok(ret
== TRUE
,"InternetGetCookie failed\n");
477 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
478 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
479 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
480 ok(strstr(buffer
,"G=H")!=NULL
,"G=H missing\n");
481 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
482 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
483 ok(strstr(buffer
,"M=N")!=NULL
,"M=N missing\n");
484 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
487 ret
= InternetGetCookieA("http://testing.example.com/barfoo", NULL
, buffer
, &len
);
488 ok(ret
== TRUE
,"InternetGetCookie failed\n");
489 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
490 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
491 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
492 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
493 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
494 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
495 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
496 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
499 ret
= InternetGetCookieA("http://testing.example.com/barfoo/", NULL
, buffer
, &len
);
500 ok(ret
== TRUE
,"InternetGetCookie failed\n");
501 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
502 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
503 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
504 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
505 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
506 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
507 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
508 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
511 ret
= InternetGetCookieA("http://testing.example.com/bar/foo", NULL
, buffer
, &len
);
512 ok(ret
== TRUE
,"InternetGetCookie failed\n");
513 ok(len
== 24, "len = %u\n", 24);
514 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
515 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
516 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
517 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
518 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
519 ok(strstr(buffer
,"K=L")!=NULL
,"K=L missing\n");
520 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
521 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
523 /* Cookie name argument is not implemented */
525 ret
= InternetGetCookieA("http://testing.example.com/bar/foo", "A", buffer
, &len
);
526 ok(ret
== TRUE
,"InternetGetCookie failed\n");
527 ok(len
== 24, "len = %u\n", 24);
529 /* test persistent cookies */
530 ret
= InternetSetCookieA("http://testing.example.com", NULL
, "A=B; expires=Fri, 01-Jan-2038 00:00:00 GMT");
531 ok(ret
, "InternetSetCookie failed with error %d\n", GetLastError());
534 ret
= GetUserNameA(user
, &len
);
535 ok(ret
, "GetUserName failed with error %d\n", GetLastError());
537 user
[len
-1] = tolower(user
[len
-1]);
539 sprintf(buffer
, "Cookie:%s@testing.example.com/", user
);
540 ret
= GetUrlCacheEntryInfoA(buffer
, NULL
, &len
);
541 ok(!ret
, "GetUrlCacheEntryInfo succeeded\n");
542 ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "GetLastError() = %d\n", GetLastError());
544 /* remove persistent cookie */
545 ret
= InternetSetCookieA("http://testing.example.com", NULL
, "A=B");
546 ok(ret
, "InternetSetCookie failed with error %d\n", GetLastError());
548 ret
= GetUrlCacheEntryInfoA(buffer
, NULL
, &len
);
549 ok(!ret
, "GetUrlCacheEntryInfo succeeded\n");
550 ok(GetLastError() == ERROR_FILE_NOT_FOUND
, "GetLastError() = %d\n", GetLastError());
552 /* try setting cookie for different domain */
553 ret
= InternetSetCookieA("http://www.aaa.example.com/bar",NULL
,"E=F; domain=different.com");
554 ok(!ret
, "InternetSetCookie succeeded\n");
555 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %d\n", GetLastError());
556 ret
= InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL
,"E=F; domain=example.com.pl");
557 ok(ret
, "InternetSetCookie failed with error: %d\n", GetLastError());
558 ret
= InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL
,"E=F; domain=com.pl");
559 todo_wine
ok(!ret
, "InternetSetCookie succeeded\n");
562 static void test_cookie_attrs(void)
568 if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "DeleteWpadCacheForNetworks")) {
569 win_skip("Skipping cookie attributes tests. Too old IE.\n");
573 ret
= InternetSetCookieA("http://cookie.attrs.com/bar", NULL
, "A=data; httponly");
574 ok(!ret
&& GetLastError() == ERROR_INVALID_OPERATION
, "InternetSetCookie returned: %x (%u)\n", ret
, GetLastError());
576 SetLastError(0xdeadbeef);
577 state
= InternetSetCookieExA("http://cookie.attrs.com/bar", NULL
, "A=data; httponly", 0, 0);
578 ok(state
== COOKIE_STATE_REJECT
&& GetLastError() == ERROR_INVALID_OPERATION
,
579 "InternetSetCookieEx returned: %x (%u)\n", ret
, GetLastError());
582 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, INTERNET_COOKIE_HTTPONLY
, NULL
);
583 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookieEx returned: %x (%u)\n", ret
, GetLastError());
585 state
= InternetSetCookieExA("http://cookie.attrs.com/bar",NULL
,"A=data; httponly", INTERNET_COOKIE_HTTPONLY
, 0);
586 ok(state
== COOKIE_STATE_ACCEPT
,"InternetSetCookieEx failed: %u\n", GetLastError());
589 ret
= InternetGetCookieA("http://cookie.attrs.com/", NULL
, buf
, &size
);
590 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookie returned: %x (%u)\n", ret
, GetLastError());
593 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, 0, NULL
);
594 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookieEx returned: %x (%u)\n", ret
, GetLastError());
597 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, INTERNET_COOKIE_HTTPONLY
, NULL
);
598 ok(ret
, "InternetGetCookieEx failed: %u\n", GetLastError());
599 ok(!strcmp(buf
, "A=data"), "data = %s\n", buf
);
601 /* Try to override httponly cookie with non-httponly one */
602 ret
= InternetSetCookieA("http://cookie.attrs.com/bar", NULL
, "A=test");
603 ok(!ret
&& GetLastError() == ERROR_INVALID_OPERATION
, "InternetSetCookie returned: %x (%u)\n", ret
, GetLastError());
605 SetLastError(0xdeadbeef);
606 state
= InternetSetCookieExA("http://cookie.attrs.com/bar", NULL
, "A=data", 0, 0);
607 ok(state
== COOKIE_STATE_REJECT
&& GetLastError() == ERROR_INVALID_OPERATION
,
608 "InternetSetCookieEx returned: %x (%u)\n", ret
, GetLastError());
611 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, INTERNET_COOKIE_HTTPONLY
, NULL
);
612 ok(ret
, "InternetGetCookieEx failed: %u\n", GetLastError());
613 ok(!strcmp(buf
, "A=data"), "data = %s\n", buf
);
617 static void test_cookie_url(void)
619 char long_url
[5000] = "http://long.url.test.com/", *p
;
625 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
628 res
= InternetGetCookieA("about:blank", NULL
, buf
, &len
);
629 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
630 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
632 len
= ARRAY_SIZE(bufw
);
633 res
= InternetGetCookieW(about_blankW
, NULL
, bufw
, &len
);
634 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
635 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
638 res
= pInternetGetCookieExA("about:blank", NULL
, buf
, &len
, 0, NULL
);
639 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
640 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
642 len
= ARRAY_SIZE(bufw
);
643 res
= pInternetGetCookieExW(about_blankW
, NULL
, bufw
, &len
, 0, NULL
);
644 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
645 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
647 p
= long_url
+ strlen(long_url
);
648 memset(p
, 'x', long_url
+sizeof(long_url
)-p
);
649 p
+= (long_url
+sizeof(long_url
)-p
) - 3;
652 res
= InternetSetCookieA(long_url
, NULL
, "A=B");
653 ok(res
, "InternetSetCookieA failed: %u\n", GetLastError());
656 res
= InternetGetCookieA(long_url
, NULL
, buf
, &len
);
657 ok(res
, "InternetGetCookieA failed: %u\n", GetLastError());
658 ok(!strcmp(buf
, "A=B"), "buf = %s\n", buf
);
661 res
= InternetGetCookieA("http://long.url.test.com/", NULL
, buf
, &len
);
662 ok(!res
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookieA failed: %u\n", GetLastError());
665 static void test_null(void)
668 static const WCHAR szServer
[] = { 's','e','r','v','e','r',0 };
669 static const WCHAR szServer2
[] = { 's','e','r','v','e','r','=',0 };
670 static const WCHAR szEmpty
[] = { 0 };
671 static const WCHAR szUrl
[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
672 static const WCHAR szUrlEmpty
[] = { 'h','t','t','p',':','/','/',0 };
673 static const WCHAR szExpect
[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
678 SetLastError(0xdeadbeef);
679 hi
= InternetOpenW(NULL
, 0, NULL
, NULL
, 0);
680 if (hi
== NULL
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
682 win_skip("Internet*W functions are not implemented\n");
685 ok(hi
!= NULL
, "open failed\n");
687 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, 0, 0, 0);
688 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
689 ok(hc
== NULL
, "connect failed\n");
691 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
692 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
693 ok(hc
== NULL
, "connect failed\n");
695 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
696 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
697 ok(hc
== NULL
, "connect failed\n");
699 hc
= InternetConnectW(NULL
, szServer
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
700 ok(GetLastError() == ERROR_INVALID_HANDLE
, "wrong error\n");
701 ok(hc
== NULL
, "connect failed\n");
703 hc
= InternetOpenUrlW(hi
, NULL
, NULL
, 0, 0, 0);
704 ok(GetLastError() == ERROR_INVALID_PARAMETER
||
705 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
706 ok(hc
== NULL
, "connect failed\n");
708 hc
= InternetOpenUrlW(hi
, szServer
, NULL
, 0, 0, 0);
709 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
710 ok(hc
== NULL
, "connect failed\n");
712 InternetCloseHandle(hi
);
714 r
= InternetSetCookieW(NULL
, NULL
, NULL
);
715 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
716 ok(r
== FALSE
, "return wrong\n");
718 r
= InternetSetCookieW(szServer
, NULL
, NULL
);
719 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
720 ok(r
== FALSE
, "return wrong\n");
722 r
= InternetSetCookieW(szUrl
, szServer
, NULL
);
723 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
724 ok(r
== FALSE
, "return wrong\n");
726 r
= InternetSetCookieW(szUrl
, szServer
, szServer
);
727 ok(r
== TRUE
, "return wrong\n");
729 r
= InternetSetCookieW(szUrl
, NULL
, szServer
);
730 ok(r
== TRUE
, "return wrong\n");
732 r
= InternetSetCookieW(szUrl
, szServer
, szEmpty
);
733 ok(r
== TRUE
, "return wrong\n");
735 r
= InternetSetCookieW(szUrlEmpty
, szServer
, szServer
);
736 ok(r
== FALSE
, "return wrong\n");
738 r
= InternetSetCookieW(szServer
, NULL
, szServer
);
739 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
740 ok(r
== FALSE
, "return wrong\n");
743 r
= InternetGetCookieW(NULL
, NULL
, NULL
, &sz
);
744 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
745 "wrong error %u\n", GetLastError());
746 ok( r
== FALSE
, "return wrong\n");
748 r
= InternetGetCookieW(szServer
, NULL
, NULL
, &sz
);
750 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
752 ok( r
== FALSE
, "return wrong\n");
755 r
= InternetGetCookieW(szUrlEmpty
, szServer
, NULL
, &sz
);
756 ok( r
== FALSE
, "return wrong\n");
759 r
= InternetGetCookieW(szUrl
, szServer
, NULL
, &sz
);
760 ok( r
== TRUE
, "return wrong\n");
762 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */
763 ok( sz
== 14 || sz
== 16 || sz
== 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz
);
766 memset(buffer
, 0, sizeof buffer
);
767 r
= InternetGetCookieW(szUrl
, szServer
, buffer
, &sz
);
768 ok( r
== TRUE
, "return wrong\n");
770 /* sz == lstrlenW(buffer) only in XP SP1 */
771 ok( sz
== 1 + lstrlenW(buffer
) || sz
== lstrlenW(buffer
), "sz wrong %d\n", sz
);
773 /* before XP SP2, buffer is "server; server" */
774 ok( !lstrcmpW(szExpect
, buffer
) || !lstrcmpW(szServer
, buffer
) || !lstrcmpW(szServer2
, buffer
),
775 "cookie data wrong %s\n", wine_dbgstr_w(buffer
));
778 r
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECTED_STATE
, buffer
, &sz
);
779 ok(r
== TRUE
, "ret %d\n", r
);
782 static void test_version(void)
784 INTERNET_VERSION_INFO version
;
788 size
= sizeof(version
);
789 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_VERSION
, &version
, &size
);
790 ok(res
, "Could not get version: %u\n", GetLastError());
791 ok(version
.dwMajorVersion
== 1, "dwMajorVersion=%d, expected 1\n", version
.dwMajorVersion
);
792 ok(version
.dwMinorVersion
== 2, "dwMinorVersion=%d, expected 2\n", version
.dwMinorVersion
);
795 static void InternetTimeFromSystemTimeA_test(void)
798 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
799 char string
[INTERNET_RFC1123_BUFSIZE
];
800 static const char expect
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
803 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
804 ok( ret
, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
806 ok( !memcmp( string
, expect
, sizeof(expect
) ),
807 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
809 /* test NULL time parameter */
810 SetLastError(0xdeadbeef);
811 ret
= pInternetTimeFromSystemTimeA( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
812 error
= GetLastError();
813 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
814 ok( error
== ERROR_INVALID_PARAMETER
,
815 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
818 /* test NULL string parameter */
819 SetLastError(0xdeadbeef);
820 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
821 error
= GetLastError();
822 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
823 ok( error
== ERROR_INVALID_PARAMETER
,
824 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
827 /* test invalid format parameter */
828 SetLastError(0xdeadbeef);
829 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
830 error
= GetLastError();
831 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
832 ok( error
== ERROR_INVALID_PARAMETER
,
833 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
836 /* test too small buffer size */
837 SetLastError(0xdeadbeef);
838 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, 0 );
839 error
= GetLastError();
840 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
841 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
842 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
846 static void InternetTimeFromSystemTimeW_test(void)
849 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
850 WCHAR string
[INTERNET_RFC1123_BUFSIZE
+ 1];
851 static const WCHAR expect
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
852 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
855 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
856 ok( ret
, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
858 ok( !memcmp( string
, expect
, sizeof(expect
) ),
859 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
861 /* test NULL time parameter */
862 SetLastError(0xdeadbeef);
863 ret
= pInternetTimeFromSystemTimeW( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
864 error
= GetLastError();
865 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
866 ok( error
== ERROR_INVALID_PARAMETER
,
867 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
870 /* test NULL string parameter */
871 SetLastError(0xdeadbeef);
872 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
873 error
= GetLastError();
874 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
875 ok( error
== ERROR_INVALID_PARAMETER
,
876 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
879 /* test invalid format parameter */
880 SetLastError(0xdeadbeef);
881 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
882 error
= GetLastError();
883 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
884 ok( error
== ERROR_INVALID_PARAMETER
,
885 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
888 /* test too small buffer size */
889 SetLastError(0xdeadbeef);
890 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, ARRAY_SIZE(string
));
891 error
= GetLastError();
892 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
893 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
894 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
898 static void InternetTimeToSystemTimeA_test(void)
902 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
903 static const char string
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
904 static const char string2
[] = " fri 7 jan 2005 12 06 35";
906 ret
= pInternetTimeToSystemTimeA( string
, &time
, 0 );
907 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
908 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
909 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
911 ret
= pInternetTimeToSystemTimeA( string2
, &time
, 0 );
912 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
913 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
914 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
917 static void InternetTimeToSystemTimeW_test(void)
921 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
922 static const WCHAR string
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
923 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
924 static const WCHAR string2
[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
925 '1','2',' ','0','6',' ','3','5',0 };
926 static const WCHAR string3
[] = { 'F','r',0 };
928 ret
= pInternetTimeToSystemTimeW( NULL
, NULL
, 0 );
929 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
931 ret
= pInternetTimeToSystemTimeW( NULL
, &time
, 0 );
932 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
934 ret
= pInternetTimeToSystemTimeW( string
, NULL
, 0 );
935 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
937 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
938 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
940 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
941 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
942 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
943 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
945 ret
= pInternetTimeToSystemTimeW( string2
, &time
, 0 );
946 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
947 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
948 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
950 ret
= pInternetTimeToSystemTimeW( string3
, &time
, 0 );
951 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
954 static void test_IsDomainLegalCookieDomainW(void)
957 static const WCHAR empty
[] = {0};
958 static const WCHAR dot
[] = {'.',0};
959 static const WCHAR uk
[] = {'u','k',0};
960 static const WCHAR com
[] = {'c','o','m',0};
961 static const WCHAR dot_com
[] = {'.','c','o','m',0};
962 static const WCHAR gmail_com
[] = {'g','m','a','i','l','.','c','o','m',0};
963 static const WCHAR dot_gmail_com
[] = {'.','g','m','a','i','l','.','c','o','m',0};
964 static const WCHAR www_gmail_com
[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
965 static const WCHAR www_mail_gmail_com
[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
966 static const WCHAR mail_gmail_com
[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
967 static const WCHAR gmail_co_uk
[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
968 static const WCHAR co_uk
[] = {'c','o','.','u','k',0};
969 static const WCHAR dot_co_uk
[] = {'.','c','o','.','u','k',0};
971 SetLastError(0xdeadbeef);
972 ret
= pIsDomainLegalCookieDomainW(NULL
, NULL
);
973 if (!ret
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
))
975 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
979 broken(ret
), /* IE6 */
980 "IsDomainLegalCookieDomainW succeeded\n");
982 SetLastError(0xdeadbeef);
983 ret
= pIsDomainLegalCookieDomainW(com
, NULL
);
984 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
986 SetLastError(0xdeadbeef);
987 ret
= pIsDomainLegalCookieDomainW(NULL
, gmail_com
);
988 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
990 SetLastError(0xdeadbeef);
991 ret
= pIsDomainLegalCookieDomainW(empty
, gmail_com
);
992 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
994 SetLastError(0xdeadbeef);
995 ret
= pIsDomainLegalCookieDomainW(com
, empty
);
996 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
998 SetLastError(0xdeadbeef);
999 ret
= pIsDomainLegalCookieDomainW(gmail_com
, dot
);
1000 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1002 SetLastError(0xdeadbeef);
1003 ret
= pIsDomainLegalCookieDomainW(dot
, gmail_com
);
1004 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1006 SetLastError(0xdeadbeef);
1007 ret
= pIsDomainLegalCookieDomainW(com
, com
);
1008 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1010 SetLastError(0xdeadbeef);
1011 ret
= pIsDomainLegalCookieDomainW(com
, dot_com
);
1012 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1014 SetLastError(0xdeadbeef);
1015 ret
= pIsDomainLegalCookieDomainW(dot_com
, com
);
1016 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1018 SetLastError(0xdeadbeef);
1019 ret
= pIsDomainLegalCookieDomainW(com
, gmail_com
);
1020 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1022 ret
= pIsDomainLegalCookieDomainW(gmail_com
, gmail_com
);
1023 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1025 ret
= pIsDomainLegalCookieDomainW(gmail_com
, www_gmail_com
);
1026 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1028 ret
= pIsDomainLegalCookieDomainW(gmail_com
, www_mail_gmail_com
);
1029 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1031 SetLastError(0xdeadbeef);
1032 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, co_uk
);
1033 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1035 ret
= pIsDomainLegalCookieDomainW(uk
, co_uk
);
1036 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1038 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, dot_co_uk
);
1039 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1041 ret
= pIsDomainLegalCookieDomainW(co_uk
, gmail_co_uk
);
1042 todo_wine
ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1044 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, gmail_co_uk
);
1045 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1047 ret
= pIsDomainLegalCookieDomainW(gmail_com
, com
);
1048 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1050 SetLastError(0xdeadbeef);
1051 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
1052 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1054 ret
= pIsDomainLegalCookieDomainW(gmail_com
, mail_gmail_com
);
1055 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1057 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, gmail_com
);
1058 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1060 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, com
);
1061 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1063 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
1064 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1066 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, dot_gmail_com
);
1067 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1070 static void test_PrivacyGetSetZonePreferenceW(void)
1072 DWORD ret
, zone
, type
, template, old_template
, pref_size
= 0;
1077 ret
= pPrivacyGetZonePreferenceW(zone
, type
, NULL
, NULL
, NULL
);
1078 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1081 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &old_template
, NULL
, NULL
);
1082 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1084 trace("template %u\n", old_template
);
1086 if(old_template
== PRIVACY_TEMPLATE_ADVANCED
) {
1087 pref_size
= ARRAY_SIZE(pref
);
1088 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &old_template
, pref
, &pref_size
);
1089 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1093 ret
= pPrivacySetZonePreferenceW(zone
, type
, template, NULL
);
1094 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1097 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &template, NULL
, NULL
);
1098 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1099 ok(template == 5, "expected template == 5, got %u\n", template);
1102 ret
= pPrivacySetZonePreferenceW(zone
, type
, old_template
, pref_size
? pref
: NULL
);
1103 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1106 static void test_InternetSetOption(void)
1108 HINTERNET ses
, con
, req
;
1113 ses
= InternetOpenA(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1114 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1115 con
= InternetConnectA(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1116 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1117 req
= HttpOpenRequestA(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1118 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1120 /* INTERNET_OPTION_POLICY tests */
1121 SetLastError(0xdeadbeef);
1122 ret
= InternetSetOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
1123 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1124 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
1125 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1127 SetLastError(0xdeadbeef);
1128 ret
= InternetQueryOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
1129 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1130 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
1131 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1133 /* INTERNET_OPTION_ERROR_MASK tests */
1134 SetLastError(0xdeadbeef);
1135 size
= sizeof(ulArg
);
1136 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, &size
);
1137 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1138 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1140 SetLastError(0xdeadbeef);
1142 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1143 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1144 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1146 SetLastError(0xdeadbeef);
1148 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, 20);
1149 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1150 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %d\n", GetLastError());
1153 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1154 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1156 SetLastError(0xdeadbeef);
1158 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1159 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1160 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
1162 SetLastError(0xdeadbeef);
1164 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1165 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1166 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
1168 ret
= InternetSetOptionA(req
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1169 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1171 ret
= InternetSetOptionA(con
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1172 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1174 ret
= InternetSetOptionA(ses
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1175 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1177 ret
= InternetSetOptionA(ses
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1178 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1180 SetLastError(0xdeadbeef);
1181 ret
= InternetSetOptionA(req
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1182 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1183 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %u\n", GetLastError());
1185 SetLastError(0xdeadbeef);
1186 ret
= InternetSetOptionA(con
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1187 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1188 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %u\n", GetLastError());
1190 ret
= InternetCloseHandle(req
);
1191 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1192 ret
= InternetCloseHandle(con
);
1193 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1194 ret
= InternetCloseHandle(ses
);
1195 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1198 static void test_end_browser_session(void)
1203 ret
= InternetSetCookieA("http://www.example.com/test_end", NULL
, "A=B");
1204 ok(ret
== TRUE
, "InternetSetCookie failed\n");
1207 ret
= InternetGetCookieA("http://www.example.com/test_end", NULL
, NULL
, &len
);
1208 ok(ret
== TRUE
,"InternetGetCookie failed\n");
1209 ok(len
!= 0, "len = 0\n");
1211 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_END_BROWSER_SESSION
, NULL
, 0);
1212 ok(ret
, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
1215 ret
= InternetGetCookieA("http://www.example.com/test_end", NULL
, NULL
, &len
);
1216 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookie returned %x (%u)\n", ret
, GetLastError());
1217 ok(!len
, "len = %u\n", len
);
1220 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1221 static void r_verifyProxyEnable(LONG l
, DWORD exp
)
1224 DWORD type
, val
, size
= sizeof(DWORD
);
1226 static const CHAR szInternetSettings
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1227 static const CHAR szProxyEnable
[] = "ProxyEnable";
1229 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, szInternetSettings
, &hkey
);
1230 ok_(__FILE__
,l
) (!ret
, "RegOpenKeyA failed: 0x%08x\n", ret
);
1232 ret
= RegQueryValueExA(hkey
, szProxyEnable
, 0, &type
, (BYTE
*)&val
, &size
);
1233 ok_(__FILE__
,l
) (!ret
, "RegQueryValueExA failed: 0x%08x\n", ret
);
1234 ok_(__FILE__
,l
) (type
== REG_DWORD
, "Expected regtype to be REG_DWORD, was: %d\n", type
);
1235 ok_(__FILE__
,l
) (val
== exp
, "Expected ProxyEnabled to be %d, got: %d\n", exp
, val
);
1237 ret
= RegCloseKey(hkey
);
1238 ok_(__FILE__
,l
) (!ret
, "RegCloseKey failed: 0x%08x\n", ret
);
1241 static void test_Option_PerConnectionOption(void)
1244 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
1245 INTERNET_PER_CONN_OPTION_LISTW list
= {size
};
1246 INTERNET_PER_CONN_OPTIONW
*orig_settings
;
1247 static WCHAR proxy_srvW
[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1249 /* get the global IE proxy server info, to restore later */
1250 list
.dwOptionCount
= 2;
1251 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1253 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1254 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1256 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1258 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1259 orig_settings
= list
.pOptions
;
1261 /* set the global IE proxy server */
1262 list
.dwOptionCount
= 2;
1263 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1265 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1266 list
.pOptions
[0].Value
.pszValue
= proxy_srvW
;
1267 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1268 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1270 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1272 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1274 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1276 /* get & verify the global IE proxy server */
1277 list
.dwOptionCount
= 2;
1278 list
.dwOptionError
= 0;
1279 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1281 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1282 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1284 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1286 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1287 ok(!lstrcmpW(list
.pOptions
[0].Value
.pszValue
, proxy_srvW
),
1288 "Retrieved proxy server should've been %s, was: %s\n",
1289 wine_dbgstr_w(proxy_srvW
), wine_dbgstr_w(list
.pOptions
[0].Value
.pszValue
));
1290 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1291 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1292 list
.pOptions
[1].Value
.dwValue
);
1293 verifyProxyEnable(1);
1295 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1296 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1298 /* disable the proxy server */
1299 list
.dwOptionCount
= 1;
1300 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1302 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1303 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_DIRECT
;
1305 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1307 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1309 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1311 /* verify that the proxy is disabled */
1312 list
.dwOptionCount
= 1;
1313 list
.dwOptionError
= 0;
1314 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1316 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1318 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1320 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1321 ok(list
.pOptions
[0].Value
.dwValue
== PROXY_TYPE_DIRECT
,
1322 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1323 list
.pOptions
[0].Value
.dwValue
);
1324 verifyProxyEnable(0);
1326 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1328 /* set the proxy flags to 'invalid' value */
1329 list
.dwOptionCount
= 1;
1330 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1332 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1333 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
;
1335 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1337 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1339 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1341 /* verify that the proxy is enabled */
1342 list
.dwOptionCount
= 1;
1343 list
.dwOptionError
= 0;
1344 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1346 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1348 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1350 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1351 todo_wine
ok(list
.pOptions
[0].Value
.dwValue
== (PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
),
1352 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1353 list
.pOptions
[0].Value
.dwValue
);
1354 verifyProxyEnable(1);
1356 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1358 /* restore original settings */
1359 list
.dwOptionCount
= 2;
1360 list
.pOptions
= orig_settings
;
1362 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1364 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1366 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1369 static void test_Option_PerConnectionOptionA(void)
1372 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTA
);
1373 INTERNET_PER_CONN_OPTION_LISTA list
= {size
};
1374 INTERNET_PER_CONN_OPTIONA
*orig_settings
;
1375 char proxy_srv
[] = "proxy.example";
1377 /* get the global IE proxy server info, to restore later */
1378 list
.dwOptionCount
= 2;
1379 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1381 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1382 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1384 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1386 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1387 orig_settings
= list
.pOptions
;
1389 /* set the global IE proxy server */
1390 list
.dwOptionCount
= 2;
1391 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1393 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1394 list
.pOptions
[0].Value
.pszValue
= proxy_srv
;
1395 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1396 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1398 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1400 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1402 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1404 /* get & verify the global IE proxy server */
1405 list
.dwOptionCount
= 2;
1406 list
.dwOptionError
= 0;
1407 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1409 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1410 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1412 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1414 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1415 ok(!lstrcmpA(list
.pOptions
[0].Value
.pszValue
, "proxy.example"),
1416 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1417 proxy_srv
, list
.pOptions
[0].Value
.pszValue
);
1418 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1419 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1420 list
.pOptions
[1].Value
.dwValue
);
1422 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1423 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1425 /* test with NULL as proxy server */
1426 list
.dwOptionCount
= 1;
1427 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA
));
1428 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1429 list
.pOptions
[0].Value
.pszValue
= NULL
;
1431 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, size
);
1432 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1434 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, size
);
1435 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1437 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1439 /* get & verify the proxy server */
1440 list
.dwOptionCount
= 1;
1441 list
.dwOptionError
= 0;
1442 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA
));
1443 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1445 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, &size
);
1446 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1447 ok(!list
.pOptions
[0].Value
.pszValue
,
1448 "Retrieved proxy server should've been NULL, was: \"%s\"\n",
1449 list
.pOptions
[0].Value
.pszValue
);
1451 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1452 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1454 /* restore original settings */
1455 list
.dwOptionCount
= 2;
1456 list
.pOptions
= orig_settings
;
1458 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1460 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1462 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1465 #define FLAG_TODO 0x1
1466 #define FLAG_NEEDREQ 0x2
1467 #define FLAG_UNIMPL 0x4
1469 static void test_InternetErrorDlg(void)
1471 HINTERNET ses
, con
, req
;
1475 static const struct {
1480 { ERROR_INTERNET_INCORRECT_PASSWORD
, ERROR_SUCCESS
, FLAG_NEEDREQ
},
1481 { ERROR_INTERNET_SEC_CERT_DATE_INVALID
, ERROR_CANCELLED
, 0 },
1482 { ERROR_INTERNET_SEC_CERT_CN_INVALID
, ERROR_CANCELLED
, 0 },
1483 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
, ERROR_SUCCESS
, 0 },
1484 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
, ERROR_SUCCESS
, FLAG_TODO
},
1485 { ERROR_INTERNET_MIXED_SECURITY
, ERROR_CANCELLED
, FLAG_TODO
},
1486 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE
, ERROR_CANCELLED
, FLAG_TODO
},
1487 { ERROR_INTERNET_POST_IS_NON_SECURE
, ERROR_SUCCESS
, 0 },
1488 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
, ERROR_CANCELLED
, FLAG_NEEDREQ
|FLAG_TODO
},
1489 { ERROR_INTERNET_INVALID_CA
, ERROR_CANCELLED
, 0 },
1490 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
, ERROR_CANCELLED
, FLAG_TODO
},
1491 { ERROR_INTERNET_INSERT_CDROM
, ERROR_CANCELLED
, FLAG_TODO
|FLAG_NEEDREQ
|FLAG_UNIMPL
},
1492 { ERROR_INTERNET_SEC_CERT_ERRORS
, ERROR_CANCELLED
, 0 },
1493 { ERROR_INTERNET_SEC_CERT_REV_FAILED
, ERROR_CANCELLED
, 0 },
1494 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
, ERROR_HTTP_COOKIE_DECLINED
, FLAG_TODO
},
1495 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1496 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1497 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
, ERROR_CANCELLED
, FLAG_TODO
},
1498 { ERROR_INTERNET_SEC_CERT_REVOKED
, ERROR_CANCELLED
, 0 },
1499 { 0, ERROR_NOT_SUPPORTED
}
1504 res
= InternetErrorDlg(NULL
, NULL
, 12055, flags
, NULL
);
1505 ok(res
== ERROR_INVALID_HANDLE
, "Got %d\n", res
);
1507 ses
= InternetOpenA(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1508 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1509 con
= InternetConnectA(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1510 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1511 req
= HttpOpenRequestA(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1512 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1514 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1515 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1517 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1518 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1521 hwnd
= GetDesktopWindow();
1522 ok(hwnd
!= NULL
, "GetDesktopWindow failed (%d)\n", GetLastError());
1524 flags
= FLAGS_ERROR_UI_FLAGS_NO_UI
;
1525 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1527 DWORD expected
, test_flags
, j
;
1529 for(j
= 0; no_ui_res
[j
].error
!= 0; ++j
)
1530 if(no_ui_res
[j
].error
== i
)
1533 test_flags
= no_ui_res
[j
].test_flags
;
1534 expected
= no_ui_res
[j
].res
;
1536 /* Try an invalid request handle */
1537 res
= InternetErrorDlg(hwnd
, (HANDLE
)0xdeadbeef, i
, flags
, NULL
);
1538 if(res
== ERROR_CALL_NOT_IMPLEMENTED
)
1540 ok(test_flags
& FLAG_UNIMPL
, "%i is unexpectedly unimplemented.\n", i
);
1544 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1546 /* With a valid req */
1547 if(i
== ERROR_INTERNET_NEED_UI
)
1548 continue; /* Crashes on windows XP */
1550 if(i
== ERROR_INTERNET_SEC_CERT_REVOKED
)
1551 continue; /* Interactive (XP, Win7) */
1553 res
= InternetErrorDlg(hwnd
, req
, i
, flags
, NULL
);
1555 /* Handle some special cases */
1558 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
: /* later 9.x versions */
1559 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
: /* later 9.x versions */
1560 case ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE
: /* later 11.x versions */
1561 if(res
== ERROR_CANCELLED
)
1562 expected
= ERROR_CANCELLED
;
1564 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
:
1567 /* Windows XP, W2K3 */
1568 ok(res
== NTE_PROV_TYPE_NOT_DEF
, "Got %d\n", res
);
1569 win_skip("Skipping some tests for %d\n", i
);
1573 case ERROR_INTERNET_CHG_POST_IS_NON_SECURE
:
1574 if(res
== ERROR_SUCCESS
) /* win10 returns ERROR_SUCCESS */
1575 expected
= ERROR_SUCCESS
;
1580 todo_wine_if(test_flags
& FLAG_TODO
)
1581 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1583 /* Same thing with NULL hwnd */
1584 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1585 todo_wine_if(test_flags
& FLAG_TODO
)
1586 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1589 /* With a null req */
1590 if(test_flags
& FLAG_NEEDREQ
)
1591 expected
= ERROR_INVALID_PARAMETER
;
1593 res
= InternetErrorDlg(hwnd
, NULL
, i
, flags
, NULL
);
1594 todo_wine_if( test_flags
& FLAG_TODO
|| i
== ERROR_INTERNET_INCORRECT_PASSWORD
)
1595 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1598 res
= InternetCloseHandle(req
);
1599 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1600 res
= InternetCloseHandle(con
);
1601 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1602 res
= InternetCloseHandle(ses
);
1603 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1606 static void test_InternetGetConnectedStateExA(void)
1612 if(!pInternetGetConnectedStateExA
) {
1613 win_skip("InternetGetConnectedStateExA is not supported\n");
1619 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sizeof(buffer
), 0);
1620 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags
, buffer
);
1622 ok (flags
& INTERNET_RAS_INSTALLED
, "Missing RAS flag\n");
1624 win_skip("InternetGetConnectedStateExA tests require a valid connection\n");
1628 res
= pInternetGetConnectedStateExA(NULL
, NULL
, 0, 0);
1629 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1632 res
= pInternetGetConnectedStateExA(&flags
, NULL
, 0, 0);
1633 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1634 if (flags
& INTERNET_CONNECTION_CONFIGURED
)
1636 ok(flags
& INTERNET_CONNECTION_MODEM
, "Modem connection flag missing\n");
1637 ok(flags
& ~INTERNET_CONNECTION_LAN
, "Mixed Modem and LAN flags\n");
1641 ok(flags
& INTERNET_CONNECTION_LAN
, "LAN connection flag missing\n");
1642 ok(flags
& ~INTERNET_CONNECTION_MODEM
, "Mixed Modem and LAN flags\n");
1647 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 0, 0);
1648 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1649 ok(flags
, "Expected at least one flag set\n");
1650 ok(!buffer
[0], "Buffer must not change, got %02X\n", buffer
[0]);
1653 res
= pInternetGetConnectedStateExA(NULL
, buffer
, sizeof(buffer
), 0);
1654 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1655 sz
= strlen(buffer
);
1656 ok(sz
> 0, "Expected a connection name\n");
1660 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sizeof(buffer
), 0);
1661 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1662 ok(flags
, "Expected at least one flag set\n");
1663 sz
= strlen(buffer
);
1664 ok(sz
> 0, "Expected a connection name\n");
1667 res
= pInternetGetConnectedStateExA(&flags
, NULL
, sizeof(buffer
), 0);
1668 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1669 ok(flags
, "Expected at least one flag set\n");
1671 /* no space for complete string this time */
1674 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sz
, 0);
1675 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1676 ok(flags
, "Expected at least one flag set\n");
1677 ok(sz
- 1 == strlen(buffer
), "Expected %u bytes, got %u\n", sz
- 1, lstrlenA(buffer
));
1681 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sz
/ 2, 0);
1682 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1683 ok(flags
, "Expected at least one flag set\n");
1684 ok(sz
/ 2 - 1 == strlen(buffer
), "Expected %u bytes, got %u\n", sz
/ 2 - 1, lstrlenA(buffer
));
1688 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 1, 0);
1689 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1690 ok(flags
, "Expected at least one flag set\n");
1691 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer
));
1695 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 2, 0);
1696 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1697 ok(flags
, "Expected at least one flag set\n");
1698 ok(strlen(buffer
) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer
));
1702 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 1, 0);
1703 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1704 ok(flags
, "Expected at least one flag set\n");
1705 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer
));
1708 static void test_InternetGetConnectedStateExW(void)
1714 if(!pInternetGetConnectedStateExW
) {
1715 win_skip("InternetGetConnectedStateExW is not supported\n");
1721 res
= pInternetGetConnectedStateExW(&flags
, buffer
, ARRAY_SIZE(buffer
), 0);
1722 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags
, wine_dbgstr_w(buffer
));
1724 ok (flags
& INTERNET_RAS_INSTALLED
, "Missing RAS flag\n");
1726 win_skip("InternetGetConnectedStateExW tests require a valid connection\n");
1730 res
= pInternetGetConnectedStateExW(NULL
, NULL
, 0, 0);
1731 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1734 res
= pInternetGetConnectedStateExW(&flags
, NULL
, 0, 0);
1735 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1736 if (flags
& INTERNET_CONNECTION_CONFIGURED
)
1738 ok(flags
& INTERNET_CONNECTION_MODEM
, "Modem connection flag missing\n");
1739 ok(flags
& ~INTERNET_CONNECTION_LAN
, "Mixed Modem and LAN flags\n");
1743 ok(flags
& INTERNET_CONNECTION_LAN
, "LAN connection flag missing\n");
1744 ok(flags
& ~INTERNET_CONNECTION_MODEM
, "Mixed Modem and LAN flags\n");
1749 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 0, 0);
1750 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1751 ok(flags
, "Expected at least one flag set\n");
1752 ok(!buffer
[0], "Buffer must not change, got %02X\n", buffer
[0]);
1755 res
= pInternetGetConnectedStateExW(NULL
, buffer
, ARRAY_SIZE(buffer
), 0);
1756 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1757 sz
= lstrlenW(buffer
);
1758 ok(sz
> 0, "Expected a connection name\n");
1762 res
= pInternetGetConnectedStateExW(&flags
, buffer
, ARRAY_SIZE(buffer
), 0);
1763 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1764 ok(flags
, "Expected at least one flag set\n");
1765 sz
= lstrlenW(buffer
);
1766 ok(sz
> 0, "Expected a connection name\n");
1769 res
= pInternetGetConnectedStateExW(&flags
, NULL
, ARRAY_SIZE(buffer
), 0);
1770 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1771 ok(flags
, "Expected at least one flag set\n");
1773 /* no space for complete string this time */
1776 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sz
, 0);
1777 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1778 ok(flags
, "Expected at least one flag set\n");
1779 if (flags
& INTERNET_CONNECTION_MODEM
)
1780 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1782 ok(sz
- 1 == lstrlenW(buffer
), "Expected %u bytes, got %u\n", sz
- 1, lstrlenW(buffer
));
1786 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sz
/ 2, 0);
1787 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1788 ok(flags
, "Expected at least one flag set\n");
1789 if (flags
& INTERNET_CONNECTION_MODEM
)
1790 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1792 ok(sz
/ 2 - 1 == lstrlenW(buffer
), "Expected %u bytes, got %u\n", sz
/ 2 - 1, lstrlenW(buffer
));
1796 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 1, 0);
1797 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1798 ok(flags
, "Expected at least one flag set\n");
1799 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1803 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 2, 0);
1804 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1805 ok(flags
, "Expected at least one flag set\n");
1806 if (flags
& INTERNET_CONNECTION_MODEM
)
1807 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1809 ok(lstrlenW(buffer
) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer
));
1813 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 1, 0);
1814 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1815 ok(flags
, "Expected at least one flag set\n");
1816 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1819 static void test_format_message(HMODULE hdll
)
1824 /* These messages come from wininet and not the system. */
1825 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, ERROR_INTERNET_TIMEOUT
,
1826 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1827 ok(ret
== 0, "FormatMessageA returned %d\n", ret
);
1829 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_TIMEOUT
,
1830 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1831 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1833 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_INTERNAL_ERROR
,
1834 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1835 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1837 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_INVALID_URL
,
1838 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1839 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1841 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
1842 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1843 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1845 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_NAME_NOT_RESOLVED
,
1846 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1847 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1849 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_INVALID_OPERATION
,
1850 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1851 ok(ret
!= 0 || broken(!ret
) /* XP, w2k3 */, "FormatMessageA returned %d\n", ret
);
1853 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_OPERATION_CANCELLED
,
1854 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1855 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1857 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_ITEM_NOT_FOUND
,
1858 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1859 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1861 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_CANNOT_CONNECT
,
1862 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1863 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1865 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_CONNECTION_ABORTED
,
1866 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1867 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1869 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_SEC_CERT_DATE_INVALID
,
1870 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1871 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1873 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_SEC_CERT_CN_INVALID
,
1874 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1875 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1878 /* ############################### */
1880 START_TEST(internet
)
1883 hdll
= GetModuleHandleA("wininet.dll");
1885 pCreateUrlCacheContainerA
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerA");
1886 pCreateUrlCacheContainerW
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerW");
1887 pInternetTimeFromSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeA");
1888 pInternetTimeFromSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeW");
1889 pInternetTimeToSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeA");
1890 pInternetTimeToSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeW");
1891 pIsDomainLegalCookieDomainW
= (void*)GetProcAddress(hdll
, (LPCSTR
)117);
1892 pPrivacyGetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacyGetZonePreferenceW");
1893 pPrivacySetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacySetZonePreferenceW");
1894 pInternetGetCookieExA
= (void*)GetProcAddress(hdll
, "InternetGetCookieExA");
1895 pInternetGetCookieExW
= (void*)GetProcAddress(hdll
, "InternetGetCookieExW");
1896 pInternetGetConnectedStateExA
= (void*)GetProcAddress(hdll
, "InternetGetConnectedStateExA");
1897 pInternetGetConnectedStateExW
= (void*)GetProcAddress(hdll
, "InternetGetConnectedStateExW");
1899 if(!pInternetGetCookieExW
) {
1900 win_skip("Too old IE (older than 6.0)\n");
1904 test_InternetCanonicalizeUrlA();
1905 test_InternetQueryOptionA();
1906 test_InternetGetConnectedStateExA();
1907 test_InternetGetConnectedStateExW();
1909 test_complicated_cookie();
1911 test_cookie_attrs();
1914 test_Option_PerConnectionOption();
1915 test_Option_PerConnectionOptionA();
1916 test_InternetErrorDlg();
1919 if (!pInternetTimeFromSystemTimeA
)
1920 win_skip("skipping the InternetTime tests\n");
1923 InternetTimeFromSystemTimeA_test();
1924 InternetTimeFromSystemTimeW_test();
1925 InternetTimeToSystemTimeA_test();
1926 InternetTimeToSystemTimeW_test();
1928 if (pIsDomainLegalCookieDomainW
&&
1929 ((void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerA
||
1930 (void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerW
))
1931 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1932 else if (!pIsDomainLegalCookieDomainW
)
1933 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1935 test_IsDomainLegalCookieDomainW();
1937 if (pPrivacyGetZonePreferenceW
&& pPrivacySetZonePreferenceW
)
1938 test_PrivacyGetSetZonePreferenceW();
1940 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1942 test_InternetSetOption();
1943 test_end_browser_session();
1944 test_format_message(hdll
);