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
= sizeof(bufw
)/sizeof(*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
= sizeof(bufw
)/sizeof(*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
, sizeof(string
)/sizeof(string
[0]) );
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
= sizeof(pref
)/sizeof(WCHAR
);
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(ses
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1172 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1174 ret
= InternetSetOptionA(ses
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1175 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1177 SetLastError(0xdeadbeef);
1178 ret
= InternetSetOptionA(req
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1179 todo_wine
ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1180 todo_wine
ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1182 ret
= InternetCloseHandle(req
);
1183 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1184 ret
= InternetCloseHandle(con
);
1185 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1186 ret
= InternetCloseHandle(ses
);
1187 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1190 static void test_end_browser_session(void)
1195 ret
= InternetSetCookieA("http://www.example.com/test_end", NULL
, "A=B");
1196 ok(ret
== TRUE
, "InternetSetCookie failed\n");
1199 ret
= InternetGetCookieA("http://www.example.com/test_end", NULL
, NULL
, &len
);
1200 ok(ret
== TRUE
,"InternetGetCookie failed\n");
1201 ok(len
!= 0, "len = 0\n");
1203 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_END_BROWSER_SESSION
, NULL
, 0);
1204 ok(ret
, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
1207 ret
= InternetGetCookieA("http://www.example.com/test_end", NULL
, NULL
, &len
);
1208 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookie returned %x (%u)\n", ret
, GetLastError());
1209 ok(!len
, "len = %u\n", len
);
1212 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1213 static void r_verifyProxyEnable(LONG l
, DWORD exp
)
1216 DWORD type
, val
, size
= sizeof(DWORD
);
1218 static const CHAR szInternetSettings
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1219 static const CHAR szProxyEnable
[] = "ProxyEnable";
1221 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, szInternetSettings
, &hkey
);
1222 ok_(__FILE__
,l
) (!ret
, "RegOpenKeyA failed: 0x%08x\n", ret
);
1224 ret
= RegQueryValueExA(hkey
, szProxyEnable
, 0, &type
, (BYTE
*)&val
, &size
);
1225 ok_(__FILE__
,l
) (!ret
, "RegQueryValueExA failed: 0x%08x\n", ret
);
1226 ok_(__FILE__
,l
) (type
== REG_DWORD
, "Expected regtype to be REG_DWORD, was: %d\n", type
);
1227 ok_(__FILE__
,l
) (val
== exp
, "Expected ProxyEnabled to be %d, got: %d\n", exp
, val
);
1229 ret
= RegCloseKey(hkey
);
1230 ok_(__FILE__
,l
) (!ret
, "RegCloseKey failed: 0x%08x\n", ret
);
1233 static void test_Option_PerConnectionOption(void)
1236 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
1237 INTERNET_PER_CONN_OPTION_LISTW list
= {size
};
1238 INTERNET_PER_CONN_OPTIONW
*orig_settings
;
1239 static WCHAR proxy_srvW
[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1241 /* get the global IE proxy server info, to restore later */
1242 list
.dwOptionCount
= 2;
1243 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1245 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1246 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1248 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1250 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1251 orig_settings
= list
.pOptions
;
1253 /* set the global IE proxy server */
1254 list
.dwOptionCount
= 2;
1255 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1257 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1258 list
.pOptions
[0].Value
.pszValue
= proxy_srvW
;
1259 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1260 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1262 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1264 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1266 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1268 /* get & verify the global IE proxy server */
1269 list
.dwOptionCount
= 2;
1270 list
.dwOptionError
= 0;
1271 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1273 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1274 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1276 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1278 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1279 ok(!lstrcmpW(list
.pOptions
[0].Value
.pszValue
, proxy_srvW
),
1280 "Retrieved proxy server should've been %s, was: %s\n",
1281 wine_dbgstr_w(proxy_srvW
), wine_dbgstr_w(list
.pOptions
[0].Value
.pszValue
));
1282 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1283 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1284 list
.pOptions
[1].Value
.dwValue
);
1285 verifyProxyEnable(1);
1287 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1288 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1290 /* disable the proxy server */
1291 list
.dwOptionCount
= 1;
1292 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1294 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1295 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_DIRECT
;
1297 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1299 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1301 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1303 /* verify that the proxy is disabled */
1304 list
.dwOptionCount
= 1;
1305 list
.dwOptionError
= 0;
1306 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1308 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1310 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1312 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1313 ok(list
.pOptions
[0].Value
.dwValue
== PROXY_TYPE_DIRECT
,
1314 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1315 list
.pOptions
[0].Value
.dwValue
);
1316 verifyProxyEnable(0);
1318 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1320 /* set the proxy flags to 'invalid' value */
1321 list
.dwOptionCount
= 1;
1322 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1324 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1325 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
;
1327 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1329 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1331 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1333 /* verify that the proxy is enabled */
1334 list
.dwOptionCount
= 1;
1335 list
.dwOptionError
= 0;
1336 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1338 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1340 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1342 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1343 todo_wine
ok(list
.pOptions
[0].Value
.dwValue
== (PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
),
1344 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1345 list
.pOptions
[0].Value
.dwValue
);
1346 verifyProxyEnable(1);
1348 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1350 /* restore original settings */
1351 list
.dwOptionCount
= 2;
1352 list
.pOptions
= orig_settings
;
1354 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1356 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1358 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1361 static void test_Option_PerConnectionOptionA(void)
1364 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTA
);
1365 INTERNET_PER_CONN_OPTION_LISTA list
= {size
};
1366 INTERNET_PER_CONN_OPTIONA
*orig_settings
;
1367 char proxy_srv
[] = "proxy.example";
1369 /* get the global IE proxy server info, to restore later */
1370 list
.dwOptionCount
= 2;
1371 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1373 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1374 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1376 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1378 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1379 orig_settings
= list
.pOptions
;
1381 /* set the global IE proxy server */
1382 list
.dwOptionCount
= 2;
1383 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1385 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1386 list
.pOptions
[0].Value
.pszValue
= proxy_srv
;
1387 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1388 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1390 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1392 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1394 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1396 /* get & verify the global IE proxy server */
1397 list
.dwOptionCount
= 2;
1398 list
.dwOptionError
= 0;
1399 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1401 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1402 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1404 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1406 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1407 ok(!lstrcmpA(list
.pOptions
[0].Value
.pszValue
, "proxy.example"),
1408 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1409 proxy_srv
, list
.pOptions
[0].Value
.pszValue
);
1410 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1411 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1412 list
.pOptions
[1].Value
.dwValue
);
1414 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1415 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1417 /* test with NULL as proxy server */
1418 list
.dwOptionCount
= 1;
1419 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA
));
1420 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1421 list
.pOptions
[0].Value
.pszValue
= NULL
;
1423 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, size
);
1424 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1426 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, size
);
1427 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1429 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1431 /* get & verify the proxy server */
1432 list
.dwOptionCount
= 1;
1433 list
.dwOptionError
= 0;
1434 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA
));
1435 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1437 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, &size
);
1438 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1439 ok(!list
.pOptions
[0].Value
.pszValue
,
1440 "Retrieved proxy server should've been NULL, was: \"%s\"\n",
1441 list
.pOptions
[0].Value
.pszValue
);
1443 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1444 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1446 /* restore original settings */
1447 list
.dwOptionCount
= 2;
1448 list
.pOptions
= orig_settings
;
1450 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1452 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1454 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1457 #define FLAG_TODO 0x1
1458 #define FLAG_NEEDREQ 0x2
1459 #define FLAG_UNIMPL 0x4
1461 static void test_InternetErrorDlg(void)
1463 HINTERNET ses
, con
, req
;
1467 static const struct {
1472 { ERROR_INTERNET_INCORRECT_PASSWORD
, ERROR_SUCCESS
, FLAG_NEEDREQ
},
1473 { ERROR_INTERNET_SEC_CERT_DATE_INVALID
, ERROR_CANCELLED
, 0 },
1474 { ERROR_INTERNET_SEC_CERT_CN_INVALID
, ERROR_CANCELLED
, 0 },
1475 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
, ERROR_SUCCESS
, 0 },
1476 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
, ERROR_SUCCESS
, FLAG_TODO
},
1477 { ERROR_INTERNET_MIXED_SECURITY
, ERROR_CANCELLED
, FLAG_TODO
},
1478 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE
, ERROR_CANCELLED
, FLAG_TODO
},
1479 { ERROR_INTERNET_POST_IS_NON_SECURE
, ERROR_SUCCESS
, 0 },
1480 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
, ERROR_CANCELLED
, FLAG_NEEDREQ
|FLAG_TODO
},
1481 { ERROR_INTERNET_INVALID_CA
, ERROR_CANCELLED
, 0 },
1482 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
, ERROR_CANCELLED
, FLAG_TODO
},
1483 { ERROR_INTERNET_INSERT_CDROM
, ERROR_CANCELLED
, FLAG_TODO
|FLAG_NEEDREQ
|FLAG_UNIMPL
},
1484 { ERROR_INTERNET_SEC_CERT_ERRORS
, ERROR_CANCELLED
, 0 },
1485 { ERROR_INTERNET_SEC_CERT_REV_FAILED
, ERROR_CANCELLED
, 0 },
1486 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
, ERROR_HTTP_COOKIE_DECLINED
, FLAG_TODO
},
1487 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1488 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1489 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
, ERROR_CANCELLED
, FLAG_TODO
},
1490 { ERROR_INTERNET_SEC_CERT_REVOKED
, ERROR_CANCELLED
, 0 },
1491 { 0, ERROR_NOT_SUPPORTED
}
1496 res
= InternetErrorDlg(NULL
, NULL
, 12055, flags
, NULL
);
1497 ok(res
== ERROR_INVALID_HANDLE
, "Got %d\n", res
);
1499 ses
= InternetOpenA(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1500 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1501 con
= InternetConnectA(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1502 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1503 req
= HttpOpenRequestA(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1504 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1506 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1507 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1509 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1510 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1513 hwnd
= GetDesktopWindow();
1514 ok(hwnd
!= NULL
, "GetDesktopWindow failed (%d)\n", GetLastError());
1516 flags
= FLAGS_ERROR_UI_FLAGS_NO_UI
;
1517 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1519 DWORD expected
, test_flags
, j
;
1521 for(j
= 0; no_ui_res
[j
].error
!= 0; ++j
)
1522 if(no_ui_res
[j
].error
== i
)
1525 test_flags
= no_ui_res
[j
].test_flags
;
1526 expected
= no_ui_res
[j
].res
;
1528 /* Try an invalid request handle */
1529 res
= InternetErrorDlg(hwnd
, (HANDLE
)0xdeadbeef, i
, flags
, NULL
);
1530 if(res
== ERROR_CALL_NOT_IMPLEMENTED
)
1532 ok(test_flags
& FLAG_UNIMPL
, "%i is unexpectedly unimplemented.\n", i
);
1536 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1538 /* With a valid req */
1539 if(i
== ERROR_INTERNET_NEED_UI
)
1540 continue; /* Crashes on windows XP */
1542 if(i
== ERROR_INTERNET_SEC_CERT_REVOKED
)
1543 continue; /* Interactive (XP, Win7) */
1545 res
= InternetErrorDlg(hwnd
, req
, i
, flags
, NULL
);
1547 /* Handle some special cases */
1550 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
:
1551 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
:
1552 if(res
== ERROR_CANCELLED
)
1554 /* Some windows XP, w2k3 x64, W2K8 */
1555 win_skip("Skipping some tests for %d\n", i
);
1559 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
:
1562 /* Windows XP, W2K3 */
1563 ok(res
== NTE_PROV_TYPE_NOT_DEF
, "Got %d\n", res
);
1564 win_skip("Skipping some tests for %d\n", i
);
1568 case ERROR_INTERNET_CHG_POST_IS_NON_SECURE
:
1569 if(res
== ERROR_SUCCESS
) /* win10 returns ERROR_SUCCESS */
1570 expected
= ERROR_SUCCESS
;
1575 todo_wine_if(test_flags
& FLAG_TODO
)
1576 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1578 /* Same thing with NULL hwnd */
1579 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1580 todo_wine_if(test_flags
& FLAG_TODO
)
1581 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1584 /* With a null req */
1585 if(test_flags
& FLAG_NEEDREQ
)
1586 expected
= ERROR_INVALID_PARAMETER
;
1588 res
= InternetErrorDlg(hwnd
, NULL
, i
, flags
, NULL
);
1589 todo_wine_if( test_flags
& FLAG_TODO
|| i
== ERROR_INTERNET_INCORRECT_PASSWORD
)
1590 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1593 res
= InternetCloseHandle(req
);
1594 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1595 res
= InternetCloseHandle(con
);
1596 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1597 res
= InternetCloseHandle(ses
);
1598 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1601 static void test_InternetGetConnectedStateExA(void)
1607 if(!pInternetGetConnectedStateExA
) {
1608 win_skip("InternetGetConnectedStateExA is not supported\n");
1614 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sizeof(buffer
), 0);
1615 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags
, buffer
);
1617 ok (flags
& INTERNET_RAS_INSTALLED
, "Missing RAS flag\n");
1619 win_skip("InternetGetConnectedStateExA tests require a valid connection\n");
1623 res
= pInternetGetConnectedStateExA(NULL
, NULL
, 0, 0);
1624 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1627 res
= pInternetGetConnectedStateExA(&flags
, NULL
, 0, 0);
1628 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1629 if (flags
& INTERNET_CONNECTION_CONFIGURED
)
1631 ok(flags
& INTERNET_CONNECTION_MODEM
, "Modem connection flag missing\n");
1632 ok(flags
& ~INTERNET_CONNECTION_LAN
, "Mixed Modem and LAN flags\n");
1636 ok(flags
& INTERNET_CONNECTION_LAN
, "LAN connection flag missing\n");
1637 ok(flags
& ~INTERNET_CONNECTION_MODEM
, "Mixed Modem and LAN flags\n");
1642 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 0, 0);
1643 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1644 ok(flags
, "Expected at least one flag set\n");
1645 ok(!buffer
[0], "Buffer must not change, got %02X\n", buffer
[0]);
1648 res
= pInternetGetConnectedStateExA(NULL
, buffer
, sizeof(buffer
), 0);
1649 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1650 sz
= strlen(buffer
);
1651 ok(sz
> 0, "Expected a connection name\n");
1655 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sizeof(buffer
), 0);
1656 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1657 ok(flags
, "Expected at least one flag set\n");
1658 sz
= strlen(buffer
);
1659 ok(sz
> 0, "Expected a connection name\n");
1662 res
= pInternetGetConnectedStateExA(&flags
, NULL
, sizeof(buffer
), 0);
1663 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1664 ok(flags
, "Expected at least one flag set\n");
1666 /* no space for complete string this time */
1669 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sz
, 0);
1670 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1671 ok(flags
, "Expected at least one flag set\n");
1672 ok(sz
- 1 == strlen(buffer
), "Expected %u bytes, got %u\n", sz
- 1, lstrlenA(buffer
));
1676 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sz
/ 2, 0);
1677 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1678 ok(flags
, "Expected at least one flag set\n");
1679 ok(sz
/ 2 - 1 == strlen(buffer
), "Expected %u bytes, got %u\n", sz
/ 2 - 1, lstrlenA(buffer
));
1683 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 1, 0);
1684 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1685 ok(flags
, "Expected at least one flag set\n");
1686 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer
));
1690 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 2, 0);
1691 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1692 ok(flags
, "Expected at least one flag set\n");
1693 ok(strlen(buffer
) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer
));
1697 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 1, 0);
1698 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1699 ok(flags
, "Expected at least one flag set\n");
1700 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer
));
1703 static void test_InternetGetConnectedStateExW(void)
1709 if(!pInternetGetConnectedStateExW
) {
1710 win_skip("InternetGetConnectedStateExW is not supported\n");
1716 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sizeof(buffer
) / sizeof(buffer
[0]), 0);
1717 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags
, wine_dbgstr_w(buffer
));
1719 ok (flags
& INTERNET_RAS_INSTALLED
, "Missing RAS flag\n");
1721 win_skip("InternetGetConnectedStateExW tests require a valid connection\n");
1725 res
= pInternetGetConnectedStateExW(NULL
, NULL
, 0, 0);
1726 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1729 res
= pInternetGetConnectedStateExW(&flags
, NULL
, 0, 0);
1730 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1731 if (flags
& INTERNET_CONNECTION_CONFIGURED
)
1733 ok(flags
& INTERNET_CONNECTION_MODEM
, "Modem connection flag missing\n");
1734 ok(flags
& ~INTERNET_CONNECTION_LAN
, "Mixed Modem and LAN flags\n");
1738 ok(flags
& INTERNET_CONNECTION_LAN
, "LAN connection flag missing\n");
1739 ok(flags
& ~INTERNET_CONNECTION_MODEM
, "Mixed Modem and LAN flags\n");
1744 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 0, 0);
1745 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1746 ok(flags
, "Expected at least one flag set\n");
1747 ok(!buffer
[0], "Buffer must not change, got %02X\n", buffer
[0]);
1750 res
= pInternetGetConnectedStateExW(NULL
, buffer
, sizeof(buffer
) / sizeof(buffer
[0]), 0);
1751 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1752 sz
= lstrlenW(buffer
);
1753 ok(sz
> 0, "Expected a connection name\n");
1757 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sizeof(buffer
) / sizeof(buffer
[0]), 0);
1758 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1759 ok(flags
, "Expected at least one flag set\n");
1760 sz
= lstrlenW(buffer
);
1761 ok(sz
> 0, "Expected a connection name\n");
1764 res
= pInternetGetConnectedStateExW(&flags
, NULL
, sizeof(buffer
) / sizeof(buffer
[0]), 0);
1765 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1766 ok(flags
, "Expected at least one flag set\n");
1768 /* no space for complete string this time */
1771 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sz
, 0);
1772 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1773 ok(flags
, "Expected at least one flag set\n");
1774 if (flags
& INTERNET_CONNECTION_MODEM
)
1775 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1777 ok(sz
- 1 == lstrlenW(buffer
), "Expected %u bytes, got %u\n", sz
- 1, lstrlenW(buffer
));
1781 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sz
/ 2, 0);
1782 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1783 ok(flags
, "Expected at least one flag set\n");
1784 if (flags
& INTERNET_CONNECTION_MODEM
)
1785 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1787 ok(sz
/ 2 - 1 == lstrlenW(buffer
), "Expected %u bytes, got %u\n", sz
/ 2 - 1, lstrlenW(buffer
));
1791 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 1, 0);
1792 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1793 ok(flags
, "Expected at least one flag set\n");
1794 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1798 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 2, 0);
1799 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1800 ok(flags
, "Expected at least one flag set\n");
1801 if (flags
& INTERNET_CONNECTION_MODEM
)
1802 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1804 ok(lstrlenW(buffer
) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer
));
1808 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 1, 0);
1809 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1810 ok(flags
, "Expected at least one flag set\n");
1811 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1814 /* ############################### */
1816 START_TEST(internet
)
1819 hdll
= GetModuleHandleA("wininet.dll");
1821 pCreateUrlCacheContainerA
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerA");
1822 pCreateUrlCacheContainerW
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerW");
1823 pInternetTimeFromSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeA");
1824 pInternetTimeFromSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeW");
1825 pInternetTimeToSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeA");
1826 pInternetTimeToSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeW");
1827 pIsDomainLegalCookieDomainW
= (void*)GetProcAddress(hdll
, (LPCSTR
)117);
1828 pPrivacyGetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacyGetZonePreferenceW");
1829 pPrivacySetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacySetZonePreferenceW");
1830 pInternetGetCookieExA
= (void*)GetProcAddress(hdll
, "InternetGetCookieExA");
1831 pInternetGetCookieExW
= (void*)GetProcAddress(hdll
, "InternetGetCookieExW");
1832 pInternetGetConnectedStateExA
= (void*)GetProcAddress(hdll
, "InternetGetConnectedStateExA");
1833 pInternetGetConnectedStateExW
= (void*)GetProcAddress(hdll
, "InternetGetConnectedStateExW");
1835 if(!pInternetGetCookieExW
) {
1836 win_skip("Too old IE (older than 6.0)\n");
1840 test_InternetCanonicalizeUrlA();
1841 test_InternetQueryOptionA();
1842 test_InternetGetConnectedStateExA();
1843 test_InternetGetConnectedStateExW();
1845 test_complicated_cookie();
1847 test_cookie_attrs();
1850 test_Option_PerConnectionOption();
1851 test_Option_PerConnectionOptionA();
1852 test_InternetErrorDlg();
1855 if (!pInternetTimeFromSystemTimeA
)
1856 win_skip("skipping the InternetTime tests\n");
1859 InternetTimeFromSystemTimeA_test();
1860 InternetTimeFromSystemTimeW_test();
1861 InternetTimeToSystemTimeA_test();
1862 InternetTimeToSystemTimeW_test();
1864 if (pIsDomainLegalCookieDomainW
&&
1865 ((void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerA
||
1866 (void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerW
))
1867 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1868 else if (!pIsDomainLegalCookieDomainW
)
1869 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1871 test_IsDomainLegalCookieDomainW();
1873 if (pPrivacyGetZonePreferenceW
&& pPrivacySetZonePreferenceW
)
1874 test_PrivacyGetSetZonePreferenceW();
1876 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1878 test_InternetSetOption();
1879 test_end_browser_session();