2 * Wininet - internet tests
4 * Copyright 2005 Vijay Kiran Kamuju
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/test.h"
32 static BOOL (WINAPI
*pCreateUrlCacheContainerA
)(DWORD
, DWORD
, DWORD
, DWORD
,
33 DWORD
, DWORD
, DWORD
, DWORD
);
34 static BOOL (WINAPI
*pCreateUrlCacheContainerW
)(DWORD
, DWORD
, DWORD
, DWORD
,
35 DWORD
, DWORD
, DWORD
, DWORD
);
36 static BOOL (WINAPI
*pInternetTimeFromSystemTimeA
)(CONST SYSTEMTIME
*,DWORD
,LPSTR
,DWORD
);
37 static BOOL (WINAPI
*pInternetTimeFromSystemTimeW
)(CONST SYSTEMTIME
*,DWORD
,LPWSTR
,DWORD
);
38 static BOOL (WINAPI
*pInternetTimeToSystemTimeA
)(LPCSTR
,SYSTEMTIME
*,DWORD
);
39 static BOOL (WINAPI
*pInternetTimeToSystemTimeW
)(LPCWSTR
,SYSTEMTIME
*,DWORD
);
40 static BOOL (WINAPI
*pIsDomainLegalCookieDomainW
)(LPCWSTR
, LPCWSTR
);
41 static DWORD (WINAPI
*pPrivacyGetZonePreferenceW
)(DWORD
, DWORD
, LPDWORD
, LPWSTR
, LPDWORD
);
42 static DWORD (WINAPI
*pPrivacySetZonePreferenceW
)(DWORD
, DWORD
, DWORD
, LPCWSTR
);
44 /* ############################### */
46 static void test_InternetCanonicalizeUrlA(void)
54 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
55 url
= "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
56 urllen
= lstrlenA(url
);
58 memset(buffer
, '#', sizeof(buffer
)-1);
59 buffer
[sizeof(buffer
)-1] = '\0';
60 dwSize
= 1; /* Acrobat Updater use this size */
61 SetLastError(0xdeadbeef);
62 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
63 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
64 "got %u and %u with size %u for '%s' (%d)\n",
65 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
68 /* buffer has no space for the terminating '\0' */
69 memset(buffer
, '#', sizeof(buffer
)-1);
70 buffer
[sizeof(buffer
)-1] = '\0';
72 SetLastError(0xdeadbeef);
73 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
74 /* dwSize is nr. of needed bytes with the terminating '\0' */
75 ok( !res
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
) && (dwSize
== (urllen
+1)),
76 "got %u and %u with size %u for '%s' (%d)\n",
77 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
79 /* buffer has the required size */
80 memset(buffer
, '#', sizeof(buffer
)-1);
81 buffer
[sizeof(buffer
)-1] = '\0';
83 SetLastError(0xdeadbeef);
84 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
85 /* dwSize is nr. of copied bytes without the terminating '\0' */
86 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
87 "got %u and %u with size %u for '%s' (%d)\n",
88 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
90 memset(buffer
, '#', sizeof(buffer
)-1);
91 buffer
[sizeof(buffer
)-1] = '\0';
92 dwSize
= sizeof(buffer
);
93 SetLastError(0xdeadbeef);
94 res
= InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer
, &dwSize
, ICU_DECODE
| ICU_NO_ENCODE
);
95 ok(res
, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
96 ok(dwSize
== lstrlenA(buffer
), "got %d expected %d\n", dwSize
, lstrlenA(buffer
));
97 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer
),
98 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer
);
100 /* buffer is larger as the required size */
101 memset(buffer
, '#', sizeof(buffer
)-1);
102 buffer
[sizeof(buffer
)-1] = '\0';
104 SetLastError(0xdeadbeef);
105 res
= InternetCanonicalizeUrlA(url
, buffer
, &dwSize
, 0);
106 /* dwSize is nr. of copied bytes without the terminating '\0' */
107 ok( res
&& (dwSize
== urllen
) && (lstrcmpA(url
, buffer
) == 0),
108 "got %u and %u with size %u for '%s' (%d)\n",
109 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
112 /* check NULL pointers */
113 memset(buffer
, '#', urllen
+ 4);
114 buffer
[urllen
+ 4] = '\0';
116 SetLastError(0xdeadbeef);
117 res
= InternetCanonicalizeUrlA(NULL
, buffer
, &dwSize
, 0);
118 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
119 "got %u and %u with size %u for '%s' (%d)\n",
120 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
122 memset(buffer
, '#', urllen
+ 4);
123 buffer
[urllen
+ 4] = '\0';
125 SetLastError(0xdeadbeef);
126 res
= InternetCanonicalizeUrlA(url
, NULL
, &dwSize
, 0);
127 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
128 "got %u and %u with size %u for '%s' (%d)\n",
129 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
131 memset(buffer
, '#', urllen
+ 4);
132 buffer
[urllen
+ 4] = '\0';
134 SetLastError(0xdeadbeef);
135 res
= InternetCanonicalizeUrlA(url
, buffer
, NULL
, 0);
136 ok( !res
&& (GetLastError() == ERROR_INVALID_PARAMETER
),
137 "got %u and %u with size %u for '%s' (%d)\n",
138 res
, GetLastError(), dwSize
, buffer
, lstrlenA(buffer
));
140 /* test with trailing space */
142 res
= InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer
, &dwSize
, ICU_BROWSER_MODE
);
143 ok(res
== 1, "InternetCanonicalizeUrlA failed\n");
144 ok(!strcmp(buffer
, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer
);
146 res
= InternetSetOptionA(NULL
, 0xdeadbeef, buffer
, sizeof(buffer
));
147 ok(!res
, "InternetSetOptionA succeeded\n");
148 ok(GetLastError() == ERROR_INTERNET_INVALID_OPTION
,
149 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
152 /* ############################### */
154 static void test_InternetQueryOptionA(void)
156 HINTERNET hinet
,hurl
;
159 static const char useragent
[] = {"Wininet Test"};
164 hinet
= InternetOpenA(useragent
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
165 ok((hinet
!= 0x0),"InternetOpen Failed\n");
167 SetLastError(0xdeadbeef);
168 retval
=InternetQueryOptionA(NULL
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
170 ok(retval
== 0,"Got wrong return value %d\n",retval
);
171 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code%d\n",err
);
173 SetLastError(0xdeadbeef);
174 len
=strlen(useragent
)+1;
175 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
177 ok(len
== strlen(useragent
)+1,"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
178 ok(retval
== 0,"Got wrong return value %d\n",retval
);
179 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n",err
);
181 SetLastError(0xdeadbeef);
182 len
=strlen(useragent
)+1;
183 buffer
=HeapAlloc(GetProcessHeap(),0,len
);
184 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
186 ok(retval
== 1,"Got wrong return value %d\n",retval
);
189 ok(!strcmp(useragent
,buffer
),"Got wrong user agent string %s instead of %s\n",buffer
,useragent
);
190 ok(len
== strlen(useragent
),"Got wrong user agent length %d instead of %d\n",len
,lstrlenA(useragent
));
192 ok(err
== 0xdeadbeef, "Got wrong error code %d\n",err
);
193 HeapFree(GetProcessHeap(),0,buffer
);
195 SetLastError(0xdeadbeef);
197 buffer
=HeapAlloc(GetProcessHeap(),0,100);
198 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,buffer
,&len
);
200 ok(len
== strlen(useragent
) + 1,"Got wrong user agent length %d instead of %d\n", len
, lstrlenA(useragent
) + 1);
201 ok(!retval
, "Got wrong return value %d\n", retval
);
202 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code %d\n", err
);
203 HeapFree(GetProcessHeap(),0,buffer
);
205 hurl
= InternetConnectA(hinet
,"www.winehq.org",INTERNET_DEFAULT_HTTP_PORT
,NULL
,NULL
,INTERNET_SERVICE_HTTP
,0,0);
207 SetLastError(0xdeadbeef);
209 retval
= InternetQueryOptionA(hurl
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
211 ok(len
== 0,"Got wrong user agent length %d instead of 0\n",len
);
212 ok(retval
== 0,"Got wrong return value %d\n",retval
);
213 ok(err
== ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "Got wrong error code %d\n",err
);
215 InternetCloseHandle(hurl
);
216 InternetCloseHandle(hinet
);
218 hinet
= InternetOpenA("",INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
219 ok((hinet
!= 0x0),"InternetOpen Failed\n");
221 SetLastError(0xdeadbeef);
223 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
225 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
226 ok(retval
== 0,"Got wrong return value %d\n",retval
);
227 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
229 InternetCloseHandle(hinet
);
232 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
233 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
236 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
237 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
238 ok(val
== 12345, "val = %d\n", val
);
239 ok(len
== sizeof(val
), "len = %d\n", len
);
241 hinet
= InternetOpenA(NULL
,INTERNET_OPEN_TYPE_DIRECT
,NULL
,NULL
, 0);
242 ok((hinet
!= 0x0),"InternetOpen Failed\n");
243 SetLastError(0xdeadbeef);
245 retval
=InternetQueryOptionA(hinet
,INTERNET_OPTION_USER_AGENT
,NULL
,&len
);
247 ok(len
== 1,"Got wrong user agent length %d instead of %d\n",len
,1);
248 ok(retval
== 0,"Got wrong return value %d\n",retval
);
249 ok(err
== ERROR_INSUFFICIENT_BUFFER
, "Got wrong error code%d\n",err
);
253 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
254 ok(!res
, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
255 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
258 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
259 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
260 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION
, "GetLastError() = %u\n", GetLastError());
263 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
264 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
265 ok(val
== 12345, "val = %d\n", val
);
266 ok(len
== sizeof(val
), "len = %d\n", len
);
269 res
= InternetSetOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, sizeof(val
));
270 ok(res
, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
273 res
= InternetQueryOptionA(hinet
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
274 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
275 ok(val
== 1, "val = %d\n", val
);
276 ok(len
== sizeof(val
), "len = %d\n", len
);
279 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECT_TIMEOUT
, &val
, &len
);
280 ok(res
, "InternetQueryOptionA failed %d)\n", GetLastError());
281 ok(val
== 12345, "val = %d\n", val
);
282 ok(len
== sizeof(val
), "len = %d\n", len
);
284 InternetCloseHandle(hinet
);
287 static void test_max_conns(void)
294 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
295 ok(res
,"Got wrong return value %x\n", res
);
296 ok(len
== sizeof(val
), "got %d\n", len
);
297 ok(val
== 2, "got %d\n", val
);
301 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
, &val
, &len
);
302 ok(res
,"Got wrong return value %x\n", res
);
303 ok(len
== sizeof(val
), "got %d\n", len
);
304 ok(val
== 4, "got %d\n", val
);
307 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
308 ok(res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res
);
312 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, &len
);
313 ok(res
,"Got wrong return value %x\n", res
);
314 ok(len
== sizeof(val
), "got %d\n", len
);
315 ok(val
== 3, "got %d\n", val
);
318 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
));
319 ok(!res
|| broken(res
), /* <= w2k3 */
320 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
321 if (!res
) ok(GetLastError() == ERROR_BAD_ARGUMENTS
, "GetLastError() = %u\n", GetLastError());
324 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)-1);
325 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
326 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
329 res
= InternetSetOptionA(NULL
, INTERNET_OPTION_MAX_CONNS_PER_SERVER
, &val
, sizeof(val
)+1);
330 ok(!res
, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
331 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %u\n", GetLastError());
334 static void test_get_cookie(void)
339 SetLastError(0xdeadbeef);
340 ret
= InternetGetCookie("http://www.example.com", NULL
, NULL
, &len
);
341 ok(!ret
&& GetLastError() == ERROR_NO_MORE_ITEMS
,
342 "InternetGetCookie should have failed with %s and error %d\n",
343 ret
? "TRUE" : "FALSE", GetLastError());
347 static void test_complicated_cookie(void)
354 ret
= InternetSetCookie("http://www.example.com/bar",NULL
,"A=B; domain=.example.com");
355 ok(ret
== TRUE
,"InternetSetCookie failed\n");
356 ret
= InternetSetCookie("http://www.example.com/bar",NULL
,"C=D; domain=.example.com; path=/");
357 ok(ret
== TRUE
,"InternetSetCookie failed\n");
359 /* Technically illegal! domain should require 2 dots, but native wininet accepts it */
360 ret
= InternetSetCookie("http://www.example.com",NULL
,"E=F; domain=example.com");
361 ok(ret
== TRUE
,"InternetSetCookie failed\n");
362 ret
= InternetSetCookie("http://www.example.com",NULL
,"G=H; domain=.example.com; path=/foo");
363 ok(ret
== TRUE
,"InternetSetCookie failed\n");
364 ret
= InternetSetCookie("http://www.example.com/bar.html",NULL
,"I=J; domain=.example.com");
365 ok(ret
== TRUE
,"InternetSetCookie failed\n");
366 ret
= InternetSetCookie("http://www.example.com/bar/",NULL
,"K=L; domain=.example.com");
367 ok(ret
== TRUE
,"InternetSetCookie failed\n");
368 ret
= InternetSetCookie("http://www.example.com/bar/",NULL
,"M=N; domain=.example.com; path=/foo/");
369 ok(ret
== TRUE
,"InternetSetCookie failed\n");
370 ret
= InternetSetCookie("http://www.example.com/bar/",NULL
,"O=P; secure; path=/bar");
371 ok(ret
== TRUE
,"InternetSetCookie failed\n");
374 ret
= InternetGetCookie("http://testing.example.com", NULL
, buffer
, &len
);
375 ok(ret
== TRUE
,"InternetGetCookie failed\n");
376 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
377 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
378 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
379 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
380 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
381 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
382 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
383 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
386 ret
= InternetGetCookie("http://testing.example.com/foobar", NULL
, buffer
, &len
);
387 ok(ret
== TRUE
,"InternetGetCookie failed\n");
388 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
389 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
390 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
391 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
392 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
393 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
394 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
395 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
398 ret
= InternetGetCookie("http://testing.example.com/foobar/", NULL
, buffer
, &len
);
399 ok(ret
== TRUE
,"InternetGetCookie failed\n");
400 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
401 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
402 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
403 ok(strstr(buffer
,"G=H")!=NULL
,"G=H missing\n");
404 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
405 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
406 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
407 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
410 ret
= InternetGetCookie("http://testing.example.com/foo/bar", NULL
, buffer
, &len
);
411 ok(ret
== TRUE
,"InternetGetCookie failed\n");
412 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
413 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
414 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
415 ok(strstr(buffer
,"G=H")!=NULL
,"G=H missing\n");
416 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
417 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
418 ok(strstr(buffer
,"M=N")!=NULL
,"M=N missing\n");
419 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
422 ret
= InternetGetCookie("http://testing.example.com/barfoo", NULL
, buffer
, &len
);
423 ok(ret
== TRUE
,"InternetGetCookie failed\n");
424 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
425 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
426 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
427 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
428 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
429 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
430 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
431 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
434 ret
= InternetGetCookie("http://testing.example.com/barfoo/", NULL
, buffer
, &len
);
435 ok(ret
== TRUE
,"InternetGetCookie failed\n");
436 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
437 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
438 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
439 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
440 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
441 ok(strstr(buffer
,"K=L")==NULL
,"K=L present\n");
442 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
443 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
446 ret
= InternetGetCookie("http://testing.example.com/bar/foo", NULL
, buffer
, &len
);
447 ok(ret
== TRUE
,"InternetGetCookie failed\n");
448 ok(strstr(buffer
,"A=B")!=NULL
,"A=B missing\n");
449 ok(strstr(buffer
,"C=D")!=NULL
,"C=D missing\n");
450 ok(strstr(buffer
,"E=F")!=NULL
,"E=F missing\n");
451 ok(strstr(buffer
,"G=H")==NULL
,"G=H present\n");
452 ok(strstr(buffer
,"I=J")!=NULL
,"I=J missing\n");
453 ok(strstr(buffer
,"K=L")!=NULL
,"K=L missing\n");
454 ok(strstr(buffer
,"M=N")==NULL
,"M=N present\n");
455 ok(strstr(buffer
,"O=P")==NULL
,"O=P present\n");
458 static void test_null(void)
461 static const WCHAR szServer
[] = { 's','e','r','v','e','r',0 };
462 static const WCHAR szEmpty
[] = { 0 };
463 static const WCHAR szUrl
[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
464 static const WCHAR szUrlEmpty
[] = { 'h','t','t','p',':','/','/',0 };
465 static const WCHAR szExpect
[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
470 SetLastError(0xdeadbeef);
471 hi
= InternetOpenW(NULL
, 0, NULL
, NULL
, 0);
472 if (hi
== NULL
&& GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
474 win_skip("Internet*W functions are not implemented\n");
477 ok(hi
!= NULL
, "open failed\n");
479 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, 0, 0, 0);
480 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
481 ok(hc
== NULL
, "connect failed\n");
483 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
484 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
485 ok(hc
== NULL
, "connect failed\n");
487 hc
= InternetConnectW(hi
, NULL
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
488 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
489 ok(hc
== NULL
, "connect failed\n");
491 hc
= InternetConnectW(NULL
, szServer
, 0, NULL
, NULL
, INTERNET_SERVICE_FTP
, 0, 0);
492 ok(GetLastError() == ERROR_INVALID_HANDLE
, "wrong error\n");
493 ok(hc
== NULL
, "connect failed\n");
495 hc
= InternetOpenUrlW(hi
, NULL
, NULL
, 0, 0, 0);
496 ok(GetLastError() == ERROR_INVALID_PARAMETER
||
497 GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
498 ok(hc
== NULL
, "connect failed\n");
500 hc
= InternetOpenUrlW(hi
, szServer
, NULL
, 0, 0, 0);
501 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
502 ok(hc
== NULL
, "connect failed\n");
504 InternetCloseHandle(hi
);
506 r
= InternetSetCookieW(NULL
, NULL
, NULL
);
507 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
508 ok(r
== FALSE
, "return wrong\n");
510 r
= InternetSetCookieW(szServer
, NULL
, NULL
);
511 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
512 ok(r
== FALSE
, "return wrong\n");
514 r
= InternetSetCookieW(szUrl
, szServer
, NULL
);
515 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error\n");
516 ok(r
== FALSE
, "return wrong\n");
518 r
= InternetSetCookieW(szUrl
, szServer
, szServer
);
519 ok(r
== TRUE
, "return wrong\n");
521 r
= InternetSetCookieW(szUrl
, NULL
, szServer
);
522 ok(r
== TRUE
, "return wrong\n");
524 r
= InternetSetCookieW(szUrl
, szServer
, szEmpty
);
525 ok(r
== TRUE
, "return wrong\n");
527 r
= InternetSetCookieW(szUrlEmpty
, szServer
, szServer
);
528 ok(r
== FALSE
, "return wrong\n");
530 r
= InternetSetCookieW(szServer
, NULL
, szServer
);
532 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
534 ok(r
== FALSE
, "return wrong\n");
537 r
= InternetGetCookieW(NULL
, NULL
, NULL
, &sz
);
538 ok(GetLastError() == ERROR_INVALID_PARAMETER
|| GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
,
539 "wrong error %u\n", GetLastError());
540 ok( r
== FALSE
, "return wrong\n");
542 r
= InternetGetCookieW(szServer
, NULL
, NULL
, &sz
);
544 ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME
, "wrong error\n");
546 ok( r
== FALSE
, "return wrong\n");
549 r
= InternetGetCookieW(szUrlEmpty
, szServer
, NULL
, &sz
);
550 ok( r
== FALSE
, "return wrong\n");
553 r
= InternetGetCookieW(szUrl
, szServer
, NULL
, &sz
);
554 ok( r
== TRUE
, "return wrong\n");
556 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before */
557 ok( sz
== 14 || sz
== 30, "sz wrong, got %u, expected 14 or 30\n", sz
);
560 memset(buffer
, 0, sizeof buffer
);
561 r
= InternetGetCookieW(szUrl
, szServer
, buffer
, &sz
);
562 ok( r
== TRUE
, "return wrong\n");
564 /* sz == lstrlenW(buffer) only in XP SP1 */
565 ok( sz
== 1 + lstrlenW(buffer
) || sz
== lstrlenW(buffer
), "sz wrong %d\n", sz
);
567 /* before XP SP2, buffer is "server; server" */
568 ok( !lstrcmpW(szExpect
, buffer
) || !lstrcmpW(szServer
, buffer
), "cookie data wrong\n");
571 r
= InternetQueryOptionA(NULL
, INTERNET_OPTION_CONNECTED_STATE
, buffer
, &sz
);
572 ok(r
== TRUE
, "ret %d\n", r
);
575 static void test_version(void)
577 INTERNET_VERSION_INFO version
;
581 size
= sizeof(version
);
582 res
= InternetQueryOptionA(NULL
, INTERNET_OPTION_VERSION
, &version
, &size
);
583 ok(res
, "Could not get version: %u\n", GetLastError());
584 ok(version
.dwMajorVersion
== 1, "dwMajorVersion=%d, expected 1\n", version
.dwMajorVersion
);
585 ok(version
.dwMinorVersion
== 2, "dwMinorVersion=%d, expected 2\n", version
.dwMinorVersion
);
588 static void InternetTimeFromSystemTimeA_test(void)
591 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
592 char string
[INTERNET_RFC1123_BUFSIZE
];
593 static const char expect
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
596 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
597 ok( ret
, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
599 ok( !memcmp( string
, expect
, sizeof(expect
) ),
600 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
602 /* test NULL time parameter */
603 SetLastError(0xdeadbeef);
604 ret
= pInternetTimeFromSystemTimeA( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
605 error
= GetLastError();
606 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
607 ok( error
== ERROR_INVALID_PARAMETER
,
608 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
611 /* test NULL string parameter */
612 SetLastError(0xdeadbeef);
613 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
614 error
= GetLastError();
615 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
616 ok( error
== ERROR_INVALID_PARAMETER
,
617 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
620 /* test invalid format parameter */
621 SetLastError(0xdeadbeef);
622 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
623 error
= GetLastError();
624 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
625 ok( error
== ERROR_INVALID_PARAMETER
,
626 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
629 /* test too small buffer size */
630 SetLastError(0xdeadbeef);
631 ret
= pInternetTimeFromSystemTimeA( &time
, INTERNET_RFC1123_FORMAT
, string
, 0 );
632 error
= GetLastError();
633 ok( !ret
, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
634 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
635 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
639 static void InternetTimeFromSystemTimeW_test(void)
642 static const SYSTEMTIME time
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
643 WCHAR string
[INTERNET_RFC1123_BUFSIZE
+ 1];
644 static const WCHAR expect
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
645 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
648 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
649 ok( ret
, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
651 ok( !memcmp( string
, expect
, sizeof(expect
) ),
652 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
654 /* test NULL time parameter */
655 SetLastError(0xdeadbeef);
656 ret
= pInternetTimeFromSystemTimeW( NULL
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
) );
657 error
= GetLastError();
658 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
659 ok( error
== ERROR_INVALID_PARAMETER
,
660 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
663 /* test NULL string parameter */
664 SetLastError(0xdeadbeef);
665 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, NULL
, sizeof(string
) );
666 error
= GetLastError();
667 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
668 ok( error
== ERROR_INVALID_PARAMETER
,
669 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
672 /* test invalid format parameter */
673 SetLastError(0xdeadbeef);
674 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
+ 1, string
, sizeof(string
) );
675 error
= GetLastError();
676 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
677 ok( error
== ERROR_INVALID_PARAMETER
,
678 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
681 /* test too small buffer size */
682 SetLastError(0xdeadbeef);
683 ret
= pInternetTimeFromSystemTimeW( &time
, INTERNET_RFC1123_FORMAT
, string
, sizeof(string
)/sizeof(string
[0]) );
684 error
= GetLastError();
685 ok( !ret
, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
686 ok( error
== ERROR_INSUFFICIENT_BUFFER
,
687 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
691 static void InternetTimeToSystemTimeA_test(void)
695 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
696 static const char string
[] = "Fri, 07 Jan 2005 12:06:35 GMT";
697 static const char string2
[] = " fri 7 jan 2005 12 06 35";
699 ret
= pInternetTimeToSystemTimeA( string
, &time
, 0 );
700 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
701 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
702 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
704 ret
= pInternetTimeToSystemTimeA( string2
, &time
, 0 );
705 ok( ret
, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
706 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
707 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
710 static void InternetTimeToSystemTimeW_test(void)
714 static const SYSTEMTIME expect
= { 2005, 1, 5, 7, 12, 6, 35, 0 };
715 static const WCHAR string
[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
716 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
717 static const WCHAR string2
[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
718 '1','2',' ','0','6',' ','3','5',0 };
719 static const WCHAR string3
[] = { 'F','r',0 };
721 ret
= pInternetTimeToSystemTimeW( NULL
, NULL
, 0 );
722 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
724 ret
= pInternetTimeToSystemTimeW( NULL
, &time
, 0 );
725 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
727 ret
= pInternetTimeToSystemTimeW( string
, NULL
, 0 );
728 ok( !ret
, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
730 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
731 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
733 ret
= pInternetTimeToSystemTimeW( string
, &time
, 0 );
734 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
735 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
736 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
738 ret
= pInternetTimeToSystemTimeW( string2
, &time
, 0 );
739 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
740 ok( !memcmp( &time
, &expect
, sizeof(expect
) ),
741 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
743 ret
= pInternetTimeToSystemTimeW( string3
, &time
, 0 );
744 ok( ret
, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
747 static void test_IsDomainLegalCookieDomainW(void)
751 static const WCHAR empty
[] = {0};
752 static const WCHAR dot
[] = {'.',0};
753 static const WCHAR uk
[] = {'u','k',0};
754 static const WCHAR com
[] = {'c','o','m',0};
755 static const WCHAR dot_com
[] = {'.','c','o','m',0};
756 static const WCHAR gmail_com
[] = {'g','m','a','i','l','.','c','o','m',0};
757 static const WCHAR dot_gmail_com
[] = {'.','g','m','a','i','l','.','c','o','m',0};
758 static const WCHAR mail_gmail_com
[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
759 static const WCHAR gmail_co_uk
[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
760 static const WCHAR co_uk
[] = {'c','o','.','u','k',0};
761 static const WCHAR dot_co_uk
[] = {'.','c','o','.','u','k',0};
763 SetLastError(0xdeadbeef);
764 ret
= pIsDomainLegalCookieDomainW(NULL
, NULL
);
765 error
= GetLastError();
766 if (!ret
&& error
== ERROR_CALL_NOT_IMPLEMENTED
)
768 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
772 broken(ret
), /* IE6 */
773 "IsDomainLegalCookieDomainW succeeded\n");
774 ok(error
== ERROR_INVALID_PARAMETER
, "got %u expected ERROR_INVALID_PARAMETER\n", error
);
776 SetLastError(0xdeadbeef);
777 ret
= pIsDomainLegalCookieDomainW(com
, NULL
);
778 error
= GetLastError();
779 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
780 ok(error
== ERROR_INVALID_PARAMETER
, "got %u expected ERROR_INVALID_PARAMETER\n", error
);
782 SetLastError(0xdeadbeef);
783 ret
= pIsDomainLegalCookieDomainW(NULL
, gmail_com
);
784 error
= GetLastError();
785 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
786 ok(error
== ERROR_INVALID_PARAMETER
, "got %u expected ERROR_INVALID_PARAMETER\n", error
);
788 SetLastError(0xdeadbeef);
789 ret
= pIsDomainLegalCookieDomainW(empty
, gmail_com
);
790 error
= GetLastError();
791 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
792 ok(error
== ERROR_INVALID_NAME
||
793 broken(error
== ERROR_INVALID_PARAMETER
), /* IE6 */
794 "got %u expected ERROR_INVALID_NAME\n", error
);
796 SetLastError(0xdeadbeef);
797 ret
= pIsDomainLegalCookieDomainW(com
, empty
);
798 error
= GetLastError();
799 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
800 ok(error
== ERROR_INVALID_NAME
||
801 broken(error
== ERROR_INVALID_PARAMETER
), /* IE6 */
802 "got %u expected ERROR_INVALID_NAME\n", error
);
804 SetLastError(0xdeadbeef);
805 ret
= pIsDomainLegalCookieDomainW(gmail_com
, dot
);
806 error
= GetLastError();
807 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
808 ok(error
== ERROR_INVALID_NAME
||
809 broken(error
== 0xdeadbeef), /* IE6 */
810 "got %u expected ERROR_INVALID_NAME\n", error
);
812 SetLastError(0xdeadbeef);
813 ret
= pIsDomainLegalCookieDomainW(dot
, gmail_com
);
814 error
= GetLastError();
815 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
816 ok(error
== ERROR_INVALID_NAME
||
817 broken(error
== 0xdeadbeef), /* IE6 */
818 "got %u expected ERROR_INVALID_NAME\n", error
);
820 SetLastError(0xdeadbeef);
821 ret
= pIsDomainLegalCookieDomainW(com
, com
);
822 error
= GetLastError();
823 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
824 ok(error
== 0xdeadbeef, "got %u expected 0xdeadbeef\n", error
);
826 SetLastError(0xdeadbeef);
827 ret
= pIsDomainLegalCookieDomainW(com
, dot_com
);
828 error
= GetLastError();
829 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
830 ok(error
== ERROR_INVALID_NAME
||
831 broken(error
== 0xdeadbeef), /* IE6 */
832 "got %u expected ERROR_INVALID_NAME\n", error
);
834 SetLastError(0xdeadbeef);
835 ret
= pIsDomainLegalCookieDomainW(dot_com
, com
);
836 error
= GetLastError();
837 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
838 ok(error
== ERROR_INVALID_NAME
||
839 broken(error
== 0xdeadbeef), /* IE6 */
840 "got %u expected ERROR_INVALID_NAME\n", error
);
842 SetLastError(0xdeadbeef);
843 ret
= pIsDomainLegalCookieDomainW(com
, gmail_com
);
844 error
= GetLastError();
845 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
846 ok(error
== ERROR_SXS_KEY_NOT_FOUND
||
847 error
== ERROR_SUCCESS
|| /* IE8 on W2K3 */
848 error
== 0xdeadbeef, /* up to IE7 */
849 "unexpected error: %u\n", error
);
851 ret
= pIsDomainLegalCookieDomainW(gmail_com
, gmail_com
);
852 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
854 SetLastError(0xdeadbeef);
855 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, co_uk
);
856 error
= GetLastError();
857 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
858 ok(error
== ERROR_SXS_KEY_NOT_FOUND
|| /* IE8 on XP */
859 error
== ERROR_FILE_NOT_FOUND
|| /* IE8 on Vista */
860 error
== ERROR_SUCCESS
|| /* IE8 on W2K3 */
861 error
== 0xdeadbeef, /* up to IE7 */
862 "unexpected error: %u\n", error
);
864 ret
= pIsDomainLegalCookieDomainW(uk
, co_uk
);
865 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
867 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, dot_co_uk
);
868 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
870 ret
= pIsDomainLegalCookieDomainW(gmail_co_uk
, gmail_co_uk
);
871 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
873 ret
= pIsDomainLegalCookieDomainW(gmail_com
, com
);
874 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
876 SetLastError(0xdeadbeef);
877 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
878 error
= GetLastError();
879 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
880 ok(error
== ERROR_INVALID_NAME
||
881 broken(error
== 0xdeadbeef), /* IE6 */
882 "got %u expected ERROR_INVALID_NAME\n", error
);
884 ret
= pIsDomainLegalCookieDomainW(gmail_com
, mail_gmail_com
);
885 ok(ret
, "IsDomainLegalCookieDomainW failed\n");
887 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, gmail_com
);
888 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
890 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, com
);
891 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
893 ret
= pIsDomainLegalCookieDomainW(dot_gmail_com
, mail_gmail_com
);
894 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
896 ret
= pIsDomainLegalCookieDomainW(mail_gmail_com
, dot_gmail_com
);
897 ok(!ret
, "IsDomainLegalCookieDomainW succeeded\n");
900 static void test_PrivacyGetSetZonePreferenceW(void)
902 DWORD ret
, zone
, type
, template, old_template
;
906 ret
= pPrivacyGetZonePreferenceW(zone
, type
, NULL
, NULL
, NULL
);
907 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
910 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &old_template
, NULL
, NULL
);
911 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
914 ret
= pPrivacySetZonePreferenceW(zone
, type
, template, NULL
);
915 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
918 ret
= pPrivacyGetZonePreferenceW(zone
, type
, &template, NULL
, NULL
);
919 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
920 ok(template == 5, "expected template == 5, got %u\n", template);
923 ret
= pPrivacySetZonePreferenceW(zone
, type
, old_template
, NULL
);
924 ok(ret
== 0, "expected ret == 0, got %u\n", ret
);
927 static void test_InternetSetOption(void)
929 HINTERNET ses
, con
, req
;
934 ses
= InternetOpen(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
935 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
936 con
= InternetConnect(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
937 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
938 req
= HttpOpenRequest(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
939 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
941 /* INTERNET_OPTION_POLICY tests */
942 SetLastError(0xdeadbeef);
943 ret
= InternetSetOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
944 ok(ret
== FALSE
, "InternetSetOption should've failed\n");
945 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
946 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
948 SetLastError(0xdeadbeef);
949 ret
= InternetQueryOptionW(ses
, INTERNET_OPTION_POLICY
, NULL
, 0);
950 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
951 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError should've "
952 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
954 /* INTERNET_OPTION_ERROR_MASK tests */
955 SetLastError(0xdeadbeef);
956 size
= sizeof(ulArg
);
957 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, &size
);
958 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
959 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
961 SetLastError(0xdeadbeef);
963 ret
= InternetSetOption(NULL
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
964 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
965 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE
, "GetLastError() = %x\n", GetLastError());
967 SetLastError(0xdeadbeef);
969 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, 20);
970 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
971 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH
, "GetLastError() = %d\n", GetLastError());
973 SetLastError(0xdeadbeef);
975 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
976 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
977 ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
979 SetLastError(0xdeadbeef);
981 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
982 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
983 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
985 SetLastError(0xdeadbeef);
987 ret
= InternetSetOption(req
, INTERNET_OPTION_ERROR_MASK
, (void*)&ulArg
, sizeof(ULONG
));
988 ok(ret
== FALSE
, "InternetQueryOption should've failed\n");
989 ok(GetLastError() == ERROR_INVALID_PARAMETER
, "GetLastError() = %x\n", GetLastError());
991 ret
= InternetCloseHandle(req
);
992 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
993 ret
= InternetCloseHandle(con
);
994 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
995 ret
= InternetCloseHandle(ses
);
996 ok(ret
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
999 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1000 static void r_verifyProxyEnable(LONG l
, DWORD exp
)
1003 DWORD type
, val
, size
= sizeof(DWORD
);
1005 static const CHAR szInternetSettings
[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1006 static const CHAR szProxyEnable
[] = "ProxyEnable";
1008 ret
= RegOpenKeyA(HKEY_CURRENT_USER
, szInternetSettings
, &hkey
);
1009 ok_(__FILE__
,l
) (!ret
, "RegOpenKeyA failed: 0x%08x\n", ret
);
1011 ret
= RegQueryValueExA(hkey
, szProxyEnable
, 0, &type
, (BYTE
*)&val
, &size
);
1012 ok_(__FILE__
,l
) (!ret
, "RegQueryValueExA failed: 0x%08x\n", ret
);
1013 ok_(__FILE__
,l
) (type
== REG_DWORD
, "Expected regtype to be REG_DWORD, was: %d\n", type
);
1014 ok_(__FILE__
,l
) (val
== exp
, "Expected ProxyEnabled to be %d, got: %d\n", exp
, val
);
1016 ret
= RegCloseKey(hkey
);
1017 ok_(__FILE__
,l
) (!ret
, "RegCloseKey failed: 0x%08x\n", ret
);
1020 static void test_Option_PerConnectionOption(void)
1023 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
1024 INTERNET_PER_CONN_OPTION_LISTW list
= {size
};
1025 INTERNET_PER_CONN_OPTIONW
*orig_settings
;
1026 static WCHAR proxy_srvW
[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1028 /* get the global IE proxy server info, to restore later */
1029 list
.dwOptionCount
= 2;
1030 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1032 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1033 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1035 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1037 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1038 orig_settings
= list
.pOptions
;
1040 /* set the global IE proxy server */
1041 list
.dwOptionCount
= 2;
1042 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1044 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1045 list
.pOptions
[0].Value
.pszValue
= proxy_srvW
;
1046 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1047 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1049 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1051 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1053 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1055 /* get & verify the global IE proxy server */
1056 list
.dwOptionCount
= 2;
1057 list
.dwOptionError
= 0;
1058 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW
));
1060 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1061 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1063 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1065 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1066 ok(!lstrcmpW(list
.pOptions
[0].Value
.pszValue
, proxy_srvW
),
1067 "Retrieved proxy server should've been %s, was: %s\n",
1068 wine_dbgstr_w(proxy_srvW
), wine_dbgstr_w(list
.pOptions
[0].Value
.pszValue
));
1069 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1070 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1071 list
.pOptions
[1].Value
.dwValue
);
1072 verifyProxyEnable(1);
1074 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1075 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1077 /* disable the proxy server */
1078 list
.dwOptionCount
= 1;
1079 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1081 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1082 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_DIRECT
;
1084 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1086 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1088 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1090 /* verify that the proxy is disabled */
1091 list
.dwOptionCount
= 1;
1092 list
.dwOptionError
= 0;
1093 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1095 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1097 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1099 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1100 ok(list
.pOptions
[0].Value
.dwValue
== PROXY_TYPE_DIRECT
,
1101 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1102 list
.pOptions
[0].Value
.dwValue
);
1103 verifyProxyEnable(0);
1105 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1107 /* set the proxy flags to 'invalid' value */
1108 list
.dwOptionCount
= 1;
1109 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1111 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1112 list
.pOptions
[0].Value
.dwValue
= PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
;
1114 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1116 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1118 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1120 /* verify that the proxy is enabled */
1121 list
.dwOptionCount
= 1;
1122 list
.dwOptionError
= 0;
1123 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
));
1125 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_FLAGS
;
1127 ret
= InternetQueryOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1129 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1130 todo_wine
ok(list
.pOptions
[0].Value
.dwValue
== (PROXY_TYPE_PROXY
| PROXY_TYPE_DIRECT
),
1131 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1132 list
.pOptions
[0].Value
.dwValue
);
1133 verifyProxyEnable(1);
1135 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1137 /* restore original settings */
1138 list
.dwOptionCount
= 2;
1139 list
.pOptions
= orig_settings
;
1141 ret
= InternetSetOptionW(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1143 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1145 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1148 static void test_Option_PerConnectionOptionA(void)
1151 DWORD size
= sizeof(INTERNET_PER_CONN_OPTION_LISTA
);
1152 INTERNET_PER_CONN_OPTION_LISTA list
= {size
};
1153 INTERNET_PER_CONN_OPTIONA
*orig_settings
;
1154 char proxy_srv
[] = "proxy.example";
1156 /* get the global IE proxy server info, to restore later */
1157 list
.dwOptionCount
= 2;
1158 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1160 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1161 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1163 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1165 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1166 orig_settings
= list
.pOptions
;
1168 /* set the global IE proxy server */
1169 list
.dwOptionCount
= 2;
1170 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1172 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1173 list
.pOptions
[0].Value
.pszValue
= proxy_srv
;
1174 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1175 list
.pOptions
[1].Value
.dwValue
= PROXY_TYPE_PROXY
;
1177 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1179 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1181 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1183 /* get & verify the global IE proxy server */
1184 list
.dwOptionCount
= 2;
1185 list
.dwOptionError
= 0;
1186 list
.pOptions
= HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA
));
1188 list
.pOptions
[0].dwOption
= INTERNET_PER_CONN_PROXY_SERVER
;
1189 list
.pOptions
[1].dwOption
= INTERNET_PER_CONN_FLAGS
;
1191 ret
= InternetQueryOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1193 ok(ret
== TRUE
, "InternetQueryOption should've succeeded\n");
1194 ok(!lstrcmpA(list
.pOptions
[0].Value
.pszValue
, "proxy.example"),
1195 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1196 proxy_srv
, list
.pOptions
[0].Value
.pszValue
);
1197 ok(list
.pOptions
[1].Value
.dwValue
== PROXY_TYPE_PROXY
,
1198 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1199 list
.pOptions
[1].Value
.dwValue
);
1201 HeapFree(GetProcessHeap(), 0, list
.pOptions
[0].Value
.pszValue
);
1202 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1204 /* restore original settings */
1205 list
.dwOptionCount
= 2;
1206 list
.pOptions
= orig_settings
;
1208 ret
= InternetSetOptionA(NULL
, INTERNET_OPTION_PER_CONNECTION_OPTION
,
1210 ok(ret
== TRUE
, "InternetSetOption should've succeeded\n");
1212 HeapFree(GetProcessHeap(), 0, list
.pOptions
);
1215 #define FLAG_TODO 0x1
1216 #define FLAG_NEEDREQ 0x2
1217 #define FLAG_UNIMPL 0x4
1219 static void test_InternetErrorDlg(void)
1221 HINTERNET ses
, con
, req
;
1225 static const struct {
1230 { ERROR_INTERNET_INCORRECT_PASSWORD
, ERROR_SUCCESS
, FLAG_NEEDREQ
},
1231 { ERROR_INTERNET_SEC_CERT_DATE_INVALID
, ERROR_CANCELLED
, 0 },
1232 { ERROR_INTERNET_SEC_CERT_CN_INVALID
, ERROR_CANCELLED
, 0 },
1233 { ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
, ERROR_SUCCESS
, 0 },
1234 { ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
, ERROR_SUCCESS
, FLAG_TODO
},
1235 { ERROR_INTERNET_MIXED_SECURITY
, ERROR_CANCELLED
, FLAG_TODO
},
1236 { ERROR_INTERNET_CHG_POST_IS_NON_SECURE
, ERROR_CANCELLED
, FLAG_TODO
},
1237 { ERROR_INTERNET_POST_IS_NON_SECURE
, ERROR_SUCCESS
, 0 },
1238 { ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
, ERROR_CANCELLED
, FLAG_NEEDREQ
|FLAG_TODO
},
1239 { ERROR_INTERNET_INVALID_CA
, ERROR_CANCELLED
, 0 },
1240 { ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
, ERROR_CANCELLED
, FLAG_TODO
},
1241 { ERROR_INTERNET_INSERT_CDROM
, ERROR_CANCELLED
, FLAG_TODO
|FLAG_NEEDREQ
|FLAG_UNIMPL
},
1242 { ERROR_INTERNET_SEC_CERT_ERRORS
, ERROR_CANCELLED
, 0 },
1243 { ERROR_INTERNET_SEC_CERT_REV_FAILED
, ERROR_CANCELLED
, FLAG_TODO
},
1244 { ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
, ERROR_HTTP_COOKIE_DECLINED
, FLAG_TODO
},
1245 { ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1246 { ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
, ERROR_CANCELLED
, FLAG_TODO
},
1247 { ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
, ERROR_CANCELLED
, FLAG_TODO
},
1248 { ERROR_INTERNET_SEC_CERT_REVOKED
, ERROR_CANCELLED
, 0 },
1249 { 0, ERROR_NOT_SUPPORTED
}
1254 res
= InternetErrorDlg(NULL
, NULL
, 12055, flags
, NULL
);
1255 ok(res
== ERROR_INVALID_HANDLE
, "Got %d\n", res
);
1257 ses
= InternetOpen(NULL
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
1258 ok(ses
!= 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1259 con
= InternetConnect(ses
, "www.winehq.org", 80, NULL
, NULL
, INTERNET_SERVICE_HTTP
, 0, 0);
1260 ok(con
!= 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1261 req
= HttpOpenRequest(con
, "GET", "/", NULL
, NULL
, NULL
, 0, 0);
1262 ok(req
!= 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1264 /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1265 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1267 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1268 ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1271 hwnd
= GetDesktopWindow();
1272 ok(hwnd
!= NULL
, "GetDesktopWindow failed (%d)\n", GetLastError());
1274 flags
= FLAGS_ERROR_UI_FLAGS_NO_UI
;
1275 for(i
= INTERNET_ERROR_BASE
; i
< INTERNET_ERROR_LAST
; i
++)
1277 DWORD expected
, test_flags
, j
;
1279 for(j
= 0; no_ui_res
[j
].error
!= 0; ++j
)
1280 if(no_ui_res
[j
].error
== i
)
1283 test_flags
= no_ui_res
[j
].test_flags
;
1284 expected
= no_ui_res
[j
].res
;
1286 /* Try an invalid request handle */
1287 res
= InternetErrorDlg(hwnd
, (HANDLE
)0xdeadbeef, i
, flags
, NULL
);
1288 if(res
== ERROR_CALL_NOT_IMPLEMENTED
)
1290 todo_wine
ok(test_flags
& FLAG_UNIMPL
, "%i is unexpectedly unimplemented.\n", i
);
1294 todo_wine
ok(res
== ERROR_INVALID_HANDLE
, "Got %d (%d)\n", res
, i
);
1296 /* With a valid req */
1297 if(i
== ERROR_INTERNET_NEED_UI
)
1298 continue; /* Crashes on windows XP */
1300 if(i
== ERROR_INTERNET_SEC_CERT_REVOKED
)
1301 continue; /* Interactive (XP, Win7) */
1303 res
= InternetErrorDlg(hwnd
, req
, i
, flags
, NULL
);
1305 /* Handle some special cases */
1308 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
:
1309 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
:
1310 if(res
== ERROR_CANCELLED
)
1312 /* Some windows XP, w2k3 x64, W2K8 */
1313 win_skip("Skipping some tests for %d\n", i
);
1317 case ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
:
1320 /* Windows XP, W2K3 */
1321 ok(res
== NTE_PROV_TYPE_NOT_DEF
, "Got %d\n", res
);
1322 win_skip("Skipping some tests for %d\n", i
);
1329 if(test_flags
& FLAG_TODO
)
1330 todo_wine
ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1332 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1334 /* Same thing with NULL hwnd */
1335 res
= InternetErrorDlg(NULL
, req
, i
, flags
, NULL
);
1336 if(test_flags
& FLAG_TODO
)
1337 todo_wine
ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1339 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1342 /* With a null req */
1343 if(test_flags
& FLAG_NEEDREQ
)
1344 expected
= ERROR_INVALID_PARAMETER
;
1346 res
= InternetErrorDlg(hwnd
, NULL
, i
, flags
, NULL
);
1347 if( test_flags
& FLAG_TODO
|| i
== ERROR_INTERNET_INCORRECT_PASSWORD
)
1348 todo_wine
ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1350 ok(res
== expected
, "Got %d, expected %d (%d)\n", res
, expected
, i
);
1353 res
= InternetCloseHandle(req
);
1354 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1355 res
= InternetCloseHandle(con
);
1356 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1357 res
= InternetCloseHandle(ses
);
1358 ok(res
== TRUE
, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1361 /* ############################### */
1363 START_TEST(internet
)
1366 hdll
= GetModuleHandleA("wininet.dll");
1368 if(!GetProcAddress(hdll
, "InternetGetCookieExW")) {
1369 win_skip("Too old IE (older than 6.0)\n");
1373 pCreateUrlCacheContainerA
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerA");
1374 pCreateUrlCacheContainerW
= (void*)GetProcAddress(hdll
, "CreateUrlCacheContainerW");
1375 pInternetTimeFromSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeA");
1376 pInternetTimeFromSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeFromSystemTimeW");
1377 pInternetTimeToSystemTimeA
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeA");
1378 pInternetTimeToSystemTimeW
= (void*)GetProcAddress(hdll
, "InternetTimeToSystemTimeW");
1379 pIsDomainLegalCookieDomainW
= (void*)GetProcAddress(hdll
, (LPCSTR
)117);
1380 pPrivacyGetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacyGetZonePreferenceW");
1381 pPrivacySetZonePreferenceW
= (void*)GetProcAddress(hdll
, "PrivacySetZonePreferenceW");
1383 test_InternetCanonicalizeUrlA();
1384 test_InternetQueryOptionA();
1386 test_complicated_cookie();
1389 test_Option_PerConnectionOption();
1390 test_Option_PerConnectionOptionA();
1391 test_InternetErrorDlg();
1394 if (!pInternetTimeFromSystemTimeA
)
1395 win_skip("skipping the InternetTime tests\n");
1398 InternetTimeFromSystemTimeA_test();
1399 InternetTimeFromSystemTimeW_test();
1400 InternetTimeToSystemTimeA_test();
1401 InternetTimeToSystemTimeW_test();
1403 if (pIsDomainLegalCookieDomainW
&&
1404 ((void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerA
||
1405 (void*)pIsDomainLegalCookieDomainW
== (void*)pCreateUrlCacheContainerW
))
1406 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1407 else if (!pIsDomainLegalCookieDomainW
)
1408 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1410 test_IsDomainLegalCookieDomainW();
1412 if (pPrivacyGetZonePreferenceW
&& pPrivacySetZonePreferenceW
)
1413 test_PrivacyGetSetZonePreferenceW();
1415 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1417 test_InternetSetOption();