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 SET_CALLED(func) \
70 expect_ ## func = called_ ## func = FALSE; \
73 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input
);
74 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input2
);
75 DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected
);
76 DEFINE_EXPECT(ParseUrl_SECURITY_URL_http
);
77 DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
78 DEFINE_EXPECT(ProcessUrlAction
);
80 static HRESULT (WINAPI
*pCoInternetCreateSecurityManager
)(IServiceProvider
*, IInternetSecurityManager
**, DWORD
);
81 static HRESULT (WINAPI
*pCoInternetCreateZoneManager
)(IServiceProvider
*, IInternetZoneManager
**, DWORD
);
82 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
83 static HRESULT (WINAPI
*pCoInternetGetSecurityUrlEx
)(IUri
*, IUri
**, PSUACTION
, DWORD_PTR
);
84 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
85 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
86 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabled
)(INTERNETFEATURELIST
, DWORD
);
87 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabledForUrl
)(INTERNETFEATURELIST
, DWORD
, LPCWSTR
, IInternetSecurityManager
*);
88 static HRESULT (WINAPI
*pCoInternetIsFeatureZoneElevationEnabled
)(LPCWSTR
, LPCWSTR
, IInternetSecurityManager
*, DWORD
);
90 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
91 '/','b','l','a','n','k','.','h','t','m',0};
92 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
93 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
94 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
95 '%','2','e','j','p','g',0};
96 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
97 '.','w','i','n','e','t','e','s','t',0};
98 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
99 static const WCHAR url7
[] = {'f','t','p',':','/','/','z','o','n','e','3',
100 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
101 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
102 static const WCHAR url9
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
103 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
104 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
106 static const WCHAR url11
[] = {'f','i','l','e',':','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
107 static const WCHAR url12
[] = {'f','i','l','e',':','/','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
108 static const WCHAR url13
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m',0};
109 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};
110 static const WCHAR url15
[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','c','o','m','.','u','k',0};
111 static const WCHAR url16
[] = {'f','i','l','e',':','/','/','/','c',':',0};
112 static const WCHAR url17
[] = {'f','i','l','e',':','/','/','/','c',':','c','\\',0};
113 static const WCHAR url18
[] = {'c',':','\\','t','e','s','t','.','h','t','m',0};
115 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
118 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
119 static const WCHAR security_urlW
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
120 static const WCHAR security_url2W
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g','2',0};
121 static const WCHAR security_expectedW
[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
122 static const WCHAR winetest_to_httpW
[] = {'w','i','n','e','t','e','s','t',':','h',0};
124 static const char *szZoneMapDomainsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains";
125 static const char *szInternetSettingsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
127 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
128 static const BYTE secid2
[] = {'*',':','i','n','d','e','x','.','h','t','m',3,0,0,0};
129 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
130 '.','w','i','n','e','t','e','s','t',3,0,0,0};
131 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
132 static const BYTE secid7
[] = {'f','t','p',':','z','o','n','e','3',
133 '.','w','i','n','e','t','e','s','t',3,0,0,0};
134 static const BYTE secid10
[] =
135 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
136 static const BYTE secid14
[] =
137 {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',3,0,0,0};
138 static const BYTE secid10_2
[] =
139 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
140 static const BYTE secid13
[] = {'h','t','t','p',':','c','o','m','.','u','k',3,0,0,0};
141 static const BYTE secid13_2
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m','.','u','k',3,0,0,0};
143 static const GUID CLSID_TestActiveX
=
144 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
146 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
147 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
148 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
150 static int called_securl_http
;
151 static DWORD ProcessUrlAction_policy
;
153 static struct secmgr_test
{
161 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
162 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
163 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
164 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
165 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
166 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
},
167 {url11
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
168 {url12
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
169 {url16
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
170 {url17
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
171 {url18
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
}
174 static int strcmp_w(const WCHAR
*str1
, const WCHAR
*str2
)
176 DWORD len1
= lstrlenW(str1
);
177 DWORD len2
= lstrlenW(str2
);
179 if(len1
!=len2
) return 1;
180 return memcmp(str1
, str2
, len1
*sizeof(WCHAR
));
183 static inline void heap_free(void *mem
)
185 HeapFree(GetProcessHeap(), 0, mem
);
188 static inline LPWSTR
a2w(LPCSTR str
)
193 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
194 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
195 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
201 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
202 LPWSTR strAW
= a2w(strA
);
203 DWORD ret
= lstrcmpW(strAW
, strB
);
209 /* Based on RegDeleteTreeW from dlls/advapi32/registry.c */
210 static LONG
myRegDeleteTreeA(HKEY hKey
, LPCSTR lpszSubKey
)
213 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
214 DWORD dwMaxLen
, dwSize
;
215 CHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
220 ret
= RegOpenKeyExA(hKey
, lpszSubKey
, 0, KEY_READ
, &hSubKey
);
224 /* Get highest length for keys, values */
225 ret
= RegQueryInfoKeyA(hSubKey
, NULL
, NULL
, NULL
, NULL
,
226 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
227 if (ret
) goto cleanup
;
231 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
232 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(CHAR
))
234 /* Name too big: alloc a buffer for it */
235 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(CHAR
))))
237 ret
= ERROR_NOT_ENOUGH_MEMORY
;
242 /* Recursively delete all the subkeys */
246 if (RegEnumKeyExA(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
247 NULL
, NULL
, NULL
)) break;
249 ret
= myRegDeleteTreeA(hSubKey
, lpszName
);
250 if (ret
) goto cleanup
;
254 ret
= RegDeleteKeyA(hKey
, lpszSubKey
);
259 if (RegEnumValueA(hKey
, 0, lpszName
, &dwSize
,
260 NULL
, NULL
, NULL
, NULL
)) break;
262 ret
= RegDeleteValueA(hKey
, lpszName
);
263 if (ret
) goto cleanup
;
267 /* Free buffer if allocated */
268 if (lpszName
!= szNameBuf
)
271 RegCloseKey(hSubKey
);
275 static HRESULT WINAPI
SecurityManager_QueryInterface(IInternetSecurityManager
* This
,
276 REFIID riid
, void **ppvObject
)
278 ok(0, "unexpected call\n");
282 static ULONG WINAPI
SecurityManager_AddRef(IInternetSecurityManager
* This
)
287 static ULONG WINAPI
SecurityManager_Release(IInternetSecurityManager
* This
)
292 static HRESULT WINAPI
SecurityManager_SetSecuritySite(IInternetSecurityManager
* This
,
293 IInternetSecurityMgrSite
*pSite
)
295 ok(0, "unexpected call\n");
299 static HRESULT WINAPI
SecurityManager_GetSecuritySite(IInternetSecurityManager
* This
,
300 IInternetSecurityMgrSite
**ppSite
)
302 ok(0, "unexpected call\n");
306 static HRESULT WINAPI
SecurityManager_MapUrlToZone(IInternetSecurityManager
* This
,
307 LPCWSTR pwszUrl
, DWORD
*pdwZone
, DWORD dwFlags
)
309 ok(0, "unexpected call\n");
313 static HRESULT WINAPI
SecurityManager_GetSecurityId(IInternetSecurityManager
* This
,
314 LPCWSTR pwszUrl
, BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
316 ok(0, "unexpected call\n");
320 static HRESULT WINAPI
SecurityManager_ProcessUrlAction(IInternetSecurityManager
* This
,
321 LPCWSTR pwszUrl
, DWORD dwAction
, BYTE
*pPolicy
, DWORD cbPolicy
,
322 BYTE
*pContext
, DWORD cbContext
, DWORD dwFlags
, DWORD dwReserved
)
324 CHECK_EXPECT(ProcessUrlAction
);
325 ok(dwAction
== URLACTION_FEATURE_ZONE_ELEVATION
, "dwAction = %x\n", dwAction
);
326 ok(cbPolicy
== sizeof(DWORD
), "cbPolicy = %d\n", cbPolicy
);
327 ok(!pContext
, "pContext != NULL\n");
328 ok(dwFlags
== PUAF_NOUI
, "dwFlags = %x\n", dwFlags
);
329 ok(dwReserved
== 0, "dwReserved = %x\n", dwReserved
);
331 *pPolicy
= ProcessUrlAction_policy
;
332 return ProcessUrlAction_policy
==URLPOLICY_ALLOW
? S_OK
: S_FALSE
;
335 static HRESULT WINAPI
SecurityManager_QueryCustomPolicy(IInternetSecurityManager
* This
,
336 LPCWSTR pwszUrl
, REFGUID guidKey
, BYTE
**ppPolicy
, DWORD
*pcbPolicy
,
337 BYTE
*pContext
, DWORD cbContext
, DWORD dwReserved
)
339 ok(0, "unexpected call\n");
343 static HRESULT WINAPI
SecurityManager_SetZoneMapping(IInternetSecurityManager
* This
,
344 DWORD dwZone
, LPCWSTR lpszPattern
, DWORD dwFlags
)
346 ok(0, "unexpected call\n");
350 static HRESULT WINAPI
SecurityManager_GetZoneMappings(IInternetSecurityManager
* This
,
351 DWORD dwZone
, IEnumString
**ppenumString
, DWORD dwFlags
)
353 ok(0, "unexpected call\n");
357 static const IInternetSecurityManagerVtbl SecurityManagerVtbl
= {
358 SecurityManager_QueryInterface
,
359 SecurityManager_AddRef
,
360 SecurityManager_Release
,
361 SecurityManager_SetSecuritySite
,
362 SecurityManager_GetSecuritySite
,
363 SecurityManager_MapUrlToZone
,
364 SecurityManager_GetSecurityId
,
365 SecurityManager_ProcessUrlAction
,
366 SecurityManager_QueryCustomPolicy
,
367 SecurityManager_SetZoneMapping
,
368 SecurityManager_GetZoneMappings
371 static IInternetSecurityManager security_manager
= { &SecurityManagerVtbl
};
373 static void test_SecurityManager(void)
376 IInternetSecurityManager
*secmgr
= NULL
;
378 DWORD zone
, size
, policy
;
381 if(!pCoInternetCreateSecurityManager
) {
385 trace("Testing security manager...\n");
387 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
388 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
392 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
394 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
396 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
397 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
398 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
399 i
, hres
, secmgr_tests
[i
].zone_hres
);
401 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
402 secmgr_tests
[i
].zone
);
404 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
407 memset(buf
, 0xf0, sizeof(buf
));
408 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
410 ok(hres
== secmgr_tests
[i
].secid_hres
,
411 "[%d] GetSecurityId failed: %08x, expected %08x\n",
412 i
, hres
, secmgr_tests
[i
].secid_hres
);
413 if(secmgr_tests
[i
].secid
) {
414 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
415 i
, size
, secmgr_tests
[i
].secid_size
);
416 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
421 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
422 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
423 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
425 /* win2k3 translates %20 into a space */
427 memset(buf
, 0xf0, sizeof(buf
));
428 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
429 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
430 ok(size
== sizeof(secid10
) ||
431 size
== sizeof(secid10_2
), /* win2k3 */
433 ok(!memcmp(buf
, secid10
, sizeof(secid10
)) ||
434 !memcmp(buf
, secid10_2
, sizeof(secid10_2
)), /* win2k3 */
438 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url13
, &zone
, 0);
439 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
440 ok(zone
== URLZONE_INVALID
|| broken(zone
== URLZONE_INTERNET
), "zone=%d\n", zone
);
443 memset(buf
, 0xf0, sizeof(buf
));
444 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url13
, buf
, &size
, 0);
445 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityId failed: %08x\n", hres
);
448 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url14
, &zone
, 0);
449 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
450 ok(zone
== URLZONE_INTERNET
, "zone=%d\n", zone
);
453 memset(buf
, 0xf0, sizeof(buf
));
454 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url14
, buf
, &size
, 0);
455 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
456 ok(size
== sizeof(secid14
), "size=%d\n", size
);
457 ok(!memcmp(buf
, secid14
, size
), "wrong secid\n");
460 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
461 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
462 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
465 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
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
);
472 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
474 ok(hres
== E_INVALIDARG
,
475 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
477 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
478 sizeof(WCHAR
), NULL
, 0, 0, 0);
479 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
481 IInternetSecurityManager_Release(secmgr
);
484 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
485 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
486 static BOOL
is_ie_hardened(void)
489 DWORD ie_harden
, type
, size
;
492 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
493 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
494 size
= sizeof(DWORD
);
495 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
499 RegCloseKey(zone_map
);
502 return ie_harden
!= 0;
505 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
507 DWORD res
, size
, policy
, reg_policy
;
512 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
513 * The test should be changed to cope with that, if need be.
515 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
516 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
517 ok(res
== ERROR_SUCCESS
, "Could not open zone key\n");
518 if(res
!= ERROR_SUCCESS
)
521 wsprintfA(buf
, "%X", action
);
522 size
= sizeof(DWORD
);
523 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
526 /* Try settings from HKEY_LOCAL_MACHINE. */
527 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
528 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
,
529 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
530 ok(res
== ERROR_SUCCESS
, "Could not open zone key\n");
532 size
= sizeof(DWORD
);
533 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
537 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
539 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
540 sizeof(WCHAR
), NULL
, 0, 0, 0);
541 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
542 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
543 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
546 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
547 sizeof(DWORD
), URLZONEREG_DEFAULT
);
548 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
549 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
550 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
555 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
556 sizeof(DWORD
), URLZONEREG_DEFAULT
);
557 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
558 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
560 if(policy
!= URLPOLICY_QUERY
) {
561 if(winetest_interactive
|| ! is_ie_hardened()) {
562 BOOL expect_parse_call
= !called_securl_http
;
565 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
566 sizeof(WCHAR
), NULL
, 0, 0, 0);
567 if(reg_policy
== URLPOLICY_DISALLOW
)
568 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
570 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
571 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
574 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
576 if(reg_policy
== URLPOLICY_DISALLOW
)
577 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
579 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
580 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
583 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
584 sizeof(DWORD
), NULL
, 0, 0, 0);
585 if(reg_policy
== URLPOLICY_DISALLOW
)
586 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
588 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
589 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
592 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
593 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
594 if(reg_policy
== URLPOLICY_DISALLOW
)
595 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
597 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
598 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
601 if(expect_parse_call
)
602 SET_EXPECT(ParseUrl_SECURITY_URL_http
);
603 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, winetest_to_httpW
, action
, (BYTE
*)&policy
,
604 sizeof(DWORD
), NULL
, 0, 0, 0);
605 if(expect_parse_call
)
606 CHECK_CALLED(ParseUrl_SECURITY_URL_http
);
607 if(reg_policy
== URLPOLICY_DISALLOW
)
608 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
610 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
611 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
613 skip("IE running in Enhanced Security Configuration\n");
618 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
624 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
625 sizeof(DWORD
), URLZONEREG_DEFAULT
);
626 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
627 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
630 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
631 sizeof(WCHAR
), NULL
, 0, 0, 0);
632 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
635 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
636 sizeof(DWORD
), NULL
, 0, 0, 0);
637 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
638 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
641 static void test_activex(IInternetSecurityManager
*secmgr
)
643 DWORD policy
, policy_size
;
644 struct CONFIRMSAFETY cs
;
649 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
650 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
651 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
652 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
654 cs
.clsid
= CLSID_TestActiveX
;
655 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
657 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
658 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
659 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
662 static void test_polices(void)
664 IInternetZoneManager
*zonemgr
= NULL
;
665 IInternetSecurityManager
*secmgr
= NULL
;
668 trace("testing polices...\n");
670 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
671 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
672 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
673 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
675 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
676 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
677 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
678 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
679 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
681 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
682 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
684 test_activex(secmgr
);
686 IInternetSecurityManager_Release(secmgr
);
687 IInternetZoneManager_Release(zonemgr
);
690 /* IE (or at least newer versions of it) seem to cache the keys in ZoneMap
691 * when urlmon.dll is loaded and it doesn't seem to update its cache, unless
692 * SetZoneMapping is used.
694 static void test_zone_domain_cache(void)
698 IInternetSecurityManager
*secmgr
= NULL
;
699 HKEY domains
, domain
;
701 static const WCHAR testing_domain_urlW
[] = {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.',
702 'd','o','m','a','i','n','/',0};
704 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
705 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
706 if(res
!= ERROR_SUCCESS
)
709 res
= RegCreateKeyA(domains
, "testing.domain", &domain
);
710 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
711 if(res
!= ERROR_SUCCESS
) {
712 RegCloseKey(domains
);
716 zone
= URLZONE_CUSTOM
;
717 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
718 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
722 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
723 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
725 zone
= URLZONE_INVALID
;
726 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, testing_domain_urlW
, &zone
, 0);
727 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
728 todo_wine
ok(zone
== URLZONE_INTERNET
, "Got %d, expected URLZONE_INTERNET\n", zone
);
730 /* FIXME: Play nice with ZoneMaps that existed before the test is run. */
731 res
= RegDeleteKeyA(domains
, "testing.domain");
732 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
734 RegCloseKey(domains
);
735 IInternetSecurityManager_Release(secmgr
);
740 const char *subdomain
;
743 } zone_domain_mapping
;
745 /* FIXME: Move these into SetZoneMapping tests when the day comes... */
746 static const zone_domain_mapping zone_domain_mappings
[] = {
747 /* Implicitly means "*.yabadaba.do". */
748 {"yabadaba.do",NULL
,"http",URLZONE_CUSTOM
},
749 /* The '*' doesn't count as a wildcard, since it's not the first component of the subdomain. */
750 {"super.cool","testing.*","ftp",URLZONE_CUSTOM2
},
751 /* The '*' counts since it's the first component of the subdomain. */
752 {"super.cool","*.testing","ftp",URLZONE_CUSTOM2
},
753 /* All known scheme types apply to wildcard schemes. */
754 {"tests.test",NULL
,"*",URLZONE_CUSTOM
},
755 /* Due to a defect with how windows checks the mappings, unknown scheme types
756 * never seem to get mapped properly. */
757 {"tests.test",NULL
,"zip",URLZONE_CUSTOM
},
758 {"www.testing.com",NULL
,"http",URLZONE_CUSTOM
},
759 {"www.testing.com","testing","http",URLZONE_CUSTOM2
},
760 {"org",NULL
,"http",URLZONE_CUSTOM
},
761 {"org","testing","http",URLZONE_CUSTOM2
},
762 {"wine.testing",NULL
,"*",URLZONE_CUSTOM2
}
765 static void register_zone_domains(void)
770 /* Some Windows versions don't seem to have a "Domains" key in their HKLM. */
771 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
772 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
773 if(res
== ERROR_SUCCESS
) {
775 DWORD zone
= URLZONE_CUSTOM
;
777 res
= RegCreateKeyA(domains
, "local.machine", &domain
);
778 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
780 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
781 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
784 RegCloseKey(domains
);
787 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
788 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
790 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
791 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
794 res
= RegCreateKeyA(domains
, test
->domain
, &domain
);
795 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
797 /* Only set the value if there's no subdomain. */
798 if(!test
->subdomain
) {
799 res
= RegSetValueExA(domain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
800 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
804 res
= RegCreateKeyA(domain
, test
->subdomain
, &subdomain
);
805 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
807 res
= RegSetValueExA(subdomain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
808 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
810 RegCloseKey(subdomain
);
816 RegCloseKey(domains
);
819 static void unregister_zone_domains(void)
824 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
825 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
826 if(res
== ERROR_SUCCESS
) {
827 RegDeleteKeyA(domains
, "local.machine");
828 RegCloseKey(domains
);
831 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
832 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
834 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
835 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
837 /* FIXME: Uses the "cludge" approach to remove the test data from the registry!
838 * Although, if domain names are... unique, this shouldn't cause any harm
839 * to keys (if any) that existed before the tests.
841 if(test
->subdomain
) {
844 res
= RegOpenKeyA(domains
, test
->domain
, &domain
);
845 if(res
== ERROR_SUCCESS
) {
846 RegDeleteKeyA(domain
, test
->subdomain
);
850 RegDeleteKeyA(domains
, test
->domain
);
853 RegCloseKey(domains
);
856 static void run_child_process(void)
858 char cmdline
[MAX_PATH
];
861 PROCESS_INFORMATION pi
;
862 STARTUPINFOA si
= { 0 };
865 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
868 winetest_get_mainargs(&argv
);
869 sprintf(cmdline
, "\"%s\" %s domain_tests", argv
[0], argv
[1]);
870 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
871 ok(ret
, "Failed to spawn child process: %u\n", GetLastError());
872 winetest_wait_child_process(pi
.hProcess
);
873 CloseHandle(pi
.hThread
);
874 CloseHandle(pi
.hProcess
);
884 static const zone_mapping_test zone_mapping_tests
[] = {
885 /* Tests for "yabadaba.do" zone mappings. */
886 {"http://yabadaba.do/",URLZONE_CUSTOM
},
887 {"http://google.yabadaba.do/",URLZONE_CUSTOM
},
888 {"zip://yabadaba.do/",URLZONE_INTERNET
},
889 /* Tests for "super.cool" zone mappings. */
890 {"ftp://testing.google.super.cool/",URLZONE_INTERNET
},
891 {"ftp://testing.*.super.cool/",URLZONE_CUSTOM2
},
892 {"ftp://google.testing.super.cool/",URLZONE_CUSTOM2
},
893 /* Tests for "tests.test" zone mappings. */
894 {"http://tests.test/",URLZONE_CUSTOM
},
895 {"http://www.tests.test/",URLZONE_CUSTOM
},
896 {"ftp://tests.test/",URLZONE_CUSTOM
},
897 {"ftp://www.tests.test/",URLZONE_CUSTOM
},
898 {"test://www.tests.test/",URLZONE_INTERNET
},
899 {"test://tests.test/",URLZONE_INTERNET
},
900 {"zip://www.tests.test/",URLZONE_INTERNET
},
901 {"zip://tests.test/",URLZONE_INTERNET
},
902 /* Tests for "www.testing.com" zone mappings. */
903 {"http://google.www.testing.com/",URLZONE_INTERNET
},
904 {"http://www.testing.com/",URLZONE_CUSTOM
,FALSE
,URLZONE_INTERNET
},
905 {"http://testing.www.testing.com/",URLZONE_CUSTOM2
,FALSE
,URLZONE_INTERNET
},
906 /* Tests for "org" zone mappings. */
907 {"http://google.org/",URLZONE_INTERNET
,FALSE
,URLZONE_CUSTOM
},
908 {"http://org/",URLZONE_CUSTOM
},
909 {"http://testing.org/",URLZONE_CUSTOM2
},
910 /* Tests for "wine.testing" mapping */
911 {"*:wine.testing/test",URLZONE_CUSTOM2
},
912 {"http://wine.testing/testing",URLZONE_CUSTOM2
}
915 static void test_zone_domain_mappings(void)
919 IInternetSecurityManager
*secmgr
= NULL
;
921 DWORD zone
= URLZONE_INVALID
;
923 trace("testing zone domain mappings...\n");
925 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
926 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
928 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
929 if(res
== ERROR_SUCCESS
) {
930 static const WCHAR local_machineW
[] = {'h','t','t','p',':','/','/','t','e','s','t','.','l','o','c','a','l',
931 '.','m','a','c','h','i','n','e','/',0};
933 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, local_machineW
, &zone
, 0);
934 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
935 ok(zone
== URLZONE_CUSTOM
, "Expected URLZONE_CUSTOM, but got %d\n", zone
);
937 RegCloseKey(domains
);
940 for(i
= 0; i
< sizeof(zone_mapping_tests
)/sizeof(zone_mapping_tests
[0]); ++i
) {
941 const zone_mapping_test
*test
= zone_mapping_tests
+i
;
942 LPWSTR urlW
= a2w(test
->url
);
943 zone
= URLZONE_INVALID
;
945 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, urlW
, &zone
, 0);
946 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
949 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
950 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
952 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
953 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
958 IInternetSecurityManager_Release(secmgr
);
961 static void test_zone_domains(void)
963 if(is_ie_hardened()) {
964 skip("IE running in Enhanced Security Configuration\n");
966 } else if(!pCreateUri
) {
967 win_skip("Skipping zone domain tests, IE too old\n");
971 trace("testing zone domains...\n");
973 test_zone_domain_cache();
975 register_zone_domains();
977 unregister_zone_domains();
980 static void test_CoInternetCreateZoneManager(void)
982 IInternetZoneManager
*zonemgr
= NULL
;
983 IUnknown
*punk
= NULL
;
986 trace("simple zone manager tests...\n");
988 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
989 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
993 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
994 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
996 IUnknown_Release(punk
);
998 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
999 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
1001 IUnknown_Release(punk
);
1004 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
1005 if (SUCCEEDED(hr
)) {
1006 IUnknown_Release(punk
);
1008 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
1009 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
/* some W2K3 */),
1010 "got 0x%x (expected S_OK)\n", hr
);
1012 IUnknown_Release(punk
);
1014 win_skip("InternetZoneManagerEx2 not supported\n");
1018 win_skip("InternetZoneManagerEx not supported\n");
1020 hr
= IInternetZoneManager_Release(zonemgr
);
1021 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1025 static void test_CreateZoneEnumerator(void)
1027 IInternetZoneManager
*zonemgr
= NULL
;
1034 trace("testing zone enumerator...\n");
1036 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1037 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1042 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
1043 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
1044 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
1047 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
1048 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
1049 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
1053 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
1054 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1055 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1056 hr
, dwEnum
, dwCount
);
1060 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
1061 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1062 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1063 hr
, dwEnum
, dwCount
);
1068 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1069 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1071 if (SUCCEEDED(hr
)) {
1073 dwCount2
=0xdeadbeef;
1074 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
1075 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1076 if (SUCCEEDED(hr
)) {
1077 /* native urlmon has an incrementing counter for dwEnum */
1078 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
1079 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1082 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1083 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1085 /* Destroy the Enumerator twice is detected and handled in native urlmon */
1086 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1087 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
1090 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
1091 hr
= IInternetZoneManager_Release(zonemgr
);
1092 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1095 static void test_GetZoneActionPolicy(void)
1097 IInternetZoneManager
*zonemgr
= NULL
;
1100 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
1102 trace("testing GetZoneActionPolixy...\n");
1104 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1105 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
1109 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1110 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1111 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
1112 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
1113 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
1114 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
1115 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
1116 "unexpected policy=%d\n", *(DWORD
*)buf
);
1118 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
1119 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1120 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1122 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1123 2, URLZONEREG_DEFAULT
);
1124 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1126 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
1127 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1128 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
1129 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
1131 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
1132 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1133 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1135 IInternetZoneManager_Release(zonemgr
);
1138 static void test_GetZoneAt(void)
1140 IInternetZoneManager
*zonemgr
= NULL
;
1147 trace("testing GetZoneAt...\n");
1149 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1150 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1154 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1159 /* this crashes with native urlmon */
1160 IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
1163 dwZone
= 0xdeadbeef;
1164 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
1165 ok(hr
== E_INVALIDARG
,
1166 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1168 for (i
= 0; i
< dwCount
; i
++)
1170 dwZone
= 0xdeadbeef;
1171 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
1172 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
1175 dwZone
= 0xdeadbeef;
1176 /* MSDN (index .. must be .. less than or equal to) is wrong */
1177 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
1178 ok(hr
== E_INVALIDARG
,
1179 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1181 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1182 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1185 hr
= IInternetZoneManager_Release(zonemgr
);
1186 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1189 static void test_GetZoneAttributes(void)
1191 IInternetZoneManager
*zonemgr
= NULL
;
1192 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
1193 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1197 trace("testing GetZoneAttributes...\n");
1199 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1200 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1204 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
1205 for (i
= 0; i
< 5; i
++) {
1206 memset(buffer
, -1, sizeof(buffer
));
1207 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
1208 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
1211 /* IE8 no longer set cbSize */
1212 memset(buffer
, -1, sizeof(buffer
));
1214 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1215 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1216 ok((pZA
->cbSize
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1217 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
1219 memset(buffer
, -1, sizeof(buffer
));
1221 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1222 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1223 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1224 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
1226 memset(buffer
, -1, sizeof(buffer
));
1227 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1228 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1229 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1230 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
1232 /* IE8 up to IE10 don't fail on invalid zones */
1233 memset(buffer
, -1, sizeof(buffer
));
1234 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
1235 ok(hr
== S_OK
|| hr
== E_FAIL
|| hr
== E_POINTER
,
1236 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
1238 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
1239 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1241 hr
= IInternetZoneManager_Release(zonemgr
);
1242 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1245 static void test_SetZoneAttributes(void)
1247 IInternetZoneManager
*zonemgr
= NULL
;
1248 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 16];
1249 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1250 CHAR regpath
[MAX_PATH
];
1255 trace("testing SetZoneAttributes...\n");
1256 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1257 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1261 memset(buffer
, -1, sizeof(buffer
));
1262 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, URLZONE_LOCAL_MACHINE
, pZA
);
1263 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1265 sprintf(regpath
, "%s\\Zones\\%d", szInternetSettingsKey
, URLZONE_CUSTOM
);
1266 res
= RegCreateKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1269 ok(res
== ERROR_SUCCESS
, "got %d (expected ERROR_SUCCESS)\n", res
);
1270 if (res
!= ERROR_SUCCESS
)
1273 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
);
1274 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, NULL
);
1275 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1278 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1280 win_skip("SetZoneAttributes not supported: IE too old\n");
1283 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1285 /* native urlmon ignores cbSize */
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
);
1290 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) - sizeof(DWORD
);
1291 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1292 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) - sizeof(DWORD) (expected S_OK)\n", hr
);
1295 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1296 ok(hr
== S_OK
, "got 0x%x for size 0 (expected S_OK)\n", hr
);
1298 /* The key for the zone must be present, when calling SetZoneAttributes */
1299 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1300 /* E_FAIL is returned from IE6 here, which is reasonable.
1301 All newer IE return S_OK without saving the zone attributes to the registry.
1302 This is a Windows bug, but we have to accept that as standard */
1303 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1304 ok((hr
== S_OK
) || broken(hr
== E_FAIL
), "got 0x%x (expected S_OK)\n", hr
);
1306 /* SetZoneAttributes did not create the directory */
1307 res
= RegOpenKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1308 ok((res
== ERROR_FILE_NOT_FOUND
) && (hkey
== NULL
),
1309 "got %u with %p (expected ERROR_FILE_NOT_FOUND with NULL)\n", res
, hkey
);
1311 if (hkey
) RegCloseKey(hkey
);
1314 /* delete zone settings in the registry */
1315 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1317 hr
= IInternetZoneManager_Release(zonemgr
);
1318 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1322 static void test_InternetSecurityMarshalling(void)
1324 IInternetSecurityManager
*secmgr
= NULL
;
1329 trace("testing marshalling...\n");
1331 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
1332 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1336 hres
= IInternetSecurityManager_QueryInterface(secmgr
, &IID_IUnknown
, (void**)&unk
);
1337 ok(hres
== S_OK
, "QueryInterface returned: %08x\n", hres
);
1339 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
1340 ok(hres
== S_OK
, "CreateStreamOnHGlobal returned: %08x\n", hres
);
1342 hres
= CoMarshalInterface(stream
, &IID_IInternetSecurityManager
, unk
, MSHCTX_INPROC
, NULL
, MSHLFLAGS_NORMAL
);
1343 /* Not supported in W98 */
1344 ok(hres
== S_OK
|| broken(hres
== REGDB_E_IIDNOTREG
),
1345 "CoMarshalInterface returned: %08x\n", hres
);
1347 IStream_Release(stream
);
1348 IUnknown_Release(unk
);
1349 IInternetSecurityManager_Release(secmgr
);
1352 static void test_InternetGetSecurityUrl(void)
1354 const WCHAR url5_out
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
1355 '.','w','i','n','e','t','e','s','t',0};
1356 const WCHAR url7_out
[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
1358 const WCHAR
*in
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1359 const WCHAR
*out_default
[] = {url2
, url3
, url4
, url5_out
, url7_out
, url8
, url5_out
, url10
};
1360 const WCHAR
*out_securl
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1366 trace("testing CoInternetGetSecurityUrl...\n");
1368 for(i
=0; i
<sizeof(in
)/sizeof(WCHAR
*); i
++) {
1369 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_DEFAULT
, 0);
1370 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1372 ok(!strcmp_w(sec
, out_default
[i
]), "(%d) Got %s, expected %s\n",
1373 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_default
[i
]));
1377 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_SECURITY_URL_ONLY
, 0);
1378 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1380 ok(!strcmp_w(sec
, out_securl
[i
]), "(%d) Got %s, expected %s\n",
1381 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_securl
[i
]));
1386 SET_EXPECT(ParseUrl_SECURITY_URL_input2
);
1387 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1388 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1390 hres
= pCoInternetGetSecurityUrl(security_url2W
, &sec
, PSU_DEFAULT
, 0);
1391 ok(hres
== S_OK
, "CoInternetGetSecurityUrl returned 0x%08x, expected S_OK\n", hres
);
1393 CHECK_CALLED(ParseUrl_SECURITY_URL_input2
);
1394 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1395 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1397 ok(!lstrcmpW(security_expectedW
, sec
), "Expected %s but got %s\n",
1398 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(sec
));
1402 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
1403 REFIID riid
, void **ppv
)
1405 ok(0, "unexpected call\n");
1406 return E_NOINTERFACE
;
1409 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
1414 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
1419 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
1420 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
1421 DWORD
*pcchResult
, DWORD dwReserved
)
1423 const WCHAR
*ret
= NULL
;
1425 ok(pwzResult
!= NULL
, "pwzResult == NULL\n");
1426 ok(pcchResult
!= NULL
, "pcchResult == NULL\n");
1427 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
1429 switch(ParseAction
) {
1430 case PARSE_SECURITY_URL
:
1431 if(!strcmp_w(pwzUrl
, security_urlW
)) {
1432 CHECK_EXPECT(ParseUrl_SECURITY_URL_input
);
1433 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1434 ret
= security_expectedW
;
1435 } else if(!strcmp_w(pwzUrl
, security_url2W
)) {
1436 CHECK_EXPECT(ParseUrl_SECURITY_URL_input2
);
1437 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1438 ret
= security_expectedW
;
1439 } else if(!strcmp_w(pwzUrl
, security_expectedW
)) {
1440 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected
);
1441 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1442 ret
= security_expectedW
;
1443 } else if(!strcmp_w(pwzUrl
, winetest_to_httpW
)) {
1444 switch(++called_securl_http
) {
1446 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1449 CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1450 ok(cchResult
== lstrlenW(url9
)+1, "Got %d\n", cchResult
);
1453 todo_wine
CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1457 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl
));
1460 case PARSE_SECURITY_DOMAIN
:
1462 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1464 ok(!strcmp_w(pwzUrl
, security_expectedW
), "Expected %s but got %s\n",
1465 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(pwzUrl
));
1466 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1467 ret
= security_expectedW
;
1470 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction
,
1471 wine_dbgstr_w(pwzUrl
));
1477 *pcchResult
= lstrlenW(ret
)+1;
1478 if(*pcchResult
> cchResult
)
1480 memcpy(pwzResult
, ret
, (*pcchResult
)*sizeof(WCHAR
));
1484 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
1485 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
1486 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
1488 ok(0, "unexpected call\n");
1492 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
1493 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
1495 ok(0, "unexpected call\n");
1499 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
1500 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
1501 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
1503 ok(0, "unexpected call\n");
1507 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
1508 InternetProtocolInfo_QueryInterface
,
1509 InternetProtocolInfo_AddRef
,
1510 InternetProtocolInfo_Release
,
1511 InternetProtocolInfo_ParseUrl
,
1512 InternetProtocolInfo_CombineUrl
,
1513 InternetProtocolInfo_CompareUrl
,
1514 InternetProtocolInfo_QueryInfo
1517 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
1519 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1521 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
1522 *ppv
= &protocol_info
;
1526 ok(0, "unexpected call\n");
1527 return E_NOINTERFACE
;
1530 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1535 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1540 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
1541 REFIID riid
, void **ppv
)
1543 ok(0, "unexpected call\n");
1547 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1549 ok(0, "unexpected call\n");
1553 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1554 ClassFactory_QueryInterface
,
1555 ClassFactory_AddRef
,
1556 ClassFactory_Release
,
1557 ClassFactory_CreateInstance
,
1558 ClassFactory_LockServer
1561 static IClassFactory protocol_cf
= { &ClassFactoryVtbl
};
1563 static void register_protocols(void)
1565 IInternetSession
*session
;
1568 hres
= pCoInternetGetSession(0, &session
, 0);
1569 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1573 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
1574 winetestW
, 0, NULL
, 0);
1575 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1577 IInternetSession_Release(session
);
1580 static void unregister_protocols(void) {
1581 IInternetSession
*session
;
1584 hr
= pCoInternetGetSession(0, &session
, 0);
1585 ok(hr
== S_OK
, "CoInternetGetSession failed: 0x%08x\n", hr
);
1589 hr
= IInternetSession_UnregisterNameSpace(session
, &protocol_cf
, winetestW
);
1590 ok(hr
== S_OK
, "UnregisterNameSpace failed: 0x%08x\n", hr
);
1592 IInternetSession_Release(session
);
1595 static const struct {
1598 const char *security_uri
;
1599 HRESULT security_hres
;
1600 const char *default_uri
;
1601 HRESULT default_hres
;
1603 } sec_url_ex_tests
[] = {
1604 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,"*:index.html",S_OK
,"*:index.htm",S_OK
},
1605 {"file://c:\\Index.htm",Uri_CREATE_FILE_USE_DOS_PATH
,"file:///c:/Index.htm",S_OK
,"file:///c:/Index.htm",S_OK
},
1606 {"file:some%20file%2ejpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1607 {"file:some file.jpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1608 {"http://www.zone3.winetest/",0,"http://www.zone3.winetest/",S_OK
,"http://www.zone3.winetest/",S_OK
},
1609 {"about:blank",0,"about:blank",S_OK
,"about:blank",S_OK
},
1610 {"ftp://zone3.winetest/file.test",0,"ftp://zone3.winetest/file.test",S_OK
,"ftp://zone3.winetest/file.test",S_OK
},
1611 {"test:123abc",0,"test:123abc",S_OK
,"test:123abc",S_OK
},
1612 {"http:google.com/test.file",0,"http:google.com/test.file",S_OK
,"http:google.com/test.file",S_OK
},
1613 {"ftp://test@ftp.winehq.org/",0,"ftp://ftp.winehq.org/",S_OK
,"ftp://ftp.winehq.org/",S_OK
},
1614 {"test://google@ftp.winehq.org/",0,"test://google@ftp.winehq.org/",S_OK
,"test://google@ftp.winehq.org/",S_OK
}
1617 static void test_InternetGetSecurityUrlEx(void)
1621 IUri
*uri
= NULL
, *result
= NULL
;
1623 trace("testing CoInternetGetSecurityUrlEx...\n");
1625 hr
= pCoInternetGetSecurityUrlEx(NULL
, NULL
, PSU_DEFAULT
, 0);
1626 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1628 result
= (void*) 0xdeadbeef;
1629 hr
= pCoInternetGetSecurityUrlEx(NULL
, &result
, PSU_DEFAULT
, 0);
1630 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1631 ok(result
== (void*) 0xdeadbeef, "'result' was %p\n", result
);
1633 for(i
= 0; i
< sizeof(sec_url_ex_tests
)/sizeof(sec_url_ex_tests
[0]); ++i
) {
1634 LPWSTR uriW
= a2w(sec_url_ex_tests
[i
].uri
);
1637 hr
= pCreateUri(uriW
, sec_url_ex_tests
[i
].create_flags
, 0, &uri
);
1638 ok(hr
== S_OK
, "CreateUri returned 0x%08x on test %d\n", hr
, i
);
1642 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1643 if(sec_url_ex_tests
[i
].todo
) {
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
);
1649 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1650 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1651 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1656 hr
= IUri_GetDisplayUri(result
, &received
);
1657 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1659 if(sec_url_ex_tests
[i
].todo
) {
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
);
1665 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1666 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1667 wine_dbgstr_w(received
), i
);
1670 SysFreeString(received
);
1672 if(result
) IUri_Release(result
);
1675 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1676 if(sec_url_ex_tests
[i
].todo
) {
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
);
1682 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1683 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1684 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1689 hr
= IUri_GetDisplayUri(result
, &received
);
1690 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1692 if(sec_url_ex_tests
[i
].todo
) {
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
);
1698 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1699 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1700 wine_dbgstr_w(received
), i
);
1703 SysFreeString(received
);
1705 if(result
) IUri_Release(result
);
1708 if(uri
) IUri_Release(uri
);
1713 static void test_InternetGetSecurityUrlEx_Pluggable(void)
1716 IUri
*uri
= NULL
, *result
;
1718 trace("testing CoInternetGetSecurityUrlEx for pluggable protocols...\n");
1720 hr
= pCreateUri(security_urlW
, 0, 0, &uri
);
1721 ok(hr
== S_OK
, "CreateUri returned 0x%08x\n", hr
);
1723 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1724 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1725 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1727 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1728 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1730 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1731 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1732 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1735 BSTR received
= NULL
;
1737 hr
= IUri_GetAbsoluteUri(result
, &received
);
1738 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1740 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1741 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1743 SysFreeString(received
);
1745 if(result
) IUri_Release(result
);
1749 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1750 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1752 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1753 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1755 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1756 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1759 BSTR received
= NULL
;
1761 hr
= IUri_GetAbsoluteUri(result
, &received
);
1762 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1764 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1765 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1767 SysFreeString(received
);
1769 if(result
) IUri_Release(result
);
1771 if(uri
) IUri_Release(uri
);
1774 static const BYTE secidex2_1
[] = {'z','i','p',':','/','/','t','e','s','t','i','n','g','.','c','o','m','/',3,0,0,0};
1775 static const BYTE secidex2_2
[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1776 static const BYTE secidex2_3
[] = {'*',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1778 static const struct {
1788 } sec_mgr_ex2_tests
[] = {
1789 {"res://mshtml.dll/blank.htm",0,S_OK
,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1790 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,secid2
,sizeof(secid2
),S_OK
},
1791 {"file://c:\\Index.html",0,0,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1792 {"http://www.zone3.winetest/",0,0,URLZONE_INTERNET
,FALSE
,secid5
,sizeof(secid5
),S_OK
},
1793 {"about:blank",0,0,URLZONE_INTERNET
,FALSE
,secid6
,sizeof(secid6
),S_OK
},
1794 {"ftp://zone3.winetest/file.test",0,0,URLZONE_INTERNET
,FALSE
,secid7
,sizeof(secid7
),S_OK
},
1795 {"/file/testing/test.test",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1796 {"zip://testing.com/",0,0,URLZONE_INTERNET
,FALSE
,secidex2_1
,sizeof(secidex2_1
),S_OK
},
1797 {"zip:testing.com",0,0,URLZONE_INTERNET
,FALSE
,secidex2_2
,sizeof(secidex2_2
),S_OK
},
1798 {"http:google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1799 {"http:/google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1800 {"*:/testing",0,S_OK
,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1801 {"*://testing.com",0,S_OK
,URLZONE_INTERNET
,FALSE
,secidex2_3
,sizeof(secidex2_3
),S_OK
}
1804 static void test_SecurityManagerEx2(void)
1809 DWORD buf_size
= sizeof(buf
);
1810 IInternetSecurityManager
*sec_mgr
;
1811 IInternetSecurityManagerEx2
*sec_mgr2
;
1814 static const WCHAR domainW
[] = {'c','o','m','.','u','k',0};
1817 win_skip("Skipping SecurityManagerEx2, IE is too old\n");
1821 trace("Testing SecurityManagerEx2...\n");
1823 hres
= pCoInternetCreateSecurityManager(NULL
, &sec_mgr
, 0);
1824 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1826 hres
= IInternetSecurityManager_QueryInterface(sec_mgr
, &IID_IInternetSecurityManagerEx2
, (void**)&sec_mgr2
);
1827 ok(hres
== S_OK
, "QueryInterface(IID_IInternetSecurityManagerEx2) failed: %08x\n", hres
);
1831 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, NULL
, &zone
, 0, NULL
, NULL
);
1832 ok(hres
== E_INVALIDARG
, "MapUrlToZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1833 ok(zone
== URLZONE_INVALID
, "zone was %d\n", zone
);
1835 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, NULL
, buf
, &buf_size
, 0);
1836 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1837 ok(buf_size
== sizeof(buf
), "buf_size was %d\n", buf_size
);
1839 hres
= pCreateUri(url5
, 0, 0, &uri
);
1840 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1842 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, NULL
, 0, NULL
, NULL
);
1843 ok(hres
== E_INVALIDARG
, "MapToUrlZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1845 buf_size
= sizeof(buf
);
1846 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, NULL
, &buf_size
, 0);
1847 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityIdEx2 failed: %08x\n", hres
);
1848 ok(buf_size
== sizeof(buf
), "bug_size was %d\n", buf_size
);
1850 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, NULL
, 0);
1851 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1855 for(i
= 0; i
< sizeof(sec_mgr_ex2_tests
)/sizeof(sec_mgr_ex2_tests
[0]); ++i
) {
1856 LPWSTR uriW
= a2w(sec_mgr_ex2_tests
[i
].uri
);
1859 zone
= URLZONE_INVALID
;
1861 hres
= pCreateUri(uriW
, sec_mgr_ex2_tests
[i
].create_flags
, 0, &uri
);
1862 ok(hres
== S_OK
, "CreateUri returned %08x for '%s'\n", hres
, sec_mgr_ex2_tests
[i
].uri
);
1864 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, &zone
, 0, NULL
, NULL
);
1865 if(sec_mgr_ex2_tests
[i
].map_todo
) {
1867 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlZoneToEx2 returned %08x, expected %08x for '%s'\n",
1868 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1870 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1871 zone
, sec_mgr_ex2_tests
[i
].uri
);
1873 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlToZoneEx2 returned %08x, expected %08x for '%s'\n",
1874 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1875 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1876 zone
, sec_mgr_ex2_tests
[i
].uri
);
1879 buf_size
= sizeof(buf
);
1880 memset(buf
, 0xf0, buf_size
);
1882 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1883 if(sec_mgr_ex2_tests
[i
].secid_todo
) {
1885 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1886 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1887 if(sec_mgr_ex2_tests
[i
].secid
) {
1889 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1890 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1891 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1892 sec_mgr_ex2_tests
[i
].uri
);
1896 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1897 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1898 if(sec_mgr_ex2_tests
[i
].secid
) {
1899 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1900 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1901 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1902 sec_mgr_ex2_tests
[i
].uri
);
1910 hres
= pCreateUri(url15
, 0, 0, &uri
);
1911 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1913 buf_size
= sizeof(buf
);
1914 memset(buf
, 0xf0, buf_size
);
1916 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, (DWORD_PTR
)domainW
);
1917 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1918 todo_wine
ok(buf_size
== sizeof(secid13
), "buf_size was %d\n", buf_size
);
1919 todo_wine
ok(!memcmp(buf
, secid13
, sizeof(secid13
)), "Got wrong secid\n");
1921 buf_size
= sizeof(buf
);
1922 memset(buf
, 0xf0, buf_size
);
1924 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1925 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1926 ok(buf_size
== sizeof(secid13_2
), "buf_size was %d\n", buf_size
);
1927 ok(!memcmp(buf
, secid13_2
, sizeof(secid13_2
)), "Got wrong secid\n");
1931 IInternetSecurityManagerEx2_Release(sec_mgr2
);
1932 IInternetSecurityManager_Release(sec_mgr
);
1935 static void test_CoInternetIsFeatureZoneElevationEnabled(void)
1938 const char *url_from
;
1944 /* 0 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_FALSE
, URLPOLICY_ALLOW
},
1945 /* 1 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_OK
, URLPOLICY_DISALLOW
},
1946 /* 2 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_FALSE
, URLPOLICY_ALLOW
},
1947 /* 3 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_OK
, URLPOLICY_DISALLOW
},
1948 /* 4 */ { "http://www.winehq.org", "http://www.winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1949 /* 5 */ { "http://www.winehq.org", "http://www.winehq.org/dir", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1950 /* 6 */ { "http://www.winehq.org", "http://www.codeweavers.com", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1951 /* 7 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1952 /* 8 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
|0x100, S_FALSE
, URLPOLICY_ALLOW
},
1953 /* 9 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_REGISTRY
, S_FALSE
, URLPOLICY_ALLOW
},
1956 WCHAR
*url_from
, *url_to
;
1960 if(!pCoInternetIsFeatureZoneElevationEnabled
|| !pCoInternetIsFeatureEnabled
1961 || !pCoInternetIsFeatureEnabledForUrl
) {
1962 win_skip("Skipping CoInternetIsFeatureZoneElevationEnabled tests\n");
1967 hres
= pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, GET_FEATURE_FROM_PROCESS
);
1968 ok(SUCCEEDED(hres
), "CoInternetIsFeatureEnabled returned %x\n", hres
);
1970 trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%x)\n", hres
);
1972 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1973 if(hres
==S_OK
&& testcases
[i
].flags
== GET_FEATURE_FROM_PROCESS
)
1974 testcases
[i
].policy_flags
= URLPOLICY_ALLOW
;
1977 /* IE10 does not seem to use passed ISecurityManager */
1978 SET_EXPECT(ProcessUrlAction
);
1979 pCoInternetIsFeatureZoneElevationEnabled(url1
, url1
, &security_manager
, 0);
1980 i
= called_ProcessUrlAction
;
1981 SET_CALLED(ProcessUrlAction
);
1983 skip("CoInternetIsFeatureZoneElevationEnabled does not use passed ISecurityManager\n");
1987 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1988 url_from
= a2w(testcases
[i
].url_from
);
1989 url_to
= a2w(testcases
[i
].url_to
);
1991 if(testcases
[i
].policy_flags
!= -1) {
1992 ProcessUrlAction_policy
= testcases
[i
].policy_flags
;
1993 SET_EXPECT(ProcessUrlAction
);
1995 hres
= pCoInternetIsFeatureZoneElevationEnabled(url_from
, url_to
,
1996 &security_manager
, testcases
[i
].flags
);
1997 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureZoneElevationEnabled returned %x\n", i
, hres
);
1998 if(testcases
[i
].policy_flags
!= -1)
1999 CHECK_CALLED(ProcessUrlAction
);
2001 if(testcases
[i
].policy_flags
!= -1)
2002 SET_EXPECT(ProcessUrlAction
);
2003 hres
= pCoInternetIsFeatureEnabledForUrl(FEATURE_ZONE_ELEVATION
,
2004 testcases
[i
].flags
, url_to
, &security_manager
);
2005 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureEnabledForUrl returned %x\n", i
, hres
);
2006 if(testcases
[i
].policy_flags
!= -1)
2007 CHECK_CALLED(ProcessUrlAction
);
2009 heap_free(url_from
);
2020 hurlmon
= GetModuleHandleA("urlmon.dll");
2021 pCoInternetCreateSecurityManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateSecurityManager");
2022 pCoInternetCreateZoneManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateZoneManager");
2023 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
2024 pCoInternetGetSecurityUrlEx
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrlEx");
2025 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
2026 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
2027 pCoInternetIsFeatureEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabled");
2028 pCoInternetIsFeatureEnabledForUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabledForUrl");
2029 pCoInternetIsFeatureZoneElevationEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureZoneElevationEnabled");
2031 if (!pCoInternetCreateSecurityManager
|| !pCoInternetCreateZoneManager
||
2032 !pCoInternetGetSecurityUrl
) {
2033 win_skip("Various CoInternet* functions not present in IE 4.0\n");
2037 argc
= winetest_get_mainargs(&argv
);
2038 if(argc
> 2 && !strcmp(argv
[2], "domain_tests")) {
2039 test_zone_domain_mappings();
2043 OleInitialize(NULL
);
2044 register_protocols();
2046 test_InternetGetSecurityUrl();
2048 if(!pCoInternetGetSecurityUrlEx
|| !pCreateUri
)
2049 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
2051 test_InternetGetSecurityUrlEx();
2052 test_InternetGetSecurityUrlEx_Pluggable();
2055 test_SecurityManager();
2056 test_SecurityManagerEx2();
2058 test_zone_domains();
2059 test_CoInternetCreateZoneManager();
2060 test_CreateZoneEnumerator();
2061 test_GetZoneActionPolicy();
2063 test_GetZoneAttributes();
2064 test_SetZoneAttributes();
2065 test_InternetSecurityMarshalling();
2066 test_CoInternetIsFeatureZoneElevationEnabled();
2068 unregister_protocols();