ReactOS 0.4.15-dev-7788-g1ad9096
internet.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "wininet.h"
#include "winineti.h"
#include "winerror.h"
#include "winreg.h"
#include "wine/test.h"
Include dependency graph for internet.c:

Go to the source code of this file.

Macros

#define verifyProxyEnable(e)   r_verifyProxyEnable(__LINE__, e)
 
#define FLAG_TODO   0x1
 
#define FLAG_NEEDREQ   0x2
 
#define FLAG_UNIMPL   0x4
 

Functions

static BOOL (WINAPI *pCreateUrlCacheContainerA)(DWORD
 
static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD
 
static void test_InternetCanonicalizeUrlA (void)
 
static void test_InternetQueryOptionA (void)
 
static void test_max_conns (void)
 
static void test_get_cookie (void)
 
static void test_complicated_cookie (void)
 
static void test_cookie_attrs (void)
 
static void test_cookie_url (void)
 
static void test_null (void)
 
static void test_version (void)
 
static void InternetTimeFromSystemTimeA_test (void)
 
static void InternetTimeFromSystemTimeW_test (void)
 
static void InternetTimeToSystemTimeA_test (void)
 
static void InternetTimeToSystemTimeW_test (void)
 
static void test_IsDomainLegalCookieDomainW (void)
 
static void test_PrivacyGetSetZonePreferenceW (void)
 
static void test_InternetSetOption (void)
 
static void test_end_browser_session (void)
 
static void r_verifyProxyEnable (LONG l, DWORD exp)
 
static void test_Option_PerConnectionOption (void)
 
static void test_Option_PerConnectionOptionA (void)
 
static void test_InternetErrorDlg (void)
 
static void test_InternetGetConnectedStateExA (void)
 
static void test_InternetGetConnectedStateExW (void)
 
static void test_format_message (HMODULE hdll)
 
 START_TEST (internet)
 

Variables

static DWORD
 
static LPSTR
 
static LPWSTR
 
static LPCWSTR
 
static LPDWORD
 
static LPCSTR
 
static LPVOID
 

Macro Definition Documentation

◆ FLAG_NEEDREQ

#define FLAG_NEEDREQ   0x2

Definition at line 1467 of file internet.c.

◆ FLAG_TODO

#define FLAG_TODO   0x1

Definition at line 1466 of file internet.c.

◆ FLAG_UNIMPL

#define FLAG_UNIMPL   0x4

Definition at line 1468 of file internet.c.

◆ verifyProxyEnable

#define verifyProxyEnable (   e)    r_verifyProxyEnable(__LINE__, e)

Definition at line 1221 of file internet.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pCreateUrlCacheContainerA)
static

◆ DWORD()

static DWORD ( WINAPI pPrivacyGetZonePreferenceW)
static

◆ InternetTimeFromSystemTimeA_test()

static void InternetTimeFromSystemTimeA_test ( void  )
static

Definition at line 796 of file internet.c.

797{
798 BOOL ret;
799 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
800 char string[INTERNET_RFC1123_BUFSIZE];
801 static const char expect[] = "Fri, 07 Jan 2005 12:06:35 GMT";
802 DWORD error;
803
804 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
805 ok( ret, "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
806
807 ok( !memcmp( string, expect, sizeof(expect) ),
808 "InternetTimeFromSystemTimeA failed (%u)\n", GetLastError() );
809
810 /* test NULL time parameter */
811 SetLastError(0xdeadbeef);
812 ret = pInternetTimeFromSystemTimeA( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
814 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
816 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
817 error );
818
819 /* test NULL string parameter */
820 SetLastError(0xdeadbeef);
821 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
823 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
825 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
826 error );
827
828 /* test invalid format parameter */
829 SetLastError(0xdeadbeef);
830 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
832 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
834 "InternetTimeFromSystemTimeA failed with ERROR_INVALID_PARAMETER instead of %u\n",
835 error );
836
837 /* test too small buffer size */
838 SetLastError(0xdeadbeef);
839 ret = pInternetTimeFromSystemTimeA( &time, INTERNET_RFC1123_FORMAT, string, 0 );
841 ok( !ret, "InternetTimeFromSystemTimeA should have returned FALSE\n" );
843 "InternetTimeFromSystemTimeA failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
844 error );
845}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
__u16 time
Definition: mkdosfs.c:8
#define error(str)
Definition: mkdosfs.c:1605
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define INTERNET_RFC1123_FORMAT
Definition: wininet.h:407
#define INTERNET_RFC1123_BUFSIZE
Definition: wininet.h:408

Referenced by START_TEST().

◆ InternetTimeFromSystemTimeW_test()

static void InternetTimeFromSystemTimeW_test ( void  )
static

Definition at line 847 of file internet.c.

848{
849 BOOL ret;
850 static const SYSTEMTIME time = { 2005, 1, 5, 7, 12, 6, 35, 0 };
852 static const WCHAR expect[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
853 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
854 DWORD error;
855
856 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
857 ok( ret, "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
858
859 ok( !memcmp( string, expect, sizeof(expect) ),
860 "InternetTimeFromSystemTimeW failed (%u)\n", GetLastError() );
861
862 /* test NULL time parameter */
863 SetLastError(0xdeadbeef);
864 ret = pInternetTimeFromSystemTimeW( NULL, INTERNET_RFC1123_FORMAT, string, sizeof(string) );
866 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
868 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
869 error );
870
871 /* test NULL string parameter */
872 SetLastError(0xdeadbeef);
873 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, NULL, sizeof(string) );
875 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
877 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
878 error );
879
880 /* test invalid format parameter */
881 SetLastError(0xdeadbeef);
882 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT + 1, string, sizeof(string) );
884 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
886 "InternetTimeFromSystemTimeW failed with ERROR_INVALID_PARAMETER instead of %u\n",
887 error );
888
889 /* test too small buffer size */
890 SetLastError(0xdeadbeef);
891 ret = pInternetTimeFromSystemTimeW( &time, INTERNET_RFC1123_FORMAT, string, ARRAY_SIZE(string));
893 ok( !ret, "InternetTimeFromSystemTimeW should have returned FALSE\n" );
895 "InternetTimeFromSystemTimeW failed with ERROR_INSUFFICIENT_BUFFER instead of %u\n",
896 error );
897}
#define ARRAY_SIZE(A)
Definition: main.h:33
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ InternetTimeToSystemTimeA_test()

static void InternetTimeToSystemTimeA_test ( void  )
static

Definition at line 899 of file internet.c.

