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
32 #include "wine/test.h"
34 static BOOL (WINAPI
*pCreateUrlCacheContainerA
)(DWORD
, DWORD
, DWORD
, DWORD
,
35 DWORD
, DWORD
, DWORD
, DWORD
);
36 static BOOL (WINAPI
*pCreateUrlCacheContainerW
)(DWORD
, DWORD
, DWORD
, DWORD
,
37 DWORD
, DWORD
, DWORD
, DWORD
);
38 static BOOL (WINAPI
*pInternetTimeFromSystemTimeA
)(const SYSTEMTIME
*, DWORD
, LPSTR
, DWORD
);
39 static BOOL (WINAPI
*pInternetTimeFromSystemTimeW
)(const SYSTEMTIME
*, DWORD
, LPWSTR
, DWORD
);
40 static BOOL (WINAPI
*pInternetTimeToSystemTimeA
)(LPCSTR
,SYSTEMTIME
*,DWORD
);
41 static BOOL (WINAPI
*pInternetTimeToSystemTimeW
)(LPCWSTR
,SYSTEMTIME
*,DWORD
);
42 static BOOL (WINAPI
*pIsDomainLegalCookieDomainW
)(LPCWSTR
, LPCWSTR
);
43 static DWORD (WINAPI
*pPrivacyGetZonePreferenceW
)(DWORD
, DWORD
, LPDWORD
, LPWSTR
, LPDWORD
);
44 static DWORD (WINAPI
*pPrivacySetZonePreferenceW
)(DWORD
, DWORD
, DWORD
, LPCWSTR
);
45 static BOOL (WINAPI
*pInternetGetCookieExA
)(LPCSTR
,LPCSTR
,LPSTR
,LPDWORD
,DWORD
,LPVOID
);
46 static BOOL (WINAPI
*pInternetGetCookieExW
)(LPCWSTR
,LPCWSTR
,LPWSTR
,LPDWORD
,DWORD
,LPVOID
);
47 static BOOL (WINAPI
*pInternetGetConnectedStateExA
)(LPDWORD
,LPSTR
,DWORD
,DWORD
);
48 static BOOL (WINAPI
*pInternetGetConnectedStateExW
)(LPDWORD
,LPWSTR
,DWORD
,DWORD
);
50 /* ############################### */
52 static void test_InternetCanonicalizeUrlA(void)
60 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
61 url
= "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
62 urllen
= lstrlenA(url
);
64 memset(buffer
, '#', sizeof(buffer
)-1);
65 buffer
[sizeof(buffer
)-1] = '\0';
66 dwSize
= 1; /* Acrobat Updater use this size */
67 SetLastError(0xdeadbeef);
68 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
69 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
70 "got %u and %u with size %u for '%s' (%d)\n",
71 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
74 /* buffer has no space for the terminating '\0' */
75 memset(buffer
, '#', sizeof(buffer
)-1);
76 buffer
[sizeof(buffer
)-1] = '\0';
78 SetLastError(0xdeadbeef);
79 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
80 /* dwSize is nr. of needed bytes with the terminating '\0' */
81 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
82 "got %u and %u with size %u for '%s' (%d)\n",
83 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
85 /* buffer has the required size */
86 memset(buffer
, '#', sizeof(buffer
)-1);
87 buffer
[sizeof(buffer
)-1] = '\0';
89 SetLastError(0xdeadbeef);
90 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
91 /* dwSize is nr. of copied bytes without the terminating '\0' */
92 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
93 "got %u and %u with size %u for '%s' (%d)\n",
94 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
96 memset(buffer
, '#', sizeof(buffer
)-1);
97 buffer
[sizeof(buffer
)-1] = '\0';
98 dwSize
= sizeof(buffer
);
99 SetLastError(0xdeadbeef);
100 res
= InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer
, &dwSize
, ICU_DECODE
| ICU_NO_ENCODE
);
101 ok(res
, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
102 ok(dwSize
== lstrlenA(buffer
), "got %d expected %d\n", dwSize
, lstrlenA(buffer
));
103 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer
),
104 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer
);
106 /* buffer is larger as the required size */
107 memset(buffer
, '#', sizeof(buffer
)-1);
108 buffer
[sizeof(buffer
)-1] = '\0';
110 SetLastError(0xdeadbeef);
111 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
112 /* dwSize is nr. of copied bytes without the terminating '\0' */
113 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
114 "got %u and %u with size %u for '%s' (%d)\n",
115 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
118 /* check NULL pointers */
119 memset(buffer
, '#', urllen
+ 4);
120 buffer
[urllen
+ 4] = '\0';
122 SetLastError(0xdeadbeef);
123 res
= InternetCanonicalizeUrlA(NULL
, buffer
, &dwSize
, 0);
124 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
125 "got %u and %u with size %u for '%s' (%d)\n",
126 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
128 memset(buffer
, '#', urllen
+ 4);
129 buffer
[urllen
+ 4] = '\0';
131 SetLastError(0xdeadbeef);
132 res
= InternetCanonicalizeUrlA(url
, NULL
, &dwSize
, 0);
133 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
134 "got %u and %u with size %u for '%s' (%d)\n",
135 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
137 memset(buffer
, '#', urllen
+ 4);
138 buffer
[urllen
+ 4] = '\0';
140 SetLastError(0xdeadbeef);
141 res
= InternetCanonicalizeUrlA(url
, buffer
, NULL
, 0);
142 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
143 "got %u and %u with size %u for '%s' (%d)\n",
144 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
146 /* test with trailing space */
148 res
= InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer
, &dwSize
, ICU_BROWSER_MODE
);
149 ok(res
== 1, "InternetCanonicalizeUrlA failed\n");
150 ok(!strcmp(buffer
, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer
);
152 res
= InternetSetOptionA(NULL
, 0xdeadbeef, buffer
, sizeof(buffer
));
153 ok(!res
, "InternetSetOptionA succeeded\n");
154 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION
,
155 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
158 /* ############################### */
160 static void test_InternetQueryOptionA(void)
162 HINTERNET hinet
,hurl
;
165 static const char useragent
[] = {"Wininet Test"};
170 SetLastError(0xdeadbeef);
172 retval
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PROXY
, NULL
, &len
);
173 ok(!retval
&& GetLastError() == ERROR_INSUFFICIENT_BUFFER
, "Got wrong error %x(%u)\n", retval
, GetLastError());
174 ok(len
>= sizeof(INTERNET_PROXY_INFOA
) && len
!= 0xdeadbeef,"len = %u\n", len
);
176 hinet
= InternetOpenA(useragent
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
177 ok((hinet
!= 0x0),"InternetOpen Failed\n");
179 SetLastError(0xdeadbeef);
180 retval
=InternetQueryOptionA(NULL
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
182 ok(retval
== 0,"Got wrong return value %d\n",retval
);
183 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code%d\n",err
);
185 SetLastError(0xdeadbeef);
186 len
=strlen(useragent
)+1;
187 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
189 ok(len
== strlen(useragent
)+1,"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
190 ok(retval
== 0,"Got wrong return value %d\n",retval
);
191 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n",err
);
193 len
=strlen(useragent
)+1;
194 buffer
=HeapAlloc(GetProcessHeap(),0,len
);
195 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
196 ok(retval
== 1,"Got wrong return value %d\n",retval
);
199 ok(!strcmp(useragent
,buffer
),"Got wrong user agent string %s instead of %s\n",buffer
,useragent
);
200 ok(len
== strlen(useragent
),"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
202 HeapFree(GetProcessHeap(),0,buffer
);
204 SetLastError(0xdeadbeef);
206 buffer
=HeapAlloc(GetProcessHeap(),0,100);
207 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
209 ok(len
== strlen(useragent
) + 1,"Got wrong user agent length %d instead of %d\n", len
, lstrlenA(useragent
) + 1);
210 ok(!retval
, "Got wrong return value %d\n", retval
);
211 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n", err
);
212 HeapFree(GetProcessHeap(),0,buffer
);
214 hurl
= InternetConnectA(hinet
,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT
,NULL
,NULL
,INTERNET_SERVICE_HTTP
,0,0);
216 SetLastError(0xdeadbeef);
218 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
220 ok(len
== 0,"Got wrong user agent length %d instead of 0\n",len
);
221 ok(retval
== 0,"Got wrong return value %d\n",retval
);
222 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
224 SetLastError(0xdeadbeef);
226 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_REQUEST_FLAGS
,NULL
,&len
);
227 err
= GetLastError();
228 ok(retval
== 0,"Got wrong return value %d\n",retval
);
229 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
230 ok(len
== sizeof(DWORD
), "len = %d\n", len
);
232 SetLastError(0xdeadbeef);
234 retval
= InternetQueryOptionA(NULL
,INTERNET_OPTION_REQUEST_FLAGS
,NULL
,&len
);
235 err
= GetLastError();
236 ok(retval
== 0,"Got wrong return value %d\n",retval
);
237 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
238 ok(!len
, "len = %d\n", len
);
240 InternetCloseHandle(hurl
);
241 InternetCloseHandle(hinet
);
243 hinet
= InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
244 ok((hinet
!= 0x0),"InternetOpen Failed\n");
246 SetLastError(0xdeadbeef);
248 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
250 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
251 ok(retval
== 0,"Got wrong return value %d\n",retval
);
252 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
254 InternetCloseHandle(hinet
);
257 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
258 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
261 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
262 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
263 ok(val
== 12345, "val = %d\n", val
);
264 ok(len
== sizeof(val
), "len = %d\n", len
);
266 hinet
= InternetOpenA(NULL
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
267 ok((hinet
!= 0x0),"InternetOpen Failed\n");
268 SetLastError(0xdeadbeef);
270 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
272 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
273 ok(retval
== 0,"Got wrong return value %d\n",retval
);
274 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
278 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
279 ok(!res
, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
280 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
283 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
284 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
285 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
288 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
289 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
290 ok(val
== 12345, "val = %d\n", val
);
291 ok(len
== sizeof(val
), "len = %d\n", len
);
294 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
295 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
298 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
299 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
300 ok(val
== 1, "val = %d\n", val
);
301 ok(len
== sizeof(val
), "len = %d\n", len
);
304 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
305 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
306 ok(val
== 12345, "val = %d\n", val
);
307 ok(len
== sizeof(val
), "len = %d\n", len
);
309 InternetCloseHandle(hinet
);
312 static void test_max_conns(void)
319 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
320 ok(res
,"Got wrong return value %x\n", res
);
321 ok(len
== sizeof(val
), "got %d\n", len
);
322 trace("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", val
);
326 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
, &val
, &len
);
327 ok(res
,"Got wrong return value %x\n", res
);
328 ok(len
== sizeof(val
), "got %d\n", len
);
329 trace("INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", val
);
332 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
333 ok(res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res
);
337 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
338 ok(res
,"Got wrong return value %x\n", res
);
339 ok(len
== sizeof(val
), "got %d\n", len
);
340 ok(val
== 3, "got %d\n", val
);
343 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
344 ok(!res
|| broken(res
), /* <= w2k3 */
345 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
346 if (!res
) ok(GetLastError() == ERROR_BAD_ARGUMENTS
, "GetLastError() = %u\n", GetLastError());
349 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)-1);
350 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
351 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
354 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)+1);
355 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
356 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
359 static void test_get_cookie(void)
365 SetLastError(0xdeadbeef);
366 ret
= InternetGetCookieA("http://www.example.com", NULL
, NULL
, &len
);
367 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
,
368 "InternetGetCookie should have failed with %s and error %d\n",
369 ret
? "TRUE" : "FALSE", GetLastError());
370 ok(!len
, "len = %u\n", len
);
374 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", len
);
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", len
);
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());
533 /* test invalid expires parameter */
534 ret
= InternetSetCookieA("http://testing.example.com", NULL
, "Q=R; expires=");
535 ok(ret
, "InternetSetCookie failed %#x.\n", GetLastError());
537 memset(buffer
, 0xac, sizeof(buffer
));
538 ret
= InternetGetCookieA("http://testing.example.com/", NULL
, buffer
, &len
);
539 ok(ret
, "InternetGetCookie failed %#x.\n", GetLastError());
540 ok(len
== 29, "got len %u.\n", len
);
541 ok(!!strstr(buffer
, "Q=R"), "cookie is not present.\n");
543 len
= sizeof(buffer
);
544 ret
= InternetGetCookieA("http://testing.example.com/foobar", NULL
, buffer
, &len
);
545 ok(ret
, "got error %#x\n", GetLastError());
546 ok(len
== 29, "got len %u\n", len
);
547 ok(!!strstr(buffer
, "A=B"), "cookie is not present\n");
549 /* remove persistent cookie */
550 ret
= InternetSetCookieA("http://testing.example.com", NULL
, "A=B");
551 ok(ret
, "InternetSetCookie failed with error %d\n", GetLastError());
553 /* try setting cookie for different domain */
554 ret
= InternetSetCookieA("http://www.aaa.example.com/bar",NULL
,"E=F; domain=different.com");
555 ok(!ret
, "InternetSetCookie succeeded\n");
556 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %d\n", GetLastError());
557 ret
= InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL
,"E=F; domain=example.com.pl");
558 ok(ret
, "InternetSetCookie failed with error: %d\n", GetLastError());
559 ret
= InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL
,"E=F; domain=com.pl");
560 todo_wine
ok(!ret
, "InternetSetCookie succeeded\n");
563 static void test_cookie_attrs(void)
569 if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "DeleteWpadCacheForNetworks")) {
570 win_skip("Skipping cookie attributes tests. Too old IE.\n");
574 ret
= InternetSetCookieA("http://cookie.attrs.com/bar", NULL
, "A=data; httponly");
575 ok(!ret
&& GetLastError() == ERROR_INVALID_OPERATION
, "InternetSetCookie returned: %x (%u)\n", ret
, GetLastError());
577 SetLastError(0xdeadbeef);
578 state
= InternetSetCookieExA("http://cookie.attrs.com/bar", NULL
, "A=data; httponly", 0, 0);
579 ok(state
== COOKIE_STATE_REJECT
&& GetLastError() == ERROR_INVALID_OPERATION
,
580 "InternetSetCookieEx returned: %x (%u)\n", ret
, GetLastError());
583 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, INTERNET_COOKIE_HTTPONLY
, NULL
);
584 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookieEx returned: %x (%u)\n", ret
, GetLastError());
586 state
= InternetSetCookieExA("http://cookie.attrs.com/bar",NULL
,"A=data; httponly", INTERNET_COOKIE_HTTPONLY
, 0);
587 ok(state
== COOKIE_STATE_ACCEPT
,"InternetSetCookieEx failed: %u\n", GetLastError());
590 ret
= InternetGetCookieA("http://cookie.attrs.com/", NULL
, buf
, &size
);
591 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookie returned: %x (%u)\n", ret
, GetLastError());
594 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, 0, NULL
);
595 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookieEx returned: %x (%u)\n", ret
, GetLastError());
598 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, INTERNET_COOKIE_HTTPONLY
, NULL
);
599 ok(ret
, "InternetGetCookieEx failed: %u\n", GetLastError());
600 ok(!strcmp(buf
, "A=data"), "data = %s\n", buf
);
602 /* Try to override httponly cookie with non-httponly one */
603 ret
= InternetSetCookieA("http://cookie.attrs.com/bar", NULL
, "A=test");
604 ok(!ret
&& GetLastError() == ERROR_INVALID_OPERATION
, "InternetSetCookie returned: %x (%u)\n", ret
, GetLastError());
606 SetLastError(0xdeadbeef);
607 state
= InternetSetCookieExA("http://cookie.attrs.com/bar", NULL
, "A=data", 0, 0);
608 ok(state
== COOKIE_STATE_REJECT
&& GetLastError() == ERROR_INVALID_OPERATION
,
609 "InternetSetCookieEx returned: %x (%u)\n", ret
, GetLastError());
612 ret
= InternetGetCookieExA("http://cookie.attrs.com/", NULL
, buf
, &size
, INTERNET_COOKIE_HTTPONLY
, NULL
);
613 ok(ret
, "InternetGetCookieEx failed: %u\n", GetLastError());
614 ok(!strcmp(buf
, "A=data"), "data = %s\n", buf
);
618 static void test_cookie_url(void)
620 char long_url
[5000] = "http://long.url.test.com/", *p
;
626 static const WCHAR about_blankW
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
629 res
= InternetGetCookieA("about:blank", NULL
, buf
, &len
);
630 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
631 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
633 len
= ARRAY_SIZE(bufw
);
634 res
= InternetGetCookieW(about_blankW
, NULL
, bufw
, &len
);
635 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
636 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
639 res
= pInternetGetCookieExA("about:blank", NULL
, buf
, &len
, 0, NULL
);
640 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
641 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
643 len
= ARRAY_SIZE(bufw
);
644 res
= pInternetGetCookieExW(about_blankW
, NULL
, bufw
, &len
, 0, NULL
);
645 ok(!res
&& GetLastError() == ERROR_INVALID_PARAMETER
,
646 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
648 p
= long_url
+ strlen(long_url
);
649 memset(p
, 'x', long_url
+sizeof(long_url
)-p
);
650 p
+= (long_url
+sizeof(long_url
)-p
) - 3;
653 res
= InternetSetCookieA(long_url
, NULL
, "A=B");
654 ok(res
, "InternetSetCookieA failed: %u\n", GetLastError());
657 res
= InternetGetCookieA(long_url
, NULL
, buf
, &len
);
658 ok(res
, "InternetGetCookieA failed: %u\n", GetLastError());
659 ok(!strcmp(buf
, "A=B"), "buf = %s\n", buf
);
662 res
= InternetGetCookieA("http://long.url.test.com/", NULL
, buf
, &len
);
663 ok(!res
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookieA failed: %u\n", GetLastError());
666 static void test_null(void)
669 static const WCHAR szServer
[] = { 's','e','r','v','e','r',0 };
670 static const WCHAR szServer2
[] = { 's','e','r','v','e','r','=',0 };
671 static const WCHAR szEmpty
[] = { 0 };
672 static const WCHAR szUrl
[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
673 static const WCHAR szUrlEmpty
[] = { 'h','t','t','p',':','/','/',0 };
674 static const WCHAR szExpect
[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
679 SetLastError(0xdeadbeef);
680 hi
= InternetOpenW(NULL
, 0, NULL
, NULL
, 0);
681 if (hi
== NULL
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
683 win_skip("Internet*W functions are not implemented\n");
686 ok(hi
!= NULL
, "open failed\n");
688 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, 0, 0, 0);
689 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
690 ok(hc
== NULL
, "connect failed\n");
692 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
693 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
694 ok(hc
== NULL
, "connect failed\n");
696 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
697 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
698 ok(hc
== NULL
, "connect failed\n");
700 hc
= InternetConnectW(NULL
, szServer
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
701 ok(GetLastError() == ERROR_INVALID_HANDLE
, "wrong error\n");
702 ok(hc
== NULL
, "connect failed\n");
704 hc
= InternetOpenUrlW(hi
, NULL
, NULL
, 0, 0, 0);
705 ok(GetLastError() == ERROR_INVALID_PARAMETER
||
706 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
707 ok(hc
== NULL
, "connect failed\n");
709 hc
= InternetOpenUrlW(hi
, szServer
, NULL
, 0, 0, 0);
710 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
711 ok(hc
== NULL
, "connect failed\n");
713 InternetCloseHandle(hi
);
715 r
= InternetSetCookieW(NULL
, NULL
, NULL
);
716 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
717 ok(r
== FALSE
, "return wrong\n");
719 r
= InternetSetCookieW(szServer
, NULL
, NULL
);
720 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
721 ok(r
== FALSE
, "return wrong\n");
723 r
= InternetSetCookieW(szUrl
, szServer
, NULL
);
724 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
725 ok(r
== FALSE
, "return wrong\n");
727 r
= InternetSetCookieW(szUrl
, szServer
, szServer
);
728 ok(r
== TRUE
, "return wrong\n");
730 r
= InternetSetCookieW(szUrl
, NULL
, szServer
);
731 ok(r
== TRUE
, "return wrong\n");
733 r
= InternetSetCookieW(szUrl
, szServer
, szEmpty
);
734 ok(r
== TRUE
, "return wrong\n");
736 r
= InternetSetCookieW(szUrlEmpty
, szServer
, szServer
);
737 ok(r
== FALSE
, "return wrong\n");
739 r
= InternetSetCookieW(szServer
, NULL
, szServer
);
740 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
741 ok(r
== FALSE
, "return wrong\n");
744 r
= InternetGetCookieW(NULL
, NULL
, NULL
, &sz
);
745 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
746 "wrong error %u\n", GetLastError());
747 ok( r
== FALSE
, "return wrong\n");
749 r
= InternetGetCookieW(szServer
, NULL
, NULL
, &sz
);
751 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
753 ok( r
== FALSE
, "return wrong\n");
756 r
= InternetGetCookieW(szUrlEmpty
, szServer
, NULL
, &sz
);
757 ok( r
== FALSE
, "return wrong\n");
760 r
= InternetGetCookieW(szUrl
, szServer
, NULL
, &sz
);
761 ok( r
== TRUE
, "return wrong\n");
763 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */
764 ok( sz
== 14 || sz
== 16 || sz
== 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz
);
767 memset(buffer
, 0, sizeof buffer
);
768 r
= InternetGetCookieW(szUrl
, szServer
, buffer
, &sz
);
769 ok( r
== TRUE
, "return wrong\n");
771 /* sz == lstrlenW(buffer) only in XP SP1 */
772 ok( sz
== 1 + lstrlenW(buffer
) || sz
== lstrlenW(buffer
), "sz wrong %d\n", sz
);
774 /* before XP SP2, buffer is "server; server" */
775 ok( !lstrcmpW(szExpect
, buffer
) || !lstrcmpW(szServer
, buffer
) || !lstrcmpW(szServer2
, buffer
),
776 "cookie data wrong %s\n", wine_dbgstr_w(buffer
));
779 r
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECTED_STATE
, buffer
, &sz
);
780 ok(r
== TRUE
, "ret %d\n", r
);
783 static void test_version(void)
785 INTERNET_VERSION_INFO version
;
789 size
= sizeof(version
);
790 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_VERSION
, &version
, &size
);
791 ok(res
, "Could not get version: %u\n", GetLastError());
792 ok(version
.dwMajorVersion
== 1, "dwMajorVersion=%d, expected 1\n", version
.dwMajorVersion
);
793 ok(version
.dwMinorVersion
== 2, "dwMinorVersion=%d, expected 2\n", version
.dwMinorVersion
);
796 static void InternetTimeFromSystemTimeA_test(void)
799 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
800 char string
[INTERNET_RFC1123_BUFSIZE
];
801 static const char expect
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
804 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
805 ok( ret
, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
807 ok( !memcmp( string
, expect
, sizeof(expect
) ),
808 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
810 /* test NULL time parameter */
811 SetLastError(0xdeadbeef);
812 ret
= pInternetTimeFromSystemTimeA( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
813 error
= GetLastError();
814 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
815 ok( error
== ERROR_INVALID_PARAMETER
,
816 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
819 /* test NULL string parameter */
820 SetLastError(0xdeadbeef);
821 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
822 error
= GetLastError();
823 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
824 ok( error
== ERROR_INVALID_PARAMETER
,
825 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
828 /* test invalid format parameter */
829 SetLastError(0xdeadbeef);
830 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
831 error
= GetLastError();
832 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
833 ok( error
== ERROR_INVALID_PARAMETER
,
834 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
837 /* test too small buffer size */
838 SetLastError(0xdeadbeef);
839 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, 0 );
840 error
= GetLastError();
841 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
842 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
843 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
847 static void InternetTimeFromSystemTimeW_test(void)
850 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
851 WCHAR string
[INTERNET_RFC1123_BUFSIZE
+ 1];
852 static const WCHAR expect
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
853 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
856 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
857 ok( ret
, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
859 ok( !memcmp( string
, expect
, sizeof(expect
) ),
860 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
862 /* test NULL time parameter */
863 SetLastError(0xdeadbeef);
864 ret
= pInternetTimeFromSystemTimeW( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
865 error
= GetLastError();
866 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
867 ok( error
== ERROR_INVALID_PARAMETER
,
868 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
871 /* test NULL string parameter */
872 SetLastError(0xdeadbeef);
873 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
874 error
= GetLastError();
875 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
876 ok( error
== ERROR_INVALID_PARAMETER
,
877 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
880 /* test invalid format parameter */
881 SetLastError(0xdeadbeef);
882 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
883 error
= GetLastError();
884 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
885 ok( error
== ERROR_INVALID_PARAMETER
,
886 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
889 /* test too small buffer size */
890 SetLastError(0xdeadbeef);
891 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, ARRAY_SIZE(string
));
892 error
= GetLastError();
893 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
894 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
895 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
899 static void InternetTimeToSystemTimeA_test(void)
903 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
904 static const char string
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
905 static const char string2
[] = " fri 7 jan 2005 12 06 35";
907 ret
= pInternetTimeToSystemTimeA( string
, &time
, 0 );
908 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
909 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
910 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
912 ret
= pInternetTimeToSystemTimeA( string2
, &time
, 0 );
913 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
914 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
915 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
918 static void InternetTimeToSystemTimeW_test(void)
922 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
923 static const WCHAR string
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
924 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
925 static const WCHAR string2
[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
926 '1','2',' ','0','6',' ','3','5',0 };
927 static const WCHAR string3
[] = { 'F','r',0 };
929 ret
= pInternetTimeToSystemTimeW( NULL
, NULL
, 0 );
930 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
932 ret
= pInternetTimeToSystemTimeW( NULL
, &time
, 0 );
933 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
935 ret
= pInternetTimeToSystemTimeW( string
, NULL
, 0 );
936 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
938 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
939 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
941 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
942 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
943 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
944 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
946 ret
= pInternetTimeToSystemTimeW( string2
, &time
, 0 );
947 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
948 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
949 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
951 ret
= pInternetTimeToSystemTimeW( string3
, &time
, 0 );
952 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
955 static void test_IsDomainLegalCookieDomainW(void)
958 static const WCHAR empty
[] = {0};
959 static const WCHAR dot
[] = {'.',0};
960 static const WCHAR uk
[] = {'u','k',0};
961 static const WCHAR com
[] = {'c','o','m',0};
962 static const WCHAR dot_com
[] = {'.','c','o','m',0};
963 static const WCHAR gmail_com
[] = {'g','m','a','i','l','.','c','o','m',0};
964 static const WCHAR dot_gmail_com
[] = {'.','g','m','a','i','l','.','c','o','m',0};
965 static const WCHAR www_gmail_com
[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
966 static const WCHAR www_mail_gmail_com
[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
967 static const WCHAR mail_gmail_com
[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
968 static const WCHAR gmail_co_uk
[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
969 static const WCHAR co_uk
[] = {'c','o','.','u','k',0};
970 static const WCHAR dot_co_uk
[] = {'.','c','o','.','u','k',0};
972 SetLastError(0xdeadbeef);
973 ret
= pIsDomainLegalCookieDomainW(NULL
, NULL
);
974 if (!ret
&& (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
))
976 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
980 broken(ret
), /* IE6 */
981 "IsDomainLegalCookieDomainW succeeded\n");
983 SetLastError(0xdeadbeef);
984 ret
= pIsDomainLegalCookieDomainW(com
, NULL
);
985 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
987 SetLastError(0xdeadbeef);
988 ret
= pIsDomainLegalCookieDomainW(NULL
, gmail_com
);
989 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
991 SetLastError(0xdeadbeef);
992 ret
= pIsDomainLegalCookieDomainW(empty
, gmail_com
);
993 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
995 SetLastError(0xdeadbeef);
996 ret
= pIsDomainLegalCookieDomainW(com
, empty
);
997 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
999 SetLastError(0xdeadbeef);
1000 ret
= pIsDomainLegalCookieDomainW(gmail_com
, dot
);
1001 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1003 SetLastError(0xdeadbeef);
1004 ret
= pIsDomainLegalCookieDomainW(dot
, gmail_com
);
1005 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1007 SetLastError(0xdeadbeef);
1008 ret
= pIsDomainLegalCookieDomainW(com
, com
);
1009 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1011 SetLastError(0xdeadbeef);
1012 ret
= pIsDomainLegalCookieDomainW(com
, dot_com
);
1013 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1015 SetLastError(0xdeadbeef);
1016 ret
= pIsDomainLegalCookieDomainW(dot_com
, com
);
1017 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1019 SetLastError(0xdeadbeef);
1020 ret
= pIsDomainLegalCookieDomainW(com
, gmail_com
);
1021 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1023 ret
= pIsDomainLegalCookieDomainW(gmail_com
, gmail_com
);
1024 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1026 ret
= pIsDomainLegalCookieDomainW(gmail_com
, www_gmail_com
);
1027 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1029 ret
= pIsDomainLegalCookieDomainW(gmail_com
, www_mail_gmail_com
);
1030 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1032 SetLastError(0xdeadbeef);
1033 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, co_uk
);
1034 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1036 ret
= pIsDomainLegalCookieDomainW(uk
, co_uk
);
1037 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1039 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, dot_co_uk
);
1040 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1042 ret
= pIsDomainLegalCookieDomainW(co_uk
, gmail_co_uk
);
1043 todo_wine
ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1045 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, gmail_co_uk
);
1046 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1048 ret
= pIsDomainLegalCookieDomainW(gmail_com
, com
);
1049 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1051 SetLastError(0xdeadbeef);
1052 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
1053 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1055 ret
= pIsDomainLegalCookieDomainW(gmail_com
, mail_gmail_com
);
1056 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
1058 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, gmail_com
);
1059 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1061 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, com
);
1062 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1064 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
1065 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1067 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, dot_gmail_com
);
1068 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
1071 static void test_PrivacyGetSetZonePreferenceW(void)
1073 DWORD ret
, zone
, type
, template, old_template
, pref_size
= 0;
1078 ret
= pPrivacyGetZonePreferenceW(zone
, type
, NULL
, NULL
, NULL
);
1079 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1082 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &old_template
, NULL
, NULL
);
1083 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1085 trace("template %u\n", old_template
);
1087 if(old_template
== PRIVACY_TEMPLATE_ADVANCED
) {
1088 pref_size
= ARRAY_SIZE(pref
);
1089 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &old_template
, pref
, &pref_size
);
1090 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1094 ret
= pPrivacySetZonePreferenceW(zone
, type
, template, NULL
);
1095 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1098 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &template, NULL
, NULL
);
1099 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1100 ok(template == 5, "expected template == 5, got %u\n", template);
1103 ret
= pPrivacySetZonePreferenceW(zone
, type
, old_template
, pref_size
? pref
: NULL
);
1104 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
1107 static void test_InternetSetOption(void)
1109 HINTERNET ses
, con
, req
;
1114 ses
= InternetOpenA(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1115 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1116 con
= InternetConnectA(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1117 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1118 req
= HttpOpenRequestA(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1119 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1121 /* INTERNET_OPTION_POLICY tests */
1122 SetLastError(0xdeadbeef);
1123 ret
= InternetSetOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
1124 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1125 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
1126 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1128 SetLastError(0xdeadbeef);
1129 ret
= InternetQueryOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
1130 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1131 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
1132 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1134 /* INTERNET_OPTION_ERROR_MASK tests */
1135 SetLastError(0xdeadbeef);
1136 size
= sizeof(ulArg
);
1137 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, &size
);
1138 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
1139 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1141 SetLastError(0xdeadbeef);
1143 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1144 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1145 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
1147 SetLastError(0xdeadbeef);
1149 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, 20);
1150 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1151 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %d\n", GetLastError());
1154 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1155 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1157 SetLastError(0xdeadbeef);
1159 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1160 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1161 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
1163 SetLastError(0xdeadbeef);
1165 ret
= InternetSetOptionA(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
1166 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1167 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
1169 ret
= InternetSetOptionA(req
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1170 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1172 ret
= InternetSetOptionA(con
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1173 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1175 ret
= InternetSetOptionA(ses
, INTERNET_OPTION_SETTINGS_CHANGED
, NULL
, 0);
1176 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1178 ret
= InternetSetOptionA(ses
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1179 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1181 SetLastError(0xdeadbeef);
1182 ret
= InternetSetOptionA(req
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1183 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1184 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %u\n", GetLastError());
1186 SetLastError(0xdeadbeef);
1187 ret
= InternetSetOptionA(con
, INTERNET_OPTION_REFRESH
, NULL
, 0);
1188 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
1189 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %u\n", GetLastError());
1191 ret
= InternetCloseHandle(req
);
1192 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1193 ret
= InternetCloseHandle(con
);
1194 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1195 ret
= InternetCloseHandle(ses
);
1196 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1199 static void test_end_browser_session(void)
1204 ret
= InternetSetCookieA("http://www.example.com/test_end", NULL
, "A=B");
1205 ok(ret
== TRUE
, "InternetSetCookie failed\n");
1208 ret
= InternetGetCookieA("http://www.example.com/test_end", NULL
, NULL
, &len
);
1209 ok(ret
== TRUE
,"InternetGetCookie failed\n");
1210 ok(len
!= 0, "len = 0\n");
1212 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_END_BROWSER_SESSION
, NULL
, 0);
1213 ok(ret
, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
1216 ret
= InternetGetCookieA("http://www.example.com/test_end", NULL
, NULL
, &len
);
1217 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
, "InternetGetCookie returned %x (%u)\n", ret
, GetLastError());
1218 ok(!len
, "len = %u\n", len
);
1221 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1222 static void r_verifyProxyEnable(LONG l
, DWORD exp
)
1225 DWORD type
, val
, size
= sizeof(DWORD
);
1227 static const CHAR szInternetSettings
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1228 static const CHAR szProxyEnable
[] = "ProxyEnable";
1230 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, szInternetSettings
, &hkey
);
1231 ok_(__FILE__
,l
) (!ret
, "RegOpenKeyA failed: 0x%08x\n", ret
);
1233 ret
= RegQueryValueExA(hkey
, szProxyEnable
, 0, &type
, (BYTE
*)&val
, &size
);
1234 ok_(__FILE__
,l
) (!ret
, "RegQueryValueExA failed: 0x%08x\n", ret
);
1235 ok_(__FILE__
,l
) (type
== REG_DWORD
, "Expected regtype to be REG_DWORD, was: %d\n", type
);
1236 ok_(__FILE__
,l
) (val
== exp
, "Expected ProxyEnabled to be %d, got: %d\n", exp
, val
);
1238 ret
= RegCloseKey(hkey
);
1239 ok_(__FILE__
,l
) (!ret
, "RegCloseKey failed: 0x%08x\n", ret
);
1242 static void test_Option_PerConnectionOption(void)
1245 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
1246 INTERNET_PER_CONN_OPTION_LISTW list
= {size
};
1247 INTERNET_PER_CONN_OPTIONW
*orig_settings
;
1248 static WCHAR proxy_srvW
[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1250 /* get the global IE proxy server info, to restore later */
1251 list
.dwOptionCount
= 2;
1252 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1254 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1255 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1257 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1259 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1260 orig_settings
= list
.pOptions
;
1262 /* set the global IE proxy server */
1263 list
.dwOptionCount
= 2;
1264 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1266 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1267 list
.pOptions
[0].Value
.pszValue
= proxy_srvW
;
1268 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1269 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1271 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1273 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1275 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1277 /* get & verify the global IE proxy server */
1278 list
.dwOptionCount
= 2;
1279 list
.dwOptionError
= 0;
1280 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1282 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1283 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1285 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1287 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1288 ok(!lstrcmpW(list
.pOptions
[0].Value
.pszValue
, proxy_srvW
),
1289 "Retrieved proxy server should've been %s, was: %s\n",
1290 wine_dbgstr_w(proxy_srvW
), wine_dbgstr_w(list
.pOptions
[0].Value
.pszValue
));
1291 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1292 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1293 list
.pOptions
[1].Value
.dwValue
);
1294 verifyProxyEnable(1);
1296 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1297 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1299 /* disable the proxy server */
1300 list
.dwOptionCount
= 1;
1301 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1303 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1304 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_DIRECT
;
1306 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1308 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1310 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1312 /* verify that the proxy is disabled */
1313 list
.dwOptionCount
= 1;
1314 list
.dwOptionError
= 0;
1315 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1317 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1319 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1321 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1322 ok(list
.pOptions
[0].Value
.dwValue
== PROXY_TYPE_DIRECT
,
1323 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1324 list
.pOptions
[0].Value
.dwValue
);
1325 verifyProxyEnable(0);
1327 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1329 /* set the proxy flags to 'invalid' value */
1330 list
.dwOptionCount
= 1;
1331 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1333 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1334 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
;
1336 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1338 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1340 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1342 /* verify that the proxy is enabled */
1343 list
.dwOptionCount
= 1;
1344 list
.dwOptionError
= 0;
1345 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1347 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1349 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1351 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1352 todo_wine
ok(list
.pOptions
[0].Value
.dwValue
== (PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
),
1353 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1354 list
.pOptions
[0].Value
.dwValue
);
1355 verifyProxyEnable(1);
1357 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1359 /* restore original settings */
1360 list
.dwOptionCount
= 2;
1361 list
.pOptions
= orig_settings
;
1363 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1365 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1367 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1370 static void test_Option_PerConnectionOptionA(void)
1373 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTA
);
1374 INTERNET_PER_CONN_OPTION_LISTA list
= {size
};
1375 INTERNET_PER_CONN_OPTIONA
*orig_settings
;
1376 char proxy_srv
[] = "proxy.example";
1378 /* get the global IE proxy server info, to restore later */
1379 list
.dwOptionCount
= 2;
1380 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1382 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1383 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1385 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1387 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1388 orig_settings
= list
.pOptions
;
1390 /* set the global IE proxy server */
1391 list
.dwOptionCount
= 2;
1392 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1394 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1395 list
.pOptions
[0].Value
.pszValue
= proxy_srv
;
1396 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1397 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1399 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1401 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1403 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1405 /* get & verify the global IE proxy server */
1406 list
.dwOptionCount
= 2;
1407 list
.dwOptionError
= 0;
1408 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1410 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1411 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1413 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1415 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1416 ok(!lstrcmpA(list
.pOptions
[0].Value
.pszValue
, "proxy.example"),
1417 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1418 proxy_srv
, list
.pOptions
[0].Value
.pszValue
);
1419 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1420 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1421 list
.pOptions
[1].Value
.dwValue
);
1423 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1424 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1426 /* test with NULL as proxy server */
1427 list
.dwOptionCount
= 1;
1428 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA
));
1429 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1430 list
.pOptions
[0].Value
.pszValue
= NULL
;
1432 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, size
);
1433 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1435 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, size
);
1436 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1438 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1440 /* get & verify the proxy server */
1441 list
.dwOptionCount
= 1;
1442 list
.dwOptionError
= 0;
1443 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA
));
1444 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1446 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
, &list
, &size
);
1447 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1448 ok(!list
.pOptions
[0].Value
.pszValue
,
1449 "Retrieved proxy server should've been NULL, was: \"%s\"\n",
1450 list
.pOptions
[0].Value
.pszValue
);
1452 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1453 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1455 /* restore original settings */
1456 list
.dwOptionCount
= 2;
1457 list
.pOptions
= orig_settings
;
1459 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1461 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1463 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1466 #define FLAG_TODO 0x1
1467 #define FLAG_NEEDREQ 0x2
1468 #define FLAG_UNIMPL 0x4
1470 static void test_InternetErrorDlg(void)
1472 HINTERNET ses
, con
, req
;
1476 static const struct {
1481 { ERROR_INTERNET_INCORRECT_PASSWORD
, ERROR_SUCCESS
, FLAG_NEEDREQ
},
1482 { ERROR_INTERNET_SEC_CERT_DATE_INVALID
, ERROR_CANCELLED
, 0 },
1483 { ERROR_INTERNET_SEC_CERT_CN_INVALID
, ERROR_CANCELLED
, 0 },
1484 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
, ERROR_SUCCESS
, 0 },
1485 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
, ERROR_SUCCESS
, FLAG_TODO
},
1486 { ERROR_INTERNET_MIXED_SECURITY
, ERROR_CANCELLED
, FLAG_TODO
},
1487 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE
, ERROR_CANCELLED
, FLAG_TODO
},
1488 { ERROR_INTERNET_POST_IS_NON_SECURE
, ERROR_SUCCESS
, 0 },
1489 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
, ERROR_CANCELLED
, FLAG_NEEDREQ
|FLAG_TODO
},
1490 { ERROR_INTERNET_INVALID_CA
, ERROR_CANCELLED
, 0 },
1491 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
, ERROR_CANCELLED
, FLAG_TODO
},
1492 { ERROR_INTERNET_INSERT_CDROM
, ERROR_CANCELLED
, FLAG_TODO
|FLAG_NEEDREQ
|FLAG_UNIMPL
},
1493 { ERROR_INTERNET_SEC_CERT_ERRORS
, ERROR_CANCELLED
, 0 },
1494 { ERROR_INTERNET_SEC_CERT_REV_FAILED
, ERROR_CANCELLED
, 0 },
1495 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
, ERROR_HTTP_COOKIE_DECLINED
, FLAG_TODO
},
1496 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1497 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1498 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
, ERROR_CANCELLED
, FLAG_TODO
},
1499 { ERROR_INTERNET_SEC_CERT_REVOKED
, ERROR_CANCELLED
, 0 },
1502 res
= InternetErrorDlg(NULL
, NULL
, ERROR_INTERNET_SEC_CERT_ERRORS
, 0, NULL
);
1503 ok(res
== ERROR_INVALID_HANDLE
, "Got %d\n", res
);
1505 ses
= InternetOpenA(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1506 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1507 con
= InternetConnectA(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1508 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1509 req
= HttpOpenRequestA(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1510 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1512 hwnd
= GetDesktopWindow();
1513 ok(hwnd
!= NULL
, "GetDesktopWindow failed (%d)\n", GetLastError());
1515 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1517 DWORD expected
= ERROR_NOT_SUPPORTED
, test_flags
= 0, j
;
1519 for (j
= 0; j
< ARRAY_SIZE(no_ui_res
); ++j
)
1521 if (no_ui_res
[j
].error
== i
)
1523 test_flags
= no_ui_res
[j
].test_flags
;
1524 expected
= no_ui_res
[j
].res
;
1528 /* Try an invalid request handle */
1529 res
= InternetErrorDlg(hwnd
, (HANDLE
)0xdeadbeef, i
, FLAGS_ERROR_UI_FLAGS_NO_UI
, 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) */
1544 if (i
== ERROR_INTERNET_PROXY_ALERT
)
1545 continue; /* Interactive (Win10 1607+) */
1547 res
= InternetErrorDlg(hwnd
, req
, i
, FLAGS_ERROR_UI_FLAGS_NO_UI
, NULL
);
1549 /* Handle some special cases */
1552 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
: /* later 9.x versions */
1553 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
: /* later 9.x versions */
1554 case ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE
: /* later 11.x versions */
1555 if(res
== ERROR_CANCELLED
)
1556 expected
= ERROR_CANCELLED
;
1558 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
:
1559 if (res
== NTE_PROV_TYPE_NOT_DEF
) /* XP, 2003 */
1560 expected
= NTE_PROV_TYPE_NOT_DEF
;
1562 case ERROR_INTERNET_CHG_POST_IS_NON_SECURE
:
1563 if(res
== ERROR_SUCCESS
) /* win10 returns ERROR_SUCCESS */
1564 expected
= ERROR_SUCCESS
;
1569 if (expected
== ERROR_NOT_SUPPORTED
&& res
== ERROR_CANCELLED
) /* Win10 1607+ */
1570 expected
= ERROR_CANCELLED
;
1572 todo_wine_if(test_flags
& FLAG_TODO
)
1573 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1575 /* Same thing with NULL hwnd */
1576 res
= InternetErrorDlg(NULL
, req
, i
, FLAGS_ERROR_UI_FLAGS_NO_UI
, NULL
);
1577 todo_wine_if(test_flags
& FLAG_TODO
)
1578 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1581 /* With a null req */
1582 if(test_flags
& FLAG_NEEDREQ
)
1583 expected
= ERROR_INVALID_PARAMETER
;
1585 res
= InternetErrorDlg(hwnd
, NULL
, i
, FLAGS_ERROR_UI_FLAGS_NO_UI
, NULL
);
1586 todo_wine_if( test_flags
& FLAG_TODO
|| i
== ERROR_INTERNET_INCORRECT_PASSWORD
)
1587 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1590 res
= InternetCloseHandle(req
);
1591 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1592 res
= InternetCloseHandle(con
);
1593 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1594 res
= InternetCloseHandle(ses
);
1595 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1598 static void test_InternetGetConnectedStateExA(void)
1604 if(!pInternetGetConnectedStateExA
) {
1605 win_skip("InternetGetConnectedStateExA is not supported\n");
1611 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sizeof(buffer
), 0);
1612 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags
, buffer
);
1614 ok (flags
& INTERNET_RAS_INSTALLED
, "Missing RAS flag\n");
1616 win_skip("InternetGetConnectedStateExA tests require a valid connection\n");
1620 res
= pInternetGetConnectedStateExA(NULL
, NULL
, 0, 0);
1621 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1624 res
= pInternetGetConnectedStateExA(&flags
, NULL
, 0, 0);
1625 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1626 if (flags
& INTERNET_CONNECTION_CONFIGURED
)
1628 ok(flags
& INTERNET_CONNECTION_MODEM
, "Modem connection flag missing\n");
1629 ok(flags
& ~INTERNET_CONNECTION_LAN
, "Mixed Modem and LAN flags\n");
1633 ok(flags
& INTERNET_CONNECTION_LAN
, "LAN connection flag missing\n");
1634 ok(flags
& ~INTERNET_CONNECTION_MODEM
, "Mixed Modem and LAN flags\n");
1639 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 0, 0);
1640 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1641 ok(flags
, "Expected at least one flag set\n");
1642 ok(!buffer
[0], "Buffer must not change, got %02X\n", buffer
[0]);
1645 res
= pInternetGetConnectedStateExA(NULL
, buffer
, sizeof(buffer
), 0);
1646 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1647 sz
= strlen(buffer
);
1648 ok(sz
> 0, "Expected a connection name\n");
1652 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sizeof(buffer
), 0);
1653 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1654 ok(flags
, "Expected at least one flag set\n");
1655 sz
= strlen(buffer
);
1656 ok(sz
> 0, "Expected a connection name\n");
1659 res
= pInternetGetConnectedStateExA(&flags
, NULL
, sizeof(buffer
), 0);
1660 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1661 ok(flags
, "Expected at least one flag set\n");
1663 /* no space for complete string this time */
1666 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sz
, 0);
1667 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1668 ok(flags
, "Expected at least one flag set\n");
1669 ok(sz
- 1 == strlen(buffer
), "Expected %u bytes, got %u\n", sz
- 1, lstrlenA(buffer
));
1673 res
= pInternetGetConnectedStateExA(&flags
, buffer
, sz
/ 2, 0);
1674 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1675 ok(flags
, "Expected at least one flag set\n");
1676 ok(sz
/ 2 - 1 == strlen(buffer
), "Expected %u bytes, got %u\n", sz
/ 2 - 1, lstrlenA(buffer
));
1680 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 1, 0);
1681 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1682 ok(flags
, "Expected at least one flag set\n");
1683 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer
));
1687 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 2, 0);
1688 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1689 ok(flags
, "Expected at least one flag set\n");
1690 ok(strlen(buffer
) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer
));
1694 res
= pInternetGetConnectedStateExA(&flags
, buffer
, 1, 0);
1695 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1696 ok(flags
, "Expected at least one flag set\n");
1697 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer
));
1700 static void test_InternetGetConnectedStateExW(void)
1706 if(!pInternetGetConnectedStateExW
) {
1707 win_skip("InternetGetConnectedStateExW is not supported\n");
1713 res
= pInternetGetConnectedStateExW(&flags
, buffer
, ARRAY_SIZE(buffer
), 0);
1714 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags
, wine_dbgstr_w(buffer
));
1716 ok (flags
& INTERNET_RAS_INSTALLED
, "Missing RAS flag\n");
1718 win_skip("InternetGetConnectedStateExW tests require a valid connection\n");
1722 res
= pInternetGetConnectedStateExW(NULL
, NULL
, 0, 0);
1723 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1726 res
= pInternetGetConnectedStateExW(&flags
, NULL
, 0, 0);
1727 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1728 if (flags
& INTERNET_CONNECTION_CONFIGURED
)
1730 ok(flags
& INTERNET_CONNECTION_MODEM
, "Modem connection flag missing\n");
1731 ok(flags
& ~INTERNET_CONNECTION_LAN
, "Mixed Modem and LAN flags\n");
1735 ok(flags
& INTERNET_CONNECTION_LAN
, "LAN connection flag missing\n");
1736 ok(flags
& ~INTERNET_CONNECTION_MODEM
, "Mixed Modem and LAN flags\n");
1741 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 0, 0);
1742 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1743 ok(flags
, "Expected at least one flag set\n");
1744 ok(!buffer
[0], "Buffer must not change, got %02X\n", buffer
[0]);
1747 res
= pInternetGetConnectedStateExW(NULL
, buffer
, ARRAY_SIZE(buffer
), 0);
1748 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1749 sz
= lstrlenW(buffer
);
1750 ok(sz
> 0, "Expected a connection name\n");
1754 res
= pInternetGetConnectedStateExW(&flags
, buffer
, ARRAY_SIZE(buffer
), 0);
1755 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1756 ok(flags
, "Expected at least one flag set\n");
1757 sz
= lstrlenW(buffer
);
1758 ok(sz
> 0, "Expected a connection name\n");
1761 res
= pInternetGetConnectedStateExW(&flags
, NULL
, ARRAY_SIZE(buffer
), 0);
1762 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1763 ok(flags
, "Expected at least one flag set\n");
1765 /* no space for complete string this time */
1768 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sz
, 0);
1769 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1770 ok(flags
, "Expected at least one flag set\n");
1771 if (flags
& INTERNET_CONNECTION_MODEM
)
1772 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1774 ok(sz
- 1 == lstrlenW(buffer
), "Expected %u bytes, got %u\n", sz
- 1, lstrlenW(buffer
));
1778 res
= pInternetGetConnectedStateExW(&flags
, buffer
, sz
/ 2, 0);
1779 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1780 ok(flags
, "Expected at least one flag set\n");
1781 if (flags
& INTERNET_CONNECTION_MODEM
)
1782 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1784 ok(sz
/ 2 - 1 == lstrlenW(buffer
), "Expected %u bytes, got %u\n", sz
/ 2 - 1, lstrlenW(buffer
));
1788 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 1, 0);
1789 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1790 ok(flags
, "Expected at least one flag set\n");
1791 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1795 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 2, 0);
1796 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1797 ok(flags
, "Expected at least one flag set\n");
1798 if (flags
& INTERNET_CONNECTION_MODEM
)
1799 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1801 ok(lstrlenW(buffer
) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer
));
1805 res
= pInternetGetConnectedStateExW(&flags
, buffer
, 1, 0);
1806 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
1807 ok(flags
, "Expected at least one flag set\n");
1808 ok(!buffer
[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer
));
1811 static void test_format_message(HMODULE hdll
)
1816 /* These messages come from wininet and not the system. */
1817 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, ERROR_INTERNET_TIMEOUT
,
1818 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1819 ok(ret
== 0, "FormatMessageA returned %d\n", ret
);
1821 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_TIMEOUT
,
1822 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1823 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1825 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_INTERNAL_ERROR
,
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_INVALID_URL
,
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_UNRECOGNIZED_SCHEME
,
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_NAME_NOT_RESOLVED
,
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_INVALID_OPERATION
,
1842 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1843 ok(ret
!= 0 || broken(!ret
) /* XP, w2k3 */, "FormatMessageA returned %d\n", ret
);
1845 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_OPERATION_CANCELLED
,
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_ITEM_NOT_FOUND
,
1850 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1851 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1853 ret
= FormatMessageA(FORMAT_MESSAGE_FROM_HMODULE
, hdll
, ERROR_INTERNET_CANNOT_CONNECT
,
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_CONNECTION_ABORTED
,
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_SEC_CERT_DATE_INVALID
,
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_SEC_CERT_CN_INVALID
,
1866 MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
), out
, sizeof(out
), NULL
);
1867 ok(ret
!= 0, "FormatMessageA returned %d\n", ret
);
1870 /* ############################### */
1872 START_TEST(internet
)
1875 hdll
= GetModuleHandleA("wininet.dll");
1877 pCreateUrlCacheContainerA
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerA");
1878 pCreateUrlCacheContainerW
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerW");
1879 pInternetTimeFromSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeA");
1880 pInternetTimeFromSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeW");
1881 pInternetTimeToSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeA");
1882 pInternetTimeToSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeW");
1883 pIsDomainLegalCookieDomainW
= (void*)GetProcAddress(hdll
, (LPCSTR
)117);
1884 pPrivacyGetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacyGetZonePreferenceW");
1885 pPrivacySetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacySetZonePreferenceW");
1886 pInternetGetCookieExA
= (void*)GetProcAddress(hdll
, "InternetGetCookieExA");
1887 pInternetGetCookieExW
= (void*)GetProcAddress(hdll
, "InternetGetCookieExW");
1888 pInternetGetConnectedStateExA
= (void*)GetProcAddress(hdll
, "InternetGetConnectedStateExA");
1889 pInternetGetConnectedStateExW
= (void*)GetProcAddress(hdll
, "InternetGetConnectedStateExW");
1891 if(!pInternetGetCookieExW
) {
1892 win_skip("Too old IE (older than 6.0)\n");
1896 test_InternetCanonicalizeUrlA();
1897 test_InternetQueryOptionA();
1898 test_InternetGetConnectedStateExA();
1899 test_InternetGetConnectedStateExW();
1901 test_complicated_cookie();
1903 test_cookie_attrs();
1906 test_Option_PerConnectionOption();
1907 test_Option_PerConnectionOptionA();
1908 test_InternetErrorDlg();
1911 if (!pInternetTimeFromSystemTimeA
)
1912 win_skip("skipping the InternetTime tests\n");
1915 InternetTimeFromSystemTimeA_test();
1916 InternetTimeFromSystemTimeW_test();
1917 InternetTimeToSystemTimeA_test();
1918 InternetTimeToSystemTimeW_test();
1920 if (pIsDomainLegalCookieDomainW
&&
1921 ((void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerA
||
1922 (void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerW
))
1923 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1924 else if (!pIsDomainLegalCookieDomainW
)
1925 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1927 test_IsDomainLegalCookieDomainW();
1929 if (pPrivacyGetZonePreferenceW
&& pPrivacySetZonePreferenceW
)
1930 test_PrivacyGetSetZonePreferenceW();
1932 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1934 test_InternetSetOption();
1935 test_end_browser_session();
1936 test_format_message(hdll
);