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
23 #define NONAMELESSUNION
25 /* needed for IInternetZoneManagerEx2 */
26 #define _WIN32_IE 0x0700
28 #include <wine/test.h>
40 #define URLZONE_CUSTOM URLZONE_USER_MIN+1
41 #define URLZONE_CUSTOM2 URLZONE_CUSTOM+1
43 #define DEFINE_EXPECT(func) \
44 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
46 #define SET_EXPECT(func) \
47 expect_ ## func = TRUE
49 #define CHECK_EXPECT(func) \
51 ok(expect_ ##func, "unexpected call " #func "\n"); \
52 expect_ ## func = FALSE; \
53 called_ ## func = TRUE; \
56 #define CHECK_EXPECT2(func) \
58 ok(expect_ ##func, "unexpected call " #func "\n"); \
59 called_ ## func = TRUE; \
62 #define CHECK_CALLED(func) \
64 ok(called_ ## func, "expected " #func "\n"); \
65 expect_ ## func = called_ ## func = FALSE; \
68 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input
);
69 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input2
);
70 DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected
);
71 DEFINE_EXPECT(ParseUrl_SECURITY_URL_http
);
72 DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
73 DEFINE_EXPECT(ProcessUrlAction
);
75 static HRESULT (WINAPI
*pCoInternetCreateSecurityManager
)(IServiceProvider
*, IInternetSecurityManager
**, DWORD
);
76 static HRESULT (WINAPI
*pCoInternetCreateZoneManager
)(IServiceProvider
*, IInternetZoneManager
**, DWORD
);
77 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
78 static HRESULT (WINAPI
*pCoInternetGetSecurityUrlEx
)(IUri
*, IUri
**, PSUACTION
, DWORD_PTR
);
79 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
80 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
81 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabled
)(INTERNETFEATURELIST
, DWORD
);
82 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabledForUrl
)(INTERNETFEATURELIST
, DWORD
, LPCWSTR
, IInternetSecurityManager
*);
83 static HRESULT (WINAPI
*pCoInternetIsFeatureZoneElevationEnabled
)(LPCWSTR
, LPCWSTR
, IInternetSecurityManager
*, DWORD
);
85 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
86 '/','b','l','a','n','k','.','h','t','m',0};
87 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
88 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
89 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
90 '%','2','e','j','p','g',0};
91 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
92 '.','w','i','n','e','t','e','s','t',0};
93 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
94 static const WCHAR url7
[] = {'f','t','p',':','/','/','z','o','n','e','3',
95 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
96 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
97 static const WCHAR url9
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
98 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
99 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
101 static const WCHAR url11
[] = {'f','i','l','e',':','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
102 static const WCHAR url12
[] = {'f','i','l','e',':','/','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
103 static const WCHAR url13
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m',0};
104 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};
105 static const WCHAR url15
[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','c','o','m','.','u','k',0};
106 static const WCHAR url16
[] = {'f','i','l','e',':','/','/','/','c',':',0};
107 static const WCHAR url17
[] = {'f','i','l','e',':','/','/','/','c',':','c','\\',0};
108 static const WCHAR url18
[] = {'c',':','\\','t','e','s','t','.','h','t','m',0};
110 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
113 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
114 static const WCHAR security_urlW
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
115 static const WCHAR security_url2W
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g','2',0};
116 static const WCHAR security_expectedW
[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
117 static const WCHAR winetest_to_httpW
[] = {'w','i','n','e','t','e','s','t',':','h',0};
119 static const char *szZoneMapDomainsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains";
120 static const char *szInternetSettingsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
122 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
123 static const BYTE secid2
[] = {'*',':','i','n','d','e','x','.','h','t','m',3,0,0,0};
124 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
125 '.','w','i','n','e','t','e','s','t',3,0,0,0};
126 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
127 static const BYTE secid7
[] = {'f','t','p',':','z','o','n','e','3',
128 '.','w','i','n','e','t','e','s','t',3,0,0,0};
129 static const BYTE secid10
[] =
130 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
131 static const BYTE secid14
[] =
132 {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',3,0,0,0};
133 static const BYTE secid10_2
[] =
134 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
135 static const BYTE secid13
[] = {'h','t','t','p',':','c','o','m','.','u','k',3,0,0,0};
136 static const BYTE secid13_2
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m','.','u','k',3,0,0,0};
138 static const GUID CLSID_TestActiveX
=
139 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
141 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
142 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
143 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
145 static int called_securl_http
;
146 static DWORD ProcessUrlAction_policy
;
148 static struct secmgr_test
{
156 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
157 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
158 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
159 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
160 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
161 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
},
162 {url11
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
163 {url12
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
164 {url16
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
165 {url17
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
166 {url18
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
}
169 static int strcmp_w(const WCHAR
*str1
, const WCHAR
*str2
)
171 DWORD len1
= lstrlenW(str1
);
172 DWORD len2
= lstrlenW(str2
);
174 if(len1
!=len2
) return 1;
175 return memcmp(str1
, str2
, len1
*sizeof(WCHAR
));
178 static inline void heap_free(void *mem
)
180 HeapFree(GetProcessHeap(), 0, mem
);
183 static inline LPWSTR
a2w(LPCSTR str
)
188 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
189 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
190 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
196 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
197 LPWSTR strAW
= a2w(strA
);
198 DWORD ret
= lstrcmpW(strAW
, strB
);
204 /* Based on RegDeleteTreeW from dlls/advapi32/registry.c */
205 static LONG
myRegDeleteTreeA(HKEY hKey
, LPCSTR lpszSubKey
)
208 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
209 DWORD dwMaxLen
, dwSize
;
210 CHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
215 ret
= RegOpenKeyExA(hKey
, lpszSubKey
, 0, KEY_READ
, &hSubKey
);
219 /* Get highest length for keys, values */
220 ret
= RegQueryInfoKeyA(hSubKey
, NULL
, NULL
, NULL
, NULL
,
221 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
222 if (ret
) goto cleanup
;
226 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
227 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(CHAR
))
229 /* Name too big: alloc a buffer for it */
230 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(CHAR
))))
232 ret
= ERROR_NOT_ENOUGH_MEMORY
;
237 /* Recursively delete all the subkeys */
241 if (RegEnumKeyExA(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
242 NULL
, NULL
, NULL
)) break;
244 ret
= myRegDeleteTreeA(hSubKey
, lpszName
);
245 if (ret
) goto cleanup
;
249 ret
= RegDeleteKeyA(hKey
, lpszSubKey
);
254 if (RegEnumValueA(hKey
, 0, lpszName
, &dwSize
,
255 NULL
, NULL
, NULL
, NULL
)) break;
257 ret
= RegDeleteValueA(hKey
, lpszName
);
258 if (ret
) goto cleanup
;
262 /* Free buffer if allocated */
263 if (lpszName
!= szNameBuf
)
266 RegCloseKey(hSubKey
);
270 static HRESULT WINAPI
SecurityManager_QueryInterface(IInternetSecurityManager
* This
,
271 REFIID riid
, void **ppvObject
)
273 ok(0, "unexpected call\n");
277 static ULONG WINAPI
SecurityManager_AddRef(IInternetSecurityManager
* This
)
282 static ULONG WINAPI
SecurityManager_Release(IInternetSecurityManager
* This
)
287 static HRESULT WINAPI
SecurityManager_SetSecuritySite(IInternetSecurityManager
* This
,
288 IInternetSecurityMgrSite
*pSite
)
290 ok(0, "unexpected call\n");
294 static HRESULT WINAPI
SecurityManager_GetSecuritySite(IInternetSecurityManager
* This
,
295 IInternetSecurityMgrSite
**ppSite
)
297 ok(0, "unexpected call\n");
301 static HRESULT WINAPI
SecurityManager_MapUrlToZone(IInternetSecurityManager
* This
,
302 LPCWSTR pwszUrl
, DWORD
*pdwZone
, DWORD dwFlags
)
304 ok(0, "unexpected call\n");
308 static HRESULT WINAPI
SecurityManager_GetSecurityId(IInternetSecurityManager
* This
,
309 LPCWSTR pwszUrl
, BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
311 ok(0, "unexpected call\n");
315 static HRESULT WINAPI
SecurityManager_ProcessUrlAction(IInternetSecurityManager
* This
,
316 LPCWSTR pwszUrl
, DWORD dwAction
, BYTE
*pPolicy
, DWORD cbPolicy
,
317 BYTE
*pContext
, DWORD cbContext
, DWORD dwFlags
, DWORD dwReserved
)
319 CHECK_EXPECT(ProcessUrlAction
);
320 ok(dwAction
== URLACTION_FEATURE_ZONE_ELEVATION
, "dwAction = %x\n", dwAction
);
321 ok(cbPolicy
== sizeof(DWORD
), "cbPolicy = %d\n", cbPolicy
);
322 ok(!pContext
, "pContext != NULL\n");
323 ok(dwFlags
== PUAF_NOUI
, "dwFlags = %x\n", dwFlags
);
324 ok(dwReserved
== 0, "dwReserved = %x\n", dwReserved
);
326 *pPolicy
= ProcessUrlAction_policy
;
327 return ProcessUrlAction_policy
==URLPOLICY_ALLOW
? S_OK
: S_FALSE
;
330 static HRESULT WINAPI
SecurityManager_QueryCustomPolicy(IInternetSecurityManager
* This
,
331 LPCWSTR pwszUrl
, REFGUID guidKey
, BYTE
**ppPolicy
, DWORD
*pcbPolicy
,
332 BYTE
*pContext
, DWORD cbContext
, DWORD dwReserved
)
334 ok(0, "unexpected call\n");
338 static HRESULT WINAPI
SecurityManager_SetZoneMapping(IInternetSecurityManager
* This
,
339 DWORD dwZone
, LPCWSTR lpszPattern
, DWORD dwFlags
)
341 ok(0, "unexpected call\n");
345 static HRESULT WINAPI
SecurityManager_GetZoneMappings(IInternetSecurityManager
* This
,
346 DWORD dwZone
, IEnumString
**ppenumString
, DWORD dwFlags
)
348 ok(0, "unexpected call\n");
352 static const IInternetSecurityManagerVtbl SecurityManagerVtbl
= {
353 SecurityManager_QueryInterface
,
354 SecurityManager_AddRef
,
355 SecurityManager_Release
,
356 SecurityManager_SetSecuritySite
,
357 SecurityManager_GetSecuritySite
,
358 SecurityManager_MapUrlToZone
,
359 SecurityManager_GetSecurityId
,
360 SecurityManager_ProcessUrlAction
,
361 SecurityManager_QueryCustomPolicy
,
362 SecurityManager_SetZoneMapping
,
363 SecurityManager_GetZoneMappings
366 static IInternetSecurityManager security_manager
= { &SecurityManagerVtbl
};
368 static void test_SecurityManager(void)
371 IInternetSecurityManager
*secmgr
= NULL
;
373 DWORD zone
, size
, policy
;
376 if(!pCoInternetCreateSecurityManager
) {
380 trace("Testing security manager...\n");
382 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
383 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
387 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
389 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
391 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
392 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
393 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
394 i
, hres
, secmgr_tests
[i
].zone_hres
);
396 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
397 secmgr_tests
[i
].zone
);
399 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
402 memset(buf
, 0xf0, sizeof(buf
));
403 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
405 ok(hres
== secmgr_tests
[i
].secid_hres
,
406 "[%d] GetSecurityId failed: %08x, expected %08x\n",
407 i
, hres
, secmgr_tests
[i
].secid_hres
);
408 if(secmgr_tests
[i
].secid
) {
409 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
410 i
, size
, secmgr_tests
[i
].secid_size
);
411 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
416 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
417 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
418 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
420 /* win2k3 translates %20 into a space */
422 memset(buf
, 0xf0, sizeof(buf
));
423 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
424 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
425 ok(size
== sizeof(secid10
) ||
426 size
== sizeof(secid10_2
), /* win2k3 */
428 ok(!memcmp(buf
, secid10
, sizeof(secid10
)) ||
429 !memcmp(buf
, secid10_2
, sizeof(secid10_2
)), /* win2k3 */
433 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url13
, &zone
, 0);
434 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
435 ok(zone
== URLZONE_INVALID
|| broken(zone
== URLZONE_INTERNET
), "zone=%d\n", zone
);
438 memset(buf
, 0xf0, sizeof(buf
));
439 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url13
, buf
, &size
, 0);
440 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityId failed: %08x\n", hres
);
443 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url14
, &zone
, 0);
444 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
445 ok(zone
== URLZONE_INTERNET
, "zone=%d\n", zone
);
448 memset(buf
, 0xf0, sizeof(buf
));
449 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url14
, buf
, &size
, 0);
450 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
451 ok(size
== sizeof(secid14
), "size=%d\n", size
);
452 ok(!memcmp(buf
, secid14
, size
), "wrong secid\n");
455 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
456 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
457 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
460 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
461 ok(hres
== E_INVALIDARG
,
462 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
463 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
465 ok(hres
== E_INVALIDARG
,
466 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
467 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
469 ok(hres
== E_INVALIDARG
,
470 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
472 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
473 sizeof(WCHAR
), NULL
, 0, 0, 0);
474 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
476 IInternetSecurityManager_Release(secmgr
);
479 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
480 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
481 static BOOL
is_ie_hardened(void)
484 DWORD ie_harden
, type
, size
;
487 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
488 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
489 size
= sizeof(DWORD
);
490 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
494 RegCloseKey(zone_map
);
497 return ie_harden
!= 0;
500 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
502 DWORD res
, size
, policy
, reg_policy
;
507 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
508 * The test should be changed to cope with that, if need be.
510 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
511 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
512 if(res
!= ERROR_SUCCESS
) {
513 ok(0, "Could not open zone key\n");
517 wsprintf(buf
, "%X", action
);
518 size
= sizeof(DWORD
);
519 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
521 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
523 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
524 sizeof(WCHAR
), NULL
, 0, 0, 0);
525 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
526 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
527 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
530 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
531 sizeof(DWORD
), URLZONEREG_DEFAULT
);
532 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
533 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
534 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
539 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
540 sizeof(DWORD
), URLZONEREG_DEFAULT
);
541 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
542 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
544 if(policy
!= URLPOLICY_QUERY
) {
545 if(winetest_interactive
|| ! is_ie_hardened()) {
546 BOOL expect_parse_call
= !called_securl_http
;
549 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
550 sizeof(WCHAR
), NULL
, 0, 0, 0);
551 if(reg_policy
== URLPOLICY_DISALLOW
)
552 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
554 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
555 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
558 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
560 if(reg_policy
== URLPOLICY_DISALLOW
)
561 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
563 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
564 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
567 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
568 sizeof(DWORD
), NULL
, 0, 0, 0);
569 if(reg_policy
== URLPOLICY_DISALLOW
)
570 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
572 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
573 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
576 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
577 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
578 if(reg_policy
== URLPOLICY_DISALLOW
)
579 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
581 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
582 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
585 if(expect_parse_call
)
586 SET_EXPECT(ParseUrl_SECURITY_URL_http
);
587 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, winetest_to_httpW
, action
, (BYTE
*)&policy
,
588 sizeof(DWORD
), NULL
, 0, 0, 0);
589 if(expect_parse_call
)
590 CHECK_CALLED(ParseUrl_SECURITY_URL_http
);
591 if(reg_policy
== URLPOLICY_DISALLOW
)
592 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
594 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
595 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
597 skip("IE running in Enhanced Security Configuration\n");
602 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
608 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
609 sizeof(DWORD
), URLZONEREG_DEFAULT
);
610 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
611 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
614 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
615 sizeof(WCHAR
), NULL
, 0, 0, 0);
616 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
619 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
620 sizeof(DWORD
), NULL
, 0, 0, 0);
621 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
622 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
625 static void test_activex(IInternetSecurityManager
*secmgr
)
627 DWORD policy
, policy_size
;
628 struct CONFIRMSAFETY cs
;
633 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
634 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
635 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
636 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
638 cs
.clsid
= CLSID_TestActiveX
;
639 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
641 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
642 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
643 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
646 static void test_polices(void)
648 IInternetZoneManager
*zonemgr
= NULL
;
649 IInternetSecurityManager
*secmgr
= NULL
;
652 trace("testing polices...\n");
654 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
655 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
656 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
657 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
659 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
660 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
661 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
662 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
663 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
665 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
666 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
668 test_activex(secmgr
);
670 IInternetSecurityManager_Release(secmgr
);
671 IInternetZoneManager_Release(zonemgr
);
674 /* IE (or at least newer versions of it) seem to cache the keys in ZoneMap
675 * when urlmon.dll is loaded and it doesn't seem to update its cache, unless
676 * SetZoneMapping is used.
678 static void test_zone_domain_cache(void)
682 IInternetSecurityManager
*secmgr
= NULL
;
683 HKEY domains
, domain
;
685 static const WCHAR testing_domain_urlW
[] = {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.',
686 'd','o','m','a','i','n','/',0};
688 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
689 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
690 if(res
!= ERROR_SUCCESS
)
693 res
= RegCreateKeyA(domains
, "testing.domain", &domain
);
694 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
695 if(res
!= ERROR_SUCCESS
) {
696 RegCloseKey(domains
);
700 zone
= URLZONE_CUSTOM
;
701 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
702 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
706 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
707 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
709 zone
= URLZONE_INVALID
;
710 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, testing_domain_urlW
, &zone
, 0);
711 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
712 todo_wine
ok(zone
== URLZONE_INTERNET
, "Got %d, expected URLZONE_INTERNET\n", zone
);
714 /* FIXME: Play nice with ZoneMaps that existed before the test is run. */
715 res
= RegDeleteKeyA(domains
, "testing.domain");
716 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
718 RegCloseKey(domains
);
719 IInternetSecurityManager_Release(secmgr
);
724 const char *subdomain
;
727 } zone_domain_mapping
;
729 /* FIXME: Move these into SetZoneMapping tests when the day comes... */
730 static const zone_domain_mapping zone_domain_mappings
[] = {
731 /* Implicitly means "*.yabadaba.do". */
732 {"yabadaba.do",NULL
,"http",URLZONE_CUSTOM
},
733 /* The '*' doesn't count as a wildcard, since its not the first component of the subdomain. */
734 {"super.cool","testing.*","ftp",URLZONE_CUSTOM2
},
735 /* The '*' counts since it's the first component of the subdomain. */
736 {"super.cool","*.testing","ftp",URLZONE_CUSTOM2
},
737 /* All known scheme types apply to wildcard schemes. */
738 {"tests.test",NULL
,"*",URLZONE_CUSTOM
},
739 /* Due to a defect with how windows checks the mappings, unknown scheme types
740 * never seem to get mapped properly. */
741 {"tests.test",NULL
,"zip",URLZONE_CUSTOM
},
742 {"www.testing.com",NULL
,"http",URLZONE_CUSTOM
},
743 {"www.testing.com","testing","http",URLZONE_CUSTOM2
},
744 {"org",NULL
,"http",URLZONE_CUSTOM
},
745 {"org","testing","http",URLZONE_CUSTOM2
},
746 {"wine.testing",NULL
,"*",URLZONE_CUSTOM2
}
749 static void register_zone_domains(void)
754 /* Some Windows versions don't seem to have a "Domains" key in their HKLM. */
755 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
756 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
757 if(res
== ERROR_SUCCESS
) {
759 DWORD zone
= URLZONE_CUSTOM
;
761 res
= RegCreateKeyA(domains
, "local.machine", &domain
);
762 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
764 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
765 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
768 RegCloseKey(domains
);
771 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
772 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
774 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
775 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
778 res
= RegCreateKeyA(domains
, test
->domain
, &domain
);
779 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
781 /* Only set the value if there's no subdomain. */
782 if(!test
->subdomain
) {
783 res
= RegSetValueExA(domain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
784 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
788 res
= RegCreateKeyA(domain
, test
->subdomain
, &subdomain
);
789 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
791 res
= RegSetValueExA(subdomain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
792 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
794 RegCloseKey(subdomain
);
800 RegCloseKey(domains
);
803 static void unregister_zone_domains(void)
808 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
809 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
810 if(res
== ERROR_SUCCESS
) {
811 RegDeleteKeyA(domains
, "local.machine");
812 RegCloseKey(domains
);
815 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
816 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
818 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
819 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
821 /* FIXME: Uses the "cludge" approach to remove the test data from the registry!
822 * Although, if domain names are... unique, this shouldn't cause any harm
823 * to keys (if any) that existed before the tests.
825 if(test
->subdomain
) {
828 res
= RegOpenKeyA(domains
, test
->domain
, &domain
);
829 if(res
== ERROR_SUCCESS
) {
830 RegDeleteKeyA(domain
, test
->subdomain
);
834 RegDeleteKeyA(domains
, test
->domain
);
837 RegCloseKey(domains
);
840 static void run_child_process(void)
842 char cmdline
[MAX_PATH
];
845 PROCESS_INFORMATION pi
;
846 STARTUPINFO si
= { 0 };
849 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
852 winetest_get_mainargs(&argv
);
853 sprintf(cmdline
, "\"%s\" %s domain_tests", argv
[0], argv
[1]);
854 ret
= CreateProcess(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
855 ok(ret
, "Failed to spawn child process: %u\n", GetLastError());
856 winetest_wait_child_process(pi
.hProcess
);
857 CloseHandle(pi
.hThread
);
858 CloseHandle(pi
.hProcess
);
868 static const zone_mapping_test zone_mapping_tests
[] = {
869 /* Tests for "yabadaba.do" zone mappings. */
870 {"http://yabadaba.do/",URLZONE_CUSTOM
},
871 {"http://google.yabadaba.do/",URLZONE_CUSTOM
},
872 {"zip://yabadaba.do/",URLZONE_INTERNET
},
873 /* Tests for "super.cool" zone mappings. */
874 {"ftp://testing.google.super.cool/",URLZONE_INTERNET
},
875 {"ftp://testing.*.super.cool/",URLZONE_CUSTOM2
},
876 {"ftp://google.testing.super.cool/",URLZONE_CUSTOM2
},
877 /* Tests for "tests.test" zone mappings. */
878 {"http://tests.test/",URLZONE_CUSTOM
},
879 {"http://www.tests.test/",URLZONE_CUSTOM
},
880 {"ftp://tests.test/",URLZONE_CUSTOM
},
881 {"ftp://www.tests.test/",URLZONE_CUSTOM
},
882 {"test://www.tests.test/",URLZONE_INTERNET
},
883 {"test://tests.test/",URLZONE_INTERNET
},
884 {"zip://www.tests.test/",URLZONE_INTERNET
},
885 {"zip://tests.test/",URLZONE_INTERNET
},
886 /* Tests for "www.testing.com" zone mappings. */
887 {"http://google.www.testing.com/",URLZONE_INTERNET
},
888 {"http://www.testing.com/",URLZONE_CUSTOM
,FALSE
,URLZONE_INTERNET
},
889 {"http://testing.www.testing.com/",URLZONE_CUSTOM2
,FALSE
,URLZONE_INTERNET
},
890 /* Tests for "org" zone mappings. */
891 {"http://google.org/",URLZONE_INTERNET
,FALSE
,URLZONE_CUSTOM
},
892 {"http://org/",URLZONE_CUSTOM
},
893 {"http://testing.org/",URLZONE_CUSTOM2
},
894 /* Tests for "wine.testing" mapping */
895 {"*:wine.testing/test",URLZONE_CUSTOM2
},
896 {"http://wine.testing/testing",URLZONE_CUSTOM2
}
899 static void test_zone_domain_mappings(void)
903 IInternetSecurityManager
*secmgr
= NULL
;
905 DWORD zone
= URLZONE_INVALID
;
907 trace("testing zone domain mappings...\n");
909 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
910 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
912 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
913 if(res
== ERROR_SUCCESS
) {
914 static const WCHAR local_machineW
[] = {'h','t','t','p',':','/','/','t','e','s','t','.','l','o','c','a','l',
915 '.','m','a','c','h','i','n','e','/',0};
917 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, local_machineW
, &zone
, 0);
918 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
919 ok(zone
== URLZONE_CUSTOM
, "Expected URLZONE_CUSTOM, but got %d\n", zone
);
921 RegCloseKey(domains
);
924 for(i
= 0; i
< sizeof(zone_mapping_tests
)/sizeof(zone_mapping_tests
[0]); ++i
) {
925 const zone_mapping_test
*test
= zone_mapping_tests
+i
;
926 LPWSTR urlW
= a2w(test
->url
);
927 zone
= URLZONE_INVALID
;
929 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, urlW
, &zone
, 0);
930 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
933 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
934 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
936 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
937 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
942 IInternetSecurityManager_Release(secmgr
);
945 static void test_zone_domains(void)
947 if(is_ie_hardened()) {
948 skip("IE running in Enhanced Security Configuration\n");
950 } else if(!pCreateUri
) {
951 win_skip("Skipping zone domain tests, IE too old\n");
955 trace("testing zone domains...\n");
957 test_zone_domain_cache();
959 register_zone_domains();
961 unregister_zone_domains();
964 static void test_CoInternetCreateZoneManager(void)
966 IInternetZoneManager
*zonemgr
= NULL
;
967 IUnknown
*punk
= NULL
;
970 trace("simple zone manager tests...\n");
972 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
973 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
977 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
978 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
980 IUnknown_Release(punk
);
982 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
983 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
985 IUnknown_Release(punk
);
988 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
990 IUnknown_Release(punk
);
992 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
993 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
/* some W2K3 */),
994 "got 0x%x (expected S_OK)\n", hr
);
996 IUnknown_Release(punk
);
998 win_skip("InternetZoneManagerEx2 not supported\n");
1002 win_skip("InternetZoneManagerEx not supported\n");
1004 hr
= IInternetZoneManager_Release(zonemgr
);
1005 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1009 static void test_CreateZoneEnumerator(void)
1011 IInternetZoneManager
*zonemgr
= NULL
;
1018 trace("testing zone enumerator...\n");
1020 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1021 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1026 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
1027 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
1028 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
1031 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
1032 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
1033 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
1037 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
1038 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1039 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1040 hr
, dwEnum
, dwCount
);
1044 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
1045 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1046 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1047 hr
, dwEnum
, dwCount
);
1052 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1053 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1055 if (SUCCEEDED(hr
)) {
1057 dwCount2
=0xdeadbeef;
1058 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
1059 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1060 if (SUCCEEDED(hr
)) {
1061 /* native urlmon has an incrementing counter for dwEnum */
1062 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
1063 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1066 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1067 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1069 /* Destroy the Enumerator twice is detected and handled in native urlmon */
1070 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1071 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
1074 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
1075 hr
= IInternetZoneManager_Release(zonemgr
);
1076 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1079 static void test_GetZoneActionPolicy(void)
1081 IInternetZoneManager
*zonemgr
= NULL
;
1084 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
1086 trace("testing GetZoneActionPolixy...\n");
1088 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1089 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
1093 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1094 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1095 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
1096 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
1097 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
1098 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
1099 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
1100 "unexpected policy=%d\n", *(DWORD
*)buf
);
1102 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
1103 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1104 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1106 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1107 2, URLZONEREG_DEFAULT
);
1108 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1110 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
1111 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1112 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
1113 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
1115 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
1116 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1117 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1119 IInternetZoneManager_Release(zonemgr
);
1122 static void test_GetZoneAt(void)
1124 IInternetZoneManager
*zonemgr
= NULL
;
1131 trace("testing GetZoneAt...\n");
1133 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1134 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1138 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1143 /* this crashes with native urlmon */
1144 IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
1147 dwZone
= 0xdeadbeef;
1148 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
1149 ok(hr
== E_INVALIDARG
,
1150 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1152 for (i
= 0; i
< dwCount
; i
++)
1154 dwZone
= 0xdeadbeef;
1155 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
1156 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
1159 dwZone
= 0xdeadbeef;
1160 /* MSDN (index .. must be .. less than or equal to) is wrong */
1161 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
1162 ok(hr
== E_INVALIDARG
,
1163 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1165 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1166 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1169 hr
= IInternetZoneManager_Release(zonemgr
);
1170 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1173 static void test_GetZoneAttributes(void)
1175 IInternetZoneManager
*zonemgr
= NULL
;
1176 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
1177 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1181 trace("testing GetZoneAttributes...\n");
1183 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1184 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1188 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
1189 for (i
= 0; i
< 5; i
++) {
1190 memset(buffer
, -1, sizeof(buffer
));
1191 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
1192 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
1195 /* IE8 no longer set cbSize */
1196 memset(buffer
, -1, sizeof(buffer
));
1198 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1199 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1200 ok((pZA
->cbSize
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1201 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
1203 memset(buffer
, -1, sizeof(buffer
));
1205 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1206 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1207 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1208 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
1210 memset(buffer
, -1, sizeof(buffer
));
1211 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1212 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1213 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1214 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
1216 /* IE8 no longer fail on invalid zones */
1217 memset(buffer
, -1, sizeof(buffer
));
1218 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
1219 ok(hr
== S_OK
|| (hr
== E_FAIL
),
1220 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
1222 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
1223 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1225 hr
= IInternetZoneManager_Release(zonemgr
);
1226 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1229 static void test_SetZoneAttributes(void)
1231 IInternetZoneManager
*zonemgr
= NULL
;
1232 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 16];
1233 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1234 CHAR regpath
[MAX_PATH
];
1239 trace("testing SetZoneAttributes...\n");
1240 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1241 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1245 memset(buffer
, -1, sizeof(buffer
));
1246 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, URLZONE_LOCAL_MACHINE
, pZA
);
1247 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1249 sprintf(regpath
, "%s\\Zones\\%d", szInternetSettingsKey
, URLZONE_CUSTOM
);
1250 res
= RegCreateKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1253 ok(res
== ERROR_SUCCESS
, "got %d (expected ERROR_SUCCESS)\n", res
);
1254 if (res
!= ERROR_SUCCESS
)
1257 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
);
1258 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, NULL
);
1259 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1262 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1264 win_skip("SetZoneAttributes not supported: IE too old\n");
1267 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1269 /* native urlmon ignores cbSize */
1270 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) + sizeof(DWORD
);
1271 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1272 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) + sizeof(DWORD) (expected S_OK)\n", hr
);
1274 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) - sizeof(DWORD
);
1275 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1276 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) - sizeof(DWORD) (expected S_OK)\n", hr
);
1279 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1280 ok(hr
== S_OK
, "got 0x%x for size 0 (expected S_OK)\n", hr
);
1282 /* The key for the zone must be present, when calling SetZoneAttributes */
1283 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1284 /* E_FAIL is returned from IE6 here, which is reasonable.
1285 All newer IE return S_OK without saving the zone attributes to the registry.
1286 This is a Windows bug, but we have to accept that as standard */
1287 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1288 ok((hr
== S_OK
) || broken(hr
== E_FAIL
), "got 0x%x (expected S_OK)\n", hr
);
1290 /* SetZoneAttributes did not create the directory */
1291 res
= RegOpenKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1292 ok((res
== ERROR_FILE_NOT_FOUND
) && (hkey
== NULL
),
1293 "got %u with %p (expected ERROR_FILE_NOT_FOUND with NULL)\n", res
, hkey
);
1295 if (hkey
) RegCloseKey(hkey
);
1298 /* delete zone settings in the registry */
1299 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1301 hr
= IInternetZoneManager_Release(zonemgr
);
1302 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1306 static void test_InternetSecurityMarshalling(void)
1308 IInternetSecurityManager
*secmgr
= NULL
;
1313 trace("testing marshalling...\n");
1315 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
1316 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1320 hres
= IInternetSecurityManager_QueryInterface(secmgr
, &IID_IUnknown
, (void**)&unk
);
1321 ok(hres
== S_OK
, "QueryInterface returned: %08x\n", hres
);
1323 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
1324 ok(hres
== S_OK
, "CreateStreamOnHGlobal returned: %08x\n", hres
);
1326 hres
= CoMarshalInterface(stream
, &IID_IInternetSecurityManager
, unk
, MSHCTX_INPROC
, NULL
, MSHLFLAGS_NORMAL
);
1327 /* Not supported in W98 */
1328 ok(hres
== S_OK
|| broken(hres
== REGDB_E_IIDNOTREG
),
1329 "CoMarshalInterface returned: %08x\n", hres
);
1331 IStream_Release(stream
);
1332 IUnknown_Release(unk
);
1333 IInternetSecurityManager_Release(secmgr
);
1336 static void test_InternetGetSecurityUrl(void)
1338 const WCHAR url5_out
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
1339 '.','w','i','n','e','t','e','s','t',0};
1340 const WCHAR url7_out
[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
1342 const WCHAR
*in
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1343 const WCHAR
*out_default
[] = {url2
, url3
, url4
, url5_out
, url7_out
, url8
, url5_out
, url10
};
1344 const WCHAR
*out_securl
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1350 trace("testing CoInternetGetSecurityUrl...\n");
1352 for(i
=0; i
<sizeof(in
)/sizeof(WCHAR
*); i
++) {
1353 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_DEFAULT
, 0);
1354 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1356 ok(!strcmp_w(sec
, out_default
[i
]), "(%d) Got %s, expected %s\n",
1357 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_default
[i
]));
1361 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_SECURITY_URL_ONLY
, 0);
1362 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1364 ok(!strcmp_w(sec
, out_securl
[i
]), "(%d) Got %s, expected %s\n",
1365 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_securl
[i
]));
1370 SET_EXPECT(ParseUrl_SECURITY_URL_input2
);
1371 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1372 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1374 hres
= pCoInternetGetSecurityUrl(security_url2W
, &sec
, PSU_DEFAULT
, 0);
1375 ok(hres
== S_OK
, "CoInternetGetSecurityUrl returned 0x%08x, expected S_OK\n", hres
);
1377 CHECK_CALLED(ParseUrl_SECURITY_URL_input2
);
1378 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1379 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1381 ok(!lstrcmpW(security_expectedW
, sec
), "Expected %s but got %s\n",
1382 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(sec
));
1386 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
1387 REFIID riid
, void **ppv
)
1389 ok(0, "unexpected call\n");
1390 return E_NOINTERFACE
;
1393 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
1398 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
1403 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
1404 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
1405 DWORD
*pcchResult
, DWORD dwReserved
)
1407 const WCHAR
*ret
= NULL
;
1409 ok(pwzResult
!= NULL
, "pwzResult == NULL\n");
1410 ok(pcchResult
!= NULL
, "pcchResult == NULL\n");
1411 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
1413 switch(ParseAction
) {
1414 case PARSE_SECURITY_URL
:
1415 if(!strcmp_w(pwzUrl
, security_urlW
)) {
1416 CHECK_EXPECT(ParseUrl_SECURITY_URL_input
);
1417 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1418 ret
= security_expectedW
;
1419 } else if(!strcmp_w(pwzUrl
, security_url2W
)) {
1420 CHECK_EXPECT(ParseUrl_SECURITY_URL_input2
);
1421 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1422 ret
= security_expectedW
;
1423 } else if(!strcmp_w(pwzUrl
, security_expectedW
)) {
1424 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected
);
1425 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1426 ret
= security_expectedW
;
1427 } else if(!strcmp_w(pwzUrl
, winetest_to_httpW
)) {
1428 switch(++called_securl_http
) {
1430 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1433 CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1434 ok(cchResult
== lstrlenW(url9
)+1, "Got %d\n", cchResult
);
1437 todo_wine
CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1441 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl
));
1444 case PARSE_SECURITY_DOMAIN
:
1446 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1448 ok(!strcmp_w(pwzUrl
, security_expectedW
), "Expected %s but got %s\n",
1449 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(pwzUrl
));
1450 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1451 ret
= security_expectedW
;
1454 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction
,
1455 wine_dbgstr_w(pwzUrl
));
1461 *pcchResult
= lstrlenW(ret
)+1;
1462 if(*pcchResult
> cchResult
)
1464 memcpy(pwzResult
, ret
, (*pcchResult
)*sizeof(WCHAR
));
1468 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
1469 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
1470 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
1472 ok(0, "unexpected call\n");
1476 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
1477 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
1479 ok(0, "unexpected call\n");
1483 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
1484 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
1485 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
1487 ok(0, "unexpected call\n");
1491 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
1492 InternetProtocolInfo_QueryInterface
,
1493 InternetProtocolInfo_AddRef
,
1494 InternetProtocolInfo_Release
,
1495 InternetProtocolInfo_ParseUrl
,
1496 InternetProtocolInfo_CombineUrl
,
1497 InternetProtocolInfo_CompareUrl
,
1498 InternetProtocolInfo_QueryInfo
1501 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
1503 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1505 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
1506 *ppv
= &protocol_info
;
1510 ok(0, "unexpected call\n");
1511 return E_NOINTERFACE
;
1514 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1519 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1524 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
1525 REFIID riid
, void **ppv
)
1527 ok(0, "unexpected call\n");
1531 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1533 ok(0, "unexpected call\n");
1537 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1538 ClassFactory_QueryInterface
,
1539 ClassFactory_AddRef
,
1540 ClassFactory_Release
,
1541 ClassFactory_CreateInstance
,
1542 ClassFactory_LockServer
1545 static IClassFactory protocol_cf
= { &ClassFactoryVtbl
};
1547 static void register_protocols(void)
1549 IInternetSession
*session
;
1552 hres
= pCoInternetGetSession(0, &session
, 0);
1553 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1557 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
1558 winetestW
, 0, NULL
, 0);
1559 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1561 IInternetSession_Release(session
);
1564 static void unregister_protocols(void) {
1565 IInternetSession
*session
;
1568 hr
= pCoInternetGetSession(0, &session
, 0);
1569 ok(hr
== S_OK
, "CoInternetGetSession failed: 0x%08x\n", hr
);
1573 hr
= IInternetSession_UnregisterNameSpace(session
, &protocol_cf
, winetestW
);
1574 ok(hr
== S_OK
, "UnregisterNameSpace failed: 0x%08x\n", hr
);
1576 IInternetSession_Release(session
);
1579 static const struct {
1582 const char *security_uri
;
1583 HRESULT security_hres
;
1584 const char *default_uri
;
1585 HRESULT default_hres
;
1587 } sec_url_ex_tests
[] = {
1588 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,"*:index.html",S_OK
,"*:index.htm",S_OK
},
1589 {"file://c:\\Index.htm",Uri_CREATE_FILE_USE_DOS_PATH
,"file:///c:/Index.htm",S_OK
,"file:///c:/Index.htm",S_OK
},
1590 {"file:some%20file%2ejpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1591 {"file:some file.jpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1592 {"http://www.zone3.winetest/",0,"http://www.zone3.winetest/",S_OK
,"http://www.zone3.winetest/",S_OK
},
1593 {"about:blank",0,"about:blank",S_OK
,"about:blank",S_OK
},
1594 {"ftp://zone3.winetest/file.test",0,"ftp://zone3.winetest/file.test",S_OK
,"ftp://zone3.winetest/file.test",S_OK
},
1595 {"test:123abc",0,"test:123abc",S_OK
,"test:123abc",S_OK
},
1596 {"http:google.com/test.file",0,"http:google.com/test.file",S_OK
,"http:google.com/test.file",S_OK
},
1597 {"ftp://test@ftp.winehq.org/",0,"ftp://ftp.winehq.org/",S_OK
,"ftp://ftp.winehq.org/",S_OK
},
1598 {"test://google@ftp.winehq.org/",0,"test://google@ftp.winehq.org/",S_OK
,"test://google@ftp.winehq.org/",S_OK
}
1601 static void test_InternetGetSecurityUrlEx(void)
1605 IUri
*uri
= NULL
, *result
= NULL
;
1607 trace("testing CoInternetGetSecurityUrlEx...\n");
1609 hr
= pCoInternetGetSecurityUrlEx(NULL
, NULL
, PSU_DEFAULT
, 0);
1610 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1612 result
= (void*) 0xdeadbeef;
1613 hr
= pCoInternetGetSecurityUrlEx(NULL
, &result
, PSU_DEFAULT
, 0);
1614 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1615 ok(result
== (void*) 0xdeadbeef, "'result' was %p\n", result
);
1617 for(i
= 0; i
< sizeof(sec_url_ex_tests
)/sizeof(sec_url_ex_tests
[0]); ++i
) {
1618 LPWSTR uriW
= a2w(sec_url_ex_tests
[i
].uri
);
1621 hr
= pCreateUri(uriW
, sec_url_ex_tests
[i
].create_flags
, 0, &uri
);
1622 ok(hr
== S_OK
, "CreateUri returned 0x%08x on test %d\n", hr
, i
);
1626 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1627 if(sec_url_ex_tests
[i
].todo
) {
1629 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1630 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1631 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1633 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1634 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1635 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1640 hr
= IUri_GetDisplayUri(result
, &received
);
1641 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1643 if(sec_url_ex_tests
[i
].todo
) {
1645 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1646 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1647 wine_dbgstr_w(received
), i
);
1649 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1650 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1651 wine_dbgstr_w(received
), i
);
1654 SysFreeString(received
);
1656 if(result
) IUri_Release(result
);
1659 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1660 if(sec_url_ex_tests
[i
].todo
) {
1662 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1663 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1664 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1666 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1667 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1668 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1673 hr
= IUri_GetDisplayUri(result
, &received
);
1674 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1676 if(sec_url_ex_tests
[i
].todo
) {
1678 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1679 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1680 wine_dbgstr_w(received
), i
);
1682 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1683 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1684 wine_dbgstr_w(received
), i
);
1687 SysFreeString(received
);
1689 if(result
) IUri_Release(result
);
1692 if(uri
) IUri_Release(uri
);
1697 static void test_InternetGetSecurityUrlEx_Pluggable(void)
1700 IUri
*uri
= NULL
, *result
;
1702 trace("testing CoInternetGetSecurityUrlEx for pluggable protocols...\n");
1704 hr
= pCreateUri(security_urlW
, 0, 0, &uri
);
1705 ok(hr
== S_OK
, "CreateUri returned 0x%08x\n", hr
);
1707 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1708 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1709 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1711 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1712 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1714 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1715 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1716 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1719 BSTR received
= NULL
;
1721 hr
= IUri_GetAbsoluteUri(result
, &received
);
1722 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1724 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1725 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1727 SysFreeString(received
);
1729 if(result
) IUri_Release(result
);
1733 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1734 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1736 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1737 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1739 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1740 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1743 BSTR received
= NULL
;
1745 hr
= IUri_GetAbsoluteUri(result
, &received
);
1746 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1748 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1749 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1751 SysFreeString(received
);
1753 if(result
) IUri_Release(result
);
1755 if(uri
) IUri_Release(uri
);
1758 static const BYTE secidex2_1
[] = {'z','i','p',':','/','/','t','e','s','t','i','n','g','.','c','o','m','/',3,0,0,0};
1759 static const BYTE secidex2_2
[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1760 static const BYTE secidex2_3
[] = {'*',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1762 static const struct {
1772 } sec_mgr_ex2_tests
[] = {
1773 {"res://mshtml.dll/blank.htm",0,S_OK
,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1774 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,secid2
,sizeof(secid2
),S_OK
},
1775 {"file://c:\\Index.html",0,0,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1776 {"http://www.zone3.winetest/",0,0,URLZONE_INTERNET
,FALSE
,secid5
,sizeof(secid5
),S_OK
},
1777 {"about:blank",0,0,URLZONE_INTERNET
,FALSE
,secid6
,sizeof(secid6
),S_OK
},
1778 {"ftp://zone3.winetest/file.test",0,0,URLZONE_INTERNET
,FALSE
,secid7
,sizeof(secid7
),S_OK
},
1779 {"/file/testing/test.test",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1780 {"zip://testing.com/",0,0,URLZONE_INTERNET
,FALSE
,secidex2_1
,sizeof(secidex2_1
),S_OK
},
1781 {"zip:testing.com",0,0,URLZONE_INTERNET
,FALSE
,secidex2_2
,sizeof(secidex2_2
),S_OK
},
1782 {"http:google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1783 {"http:/google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1784 {"*:/testing",0,S_OK
,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1785 {"*://testing.com",0,S_OK
,URLZONE_INTERNET
,FALSE
,secidex2_3
,sizeof(secidex2_3
),S_OK
}
1788 static void test_SecurityManagerEx2(void)
1793 DWORD buf_size
= sizeof(buf
);
1794 IInternetSecurityManager
*sec_mgr
;
1795 IInternetSecurityManagerEx2
*sec_mgr2
;
1798 static const WCHAR domainW
[] = {'c','o','m','.','u','k',0};
1801 win_skip("Skipping SecurityManagerEx2, IE is too old\n");
1805 trace("Testing SecurityManagerEx2...\n");
1807 hres
= pCoInternetCreateSecurityManager(NULL
, &sec_mgr
, 0);
1808 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1810 hres
= IInternetSecurityManager_QueryInterface(sec_mgr
, &IID_IInternetSecurityManagerEx2
, (void**)&sec_mgr2
);
1811 ok(hres
== S_OK
, "QueryInterface(IID_IInternetSecurityManagerEx2) failed: %08x\n", hres
);
1815 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, NULL
, &zone
, 0, NULL
, NULL
);
1816 ok(hres
== E_INVALIDARG
, "MapUrlToZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1817 ok(zone
== URLZONE_INVALID
, "zone was %d\n", zone
);
1819 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, NULL
, buf
, &buf_size
, 0);
1820 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1821 ok(buf_size
== sizeof(buf
), "buf_size was %d\n", buf_size
);
1823 hres
= pCreateUri(url5
, 0, 0, &uri
);
1824 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1826 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, NULL
, 0, NULL
, NULL
);
1827 ok(hres
== E_INVALIDARG
, "MapToUrlZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1829 buf_size
= sizeof(buf
);
1830 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, NULL
, &buf_size
, 0);
1831 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityIdEx2 failed: %08x\n", hres
);
1832 ok(buf_size
== sizeof(buf
), "bug_size was %d\n", buf_size
);
1834 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, NULL
, 0);
1835 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1839 for(i
= 0; i
< sizeof(sec_mgr_ex2_tests
)/sizeof(sec_mgr_ex2_tests
[0]); ++i
) {
1840 LPWSTR uriW
= a2w(sec_mgr_ex2_tests
[i
].uri
);
1843 zone
= URLZONE_INVALID
;
1845 hres
= pCreateUri(uriW
, sec_mgr_ex2_tests
[i
].create_flags
, 0, &uri
);
1846 ok(hres
== S_OK
, "CreateUri returned %08x for '%s'\n", hres
, sec_mgr_ex2_tests
[i
].uri
);
1848 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, &zone
, 0, NULL
, NULL
);
1849 if(sec_mgr_ex2_tests
[i
].map_todo
) {
1851 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlZoneToEx2 returned %08x, expected %08x for '%s'\n",
1852 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1854 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1855 zone
, sec_mgr_ex2_tests
[i
].uri
);
1857 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlToZoneEx2 returned %08x, expected %08x for '%s'\n",
1858 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1859 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1860 zone
, sec_mgr_ex2_tests
[i
].uri
);
1863 buf_size
= sizeof(buf
);
1864 memset(buf
, 0xf0, buf_size
);
1866 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1867 if(sec_mgr_ex2_tests
[i
].secid_todo
) {
1869 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1870 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1871 if(sec_mgr_ex2_tests
[i
].secid
) {
1873 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1874 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1875 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1876 sec_mgr_ex2_tests
[i
].uri
);
1880 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1881 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1882 if(sec_mgr_ex2_tests
[i
].secid
) {
1883 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1884 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1885 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1886 sec_mgr_ex2_tests
[i
].uri
);
1894 hres
= pCreateUri(url15
, 0, 0, &uri
);
1895 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1897 buf_size
= sizeof(buf
);
1898 memset(buf
, 0xf0, buf_size
);
1900 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, (DWORD_PTR
)domainW
);
1901 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1902 todo_wine
ok(buf_size
== sizeof(secid13
), "buf_size was %d\n", buf_size
);
1903 todo_wine
ok(!memcmp(buf
, secid13
, sizeof(secid13
)), "Got wrong secid\n");
1905 buf_size
= sizeof(buf
);
1906 memset(buf
, 0xf0, buf_size
);
1908 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1909 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1910 ok(buf_size
== sizeof(secid13_2
), "buf_size was %d\n", buf_size
);
1911 ok(!memcmp(buf
, secid13_2
, sizeof(secid13_2
)), "Got wrong secid\n");
1915 IInternetSecurityManagerEx2_Release(sec_mgr2
);
1916 IInternetSecurityManager_Release(sec_mgr
);
1919 static void test_CoInternetIsFeatureZoneElevationEnabled(void)
1922 const char *url_from
;
1928 /* 0 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_FALSE
, URLPOLICY_ALLOW
},
1929 /* 1 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_OK
, URLPOLICY_DISALLOW
},
1930 /* 2 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_FALSE
, URLPOLICY_ALLOW
},
1931 /* 3 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_OK
, URLPOLICY_DISALLOW
},
1932 /* 4 */ { "http://www.winehq.org", "http://www.winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1933 /* 5 */ { "http://www.winehq.org", "http://www.winehq.org/dir", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1934 /* 6 */ { "http://www.winehq.org", "http://www.codeweavers.com", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1935 /* 7 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1936 /* 8 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
|0x100, S_FALSE
, URLPOLICY_ALLOW
},
1937 /* 9 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_REGISTRY
, S_FALSE
, URLPOLICY_ALLOW
},
1940 WCHAR
*url_from
, *url_to
;
1944 if(!pCoInternetIsFeatureZoneElevationEnabled
|| !pCoInternetIsFeatureEnabled
1945 || !pCoInternetIsFeatureEnabledForUrl
) {
1946 win_skip("Skipping CoInternetIsFeatureZoneElevationEnabled tests\n");
1951 hres
= pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, GET_FEATURE_FROM_PROCESS
);
1952 ok(SUCCEEDED(hres
), "CoInternetIsFeatureEnabled returned %x\n", hres
);
1954 trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%x)\n", hres
);
1956 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1957 if(hres
==S_OK
&& testcases
[i
].flags
== GET_FEATURE_FROM_PROCESS
)
1958 testcases
[i
].policy_flags
= URLPOLICY_ALLOW
;
1961 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1962 url_from
= a2w(testcases
[i
].url_from
);
1963 url_to
= a2w(testcases
[i
].url_to
);
1965 if(testcases
[i
].policy_flags
!= -1) {
1966 ProcessUrlAction_policy
= testcases
[i
].policy_flags
;
1967 SET_EXPECT(ProcessUrlAction
);
1969 hres
= pCoInternetIsFeatureZoneElevationEnabled(url_from
, url_to
,
1970 &security_manager
, testcases
[i
].flags
);
1971 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureZoneElevationEnabled returned %x\n", i
, hres
);
1972 if(testcases
[i
].policy_flags
!= -1)
1973 CHECK_CALLED(ProcessUrlAction
);
1975 if(testcases
[i
].policy_flags
!= -1)
1976 SET_EXPECT(ProcessUrlAction
);
1977 hres
= pCoInternetIsFeatureEnabledForUrl(FEATURE_ZONE_ELEVATION
,
1978 testcases
[i
].flags
, url_to
, &security_manager
);
1979 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureEnabledForUrl returned %x\n", i
, hres
);
1980 if(testcases
[i
].policy_flags
!= -1)
1981 CHECK_CALLED(ProcessUrlAction
);
1983 heap_free(url_from
);
1994 hurlmon
= GetModuleHandle("urlmon.dll");
1995 pCoInternetCreateSecurityManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateSecurityManager");
1996 pCoInternetCreateZoneManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateZoneManager");
1997 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
1998 pCoInternetGetSecurityUrlEx
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrlEx");
1999 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
2000 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
2001 pCoInternetIsFeatureEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabled");
2002 pCoInternetIsFeatureEnabledForUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabledForUrl");
2003 pCoInternetIsFeatureZoneElevationEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureZoneElevationEnabled");
2005 if (!pCoInternetCreateSecurityManager
|| !pCoInternetCreateZoneManager
||
2006 !pCoInternetGetSecurityUrl
) {
2007 win_skip("Various CoInternet* functions not present in IE 4.0\n");
2011 argc
= winetest_get_mainargs(&argv
);
2012 if(argc
> 2 && !strcmp(argv
[2], "domain_tests")) {
2013 test_zone_domain_mappings();
2017 OleInitialize(NULL
);
2018 register_protocols();
2020 test_InternetGetSecurityUrl();
2022 if(!pCoInternetGetSecurityUrlEx
|| !pCreateUri
)
2023 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
2025 test_InternetGetSecurityUrlEx();
2026 test_InternetGetSecurityUrlEx_Pluggable();
2029 test_SecurityManager();
2030 test_SecurityManagerEx2();
2032 test_zone_domains();
2033 test_CoInternetCreateZoneManager();
2034 test_CreateZoneEnumerator();
2035 test_GetZoneActionPolicy();
2037 test_GetZoneAttributes();
2038 test_SetZoneAttributes();
2039 test_InternetSecurityMarshalling();
2040 test_CoInternetIsFeatureZoneElevationEnabled();
2042 unregister_protocols();