900{
901 BOOL ret;
903 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
904 static const char string[] = "Fri, 07 Jan 2005 12:06:35 GMT";
905 static const char string2[] = " fri 7 jan 2005 12 06 35";
906
907 ret = pInternetTimeToSystemTimeA( string, &time, 0 );
908 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
909 ok( !memcmp( &time, &expect, sizeof(expect) ),
910 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
911
912 ret = pInternetTimeToSystemTimeA( string2, &time, 0 );
913 ok( ret, "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
914 ok( !memcmp( &time, &expect, sizeof(expect) ),
915 "InternetTimeToSystemTimeA failed (%u)\n", GetLastError() );
916}
static CHAR string2[MAX_PATH]
Definition: automation.c:449

Referenced by START_TEST().

◆ InternetTimeToSystemTimeW_test()

static void InternetTimeToSystemTimeW_test ( void  )
static

Definition at line 918 of file internet.c.

919{
920 BOOL ret;
922 static const SYSTEMTIME expect = { 2005, 1, 5, 7, 12, 6, 35, 0 };
923 static const WCHAR string[] = { 'F','r','i',',',' ','0','7',' ','J','a','n',' ','2','0','0','5',' ',
924 '1','2',':','0','6',':','3','5',' ','G','M','T',0 };
925 static const WCHAR string2[] = { ' ','f','r','i',' ','7',' ','j','a','n',' ','2','0','0','5',' ',
926 '1','2',' ','0','6',' ','3','5',0 };
927 static const WCHAR string3[] = { 'F','r',0 };
928
929 ret = pInternetTimeToSystemTimeW( NULL, NULL, 0 );
930 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
931
932 ret = pInternetTimeToSystemTimeW( NULL, &time, 0 );
933 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
934
935 ret = pInternetTimeToSystemTimeW( string, NULL, 0 );
936 ok( !ret, "InternetTimeToSystemTimeW succeeded (%u)\n", GetLastError() );
937
938 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
939 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
940
941 ret = pInternetTimeToSystemTimeW( string, &time, 0 );
942 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
943 ok( !memcmp( &time, &expect, sizeof(expect) ),
944 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
945
946 ret = pInternetTimeToSystemTimeW( string2, &time, 0 );
947 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
948 ok( !memcmp( &time, &expect, sizeof(expect) ),
949 "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
950
951 ret = pInternetTimeToSystemTimeW( string3, &time, 0 );
952 ok( ret, "InternetTimeToSystemTimeW failed (%u)\n", GetLastError() );
953}
static CHAR string3[MAX_PATH]
Definition: editor.c:42

Referenced by START_TEST().

◆ r_verifyProxyEnable()

static void r_verifyProxyEnable ( LONG  l,
DWORD  exp 
)
static

Definition at line 1222 of file internet.c.

1223{
1224 HKEY hkey;
1225 DWORD type, val, size = sizeof(DWORD);
1226 LONG ret;
1227 static const CHAR szInternetSettings[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
1228 static const CHAR szProxyEnable[] = "ProxyEnable";
1229
1231 ok_(__FILE__,l) (!ret, "RegOpenKeyA failed: 0x%08x\n", ret);
1232
1233 ret = RegQueryValueExA(hkey, szProxyEnable, 0, &type, (BYTE*)&val, &size);
1234 ok_(__FILE__,l) (!ret, "RegQueryValueExA failed: 0x%08x\n", ret);
1235 ok_(__FILE__,l) (type == REG_DWORD, "Expected regtype to be REG_DWORD, was: %d\n", type);
1236 ok_(__FILE__,l) (val == exp, "Expected ProxyEnabled to be %d, got: %d\n", exp, val);
1237
1238 ret = RegCloseKey(hkey);
1239 ok_(__FILE__,l) (!ret, "RegCloseKey failed: 0x%08x\n", ret);
1240}
#define ok_(x1, x2)
Definition: atltest.h:61
#define RegCloseKey(hKey)
Definition: registry.h:49
r l[0]
Definition: byte_order.h:168
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3263
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:4038
static const WCHAR szInternetSettings[]
Definition: internet.c:100
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint GLfloat * val
Definition: glext.h:7180
DWORD exp
Definition: msg.c:16058
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define REG_DWORD
Definition: sdbapi.c:596
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193

◆ START_TEST()

START_TEST ( internet  )

Definition at line 1872 of file internet.c.

1873{
1874 HMODULE hdll;
1875 hdll = GetModuleHandleA("wininet.dll");
1876
1877 pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
1878 pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
1879 pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
1880 pInternetTimeFromSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeW");
1881 pInternetTimeToSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeA");
1882 pInternetTimeToSystemTimeW = (void*)GetProcAddress(hdll, "InternetTimeToSystemTimeW");
1883 pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
1884 pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
1885 pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
1886 pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
1887 pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
1888 pInternetGetConnectedStateExA = (void*)GetProcAddress(hdll, "InternetGetConnectedStateExA");
1889 pInternetGetConnectedStateExW = (void*)GetProcAddress(hdll, "InternetGetConnectedStateExW");
1890
1891 if(!pInternetGetCookieExW) {
1892 win_skip("Too old IE (older than 6.0)\n");
1893 return;
1894 }
1895
1904 test_version();
1905 test_null();
1910
1911 if (!pInternetTimeFromSystemTimeA)
1912 win_skip("skipping the InternetTime tests\n");
1913 else
1914 {
1919 }
1920 if (pIsDomainLegalCookieDomainW &&
1921 ((void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerA ||
1922 (void*)pIsDomainLegalCookieDomainW == (void*)pCreateUrlCacheContainerW))
1923 win_skip("IsDomainLegalCookieDomainW is not available on systems with IE5\n");
1924 else if (!pIsDomainLegalCookieDomainW)
1925 win_skip("IsDomainLegalCookieDomainW (or ordinal 117) is not available\n");
1926 else
1928
1929 if (pPrivacyGetZonePreferenceW && pPrivacySetZonePreferenceW)
1931 else
1932 win_skip("Privacy[SG]etZonePreferenceW are not available\n");
1933
1937}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static void test_PrivacyGetSetZonePreferenceW(void)
Definition: internet.c:1071
static void test_Option_PerConnectionOption(void)
Definition: internet.c:1242
static void test_IsDomainLegalCookieDomainW(void)
Definition: internet.c:955
static void test_get_cookie(void)
Definition: internet.c:359
static void test_InternetQueryOptionA(void)
Definition: internet.c:160
static void test_cookie_url(void)
Definition: internet.c:618
static void test_InternetErrorDlg(void)
Definition: internet.c:1470
static void InternetTimeToSystemTimeW_test(void)
Definition: internet.c:918
static void test_InternetCanonicalizeUrlA(void)
Definition: internet.c:52
static void test_max_conns(void)
Definition: internet.c:312
static void test_InternetSetOption(void)
Definition: internet.c:1107
static void test_InternetGetConnectedStateExA(void)
Definition: internet.c:1598
static void test_Option_PerConnectionOptionA(void)
Definition: internet.c:1370
static void test_end_browser_session(void)
Definition: internet.c:1199
static void test_InternetGetConnectedStateExW(void)
Definition: internet.c:1700
static void test_cookie_attrs(void)
Definition: internet.c:563
static void test_complicated_cookie(void)
Definition: internet.c:374
static void test_null(void)
Definition: internet.c:666
static void InternetTimeFromSystemTimeW_test(void)
Definition: internet.c:847
static void test_version(void)
Definition: internet.c:783
static void InternetTimeToSystemTimeA_test(void)
Definition: internet.c:899
static void test_format_message(HMODULE hdll)
Definition: internet.c:1811
static void InternetTimeFromSystemTimeA_test(void)
Definition: internet.c:796
#define win_skip
Definition: test.h:160
static PVOID hdll
Definition: shimdbg.c:126
const char * LPCSTR
Definition: xmlstorage.h:183

◆ test_complicated_cookie()

static void test_complicated_cookie ( void  )
static

Definition at line 374 of file internet.c.

375{
376 DWORD len;
377 BOOL ret;
378
379 CHAR buffer[1024];
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", len);
514 ok(strstr(buffer,"A=B")!=NULL,"A=B missing\n");
515 ok(strstr(buffer,"C=D")!=NULL,"C=D missing\n");
516 ok(strstr(buffer,"E=F")!=NULL,"E=F missing\n");
517 ok(strstr(buffer,"G=H")==NULL,"G=H present\n");
518 ok(strstr(buffer,"I=J")!=NULL,"I=J missing\n");
519 ok(strstr(buffer,"K=L")!=NULL,"K=L missing\n");
520 ok(strstr(buffer,"M=N")==NULL,"M=N present\n");
521 ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
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", len);
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 /* test invalid expires parameter */
534 ret = InternetSetCookieA("http://testing.example.com", NULL, "Q=R; expires=");
535 ok(ret, "InternetSetCookie failed %#x.\n", GetLastError());
536 len = 1024;
537 memset(buffer, 0xac, sizeof(buffer));
538 ret = InternetGetCookieA("http://testing.example.com/", NULL, buffer, &len);
539 ok(ret, "InternetGetCookie failed %#x.\n", GetLastError());
540 ok(len == 29, "got len %u.\n", len);
541 ok(!!strstr(buffer, "Q=R"), "cookie is not present.\n");
542
543 len = sizeof(buffer);
544 ret = InternetGetCookieA("http://testing.example.com/foobar", NULL, buffer, &len);
545 ok(ret, "got error %#x\n", GetLastError());
546 ok(len == 29, "got len %u\n", len);
547 ok(!!strstr(buffer, "A=B"), "cookie is not present\n");
548
549 /* remove persistent cookie */
550 ret = InternetSetCookieA("http://testing.example.com", NULL, "A=B");
551 ok(ret, "InternetSetCookie failed with error %d\n", GetLastError());
552
553 /* try setting cookie for different domain */
554 ret = InternetSetCookieA("http://www.aaa.example.com/bar",NULL,"E=F; domain=different.com");
555 ok(!ret, "InternetSetCookie succeeded\n");
556 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %d\n", GetLastError());
557 ret = InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=example.com.pl");
558 ok(ret, "InternetSetCookie failed with error: %d\n", GetLastError());
559 ret = InternetSetCookieA("http://www.aaa.example.com.pl/bar",NULL,"E=F; domain=com.pl");
560 todo_wine ok(!ret, "InternetSetCookie succeeded\n");
561}
#define broken(x)
Definition: _sntprintf.h:21
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
#define lstrlenW
Definition: compat.h:750
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define todo_wine
Definition: custom.c:79
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI InternetGetCookieA(const char *url, const char *name, char *data, DWORD *size)
Definition: cookie.c:862
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPCSTR lpCookieData)
Definition: cookie.c:1139
BOOL WINAPI InternetGetCookieW(const WCHAR *url, const WCHAR *name, WCHAR *data, DWORD *size)
Definition: cookie.c:792

Referenced by START_TEST().

◆ test_cookie_attrs()

static void test_cookie_attrs ( void  )
static

Definition at line 563 of file internet.c.

564{
565 char buf[100];
567 BOOL ret;
568
569 if(!GetProcAddress(GetModuleHandleA("wininet.dll"), "DeleteWpadCacheForNetworks")) {
570 win_skip("Skipping cookie attributes tests. Too old IE.\n");
571 return;
572 }
573
574 ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=data; httponly");
575 ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
576
577 SetLastError(0xdeadbeef);
578 state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data; httponly", 0, 0);
580 "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
581
582 size = sizeof(buf);
583 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
584 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
585
586 state = InternetSetCookieExA("http://cookie.attrs.com/bar",NULL,"A=data; httponly", INTERNET_COOKIE_HTTPONLY, 0);
587 ok(state == COOKIE_STATE_ACCEPT,"InternetSetCookieEx failed: %u\n", GetLastError());
588
589 size = sizeof(buf);
590 ret = InternetGetCookieA("http://cookie.attrs.com/", NULL, buf, &size);
591 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned: %x (%u)\n", ret, GetLastError());
592
593 size = sizeof(buf);
594 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, 0, NULL);
595 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieEx returned: %x (%u)\n", ret, GetLastError());
596
597 size = sizeof(buf);
598 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
599 ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
600 ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
601
602 /* Try to override httponly cookie with non-httponly one */
603 ret = InternetSetCookieA("http://cookie.attrs.com/bar", NULL, "A=test");
604 ok(!ret && GetLastError() == ERROR_INVALID_OPERATION, "InternetSetCookie returned: %x (%u)\n", ret, GetLastError());
605
606 SetLastError(0xdeadbeef);
607 state = InternetSetCookieExA("http://cookie.attrs.com/bar", NULL, "A=data", 0, 0);
609 "InternetSetCookieEx returned: %x (%u)\n", ret, GetLastError());
610
611 size = sizeof(buf);
612 ret = InternetGetCookieExA("http://cookie.attrs.com/", NULL, buf, &size, INTERNET_COOKIE_HTTPONLY, NULL);
613 ok(ret, "InternetGetCookieEx failed: %u\n", GetLastError());
614 ok(!strcmp(buf, "A=data"), "data = %s\n", buf);
615
616}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
static int state
Definition: maze.c:121
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define ERROR_INVALID_OPERATION
Definition: winerror.h:1261
DWORD WINAPI InternetSetCookieExA(LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData, DWORD dwFlags, DWORD_PTR dwReserved)
Definition: cookie.c:1165
BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPSTR lpCookieData, LPDWORD lpdwSize, DWORD flags, void *reserved)
Definition: cookie.c:809
#define INTERNET_COOKIE_HTTPONLY
Definition: wininet.h:1828
@ COOKIE_STATE_ACCEPT
Definition: wininet.h:1792
@ COOKIE_STATE_REJECT
Definition: wininet.h:1796

Referenced by START_TEST().

◆ test_cookie_url()

static void test_cookie_url ( void  )
static

Definition at line 618 of file internet.c.

619{
620 char long_url[5000] = "http://long.url.test.com/", *p;
621 WCHAR bufw[512];
622 char buf[512];
623 DWORD len;
624 BOOL res;
625
626 static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
627
628 len = sizeof(buf);
629 res = InternetGetCookieA("about:blank", NULL, buf, &len);
631 "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
632
633 len = ARRAY_SIZE(bufw);
636 "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
637
638 len = sizeof(buf);
639 res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
641 "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
642
643 len = ARRAY_SIZE(bufw);
644 res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
646 "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
647
648 p = long_url + strlen(long_url);
649 memset(p, 'x', long_url+sizeof(long_url)-p);
650 p += (long_url+sizeof(long_url)-p) - 3;
651 p[0] = '/';
652 p[2] = 0;
653 res = InternetSetCookieA(long_url, NULL, "A=B");
654 ok(res, "InternetSetCookieA failed: %u\n", GetLastError());
655
656 len = sizeof(buf);
657 res = InternetGetCookieA(long_url, NULL, buf, &len);
658 ok(res, "InternetGetCookieA failed: %u\n", GetLastError());
659 ok(!strcmp(buf, "A=B"), "buf = %s\n", buf);
660
661 len = sizeof(buf);
662 res = InternetGetCookieA("http://long.url.test.com/", NULL, buf, &len);
663 ok(!res && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookieA failed: %u\n", GetLastError());
664}
GLuint res
Definition: glext.h:9613
GLfloat GLfloat p
Definition: glext.h:8902
static const WCHAR about_blankW[]
Definition: persist.c:24

Referenced by START_TEST().

◆ test_end_browser_session()

static void test_end_browser_session ( void  )
static

Definition at line 1199 of file internet.c.

1200{
1201 DWORD len;
1202 BOOL ret;
1203
1204 ret = InternetSetCookieA("http://www.example.com/test_end", NULL, "A=B");
1205 ok(ret == TRUE, "InternetSetCookie failed\n");
1206
1207 len = 1024;
1208 ret = InternetGetCookieA("http://www.example.com/test_end", NULL, NULL, &len);
1209 ok(ret == TRUE,"InternetGetCookie failed\n");
1210 ok(len != 0, "len = 0\n");
1211
1213 ok(ret, "InternetSetOption(INTERNET_OPTION_END_BROWSER_SESSION) failed: %u\n", GetLastError());
1214
1215 len = 1024;
1216 ret = InternetGetCookieA("http://www.example.com/test_end", NULL, NULL, &len);
1217 ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS, "InternetGetCookie returned %x (%u)\n", ret, GetLastError());
1218 ok(!len, "len = %u\n", len);
1219}
BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:3131
#define INTERNET_OPTION_END_BROWSER_SESSION
Definition: wininet.h:736

Referenced by START_TEST().

◆ test_format_message()

static void test_format_message ( HMODULE  hdll)
static

Definition at line 1811 of file internet.c.

1812{
1813 DWORD ret;
1814 CHAR out[0x100];
1815
1816 /* These messages come from wininet and not the system. */
1819 ok(ret == 0, "FormatMessageA returned %d\n", ret);
1820
1823 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1824
1827 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1828
1831 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1832
1835 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1836
1839 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1840
1843 ok(ret != 0 || broken(!ret) /* XP, w2k3 */, "FormatMessageA returned %d\n", ret);
1844
1847 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1848
1851 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1852
1855 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1856
1859 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1860
1863 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1864
1867 ok(ret != 0, "FormatMessageA returned %d\n", ret);
1868}
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 FILE * out
Definition: regtests2xml.c:44
#define LANG_NEUTRAL
Definition: nls.h:22
#define MAKELANGID(p, s)
Definition: nls.h:15
#define SUBLANG_NEUTRAL
Definition: nls.h:167
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:422
#define ERROR_INTERNET_SEC_CERT_CN_INVALID
Definition: wininet.h:2026
#define ERROR_INTERNET_INVALID_URL
Definition: wininet.h:1994
#define ERROR_INTERNET_OPERATION_CANCELLED
Definition: wininet.h:2006
#define ERROR_INTERNET_ITEM_NOT_FOUND
Definition: wininet.h:2017
#define ERROR_INTERNET_TIMEOUT
Definition: wininet.h:1991
#define ERROR_INTERNET_CONNECTION_ABORTED
Definition: wininet.h:2019
#define ERROR_INTERNET_SEC_CERT_DATE_INVALID
Definition: wininet.h:2025
#define ERROR_INTERNET_INVALID_OPERATION
Definition: wininet.h:2005
#define ERROR_INTERNET_CANNOT_CONNECT
Definition: wininet.h:2018
#define ERROR_INTERNET_NAME_NOT_RESOLVED
Definition: wininet.h:1996
#define ERROR_INTERNET_UNRECOGNIZED_SCHEME
Definition: wininet.h:1995
#define ERROR_INTERNET_INTERNAL_ERROR
Definition: wininet.h:1993

Referenced by START_TEST().

◆ test_get_cookie()

static void test_get_cookie ( void  )
static

Definition at line 359 of file internet.c.

360{
361 DWORD len;
362 BOOL ret;
363
364 len = 1024;
365 SetLastError(0xdeadbeef);
366 ret = InternetGetCookieA("http://www.example.com", NULL, NULL, &len);
368 "InternetGetCookie should have failed with %s and error %d\n",
369 ret ? "TRUE" : "FALSE", GetLastError());
370 ok(!len, "len = %u\n", len);
371}

Referenced by START_TEST().

◆ test_InternetCanonicalizeUrlA()

static void test_InternetCanonicalizeUrlA ( void  )
static

Definition at line 52 of file internet.c.

53{
54 CHAR buffer[256];
55 LPCSTR url;
56 DWORD urllen;
58 DWORD res;
59
60 /* Acrobat Updater 5 calls this for Adobe Reader 8.1 */
61 url = "http://swupmf.adobe.com/manifest/50/win/AdobeUpdater.upd";
62 urllen = lstrlenA(url);
63
64 memset(buffer, '#', sizeof(buffer)-1);
65 buffer[sizeof(buffer)-1] = '\0';
66 dwSize = 1; /* Acrobat Updater use this size */
67 SetLastError(0xdeadbeef);
69 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
70 "got %u and %u with size %u for '%s' (%d)\n",
72
73
74 /* buffer has no space for the terminating '\0' */
75 memset(buffer, '#', sizeof(buffer)-1);
76 buffer[sizeof(buffer)-1] = '\0';
77 dwSize = urllen;
78 SetLastError(0xdeadbeef);
80 /* dwSize is nr. of needed bytes with the terminating '\0' */
81 ok( !res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER) && (dwSize == (urllen+1)),
82 "got %u and %u with size %u for '%s' (%d)\n",
84
85 /* buffer has the required size */
86 memset(buffer, '#', sizeof(buffer)-1);
87 buffer[sizeof(buffer)-1] = '\0';
88 dwSize = urllen+1;
89 SetLastError(0xdeadbeef);
91 /* dwSize is nr. of copied bytes without the terminating '\0' */
92 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
93 "got %u and %u with size %u for '%s' (%d)\n",
95
96 memset(buffer, '#', sizeof(buffer)-1);
97 buffer[sizeof(buffer)-1] = '\0';
98 dwSize = sizeof(buffer);
99 SetLastError(0xdeadbeef);
100 res = InternetCanonicalizeUrlA("file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml", buffer, &dwSize, ICU_DECODE | ICU_NO_ENCODE);
101 ok(res, "InternetCanonicalizeUrlA failed %u\n", GetLastError());
102 ok(dwSize == lstrlenA(buffer), "got %d expected %d\n", dwSize, lstrlenA(buffer));
103 ok(!lstrcmpA("file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml", buffer),
104 "got %s expected 'file://C:\\Program Files\\Atmel\\AVR Tools\\STK500\\STK500.xml'\n", buffer);
105
106 /* buffer is larger as the required size */
107 memset(buffer, '#', sizeof(buffer)-1);
108 buffer[sizeof(buffer)-1] = '\0';
109 dwSize = urllen+2;
110 SetLastError(0xdeadbeef);
112 /* dwSize is nr. of copied bytes without the terminating '\0' */
113 ok( res && (dwSize == urllen) && (lstrcmpA(url, buffer) == 0),
114 "got %u and %u with size %u for '%s' (%d)\n",
116
117
118 /* check NULL pointers */
119 memset(buffer, '#', urllen + 4);
120 buffer[urllen + 4] = '\0';
121 dwSize = urllen+1;
122 SetLastError(0xdeadbeef);
125 "got %u and %u with size %u for '%s' (%d)\n",
127
128 memset(buffer, '#', urllen + 4);
129 buffer[urllen + 4] = '\0';
130 dwSize = urllen+1;
131 SetLastError(0xdeadbeef);
134 "got %u and %u with size %u for '%s' (%d)\n",
136
137 memset(buffer, '#', urllen + 4);
138 buffer[urllen + 4] = '\0';
139 dwSize = urllen+1;
140 SetLastError(0xdeadbeef);
143 "got %u and %u with size %u for '%s' (%d)\n",
145
146 /* test with trailing space */
147 dwSize = 256;
148 res = InternetCanonicalizeUrlA("http://www.winehq.org/index.php?x= ", buffer, &dwSize, ICU_BROWSER_MODE);
149 ok(res == 1, "InternetCanonicalizeUrlA failed\n");
150 ok(!strcmp(buffer, "http://www.winehq.org/index.php?x="), "Trailing space should have been stripped even in ICU_BROWSER_MODE (%s)\n", buffer);
151
152 res = InternetSetOptionA(NULL, 0xdeadbeef, buffer, sizeof(buffer));
153 ok(!res, "InternetSetOptionA succeeded\n");
155 "InternetSetOptionA failed %u, expected ERROR_INTERNET_INVALID_OPTION\n", GetLastError());
156}
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:1978
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static const WCHAR url[]
Definition: encode.c:1432
#define ICU_DECODE
Definition: winhttp.h:291
#define ICU_BROWSER_MODE
Definition: winhttp.h:294
#define ICU_NO_ENCODE
Definition: winhttp.h:290
#define ERROR_INTERNET_INVALID_OPTION
Definition: wininet.h:1998

Referenced by START_TEST().

◆ test_InternetErrorDlg()

static void test_InternetErrorDlg ( void  )
static

Definition at line 1470 of file internet.c.

1471{
1472 HINTERNET ses, con, req;
1473 DWORD res;
1474 HWND hwnd;
1475 ULONG i;
1476 static const struct {
1477 DWORD error;
1478 DWORD res;
1479 DWORD test_flags;
1480 } no_ui_res[] = {
1500 };
1501
1503 ok(res == ERROR_INVALID_HANDLE, "Got %d\n", res);
1504
1506 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1507 con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1508 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1509 req = HttpOpenRequestA(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1510 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1511
1513 ok(hwnd != NULL, "GetDesktopWindow failed (%d)\n", GetLastError());
1514
1516 {
1517 DWORD expected = ERROR_NOT_SUPPORTED, test_flags = 0, j;
1518
1519 for (j = 0; j < ARRAY_SIZE(no_ui_res); ++j)
1520 {
1521 if (no_ui_res[j].error == i)
1522 {
1523 test_flags = no_ui_res[j].test_flags;
1524 expected = no_ui_res[j].res;
1525 }
1526 }
1527
1528 /* Try an invalid request handle */
1531 {
1532 ok(test_flags & FLAG_UNIMPL, "%i is unexpectedly unimplemented.\n", i);
1533 continue;
1534 }
1535 else
1536 ok(res == ERROR_INVALID_HANDLE, "Got %d (%d)\n", res, i);
1537
1538 /* With a valid req */
1540 continue; /* Crashes on windows XP */
1541
1543 continue; /* Interactive (XP, Win7) */
1545 continue; /* Interactive (Win10 1607+) */
1546
1548
1549 /* Handle some special cases */
1550 switch(i)
1551 {
1552 case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR: /* later 9.x versions */
1553 case ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR: /* later 9.x versions */
1554 case ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE: /* later 11.x versions */
1555 if(res == ERROR_CANCELLED)
1557 break;
1559 if (res == NTE_PROV_TYPE_NOT_DEF) /* XP, 2003 */
1561 break;
1563 if(res == ERROR_SUCCESS) /* win10 returns ERROR_SUCCESS */
1565 break;
1566 default: break;
1567 }
1568
1569 if (expected == ERROR_NOT_SUPPORTED && res == ERROR_CANCELLED) /* Win10 1607+ */
1571
1572 todo_wine_if(test_flags & FLAG_TODO)
1573 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1574
1575 /* Same thing with NULL hwnd */
1577 todo_wine_if(test_flags & FLAG_TODO)
1578 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1579
1580
1581 /* With a null req */
1582 if(test_flags & FLAG_NEEDREQ)
1584
1587 ok(res == expected, "Got %d, expected %d (%d)\n", res, expected, i);
1588 }
1589
1590 res = InternetCloseHandle(req);
1591 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1592 res = InternetCloseHandle(con);
1593 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1594 res = InternetCloseHandle(ses);
1595 ok(res == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1596}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
DWORD WINAPI InternetErrorDlg(HWND hWnd, HINTERNET hRequest, DWORD dwError, DWORD dwFlags, LPVOID *lppvData)
Definition: dialogs.c:472
HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:1410
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType, LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:1057
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1321
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
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
BOOL expected
Definition: store.c:2063
#define todo_wine_if(is_todo)
Definition: custom.c:76
#define FLAG_UNIMPL
Definition: internet.c:1468
#define FLAG_TODO
Definition: internet.c:1466
#define FLAG_NEEDREQ
Definition: internet.c:1467
uint32_t ULONG
Definition: typedefs.h:59
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define ERROR_CANCELLED
Definition: winerror.h:726
#define NTE_PROV_TYPE_NOT_DEF
Definition: winerror.h:2891
#define INTERNET_ERROR_BASE
Definition: wininet.h:1988
#define ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR
Definition: wininet.h:2027
#define ERROR_INTERNET_NEED_UI
Definition: wininet.h:2023
#define ERROR_INTERNET_INSERT_CDROM
Definition: wininet.h:2040
#define ERROR_INTERNET_UNABLE_TO_DOWNLOAD_SCRIPT
Definition: wininet.h:2076
#define ERROR_INTERNET_FORTEZZA_LOGIN_NEEDED
Definition: wininet.h:2041
#define ERROR_INTERNET_INVALID_CA
Definition: wininet.h:2033
#define ERROR_INTERNET_INCORRECT_PASSWORD
Definition: wininet.h:2003
#define ERROR_INTERNET_CHG_POST_IS_NON_SECURE
Definition: wininet.h:2030
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
#define ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED
Definition: wininet.h:2032
#define ERROR_HTTP_COOKIE_NEEDS_CONFIRMATION
Definition: wininet.h:2066
#define FLAGS_ERROR_UI_FLAGS_NO_UI
Definition: wininet.h:1909
#define ERROR_HTTP_COOKIE_DECLINED
Definition: wininet.h:2067
#define ERROR_HTTP_REDIRECT_NEEDS_CONFIRMATION
Definition: wininet.h:2068
#define ERROR_INTERNET_MIXED_SECURITY
Definition: wininet.h:2029
#define ERROR_INTERNET_SEC_CERT_WEAK_SIGNATURE
Definition: wininet.h:2045
#define ERROR_INTERNET_HTTPS_HTTP_SUBMIT_REDIR
Definition: wininet.h:2039
#define INTERNET_ERROR_LAST
Definition: wininet.h:2084
#define ERROR_INTERNET_POST_IS_NON_SECURE
Definition: wininet.h:2031
#define ERROR_INTERNET_SEC_CERT_REV_FAILED
Definition: wininet.h:2044
#define ERROR_INTERNET_SEC_CERT_REVOKED
Definition: wininet.h:2078
#define ERROR_INTERNET_SEC_CERT_ERRORS
Definition: wininet.h:2042
#define ERROR_INTERNET_BAD_AUTO_PROXY_SCRIPT
Definition: wininet.h:2075
#define ERROR_INTERNET_HTTPS_TO_HTTP_ON_REDIR
Definition: wininet.h:2028
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
#define ERROR_INTERNET_PROXY_ALERT
Definition: winineti.h:112
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:656

Referenced by START_TEST().

◆ test_InternetGetConnectedStateExA()

static void test_InternetGetConnectedStateExA ( void  )
static

Definition at line 1598 of file internet.c.

1599{
1600 BOOL res;
1601 CHAR buffer[256];
1602 DWORD flags, sz;
1603
1604 if(!pInternetGetConnectedStateExA) {
1605 win_skip("InternetGetConnectedStateExA is not supported\n");
1606 return;
1607 }
1608
1609 flags = 0;
1610 buffer[0] = 0;
1611 res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0);
1612 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, buffer);
1614 ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n");
1615 if(!res) {
1616 win_skip("InternetGetConnectedStateExA tests require a valid connection\n");
1617 return;
1618 }
1619
1620 res = pInternetGetConnectedStateExA(NULL, NULL, 0, 0);
1621 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1622
1623 flags = 0;
1624 res = pInternetGetConnectedStateExA(&flags, NULL, 0, 0);
1625 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1627 {
1628 ok(flags & INTERNET_CONNECTION_MODEM, "Modem connection flag missing\n");
1629 ok(flags & ~INTERNET_CONNECTION_LAN, "Mixed Modem and LAN flags\n");
1630 }
1631 else
1632 {
1633 ok(flags & INTERNET_CONNECTION_LAN, "LAN connection flag missing\n");
1634 ok(flags & ~INTERNET_CONNECTION_MODEM, "Mixed Modem and LAN flags\n");
1635 }
1636
1637 buffer[0] = 0;
1638 flags = 0;
1639 res = pInternetGetConnectedStateExA(&flags, buffer, 0, 0);
1640 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1641 ok(flags, "Expected at least one flag set\n");
1642 ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
1643
1644 buffer[0] = 0;
1645 res = pInternetGetConnectedStateExA(NULL, buffer, sizeof(buffer), 0);
1646 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1647 sz = strlen(buffer);
1648 ok(sz > 0, "Expected a connection name\n");
1649
1650 buffer[0] = 0;
1651 flags = 0;
1652 res = pInternetGetConnectedStateExA(&flags, buffer, sizeof(buffer), 0);
1653 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1654 ok(flags, "Expected at least one flag set\n");
1655 sz = strlen(buffer);
1656 ok(sz > 0, "Expected a connection name\n");
1657
1658 flags = 0;
1659 res = pInternetGetConnectedStateExA(&flags, NULL, sizeof(buffer), 0);
1660 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1661 ok(flags, "Expected at least one flag set\n");
1662
1663 /* no space for complete string this time */
1664 buffer[0] = 0;
1665 flags = 0;
1666 res = pInternetGetConnectedStateExA(&flags, buffer, sz, 0);
1667 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1668 ok(flags, "Expected at least one flag set\n");
1669 ok(sz - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenA(buffer));
1670
1671 buffer[0] = 0;
1672 flags = 0;
1673 res = pInternetGetConnectedStateExA(&flags, buffer, sz / 2, 0);
1674 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1675 ok(flags, "Expected at least one flag set\n");
1676 ok(sz / 2 - 1 == strlen(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenA(buffer));
1677
1678 buffer[0] = 0;
1679 flags = 0;
1680 res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
1681 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1682 ok(flags, "Expected at least one flag set\n");
1683 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
1684
1685 buffer[0] = 0;
1686 flags = 0;
1687 res = pInternetGetConnectedStateExA(&flags, buffer, 2, 0);
1688 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1689 ok(flags, "Expected at least one flag set\n");
1690 ok(strlen(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenA(buffer));
1691
1692 flags = 0;
1693 buffer[0] = 0xDE;
1694 res = pInternetGetConnectedStateExA(&flags, buffer, 1, 0);
1695 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1696 ok(flags, "Expected at least one flag set\n");
1697 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenA(buffer));
1698}
#define trace
Definition: atltest.h:70
GLbitfield flags
Definition: glext.h:7161
#define INTERNET_CONNECTION_MODEM
Definition: wininet.h:2538
#define INTERNET_CONNECTION_LAN
Definition: wininet.h:2539
#define INTERNET_CONNECTION_CONFIGURED
Definition: wininet.h:2544
#define INTERNET_RAS_INSTALLED
Definition: wininet.h:2542

Referenced by START_TEST().

◆ test_InternetGetConnectedStateExW()

static void test_InternetGetConnectedStateExW ( void  )
static

Definition at line 1700 of file internet.c.

1701{
1702 BOOL res;
1703 WCHAR buffer[256];
1704 DWORD flags, sz;
1705
1706 if(!pInternetGetConnectedStateExW) {
1707 win_skip("InternetGetConnectedStateExW is not supported\n");
1708 return;
1709 }
1710
1711 flags = 0;
1712 buffer[0] = 0;
1713 res = pInternetGetConnectedStateExW(&flags, buffer, ARRAY_SIZE(buffer), 0);
1714 trace("Internet Connection: Flags 0x%02x - Name '%s'\n", flags, wine_dbgstr_w(buffer));
1716 ok (flags & INTERNET_RAS_INSTALLED, "Missing RAS flag\n");
1717 if(!res) {
1718 win_skip("InternetGetConnectedStateExW tests require a valid connection\n");
1719 return;
1720 }
1721
1722 res = pInternetGetConnectedStateExW(NULL, NULL, 0, 0);
1723 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1724
1725 flags = 0;
1726 res = pInternetGetConnectedStateExW(&flags, NULL, 0, 0);
1727 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1729 {
1730 ok(flags & INTERNET_CONNECTION_MODEM, "Modem connection flag missing\n");
1731 ok(flags & ~INTERNET_CONNECTION_LAN, "Mixed Modem and LAN flags\n");
1732 }
1733 else
1734 {
1735 ok(flags & INTERNET_CONNECTION_LAN, "LAN connection flag missing\n");
1736 ok(flags & ~INTERNET_CONNECTION_MODEM, "Mixed Modem and LAN flags\n");
1737 }
1738
1739 buffer[0] = 0;
1740 flags = 0;
1741 res = pInternetGetConnectedStateExW(&flags, buffer, 0, 0);
1742 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1743 ok(flags, "Expected at least one flag set\n");
1744 ok(!buffer[0], "Buffer must not change, got %02X\n", buffer[0]);
1745
1746 buffer[0] = 0;
1747 res = pInternetGetConnectedStateExW(NULL, buffer, ARRAY_SIZE(buffer), 0);
1748 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1749 sz = lstrlenW(buffer);
1750 ok(sz > 0, "Expected a connection name\n");
1751
1752 buffer[0] = 0;
1753 flags = 0;
1754 res = pInternetGetConnectedStateExW(&flags, buffer, ARRAY_SIZE(buffer), 0);
1755 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1756 ok(flags, "Expected at least one flag set\n");
1757 sz = lstrlenW(buffer);
1758 ok(sz > 0, "Expected a connection name\n");
1759
1760 flags = 0;
1761 res = pInternetGetConnectedStateExW(&flags, NULL, ARRAY_SIZE(buffer), 0);
1762 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1763 ok(flags, "Expected at least one flag set\n");
1764
1765 /* no space for complete string this time */
1766 buffer[0] = 0;
1767 flags = 0;
1768 res = pInternetGetConnectedStateExW(&flags, buffer, sz, 0);
1769 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1770 ok(flags, "Expected at least one flag set\n");
1772 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1773 else
1774 ok(sz - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz - 1, lstrlenW(buffer));
1775
1776 buffer[0] = 0;
1777 flags = 0;
1778 res = pInternetGetConnectedStateExW(&flags, buffer, sz / 2, 0);
1779 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1780 ok(flags, "Expected at least one flag set\n");
1782 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1783 else
1784 ok(sz / 2 - 1 == lstrlenW(buffer), "Expected %u bytes, got %u\n", sz / 2 - 1, lstrlenW(buffer));
1785
1786 buffer[0] = 0;
1787 flags = 0;
1788 res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
1789 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1790 ok(flags, "Expected at least one flag set\n");
1791 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1792
1793 buffer[0] = 0;
1794 flags = 0;
1795 res = pInternetGetConnectedStateExW(&flags, buffer, 2, 0);
1796 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1797 ok(flags, "Expected at least one flag set\n");
1799 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1800 else
1801 ok(lstrlenW(buffer) == 1, "Expected 1 byte, got %u\n", lstrlenW(buffer));
1802
1803 buffer[0] = 0xDEAD;
1804 flags = 0;
1805 res = pInternetGetConnectedStateExW(&flags, buffer, 1, 0);
1806 ok(res == TRUE, "Expected TRUE, got %d\n", res);
1807 ok(flags, "Expected at least one flag set\n");
1808 ok(!buffer[0], "Expected 0 bytes, got %u\n", lstrlenW(buffer));
1809}
#define wine_dbgstr_w
Definition: kernel32.h:34

Referenced by START_TEST().

◆ test_InternetQueryOptionA()

static void test_InternetQueryOptionA ( void  )
static

Definition at line 160 of file internet.c.

161{
162 HINTERNET hinet,hurl;
163 DWORD len, val;
164 DWORD err;
165 static const char useragent[] = {"Wininet Test"};
166 char *buffer;
167 int retval;
168 BOOL res;
169
170 SetLastError(0xdeadbeef);
171 len = 0xdeadbeef;
173 ok(!retval && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got wrong error %x(%u)\n", retval, GetLastError());
174 ok(len >= sizeof(INTERNET_PROXY_INFOA) && len != 0xdeadbeef,"len = %u\n", len);
175
176 hinet = InternetOpenA(useragent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL, 0);
177 ok((hinet != 0x0),"InternetOpen Failed\n");
178
179 SetLastError(0xdeadbeef);
182 ok(retval == 0,"Got wrong return value %d\n",retval);
183 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code%d\n",err);
184
185 SetLastError(0xdeadbeef);
186 len=strlen(useragent)+1;
189 ok(len == strlen(useragent)+1,"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
190 ok(retval == 0,"Got wrong return value %d\n",retval);
191 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n",err);
192
193 len=strlen(useragent)+1;
196 ok(retval == 1,"Got wrong return value %d\n",retval);
197 if (retval)
198 {
199 ok(!strcmp(useragent,buffer),"Got wrong user agent string %s instead of %s\n",buffer,useragent);
200 ok(len == strlen(useragent),"Got wrong user agent length %d instead of %d\n",len,lstrlenA(useragent));
201 }
203
204 SetLastError(0xdeadbeef);
205 len=0;
209 ok(len == strlen(useragent) + 1,"Got wrong user agent length %d instead of %d\n", len, lstrlenA(useragent) + 1);
210 ok(!retval, "Got wrong return value %d\n", retval);
211 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code %d\n", err);
213
215
216 SetLastError(0xdeadbeef);
217 len=0;
220 ok(len == 0,"Got wrong user agent length %d instead of 0\n",len);
221 ok(retval == 0,"Got wrong return value %d\n",retval);
222 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
223
224 SetLastError(0xdeadbeef);
225 len = sizeof(DWORD);
227 err = GetLastError();
228 ok(retval == 0,"Got wrong return value %d\n",retval);
229 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
230 ok(len == sizeof(DWORD), "len = %d\n", len);
231
232 SetLastError(0xdeadbeef);
233 len = sizeof(DWORD);
235 err = GetLastError();
236 ok(retval == 0,"Got wrong return value %d\n",retval);
237 ok(err == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Got wrong error code %d\n",err);
238 ok(!len, "len = %d\n", len);
239
241 InternetCloseHandle(hinet);
242
244 ok((hinet != 0x0),"InternetOpen Failed\n");
245
246 SetLastError(0xdeadbeef);
247 len=0;
250 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
251 ok(retval == 0,"Got wrong return value %d\n",retval);
252 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
253
254 InternetCloseHandle(hinet);
255
256 val = 12345;
258 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
259
260 len = sizeof(val);
262 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
263 ok(val == 12345, "val = %d\n", val);
264 ok(len == sizeof(val), "len = %d\n", len);
265
267 ok((hinet != 0x0),"InternetOpen Failed\n");
268 SetLastError(0xdeadbeef);
269 len=0;
272 ok(len == 1,"Got wrong user agent length %d instead of %d\n",len,1);
273 ok(retval == 0,"Got wrong return value %d\n",retval);
274 ok(err == ERROR_INSUFFICIENT_BUFFER, "Got wrong error code%d\n",err);
275
276 len = sizeof(val);
277 val = 0xdeadbeef;
279 ok(!res, "InternetQueryOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
280 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
281
282 val = 2;
284 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
285 ok(GetLastError() == ERROR_INTERNET_INVALID_OPERATION, "GetLastError() = %u\n", GetLastError());
286
287 len = sizeof(val);
289 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
290 ok(val == 12345, "val = %d\n", val);
291 ok(len == sizeof(val), "len = %d\n", len);
292
293 val = 1;
295 ok(res, "InternetSetOptionA(INTERNET_OPTION_CONNECT_TIMEOUT) failed (%u)\n", GetLastError());
296
297 len = sizeof(val);
299 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
300 ok(val == 1, "val = %d\n", val);
301 ok(len == sizeof(val), "len = %d\n", len);
302
303 len = sizeof(val);
305 ok(res, "InternetQueryOptionA failed %d)\n", GetLastError());
306 ok(val == 12345, "val = %d\n", val);
307 ok(len == sizeof(val), "len = %d\n", len);
308
309 InternetCloseHandle(hinet);
310}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2730
#define err(...)
#define INTERNET_DEFAULT_HTTP_PORT
Definition: winhttp.h:36
#define INTERNET_OPTION_USER_AGENT
Definition: wininet.h:735
#define INTERNET_OPTION_CONNECT_TIMEOUT
Definition: wininet.h:701
#define INTERNET_OPTION_MAX_CONNS_PER_SERVER
Definition: wininet.h:763
#define INTERNET_OPTION_PROXY
Definition: wininet.h:732
#define ERROR_INTERNET_INCORRECT_HANDLE_TYPE
Definition: wininet.h:2007
#define INTERNET_OPTION_REQUEST_FLAGS
Definition: wininet.h:718

Referenced by START_TEST().

◆ test_InternetSetOption()

static void test_InternetSetOption ( void  )
static

Definition at line 1107 of file internet.c.

1108{
1109 HINTERNET ses, con, req;
1110 ULONG ulArg;
1111 DWORD size;
1112 BOOL ret;
1113
1115 ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
1116 con = InternetConnectA(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
1117 ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
1118 req = HttpOpenRequestA(con, "GET", "/", NULL, NULL, NULL, 0, 0);
1119 ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
1120
1121 /* INTERNET_OPTION_POLICY tests */
1122 SetLastError(0xdeadbeef);
1124 ok(ret == FALSE, "InternetSetOption should've failed\n");
1125 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1126 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1127
1128 SetLastError(0xdeadbeef);
1130 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1131 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
1132 "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
1133
1134 /* INTERNET_OPTION_ERROR_MASK tests */
1135 SetLastError(0xdeadbeef);
1136 size = sizeof(ulArg);
1138 ok(ret == FALSE, "InternetQueryOption should've failed\n");
1139 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1140
1141 SetLastError(0xdeadbeef);
1142 ulArg = 11;
1143 ret = InternetSetOptionA(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1144 ok(ret == FALSE, "InternetSetOption should've failed\n");
1145 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
1146
1147 SetLastError(0xdeadbeef);
1148 ulArg = 11;
1149 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
1150 ok(ret == FALSE, "InternetSetOption should've failed\n");
1151 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
1152
1153 ulArg = 11;
1154 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1155 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1156
1157 SetLastError(0xdeadbeef);
1158 ulArg = 4;
1159 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1160 ok(ret == FALSE, "InternetSetOption should've failed\n");
1161 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1162
1163 SetLastError(0xdeadbeef);
1164 ulArg = 16;
1165 ret = InternetSetOptionA(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
1166 ok(ret == FALSE, "InternetSetOption should've failed\n");
1167 ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
1168
1170 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1171
1173 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1174
1176 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1177
1179 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1180
1181 SetLastError(0xdeadbeef);
1183 ok(ret == FALSE, "InternetSetOption should've failed\n");
1184 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %u\n", GetLastError());
1185
1186 SetLastError(0xdeadbeef);
1188 ok(ret == FALSE, "InternetSetOption should've failed\n");
1189 ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %u\n", GetLastError());
1190
1191 ret = InternetCloseHandle(req);
1192 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1193 ret = InternetCloseHandle(con);
1194 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1195 ret = InternetCloseHandle(ses);
1196 ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
1197}
#define FALSE
Definition: types.h:117
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, LPDWORD lpdwBufferLength)
Definition: internet.c:2697
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption, LPVOID lpBuffer, DWORD dwBufferLength)
Definition: internet.c:2837
#define INTERNET_OPTION_ERROR_MASK
Definition: wininet.h:755
#define INTERNET_OPTION_POLICY
Definition: wininet.h:742
#define INTERNET_OPTION_REFRESH
Definition: wininet.h:731
#define ERROR_INTERNET_BAD_OPTION_LENGTH
Definition: wininet.h:1999
#define INTERNET_OPTION_SETTINGS_CHANGED
Definition: wininet.h:733

Referenced by START_TEST().

◆ test_IsDomainLegalCookieDomainW()

static void test_IsDomainLegalCookieDomainW ( void  )
static

Definition at line 955 of file internet.c.

956{
957 BOOL ret;
958 static const WCHAR empty[] = {0};
959 static const WCHAR dot[] = {'.',0};
960 static const WCHAR uk[] = {'u','k',0};
961 static const WCHAR com[] = {'c','o','m',0};
962 static const WCHAR dot_com[] = {'.','c','o','m',0};
963 static const WCHAR gmail_com[] = {'g','m','a','i','l','.','c','o','m',0};
964 static const WCHAR dot_gmail_com[] = {'.','g','m','a','i','l','.','c','o','m',0};
965 static const WCHAR www_gmail_com[] = {'w','w','w','.','g','m','a','i','l','.','c','o','m',0};
966 static const WCHAR www_mail_gmail_com[] = {'w','w','w','.','m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
967 static const WCHAR mail_gmail_com[] = {'m','a','i','l','.','g','m','a','i','l','.','c','o','m',0};
968 static const WCHAR gmail_co_uk[] = {'g','m','a','i','l','.','c','o','.','u','k',0};
969 static const WCHAR co_uk[] = {'c','o','.','u','k',0};
970 static const WCHAR dot_co_uk[] = {'.','c','o','.','u','k',0};
971
972 SetLastError(0xdeadbeef);
973 ret = pIsDomainLegalCookieDomainW(NULL, NULL);
975 {
976 win_skip("IsDomainLegalCookieDomainW is not implemented\n");
977 return;
978 }
979 ok(!ret ||
980 broken(ret), /* IE6 */
981 "IsDomainLegalCookieDomainW succeeded\n");
982
983 SetLastError(0xdeadbeef);
984 ret = pIsDomainLegalCookieDomainW(com, NULL);
985 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
986
987 SetLastError(0xdeadbeef);
988 ret = pIsDomainLegalCookieDomainW(NULL, gmail_com);
989 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
990
991 SetLastError(0xdeadbeef);
992 ret = pIsDomainLegalCookieDomainW(empty, gmail_com);
993 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
994
995 SetLastError(0xdeadbeef);
996 ret = pIsDomainLegalCookieDomainW(com, empty);
997 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
998
999 SetLastError(0xdeadbeef);
1000 ret = pIsDomainLegalCookieDomainW(gmail_com, dot);
1001 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1002
1003 SetLastError(0xdeadbeef);
1004 ret = pIsDomainLegalCookieDomainW(dot, gmail_com);
1005 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1006
1007 SetLastError(0xdeadbeef);
1008 ret = pIsDomainLegalCookieDomainW(com, com);
1009 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1010
1011 SetLastError(0xdeadbeef);
1012 ret = pIsDomainLegalCookieDomainW(com, dot_com);
1013 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1014
1015 SetLastError(0xdeadbeef);
1016 ret = pIsDomainLegalCookieDomainW(dot_com, com);
1017 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1018
1019 SetLastError(0xdeadbeef);
1020 ret = pIsDomainLegalCookieDomainW(com, gmail_com);
1021 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1022
1023 ret = pIsDomainLegalCookieDomainW(gmail_com, gmail_com);
1024 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1025
1026 ret = pIsDomainLegalCookieDomainW(gmail_com, www_gmail_com);
1027 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1028
1029 ret = pIsDomainLegalCookieDomainW(gmail_com, www_mail_gmail_com);
1030 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1031
1032 SetLastError(0xdeadbeef);
1033 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, co_uk);
1034 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1035
1036 ret = pIsDomainLegalCookieDomainW(uk, co_uk);
1037 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1038
1039 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, dot_co_uk);
1040 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1041
1042 ret = pIsDomainLegalCookieDomainW(co_uk, gmail_co_uk);
1043 todo_wine ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1044
1045 ret = pIsDomainLegalCookieDomainW(gmail_co_uk, gmail_co_uk);
1046 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1047
1048 ret = pIsDomainLegalCookieDomainW(gmail_com, com);
1049 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1050
1051 SetLastError(0xdeadbeef);
1052 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1053 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1054
1055 ret = pIsDomainLegalCookieDomainW(gmail_com, mail_gmail_com);
1056 ok(ret, "IsDomainLegalCookieDomainW failed\n");
1057
1058 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, gmail_com);
1059 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1060
1061 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, com);
1062 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1063
1064 ret = pIsDomainLegalCookieDomainW(dot_gmail_com, mail_gmail_com);
1065 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1066
1067 ret = pIsDomainLegalCookieDomainW(mail_gmail_com, dot_gmail_com);
1068 ok(!ret, "IsDomainLegalCookieDomainW succeeded\n");
1069}
static const WCHAR empty[]
Definition: main.c:47
IUnknown uk
Definition: typelib.c:6156

Referenced by START_TEST().

◆ test_max_conns()

static void test_max_conns ( void  )
static

Definition at line 312 of file internet.c.

313{
314 DWORD len, val;
315 BOOL res;
316
317 len = sizeof(val);
318 val = 0xdeadbeef;
320 ok(res,"Got wrong return value %x\n", res);
321 ok(len == sizeof(val), "got %d\n", len);
322 trace("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", val);
323
324 len = sizeof(val);
325 val = 0xdeadbeef;
327 ok(res,"Got wrong return value %x\n", res);
328 ok(len == sizeof(val), "got %d\n", len);
329 trace("INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER: %d\n", val);
330
331 val = 3;
333 ok(res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) failed: %x\n", res);
334
335 len = sizeof(val);
336 val = 0xdeadbeef;
338 ok(res,"Got wrong return value %x\n", res);
339 ok(len == sizeof(val), "got %d\n", len);
340 ok(val == 3, "got %d\n", val);
341
342 val = 0;
344 ok(!res || broken(res), /* <= w2k3 */
345 "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER, 0) succeeded\n");
346 if (!res) ok(GetLastError() == ERROR_BAD_ARGUMENTS, "GetLastError() = %u\n", GetLastError());
347
348 val = 2;
350 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
351 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
352
353 val = 2;
355 ok(!res, "InternetSetOptionA(INTERNET_OPTION_MAX_CONNS_PER_SERVER) succeeded\n");
356 ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %u\n", GetLastError());
357}
#define ERROR_BAD_ARGUMENTS
Definition: winerror.h:232
#define INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
Definition: wininet.h:764

Referenced by START_TEST().

◆ test_null()

static void test_null ( void  )
static

Definition at line 666 of file internet.c.

667{
668 HINTERNET hi, hc;
669 static const WCHAR szServer[] = { 's','e','r','v','e','r',0 };
670 static const WCHAR szServer2[] = { 's','e','r','v','e','r','=',0 };
671 static const WCHAR szEmpty[] = { 0 };
672 static const WCHAR szUrl[] = { 'h','t','t','p',':','/','/','a','.','b','.','c',0 };
673 static const WCHAR szUrlEmpty[] = { 'h','t','t','p',':','/','/',0 };
674 static const WCHAR szExpect[] = { 's','e','r','v','e','r',';',' ','s','e','r','v','e','r',0 };
675 WCHAR buffer[0x20];
676 BOOL r;
677 DWORD sz;
678
679 SetLastError(0xdeadbeef);
680 hi = InternetOpenW(NULL, 0, NULL, NULL, 0);
682 {
683 win_skip("Internet*W functions are not implemented\n");
684 return;
685 }
686 ok(hi != NULL, "open failed\n");
687
688 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, 0, 0, 0);
689 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
690 ok(hc == NULL, "connect failed\n");
691
693 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
694 ok(hc == NULL, "connect failed\n");
695
696 hc = InternetConnectW(hi, NULL, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
697 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
698 ok(hc == NULL, "connect failed\n");
699
700 hc = InternetConnectW(NULL, szServer, 0, NULL, NULL, INTERNET_SERVICE_FTP, 0, 0);
701 ok(GetLastError() == ERROR_INVALID_HANDLE, "wrong error\n");
702 ok(hc == NULL, "connect failed\n");
703
704 hc = InternetOpenUrlW(hi, NULL, NULL, 0, 0, 0);
707 ok(hc == NULL, "connect failed\n");
708
709 hc = InternetOpenUrlW(hi, szServer, NULL, 0, 0, 0);
711 ok(hc == NULL, "connect failed\n");
712
714
716 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
717 ok(r == FALSE, "return wrong\n");
718
719 r = InternetSetCookieW(szServer, NULL, NULL);
720 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
721 ok(r == FALSE, "return wrong\n");
722
723 r = InternetSetCookieW(szUrl, szServer, NULL);
724 ok(GetLastError() == ERROR_INVALID_PARAMETER, "wrong error\n");
725 ok(r == FALSE, "return wrong\n");
726
727 r = InternetSetCookieW(szUrl, szServer, szServer);
728 ok(r == TRUE, "return wrong\n");
729
730 r = InternetSetCookieW(szUrl, NULL, szServer);
731 ok(r == TRUE, "return wrong\n");
732
733 r = InternetSetCookieW(szUrl, szServer, szEmpty);
734 ok(r == TRUE, "return wrong\n");
735
736 r = InternetSetCookieW(szUrlEmpty, szServer, szServer);
737 ok(r == FALSE, "return wrong\n");
738
739 r = InternetSetCookieW(szServer, NULL, szServer);
741 ok(r == FALSE, "return wrong\n");
742
743 sz = 0;
746 "wrong error %u\n", GetLastError());
747 ok( r == FALSE, "return wrong\n");
748
749 r = InternetGetCookieW(szServer, NULL, NULL, &sz);
750 todo_wine {
752 }
753 ok( r == FALSE, "return wrong\n");
754
755 sz = 0;
756 r = InternetGetCookieW(szUrlEmpty, szServer, NULL, &sz);
757 ok( r == FALSE, "return wrong\n");
758
759 sz = 0;
760 r = InternetGetCookieW(szUrl, szServer, NULL, &sz);
761 ok( r == TRUE, "return wrong\n");
762
763 /* sz is 14 on XP SP2 and beyond, 30 on XP SP1 and before, 16 on IE11 */
764 ok( sz == 14 || sz == 16 || sz == 30, "sz wrong, got %u, expected 14, 16 or 30\n", sz);
765
766 sz = 0x20;
767 memset(buffer, 0, sizeof buffer);
768 r = InternetGetCookieW(szUrl, szServer, buffer, &sz);
769 ok( r == TRUE, "return wrong\n");
770
771 /* sz == lstrlenW(buffer) only in XP SP1 */
772 ok( sz == 1 + lstrlenW(buffer) || sz == lstrlenW(buffer), "sz wrong %d\n", sz);
773
774 /* before XP SP2, buffer is "server; server" */
775 ok( !lstrcmpW(szExpect, buffer) || !lstrcmpW(szServer, buffer) || !lstrcmpW(szServer2, buffer),
776 "cookie data wrong %s\n", wine_dbgstr_w(buffer));
777
778 sz = sizeof(buffer);
780 ok(r == TRUE, "ret %d\n", r);
781}
static const WCHAR szEmpty[]
Definition: provider.c:50
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl, LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3722
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1258
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
BOOL WINAPI InternetSetCookieW(const WCHAR *url, const WCHAR *name, const WCHAR *data)
Definition: cookie.c:1122
#define INTERNET_OPTION_CONNECTED_STATE
Definition: wininet.h:744
#define INTERNET_SERVICE_FTP
Definition: wininet.h:560

Referenced by START_TEST().

◆ test_Option_PerConnectionOption()

static void test_Option_PerConnectionOption ( void  )
static

Definition at line 1242 of file internet.c.

1243{
1244 BOOL ret;
1247 INTERNET_PER_CONN_OPTIONW *orig_settings;
1248 static WCHAR proxy_srvW[] = {'p','r','o','x','y','.','e','x','a','m','p','l','e',0};
1249
1250 /* get the global IE proxy server info, to restore later */
1251 list.dwOptionCount = 2;
1252 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1253
1254 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1255 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1256
1258 &list, &size);
1259 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1260 orig_settings = list.pOptions;
1261
1262 /* set the global IE proxy server */
1263 list.dwOptionCount = 2;
1264 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1265
1266 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1267 list.pOptions[0].Value.pszValue = proxy_srvW;
1268 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1269 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1270
1272 &list, size);
1273 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1274
1275 HeapFree(GetProcessHeap(), 0, list.pOptions);
1276
1277 /* get & verify the global IE proxy server */
1278 list.dwOptionCount = 2;
1279 list.dwOptionError = 0;
1280 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONW));
1281
1282 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1283 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1284
1286 &list, &size);
1287 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1288 ok(!lstrcmpW(list.pOptions[0].Value.pszValue, proxy_srvW),
1289 "Retrieved proxy server should've been %s, was: %s\n",
1290 wine_dbgstr_w(proxy_srvW), wine_dbgstr_w(list.pOptions[0].Value.pszValue));
1291 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1292 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1293 list.pOptions[1].Value.dwValue);
1295
1296 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1297 HeapFree(GetProcessHeap(), 0, list.pOptions);
1298
1299 /* disable the proxy server */
1300 list.dwOptionCount = 1;
1301 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1302
1303 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1304 list.pOptions[0].Value.dwValue = PROXY_TYPE_DIRECT;
1305
1307 &list, size);
1308 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1309
1310 HeapFree(GetProcessHeap(), 0, list.pOptions);
1311
1312 /* verify that the proxy is disabled */
1313 list.dwOptionCount = 1;
1314 list.dwOptionError = 0;
1315 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1316
1317 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1318
1320 &list, &size);
1321 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1322 ok(list.pOptions[0].Value.dwValue == PROXY_TYPE_DIRECT,
1323 "Retrieved flags should've been PROXY_TYPE_DIRECT, was: %d\n",
1324 list.pOptions[0].Value.dwValue);
1326
1327 HeapFree(GetProcessHeap(), 0, list.pOptions);
1328
1329 /* set the proxy flags to 'invalid' value */
1330 list.dwOptionCount = 1;
1331 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1332
1333 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1334 list.pOptions[0].Value.dwValue = PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT;
1335
1337 &list, size);
1338 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1339
1340 HeapFree(GetProcessHeap(), 0, list.pOptions);
1341
1342 /* verify that the proxy is enabled */
1343 list.dwOptionCount = 1;
1344 list.dwOptionError = 0;
1345 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW));
1346
1347 list.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS;
1348
1350 &list, &size);
1351 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1352 todo_wine ok(list.pOptions[0].Value.dwValue == (PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT),
1353 "Retrieved flags should've been PROXY_TYPE_PROXY | PROXY_TYPE_DIRECT, was: %d\n",
1354 list.pOptions[0].Value.dwValue);
1356
1357 HeapFree(GetProcessHeap(), 0, list.pOptions);
1358
1359 /* restore original settings */
1360 list.dwOptionCount = 2;
1361 list.pOptions = orig_settings;
1362
1364 &list, size);
1365 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1366
1367 HeapFree(GetProcessHeap(), 0, list.pOptions);
1368}
Definition: list.h:37
#define verifyProxyEnable(e)
Definition: internet.c:1221
#define INTERNET_PER_CONN_FLAGS
Definition: wininet.h:334
#define PROXY_TYPE_DIRECT
Definition: wininet.h:346
struct _INTERNET_PER_CONN_OPTION_LISTW INTERNET_PER_CONN_OPTION_LISTW
#define INTERNET_PER_CONN_PROXY_SERVER
Definition: wininet.h:335
#define INTERNET_OPTION_PER_CONNECTION_OPTION
Definition: wininet.h:765
#define PROXY_TYPE_PROXY
Definition: wininet.h:347

