ReactOS  0.4.14-dev-49-gfb4591c
internet.c
Go to the documentation of this file.
1 /*
2  * Wininet - internet tests
3  *
4  * Copyright 2005 Vijay Kiran Kamuju
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "wininet.h"
28 #include "winerror.h"
29 #include "winreg.h"
30 
31 #include "wine/test.h"
32 
33 static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD, DWORD, DWORD, DWORD,
34  DWORD, DWORD, DWORD, DWORD);
35 static BOOL (WINAPI *pCreateUrlCacheContainerW)(DWORD, DWORD, DWORD, DWORD,
36  DWORD, DWORD, DWORD, DWORD);
37 static BOOL (WINAPI *pInternetTimeFromSystemTimeA)(const SYSTEMTIME *, DWORD, LPSTR, DWORD);
38 static BOOL (WINAPI *pInternetTimeFromSystemTimeW)(const SYSTEMTIME *, DWORD, LPWSTR, DWORD);
39 static BOOL (WINAPI *pInternetTimeToSystemTimeA)(LPCSTR ,SYSTEMTIME *,DWORD);
40 static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
41 static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
42 static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
43 static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
44 static BOOL (WINAPI *pInternetGetCookieExA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD,LPVOID);
45 static BOOL (WINAPI *pInternetGetCookieExW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD,LPVOID);
46 static BOOL (WINAPI *pInternetGetConnectedStateExA)(LPDWORD,LPSTR,DWORD,DWORD);
47 static BOOL (WINAPI *pInternetGetConnectedStateExW)(LPDWORD,LPWSTR,DWORD,DWORD);
48 
49 /* ############################### */
50 
52 {
53  CHAR buffer[256];
54  LPCSTR url;
55  DWORD urllen;
56  DWORD dwSize;
57  DWORD res;
58 
59  /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
60  url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
61  urllen = lstrlenA(url);
62 
63  memset(buffer, '#', sizeof(buffer)-1);
64  buffer[sizeof(buffer)-1] = '\0';
65  dwSize = 1; /* Acrobat Updater use this size */
66  SetLastError(0xdeadbeef);
68  ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
69  "got %u and %u with size %u for '%s' (%d)\n",
71 
72 
73  /* buffer has no space for the terminating '\0' */
74  memset(buffer, '#', sizeof(buffer)-1);
75  buffer[sizeof(buffer)-1] = '\0';
76  dwSize = urllen;
77  SetLastError(0xdeadbeef);
79  /* dwSize is nr. of needed bytes with the terminating '\0' */
80  ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
81  "got %u and %u with size %u for '%s' (%d)\n",
83 
84  /* buffer has the required size */
85  memset(buffer, '#', sizeof(buffer)-1);
86  buffer[sizeof(buffer)-1] = '\0';
87  dwSize = urllen+1;
88  SetLastError(0xdeadbeef);
90  /* dwSize is nr. of copied bytes without the terminating '\0' */
91  ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
92  "got %u and %u with size %u for '%s' (%d)\n",
94 
95  memset(buffer, '#', sizeof(buffer)-1);
96  buffer[sizeof(buffer)-1] = '\0';
97  dwSize = sizeof(buffer);
98  SetLastError(0xdeadbeef);
99  res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
100  ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
101  ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
102  ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
103  "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
104 
105  /* buffer is larger as the required size */
106  memset(buffer, '#', sizeof(buffer)-1);
107  buffer[sizeof(buffer)-1] = '\0';
108  dwSize = urllen+2;
109  SetLastError(0xdeadbeef);
111  /* dwSize is nr. of copied bytes without the terminating '\0' */
112  ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
113  "got %u and %u with size %u for '%s' (%d)\n",
115 
116 
117  /* check NULL pointers */
118  memset(buffer, '#', urllen + 4);
119  buffer[urllen + 4] = '\0';
120  dwSize = urllen+1;
121  SetLastError(0xdeadbeef);
124  "got %u and %u with size %u for '%s' (%d)\n",
126 
127  memset(buffer, '#', urllen + 4);
128  buffer[urllen + 4] = '\0';
129  dwSize = urllen+1;
130  SetLastError(0xdeadbeef);
133  "got %u and %u with size %u for '%s' (%d)\n",
135 
136  memset(buffer, '#', urllen + 4);
137  buffer[urllen + 4] = '\0';
138  dwSize = urllen+1;
139  SetLastError(0xdeadbeef);
142  "got %u and %u with size %u for '%s' (%d)\n",
144 
145  /* test with trailing space */
146  dwSize = 256;
147  res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
148  ok(res == 1, "InternetCanonicalizeUrlA failed\n");
149  ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
150 
151  res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
152  ok(!res, "InternetSetOptionA succeeded\n");
154  "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
155 }
156 
157 /* ############################### */
158 
159 static void test_InternetQueryOptionA(void)
160 {
161  HINTERNET hinet,hurl;
162  DWORD len, val;
163  DWORD err;
164  static const char useragent[] = {"Wininet Test"};
165  char *buffer;
166  int retval;
167  BOOL res;
168 
169  SetLastError(0xdeadbeef);
170  len = 0xdeadbeef;
172  ok(!retval && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got wrong error %x(%u)\n", retval, GetLastError());
173  ok(len >= sizeof(INTERNET_PROXY_INFOA) && len != 0xdeadbeef,"len = %u\n", len);
174 
175  hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
176  ok((hinet != 0x0),"InternetOpen Failed\n");
177 
178  SetLastError(0xdeadbeef);
180  err=GetLastError();
181  ok(retval == 0,"Got wrong return value %d\n",retval);
182  ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
183 
184  SetLastError(0xdeadbeef);
185  len=strlen(useragent)+1;
187  err=GetLastError();
188  ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
189  ok(retval == 0,"Got wrong return value %d\n",retval);
190  ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
191 
192  len=strlen(useragent)+1;
195  ok(retval == 1,"Got wrong return value %d\n",retval);
196  if (retval)
197  {
198  ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
199  ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
200  }
202 
203  SetLastError(0xdeadbeef);
204  len=0;
207  err=GetLastError();
208  ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
209  ok(!retval, "Got wrong return value %d\n", retval);
210  ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
212 
214 
215  SetLastError(0xdeadbeef);
216  len=0;
218  err=GetLastError();
219  ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
220  ok(retval == 0,"Got wrong return value %d\n",retval);
221  ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
222 
223  SetLastError(0xdeadbeef);
224  len = sizeof(DWORD);
226  err = GetLastError();
227  ok(retval == 0,"Got wrong return value %d\n",retval);
228  ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
229  ok(len == sizeof(DWORD), "len = %d\n", len);
230 
231  SetLastError(0xdeadbeef);
232  len = sizeof(DWORD);
234  err = GetLastError();
235  ok(retval == 0,"Got wrong return value %d\n",retval);
236  ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
237  ok(!len, "len = %d\n", len);
238 
239  InternetCloseHandle(hurl);
240  InternetCloseHandle(hinet);
241 
243  ok((hinet != 0x0),"InternetOpen Failed\n");
244 
245  SetLastError(0xdeadbeef);
246  len=0;
248  err=GetLastError();
249  ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
250  ok(retval == 0,"Got wrong return value %d\n",retval);
251  ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
252 
253  InternetCloseHandle(hinet);
254 
255  val = 12345;
257  ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
258 
259  len = sizeof(val);
261  ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
262  ok(val == 12345, "val = %d\n", val);
263  ok(len == sizeof(val), "len = %d\n", len);
264 
266  ok((hinet != 0x0),"InternetOpen Failed\n");
267  SetLastError(0xdeadbeef);
268  len=0;
270  err=GetLastError();
271  ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
272  ok(retval == 0,"Got wrong return value %d\n",retval);
273  ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
274 
275  len = sizeof(val);
276  val = 0xdeadbeef;
278  ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
279  ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
280 
281  val = 2;
283  ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
284  ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
285 
286  len = sizeof(val);
288  ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
289  ok(val == 12345, "val = %d\n", val);
290  ok(len == sizeof(val), "len = %d\n", len);
291 
292  val = 1;
294  ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
295 
296  len = sizeof(val);
298  ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
299  ok(val == 1, "val = %d\n", val);
300  ok(len == sizeof(val), "len = %d\n", len);
301 
302  len = sizeof(val);
304  ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
305  ok(val == 12345, "val = %d\n", val);
306  ok(len == sizeof(val), "len = %d\n", len);
307 
308  InternetCloseHandle(hinet);
309 }
310 
311 static void test_max_conns(void)
312 {
313  DWORD len, val;
314  BOOL res;
315 
316  len = sizeof(val);
317  val = 0xdeadbeef;
319  ok(res,"Got wrong return value %x\n", res);
320  ok(len == sizeof(val), "got %d\n", len);
321  trace("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", val);
322 
323  len = sizeof(val);
324  val = 0xdeadbeef;
326  ok(res,"Got wrong return value %x\n", res);
327  ok(len == sizeof(val), "got %d\n", len);
328  trace("INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", val);
329 
330  val = 3;
332  ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res);
333 
334  len = sizeof(val);
335  val = 0xdeadbeef;
337  ok(res,"Got wrong return value %x\n", res);
338  ok(len == sizeof(val), "got %d\n", len);
339  ok(val == 3, "got %d\n", val);
340 
341  val = 0;
343  ok(!res || broken(res), /* <= w2k3 */
344  "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
345  if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError());
346 
347  val = 2;
349  ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
350  ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
351 
352  val = 2;
354  ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
355  ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
356 }
357 
358 static void test_get_cookie(void)
359 {
360  DWORD len;
361  BOOL ret;
362 
363  len = 1024;
364  SetLastError(0xdeadbeef);
365  ret = InternetGetCookieA("http://www.example.com", NULL, NULL, &len);
367  "InternetGetCookie should have failed with %s and error %d\n",
368  ret ? "TRUE" : "FALSE", GetLastError());
369  ok(!len, "len = %u\n", len);
370 }
371 
372 
373 static void test_complicated_cookie(void)
374 {
375  DWORD len;
376  BOOL ret;
377 
378  CHAR buffer[1024];
379  CHAR user[256];
380  WCHAR wbuf[1024];
381 
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};
384 
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");
389 
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");
403 
404  len = 1024;
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);
408 
409  len = 1024;
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");
423 
424  len = 10;
425  memset(buffer, 0xac, sizeof(buffer));
426  ret = InternetGetCookieA("http://testing.example.com", NULL, buffer, &len);
428  "InternetGetCookie returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
429  ok(len == 19, "len = %u\n", len);
430 
431  len = 1024;
432  ret = InternetGetCookieW(testing_example_comW, NULL, NULL, &len);
433  ok(ret == TRUE,"InternetGetCookieW failed\n");
434  ok(len == 38, "len = %u\n", len);
435 
436  len = 1024;
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));
442 
443  len = 10;
444  memset(wbuf, 0xac, sizeof(wbuf));
445  ret = InternetGetCookieW(testing_example_comW, NULL, wbuf, &len);
447  "InternetGetCookieW returned: %x(%u), expected ERROR_INSUFFICIENT_BUFFER\n", ret, GetLastError());
448  ok(len == 38, "len = %u\n", len);
449 
450  len = 1024;
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");
461 
462  len = 1024;
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");
473 
474  len = 1024;
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");
485 
486  len = 1024;
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");
497 
498  len = 1024;
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");
509 
510  len = 1024;
511  ret = InternetGetCookieA("http://testing.example.com/bar/foo", NULL, buffer, &len);
512  ok(ret == TRUE,"InternetGetCookie failed\n");
513  ok(len == 24, "len = %u\n", 24);
514  ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
515  ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
516  ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
517  ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
518  ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
519  ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
520  ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
521  ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
522 
523  /* Cookie name argument is not implemented */
524  len = 1024;
525  ret = InternetGetCookieA("http://testing.example.com/bar/foo", "A", buffer, &len);
526  ok(ret == TRUE,"InternetGetCookie failed\n");
527  ok(len == 24, "len = %u\n", 24);
528 
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());
532 
533  len = sizeof(user);
534  ret = GetUserNameA(user, &len);
535  ok(ret, "GetUserName failed with error %d\n", GetLastError());
536  for(; len>0; len--)
537  user[len-1] = tolower(user[len-1]);
538 
539  sprintf(buffer, "Cookie:%s@testing.example.com/", user);
541  ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
542  ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "GetLastError() = %d\n", GetLastError());
543 
544  /* remove persistent cookie */
545  ret = InternetSetCookieA("http://testing.example.com", NULL, "A=B");
546  ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
547 
549  ok(!ret, "GetUrlCacheEntryInfo succeeded\n");
550  ok(GetLastError() == ERROR_FILE_NOT_FOUND, "GetLastError() = %d\n", GetLastError());
551 
552  /* try setting cookie for different domain */
553  ret = InternetSetCookieA("http://www.aaa.example.com/bar",NULL,"E=F; domain=different.com");
554  ok(!ret, "InternetSetCookie succeeded\n");
555  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %d\n", GetLastError());
556  ret = InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=example.com.pl");
557  ok(ret, "InternetSetCookie failed with error: %d\n", GetLastError());
558  ret = InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=com.pl");
559  todo_wine ok(!ret, "InternetSetCookie succeeded\n");
560 }
561 
562 static void test_cookie_attrs(void)
563 {
564  char buf[100];
565  DWORD size, state;
566  BOOL ret;
567 
568  if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "DeleteWpadCacheForNetworks")) {
569  win_skip("Skipping cookie attributes tests. Too old IE.\n");
570  return;
571  }
572 
573  ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=data; httponly");
574  ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
575 
576  SetLastError(0xdeadbeef);
577  state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data; httponly", 0, 0);
579  "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
580 
581  size = sizeof(buf);
582  ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
583  ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
584 
585  state = InternetSetCookieExA("http://cookie.attrs.com/bar",NULL,"A=data; httponly", INTERNET_COOKIE_HTTPONLY, 0);
586  ok(state == COOKIE_STATE_ACCEPT,"InternetSetCookieEx failed: %u\n", GetLastError());
587 
588  size = sizeof(buf);
589  ret = InternetGetCookieA("http://cookie.attrs.com/", NULL, buf, &size);
590  ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned: %x (%u)\n", ret, GetLastError());
591 
592  size = sizeof(buf);
593  ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, 0, NULL);
594  ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
595 
596  size = sizeof(buf);
597  ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
598  ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
599  ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
600 
601  /* Try to override httponly cookie with non-httponly one */
602  ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=test");
603  ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
604 
605  SetLastError(0xdeadbeef);
606  state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data", 0, 0);
608  "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
609 
610  size = sizeof(buf);
611  ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
612  ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
613  ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
614 
615 }
616 
617 static void test_cookie_url(void)
618 {
619  char long_url[5000] = "http://long.url.test.com/", *p;
620  WCHAR bufw[512];
621  char buf[512];
622  DWORD len;
623  BOOL res;
624 
625  static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
626 
627  len = sizeof(buf);
628  res = InternetGetCookieA("about:blank", NULL, buf, &len);
630  "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
631 
632  len = sizeof(bufw)/sizeof(*bufw);
635  "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
636 
637  len = sizeof(buf);
638  res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
640  "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
641 
642  len = sizeof(bufw)/sizeof(*bufw);
643  res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
645  "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
646 
647  p = long_url + strlen(long_url);
648  memset(p, 'x', long_url+sizeof(long_url)-p);
649  p += (long_url+sizeof(long_url)-p) - 3;
650  p[0] = '/';
651  p[2] = 0;
652  res = InternetSetCookieA(long_url, NULL, "A=B");
653  ok(res, "InternetSetCookieA failed: %u\n", GetLastError());
654 
655  len = sizeof(buf);
656  res = InternetGetCookieA(long_url, NULL, buf, &len);
657  ok(res, "InternetGetCookieA failed: %u\n", GetLastError());
658  ok(!strcmp(buf, "A=B"), "buf = %s\n", buf);
659 
660  len = sizeof(buf);
661  res = InternetGetCookieA("http://long.url.test.com/", NULL, buf, &len);
662  ok(!res && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieA failed: %u\n", GetLastError());
663 }
664 
665 static void test_null(void)
666 {
667  HINTERNET hi, hc;
668  static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
669  static const WCHAR szServer2[] = { 's','e','r','v','e','r','=',0 };
670  static const WCHAR szEmpty[] = { 0 };
671  static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
672  static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
673  static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
674  WCHAR buffer[0x20];
675  BOOL r;
676  DWORD sz;
677 
678  SetLastError(0xdeadbeef);
679  hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
680  if (hi == NULL && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
681  {
682  win_skip("Internet*W functions are not implemented\n");
683  return;
684  }
685  ok(hi != NULL, "open failed\n");
686 
687  hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
688  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
689  ok(hc == NULL, "connect failed\n");
690 
691  hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
692  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
693  ok(hc == NULL, "connect failed\n");
694 
695  hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
696  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
697  ok(hc == NULL, "connect failed\n");
698 
700  ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
701  ok(hc == NULL, "connect failed\n");
702 
703  hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
705  GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
706  ok(hc == NULL, "connect failed\n");
707 
708  hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
709  ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
710  ok(hc == NULL, "connect failed\n");
711 
713 
715  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
716  ok(r == FALSE, "return wrong\n");
717 
719  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
720  ok(r == FALSE, "return wrong\n");
721 
722  r = InternetSetCookieW(szUrl, szServer, NULL);
723  ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
724  ok(r == FALSE, "return wrong\n");
725 
727  ok(r == TRUE, "return wrong\n");
728 
729  r = InternetSetCookieW(szUrl, NULL, szServer);
730  ok(r == TRUE, "return wrong\n");
731 
733  ok(r == TRUE, "return wrong\n");
734 
735  r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
736  ok(r == FALSE, "return wrong\n");
737 
739  ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
740  ok(r == FALSE, "return wrong\n");
741 
742  sz = 0;
743  r = InternetGetCookieW(NULL, NULL, NULL, &sz);
745  "wrong error %u\n", GetLastError());
746  ok( r == FALSE, "return wrong\n");
747 
749  todo_wine {
750  ok(GetLastError() == ERROR_INTERNET_UNRECOGNIZED_SCHEME, "wrong error\n");
751  }
752  ok( r == FALSE, "return wrong\n");
753 
754  sz = 0;
755  r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
756  ok( r == FALSE, "return wrong\n");
757 
758  sz = 0;
759  r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
760  ok( r == TRUE, "return wrong\n");
761 
762  /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */
763  ok( sz == 14 || sz == 16 || sz == 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz);
764 
765  sz = 0x20;
766  memset(buffer, 0, sizeof buffer);
767  r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
768  ok( r == TRUE, "return wrong\n");
769 
770  /* sz == lstrlenW(buffer) only in XP SP1 */
771  ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
772 
773  /* before XP SP2, buffer is "server; server" */
774  ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer) || !lstrcmpW(szServer2, buffer),
775  "cookie data wrong %s\n", wine_dbgstr_w(buffer));
776 
777  sz = sizeof(buffer);
779  ok(r == TRUE, "ret %d\n", r);
780 }
781 
782 static void test_version(void)
783 {
785  DWORD size;
786  BOOL res;
787 
788  size = sizeof(version);
790  ok(res, "Could not get version: %u\n", GetLastError());
791  ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
792  ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
793 }
794 
796 {
797  BOOL ret;
798  static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
799  char string[INTERNET_RFC1123_BUFSIZE];
800  static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
801  DWORD error;
802 
803  ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
804  ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
805 
806  ok( !memcmp( string, expect, sizeof(expect) ),
807  "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
808 
809  /* test NULL time parameter */
810  SetLastError(0xdeadbeef);
811  ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
812  error = GetLastError();
813  ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
815  "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
816  error );
817 
818  /* test NULL string parameter */
819  SetLastError(0xdeadbeef);
820  ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
821  error = GetLastError();
822  ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
824  "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
825  error );
826 
827  /* test invalid format parameter */
828  SetLastError(0xdeadbeef);
829  ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
830  error = GetLastError();
831  ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
833  "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
834  error );
835 
836  /* test too small buffer size */
837  SetLastError(0xdeadbeef);
838  ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
839  error = GetLastError();
840  ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
842  "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
843  error );
844 }
845 
847 {
848  BOOL ret;
849  static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
850  WCHAR string[INTERNET_RFC1123_BUFSIZE + 1];
851  static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
852  '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
853  DWORD error;
854 
855  ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
856  ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
857 
858  ok( !memcmp( string, expect, sizeof(expect) ),
859  "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
860 
861  /* test NULL time parameter */
862  SetLastError(0xdeadbeef);
863  ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
864  error = GetLastError();
865  ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
867  "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
868  error );
869 
870  /* test NULL string parameter */
871  SetLastError(0xdeadbeef);
872  ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
873  error = GetLastError();
874  ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
876  "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
877  error );
878 
879  /* test invalid format parameter */
880  SetLastError(0xdeadbeef);
881  ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
882  error = GetLastError();
883  ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
885  "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
886  error );
887 
888  /* test too small buffer size */
889  SetLastError(0xdeadbeef);
890  ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string)/sizeof(string[0]) );
891  error = GetLastError();
892  ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
894  "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
895  error );
896 }
897 
899 {
900  BOOL ret;
902  static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
903  static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
904  static const char string2[] = " fri 7 jan 2005 12 06 35";
905 
906  ret = pInternetTimeToSystemTimeA( string, &time, 0 );
907  ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
908  ok( !memcmp( &time, &expect, sizeof(expect) ),
909  "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
910 
911  ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
912  ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
913  ok( !memcmp( &time, &expect, sizeof(expect) ),
914  "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
915 }
916 
918 {
919  BOOL ret;
921  static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
922  static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
923  '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
924  static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
925  '1','2',' ','0','6',' ','3','5',0 };
926  static const WCHAR string3[] = { 'F','r',0 };
927 
928  ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
929  ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
930 
931  ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
932  ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
933 
934  ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
935  ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
936 
937  ret = pInternetTimeToSystemTimeW( string, &time, 0 );
938  ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
939 
940  ret = pInternetTimeToSystemTimeW( string, &time, 0 );
941  ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
942  ok( !memcmp( &time, &expect, sizeof(expect) ),
943  "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
944 
945  ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
946  ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
947  ok( !memcmp( &time, &expect, sizeof(expect) ),
948  "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
949 
950  ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
951  ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
952 }
953 
955 {
956  BOOL ret;
957  static const WCHAR empty[] = {0};
958  static const WCHAR dot[] = {'.',0};
959  static const WCHAR uk[] = {'u','k',0};
960  static const WCHAR com[] = {'c','o','m',0};
961  static const WCHAR dot_com[] = {'.','c','o','m',0};
962  static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
963  static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
964  static const WCHAR www_gmail_com[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
965  static const WCHAR www_mail_gmail_com[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
966  static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
967  static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
968  static const WCHAR co_uk[] = {'c','o','.','u','k',0};
969  static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
970 
971  SetLastError(0xdeadbeef);
972  ret = pIsDomainLegalCookieDomainW(NULL, NULL);
974  {
975  win_skip("IsDomainLegalCookieDomainW is not implemented\n");
976  return;
977  }
978  ok(!ret ||
979  broken(ret), /* IE6 */
980  "IsDomainLegalCookieDomainW succeeded\n");
981 
982  SetLastError(0xdeadbeef);
983  ret = pIsDomainLegalCookieDomainW(com, NULL);
984  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
985 
986  SetLastError(0xdeadbeef);
987  ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
988  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
989 
990  SetLastError(0xdeadbeef);
991  ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
992  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
993 
994  SetLastError(0xdeadbeef);
995  ret = pIsDomainLegalCookieDomainW(com, empty);
996  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
997 
998  SetLastError(0xdeadbeef);
999  ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
1000  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1001 
1002  SetLastError(0xdeadbeef);
1003  ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
1004  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1005 
1006  SetLastError(0xdeadbeef);
1007  ret = pIsDomainLegalCookieDomainW(com, com);
1008  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1009 
1010  SetLastError(0xdeadbeef);
1011  ret = pIsDomainLegalCookieDomainW(com, dot_com);
1012  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1013 
1014  SetLastError(0xdeadbeef);
1015  ret = pIsDomainLegalCookieDomainW(dot_com, com);
1016  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1017 
1018  SetLastError(0xdeadbeef);
1019  ret = pIsDomainLegalCookieDomainW(com, gmail_com);
1020  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1021 
1022  ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
1023  ok(ret, "IsDomainLegalCookieDomainW failed\n");
1024 
1025  ret = pIsDomainLegalCookieDomainW(gmail_com, www_gmail_com);
1026  ok(ret, "IsDomainLegalCookieDomainW failed\n");
1027 
1028  ret = pIsDomainLegalCookieDomainW(gmail_com, www_mail_gmail_com);
1029  ok(ret, "IsDomainLegalCookieDomainW failed\n");
1030 
1031  SetLastError(0xdeadbeef);
1032  ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
1033  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1034 
1035  ret = pIsDomainLegalCookieDomainW(uk, co_uk);
1036  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1037 
1038  ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
1039  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1040 
1041  ret = pIsDomainLegalCookieDomainW(co_uk, gmail_co_uk);
1042  todo_wine ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1043 
1044  ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
1045  ok(ret, "IsDomainLegalCookieDomainW failed\n");
1046 
1047  ret = pIsDomainLegalCookieDomainW(gmail_com, com);
1048  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1049 
1050  SetLastError(0xdeadbeef);
1051  ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1052  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1053 
1054  ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
1055  ok(ret, "IsDomainLegalCookieDomainW failed\n");
1056 
1057  ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
1058  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1059 
1060  ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
1061  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1062 
1063  ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1064  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1065 
1066  ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
1067  ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1068 }
1069 
1071 {
1072  DWORD ret, zone, type, template, old_template, pref_size = 0;
1073  WCHAR pref[256];
1074 
1075  zone = 3;
1076  type = 0;
1077  ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
1078  ok(ret == 0, "expected ret == 0, got %u\n", ret);
1079 
1080  old_template = 0;
1081  ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
1082  ok(ret == 0, "expected ret == 0, got %u\n", ret);
1083 
1084  trace("template %u\n", old_template);
1085 
1086  if(old_template == PRIVACY_TEMPLATE_ADVANCED) {
1087  pref_size = sizeof(pref)/sizeof(WCHAR);
1088  ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, pref, &pref_size);
1089  ok(ret == 0, "expected ret == 0, got %u\n", ret);
1090  }
1091 
1092  template = 5;
1093  ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
1094  ok(ret == 0, "expected ret == 0, got %u\n", ret);
1095 
1096  template = 0;
1097  ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
1098  ok(ret == 0, "expected ret == 0, got %u\n", ret);
1099  ok(template == 5, "expected template == 5, got %u\n", template);
1100 
1101  template = 5;
1102  ret = pPrivacySetZonePreferenceW(zone, type, old_template, pref_size ? pref : NULL);
1103  ok(ret == 0, "expected ret == 0, got %u\n", ret);
1104 }
1105 
1106 static void test_InternetSetOption(void)
1107 {
1108  HINTERNET ses, con, req;
1109  ULONG ulArg;
1110  DWORD size;
1111  BOOL ret;
1112 
1114  ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1115  con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1116  ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1117  req = HttpOpenRequestA(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1118  ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1119 
1120  /* INTERNET_OPTION_POLICY tests */
1121  SetLastError(0xdeadbeef);
1123  ok(ret == FALSE, "InternetSetOption should've failed\n");
1124  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1125  "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1126 
1127  SetLastError(0xdeadbeef);
1129  ok(ret == FALSE, "InternetQueryOption should've failed\n");
1130  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1131  "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1132 
1133  /* INTERNET_OPTION_ERROR_MASK tests */
1134  SetLastError(0xdeadbeef);
1135  size = sizeof(ulArg);
1137  ok(ret == FALSE, "InternetQueryOption should've failed\n");
1138  ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1139 
1140  SetLastError(0xdeadbeef);
1141  ulArg = 11;
1142  ret = InternetSetOptionA(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1143  ok(ret == FALSE, "InternetSetOption should've failed\n");
1144  ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1145 
1146  SetLastError(0xdeadbeef);
1147  ulArg = 11;
1148  ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
1149  ok(ret == FALSE, "InternetSetOption should've failed\n");
1150  ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
1151 
1152  ulArg = 11;
1153  ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1154  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1155 
1156  SetLastError(0xdeadbeef);
1157  ulArg = 4;
1158  ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1159  ok(ret == FALSE, "InternetSetOption should've failed\n");
1160  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1161 
1162  SetLastError(0xdeadbeef);
1163  ulArg = 16;
1164  ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1165  ok(ret == FALSE, "InternetSetOption should've failed\n");
1166  ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1167 
1169  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1170 
1172  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1173 
1175  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1176 
1178  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1179 
1180  SetLastError(0xdeadbeef);
1182  ok(ret == FALSE, "InternetSetOption should've failed\n");
1183  ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %u\n", GetLastError());
1184 
1185  SetLastError(0xdeadbeef);
1187  ok(ret == FALSE, "InternetSetOption should've failed\n");
1188  ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %u\n", GetLastError());
1189 
1190  ret = InternetCloseHandle(req);
1191  ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1192  ret = InternetCloseHandle(con);
1193  ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1194  ret = InternetCloseHandle(ses);
1195  ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1196 }
1197 
1198 static void test_end_browser_session(void)
1199 {
1200  DWORD len;
1201  BOOL ret;
1202 
1203  ret = InternetSetCookieA("http://www.example.com/test_end", NULL, "A=B");
1204  ok(ret == TRUE, "InternetSetCookie failed\n");
1205 
1206  len = 1024;
1207  ret = InternetGetCookieA("http://www.example.com/test_end", NULL, NULL, &len);
1208  ok(ret == TRUE,"InternetGetCookie failed\n");
1209  ok(len != 0, "len = 0\n");
1210 
1212  ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
1213 
1214  len = 1024;
1215  ret = InternetGetCookieA("http://www.example.com/test_end", NULL, NULL, &len);
1216  ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned %x (%u)\n", ret, GetLastError());
1217  ok(!len, "len = %u\n", len);
1218 }
1219 
1220 #define verifyProxyEnable(e) r_verifyProxyEnable(__LINE__, e)
1222 {
1223  HKEY hkey;
1224  DWORD type, val, size = sizeof(DWORD);
1225  LONG ret;
1226  static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1227  static const CHAR szProxyEnable[] = "ProxyEnable";
1228 
1230  ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
1231 
1232  ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
1233  ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
1234  ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
1235  ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
1236 
1237  ret = RegCloseKey(hkey);
1238  ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
1239 }
1240 
1242 {
1243  BOOL ret;
1246  INTERNET_PER_CONN_OPTIONW *orig_settings;
1247  static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1248 
1249  /* get the global IE proxy server info, to restore later */
1250  list.dwOptionCount = 2;
1251  list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1252 
1253  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1254  list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1255 
1257  &list, &size);
1258  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1259  orig_settings = list.pOptions;
1260 
1261  /* set the global IE proxy server */
1262  list.dwOptionCount = 2;
1263  list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1264 
1265  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1266  list.pOptions[0].Value.pszValue = proxy_srvW;
1267  list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1268  list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1269 
1271  &list, size);
1272  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1273 
1274  HeapFree(GetProcessHeap(), 0, list.pOptions);
1275 
1276  /* get & verify the global IE proxy server */
1277  list.dwOptionCount = 2;
1278  list.dwOptionError = 0;
1279  list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1280 
1281  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1282  list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1283 
1285  &list, &size);
1286  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1287  ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
1288  "Retrieved proxy server should've been %s, was: %s\n",
1289  wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
1290  ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1291  "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1292  list.pOptions[1].Value.dwValue);
1293  verifyProxyEnable(1);
1294 
1295  HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1296  HeapFree(GetProcessHeap(), 0, list.pOptions);
1297 
1298  /* disable the proxy server */
1299  list.dwOptionCount = 1;
1300  list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1301 
1302  list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1303  list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1304 
1306  &list, size);
1307  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1308 
1309  HeapFree(GetProcessHeap(), 0, list.pOptions);
1310 
1311  /* verify that the proxy is disabled */
1312  list.dwOptionCount = 1;
1313  list.dwOptionError = 0;
1314  list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1315 
1316  list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1317 
1319  &list, &size);
1320  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1321  ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1322  "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1323  list.pOptions[0].Value.dwValue);
1324  verifyProxyEnable(0);
1325 
1326  HeapFree(GetProcessHeap(), 0, list.pOptions);
1327 
1328  /* set the proxy flags to 'invalid' value */
1329  list.dwOptionCount = 1;
1330  list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1331 
1332  list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1333  list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1334 
1336  &list, size);
1337  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1338 
1339  HeapFree(GetProcessHeap(), 0, list.pOptions);
1340 
1341  /* verify that the proxy is enabled */
1342  list.dwOptionCount = 1;
1343  list.dwOptionError = 0;
1344  list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1345 
1346  list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1347 
1349  &list, &size);
1350  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1351  todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1352  "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1353  list.pOptions[0].Value.dwValue);
1354  verifyProxyEnable(1);
1355 
1356  HeapFree(GetProcessHeap(), 0, list.pOptions);
1357 
1358  /* restore original settings */
1359  list.dwOptionCount = 2;
1360  list.pOptions = orig_settings;
1361 
1363  &list, size);
1364  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1365 
1366  HeapFree(GetProcessHeap(), 0, list.pOptions);
1367 }
1368 
1370 {
1371  BOOL ret;
1374  INTERNET_PER_CONN_OPTIONA *orig_settings;
1375  char proxy_srv[] = "proxy.example";
1376 
1377  /* get the global IE proxy server info, to restore later */
1378  list.dwOptionCount = 2;
1379  list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1380 
1381  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1382  list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1383 
1385  &list, &size);
1386  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1387  orig_settings = list.pOptions;
1388 
1389  /* set the global IE proxy server */
1390  list.dwOptionCount = 2;
1391  list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1392 
1393  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1394  list.pOptions[0].Value.pszValue = proxy_srv;
1395  list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1396  list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1397 
1399  &list, size);
1400  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1401 
1402  HeapFree(GetProcessHeap(), 0, list.pOptions);
1403 
1404  /* get & verify the global IE proxy server */
1405  list.dwOptionCount = 2;
1406  list.dwOptionError = 0;
1407  list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1408 
1409  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1410  list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1411 
1413  &list, &size);
1414  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1415  ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1416  "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1417  proxy_srv, list.pOptions[0].Value.pszValue);
1418  ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1419  "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1420  list.pOptions[1].Value.dwValue);
1421 
1422  HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1423  HeapFree(GetProcessHeap(), 0, list.pOptions);
1424 
1425  /* test with NULL as proxy server */
1426  list.dwOptionCount = 1;
1427  list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
1428  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1429  list.pOptions[0].Value.pszValue = NULL;
1430 
1432  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1433 
1435  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1436 
1437  HeapFree(GetProcessHeap(), 0, list.pOptions);
1438 
1439  /* get & verify the proxy server */
1440  list.dwOptionCount = 1;
1441  list.dwOptionError = 0;
1442  list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
1443  list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1444 
1446  ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1447  ok(!list.pOptions[0].Value.pszValue,
1448  "Retrieved proxy server should've been NULL, was: \"%s\"\n",
1449  list.pOptions[0].Value.pszValue);
1450 
1451  HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1452  HeapFree(GetProcessHeap(), 0, list.pOptions);
1453 
1454  /* restore original settings */
1455  list.dwOptionCount = 2;
1456  list.pOptions = orig_settings;
1457 
1459  &list, size);
1460  ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1461 
1462  HeapFree(GetProcessHeap(), 0, list.pOptions);
1463 }
1464 
1465 #define FLAG_TODO 0x1
1466 #define FLAG_NEEDREQ 0x2
1467 #define FLAG_UNIMPL 0x4
1468 
1469 static void test_InternetErrorDlg(void)
1470 {
1471  HINTERNET ses, con, req;
1472  DWORD res, flags;
1473  HWND hwnd;
1474  ULONG i;
1475  static const struct {
1476  DWORD error;
1477  DWORD res;
1478  DWORD test_flags;
1479  } no_ui_res[] = {
1499  { 0, ERROR_NOT_SUPPORTED }
1500  };
1501 
1502  flags = 0;
1503 
1504  res = InternetErrorDlg(NULL, NULL, 12055, flags, NULL);
1505  ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1506 
1508  ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1509  con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1510  ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1511  req = HttpOpenRequestA(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1512  ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1513 
1514  /* NULL hwnd and FLAGS_ERROR_UI_FLAGS_NO_UI not set */
1516  {
1517  res = InternetErrorDlg(NULL, req, i, flags, NULL);
1518  ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1519  }
1520 
1521  hwnd = GetDesktopWindow();
1522  ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1523 
1526  {
1527  DWORD expected, test_flags, j;
1528 
1529  for(j = 0; no_ui_res[j].error != 0; ++j)
1530  if(no_ui_res[j].error == i)
1531  break;
1532 
1533  test_flags = no_ui_res[j].test_flags;
1534  expected = no_ui_res[j].res;
1535 
1536  /* Try an invalid request handle */
1537  res = InternetErrorDlg(hwnd, (HANDLE)0xdeadbeef, i, flags, NULL);
1539  {
1540  ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1541  continue;
1542  }
1543  else
1544  ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1545 
1546  /* With a valid req */
1547  if(i == ERROR_INTERNET_NEED_UI)
1548  continue; /* Crashes on windows XP */
1549 
1551  continue; /* Interactive (XP, Win7) */
1552 
1553  res = InternetErrorDlg(hwnd, req, i, flags, NULL);
1554 
1555  /* Handle some special cases */
1556  switch(i)
1557  {
1560  if(res == ERROR_CANCELLED)
1561  {
1562  /* Some windows XP, w2k3 x64, W2K8 */
1563  win_skip("Skipping some tests for %d\n", i);
1564  continue;
1565  }
1566  break;
1568  if(res != expected)
1569  {
1570  /* Windows XP, W2K3 */
1571  ok(res == NTE_PROV_TYPE_NOT_DEF, "Got %d\n", res);
1572  win_skip("Skipping some tests for %d\n", i);
1573  continue;
1574  }
1575  break;
1577  if(res == ERROR_SUCCESS) /* win10 returns ERROR_SUCCESS */
1579  break;
1580  default: break;
1581  }
1582 
1583  todo_wine_if(test_flags & FLAG_TODO)
1584  ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1585 
1586  /* Same thing with NULL hwnd */
1587  res = InternetErrorDlg(NULL, req, i, flags, NULL);
1588  todo_wine_if(test_flags & FLAG_TODO)
1589  ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1590 
1591 
1592  /* With a null req */
1593  if(test_flags & FLAG_NEEDREQ)
1595 
1598  ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1599  }
1600 
1601  res = InternetCloseHandle(req);
1602  ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1603  res = InternetCloseHandle(con);
1604  ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1605  res = InternetCloseHandle(ses);
1606  ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1607 }
1608 
1610 {
1611  BOOL res;
1612  CHAR buffer[256];
1613  DWORD flags, sz;
1614 
1615  if(!pInternetGetConnectedStateExA) {
1616  win_skip("InternetGetConnectedStateExA is not supported\n");
1617  return;
1618  }
1619 
1620  flags = 0;
1621  buffer[0] = 0;
1622  res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0);
1623  trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer);
1624 todo_wine
1625  ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n");
1626  if(!res) {
1627  win_skip("InternetGetConnectedStateExA tests require a valid connection\n");
1628  return;
1629  }
1630 
1631  res = pInternetGetConnectedStateExA(NULL, NULL, 0, 0);
1632  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1633 
1634  flags = 0;
1635  res = pInternetGetConnectedStateExA(&flags, NULL, 0, 0);
1636  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1638  {
1639  ok(flags & INTERNET_CONNECTION_MODEM, "Modem connection flag missing\n");
1640  ok(flags & ~INTERNET_CONNECTION_LAN, "Mixed Modem and LAN flags\n");
1641  }
1642  else
1643  {
1644  ok(flags & INTERNET_CONNECTION_LAN, "LAN connection flag missing\n");
1645  ok(flags & ~INTERNET_CONNECTION_MODEM, "Mixed Modem and LAN flags\n");
1646  }
1647 
1648  buffer[0] = 0;
1649  flags = 0;
1650  res = pInternetGetConnectedStateExA(&flags, buffer, 0, 0);
1651  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1652  ok(flags, "Expected at least one flag set\n");
1653  ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
1654 
1655  buffer[0] = 0;
1656  res = pInternetGetConnectedStateExA(NULL, buffer, sizeof(buffer), 0);
1657  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1658  sz = strlen(buffer);
1659  ok(sz > 0, "Expected a connection name\n");
1660 
1661  buffer[0] = 0;
1662  flags = 0;
1663  res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0);
1664  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1665  ok(flags, "Expected at least one flag set\n");
1666  sz = strlen(buffer);
1667  ok(sz > 0, "Expected a connection name\n");
1668 
1669  flags = 0;
1670  res = pInternetGetConnectedStateExA(&flags, NULL, sizeof(buffer), 0);
1671  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1672  ok(flags, "Expected at least one flag set\n");
1673 
1674  /* no space for complete string this time */
1675  buffer[0] = 0;
1676  flags = 0;
1677  res = pInternetGetConnectedStateExA(&flags, buffer, sz, 0);
1678  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1679  ok(flags, "Expected at least one flag set\n");
1680  ok(sz - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenA(buffer));
1681 
1682  buffer[0] = 0;
1683  flags = 0;
1684  res = pInternetGetConnectedStateExA(&flags, buffer, sz / 2, 0);
1685  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1686  ok(flags, "Expected at least one flag set\n");
1687  ok(sz / 2 - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenA(buffer));
1688 
1689  buffer[0] = 0;
1690  flags = 0;
1691  res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
1692  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1693  ok(flags, "Expected at least one flag set\n");
1694  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
1695 
1696  buffer[0] = 0;
1697  flags = 0;
1698  res = pInternetGetConnectedStateExA(&flags, buffer, 2, 0);
1699  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1700  ok(flags, "Expected at least one flag set\n");
1701  ok(strlen(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer));
1702 
1703  flags = 0;
1704  buffer[0] = 0xDE;
1705  res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
1706  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1707  ok(flags, "Expected at least one flag set\n");
1708  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
1709 }
1710 
1712 {
1713  BOOL res;
1714  WCHAR buffer[256];
1715  DWORD flags, sz;
1716 
1717  if(!pInternetGetConnectedStateExW) {
1718  win_skip("InternetGetConnectedStateExW is not supported\n");
1719  return;
1720  }
1721 
1722  flags = 0;
1723  buffer[0] = 0;
1724  res = pInternetGetConnectedStateExW(&flags, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);
1725  trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer));
1726 todo_wine
1727  ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n");
1728  if(!res) {
1729  win_skip("InternetGetConnectedStateExW tests require a valid connection\n");
1730  return;
1731  }
1732 
1733  res = pInternetGetConnectedStateExW(NULL, NULL, 0, 0);
1734  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1735 
1736  flags = 0;
1737  res = pInternetGetConnectedStateExW(&flags, NULL, 0, 0);
1738  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1740  {
1741  ok(flags & INTERNET_CONNECTION_MODEM, "Modem connection flag missing\n");
1742  ok(flags & ~INTERNET_CONNECTION_LAN, "Mixed Modem and LAN flags\n");
1743  }
1744  else
1745  {
1746  ok(flags & INTERNET_CONNECTION_LAN, "LAN connection flag missing\n");
1747  ok(flags & ~INTERNET_CONNECTION_MODEM, "Mixed Modem and LAN flags\n");
1748  }
1749 
1750  buffer[0] = 0;
1751  flags = 0;
1752  res = pInternetGetConnectedStateExW(&flags, buffer, 0, 0);
1753  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1754  ok(flags, "Expected at least one flag set\n");
1755  ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
1756 
1757  buffer[0] = 0;
1758  res = pInternetGetConnectedStateExW(NULL, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);
1759  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1760  sz = lstrlenW(buffer);
1761  ok(sz > 0, "Expected a connection name\n");
1762 
1763  buffer[0] = 0;
1764  flags = 0;
1765  res = pInternetGetConnectedStateExW(&flags, buffer, sizeof(buffer) / sizeof(buffer[0]), 0);
1766  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1767  ok(flags, "Expected at least one flag set\n");
1768  sz = lstrlenW(buffer);
1769  ok(sz > 0, "Expected a connection name\n");
1770 
1771  flags = 0;
1772  res = pInternetGetConnectedStateExW(&flags, NULL, sizeof(buffer) / sizeof(buffer[0]), 0);
1773  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1774  ok(flags, "Expected at least one flag set\n");
1775 
1776  /* no space for complete string this time */
1777  buffer[0] = 0;
1778  flags = 0;
1779  res = pInternetGetConnectedStateExW(&flags, buffer, sz, 0);
1780  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1781  ok(flags, "Expected at least one flag set\n");
1783  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1784  else
1785  ok(sz - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenW(buffer));
1786 
1787  buffer[0] = 0;
1788  flags = 0;
1789  res = pInternetGetConnectedStateExW(&flags, buffer, sz / 2, 0);
1790  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1791  ok(flags, "Expected at least one flag set\n");
1793  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1794  else
1795  ok(sz / 2 - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenW(buffer));
1796 
1797  buffer[0] = 0;
1798  flags = 0;
1799  res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
1800  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1801  ok(flags, "Expected at least one flag set\n");
1802  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1803 
1804  buffer[0] = 0;
1805  flags = 0;
1806  res = pInternetGetConnectedStateExW(&flags, buffer, 2, 0);
1807  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1808  ok(flags, "Expected at least one flag set\n");
1810  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1811  else
1812  ok(lstrlenW(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer));
1813 
1814  buffer[0] = 0xDEAD;
1815  flags = 0;
1816  res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
1817  ok(res == TRUE, "Expected TRUE, got %d\n", res);
1818  ok(flags, "Expected at least one flag set\n");
1819  ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1820 }
1821 
1823 {
1824  DWORD ret;
1825  CHAR out[0x100];
1826 
1827  /* These messages come from wininet and not the system. */
1830  ok(ret == 0, "FormatMessageA returned %d\n", ret);
1831 
1834  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1835 
1838  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1839 
1842  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1843 
1846  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1847 
1850  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1851 
1854  ok(ret != 0 || broken(!ret) /* XP, w2k3 */, "FormatMessageA returned %d\n", ret);
1855 
1858  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1859 
1862  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1863 
1866  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1867 
1870  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1871 
1874  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1875 
1878  ok(ret != 0, "FormatMessageA returned %d\n", ret);
1879 }
1880 
1881 /* ############################### */
1882 
1883 START_TEST(internet)
1884 {
1885  HMODULE hdll;
1886  hdll = GetModuleHandleA("wininet.dll");
1887 
1888  pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1889  pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1890  pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1891  pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1892  pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1893  pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1894  pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1895  pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1896  pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1897  pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
1898  pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
1899  pInternetGetConnectedStateExA = (void*)GetProcAddress(hdll, "InternetGetConnectedStateExA");
1900  pInternetGetConnectedStateExW = (void*)GetProcAddress(hdll, "InternetGetConnectedStateExW");
1901 
1902  if(!pInternetGetCookieExW) {
1903  win_skip("Too old IE (older than 6.0)\n");
1904  return;
1905  }
1906 
1911  test_get_cookie();
1913  test_cookie_url();
1915  test_version();
1916  test_null();
1920  test_max_conns();
1921 
1922  if (!pInternetTimeFromSystemTimeA)
1923  win_skip("skipping the InternetTime tests\n");
1924  else
1925  {
1930  }
1931  if (pIsDomainLegalCookieDomainW &&
1932  ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1933  (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1934  win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1935  else if (!pIsDomainLegalCookieDomainW)
1936  win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1937  else
1939 
1940  if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1942  else
1943  win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1944 
1948 }
struct _INTERNET_PER_CONN_OPTION_LISTA INTERNET_PER_CONN_OPTION_LISTA
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI InternetGetCookieW(const WCHAR *url, const WCHAR *name, WCHAR *data, DWORD *size)
Definition: cookie.c:786
#define ERROR_INTERNET_SEC_CERT_CN_INVALID
Definition: wininet.h:2026
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
Definition: wininet.h:2065
static LPCSTR
Definition: internet.c:44
#define ERROR_INTERNET_CONNECTION_ABORTED
Definition: wininet.h:2019
#define TRUE
Definition: types.h:120
#define ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
Definition: wininet.h:2028
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static BOOL(WINAPI *pCreateUrlCacheContainerA)(DWORD
BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPSTR lpCookieData, LPDWORD lpdwSize, DWORD flags, void *reserved)
Definition: cookie.c:803
#define ERROR_SUCCESS
Definition: deptool.c:10
#define error(str)
Definition: mkdosfs.c:1605
GLint x0
Definition: linetemp.h:95
static void InternetTimeFromSystemTimeA_test(void)
Definition: internet.c:795
#define INTERNET_OPTION_MAX_CONNS_PER_SERVER
Definition: wininet.h:763
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
static LPCWSTR
Definition: internet.c:41
static void test_null(void)
Definition: internet.c:665
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void test_Option_PerConnectionOption(void)
Definition: internet.c:1241
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const WCHAR szProxyEnable[]
Definition: internet.c:109
#define ERROR_INTERNET_SEC_CERT_REV_FAILED
Definition: wininet.h:2044
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define PRIVACY_TEMPLATE_ADVANCED
Definition: wininet.h:1962
#define ERROR_INTERNET_UNRECOGNIZED_SCHEME
Definition: wininet.h:1995
static const WCHAR empty[]
Definition: main.c:49
#define LANG_NEUTRAL
Definition: nls.h:22
#define INTERNET_PER_CONN_PROXY_SERVER
Definition: wininet.h:335
static void test_max_conns(void)
Definition: internet.c:311
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static LPWSTR
Definition: internet.c:38
#define ERROR_INTERNET_MIXED_SECURITY
Definition: wininet.h:2029
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:2001
DWORD WINAPI FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:483
static CHAR string2[MAX_PATH]
Definition: automation.c:468
char CHAR
Definition: xmlstorage.h:175
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:2716
static void test_cookie_attrs(void)
Definition: internet.c:562
#define ERROR_BAD_ARGUMENTS
Definition: winerror.h:232
#define ERROR_INTERNET_SEC_CERT_REVOKED
Definition: wininet.h:2077
#define ERROR_INTERNET_ITEM_NOT_FOUND
Definition: wininet.h:2017
static const WCHAR szServer[]
Definition: http.c:120
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1344
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void test_InternetCanonicalizeUrlA(void)
Definition: internet.c:51
static void test_IsDomainLegalCookieDomainW(void)
Definition: internet.c:954
GLuint buffer
Definition: glext.h:5915
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1437
BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:3008
__u16 time
Definition: mkdosfs.c:366
#define SUBLANG_NEUTRAL
Definition: nls.h:167
#define INTERNET_OPTION_PER_CONNECTION_OPTION
Definition: wininet.h:765
#define lstrlenW
Definition: compat.h:407
#define INTERNET_OPTION_PROXY
Definition: wininet.h:732
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
#define ERROR_INTERNET_BAD_OPTION_LENGTH
Definition: wininet.h:1999
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
static void r_verifyProxyEnable(LONG l, DWORD exp)
Definition: internet.c:1221
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1080
static DWORD
Definition: internet.c:33
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl, LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3608
#define ERROR_HTTP_COOKIE_DECLINED
Definition: wininet.h:2066
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define ICU_BROWSER_MODE
Definition: winhttp.h:294
#define NTE_PROV_TYPE_NOT_DEF
Definition: winerror.h:2891
#define ERROR_INTERNET_INSERT_CDROM
Definition: wininet.h:2040
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static void test_InternetSetOption(void)
Definition: internet.c:1106
#define FLAGS_ERROR_UI_FLAGS_NO_UI
Definition: wininet.h:1909
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static void test_get_cookie(void)
Definition: internet.c:358
static void test_PrivacyGetSetZonePreferenceW(void)
Definition: internet.c:1070
static void InternetTimeToSystemTimeW_test(void)
Definition: internet.c:917
#define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
Definition: wininet.h:2032
static void InternetTimeToSystemTimeA_test(void)
Definition: internet.c:898
#define ERROR_INTERNET_INVALID_URL
Definition: wininet.h:1994
#define verifyProxyEnable(e)
Definition: internet.c:1220
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR version[]
Definition: asmname.c:64
DWORD WINAPI InternetSetCookieExA(LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData, DWORD dwFlags, DWORD_PTR dwReserved)
Definition: cookie.c:1159
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:652
#define ERROR_INTERNET_SEC_CERT_ERRORS
Definition: wininet.h:2042
static LPVOID
Definition: internet.c:44
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2609
static void InternetTimeFromSystemTimeW_test(void)
Definition: internet.c:846
const char * LPCSTR
Definition: xmlstorage.h:183
static void test_end_browser_session(void)
Definition: internet.c:1198
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:403
#define INTERNET_ERROR_LAST
Definition: wininet.h:2083
#define INTERNET_OPTION_REFRESH
Definition: wininet.h:731
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define FLAG_UNIMPL
Definition: internet.c:1467
#define INTERNET_OPTION_SETTINGS_CHANGED
Definition: wininet.h:733
r l[0]
Definition: byte_order.h:167
#define INTERNET_CONNECTION_LAN
Definition: wininet.h:2538
static const WCHAR szEmpty[]
Definition: provider.c:47
static void test_cookie_url(void)
Definition: internet.c:617
#define todo_wine_if(is_todo)
Definition: test.h:155
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718
#define INTERNET_CONNECTION_CONFIGURED
Definition: wininet.h:2543
GLsizeiptr size
Definition: glext.h:5919
static LPSTR
Definition: internet.c:37
#define GetProcessHeap()
Definition: compat.h:395
#define trace
Definition: atltest.h:70
#define INTERNET_RFC1123_BUFSIZE
Definition: wininet.h:408
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ERROR_INTERNET_CHG_POST_IS_NON_SECURE
Definition: wininet.h:2030
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INTERNET_RAS_INSTALLED
Definition: wininet.h:2541
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPCSTR lpCookieData)
Definition: cookie.c:1133
#define INTERNET_OPTION_CONNECTED_STATE
Definition: wininet.h:744
static const WCHAR url[]
Definition: encode.c:1432
#define WINAPI
Definition: msvc.h:8
static FILE * out
Definition: regtests2xml.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ICU_NO_ENCODE
Definition: winhttp.h:290
#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: wininet.h:764
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define ERROR_INTERNET_OPERATION_CANCELLED
Definition: wininet.h:2006
#define INTERNET_RFC1123_FORMAT
Definition: wininet.h:407
#define SetLastError(x)
Definition: compat.h:409
BOOL WINAPI InternetGetCookieA(const char *url, const char *name, char *data, DWORD *size)
Definition: cookie.c:856
#define PROXY_TYPE_DIRECT
Definition: wininet.h:346
BOOL WINAPI InternetSetCookieW(const WCHAR *url, const WCHAR *name, const WCHAR *data)
Definition: cookie.c:1116
static void test_Option_PerConnectionOptionA(void)
Definition: internet.c:1369
#define INTERNET_OPTION_VERSION
Definition: wininet.h:734
static void test_format_message(HMODULE hdll)
Definition: internet.c:1822
static const WCHAR szInternetSettings[]
Definition: internet.c:104
GLbitfield flags
Definition: glext.h:7161
BOOL WINAPI GetUrlCacheEntryInfoA(LPCSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize)
Definition: urlcache.c:1897
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
int ret
#define INTERNET_SERVICE_FTP
Definition: wininet.h:560
#define todo_wine
Definition: test.h:154
static int state
Definition: maze.c:121
static void test_InternetErrorDlg(void)
Definition: internet.c:1469
#define ERROR_INTERNET_INTERNAL_ERROR
Definition: wininet.h:1993
static void test_InternetGetConnectedStateExW(void)
Definition: internet.c:1711
GLenum GLsizei len
Definition: glext.h:6722
BOOL WINAPI GetUserNameA(LPSTR lpszName, LPDWORD lpSize)
Definition: misc.c:246
unsigned char BYTE
Definition: mem.h:68
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
Definition: _list.h:228
#define err(...)
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998
#define ERROR_INTERNET_TIMEOUT
Definition: wininet.h:1991
#define ERROR_INTERNET_POST_IS_NON_SECURE
Definition: wininet.h:2031
#define broken(x)
Definition: _sntprintf.h:21
#define INTERNET_OPTION_POLICY
Definition: wininet.h:742
#define PROXY_TYPE_PROXY
Definition: wininet.h:347
#define INTERNET_ERROR_BASE
Definition: wininet.h:1988
#define INTERNET_OPTION_USER_AGENT
Definition: wininet.h:735
DWORD zone
Definition: sec_mgr.c:1760
#define FLAG_NEEDREQ
Definition: internet.c:1466
#define ERROR_INTERNET_SEC_CERT_DATE_INVALID
Definition: wininet.h:2025
#define ERROR_INTERNET_INVALID_CA
Definition: wininet.h:2033
#define INTERNET_OPTION_ERROR_MASK
Definition: wininet.h:755
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
Definition: wininet.h:2027
static const WCHAR szExpect[]
Definition: http.c:102
#define ERROR_CANCELLED
Definition: winerror.h:726
#define FLAG_TODO
Definition: internet.c:1465
#define ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
Definition: wininet.h:2039
#define ok(value,...)
Definition: atltest.h:57
static LPDWORD
Definition: internet.c:42
#define expect(expected, got)
Definition: combo.c:36
static const WCHAR about_blankW[]
Definition: persist.c:24
HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:1467
START_TEST(internet)
Definition: internet.c:1883
static PVOID hdll
Definition: shimdbg.c:126
DWORD exp
Definition: msg.c:15681
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
#define INTERNET_OPTION_END_BROWSER_SESSION
Definition: wininet.h:736
#define ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
Definition: wininet.h:2041
#define ERROR_INTERNET_INCORRECT_PASSWORD
Definition: wininet.h:2003
#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
Definition: wininet.h:2074
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
struct _INTERNET_PER_CONN_OPTION_LISTW INTERNET_PER_CONN_OPTION_LISTW
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2576
GLuint res
Definition: glext.h:9613
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define MAKELANGID(p, s)
Definition: nls.h:15
#define INTERNET_CONNECTION_MODEM
Definition: wininet.h:2537
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
static void test_InternetGetConnectedStateExA(void)
Definition: internet.c:1609
#define GetProcAddress(x, y)
Definition: compat.h:410
static void test_InternetQueryOptionA(void)
Definition: internet.c:159
#define ICU_DECODE
Definition: winhttp.h:291
#define ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
Definition: wininet.h:2067
#define INTERNET_COOKIE_HTTPONLY
Definition: wininet.h:1828
GLfloat GLfloat p
Definition: glext.h:8902
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1281
static CHAR string3[MAX_PATH]
Definition: editor.c:42
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1002
static void test_version(void)
Definition: internet.c:782
#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
Definition: wininet.h:2075
#define ERROR_INTERNET_NEED_UI
Definition: wininet.h:2023
static void test_complicated_cookie(void)
Definition: internet.c:373
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
#define INTERNET_OPTION_CONNECT_TIMEOUT
Definition: wininet.h:701
int tolower(int c)
Definition: utclib.c:902
#define win_skip
Definition: test.h:141
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
void user(int argc, const char *argv[])
Definition: cmds.c:1350
DWORD WINAPI InternetErrorDlg(HWND hWnd, HINTERNET hRequest, DWORD dwError, DWORD dwFlags, LPVOID *lppvData)
Definition: dialogs.c:476
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
IUnknown uk
Definition: typelib.c:6136
BOOL expected
Definition: store.c:2063
#define INTERNET_PER_CONN_FLAGS
Definition: wininet.h:334
#define ok_(x1, x2)
Definition: atltest.h:61
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10