2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
3 * Copyright 2009-2011 Detlef Riekenberg
4 * Copyright 2011 Thomas Mullaly for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 /* needed for IInternetZoneManagerEx2 */
25 #define _WIN32_IE 0x0700
27 #include <wine/test.h>
39 #define URLZONE_CUSTOM URLZONE_USER_MIN+1
40 #define URLZONE_CUSTOM2 URLZONE_CUSTOM+1
42 #define DEFINE_EXPECT(func) \
43 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
45 #define SET_EXPECT(func) \
46 expect_ ## func = TRUE
48 #define CHECK_EXPECT(func) \
50 ok(expect_ ##func, "unexpected call " #func "\n"); \
51 expect_ ## func = FALSE; \
52 called_ ## func = TRUE; \
55 #define CHECK_EXPECT2(func) \
57 ok(expect_ ##func, "unexpected call " #func "\n"); \
58 called_ ## func = TRUE; \
61 #define CHECK_CALLED(func) \
63 ok(called_ ## func, "expected " #func "\n"); \
64 expect_ ## func = called_ ## func = FALSE; \
67 #define SET_CALLED(func) \
69 expect_ ## func = called_ ## func = FALSE; \
72 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input
);
73 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input2
);
74 DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected
);
75 DEFINE_EXPECT(ParseUrl_SECURITY_URL_http
);
76 DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
77 DEFINE_EXPECT(ProcessUrlAction
);
79 static HRESULT (WINAPI
*pCoInternetCreateSecurityManager
)(IServiceProvider
*, IInternetSecurityManager
**, DWORD
);
80 static HRESULT (WINAPI
*pCoInternetCreateZoneManager
)(IServiceProvider
*, IInternetZoneManager
**, DWORD
);
81 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
82 static HRESULT (WINAPI
*pCoInternetGetSecurityUrlEx
)(IUri
*, IUri
**, PSUACTION
, DWORD_PTR
);
83 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
84 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
85 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabled
)(INTERNETFEATURELIST
, DWORD
);
86 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabledForUrl
)(INTERNETFEATURELIST
, DWORD
, LPCWSTR
, IInternetSecurityManager
*);
87 static HRESULT (WINAPI
*pCoInternetIsFeatureZoneElevationEnabled
)(LPCWSTR
, LPCWSTR
, IInternetSecurityManager
*, DWORD
);
89 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
90 '/','b','l','a','n','k','.','h','t','m',0};
91 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
92 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
93 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
94 '%','2','e','j','p','g',0};
95 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
96 '.','w','i','n','e','t','e','s','t',0};
97 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
98 static const WCHAR url7
[] = {'f','t','p',':','/','/','z','o','n','e','3',
99 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
100 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
101 static const WCHAR url9
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
102 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
103 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
105 static const WCHAR url11
[] = {'f','i','l','e',':','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
106 static const WCHAR url12
[] = {'f','i','l','e',':','/','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
107 static const WCHAR url13
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m',0};
108 static const WCHAR url14
[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',0};
109 static const WCHAR url15
[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','c','o','m','.','u','k',0};
110 static const WCHAR url16
[] = {'f','i','l','e',':','/','/','/','c',':',0};
111 static const WCHAR url17
[] = {'f','i','l','e',':','/','/','/','c',':','c','\\',0};
112 static const WCHAR url18
[] = {'c',':','\\','t','e','s','t','.','h','t','m',0};
114 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
115 static const WCHAR security_urlW
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
116 static const WCHAR security_url2W
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g','2',0};
117 static const WCHAR security_expectedW
[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
118 static const WCHAR winetest_to_httpW
[] = {'w','i','n','e','t','e','s','t',':','h',0};
120 static const char *szZoneMapDomainsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains";
121 static const char *szInternetSettingsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
123 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
124 static const BYTE secid2
[] = {'*',':','i','n','d','e','x','.','h','t','m',3,0,0,0};
125 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
126 '.','w','i','n','e','t','e','s','t',3,0,0,0};
127 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
128 static const BYTE secid7
[] = {'f','t','p',':','z','o','n','e','3',
129 '.','w','i','n','e','t','e','s','t',3,0,0,0};
130 static const BYTE secid10
[] =
131 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
132 static const BYTE secid14
[] =
133 {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',3,0,0,0};
134 static const BYTE secid10_2
[] =
135 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
136 static const BYTE secid13
[] = {'h','t','t','p',':','c','o','m','.','u','k',3,0,0,0};
137 static const BYTE secid13_2
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m','.','u','k',3,0,0,0};
139 static const GUID CLSID_TestActiveX
=
140 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
142 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
143 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
144 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
146 static int called_securl_http
;
147 static DWORD ProcessUrlAction_policy
;
149 static struct secmgr_test
{
157 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
158 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
159 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
160 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
161 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
162 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
},
163 {url11
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
164 {url12
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
165 {url16
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
166 {url17
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
167 {url18
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
}
170 static int strcmp_w(const WCHAR
*str1
, const WCHAR
*str2
)
172 DWORD len1
= lstrlenW(str1
);
173 DWORD len2
= lstrlenW(str2
);
175 if(len1
!=len2
) return 1;
176 return memcmp(str1
, str2
, len1
*sizeof(WCHAR
));
179 static inline void heap_free(void *mem
)
181 HeapFree(GetProcessHeap(), 0, mem
);
184 static inline LPWSTR
a2w(LPCSTR str
)
189 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
190 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
191 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
197 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
198 LPWSTR strAW
= a2w(strA
);
199 DWORD ret
= lstrcmpW(strAW
, strB
);
205 /* Based on RegDeleteTreeW from dlls/advapi32/registry.c */
206 static LONG
myRegDeleteTreeA(HKEY hKey
, LPCSTR lpszSubKey
)
209 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
210 DWORD dwMaxLen
, dwSize
;
211 CHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
216 ret
= RegOpenKeyExA(hKey
, lpszSubKey
, 0, KEY_READ
, &hSubKey
);
220 /* Get highest length for keys, values */
221 ret
= RegQueryInfoKeyA(hSubKey
, NULL
, NULL
, NULL
, NULL
,
222 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
223 if (ret
) goto cleanup
;
227 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
228 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(CHAR
))
230 /* Name too big: alloc a buffer for it */
231 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(CHAR
))))
233 ret
= ERROR_NOT_ENOUGH_MEMORY
;
238 /* Recursively delete all the subkeys */
242 if (RegEnumKeyExA(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
243 NULL
, NULL
, NULL
)) break;
245 ret
= myRegDeleteTreeA(hSubKey
, lpszName
);
246 if (ret
) goto cleanup
;
250 ret
= RegDeleteKeyA(hKey
, lpszSubKey
);
255 if (RegEnumValueA(hKey
, 0, lpszName
, &dwSize
,
256 NULL
, NULL
, NULL
, NULL
)) break;
258 ret
= RegDeleteValueA(hKey
, lpszName
);
259 if (ret
) goto cleanup
;
263 /* Free buffer if allocated */
264 if (lpszName
!= szNameBuf
)
267 RegCloseKey(hSubKey
);
271 static HRESULT WINAPI
SecurityManager_QueryInterface(IInternetSecurityManager
* This
,
272 REFIID riid
, void **ppvObject
)
274 ok(0, "unexpected call\n");
278 static ULONG WINAPI
SecurityManager_AddRef(IInternetSecurityManager
* This
)
283 static ULONG WINAPI
SecurityManager_Release(IInternetSecurityManager
* This
)
288 static HRESULT WINAPI
SecurityManager_SetSecuritySite(IInternetSecurityManager
* This
,
289 IInternetSecurityMgrSite
*pSite
)
291 ok(0, "unexpected call\n");
295 static HRESULT WINAPI
SecurityManager_GetSecuritySite(IInternetSecurityManager
* This
,
296 IInternetSecurityMgrSite
**ppSite
)
298 ok(0, "unexpected call\n");
302 static HRESULT WINAPI
SecurityManager_MapUrlToZone(IInternetSecurityManager
* This
,
303 LPCWSTR pwszUrl
, DWORD
*pdwZone
, DWORD dwFlags
)
305 ok(0, "unexpected call\n");
309 static HRESULT WINAPI
SecurityManager_GetSecurityId(IInternetSecurityManager
* This
,
310 LPCWSTR pwszUrl
, BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
312 ok(0, "unexpected call\n");
316 static HRESULT WINAPI
SecurityManager_ProcessUrlAction(IInternetSecurityManager
* This
,
317 LPCWSTR pwszUrl
, DWORD dwAction
, BYTE
*pPolicy
, DWORD cbPolicy
,
318 BYTE
*pContext
, DWORD cbContext
, DWORD dwFlags
, DWORD dwReserved
)
320 CHECK_EXPECT(ProcessUrlAction
);
321 ok(dwAction
== URLACTION_FEATURE_ZONE_ELEVATION
, "dwAction = %x\n", dwAction
);
322 ok(cbPolicy
== sizeof(DWORD
), "cbPolicy = %d\n", cbPolicy
);
323 ok(!pContext
, "pContext != NULL\n");
324 ok(dwFlags
== PUAF_NOUI
, "dwFlags = %x\n", dwFlags
);
325 ok(dwReserved
== 0, "dwReserved = %x\n", dwReserved
);
327 *pPolicy
= ProcessUrlAction_policy
;
328 return ProcessUrlAction_policy
==URLPOLICY_ALLOW
? S_OK
: S_FALSE
;
331 static HRESULT WINAPI
SecurityManager_QueryCustomPolicy(IInternetSecurityManager
* This
,
332 LPCWSTR pwszUrl
, REFGUID guidKey
, BYTE
**ppPolicy
, DWORD
*pcbPolicy
,
333 BYTE
*pContext
, DWORD cbContext
, DWORD dwReserved
)
335 ok(0, "unexpected call\n");
339 static HRESULT WINAPI
SecurityManager_SetZoneMapping(IInternetSecurityManager
* This
,
340 DWORD dwZone
, LPCWSTR lpszPattern
, DWORD dwFlags
)
342 ok(0, "unexpected call\n");
346 static HRESULT WINAPI
SecurityManager_GetZoneMappings(IInternetSecurityManager
* This
,
347 DWORD dwZone
, IEnumString
**ppenumString
, DWORD dwFlags
)
349 ok(0, "unexpected call\n");
353 static const IInternetSecurityManagerVtbl SecurityManagerVtbl
= {
354 SecurityManager_QueryInterface
,
355 SecurityManager_AddRef
,
356 SecurityManager_Release
,
357 SecurityManager_SetSecuritySite
,
358 SecurityManager_GetSecuritySite
,
359 SecurityManager_MapUrlToZone
,
360 SecurityManager_GetSecurityId
,
361 SecurityManager_ProcessUrlAction
,
362 SecurityManager_QueryCustomPolicy
,
363 SecurityManager_SetZoneMapping
,
364 SecurityManager_GetZoneMappings
367 static IInternetSecurityManager security_manager
= { &SecurityManagerVtbl
};
369 static void test_SecurityManager(void)
372 IInternetSecurityManager
*secmgr
= NULL
;
374 DWORD zone
, size
, policy
;
377 if(!pCoInternetCreateSecurityManager
) {
381 trace("Testing security manager...\n");
383 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
384 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
388 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
390 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
392 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
393 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
394 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
395 i
, hres
, secmgr_tests
[i
].zone_hres
);
397 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
398 secmgr_tests
[i
].zone
);
400 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
403 memset(buf
, 0xf0, sizeof(buf
));
404 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
406 ok(hres
== secmgr_tests
[i
].secid_hres
,
407 "[%d] GetSecurityId failed: %08x, expected %08x\n",
408 i
, hres
, secmgr_tests
[i
].secid_hres
);
409 if(secmgr_tests
[i
].secid
) {
410 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
411 i
, size
, secmgr_tests
[i
].secid_size
);
412 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
417 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
418 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
419 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
421 /* win2k3 translates %20 into a space */
423 memset(buf
, 0xf0, sizeof(buf
));
424 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
425 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
426 ok(size
== sizeof(secid10
) ||
427 size
== sizeof(secid10_2
), /* win2k3 */
429 ok(!memcmp(buf
, secid10
, sizeof(secid10
)) ||
430 !memcmp(buf
, secid10_2
, sizeof(secid10_2
)), /* win2k3 */
434 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url13
, &zone
, 0);
435 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
436 ok(zone
== URLZONE_INVALID
|| broken(zone
== URLZONE_INTERNET
), "zone=%d\n", zone
);
439 memset(buf
, 0xf0, sizeof(buf
));
440 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url13
, buf
, &size
, 0);
441 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityId failed: %08x\n", hres
);
444 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url14
, &zone
, 0);
445 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
446 ok(zone
== URLZONE_INTERNET
, "zone=%d\n", zone
);
449 memset(buf
, 0xf0, sizeof(buf
));
450 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url14
, buf
, &size
, 0);
451 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
452 ok(size
== sizeof(secid14
), "size=%d\n", size
);
453 ok(!memcmp(buf
, secid14
, size
), "wrong secid\n");
456 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
457 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
458 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
461 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
462 ok(hres
== E_INVALIDARG
,
463 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
464 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
466 ok(hres
== E_INVALIDARG
,
467 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
468 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
470 ok(hres
== E_INVALIDARG
,
471 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
473 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
474 sizeof(WCHAR
), NULL
, 0, 0, 0);
475 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
477 IInternetSecurityManager_Release(secmgr
);
480 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
481 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
482 static BOOL
is_ie_hardened(void)
485 DWORD ie_harden
, type
, size
;
488 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
489 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
490 size
= sizeof(DWORD
);
491 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
495 RegCloseKey(zone_map
);
498 return ie_harden
!= 0;
501 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
503 DWORD res
, size
, policy
, reg_policy
;
508 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
509 * The test should be changed to cope with that, if need be.
511 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
512 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
513 ok(res
== ERROR_SUCCESS
, "Could not open zone key\n");
514 if(res
!= ERROR_SUCCESS
)
517 wsprintfA(buf
, "%X", action
);
518 size
= sizeof(DWORD
);
519 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
522 /* Try settings from HKEY_LOCAL_MACHINE. */
523 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
524 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
,
525 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
526 ok(res
== ERROR_SUCCESS
, "Could not open zone key\n");
528 size
= sizeof(DWORD
);
529 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
533 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
535 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
536 sizeof(WCHAR
), NULL
, 0, 0, 0);
537 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
538 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
539 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
542 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
543 sizeof(DWORD
), URLZONEREG_DEFAULT
);
544 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
545 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
546 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
551 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
552 sizeof(DWORD
), URLZONEREG_DEFAULT
);
553 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
554 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
556 if(policy
!= URLPOLICY_QUERY
) {
557 if(winetest_interactive
|| ! is_ie_hardened()) {
558 BOOL expect_parse_call
= !called_securl_http
;
561 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
562 sizeof(WCHAR
), NULL
, 0, 0, 0);
563 if(reg_policy
== URLPOLICY_DISALLOW
)
564 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
566 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
567 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
570 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
572 if(reg_policy
== URLPOLICY_DISALLOW
)
573 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
575 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
576 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
579 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
580 sizeof(DWORD
), NULL
, 0, 0, 0);
581 if(reg_policy
== URLPOLICY_DISALLOW
)
582 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
584 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
585 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
588 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
589 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
590 if(reg_policy
== URLPOLICY_DISALLOW
)
591 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
593 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
594 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
597 if(expect_parse_call
)
598 SET_EXPECT(ParseUrl_SECURITY_URL_http
);
599 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, winetest_to_httpW
, action
, (BYTE
*)&policy
,
600 sizeof(DWORD
), NULL
, 0, 0, 0);
601 if(expect_parse_call
)
602 CHECK_CALLED(ParseUrl_SECURITY_URL_http
);
603 if(reg_policy
== URLPOLICY_DISALLOW
)
604 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
606 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
607 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
609 skip("IE running in Enhanced Security Configuration\n");
614 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
620 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
621 sizeof(DWORD
), URLZONEREG_DEFAULT
);
622 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
623 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
626 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
627 sizeof(WCHAR
), NULL
, 0, 0, 0);
628 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
631 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
632 sizeof(DWORD
), NULL
, 0, 0, 0);
633 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
634 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
637 static void test_activex(IInternetSecurityManager
*secmgr
)
639 DWORD policy
, policy_size
;
640 struct CONFIRMSAFETY cs
;
645 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
646 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
647 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
648 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
650 cs
.clsid
= CLSID_TestActiveX
;
651 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
653 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
654 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
655 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
658 static void test_polices(void)
660 IInternetZoneManager
*zonemgr
= NULL
;
661 IInternetSecurityManager
*secmgr
= NULL
;
664 trace("testing polices...\n");
666 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
667 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
668 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
669 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
671 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
672 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
673 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
674 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
675 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
677 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
678 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
680 test_activex(secmgr
);
682 IInternetSecurityManager_Release(secmgr
);
683 IInternetZoneManager_Release(zonemgr
);
686 /* IE (or at least newer versions of it) seem to cache the keys in ZoneMap
687 * when urlmon.dll is loaded and it doesn't seem to update its cache, unless
688 * SetZoneMapping is used.
690 static void test_zone_domain_cache(void)
694 IInternetSecurityManager
*secmgr
= NULL
;
695 HKEY domains
, domain
;
697 static const WCHAR testing_domain_urlW
[] = {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.',
698 'd','o','m','a','i','n','/',0};
700 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
701 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
702 if(res
!= ERROR_SUCCESS
)
705 res
= RegCreateKeyA(domains
, "testing.domain", &domain
);
706 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
707 if(res
!= ERROR_SUCCESS
) {
708 RegCloseKey(domains
);
712 zone
= URLZONE_CUSTOM
;
713 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
714 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
718 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
719 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
721 zone
= URLZONE_INVALID
;
722 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, testing_domain_urlW
, &zone
, 0);
723 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
724 todo_wine
ok(zone
== URLZONE_INTERNET
, "Got %d, expected URLZONE_INTERNET\n", zone
);
726 /* FIXME: Play nice with ZoneMaps that existed before the test is run. */
727 res
= RegDeleteKeyA(domains
, "testing.domain");
728 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
730 RegCloseKey(domains
);
731 IInternetSecurityManager_Release(secmgr
);
736 const char *subdomain
;
739 } zone_domain_mapping
;
741 /* FIXME: Move these into SetZoneMapping tests when the day comes... */
742 static const zone_domain_mapping zone_domain_mappings
[] = {
743 /* Implicitly means "*.yabadaba.do". */
744 {"yabadaba.do",NULL
,"http",URLZONE_CUSTOM
},
745 /* The '*' doesn't count as a wildcard, since it's not the first component of the subdomain. */
746 {"super.cool","testing.*","ftp",URLZONE_CUSTOM2
},
747 /* The '*' counts since it's the first component of the subdomain. */
748 {"super.cool","*.testing","ftp",URLZONE_CUSTOM2
},
749 /* All known scheme types apply to wildcard schemes. */
750 {"tests.test",NULL
,"*",URLZONE_CUSTOM
},
751 /* Due to a defect with how windows checks the mappings, unknown scheme types
752 * never seem to get mapped properly. */
753 {"tests.test",NULL
,"zip",URLZONE_CUSTOM
},
754 {"www.testing.com",NULL
,"http",URLZONE_CUSTOM
},
755 {"www.testing.com","testing","http",URLZONE_CUSTOM2
},
756 {"org",NULL
,"http",URLZONE_CUSTOM
},
757 {"org","testing","http",URLZONE_CUSTOM2
},
758 {"wine.testing",NULL
,"*",URLZONE_CUSTOM2
}
761 static void register_zone_domains(void)
766 /* Some Windows versions don't seem to have a "Domains" key in their HKLM. */
767 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
768 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
769 if(res
== ERROR_SUCCESS
) {
771 DWORD zone
= URLZONE_CUSTOM
;
773 res
= RegCreateKeyA(domains
, "local.machine", &domain
);
774 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
776 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
777 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
780 RegCloseKey(domains
);
783 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
784 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
786 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
787 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
790 res
= RegCreateKeyA(domains
, test
->domain
, &domain
);
791 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
793 /* Only set the value if there's no subdomain. */
794 if(!test
->subdomain
) {
795 res
= RegSetValueExA(domain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
796 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
800 res
= RegCreateKeyA(domain
, test
->subdomain
, &subdomain
);
801 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
803 res
= RegSetValueExA(subdomain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
804 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
806 RegCloseKey(subdomain
);
812 RegCloseKey(domains
);
815 static void unregister_zone_domains(void)
820 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
821 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
822 if(res
== ERROR_SUCCESS
) {
823 RegDeleteKeyA(domains
, "local.machine");
824 RegCloseKey(domains
);
827 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
828 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
830 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
831 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
833 /* FIXME: Uses the "cludge" approach to remove the test data from the registry!
834 * Although, if domain names are... unique, this shouldn't cause any harm
835 * to keys (if any) that existed before the tests.
837 if(test
->subdomain
) {
840 res
= RegOpenKeyA(domains
, test
->domain
, &domain
);
841 if(res
== ERROR_SUCCESS
) {
842 RegDeleteKeyA(domain
, test
->subdomain
);
846 RegDeleteKeyA(domains
, test
->domain
);
849 RegCloseKey(domains
);
852 static void run_child_process(void)
854 char cmdline
[MAX_PATH
];
857 PROCESS_INFORMATION pi
;
858 STARTUPINFOA si
= { 0 };
861 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
864 winetest_get_mainargs(&argv
);
865 sprintf(cmdline
, "\"%s\" %s domain_tests", argv
[0], argv
[1]);
866 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
867 ok(ret
, "Failed to spawn child process: %u\n", GetLastError());
868 winetest_wait_child_process(pi
.hProcess
);
869 CloseHandle(pi
.hThread
);
870 CloseHandle(pi
.hProcess
);
880 static const zone_mapping_test zone_mapping_tests
[] = {
881 /* Tests for "yabadaba.do" zone mappings. */
882 {"http://yabadaba.do/",URLZONE_CUSTOM
},
883 {"http://google.yabadaba.do/",URLZONE_CUSTOM
},
884 {"zip://yabadaba.do/",URLZONE_INTERNET
},
885 /* Tests for "super.cool" zone mappings. */
886 {"ftp://testing.google.super.cool/",URLZONE_INTERNET
},
887 {"ftp://testing.*.super.cool/",URLZONE_CUSTOM2
},
888 {"ftp://google.testing.super.cool/",URLZONE_CUSTOM2
},
889 /* Tests for "tests.test" zone mappings. */
890 {"http://tests.test/",URLZONE_CUSTOM
},
891 {"http://www.tests.test/",URLZONE_CUSTOM
},
892 {"ftp://tests.test/",URLZONE_CUSTOM
},
893 {"ftp://www.tests.test/",URLZONE_CUSTOM
},
894 {"test://www.tests.test/",URLZONE_INTERNET
},
895 {"test://tests.test/",URLZONE_INTERNET
},
896 {"zip://www.tests.test/",URLZONE_INTERNET
},
897 {"zip://tests.test/",URLZONE_INTERNET
},
898 /* Tests for "www.testing.com" zone mappings. */
899 {"http://google.www.testing.com/",URLZONE_INTERNET
},
900 {"http://www.testing.com/",URLZONE_CUSTOM
,FALSE
,URLZONE_INTERNET
},
901 {"http://testing.www.testing.com/",URLZONE_CUSTOM2
,FALSE
,URLZONE_INTERNET
},
902 /* Tests for "org" zone mappings. */
903 {"http://google.org/",URLZONE_INTERNET
,FALSE
,URLZONE_CUSTOM
},
904 {"http://org/",URLZONE_CUSTOM
},
905 {"http://testing.org/",URLZONE_CUSTOM2
},
906 /* Tests for "wine.testing" mapping */
907 {"*:wine.testing/test",URLZONE_CUSTOM2
},
908 {"http://wine.testing/testing",URLZONE_CUSTOM2
}
911 static void test_zone_domain_mappings(void)
915 IInternetSecurityManager
*secmgr
= NULL
;
917 DWORD zone
= URLZONE_INVALID
;
919 trace("testing zone domain mappings...\n");
921 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
922 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
924 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
925 if(res
== ERROR_SUCCESS
) {
926 static const WCHAR local_machineW
[] = {'h','t','t','p',':','/','/','t','e','s','t','.','l','o','c','a','l',
927 '.','m','a','c','h','i','n','e','/',0};
929 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, local_machineW
, &zone
, 0);
930 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
931 ok(zone
== URLZONE_CUSTOM
, "Expected URLZONE_CUSTOM, but got %d\n", zone
);
933 RegCloseKey(domains
);
936 for(i
= 0; i
< sizeof(zone_mapping_tests
)/sizeof(zone_mapping_tests
[0]); ++i
) {
937 const zone_mapping_test
*test
= zone_mapping_tests
+i
;
938 LPWSTR urlW
= a2w(test
->url
);
939 zone
= URLZONE_INVALID
;
941 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, urlW
, &zone
, 0);
942 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
945 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
946 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
948 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
949 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
954 IInternetSecurityManager_Release(secmgr
);
957 static void test_zone_domains(void)
959 if(is_ie_hardened()) {
960 skip("IE running in Enhanced Security Configuration\n");
962 } else if(!pCreateUri
) {
963 win_skip("Skipping zone domain tests, IE too old\n");
967 trace("testing zone domains...\n");
969 test_zone_domain_cache();
971 register_zone_domains();
973 unregister_zone_domains();
976 static void test_CoInternetCreateZoneManager(void)
978 IInternetZoneManager
*zonemgr
= NULL
;
979 IUnknown
*punk
= NULL
;
982 trace("simple zone manager tests...\n");
984 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
985 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
989 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
990 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
992 IUnknown_Release(punk
);
994 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
995 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
997 IUnknown_Release(punk
);
1000 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
1001 if (SUCCEEDED(hr
)) {
1002 IUnknown_Release(punk
);
1004 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
1005 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
/* some W2K3 */),
1006 "got 0x%x (expected S_OK)\n", hr
);
1008 IUnknown_Release(punk
);
1010 win_skip("InternetZoneManagerEx2 not supported\n");
1014 win_skip("InternetZoneManagerEx not supported\n");
1016 hr
= IInternetZoneManager_Release(zonemgr
);
1017 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1021 static void test_CreateZoneEnumerator(void)
1023 IInternetZoneManager
*zonemgr
= NULL
;
1030 trace("testing zone enumerator...\n");
1032 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1033 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1038 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
1039 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
1040 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
1043 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
1044 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
1045 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
1049 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
1050 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1051 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1052 hr
, dwEnum
, dwCount
);
1056 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
1057 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1058 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1059 hr
, dwEnum
, dwCount
);
1064 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1065 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1067 if (SUCCEEDED(hr
)) {
1069 dwCount2
=0xdeadbeef;
1070 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
1071 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1072 if (SUCCEEDED(hr
)) {
1073 /* native urlmon has an incrementing counter for dwEnum */
1074 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
1075 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1078 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1079 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1081 /* Destroy the Enumerator twice is detected and handled in native urlmon */
1082 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1083 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
1086 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
1087 hr
= IInternetZoneManager_Release(zonemgr
);
1088 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1091 static void test_GetZoneActionPolicy(void)
1093 IInternetZoneManager
*zonemgr
= NULL
;
1096 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
1098 trace("testing GetZoneActionPolixy...\n");
1100 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1101 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
1105 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1106 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1107 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
1108 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
1109 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
1110 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
1111 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
1112 "unexpected policy=%d\n", *(DWORD
*)buf
);
1114 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
1115 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1116 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1118 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1119 2, URLZONEREG_DEFAULT
);
1120 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1122 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
1123 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1124 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
1125 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
1127 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
1128 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1129 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1131 IInternetZoneManager_Release(zonemgr
);
1134 static void test_GetZoneAt(void)
1136 IInternetZoneManager
*zonemgr
= NULL
;
1143 trace("testing GetZoneAt...\n");
1145 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1146 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1150 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1155 /* this crashes with native urlmon */
1156 IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
1159 dwZone
= 0xdeadbeef;
1160 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
1161 ok(hr
== E_INVALIDARG
,
1162 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1164 for (i
= 0; i
< dwCount
; i
++)
1166 dwZone
= 0xdeadbeef;
1167 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
1168 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
1171 dwZone
= 0xdeadbeef;
1172 /* MSDN (index .. must be .. less than or equal to) is wrong */
1173 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
1174 ok(hr
== E_INVALIDARG
,
1175 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1177 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1178 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1181 hr
= IInternetZoneManager_Release(zonemgr
);
1182 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1185 static void test_GetZoneAttributes(void)
1187 IInternetZoneManager
*zonemgr
= NULL
;
1188 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
1189 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1193 trace("testing GetZoneAttributes...\n");
1195 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1196 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1200 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
1201 for (i
= 0; i
< 5; i
++) {
1202 memset(buffer
, -1, sizeof(buffer
));
1203 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
1204 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
1207 /* IE8 no longer set cbSize */
1208 memset(buffer
, -1, sizeof(buffer
));
1210 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1211 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1212 ok((pZA
->cbSize
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1213 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
1215 memset(buffer
, -1, sizeof(buffer
));
1217 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1218 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1219 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1220 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
1222 memset(buffer
, -1, sizeof(buffer
));
1223 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1224 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1225 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1226 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
1228 /* IE8 up to IE10 don't fail on invalid zones */
1229 memset(buffer
, -1, sizeof(buffer
));
1230 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
1231 ok(hr
== S_OK
|| hr
== E_FAIL
|| hr
== E_POINTER
,
1232 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
1234 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
1235 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1237 hr
= IInternetZoneManager_Release(zonemgr
);
1238 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1241 static void test_SetZoneAttributes(void)
1243 IInternetZoneManager
*zonemgr
= NULL
;
1244 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 16];
1245 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1246 CHAR regpath
[MAX_PATH
];
1251 trace("testing SetZoneAttributes...\n");
1252 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1253 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1257 memset(buffer
, -1, sizeof(buffer
));
1258 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, URLZONE_LOCAL_MACHINE
, pZA
);
1259 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1261 sprintf(regpath
, "%s\\Zones\\%d", szInternetSettingsKey
, URLZONE_CUSTOM
);
1262 res
= RegCreateKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1265 ok(res
== ERROR_SUCCESS
, "got %d (expected ERROR_SUCCESS)\n", res
);
1266 if (res
!= ERROR_SUCCESS
)
1269 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
);
1270 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, NULL
);
1271 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1274 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1276 win_skip("SetZoneAttributes not supported: IE too old\n");
1279 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1281 /* native urlmon ignores cbSize */
1282 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) + sizeof(DWORD
);
1283 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1284 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) + sizeof(DWORD) (expected S_OK)\n", hr
);
1286 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) - sizeof(DWORD
);
1287 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1288 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) - sizeof(DWORD) (expected S_OK)\n", hr
);
1291 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1292 ok(hr
== S_OK
, "got 0x%x for size 0 (expected S_OK)\n", hr
);
1294 /* The key for the zone must be present, when calling SetZoneAttributes */
1295 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1296 /* E_FAIL is returned from IE6 here, which is reasonable.
1297 All newer IE return S_OK without saving the zone attributes to the registry.
1298 This is a Windows bug, but we have to accept that as standard */
1299 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1300 ok((hr
== S_OK
) || broken(hr
== E_FAIL
), "got 0x%x (expected S_OK)\n", hr
);
1302 /* SetZoneAttributes did not create the directory */
1303 res
= RegOpenKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1304 ok((res
== ERROR_FILE_NOT_FOUND
) && (hkey
== NULL
),
1305 "got %u with %p (expected ERROR_FILE_NOT_FOUND with NULL)\n", res
, hkey
);
1307 if (hkey
) RegCloseKey(hkey
);
1310 /* delete zone settings in the registry */
1311 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1313 hr
= IInternetZoneManager_Release(zonemgr
);
1314 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1318 static void test_InternetSecurityMarshalling(void)
1320 IInternetSecurityManager
*secmgr
= NULL
;
1325 trace("testing marshalling...\n");
1327 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
1328 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1332 hres
= IInternetSecurityManager_QueryInterface(secmgr
, &IID_IUnknown
, (void**)&unk
);
1333 ok(hres
== S_OK
, "QueryInterface returned: %08x\n", hres
);
1335 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
1336 ok(hres
== S_OK
, "CreateStreamOnHGlobal returned: %08x\n", hres
);
1338 hres
= CoMarshalInterface(stream
, &IID_IInternetSecurityManager
, unk
, MSHCTX_INPROC
, NULL
, MSHLFLAGS_NORMAL
);
1339 /* Not supported in W98 */
1340 ok(hres
== S_OK
|| broken(hres
== REGDB_E_IIDNOTREG
),
1341 "CoMarshalInterface returned: %08x\n", hres
);
1343 IStream_Release(stream
);
1344 IUnknown_Release(unk
);
1345 IInternetSecurityManager_Release(secmgr
);
1348 static void test_InternetGetSecurityUrl(void)
1350 const WCHAR url5_out
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
1351 '.','w','i','n','e','t','e','s','t',0};
1352 const WCHAR url7_out
[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
1354 const WCHAR
*in
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1355 const WCHAR
*out_default
[] = {url2
, url3
, url4
, url5_out
, url7_out
, url8
, url5_out
, url10
};
1356 const WCHAR
*out_securl
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1362 trace("testing CoInternetGetSecurityUrl...\n");
1364 for(i
=0; i
<sizeof(in
)/sizeof(WCHAR
*); i
++) {
1365 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_DEFAULT
, 0);
1366 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1368 ok(!strcmp_w(sec
, out_default
[i
]), "(%d) Got %s, expected %s\n",
1369 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_default
[i
]));
1373 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_SECURITY_URL_ONLY
, 0);
1374 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1376 ok(!strcmp_w(sec
, out_securl
[i
]), "(%d) Got %s, expected %s\n",
1377 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_securl
[i
]));
1382 SET_EXPECT(ParseUrl_SECURITY_URL_input2
);
1383 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1384 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1386 hres
= pCoInternetGetSecurityUrl(security_url2W
, &sec
, PSU_DEFAULT
, 0);
1387 ok(hres
== S_OK
, "CoInternetGetSecurityUrl returned 0x%08x, expected S_OK\n", hres
);
1389 CHECK_CALLED(ParseUrl_SECURITY_URL_input2
);
1390 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1391 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1393 ok(!lstrcmpW(security_expectedW
, sec
), "Expected %s but got %s\n",
1394 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(sec
));
1398 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
1399 REFIID riid
, void **ppv
)
1401 ok(0, "unexpected call\n");
1402 return E_NOINTERFACE
;
1405 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
1410 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
1415 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
1416 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
1417 DWORD
*pcchResult
, DWORD dwReserved
)
1419 const WCHAR
*ret
= NULL
;
1421 ok(pwzResult
!= NULL
, "pwzResult == NULL\n");
1422 ok(pcchResult
!= NULL
, "pcchResult == NULL\n");
1423 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
1425 switch(ParseAction
) {
1426 case PARSE_SECURITY_URL
:
1427 if(!strcmp_w(pwzUrl
, security_urlW
)) {
1428 CHECK_EXPECT(ParseUrl_SECURITY_URL_input
);
1429 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1430 ret
= security_expectedW
;
1431 } else if(!strcmp_w(pwzUrl
, security_url2W
)) {
1432 CHECK_EXPECT(ParseUrl_SECURITY_URL_input2
);
1433 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1434 ret
= security_expectedW
;
1435 } else if(!strcmp_w(pwzUrl
, security_expectedW
)) {
1436 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected
);
1437 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1438 ret
= security_expectedW
;
1439 } else if(!strcmp_w(pwzUrl
, winetest_to_httpW
)) {
1440 switch(++called_securl_http
) {
1442 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1445 CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1446 ok(cchResult
== lstrlenW(url9
)+1, "Got %d\n", cchResult
);
1449 todo_wine
CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1453 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl
));
1456 case PARSE_SECURITY_DOMAIN
:
1458 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1460 ok(!strcmp_w(pwzUrl
, security_expectedW
), "Expected %s but got %s\n",
1461 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(pwzUrl
));
1462 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1463 ret
= security_expectedW
;
1466 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction
,
1467 wine_dbgstr_w(pwzUrl
));
1473 *pcchResult
= lstrlenW(ret
)+1;
1474 if(*pcchResult
> cchResult
)
1476 memcpy(pwzResult
, ret
, (*pcchResult
)*sizeof(WCHAR
));
1480 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
1481 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
1482 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
1484 ok(0, "unexpected call\n");
1488 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
1489 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
1491 ok(0, "unexpected call\n");
1495 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
1496 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
1497 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
1499 ok(0, "unexpected call\n");
1503 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
1504 InternetProtocolInfo_QueryInterface
,
1505 InternetProtocolInfo_AddRef
,
1506 InternetProtocolInfo_Release
,
1507 InternetProtocolInfo_ParseUrl
,
1508 InternetProtocolInfo_CombineUrl
,
1509 InternetProtocolInfo_CompareUrl
,
1510 InternetProtocolInfo_QueryInfo
1513 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
1515 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1517 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
1518 *ppv
= &protocol_info
;
1522 ok(0, "unexpected call\n");
1523 return E_NOINTERFACE
;
1526 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1531 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1536 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
1537 REFIID riid
, void **ppv
)
1539 ok(0, "unexpected call\n");
1543 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1545 ok(0, "unexpected call\n");
1549 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1550 ClassFactory_QueryInterface
,
1551 ClassFactory_AddRef
,
1552 ClassFactory_Release
,
1553 ClassFactory_CreateInstance
,
1554 ClassFactory_LockServer
1557 static IClassFactory protocol_cf
= { &ClassFactoryVtbl
};
1559 static void register_protocols(void)
1561 IInternetSession
*session
;
1564 hres
= pCoInternetGetSession(0, &session
, 0);
1565 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1569 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
1570 winetestW
, 0, NULL
, 0);
1571 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1573 IInternetSession_Release(session
);
1576 static void unregister_protocols(void) {
1577 IInternetSession
*session
;
1580 hr
= pCoInternetGetSession(0, &session
, 0);
1581 ok(hr
== S_OK
, "CoInternetGetSession failed: 0x%08x\n", hr
);
1585 hr
= IInternetSession_UnregisterNameSpace(session
, &protocol_cf
, winetestW
);
1586 ok(hr
== S_OK
, "UnregisterNameSpace failed: 0x%08x\n", hr
);
1588 IInternetSession_Release(session
);
1591 static const struct {
1594 const char *security_uri
;
1595 HRESULT security_hres
;
1596 const char *default_uri
;
1597 HRESULT default_hres
;
1599 } sec_url_ex_tests
[] = {
1600 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,"*:index.html",S_OK
,"*:index.htm",S_OK
},
1601 {"file://c:\\Index.htm",Uri_CREATE_FILE_USE_DOS_PATH
,"file:///c:/Index.htm",S_OK
,"file:///c:/Index.htm",S_OK
},
1602 {"file:some%20file%2ejpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1603 {"file:some file.jpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1604 {"http://www.zone3.winetest/",0,"http://www.zone3.winetest/",S_OK
,"http://www.zone3.winetest/",S_OK
},
1605 {"about:blank",0,"about:blank",S_OK
,"about:blank",S_OK
},
1606 {"ftp://zone3.winetest/file.test",0,"ftp://zone3.winetest/file.test",S_OK
,"ftp://zone3.winetest/file.test",S_OK
},
1607 {"test:123abc",0,"test:123abc",S_OK
,"test:123abc",S_OK
},
1608 {"http:google.com/test.file",0,"http:google.com/test.file",S_OK
,"http:google.com/test.file",S_OK
},
1609 {"ftp://test@ftp.winehq.org/",0,"ftp://ftp.winehq.org/",S_OK
,"ftp://ftp.winehq.org/",S_OK
},
1610 {"test://google@ftp.winehq.org/",0,"test://google@ftp.winehq.org/",S_OK
,"test://google@ftp.winehq.org/",S_OK
}
1613 static void test_InternetGetSecurityUrlEx(void)
1617 IUri
*uri
= NULL
, *result
= NULL
;
1619 trace("testing CoInternetGetSecurityUrlEx...\n");
1621 hr
= pCoInternetGetSecurityUrlEx(NULL
, NULL
, PSU_DEFAULT
, 0);
1622 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1624 result
= (void*) 0xdeadbeef;
1625 hr
= pCoInternetGetSecurityUrlEx(NULL
, &result
, PSU_DEFAULT
, 0);
1626 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1627 ok(result
== (void*) 0xdeadbeef, "'result' was %p\n", result
);
1629 for(i
= 0; i
< sizeof(sec_url_ex_tests
)/sizeof(sec_url_ex_tests
[0]); ++i
) {
1630 LPWSTR uriW
= a2w(sec_url_ex_tests
[i
].uri
);
1633 hr
= pCreateUri(uriW
, sec_url_ex_tests
[i
].create_flags
, 0, &uri
);
1634 ok(hr
== S_OK
, "CreateUri returned 0x%08x on test %d\n", hr
, i
);
1638 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1639 if(sec_url_ex_tests
[i
].todo
) {
1641 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1642 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1643 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1645 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1646 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1647 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1652 hr
= IUri_GetDisplayUri(result
, &received
);
1653 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1655 if(sec_url_ex_tests
[i
].todo
) {
1657 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1658 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1659 wine_dbgstr_w(received
), i
);
1661 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1662 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1663 wine_dbgstr_w(received
), i
);
1666 SysFreeString(received
);
1668 if(result
) IUri_Release(result
);
1671 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1672 if(sec_url_ex_tests
[i
].todo
) {
1674 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1675 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1676 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1678 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1679 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1680 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1685 hr
= IUri_GetDisplayUri(result
, &received
);
1686 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1688 if(sec_url_ex_tests
[i
].todo
) {
1690 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1691 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1692 wine_dbgstr_w(received
), i
);
1694 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1695 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1696 wine_dbgstr_w(received
), i
);
1699 SysFreeString(received
);
1701 if(result
) IUri_Release(result
);
1704 if(uri
) IUri_Release(uri
);
1709 static void test_InternetGetSecurityUrlEx_Pluggable(void)
1712 IUri
*uri
= NULL
, *result
;
1714 trace("testing CoInternetGetSecurityUrlEx for pluggable protocols...\n");
1716 hr
= pCreateUri(security_urlW
, 0, 0, &uri
);
1717 ok(hr
== S_OK
, "CreateUri returned 0x%08x\n", hr
);
1719 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1720 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1721 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1723 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1724 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1726 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1727 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1728 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1731 BSTR received
= NULL
;
1733 hr
= IUri_GetAbsoluteUri(result
, &received
);
1734 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1736 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1737 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1739 SysFreeString(received
);
1741 if(result
) IUri_Release(result
);
1745 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1746 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1748 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1749 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1751 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1752 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1755 BSTR received
= NULL
;
1757 hr
= IUri_GetAbsoluteUri(result
, &received
);
1758 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1760 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1761 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1763 SysFreeString(received
);
1765 if(result
) IUri_Release(result
);
1767 if(uri
) IUri_Release(uri
);
1770 static const BYTE secidex2_1
[] = {'z','i','p',':','/','/','t','e','s','t','i','n','g','.','c','o','m','/',3,0,0,0};
1771 static const BYTE secidex2_2
[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1772 static const BYTE secidex2_3
[] = {'*',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1774 static const struct {
1784 } sec_mgr_ex2_tests
[] = {
1785 {"res://mshtml.dll/blank.htm",0,S_OK
,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1786 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,secid2
,sizeof(secid2
),S_OK
},
1787 {"file://c:\\Index.html",0,0,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1788 {"http://www.zone3.winetest/",0,0,URLZONE_INTERNET
,FALSE
,secid5
,sizeof(secid5
),S_OK
},
1789 {"about:blank",0,0,URLZONE_INTERNET
,FALSE
,secid6
,sizeof(secid6
),S_OK
},
1790 {"ftp://zone3.winetest/file.test",0,0,URLZONE_INTERNET
,FALSE
,secid7
,sizeof(secid7
),S_OK
},
1791 {"/file/testing/test.test",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1792 {"zip://testing.com/",0,0,URLZONE_INTERNET
,FALSE
,secidex2_1
,sizeof(secidex2_1
),S_OK
},
1793 {"zip:testing.com",0,0,URLZONE_INTERNET
,FALSE
,secidex2_2
,sizeof(secidex2_2
),S_OK
},
1794 {"http:google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1795 {"http:/google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1796 {"*:/testing",0,S_OK
,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1797 {"*://testing.com",0,S_OK
,URLZONE_INTERNET
,FALSE
,secidex2_3
,sizeof(secidex2_3
),S_OK
}
1800 static void test_SecurityManagerEx2(void)
1805 DWORD buf_size
= sizeof(buf
);
1806 IInternetSecurityManager
*sec_mgr
;
1807 IInternetSecurityManagerEx2
*sec_mgr2
;
1810 static const WCHAR domainW
[] = {'c','o','m','.','u','k',0};
1813 win_skip("Skipping SecurityManagerEx2, IE is too old\n");
1817 trace("Testing SecurityManagerEx2...\n");
1819 hres
= pCoInternetCreateSecurityManager(NULL
, &sec_mgr
, 0);
1820 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1822 hres
= IInternetSecurityManager_QueryInterface(sec_mgr
, &IID_IInternetSecurityManagerEx2
, (void**)&sec_mgr2
);
1823 ok(hres
== S_OK
, "QueryInterface(IID_IInternetSecurityManagerEx2) failed: %08x\n", hres
);
1827 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, NULL
, &zone
, 0, NULL
, NULL
);
1828 ok(hres
== E_INVALIDARG
, "MapUrlToZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1829 ok(zone
== URLZONE_INVALID
, "zone was %d\n", zone
);
1831 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, NULL
, buf
, &buf_size
, 0);
1832 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1833 ok(buf_size
== sizeof(buf
), "buf_size was %d\n", buf_size
);
1835 hres
= pCreateUri(url5
, 0, 0, &uri
);
1836 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1838 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, NULL
, 0, NULL
, NULL
);
1839 ok(hres
== E_INVALIDARG
, "MapToUrlZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1841 buf_size
= sizeof(buf
);
1842 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, NULL
, &buf_size
, 0);
1843 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityIdEx2 failed: %08x\n", hres
);
1844 ok(buf_size
== sizeof(buf
), "bug_size was %d\n", buf_size
);
1846 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, NULL
, 0);
1847 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1851 for(i
= 0; i
< sizeof(sec_mgr_ex2_tests
)/sizeof(sec_mgr_ex2_tests
[0]); ++i
) {
1852 LPWSTR uriW
= a2w(sec_mgr_ex2_tests
[i
].uri
);
1855 zone
= URLZONE_INVALID
;
1857 hres
= pCreateUri(uriW
, sec_mgr_ex2_tests
[i
].create_flags
, 0, &uri
);
1858 ok(hres
== S_OK
, "CreateUri returned %08x for '%s'\n", hres
, sec_mgr_ex2_tests
[i
].uri
);
1860 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, &zone
, 0, NULL
, NULL
);
1861 if(sec_mgr_ex2_tests
[i
].map_todo
) {
1863 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlZoneToEx2 returned %08x, expected %08x for '%s'\n",
1864 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1866 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1867 zone
, sec_mgr_ex2_tests
[i
].uri
);
1869 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlToZoneEx2 returned %08x, expected %08x for '%s'\n",
1870 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1871 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1872 zone
, sec_mgr_ex2_tests
[i
].uri
);
1875 buf_size
= sizeof(buf
);
1876 memset(buf
, 0xf0, buf_size
);
1878 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1879 if(sec_mgr_ex2_tests
[i
].secid_todo
) {
1881 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1882 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1883 if(sec_mgr_ex2_tests
[i
].secid
) {
1885 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1886 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1887 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1888 sec_mgr_ex2_tests
[i
].uri
);
1892 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1893 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1894 if(sec_mgr_ex2_tests
[i
].secid
) {
1895 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1896 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1897 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1898 sec_mgr_ex2_tests
[i
].uri
);
1906 hres
= pCreateUri(url15
, 0, 0, &uri
);
1907 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1909 buf_size
= sizeof(buf
);
1910 memset(buf
, 0xf0, buf_size
);
1912 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, (DWORD_PTR
)domainW
);
1913 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1914 todo_wine
ok(buf_size
== sizeof(secid13
), "buf_size was %d\n", buf_size
);
1915 todo_wine
ok(!memcmp(buf
, secid13
, sizeof(secid13
)), "Got wrong secid\n");
1917 buf_size
= sizeof(buf
);
1918 memset(buf
, 0xf0, buf_size
);
1920 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1921 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1922 ok(buf_size
== sizeof(secid13_2
), "buf_size was %d\n", buf_size
);
1923 ok(!memcmp(buf
, secid13_2
, sizeof(secid13_2
)), "Got wrong secid\n");
1927 IInternetSecurityManagerEx2_Release(sec_mgr2
);
1928 IInternetSecurityManager_Release(sec_mgr
);
1931 static void test_CoInternetIsFeatureZoneElevationEnabled(void)
1934 const char *url_from
;
1940 /* 0 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_FALSE
, URLPOLICY_ALLOW
},
1941 /* 1 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_OK
, URLPOLICY_DISALLOW
},
1942 /* 2 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_FALSE
, URLPOLICY_ALLOW
},
1943 /* 3 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_OK
, URLPOLICY_DISALLOW
},
1944 /* 4 */ { "http://www.winehq.org", "http://www.winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1945 /* 5 */ { "http://www.winehq.org", "http://www.winehq.org/dir", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1946 /* 6 */ { "http://www.winehq.org", "http://www.codeweavers.com", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1947 /* 7 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1948 /* 8 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
|0x100, S_FALSE
, URLPOLICY_ALLOW
},
1949 /* 9 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_REGISTRY
, S_FALSE
, URLPOLICY_ALLOW
},
1952 WCHAR
*url_from
, *url_to
;
1956 if(!pCoInternetIsFeatureZoneElevationEnabled
|| !pCoInternetIsFeatureEnabled
1957 || !pCoInternetIsFeatureEnabledForUrl
) {
1958 win_skip("Skipping CoInternetIsFeatureZoneElevationEnabled tests\n");
1963 hres
= pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, GET_FEATURE_FROM_PROCESS
);
1964 ok(SUCCEEDED(hres
), "CoInternetIsFeatureEnabled returned %x\n", hres
);
1966 trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%x)\n", hres
);
1968 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1969 if(hres
==S_OK
&& testcases
[i
].flags
== GET_FEATURE_FROM_PROCESS
)
1970 testcases
[i
].policy_flags
= URLPOLICY_ALLOW
;
1973 /* IE10 does not seem to use passed ISecurityManager */
1974 SET_EXPECT(ProcessUrlAction
);
1975 pCoInternetIsFeatureZoneElevationEnabled(url1
, url1
, &security_manager
, 0);
1976 i
= called_ProcessUrlAction
;
1977 SET_CALLED(ProcessUrlAction
);
1979 skip("CoInternetIsFeatureZoneElevationEnabled does not use passed ISecurityManager\n");
1983 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1984 url_from
= a2w(testcases
[i
].url_from
);
1985 url_to
= a2w(testcases
[i
].url_to
);
1987 if(testcases
[i
].policy_flags
!= -1) {
1988 ProcessUrlAction_policy
= testcases
[i
].policy_flags
;
1989 SET_EXPECT(ProcessUrlAction
);
1991 hres
= pCoInternetIsFeatureZoneElevationEnabled(url_from
, url_to
,
1992 &security_manager
, testcases
[i
].flags
);
1993 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureZoneElevationEnabled returned %x\n", i
, hres
);
1994 if(testcases
[i
].policy_flags
!= -1)
1995 CHECK_CALLED(ProcessUrlAction
);
1997 if(testcases
[i
].policy_flags
!= -1)
1998 SET_EXPECT(ProcessUrlAction
);
1999 hres
= pCoInternetIsFeatureEnabledForUrl(FEATURE_ZONE_ELEVATION
,
2000 testcases
[i
].flags
, url_to
, &security_manager
);
2001 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureEnabledForUrl returned %x\n", i
, hres
);
2002 if(testcases
[i
].policy_flags
!= -1)
2003 CHECK_CALLED(ProcessUrlAction
);
2005 heap_free(url_from
);
2016 hurlmon
= GetModuleHandleA("urlmon.dll");
2017 pCoInternetCreateSecurityManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateSecurityManager");
2018 pCoInternetCreateZoneManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateZoneManager");
2019 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
2020 pCoInternetGetSecurityUrlEx
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrlEx");
2021 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
2022 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
2023 pCoInternetIsFeatureEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabled");
2024 pCoInternetIsFeatureEnabledForUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabledForUrl");
2025 pCoInternetIsFeatureZoneElevationEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureZoneElevationEnabled");
2027 if (!pCoInternetCreateSecurityManager
|| !pCoInternetCreateZoneManager
||
2028 !pCoInternetGetSecurityUrl
) {
2029 win_skip("Various CoInternet* functions not present in IE 4.0\n");
2033 argc
= winetest_get_mainargs(&argv
);
2034 if(argc
> 2 && !strcmp(argv
[2], "domain_tests")) {
2035 test_zone_domain_mappings();
2039 OleInitialize(NULL
);
2040 register_protocols();
2042 test_InternetGetSecurityUrl();
2044 if(!pCoInternetGetSecurityUrlEx
|| !pCreateUri
)
2045 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
2047 test_InternetGetSecurityUrlEx();
2048 test_InternetGetSecurityUrlEx_Pluggable();
2051 test_SecurityManager();
2052 test_SecurityManagerEx2();
2054 test_zone_domains();
2055 test_CoInternetCreateZoneManager();
2056 test_CreateZoneEnumerator();
2057 test_GetZoneActionPolicy();
2059 test_GetZoneAttributes();
2060 test_SetZoneAttributes();
2061 test_InternetSecurityMarshalling();
2062 test_CoInternetIsFeatureZoneElevationEnabled();
2064 unregister_protocols();