Referenced by START_TEST().

◆ test_Option_PerConnectionOptionA()

static void test_Option_PerConnectionOptionA ( void  )
static

Definition at line 1370 of file internet.c.

1371{
1372 BOOL ret;
1375 INTERNET_PER_CONN_OPTIONA *orig_settings;
1376 char proxy_srv[] = "proxy.example";
1377
1378 /* get the global IE proxy server info, to restore later */
1379 list.dwOptionCount = 2;
1380 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1381
1382 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1383 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1384
1386 &list, &size);
1387 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1388 orig_settings = list.pOptions;
1389
1390 /* set the global IE proxy server */
1391 list.dwOptionCount = 2;
1392 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1393
1394 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1395 list.pOptions[0].Value.pszValue = proxy_srv;
1396 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1397 list.pOptions[1].Value.dwValue = PROXY_TYPE_PROXY;
1398
1400 &list, size);
1401 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1402
1403 HeapFree(GetProcessHeap(), 0, list.pOptions);
1404
1405 /* get & verify the global IE proxy server */
1406 list.dwOptionCount = 2;
1407 list.dwOptionError = 0;
1408 list.pOptions = HeapAlloc(GetProcessHeap(), 0, 2 * sizeof(INTERNET_PER_CONN_OPTIONA));
1409
1410 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1411 list.pOptions[1].dwOption = INTERNET_PER_CONN_FLAGS;
1412
1414 &list, &size);
1415 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1416 ok(!lstrcmpA(list.pOptions[0].Value.pszValue, "proxy.example"),
1417 "Retrieved proxy server should've been \"%s\", was: \"%s\"\n",
1418 proxy_srv, list.pOptions[0].Value.pszValue);
1419 ok(list.pOptions[1].Value.dwValue == PROXY_TYPE_PROXY,
1420 "Retrieved flags should've been PROXY_TYPE_PROXY, was: %d\n",
1421 list.pOptions[1].Value.dwValue);
1422
1423 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1424 HeapFree(GetProcessHeap(), 0, list.pOptions);
1425
1426 /* test with NULL as proxy server */
1427 list.dwOptionCount = 1;
1428 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
1429 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1430 list.pOptions[0].Value.pszValue = NULL;
1431
1433 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1434
1436 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1437
1438 HeapFree(GetProcessHeap(), 0, list.pOptions);
1439
1440 /* get & verify the proxy server */
1441 list.dwOptionCount = 1;
1442 list.dwOptionError = 0;
1443 list.pOptions = HeapAlloc(GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONA));
1444 list.pOptions[0].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
1445
1447 ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
1448 ok(!list.pOptions[0].Value.pszValue,
1449 "Retrieved proxy server should've been NULL, was: \"%s\"\n",
1450 list.pOptions[0].Value.pszValue);
1451
1452 HeapFree(GetProcessHeap(), 0, list.pOptions[0].Value.pszValue);
1453 HeapFree(GetProcessHeap(), 0, list.pOptions);
1454
1455 /* restore original settings */
1456 list.dwOptionCount = 2;
1457 list.pOptions = orig_settings;
1458
1460 &list, size);
1461 ok(ret == TRUE, "InternetSetOption should've succeeded\n");
1462
1463 HeapFree(GetProcessHeap(), 0, list.pOptions);
1464}
struct _INTERNET_PER_CONN_OPTION_LISTA INTERNET_PER_CONN_OPTION_LISTA

