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
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
27 #define NONAMELESSUNION
29 /* needed for IInternetZoneManagerEx2 */
31 #define _WIN32_IE 0x0700
33 #include <wine/test.h>
39 //#include "winbase.h"
45 //#include "initguid.h"
47 #define URLZONE_CUSTOM URLZONE_USER_MIN+1
48 #define URLZONE_CUSTOM2 URLZONE_CUSTOM+1
50 #define DEFINE_EXPECT(func) \
51 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
53 #define SET_EXPECT(func) \
54 expect_ ## func = TRUE
56 #define CHECK_EXPECT(func) \
58 ok(expect_ ##func, "unexpected call " #func "\n"); \
59 expect_ ## func = FALSE; \
60 called_ ## func = TRUE; \
63 #define CHECK_EXPECT2(func) \
65 ok(expect_ ##func, "unexpected call " #func "\n"); \
66 called_ ## func = TRUE; \
69 #define CHECK_CALLED(func) \
71 ok(called_ ## func, "expected " #func "\n"); \
72 expect_ ## func = called_ ## func = FALSE; \
75 #define SET_CALLED(func) \
77 expect_ ## func = called_ ## func = FALSE; \
80 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input
);
81 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input2
);
82 DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected
);
83 DEFINE_EXPECT(ParseUrl_SECURITY_URL_http
);
84 DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
85 DEFINE_EXPECT(ProcessUrlAction
);
87 static HRESULT (WINAPI
*pCoInternetCreateSecurityManager
)(IServiceProvider
*, IInternetSecurityManager
**, DWORD
);
88 static HRESULT (WINAPI
*pCoInternetCreateZoneManager
)(IServiceProvider
*, IInternetZoneManager
**, DWORD
);
89 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
90 static HRESULT (WINAPI
*pCoInternetGetSecurityUrlEx
)(IUri
*, IUri
**, PSUACTION
, DWORD_PTR
);
91 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
92 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
93 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabled
)(INTERNETFEATURELIST
, DWORD
);
94 static HRESULT (WINAPI
*pCoInternetIsFeatureEnabledForUrl
)(INTERNETFEATURELIST
, DWORD
, LPCWSTR
, IInternetSecurityManager
*);
95 static HRESULT (WINAPI
*pCoInternetIsFeatureZoneElevationEnabled
)(LPCWSTR
, LPCWSTR
, IInternetSecurityManager
*, DWORD
);
97 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
98 '/','b','l','a','n','k','.','h','t','m',0};
99 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
100 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
101 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
102 '%','2','e','j','p','g',0};
103 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
104 '.','w','i','n','e','t','e','s','t',0};
105 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
106 static const WCHAR url7
[] = {'f','t','p',':','/','/','z','o','n','e','3',
107 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
108 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
109 static const WCHAR url9
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
110 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
111 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
113 static const WCHAR url11
[] = {'f','i','l','e',':','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
114 static const WCHAR url12
[] = {'f','i','l','e',':','/','/','/','c',':','/','I','n','d','e','x','.','h','t','m',0};
115 static const WCHAR url13
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m',0};
116 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};
117 static const WCHAR url15
[] = {'h','t','t','p',':','/','/','g','o','o','g','l','e','.','c','o','m','.','u','k',0};
118 static const WCHAR url16
[] = {'f','i','l','e',':','/','/','/','c',':',0};
119 static const WCHAR url17
[] = {'f','i','l','e',':','/','/','/','c',':','c','\\',0};
120 static const WCHAR url18
[] = {'c',':','\\','t','e','s','t','.','h','t','m',0};
122 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
123 static const WCHAR security_urlW
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
124 static const WCHAR security_url2W
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g','2',0};
125 static const WCHAR security_expectedW
[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
126 static const WCHAR winetest_to_httpW
[] = {'w','i','n','e','t','e','s','t',':','h',0};
128 static const char *szZoneMapDomainsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains";
129 static const char *szInternetSettingsKey
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
131 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
132 static const BYTE secid2
[] = {'*',':','i','n','d','e','x','.','h','t','m',3,0,0,0};
133 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
134 '.','w','i','n','e','t','e','s','t',3,0,0,0};
135 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
136 static const BYTE secid7
[] = {'f','t','p',':','z','o','n','e','3',
137 '.','w','i','n','e','t','e','s','t',3,0,0,0};
138 static const BYTE secid10
[] =
139 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
140 static const BYTE secid14
[] =
141 {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m','/','t','e','s','t','i','n','g',3,0,0,0};
142 static const BYTE secid10_2
[] =
143 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
144 static const BYTE secid13
[] = {'h','t','t','p',':','c','o','m','.','u','k',3,0,0,0};
145 static const BYTE secid13_2
[] = {'h','t','t','p',':','g','o','o','g','l','e','.','c','o','m','.','u','k',3,0,0,0};
147 static const GUID CLSID_TestActiveX
=
148 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
150 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
151 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
152 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
154 static int called_securl_http
;
155 static DWORD ProcessUrlAction_policy
;
157 static struct secmgr_test
{
165 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
166 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
167 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
168 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
169 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
170 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
},
171 {url11
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
172 {url12
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
173 {url16
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
174 {url17
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
175 {url18
,0, S_OK
, sizeof(secid1
), secid1
, S_OK
}
178 static int strcmp_w(const WCHAR
*str1
, const WCHAR
*str2
)
180 DWORD len1
= lstrlenW(str1
);
181 DWORD len2
= lstrlenW(str2
);
183 if(len1
!=len2
) return 1;
184 return memcmp(str1
, str2
, len1
*sizeof(WCHAR
));
187 static inline void heap_free(void *mem
)
189 HeapFree(GetProcessHeap(), 0, mem
);
192 static inline LPWSTR
a2w(LPCSTR str
)
197 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
198 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
199 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
205 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
206 LPWSTR strAW
= a2w(strA
);
207 DWORD ret
= lstrcmpW(strAW
, strB
);
213 /* Based on RegDeleteTreeW from dlls/advapi32/registry.c */
214 static LONG
myRegDeleteTreeA(HKEY hKey
, LPCSTR lpszSubKey
)
217 DWORD dwMaxSubkeyLen
, dwMaxValueLen
;
218 DWORD dwMaxLen
, dwSize
;
219 CHAR szNameBuf
[MAX_PATH
], *lpszName
= szNameBuf
;
224 ret
= RegOpenKeyExA(hKey
, lpszSubKey
, 0, KEY_READ
, &hSubKey
);
228 /* Get highest length for keys, values */
229 ret
= RegQueryInfoKeyA(hSubKey
, NULL
, NULL
, NULL
, NULL
,
230 &dwMaxSubkeyLen
, NULL
, NULL
, &dwMaxValueLen
, NULL
, NULL
, NULL
);
231 if (ret
) goto cleanup
;
235 dwMaxLen
= max(dwMaxSubkeyLen
, dwMaxValueLen
);
236 if (dwMaxLen
> sizeof(szNameBuf
)/sizeof(CHAR
))
238 /* Name too big: alloc a buffer for it */
239 if (!(lpszName
= HeapAlloc( GetProcessHeap(), 0, dwMaxLen
*sizeof(CHAR
))))
241 ret
= ERROR_NOT_ENOUGH_MEMORY
;
246 /* Recursively delete all the subkeys */
250 if (RegEnumKeyExA(hSubKey
, 0, lpszName
, &dwSize
, NULL
,
251 NULL
, NULL
, NULL
)) break;
253 ret
= myRegDeleteTreeA(hSubKey
, lpszName
);
254 if (ret
) goto cleanup
;
258 ret
= RegDeleteKeyA(hKey
, lpszSubKey
);
263 if (RegEnumValueA(hKey
, 0, lpszName
, &dwSize
,
264 NULL
, NULL
, NULL
, NULL
)) break;
266 ret
= RegDeleteValueA(hKey
, lpszName
);
267 if (ret
) goto cleanup
;
271 /* Free buffer if allocated */
272 if (lpszName
!= szNameBuf
)
275 RegCloseKey(hSubKey
);
279 static HRESULT WINAPI
SecurityManager_QueryInterface(IInternetSecurityManager
* This
,
280 REFIID riid
, void **ppvObject
)
282 ok(0, "unexpected call\n");
286 static ULONG WINAPI
SecurityManager_AddRef(IInternetSecurityManager
* This
)
291 static ULONG WINAPI
SecurityManager_Release(IInternetSecurityManager
* This
)
296 static HRESULT WINAPI
SecurityManager_SetSecuritySite(IInternetSecurityManager
* This
,
297 IInternetSecurityMgrSite
*pSite
)
299 ok(0, "unexpected call\n");
303 static HRESULT WINAPI
SecurityManager_GetSecuritySite(IInternetSecurityManager
* This
,
304 IInternetSecurityMgrSite
**ppSite
)
306 ok(0, "unexpected call\n");
310 static HRESULT WINAPI
SecurityManager_MapUrlToZone(IInternetSecurityManager
* This
,
311 LPCWSTR pwszUrl
, DWORD
*pdwZone
, DWORD dwFlags
)
313 ok(0, "unexpected call\n");
317 static HRESULT WINAPI
SecurityManager_GetSecurityId(IInternetSecurityManager
* This
,
318 LPCWSTR pwszUrl
, BYTE
*pbSecurityId
, DWORD
*pcbSecurityId
, DWORD_PTR dwReserved
)
320 ok(0, "unexpected call\n");
324 static HRESULT WINAPI
SecurityManager_ProcessUrlAction(IInternetSecurityManager
* This
,
325 LPCWSTR pwszUrl
, DWORD dwAction
, BYTE
*pPolicy
, DWORD cbPolicy
,
326 BYTE
*pContext
, DWORD cbContext
, DWORD dwFlags
, DWORD dwReserved
)
328 CHECK_EXPECT(ProcessUrlAction
);
329 ok(dwAction
== URLACTION_FEATURE_ZONE_ELEVATION
, "dwAction = %x\n", dwAction
);
330 ok(cbPolicy
== sizeof(DWORD
), "cbPolicy = %d\n", cbPolicy
);
331 ok(!pContext
, "pContext != NULL\n");
332 ok(dwFlags
== PUAF_NOUI
, "dwFlags = %x\n", dwFlags
);
333 ok(dwReserved
== 0, "dwReserved = %x\n", dwReserved
);
335 *pPolicy
= ProcessUrlAction_policy
;
336 return ProcessUrlAction_policy
==URLPOLICY_ALLOW
? S_OK
: S_FALSE
;
339 static HRESULT WINAPI
SecurityManager_QueryCustomPolicy(IInternetSecurityManager
* This
,
340 LPCWSTR pwszUrl
, REFGUID guidKey
, BYTE
**ppPolicy
, DWORD
*pcbPolicy
,
341 BYTE
*pContext
, DWORD cbContext
, DWORD dwReserved
)
343 ok(0, "unexpected call\n");
347 static HRESULT WINAPI
SecurityManager_SetZoneMapping(IInternetSecurityManager
* This
,
348 DWORD dwZone
, LPCWSTR lpszPattern
, DWORD dwFlags
)
350 ok(0, "unexpected call\n");
354 static HRESULT WINAPI
SecurityManager_GetZoneMappings(IInternetSecurityManager
* This
,
355 DWORD dwZone
, IEnumString
**ppenumString
, DWORD dwFlags
)
357 ok(0, "unexpected call\n");
361 static const IInternetSecurityManagerVtbl SecurityManagerVtbl
= {
362 SecurityManager_QueryInterface
,
363 SecurityManager_AddRef
,
364 SecurityManager_Release
,
365 SecurityManager_SetSecuritySite
,
366 SecurityManager_GetSecuritySite
,
367 SecurityManager_MapUrlToZone
,
368 SecurityManager_GetSecurityId
,
369 SecurityManager_ProcessUrlAction
,
370 SecurityManager_QueryCustomPolicy
,
371 SecurityManager_SetZoneMapping
,
372 SecurityManager_GetZoneMappings
375 static IInternetSecurityManager security_manager
= { &SecurityManagerVtbl
};
377 static void test_SecurityManager(void)
380 IInternetSecurityManager
*secmgr
= NULL
;
382 DWORD zone
, size
, policy
;
385 if(!pCoInternetCreateSecurityManager
) {
389 trace("Testing security manager...\n");
391 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
392 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
396 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
398 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
400 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
401 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
402 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
403 i
, hres
, secmgr_tests
[i
].zone_hres
);
405 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
406 secmgr_tests
[i
].zone
);
408 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
411 memset(buf
, 0xf0, sizeof(buf
));
412 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
414 ok(hres
== secmgr_tests
[i
].secid_hres
,
415 "[%d] GetSecurityId failed: %08x, expected %08x\n",
416 i
, hres
, secmgr_tests
[i
].secid_hres
);
417 if(secmgr_tests
[i
].secid
) {
418 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
419 i
, size
, secmgr_tests
[i
].secid_size
);
420 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
425 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
426 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
427 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
429 /* win2k3 translates %20 into a space */
431 memset(buf
, 0xf0, sizeof(buf
));
432 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
433 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
434 ok(size
== sizeof(secid10
) ||
435 size
== sizeof(secid10_2
), /* win2k3 */
437 ok(!memcmp(buf
, secid10
, sizeof(secid10
)) ||
438 !memcmp(buf
, secid10_2
, sizeof(secid10_2
)), /* win2k3 */
442 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url13
, &zone
, 0);
443 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
444 ok(zone
== URLZONE_INVALID
|| broken(zone
== URLZONE_INTERNET
), "zone=%d\n", zone
);
447 memset(buf
, 0xf0, sizeof(buf
));
448 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url13
, buf
, &size
, 0);
449 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityId failed: %08x\n", hres
);
452 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url14
, &zone
, 0);
453 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
454 ok(zone
== URLZONE_INTERNET
, "zone=%d\n", zone
);
457 memset(buf
, 0xf0, sizeof(buf
));
458 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url14
, buf
, &size
, 0);
459 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
460 ok(size
== sizeof(secid14
), "size=%d\n", size
);
461 ok(!memcmp(buf
, secid14
, size
), "wrong secid\n");
464 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
465 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
466 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
469 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
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
);
476 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
478 ok(hres
== E_INVALIDARG
,
479 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
481 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
482 sizeof(WCHAR
), NULL
, 0, 0, 0);
483 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
485 IInternetSecurityManager_Release(secmgr
);
488 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
489 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
490 static BOOL
is_ie_hardened(void)
493 DWORD ie_harden
, type
, size
;
496 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
497 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
498 size
= sizeof(DWORD
);
499 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
503 RegCloseKey(zone_map
);
506 return ie_harden
!= 0;
509 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
511 DWORD res
, size
, policy
, reg_policy
;
516 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
517 * The test should be changed to cope with that, if need be.
519 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
520 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
521 ok(res
== ERROR_SUCCESS
, "Could not open zone key\n");
522 if(res
!= ERROR_SUCCESS
)
525 wsprintfA(buf
, "%X", action
);
526 size
= sizeof(DWORD
);
527 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
530 /* Try settings from HKEY_LOCAL_MACHINE. */
531 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
532 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
,
533 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
534 ok(res
== ERROR_SUCCESS
, "Could not open zone key\n");
536 size
= sizeof(DWORD
);
537 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
541 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
543 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
544 sizeof(WCHAR
), NULL
, 0, 0, 0);
545 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
546 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
547 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
550 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
551 sizeof(DWORD
), URLZONEREG_DEFAULT
);
552 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
553 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
554 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
559 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
560 sizeof(DWORD
), URLZONEREG_DEFAULT
);
561 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
562 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
564 if(policy
!= URLPOLICY_QUERY
) {
565 if(winetest_interactive
|| ! is_ie_hardened()) {
566 BOOL expect_parse_call
= !called_securl_http
;
569 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
570 sizeof(WCHAR
), NULL
, 0, 0, 0);
571 if(reg_policy
== URLPOLICY_DISALLOW
)
572 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
574 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
575 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
578 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
580 if(reg_policy
== URLPOLICY_DISALLOW
)
581 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
583 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
584 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
587 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
588 sizeof(DWORD
), NULL
, 0, 0, 0);
589 if(reg_policy
== URLPOLICY_DISALLOW
)
590 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
592 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
593 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
596 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
597 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
598 if(reg_policy
== URLPOLICY_DISALLOW
)
599 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
601 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
602 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
605 if(expect_parse_call
)
606 SET_EXPECT(ParseUrl_SECURITY_URL_http
);
607 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, winetest_to_httpW
, action
, (BYTE
*)&policy
,
608 sizeof(DWORD
), NULL
, 0, 0, 0);
609 if(expect_parse_call
)
610 CHECK_CALLED(ParseUrl_SECURITY_URL_http
);
611 if(reg_policy
== URLPOLICY_DISALLOW
)
612 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
614 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
615 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
617 skip("IE running in Enhanced Security Configuration\n");
622 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
628 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
629 sizeof(DWORD
), URLZONEREG_DEFAULT
);
630 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
631 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
634 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
635 sizeof(WCHAR
), NULL
, 0, 0, 0);
636 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
639 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
640 sizeof(DWORD
), NULL
, 0, 0, 0);
641 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
642 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
645 static void test_activex(IInternetSecurityManager
*secmgr
)
647 DWORD policy
, policy_size
;
648 struct CONFIRMSAFETY cs
;
653 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
654 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
655 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
656 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
658 cs
.clsid
= CLSID_TestActiveX
;
659 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
661 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
662 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
663 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
666 static void test_polices(void)
668 IInternetZoneManager
*zonemgr
= NULL
;
669 IInternetSecurityManager
*secmgr
= NULL
;
672 trace("testing polices...\n");
674 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
675 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
676 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
677 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
679 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
680 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
681 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
682 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
683 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
685 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
686 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
688 test_activex(secmgr
);
690 IInternetSecurityManager_Release(secmgr
);
691 IInternetZoneManager_Release(zonemgr
);
694 /* IE (or at least newer versions of it) seem to cache the keys in ZoneMap
695 * when urlmon.dll is loaded and it doesn't seem to update its cache, unless
696 * SetZoneMapping is used.
698 static void test_zone_domain_cache(void)
702 IInternetSecurityManager
*secmgr
= NULL
;
703 HKEY domains
, domain
;
705 static const WCHAR testing_domain_urlW
[] = {'h','t','t','p',':','/','/','t','e','s','t','i','n','g','.',
706 'd','o','m','a','i','n','/',0};
708 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
709 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
710 if(res
!= ERROR_SUCCESS
)
713 res
= RegCreateKeyA(domains
, "testing.domain", &domain
);
714 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
715 if(res
!= ERROR_SUCCESS
) {
716 RegCloseKey(domains
);
720 zone
= URLZONE_CUSTOM
;
721 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
722 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
726 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
727 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
729 zone
= URLZONE_INVALID
;
730 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, testing_domain_urlW
, &zone
, 0);
731 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
732 todo_wine
ok(zone
== URLZONE_INTERNET
, "Got %d, expected URLZONE_INTERNET\n", zone
);
734 /* FIXME: Play nice with ZoneMaps that existed before the test is run. */
735 res
= RegDeleteKeyA(domains
, "testing.domain");
736 ok(res
== ERROR_SUCCESS
, "RegDeleteKey failed: %d\n", res
);
738 RegCloseKey(domains
);
739 IInternetSecurityManager_Release(secmgr
);
744 const char *subdomain
;
747 } zone_domain_mapping
;
749 /* FIXME: Move these into SetZoneMapping tests when the day comes... */
750 static const zone_domain_mapping zone_domain_mappings
[] = {
751 /* Implicitly means "*.yabadaba.do". */
752 {"yabadaba.do",NULL
,"http",URLZONE_CUSTOM
},
753 /* The '*' doesn't count as a wildcard, since it's not the first component of the subdomain. */
754 {"super.cool","testing.*","ftp",URLZONE_CUSTOM2
},
755 /* The '*' counts since it's the first component of the subdomain. */
756 {"super.cool","*.testing","ftp",URLZONE_CUSTOM2
},
757 /* All known scheme types apply to wildcard schemes. */
758 {"tests.test",NULL
,"*",URLZONE_CUSTOM
},
759 /* Due to a defect with how windows checks the mappings, unknown scheme types
760 * never seem to get mapped properly. */
761 {"tests.test",NULL
,"zip",URLZONE_CUSTOM
},
762 {"www.testing.com",NULL
,"http",URLZONE_CUSTOM
},
763 {"www.testing.com","testing","http",URLZONE_CUSTOM2
},
764 {"org",NULL
,"http",URLZONE_CUSTOM
},
765 {"org","testing","http",URLZONE_CUSTOM2
},
766 {"wine.testing",NULL
,"*",URLZONE_CUSTOM2
}
769 static BOOL
register_zone_domains(void)
774 /* Some Windows versions don't seem to have a "Domains" key in their HKLM. */
775 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
776 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
777 if(res
== ERROR_SUCCESS
) {
779 DWORD zone
= URLZONE_CUSTOM
;
781 res
= RegCreateKeyA(domains
, "local.machine", &domain
);
782 if (res
== ERROR_ACCESS_DENIED
)
784 skip("need admin rights\n");
785 RegCloseKey(domains
);
788 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed: %d\n", res
);
790 res
= RegSetValueExA(domain
, "http", 0, REG_DWORD
, (BYTE
*)&zone
, sizeof(DWORD
));
791 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed: %d\n", res
);
794 RegCloseKey(domains
);
797 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
798 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
800 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
801 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
804 res
= RegCreateKeyA(domains
, test
->domain
, &domain
);
805 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
807 /* Only set the value if there's no subdomain. */
808 if(!test
->subdomain
) {
809 res
= RegSetValueExA(domain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
810 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
814 res
= RegCreateKeyA(domain
, test
->subdomain
, &subdomain
);
815 ok(res
== ERROR_SUCCESS
, "RegCreateKey failed with %d on test %d\n", res
, i
);
817 res
= RegSetValueExA(subdomain
, test
->scheme
, 0, REG_DWORD
, (BYTE
*)&test
->zone
, sizeof(DWORD
));
818 ok(res
== ERROR_SUCCESS
, "RegSetValueEx failed with %d on test %d\n", res
, i
);
820 RegCloseKey(subdomain
);
826 RegCloseKey(domains
);
830 static void unregister_zone_domains(void)
835 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
836 ok(res
== ERROR_SUCCESS
|| broken(res
== ERROR_FILE_NOT_FOUND
), "RegOpenKey failed: %d\n", res
);
837 if(res
== ERROR_SUCCESS
) {
838 RegDeleteKeyA(domains
, "local.machine");
839 RegCloseKey(domains
);
842 res
= RegOpenKeyA(HKEY_CURRENT_USER
, szZoneMapDomainsKey
, &domains
);
843 ok(res
== ERROR_SUCCESS
, "RegOpenKey failed: %d\n", res
);
845 for(i
= 0; i
< sizeof(zone_domain_mappings
)/sizeof(zone_domain_mappings
[0]); ++i
) {
846 const zone_domain_mapping
*test
= zone_domain_mappings
+i
;
848 /* FIXME: Uses the "cludge" approach to remove the test data from the registry!
849 * Although, if domain names are... unique, this shouldn't cause any harm
850 * to keys (if any) that existed before the tests.
852 if(test
->subdomain
) {
855 res
= RegOpenKeyA(domains
, test
->domain
, &domain
);
856 if(res
== ERROR_SUCCESS
) {
857 RegDeleteKeyA(domain
, test
->subdomain
);
861 RegDeleteKeyA(domains
, test
->domain
);
864 RegCloseKey(domains
);
867 static void run_child_process(void)
869 char cmdline
[MAX_PATH
];
872 PROCESS_INFORMATION pi
;
873 STARTUPINFOA si
= { 0 };
876 GetModuleFileNameA(NULL
, path
, MAX_PATH
);
879 winetest_get_mainargs(&argv
);
880 sprintf(cmdline
, "\"%s\" %s domain_tests", argv
[0], argv
[1]);
881 ret
= CreateProcessA(argv
[0], cmdline
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
882 ok(ret
, "Failed to spawn child process: %u\n", GetLastError());
883 winetest_wait_child_process(pi
.hProcess
);
884 CloseHandle(pi
.hThread
);
885 CloseHandle(pi
.hProcess
);
895 static const zone_mapping_test zone_mapping_tests
[] = {
896 /* Tests for "yabadaba.do" zone mappings. */
897 {"http://yabadaba.do/",URLZONE_CUSTOM
},
898 {"http://google.yabadaba.do/",URLZONE_CUSTOM
},
899 {"zip://yabadaba.do/",URLZONE_INTERNET
},
900 /* Tests for "super.cool" zone mappings. */
901 {"ftp://testing.google.super.cool/",URLZONE_INTERNET
},
902 {"ftp://testing.*.super.cool/",URLZONE_CUSTOM2
},
903 {"ftp://google.testing.super.cool/",URLZONE_CUSTOM2
},
904 /* Tests for "tests.test" zone mappings. */
905 {"http://tests.test/",URLZONE_CUSTOM
},
906 {"http://www.tests.test/",URLZONE_CUSTOM
},
907 {"ftp://tests.test/",URLZONE_CUSTOM
},
908 {"ftp://www.tests.test/",URLZONE_CUSTOM
},
909 {"test://www.tests.test/",URLZONE_INTERNET
},
910 {"test://tests.test/",URLZONE_INTERNET
},
911 {"zip://www.tests.test/",URLZONE_INTERNET
},
912 {"zip://tests.test/",URLZONE_INTERNET
},
913 /* Tests for "www.testing.com" zone mappings. */
914 {"http://google.www.testing.com/",URLZONE_INTERNET
},
915 {"http://www.testing.com/",URLZONE_CUSTOM
,FALSE
,URLZONE_INTERNET
},
916 {"http://testing.www.testing.com/",URLZONE_CUSTOM2
,FALSE
,URLZONE_INTERNET
},
917 /* Tests for "org" zone mappings. */
918 {"http://google.org/",URLZONE_INTERNET
,FALSE
,URLZONE_CUSTOM
},
919 {"http://org/",URLZONE_CUSTOM
},
920 {"http://testing.org/",URLZONE_CUSTOM2
},
921 /* Tests for "wine.testing" mapping */
922 {"*:wine.testing/test",URLZONE_CUSTOM2
},
923 {"http://wine.testing/testing",URLZONE_CUSTOM2
}
926 static void test_zone_domain_mappings(void)
930 IInternetSecurityManager
*secmgr
= NULL
;
932 DWORD zone
= URLZONE_INVALID
;
934 trace("testing zone domain mappings...\n");
936 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
937 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
939 res
= RegOpenKeyA(HKEY_LOCAL_MACHINE
, szZoneMapDomainsKey
, &domains
);
940 if(res
== ERROR_SUCCESS
) {
941 static const WCHAR local_machineW
[] = {'h','t','t','p',':','/','/','t','e','s','t','.','l','o','c','a','l',
942 '.','m','a','c','h','i','n','e','/',0};
944 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, local_machineW
, &zone
, 0);
945 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
946 ok(zone
== URLZONE_CUSTOM
, "Expected URLZONE_CUSTOM, but got %d\n", zone
);
948 RegCloseKey(domains
);
951 for(i
= 0; i
< sizeof(zone_mapping_tests
)/sizeof(zone_mapping_tests
[0]); ++i
) {
952 const zone_mapping_test
*test
= zone_mapping_tests
+i
;
953 LPWSTR urlW
= a2w(test
->url
);
954 zone
= URLZONE_INVALID
;
956 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, urlW
, &zone
, 0);
957 ok(hres
== S_OK
, "MapUrlToZone failed: %08x\n", hres
);
958 todo_wine_if (test
->todo
)
959 ok(zone
== test
->zone
|| broken(test
->broken_zone
== zone
),
960 "Expected %d, but got %d on test %d\n", test
->zone
, zone
, i
);
965 IInternetSecurityManager_Release(secmgr
);
968 static void test_zone_domains(void)
970 if(is_ie_hardened()) {
971 skip("IE running in Enhanced Security Configuration\n");
973 } else if(!pCreateUri
) {
974 win_skip("Skipping zone domain tests, IE too old\n");
978 trace("testing zone domains...\n");
980 test_zone_domain_cache();
982 if (!register_zone_domains()) return;
984 unregister_zone_domains();
987 static void test_CoInternetCreateZoneManager(void)
989 IInternetZoneManager
*zonemgr
= NULL
;
990 IUnknown
*punk
= NULL
;
993 trace("simple zone manager tests...\n");
995 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
996 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1000 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
1001 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
1003 IUnknown_Release(punk
);
1005 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
1006 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
1008 IUnknown_Release(punk
);
1011 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
1012 if (SUCCEEDED(hr
)) {
1013 IUnknown_Release(punk
);
1015 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
1016 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
/* some W2K3 */),
1017 "got 0x%x (expected S_OK)\n", hr
);
1019 IUnknown_Release(punk
);
1021 win_skip("InternetZoneManagerEx2 not supported\n");
1025 win_skip("InternetZoneManagerEx not supported\n");
1027 hr
= IInternetZoneManager_Release(zonemgr
);
1028 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1032 static void test_CreateZoneEnumerator(void)
1034 IInternetZoneManager
*zonemgr
= NULL
;
1041 trace("testing zone enumerator...\n");
1043 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1044 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1049 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
1050 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
1051 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
1054 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
1055 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
1056 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
1060 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
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
);
1067 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
1068 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
1069 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
1070 hr
, dwEnum
, dwCount
);
1075 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1076 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1078 if (SUCCEEDED(hr
)) {
1080 dwCount2
=0xdeadbeef;
1081 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
1082 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1083 if (SUCCEEDED(hr
)) {
1084 /* native urlmon has an incrementing counter for dwEnum */
1085 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
1086 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1089 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1090 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1092 /* Destroy the Enumerator twice is detected and handled in native urlmon */
1093 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1094 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
1097 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
1098 hr
= IInternetZoneManager_Release(zonemgr
);
1099 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1102 static void test_GetZoneActionPolicy(void)
1104 IInternetZoneManager
*zonemgr
= NULL
;
1107 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
1109 trace("testing GetZoneActionPolixy...\n");
1111 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1112 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
1116 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1117 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1118 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
1119 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
1120 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
1121 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
1122 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
1123 "unexpected policy=%d\n", *(DWORD
*)buf
);
1125 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
1126 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1127 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1129 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
1130 2, URLZONEREG_DEFAULT
);
1131 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1133 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
1134 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1135 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
1136 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
1138 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
1139 sizeof(DWORD
), URLZONEREG_DEFAULT
);
1140 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
1142 IInternetZoneManager_Release(zonemgr
);
1145 static void test_GetZoneAt(void)
1147 IInternetZoneManager
*zonemgr
= NULL
;
1154 trace("testing GetZoneAt...\n");
1156 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1157 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1161 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
1166 /* this crashes with native urlmon */
1167 IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
1170 dwZone
= 0xdeadbeef;
1171 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
1172 ok(hr
== E_INVALIDARG
,
1173 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1175 for (i
= 0; i
< dwCount
; i
++)
1177 dwZone
= 0xdeadbeef;
1178 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
1179 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
1182 dwZone
= 0xdeadbeef;
1183 /* MSDN (index .. must be .. less than or equal to) is wrong */
1184 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
1185 ok(hr
== E_INVALIDARG
,
1186 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
1188 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
1189 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1192 hr
= IInternetZoneManager_Release(zonemgr
);
1193 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1196 static void test_GetZoneAttributes(void)
1198 IInternetZoneManager
*zonemgr
= NULL
;
1199 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
1200 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1204 trace("testing GetZoneAttributes...\n");
1206 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1207 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1211 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
1212 for (i
= 0; i
< 5; i
++) {
1213 memset(buffer
, -1, sizeof(buffer
));
1214 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
1215 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
1218 /* IE8 no longer set 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
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1224 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
1226 memset(buffer
, -1, sizeof(buffer
));
1228 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1229 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1230 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1231 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
1233 memset(buffer
, -1, sizeof(buffer
));
1234 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
1235 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1236 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
1237 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
1239 /* IE8 up to IE10 don't fail on invalid zones */
1240 memset(buffer
, -1, sizeof(buffer
));
1241 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
1242 ok(hr
== S_OK
|| hr
== E_FAIL
|| hr
== E_POINTER
,
1243 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
1245 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
1246 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1248 hr
= IInternetZoneManager_Release(zonemgr
);
1249 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1252 static void test_SetZoneAttributes(void)
1254 IInternetZoneManager
*zonemgr
= NULL
;
1255 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 16];
1256 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
1257 CHAR regpath
[MAX_PATH
];
1262 trace("testing SetZoneAttributes...\n");
1263 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
1264 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
1268 memset(buffer
, -1, sizeof(buffer
));
1269 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, URLZONE_LOCAL_MACHINE
, pZA
);
1270 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1272 sprintf(regpath
, "%s\\Zones\\%d", szInternetSettingsKey
, URLZONE_CUSTOM
);
1273 res
= RegCreateKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1276 ok(res
== ERROR_SUCCESS
, "got %d (expected ERROR_SUCCESS)\n", res
);
1277 if (res
!= ERROR_SUCCESS
)
1280 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
);
1281 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, NULL
);
1282 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
1285 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1287 win_skip("SetZoneAttributes not supported: IE too old\n");
1290 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1292 /* native urlmon ignores cbSize */
1293 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) + sizeof(DWORD
);
1294 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1295 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) + sizeof(DWORD) (expected S_OK)\n", hr
);
1297 pZA
->cbSize
= sizeof(ZONEATTRIBUTES
) - sizeof(DWORD
);
1298 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1299 ok(hr
== S_OK
, "got 0x%x for sizeof(ZONEATTRIBUTES) - sizeof(DWORD) (expected S_OK)\n", hr
);
1302 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1303 ok(hr
== S_OK
, "got 0x%x for size 0 (expected S_OK)\n", hr
);
1305 /* The key for the zone must be present, when calling SetZoneAttributes */
1306 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1307 /* E_FAIL is returned from IE6 here, which is reasonable.
1308 All newer IE return S_OK without saving the zone attributes to the registry.
1309 This is a Windows bug, but we have to accept that as standard */
1310 hr
= IInternetZoneManager_SetZoneAttributes(zonemgr
, URLZONE_CUSTOM
, pZA
);
1311 ok((hr
== S_OK
) || broken(hr
== E_FAIL
), "got 0x%x (expected S_OK)\n", hr
);
1313 /* SetZoneAttributes did not create the directory */
1314 res
= RegOpenKeyA(HKEY_CURRENT_USER
, regpath
, &hkey
);
1315 ok((res
== ERROR_FILE_NOT_FOUND
) && (hkey
== NULL
),
1316 "got %u with %p (expected ERROR_FILE_NOT_FOUND with NULL)\n", res
, hkey
);
1318 if (hkey
) RegCloseKey(hkey
);
1321 /* delete zone settings in the registry */
1322 myRegDeleteTreeA(HKEY_CURRENT_USER
, regpath
);
1324 hr
= IInternetZoneManager_Release(zonemgr
);
1325 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
1329 static void test_InternetSecurityMarshalling(void)
1331 IInternetSecurityManager
*secmgr
= NULL
;
1336 trace("testing marshalling...\n");
1338 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
1339 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1343 hres
= IInternetSecurityManager_QueryInterface(secmgr
, &IID_IUnknown
, (void**)&unk
);
1344 ok(hres
== S_OK
, "QueryInterface returned: %08x\n", hres
);
1346 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
1347 ok(hres
== S_OK
, "CreateStreamOnHGlobal returned: %08x\n", hres
);
1349 hres
= CoMarshalInterface(stream
, &IID_IInternetSecurityManager
, unk
, MSHCTX_INPROC
, NULL
, MSHLFLAGS_NORMAL
);
1350 /* Not supported in W98 */
1351 ok(hres
== S_OK
|| broken(hres
== REGDB_E_IIDNOTREG
),
1352 "CoMarshalInterface returned: %08x\n", hres
);
1354 IStream_Release(stream
);
1355 IUnknown_Release(unk
);
1356 IInternetSecurityManager_Release(secmgr
);
1359 static void test_InternetGetSecurityUrl(void)
1361 const WCHAR url5_out
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
1362 '.','w','i','n','e','t','e','s','t',0};
1363 const WCHAR url7_out
[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
1365 const WCHAR
*in
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1366 const WCHAR
*out_default
[] = {url2
, url3
, url4
, url5_out
, url7_out
, url8
, url5_out
, url10
};
1367 const WCHAR
*out_securl
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
1373 trace("testing CoInternetGetSecurityUrl...\n");
1375 for(i
=0; i
<sizeof(in
)/sizeof(WCHAR
*); i
++) {
1376 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_DEFAULT
, 0);
1377 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1379 ok(!strcmp_w(sec
, out_default
[i
]), "(%d) Got %s, expected %s\n",
1380 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_default
[i
]));
1384 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_SECURITY_URL_ONLY
, 0);
1385 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
1387 ok(!strcmp_w(sec
, out_securl
[i
]), "(%d) Got %s, expected %s\n",
1388 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_securl
[i
]));
1393 SET_EXPECT(ParseUrl_SECURITY_URL_input2
);
1394 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1395 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1397 hres
= pCoInternetGetSecurityUrl(security_url2W
, &sec
, PSU_DEFAULT
, 0);
1398 ok(hres
== S_OK
, "CoInternetGetSecurityUrl returned 0x%08x, expected S_OK\n", hres
);
1400 CHECK_CALLED(ParseUrl_SECURITY_URL_input2
);
1401 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1402 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1404 ok(!lstrcmpW(security_expectedW
, sec
), "Expected %s but got %s\n",
1405 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(sec
));
1409 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
1410 REFIID riid
, void **ppv
)
1412 ok(0, "unexpected call\n");
1413 return E_NOINTERFACE
;
1416 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
1421 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
1426 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
1427 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
1428 DWORD
*pcchResult
, DWORD dwReserved
)
1430 const WCHAR
*ret
= NULL
;
1432 ok(pwzResult
!= NULL
, "pwzResult == NULL\n");
1433 ok(pcchResult
!= NULL
, "pcchResult == NULL\n");
1434 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
1436 switch(ParseAction
) {
1437 case PARSE_SECURITY_URL
:
1438 if(!strcmp_w(pwzUrl
, security_urlW
)) {
1439 CHECK_EXPECT(ParseUrl_SECURITY_URL_input
);
1440 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1441 ret
= security_expectedW
;
1442 } else if(!strcmp_w(pwzUrl
, security_url2W
)) {
1443 CHECK_EXPECT(ParseUrl_SECURITY_URL_input2
);
1444 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1445 ret
= security_expectedW
;
1446 } else if(!strcmp_w(pwzUrl
, security_expectedW
)) {
1447 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected
);
1448 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1449 ret
= security_expectedW
;
1450 } else if(!strcmp_w(pwzUrl
, winetest_to_httpW
)) {
1451 switch(++called_securl_http
) {
1453 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1456 CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1457 ok(cchResult
== lstrlenW(url9
)+1, "Got %d\n", cchResult
);
1460 todo_wine
CHECK_EXPECT(ParseUrl_SECURITY_URL_http
);
1464 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl
));
1467 case PARSE_SECURITY_DOMAIN
:
1469 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1471 ok(!strcmp_w(pwzUrl
, security_expectedW
), "Expected %s but got %s\n",
1472 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(pwzUrl
));
1473 ok(cchResult
== lstrlenW(pwzUrl
)+1, "Got %d\n", cchResult
);
1474 ret
= security_expectedW
;
1477 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction
,
1478 wine_dbgstr_w(pwzUrl
));
1484 *pcchResult
= lstrlenW(ret
)+1;
1485 if(*pcchResult
> cchResult
)
1487 memcpy(pwzResult
, ret
, (*pcchResult
)*sizeof(WCHAR
));
1491 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
1492 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
1493 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
1495 ok(0, "unexpected call\n");
1499 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
1500 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
1502 ok(0, "unexpected call\n");
1506 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
1507 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
1508 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
1510 ok(0, "unexpected call\n");
1514 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
1515 InternetProtocolInfo_QueryInterface
,
1516 InternetProtocolInfo_AddRef
,
1517 InternetProtocolInfo_Release
,
1518 InternetProtocolInfo_ParseUrl
,
1519 InternetProtocolInfo_CombineUrl
,
1520 InternetProtocolInfo_CompareUrl
,
1521 InternetProtocolInfo_QueryInfo
1524 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
1526 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
1528 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
1529 *ppv
= &protocol_info
;
1533 ok(0, "unexpected call\n");
1534 return E_NOINTERFACE
;
1537 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
1542 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
1547 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
1548 REFIID riid
, void **ppv
)
1550 ok(0, "unexpected call\n");
1554 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
1556 ok(0, "unexpected call\n");
1560 static const IClassFactoryVtbl ClassFactoryVtbl
= {
1561 ClassFactory_QueryInterface
,
1562 ClassFactory_AddRef
,
1563 ClassFactory_Release
,
1564 ClassFactory_CreateInstance
,
1565 ClassFactory_LockServer
1568 static IClassFactory protocol_cf
= { &ClassFactoryVtbl
};
1570 static void register_protocols(void)
1572 IInternetSession
*session
;
1575 hres
= pCoInternetGetSession(0, &session
, 0);
1576 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
1580 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
1581 winetestW
, 0, NULL
, 0);
1582 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
1584 IInternetSession_Release(session
);
1587 static void unregister_protocols(void) {
1588 IInternetSession
*session
;
1591 hr
= pCoInternetGetSession(0, &session
, 0);
1592 ok(hr
== S_OK
, "CoInternetGetSession failed: 0x%08x\n", hr
);
1596 hr
= IInternetSession_UnregisterNameSpace(session
, &protocol_cf
, winetestW
);
1597 ok(hr
== S_OK
, "UnregisterNameSpace failed: 0x%08x\n", hr
);
1599 IInternetSession_Release(session
);
1602 static const struct {
1605 const char *security_uri
;
1606 HRESULT security_hres
;
1607 const char *default_uri
;
1608 HRESULT default_hres
;
1610 } sec_url_ex_tests
[] = {
1611 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,"*:index.html",S_OK
,"*:index.htm",S_OK
},
1612 {"file://c:\\Index.htm",Uri_CREATE_FILE_USE_DOS_PATH
,"file:///c:/Index.htm",S_OK
,"file:///c:/Index.htm",S_OK
},
1613 {"file:some%20file%2ejpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1614 {"file:some file.jpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
1615 {"http://www.zone3.winetest/",0,"http://www.zone3.winetest/",S_OK
,"http://www.zone3.winetest/",S_OK
},
1616 {"about:blank",0,"about:blank",S_OK
,"about:blank",S_OK
},
1617 {"ftp://zone3.winetest/file.test",0,"ftp://zone3.winetest/file.test",S_OK
,"ftp://zone3.winetest/file.test",S_OK
},
1618 {"test:123abc",0,"test:123abc",S_OK
,"test:123abc",S_OK
},
1619 {"http:google.com/test.file",0,"http:google.com/test.file",S_OK
,"http:google.com/test.file",S_OK
},
1620 {"ftp://test@ftp.winehq.org/",0,"ftp://ftp.winehq.org/",S_OK
,"ftp://ftp.winehq.org/",S_OK
},
1621 {"test://google@ftp.winehq.org/",0,"test://google@ftp.winehq.org/",S_OK
,"test://google@ftp.winehq.org/",S_OK
}
1624 static void test_InternetGetSecurityUrlEx(void)
1628 IUri
*uri
= NULL
, *result
= NULL
;
1630 trace("testing CoInternetGetSecurityUrlEx...\n");
1632 hr
= pCoInternetGetSecurityUrlEx(NULL
, NULL
, PSU_DEFAULT
, 0);
1633 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1635 result
= (void*) 0xdeadbeef;
1636 hr
= pCoInternetGetSecurityUrlEx(NULL
, &result
, PSU_DEFAULT
, 0);
1637 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
1638 ok(result
== (void*) 0xdeadbeef, "'result' was %p\n", result
);
1640 for(i
= 0; i
< sizeof(sec_url_ex_tests
)/sizeof(sec_url_ex_tests
[0]); ++i
) {
1641 LPWSTR uriW
= a2w(sec_url_ex_tests
[i
].uri
);
1644 hr
= pCreateUri(uriW
, sec_url_ex_tests
[i
].create_flags
, 0, &uri
);
1645 ok(hr
== S_OK
, "CreateUri returned 0x%08x on test %d\n", hr
, i
);
1649 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1650 todo_wine_if (sec_url_ex_tests
[i
].todo
) {
1651 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1652 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1653 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1658 hr
= IUri_GetDisplayUri(result
, &received
);
1659 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1661 todo_wine_if (sec_url_ex_tests
[i
].todo
) {
1662 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1663 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1664 wine_dbgstr_w(received
), i
);
1667 SysFreeString(received
);
1669 if(result
) IUri_Release(result
);
1672 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1673 todo_wine_if (sec_url_ex_tests
[i
].todo
) {
1674 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
1675 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1676 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1681 hr
= IUri_GetDisplayUri(result
, &received
);
1682 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1684 todo_wine_if (sec_url_ex_tests
[i
].todo
) {
1685 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1686 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1687 wine_dbgstr_w(received
), i
);
1690 SysFreeString(received
);
1692 if(result
) IUri_Release(result
);
1695 if(uri
) IUri_Release(uri
);
1700 static void test_InternetGetSecurityUrlEx_Pluggable(void)
1703 IUri
*uri
= NULL
, *result
;
1705 trace("testing CoInternetGetSecurityUrlEx for pluggable protocols...\n");
1707 hr
= pCreateUri(security_urlW
, 0, 0, &uri
);
1708 ok(hr
== S_OK
, "CreateUri returned 0x%08x\n", hr
);
1710 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1711 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1712 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1714 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1715 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1717 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1718 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1719 CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1722 BSTR received
= NULL
;
1724 hr
= IUri_GetAbsoluteUri(result
, &received
);
1725 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1727 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1728 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1730 SysFreeString(received
);
1732 if(result
) IUri_Release(result
);
1736 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1737 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1739 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1740 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1742 CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1743 CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1746 BSTR received
= NULL
;
1748 hr
= IUri_GetAbsoluteUri(result
, &received
);
1749 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1751 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1752 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1754 SysFreeString(received
);
1756 if(result
) IUri_Release(result
);
1758 if(uri
) IUri_Release(uri
);
1761 static const BYTE secidex2_1
[] = {'z','i','p',':','/','/','t','e','s','t','i','n','g','.','c','o','m','/',3,0,0,0};
1762 static const BYTE secidex2_2
[] = {'z','i','p',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1763 static const BYTE secidex2_3
[] = {'*',':','t','e','s','t','i','n','g','.','c','o','m',3,0,0,0};
1765 static const struct {
1775 } sec_mgr_ex2_tests
[] = {
1776 {"res://mshtml.dll/blank.htm",0,S_OK
,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1777 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,secid2
,sizeof(secid2
),S_OK
},
1778 {"file://c:\\Index.html",0,0,URLZONE_LOCAL_MACHINE
,FALSE
,secid1
,sizeof(secid1
),S_OK
},
1779 {"http://www.zone3.winetest/",0,0,URLZONE_INTERNET
,FALSE
,secid5
,sizeof(secid5
),S_OK
},
1780 {"about:blank",0,0,URLZONE_INTERNET
,FALSE
,secid6
,sizeof(secid6
),S_OK
},
1781 {"ftp://zone3.winetest/file.test",0,0,URLZONE_INTERNET
,FALSE
,secid7
,sizeof(secid7
),S_OK
},
1782 {"/file/testing/test.test",Uri_CREATE_ALLOW_RELATIVE
,0,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1783 {"zip://testing.com/",0,0,URLZONE_INTERNET
,FALSE
,secidex2_1
,sizeof(secidex2_1
),S_OK
},
1784 {"zip:testing.com",0,0,URLZONE_INTERNET
,FALSE
,secidex2_2
,sizeof(secidex2_2
),S_OK
},
1785 {"http:google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1786 {"http:/google.com",0,S_OK
,URLZONE_INVALID
,FALSE
,NULL
,0,E_INVALIDARG
},
1787 {"*:/testing",0,S_OK
,URLZONE_INTERNET
,FALSE
,NULL
,0,E_INVALIDARG
},
1788 {"*://testing.com",0,S_OK
,URLZONE_INTERNET
,FALSE
,secidex2_3
,sizeof(secidex2_3
),S_OK
}
1791 static void test_SecurityManagerEx2(void)
1796 DWORD buf_size
= sizeof(buf
);
1797 IInternetSecurityManager
*sec_mgr
;
1798 IInternetSecurityManagerEx2
*sec_mgr2
;
1801 static const WCHAR domainW
[] = {'c','o','m','.','u','k',0};
1804 win_skip("Skipping SecurityManagerEx2, IE is too old\n");
1808 trace("Testing SecurityManagerEx2...\n");
1810 hres
= pCoInternetCreateSecurityManager(NULL
, &sec_mgr
, 0);
1811 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
1813 hres
= IInternetSecurityManager_QueryInterface(sec_mgr
, &IID_IInternetSecurityManagerEx2
, (void**)&sec_mgr2
);
1814 ok(hres
== S_OK
, "QueryInterface(IID_IInternetSecurityManagerEx2) failed: %08x\n", hres
);
1818 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, NULL
, &zone
, 0, NULL
, NULL
);
1819 ok(hres
== E_INVALIDARG
, "MapUrlToZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1820 ok(zone
== URLZONE_INVALID
, "zone was %d\n", zone
);
1822 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, NULL
, buf
, &buf_size
, 0);
1823 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1824 ok(buf_size
== sizeof(buf
), "buf_size was %d\n", buf_size
);
1826 hres
= pCreateUri(url5
, 0, 0, &uri
);
1827 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1829 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, NULL
, 0, NULL
, NULL
);
1830 ok(hres
== E_INVALIDARG
, "MapToUrlZoneEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1832 buf_size
= sizeof(buf
);
1833 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, NULL
, &buf_size
, 0);
1834 ok(hres
== E_INVALIDARG
|| broken(hres
== S_OK
), "GetSecurityIdEx2 failed: %08x\n", hres
);
1835 ok(buf_size
== sizeof(buf
), "bug_size was %d\n", buf_size
);
1837 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, NULL
, 0);
1838 ok(hres
== E_INVALIDARG
, "GetSecurityIdEx2 returned %08x, expected E_INVALIDARG\n", hres
);
1842 for(i
= 0; i
< sizeof(sec_mgr_ex2_tests
)/sizeof(sec_mgr_ex2_tests
[0]); ++i
) {
1843 LPWSTR uriW
= a2w(sec_mgr_ex2_tests
[i
].uri
);
1846 zone
= URLZONE_INVALID
;
1848 hres
= pCreateUri(uriW
, sec_mgr_ex2_tests
[i
].create_flags
, 0, &uri
);
1849 ok(hres
== S_OK
, "CreateUri returned %08x for '%s'\n", hres
, sec_mgr_ex2_tests
[i
].uri
);
1851 hres
= IInternetSecurityManagerEx2_MapUrlToZoneEx2(sec_mgr2
, uri
, &zone
, 0, NULL
, NULL
);
1852 todo_wine_if (sec_mgr_ex2_tests
[i
].map_todo
) {
1853 ok(hres
== sec_mgr_ex2_tests
[i
].map_hres
, "MapUrlToZoneEx2 returned %08x, expected %08x for '%s'\n",
1854 hres
, sec_mgr_ex2_tests
[i
].map_hres
, sec_mgr_ex2_tests
[i
].uri
);
1855 ok(zone
== sec_mgr_ex2_tests
[i
].zone
, "Expected zone %d, but got %d for '%s'\n", sec_mgr_ex2_tests
[i
].zone
,
1856 zone
, sec_mgr_ex2_tests
[i
].uri
);
1859 buf_size
= sizeof(buf
);
1860 memset(buf
, 0xf0, buf_size
);
1862 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1863 todo_wine_if (sec_mgr_ex2_tests
[i
].secid_todo
) {
1864 ok(hres
== sec_mgr_ex2_tests
[i
].secid_hres
, "GetSecurityIdEx2 returned %08x, expected %08x on test '%s'\n",
1865 hres
, sec_mgr_ex2_tests
[i
].secid_hres
, sec_mgr_ex2_tests
[i
].uri
);
1866 if(sec_mgr_ex2_tests
[i
].secid
) {
1867 ok(buf_size
== sec_mgr_ex2_tests
[i
].secid_size
, "Got wrong security id size=%d, expected %d on test '%s'\n",
1868 buf_size
, sec_mgr_ex2_tests
[i
].secid_size
, sec_mgr_ex2_tests
[i
].uri
);
1869 ok(!memcmp(buf
, sec_mgr_ex2_tests
[i
].secid
, sec_mgr_ex2_tests
[i
].secid_size
), "Got wrong security id on test '%s'\n",
1870 sec_mgr_ex2_tests
[i
].uri
);
1878 hres
= pCreateUri(url15
, 0, 0, &uri
);
1879 ok(hres
== S_OK
, "CreateUri failed: %08x\n", hres
);
1881 buf_size
= sizeof(buf
);
1882 memset(buf
, 0xf0, buf_size
);
1884 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, (DWORD_PTR
)domainW
);
1885 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1886 todo_wine
ok(buf_size
== sizeof(secid13
), "buf_size was %d\n", buf_size
);
1887 todo_wine
ok(!memcmp(buf
, secid13
, sizeof(secid13
)), "Got wrong secid\n");
1889 buf_size
= sizeof(buf
);
1890 memset(buf
, 0xf0, buf_size
);
1892 hres
= IInternetSecurityManagerEx2_GetSecurityIdEx2(sec_mgr2
, uri
, buf
, &buf_size
, 0);
1893 ok(hres
== S_OK
, "GetSecurityIdEx2 failed: %08x\n", hres
);
1894 ok(buf_size
== sizeof(secid13_2
), "buf_size was %d\n", buf_size
);
1895 ok(!memcmp(buf
, secid13_2
, sizeof(secid13_2
)), "Got wrong secid\n");
1899 IInternetSecurityManagerEx2_Release(sec_mgr2
);
1900 IInternetSecurityManager_Release(sec_mgr
);
1903 static void test_CoInternetIsFeatureZoneElevationEnabled(void)
1906 const char *url_from
;
1912 /* 0 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_FALSE
, URLPOLICY_ALLOW
},
1913 /* 1 */ { "http://www.winehq.org", "http://www.winehq.org", 0, S_OK
, URLPOLICY_DISALLOW
},
1914 /* 2 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_FALSE
, URLPOLICY_ALLOW
},
1915 /* 3 */ { "http://www.winehq.org", "http://www.codeweavers.com", 0, S_OK
, URLPOLICY_DISALLOW
},
1916 /* 4 */ { "http://www.winehq.org", "http://www.winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1917 /* 5 */ { "http://www.winehq.org", "http://www.winehq.org/dir", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1918 /* 6 */ { "http://www.winehq.org", "http://www.codeweavers.com", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1919 /* 7 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
, S_FALSE
, -1 },
1920 /* 8 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_PROCESS
|0x100, S_FALSE
, URLPOLICY_ALLOW
},
1921 /* 9 */ { "http://www.winehq.org", "ftp://winehq.org", GET_FEATURE_FROM_REGISTRY
, S_FALSE
, URLPOLICY_ALLOW
},
1924 WCHAR
*url_from
, *url_to
;
1928 if(!pCoInternetIsFeatureZoneElevationEnabled
|| !pCoInternetIsFeatureEnabled
1929 || !pCoInternetIsFeatureEnabledForUrl
) {
1930 win_skip("Skipping CoInternetIsFeatureZoneElevationEnabled tests\n");
1935 hres
= pCoInternetIsFeatureEnabled(FEATURE_ZONE_ELEVATION
, GET_FEATURE_FROM_PROCESS
);
1936 ok(SUCCEEDED(hres
), "CoInternetIsFeatureEnabled returned %x\n", hres
);
1938 trace("Testing CoInternetIsFeatureZoneElevationEnabled... (%x)\n", hres
);
1940 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1941 if(hres
==S_OK
&& testcases
[i
].flags
== GET_FEATURE_FROM_PROCESS
)
1942 testcases
[i
].policy_flags
= URLPOLICY_ALLOW
;
1945 /* IE10 does not seem to use passed ISecurityManager */
1946 SET_EXPECT(ProcessUrlAction
);
1947 pCoInternetIsFeatureZoneElevationEnabled(url1
, url1
, &security_manager
, 0);
1948 i
= called_ProcessUrlAction
;
1949 SET_CALLED(ProcessUrlAction
);
1951 skip("CoInternetIsFeatureZoneElevationEnabled does not use passed ISecurityManager\n");
1955 for(i
=0; i
<sizeof(testcases
)/sizeof(testcases
[0]); i
++) {
1956 url_from
= a2w(testcases
[i
].url_from
);
1957 url_to
= a2w(testcases
[i
].url_to
);
1959 if(testcases
[i
].policy_flags
!= -1) {
1960 ProcessUrlAction_policy
= testcases
[i
].policy_flags
;
1961 SET_EXPECT(ProcessUrlAction
);
1963 hres
= pCoInternetIsFeatureZoneElevationEnabled(url_from
, url_to
,
1964 &security_manager
, testcases
[i
].flags
);
1965 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureZoneElevationEnabled returned %x\n", i
, hres
);
1966 if(testcases
[i
].policy_flags
!= -1)
1967 CHECK_CALLED(ProcessUrlAction
);
1969 if(testcases
[i
].policy_flags
!= -1)
1970 SET_EXPECT(ProcessUrlAction
);
1971 hres
= pCoInternetIsFeatureEnabledForUrl(FEATURE_ZONE_ELEVATION
,
1972 testcases
[i
].flags
, url_to
, &security_manager
);
1973 ok(hres
== testcases
[i
].hres
, "%d) CoInternetIsFeatureEnabledForUrl returned %x\n", i
, hres
);
1974 if(testcases
[i
].policy_flags
!= -1)
1975 CHECK_CALLED(ProcessUrlAction
);
1977 heap_free(url_from
);
1988 hurlmon
= GetModuleHandleA("urlmon.dll");
1989 pCoInternetCreateSecurityManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateSecurityManager");
1990 pCoInternetCreateZoneManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateZoneManager");
1991 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
1992 pCoInternetGetSecurityUrlEx
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrlEx");
1993 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
1994 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
1995 pCoInternetIsFeatureEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabled");
1996 pCoInternetIsFeatureEnabledForUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureEnabledForUrl");
1997 pCoInternetIsFeatureZoneElevationEnabled
= (void*) GetProcAddress(hurlmon
, "CoInternetIsFeatureZoneElevationEnabled");
1999 if (!pCoInternetCreateSecurityManager
|| !pCoInternetCreateZoneManager
||
2000 !pCoInternetGetSecurityUrl
) {
2001 win_skip("Various CoInternet* functions not present in IE 4.0\n");
2005 argc
= winetest_get_mainargs(&argv
);
2006 if(argc
> 2 && !strcmp(argv
[2], "domain_tests")) {
2007 test_zone_domain_mappings();
2011 OleInitialize(NULL
);
2012 register_protocols();
2014 test_InternetGetSecurityUrl();
2016 if(!pCoInternetGetSecurityUrlEx
|| !pCreateUri
)
2017 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
2019 test_InternetGetSecurityUrlEx();
2020 test_InternetGetSecurityUrlEx_Pluggable();
2023 test_SecurityManager();
2024 test_SecurityManagerEx2();
2026 test_zone_domains();
2027 test_CoInternetCreateZoneManager();
2028 test_CreateZoneEnumerator();
2029 test_GetZoneActionPolicy();
2031 test_GetZoneAttributes();
2032 test_SetZoneAttributes();
2033 test_InternetSecurityMarshalling();
2034 test_CoInternetIsFeatureZoneElevationEnabled();
2036 unregister_protocols();