2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
3 * Copyright 2009 Detlef Riekenberg
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define NONAMELESSUNION
24 /* needed for IInternetZoneManagerEx2 */
25 #define _WIN32_IE 0x0700
27 #include <wine/test.h>
38 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
39 '/','b','l','a','n','k','.','h','t','m',0};
40 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
41 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
42 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
43 '%','2','e','j','p','g',0};
44 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q',
46 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
47 static const WCHAR url7
[] = {'f','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g','/',
48 'f','i','l','e','.','t','e','s','t',0};
49 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
50 static const WCHAR url9
[] =
51 {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',
52 '/','s','i','t','e','/','a','b','o','u','t',0};
53 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
56 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
60 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
61 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','w','i','n','e','h','q',
62 '.','o','r','g',3,0,0,0};
63 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
64 static const BYTE secid7
[] = {'f','t','p',':','w','i','n','e','h','q','.','o','r','g',
66 static const BYTE secid10
[] =
67 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
68 static const BYTE secid10_2
[] =
69 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
71 static const GUID CLSID_TestActiveX
=
72 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
74 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
75 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
76 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
78 static struct secmgr_test
{
86 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
87 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
88 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
89 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
90 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
91 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
}
94 static void test_SecurityManager(void)
97 IInternetSecurityManager
*secmgr
= NULL
;
99 DWORD zone
, size
, policy
;
102 hres
= CoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
103 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
107 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
109 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
111 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
112 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
113 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
114 i
, hres
, secmgr_tests
[i
].zone_hres
);
116 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
117 secmgr_tests
[i
].zone
);
119 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
122 memset(buf
, 0xf0, sizeof(buf
));
123 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
125 ok(hres
== secmgr_tests
[i
].secid_hres
,
126 "[%d] GetSecurityId failed: %08x, expected %08x\n",
127 i
, hres
, secmgr_tests
[i
].secid_hres
);
128 if(secmgr_tests
[i
].secid
) {
129 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
130 i
, size
, secmgr_tests
[i
].secid_size
);
131 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
136 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
137 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
138 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
140 /* win2k3 translates %20 into a space */
142 memset(buf
, 0xf0, sizeof(buf
));
143 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
144 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
145 ok(size
== sizeof(secid10
) ||
146 size
== sizeof(secid10_2
), /* win2k3 */
148 ok(!memcmp(buf
, secid10
, size
) ||
149 !memcmp(buf
, secid10_2
, size
), /* win2k3 */
153 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
154 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
155 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
158 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
159 ok(hres
== E_INVALIDARG
,
160 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
161 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
163 ok(hres
== E_INVALIDARG
,
164 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
165 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
167 ok(hres
== E_INVALIDARG
,
168 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
170 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
171 sizeof(WCHAR
), NULL
, 0, 0, 0);
172 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
174 IInternetSecurityManager_Release(secmgr
);
177 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
178 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
179 static BOOL
is_ie_hardened(void)
182 DWORD ie_harden
, type
, size
;
185 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
186 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
187 size
= sizeof(DWORD
);
188 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
192 RegCloseKey(zone_map
);
195 return ie_harden
!= 0;
198 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
200 DWORD res
, size
, policy
, reg_policy
;
205 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
206 * The test should be changed to cope with that, if need be.
208 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
209 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
210 if(res
!= ERROR_SUCCESS
) {
211 ok(0, "Could not open zone key\n");
215 wsprintf(buf
, "%X", action
);
216 size
= sizeof(DWORD
);
217 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
219 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
221 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
222 sizeof(WCHAR
), NULL
, 0, 0, 0);
223 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
224 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
225 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
228 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
229 sizeof(DWORD
), URLZONEREG_DEFAULT
);
230 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
231 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
232 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
237 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
238 sizeof(DWORD
), URLZONEREG_DEFAULT
);
239 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
240 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
242 if(policy
!= URLPOLICY_QUERY
) {
243 if(winetest_interactive
|| ! is_ie_hardened()) {
245 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
246 sizeof(WCHAR
), NULL
, 0, 0, 0);
247 if(reg_policy
== URLPOLICY_DISALLOW
)
248 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
250 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
251 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
254 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
256 if(reg_policy
== URLPOLICY_DISALLOW
)
257 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
259 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
260 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
263 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
264 sizeof(DWORD
), NULL
, 0, 0, 0);
265 if(reg_policy
== URLPOLICY_DISALLOW
)
266 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
268 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
269 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
272 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
273 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
274 if(reg_policy
== URLPOLICY_DISALLOW
)
275 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
277 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
278 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
280 skip("IE running in Enhanced Security Configuration\n");
285 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
291 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
292 sizeof(DWORD
), URLZONEREG_DEFAULT
);
293 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
294 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
297 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
298 sizeof(WCHAR
), NULL
, 0, 0, 0);
299 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
302 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
303 sizeof(DWORD
), NULL
, 0, 0, 0);
304 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
305 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
308 static void test_activex(IInternetSecurityManager
*secmgr
)
310 DWORD policy
, policy_size
;
311 struct CONFIRMSAFETY cs
;
316 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
317 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
318 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
319 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
321 cs
.clsid
= CLSID_TestActiveX
;
322 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
324 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
325 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
326 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
329 static void test_polices(void)
331 IInternetZoneManager
*zonemgr
= NULL
;
332 IInternetSecurityManager
*secmgr
= NULL
;
335 hres
= CoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
336 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
337 hres
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
338 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
340 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
341 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
342 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
343 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
344 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
346 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
347 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
349 test_activex(secmgr
);
351 IInternetSecurityManager_Release(secmgr
);
352 IInternetZoneManager_Release(zonemgr
);
355 static void test_CoInternetCreateZoneManager(void)
357 IInternetZoneManager
*zonemgr
= NULL
;
358 IUnknown
*punk
= NULL
;
361 hr
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
362 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
366 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
367 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
369 IUnknown_Release(punk
);
371 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
372 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
374 IUnknown_Release(punk
);
377 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
379 IUnknown_Release(punk
);
381 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
383 IUnknown_Release(punk
);
385 win_skip("InternetZoneManagerEx2 not supported\n");
389 win_skip("InternetZoneManagerEx not supported\n");
391 hr
= IInternetZoneManager_Release(zonemgr
);
392 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
396 static void test_CreateZoneEnumerator(void)
398 IInternetZoneManager
*zonemgr
= NULL
;
405 hr
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
406 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
411 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
412 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
413 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
416 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
417 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
418 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
422 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
423 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
424 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
425 hr
, dwEnum
, dwCount
);
429 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
430 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
431 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
432 hr
, dwEnum
, dwCount
);
437 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
438 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
443 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
444 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
446 /* native urlmon has an incrementing counter for dwEnum */
447 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
448 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
451 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
452 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
454 /* Destroy the Enumerator twice is detected and handled in native urlmon */
455 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
456 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
459 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
460 hr
= IInternetZoneManager_Release(zonemgr
);
461 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
464 static void test_GetZoneActionPolicy(void)
466 IInternetZoneManager
*zonemgr
= NULL
;
469 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
471 hres
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
472 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
476 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
477 sizeof(DWORD
), URLZONEREG_DEFAULT
);
478 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
479 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
480 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
481 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
482 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
483 "unexpected policy=%d\n", *(DWORD
*)buf
);
485 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
486 sizeof(DWORD
), URLZONEREG_DEFAULT
);
487 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
489 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
490 2, URLZONEREG_DEFAULT
);
491 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
493 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
494 sizeof(DWORD
), URLZONEREG_DEFAULT
);
495 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
496 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
498 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
499 sizeof(DWORD
), URLZONEREG_DEFAULT
);
500 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
502 IInternetZoneManager_Release(zonemgr
);
505 static void test_GetZoneAt(void)
507 IInternetZoneManager
*zonemgr
= NULL
;
514 hr
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
515 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
519 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
524 /* this crashes with native urlmon */
525 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
529 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
530 ok(hr
== E_INVALIDARG
,
531 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
533 for (i
= 0; i
< dwCount
; i
++)
536 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
537 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
541 /* MSDN (index .. must be .. less than or equal to) is wrong */
542 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
543 ok(hr
== E_INVALIDARG
,
544 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
546 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
547 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
550 hr
= IInternetZoneManager_Release(zonemgr
);
551 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
554 static void test_GetZoneAttributes(void)
556 IInternetZoneManager
*zonemgr
= NULL
;
557 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
558 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
562 hr
= CoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
563 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
567 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
568 for (i
= 0; i
< 5; i
++) {
569 memset(buffer
, -1, sizeof(buffer
));
570 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
571 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
574 /* IE8 no longer set cbSize */
575 memset(buffer
, -1, sizeof(buffer
));
577 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
578 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
579 ok((pZA
->cbSize
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
580 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
582 memset(buffer
, -1, sizeof(buffer
));
584 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
585 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
586 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
587 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
589 memset(buffer
, -1, sizeof(buffer
));
590 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
591 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
592 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
593 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
595 /* IE8 no longer fail on invalid zones */
596 memset(buffer
, -1, sizeof(buffer
));
597 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
598 ok(hr
== S_OK
|| (hr
== E_FAIL
),
599 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
601 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
602 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
604 hr
= IInternetZoneManager_Release(zonemgr
);
605 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
613 test_SecurityManager();
615 test_CoInternetCreateZoneManager();
616 test_CreateZoneEnumerator();
617 test_GetZoneActionPolicy();
619 test_GetZoneAttributes();