Referenced by START_TEST().

◆ test_PrivacyGetSetZonePreferenceW()

static void test_PrivacyGetSetZonePreferenceW ( void  )
static

Definition at line 1071 of file internet.c.

1072{
1073 DWORD ret, zone, type, template, old_template, pref_size = 0;
1074 WCHAR pref[256];
1075
1076 zone = 3;
1077 type = 0;
1078 ret = pPrivacyGetZonePreferenceW(zone, type, NULL, NULL, NULL);
1079 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1080
1081 old_template = 0;
1082 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, NULL, NULL);
1083 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1084
1085 trace("template %u\n", old_template);
1086
1087 if(old_template == PRIVACY_TEMPLATE_ADVANCED) {
1088 pref_size = ARRAY_SIZE(pref);
1089 ret = pPrivacyGetZonePreferenceW(zone, type, &old_template, pref, &pref_size);
1090 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1091 }
1092
1093 template = 5;
1094 ret = pPrivacySetZonePreferenceW(zone, type, template, NULL);
1095 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1096
1097 template = 0;
1098 ret = pPrivacyGetZonePreferenceW(zone, type, &template, NULL, NULL);
1099 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1100 ok(template == 5, "expected template == 5, got %u\n", template);
1101
1102 template = 5;
1103 ret = pPrivacySetZonePreferenceW(zone, type, old_template, pref_size ? pref : NULL);
1104 ok(ret == 0, "expected ret == 0, got %u\n", ret);
1105}
DWORD zone
Definition: sec_mgr.c:1754
#define PRIVACY_TEMPLATE_ADVANCED
Definition: wininet.h:1962

Referenced by START_TEST().

◆ test_version()

static void test_version ( void  )
static

Definition at line 783 of file internet.c.

784{
786 DWORD size;
787 BOOL res;
788
789 size = sizeof(version);
791 ok(res, "Could not get version: %u\n", GetLastError());
792 ok(version.dwMajorVersion == 1, "dwMajorVersion=%d, expected 1\n", version.dwMajorVersion);
793 ok(version.dwMinorVersion == 2, "dwMinorVersion=%d, expected 2\n", version.dwMinorVersion);
794}
static const WCHAR version[]
Definition: asmname.c:66
#define INTERNET_OPTION_VERSION
Definition: wininet.h:734

Referenced by START_TEST().

Variable Documentation

◆ DWORD

Definition at line 34 of file internet.c.

◆ LPCSTR

Definition at line 45 of file internet.c.

◆ LPCWSTR

Definition at line 42 of file internet.c.

◆ LPDWORD

Definition at line 43 of file internet.c.

◆ LPSTR

Definition at line 38 of file internet.c.

◆ LPVOID

Definition at line 45 of file internet.c.

◆ LPWSTR

Definition at line 39 of file internet.c.