2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
3 * Copyright 2009-2010 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 #define DEFINE_EXPECT(func) \
39 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
41 #define SET_EXPECT(func) \
42 expect_ ## func = TRUE
44 #define CHECK_EXPECT(func) \
46 ok(expect_ ##func, "unexpected call " #func "\n"); \
47 expect_ ## func = FALSE; \
48 called_ ## func = TRUE; \
51 #define CHECK_EXPECT2(func) \
53 ok(expect_ ##func, "unexpected call " #func "\n"); \
54 called_ ## func = TRUE; \
57 #define CHECK_CALLED(func) \
59 ok(called_ ## func, "expected " #func "\n"); \
60 expect_ ## func = called_ ## func = FALSE; \
63 DEFINE_EXPECT(ParseUrl_SECURITY_URL_input
);
64 DEFINE_EXPECT(ParseUrl_SECURITY_URL_expected
);
65 DEFINE_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
67 static HRESULT (WINAPI
*pCoInternetCreateSecurityManager
)(IServiceProvider
*, IInternetSecurityManager
**, DWORD
);
68 static HRESULT (WINAPI
*pCoInternetCreateZoneManager
)(IServiceProvider
*, IInternetZoneManager
**, DWORD
);
69 static HRESULT (WINAPI
*pCoInternetGetSecurityUrl
)(LPCWSTR
, LPWSTR
*, PSUACTION
, DWORD
);
70 static HRESULT (WINAPI
*pCoInternetGetSecurityUrlEx
)(IUri
*, IUri
**, PSUACTION
, DWORD_PTR
);
71 static HRESULT (WINAPI
*pCreateUri
)(LPCWSTR
, DWORD
, DWORD_PTR
, IUri
**);
72 static HRESULT (WINAPI
*pCoInternetGetSession
)(DWORD
, IInternetSession
**, DWORD
);
74 static const WCHAR url1
[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',
75 '/','b','l','a','n','k','.','h','t','m',0};
76 static const WCHAR url2
[] = {'i','n','d','e','x','.','h','t','m',0};
77 static const WCHAR url3
[] = {'f','i','l','e',':','/','/','c',':','\\','I','n','d','e','x','.','h','t','m',0};
78 static const WCHAR url4
[] = {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e',
79 '%','2','e','j','p','g',0};
80 static const WCHAR url5
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
81 '.','w','i','n','e','t','e','s','t',0};
82 static const WCHAR url6
[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
83 static const WCHAR url7
[] = {'f','t','p',':','/','/','z','o','n','e','3',
84 '.','w','i','n','e','t','e','s','t','/','f','i','l','e','.','t','e','s','t',0};
85 static const WCHAR url8
[] = {'t','e','s','t',':','1','2','3','a','b','c',0};
86 static const WCHAR url9
[] = {'h','t','t','p',':','/','/','w','w','w','.','z','o','n','e','3',
87 '.','w','i','n','e','t','e','s','t', '/','s','i','t','e','/','a','b','o','u','t',0};
88 static const WCHAR url10
[] = {'f','i','l','e',':','/','/','s','o','m','e','%','2','0','f','i','l','e',
91 static const WCHAR url4e
[] = {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e',
94 static const WCHAR winetestW
[] = {'w','i','n','e','t','e','s','t',0};
95 static const WCHAR security_urlW
[] = {'w','i','n','e','t','e','s','t',':','t','e','s','t','i','n','g',0};
96 static const WCHAR security_expectedW
[] = {'w','i','n','e','t','e','s','t',':','z','i','p',0};
98 static const BYTE secid1
[] = {'f','i','l','e',':',0,0,0,0};
99 static const BYTE secid5
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
100 '.','w','i','n','e','t','e','s','t',3,0,0,0};
101 static const BYTE secid6
[] = {'a','b','o','u','t',':','b','l','a','n','k',3,0,0,0};
102 static const BYTE secid7
[] = {'f','t','p',':','z','o','n','e','3',
103 '.','w','i','n','e','t','e','s','t',3,0,0,0};
104 static const BYTE secid10
[] =
105 {'f','i','l','e',':','s','o','m','e','%','2','0','f','i','l','e','.','j','p','g',3,0,0,0};
106 static const BYTE secid10_2
[] =
107 {'f','i','l','e',':','s','o','m','e',' ','f','i','l','e','.','j','p','g',3,0,0,0};
109 static const GUID CLSID_TestActiveX
=
110 {0x178fc163,0xf585,0x4e24,{0x9c,0x13,0x4b,0xb7,0xfa,0xf8,0x06,0x46}};
112 /* Defined as extern in urlmon.idl, but not exported by uuid.lib */
113 const GUID GUID_CUSTOM_CONFIRMOBJECTSAFETY
=
114 {0x10200490,0xfa38,0x11d0,{0xac,0x0e,0x00,0xa0,0xc9,0xf,0xff,0xc0}};
116 static struct secmgr_test
{
124 {url1
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
125 {url2
, 100, 0x80041001, 0, NULL
, E_INVALIDARG
},
126 {url3
, 0, S_OK
, sizeof(secid1
), secid1
, S_OK
},
127 {url5
, 3, S_OK
, sizeof(secid5
), secid5
, S_OK
},
128 {url6
, 3, S_OK
, sizeof(secid6
), secid6
, S_OK
},
129 {url7
, 3, S_OK
, sizeof(secid7
), secid7
, S_OK
}
132 static int strcmp_w(const WCHAR
*str1
, const WCHAR
*str2
)
134 DWORD len1
= lstrlenW(str1
);
135 DWORD len2
= lstrlenW(str2
);
137 if(len1
!=len2
) return 1;
138 return memcmp(str1
, str2
, len1
*sizeof(WCHAR
));
141 static inline void heap_free(void *mem
)
143 HeapFree(GetProcessHeap(), 0, mem
);
146 static inline LPWSTR
a2w(LPCSTR str
)
151 DWORD len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
152 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
153 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
159 static inline DWORD
strcmp_aw(LPCSTR strA
, LPCWSTR strB
) {
160 LPWSTR strAW
= a2w(strA
);
161 DWORD ret
= lstrcmpW(strAW
, strB
);
166 static void test_SecurityManager(void)
169 IInternetSecurityManager
*secmgr
= NULL
;
171 DWORD zone
, size
, policy
;
174 if(!pCoInternetCreateSecurityManager
) {
178 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
179 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
183 for(i
=0; i
< sizeof(secmgr_tests
)/sizeof(secmgr_tests
[0]); i
++) {
185 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, secmgr_tests
[i
].url
,
187 ok(hres
== secmgr_tests
[i
].zone_hres
/* IE <=6 */
188 || (FAILED(secmgr_tests
[i
].zone_hres
) && hres
== E_INVALIDARG
), /* IE7 */
189 "[%d] MapUrlToZone failed: %08x, expected %08x\n",
190 i
, hres
, secmgr_tests
[i
].zone_hres
);
192 ok(zone
== secmgr_tests
[i
].zone
, "[%d] zone=%d, expected %d\n", i
, zone
,
193 secmgr_tests
[i
].zone
);
195 ok(zone
== secmgr_tests
[i
].zone
|| zone
== -1, "[%d] zone=%d\n", i
, zone
);
198 memset(buf
, 0xf0, sizeof(buf
));
199 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[i
].url
,
201 ok(hres
== secmgr_tests
[i
].secid_hres
,
202 "[%d] GetSecurityId failed: %08x, expected %08x\n",
203 i
, hres
, secmgr_tests
[i
].secid_hres
);
204 if(secmgr_tests
[i
].secid
) {
205 ok(size
== secmgr_tests
[i
].secid_size
, "[%d] size=%d, expected %d\n",
206 i
, size
, secmgr_tests
[i
].secid_size
);
207 ok(!memcmp(buf
, secmgr_tests
[i
].secid
, size
), "[%d] wrong secid\n", i
);
212 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, url10
, &zone
, 0);
213 ok(hres
== S_OK
, "MapUrlToZone failed: %08x, expected S_OK\n", hres
);
214 ok(zone
== 3, "zone=%d, expected 3\n", zone
);
216 /* win2k3 translates %20 into a space */
218 memset(buf
, 0xf0, sizeof(buf
));
219 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, url10
, buf
, &size
, 0);
220 ok(hres
== S_OK
, "GetSecurityId failed: %08x, expected S_OK\n", hres
);
221 ok(size
== sizeof(secid10
) ||
222 size
== sizeof(secid10_2
), /* win2k3 */
224 ok(!memcmp(buf
, secid10
, size
) ||
225 !memcmp(buf
, secid10_2
, size
), /* win2k3 */
229 hres
= IInternetSecurityManager_MapUrlToZone(secmgr
, NULL
, &zone
, 0);
230 ok(hres
== E_INVALIDARG
, "MapUrlToZone failed: %08x, expected E_INVALIDARG\n", hres
);
231 ok(zone
== 100 || zone
== -1, "zone=%d\n", zone
);
234 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, NULL
, buf
, &size
, 0);
235 ok(hres
== E_INVALIDARG
,
236 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
237 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
239 ok(hres
== E_INVALIDARG
,
240 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
241 hres
= IInternetSecurityManager_GetSecurityId(secmgr
, secmgr_tests
[1].url
,
243 ok(hres
== E_INVALIDARG
,
244 "GetSecurityId failed: %08x, expected E_INVALIDARG\n", hres
);
246 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, NULL
, URLACTION_SCRIPT_RUN
, (BYTE
*)&policy
,
247 sizeof(WCHAR
), NULL
, 0, 0, 0);
248 ok(hres
== E_INVALIDARG
, "ProcessUrlAction failed: %08x, expected E_INVALIDARG\n", hres
);
250 IInternetSecurityManager_Release(secmgr
);
253 /* Check if Internet Explorer is configured to run in "Enhanced Security Configuration" (aka hardened mode) */
254 /* Note: this code is duplicated in dlls/mshtml/tests/mshtml_test.h and dlls/urlmon/tests/sec_mgr.c */
255 static BOOL
is_ie_hardened(void)
258 DWORD ie_harden
, type
, size
;
261 if(RegOpenKeyExA(HKEY_CURRENT_USER
, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap",
262 0, KEY_QUERY_VALUE
, &zone_map
) == ERROR_SUCCESS
) {
263 size
= sizeof(DWORD
);
264 if (RegQueryValueExA(zone_map
, "IEHarden", NULL
, &type
, (LPBYTE
) &ie_harden
, &size
) != ERROR_SUCCESS
||
268 RegCloseKey(zone_map
);
271 return ie_harden
!= 0;
274 static void test_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
276 DWORD res
, size
, policy
, reg_policy
;
281 /* FIXME: HKEY_CURRENT_USER is most of the time the default but this can be changed on a system.
282 * The test should be changed to cope with that, if need be.
284 res
= RegOpenKeyA(HKEY_CURRENT_USER
,
285 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3", &hkey
);
286 if(res
!= ERROR_SUCCESS
) {
287 ok(0, "Could not open zone key\n");
291 wsprintf(buf
, "%X", action
);
292 size
= sizeof(DWORD
);
293 res
= RegQueryValueExA(hkey
, buf
, NULL
, NULL
, (BYTE
*)®_policy
, &size
);
295 if(res
!= ERROR_SUCCESS
|| size
!= sizeof(DWORD
)) {
297 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
298 sizeof(WCHAR
), NULL
, 0, 0, 0);
299 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
300 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
301 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
304 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
305 sizeof(DWORD
), URLZONEREG_DEFAULT
);
306 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
307 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
308 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
313 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
314 sizeof(DWORD
), URLZONEREG_DEFAULT
);
315 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
316 ok(policy
== reg_policy
, "(%x) policy=%x, expected %x\n", action
, policy
, reg_policy
);
318 if(policy
!= URLPOLICY_QUERY
) {
319 if(winetest_interactive
|| ! is_ie_hardened()) {
321 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
322 sizeof(WCHAR
), NULL
, 0, 0, 0);
323 if(reg_policy
== URLPOLICY_DISALLOW
)
324 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
326 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
327 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
330 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
332 if(reg_policy
== URLPOLICY_DISALLOW
)
333 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
335 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
336 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
339 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
340 sizeof(DWORD
), NULL
, 0, 0, 0);
341 if(reg_policy
== URLPOLICY_DISALLOW
)
342 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
344 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
345 ok(policy
== reg_policy
, "(%x) policy=%x\n", action
, policy
);
348 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url9
, action
, (BYTE
*)&policy
,
349 sizeof(WCHAR
), (BYTE
*)0xdeadbeef, 16, 0, 0);
350 if(reg_policy
== URLPOLICY_DISALLOW
)
351 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
353 ok(hres
== S_OK
, "ProcessUrlAction(%x) failed: %08x\n", action
, hres
);
354 ok(policy
== 0xdeadbeef, "(%x) policy=%x\n", action
, policy
);
356 skip("IE running in Enhanced Security Configuration\n");
361 static void test_special_url_action(IInternetSecurityManager
*secmgr
, IInternetZoneManager
*zonemgr
, DWORD action
)
367 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, (BYTE
*)&policy
,
368 sizeof(DWORD
), URLZONEREG_DEFAULT
);
369 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
370 ok(policy
== URLPOLICY_DISALLOW
, "(%x) policy=%x, expected URLPOLICY_DISALLOW\n", action
, policy
);
373 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
374 sizeof(WCHAR
), NULL
, 0, 0, 0);
375 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
378 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, action
, (BYTE
*)&policy
,
379 sizeof(DWORD
), NULL
, 0, 0, 0);
380 ok(hres
== S_FALSE
, "ProcessUrlAction(%x) failed: %08x, expected S_FALSE\n", action
, hres
);
381 ok(policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
384 static void test_activex(IInternetSecurityManager
*secmgr
)
386 DWORD policy
, policy_size
;
387 struct CONFIRMSAFETY cs
;
392 hres
= IInternetSecurityManager_ProcessUrlAction(secmgr
, url1
, URLACTION_ACTIVEX_RUN
, (BYTE
*)&policy
,
393 sizeof(DWORD
), (BYTE
*)&CLSID_TestActiveX
, sizeof(CLSID
), 0, 0);
394 ok(hres
== S_OK
, "ProcessUrlAction(URLACTION_ACTIVEX_RUN) failed: %08x\n", hres
);
395 ok(policy
== URLPOLICY_ALLOW
|| policy
== URLPOLICY_DISALLOW
, "policy = %x\n", policy
);
397 cs
.clsid
= CLSID_TestActiveX
;
398 cs
.pUnk
= (IUnknown
*)0xdeadbeef;
400 hres
= IInternetSecurityManager_QueryCustomPolicy(secmgr
, url1
, &GUID_CUSTOM_CONFIRMOBJECTSAFETY
,
401 &ppolicy
, &policy_size
, (BYTE
*)&cs
, sizeof(cs
), 0);
402 ok(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
), "QueryCusromPolicy failed: %08x\n", hres
);
405 static void test_polices(void)
407 IInternetZoneManager
*zonemgr
= NULL
;
408 IInternetSecurityManager
*secmgr
= NULL
;
411 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
412 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
413 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
414 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
416 test_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_RUN
);
417 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_RUN
);
418 test_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_OBJECT_SAFETY
);
419 test_url_action(secmgr
, zonemgr
, URLACTION_CHANNEL_SOFTDIST_PERMISSIONS
);
420 test_url_action(secmgr
, zonemgr
, 0xdeadbeef);
422 test_special_url_action(secmgr
, zonemgr
, URLACTION_SCRIPT_OVERRIDE_SAFETY
);
423 test_special_url_action(secmgr
, zonemgr
, URLACTION_ACTIVEX_OVERRIDE_SCRIPT_SAFETY
);
425 test_activex(secmgr
);
427 IInternetSecurityManager_Release(secmgr
);
428 IInternetZoneManager_Release(zonemgr
);
431 static void test_CoInternetCreateZoneManager(void)
433 IInternetZoneManager
*zonemgr
= NULL
;
434 IUnknown
*punk
= NULL
;
437 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
438 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
442 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IUnknown
, (void **) &punk
);
443 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
445 IUnknown_Release(punk
);
447 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManager
, (void **) &punk
);
448 ok(SUCCEEDED(hr
), "got 0x%x with %p (expected Success)\n", hr
, punk
);
450 IUnknown_Release(punk
);
453 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx
, (void **) &punk
);
455 IUnknown_Release(punk
);
457 hr
= IInternetZoneManager_QueryInterface(zonemgr
, &IID_IInternetZoneManagerEx2
, (void **) &punk
);
459 IUnknown_Release(punk
);
461 win_skip("InternetZoneManagerEx2 not supported\n");
465 win_skip("InternetZoneManagerEx not supported\n");
467 hr
= IInternetZoneManager_Release(zonemgr
);
468 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
472 static void test_CreateZoneEnumerator(void)
474 IInternetZoneManager
*zonemgr
= NULL
;
481 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
482 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
487 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, NULL
, 0);
488 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef),
489 "got 0x%x with 0x%x (expected E_INVALIDARG with 0xdeadbeef)\n", hr
, dwEnum
);
492 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, NULL
, &dwCount
, 0);
493 ok((hr
== E_INVALIDARG
) && (dwCount
== 0xdeadbeef),
494 "got 0x%x and 0x%x (expected E_INVALIDARG and 0xdeadbeef)\n", hr
, dwCount
);
498 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0xffffffff);
499 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
500 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
501 hr
, dwEnum
, dwCount
);
505 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 1);
506 ok((hr
== E_INVALIDARG
) && (dwEnum
== 0xdeadbeef) && (dwCount
== 0xdeadbeef),
507 "got 0x%x with 0x%x and 0x%x (expected E_INVALIDARG with 0xdeadbeef and 0xdeadbeef)\n",
508 hr
, dwEnum
, dwCount
);
513 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
514 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
519 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum2
, &dwCount2
, 0);
520 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
522 /* native urlmon has an incrementing counter for dwEnum */
523 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum2
);
524 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
527 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
528 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
530 /* Destroy the Enumerator twice is detected and handled in native urlmon */
531 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
532 ok((hr
== E_INVALIDARG
), "got 0x%x (expected E_INVALIDARG)\n", hr
);
535 /* ::Release succeed also, when a ::DestroyZoneEnumerator is missing */
536 hr
= IInternetZoneManager_Release(zonemgr
);
537 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
540 static void test_GetZoneActionPolicy(void)
542 IInternetZoneManager
*zonemgr
= NULL
;
545 DWORD action
= URLACTION_CREDENTIALS_USE
; /* Implemented on all IE versions */
547 hres
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
548 ok(hres
== S_OK
, "CoInternetCreateZoneManager failed: %08x\n", hres
);
552 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
553 sizeof(DWORD
), URLZONEREG_DEFAULT
);
554 ok(hres
== S_OK
, "GetZoneActionPolicy failed: %08x\n", hres
);
555 ok(*(DWORD
*)buf
== URLPOLICY_CREDENTIALS_SILENT_LOGON_OK
||
556 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_MUST_PROMPT_USER
||
557 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_CONDITIONAL_PROMPT
||
558 *(DWORD
*)buf
== URLPOLICY_CREDENTIALS_ANONYMOUS_ONLY
,
559 "unexpected policy=%d\n", *(DWORD
*)buf
);
561 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, NULL
,
562 sizeof(DWORD
), URLZONEREG_DEFAULT
);
563 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
565 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, action
, buf
,
566 2, URLZONEREG_DEFAULT
);
567 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
569 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 3, 0x1fff, buf
,
570 sizeof(DWORD
), URLZONEREG_DEFAULT
);
571 ok(hres
== E_FAIL
|| broken(hres
== HRESULT_FROM_WIN32(ERROR_NOT_FOUND
)),
572 "(0x%x) got 0x%x (expected E_FAIL)\n", action
, hres
);
574 hres
= IInternetZoneManager_GetZoneActionPolicy(zonemgr
, 13, action
, buf
,
575 sizeof(DWORD
), URLZONEREG_DEFAULT
);
576 ok(hres
== E_INVALIDARG
, "GetZoneActionPolicy failed: %08x, expected E_INVALIDARG\n", hres
);
578 IInternetZoneManager_Release(zonemgr
);
581 static void test_GetZoneAt(void)
583 IInternetZoneManager
*zonemgr
= NULL
;
590 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
591 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
595 hr
= IInternetZoneManager_CreateZoneEnumerator(zonemgr
, &dwEnum
, &dwCount
, 0);
600 /* this crashes with native urlmon */
601 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, 0, NULL
);
605 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, 0xdeadbeef, 0, &dwZone
);
606 ok(hr
== E_INVALIDARG
,
607 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
609 for (i
= 0; i
< dwCount
; i
++)
612 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, i
, &dwZone
);
613 ok(hr
== S_OK
, "#%d: got x%x with %d (expected S_OK)\n", i
, hr
, dwZone
);
617 /* MSDN (index .. must be .. less than or equal to) is wrong */
618 hr
= IInternetZoneManager_GetZoneAt(zonemgr
, dwEnum
, dwCount
, &dwZone
);
619 ok(hr
== E_INVALIDARG
,
620 "got 0x%x with 0x%x (expected E_INVALIDARG)\n", hr
, dwZone
);
622 hr
= IInternetZoneManager_DestroyZoneEnumerator(zonemgr
, dwEnum
);
623 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
626 hr
= IInternetZoneManager_Release(zonemgr
);
627 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
630 static void test_GetZoneAttributes(void)
632 IInternetZoneManager
*zonemgr
= NULL
;
633 CHAR buffer
[sizeof(ZONEATTRIBUTES
) + 32];
634 ZONEATTRIBUTES
* pZA
= (ZONEATTRIBUTES
*) buffer
;
638 hr
= pCoInternetCreateZoneManager(NULL
, &zonemgr
, 0);
639 ok(hr
== S_OK
, "CoInternetCreateZoneManager result: 0x%x\n", hr
);
643 /* native urlmon has Zone "0" up to Zone "4" since IE4 */
644 for (i
= 0; i
< 5; i
++) {
645 memset(buffer
, -1, sizeof(buffer
));
646 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, i
, pZA
);
647 ok(hr
== S_OK
, "#%d: got 0x%x (expected S_OK)\n", i
, hr
);
650 /* IE8 no longer set cbSize */
651 memset(buffer
, -1, sizeof(buffer
));
653 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
654 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
655 ok((pZA
->cbSize
== 0) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
656 "got cbSize = %d (expected 0)\n", pZA
->cbSize
);
658 memset(buffer
, -1, sizeof(buffer
));
660 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
661 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
662 ok((pZA
->cbSize
== 64) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
663 "got cbSize = %d (expected 64)\n", pZA
->cbSize
);
665 memset(buffer
, -1, sizeof(buffer
));
666 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, pZA
);
667 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
668 ok((pZA
->cbSize
== 0xffffffff) || (pZA
->cbSize
== sizeof(ZONEATTRIBUTES
)),
669 "got cbSize = 0x%x (expected 0xffffffff)\n", pZA
->cbSize
);
671 /* IE8 no longer fail on invalid zones */
672 memset(buffer
, -1, sizeof(buffer
));
673 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0xdeadbeef, pZA
);
674 ok(hr
== S_OK
|| (hr
== E_FAIL
),
675 "got 0x%x (expected S_OK or E_FAIL)\n", hr
);
677 hr
= IInternetZoneManager_GetZoneAttributes(zonemgr
, 0, NULL
);
678 ok(hr
== E_INVALIDARG
, "got 0x%x (expected E_INVALIDARG)\n", hr
);
680 hr
= IInternetZoneManager_Release(zonemgr
);
681 ok(hr
== S_OK
, "got 0x%x (expected S_OK)\n", hr
);
684 static void test_InternetSecurityMarshalling(void)
686 IInternetSecurityManager
*secmgr
= NULL
;
691 hres
= pCoInternetCreateSecurityManager(NULL
, &secmgr
, 0);
692 ok(hres
== S_OK
, "CoInternetCreateSecurityManager failed: %08x\n", hres
);
696 hres
= IInternetSecurityManager_QueryInterface(secmgr
, &IID_IUnknown
, (void**)&unk
);
697 ok(hres
== S_OK
, "QueryInterface returned: %08x\n", hres
);
699 hres
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
700 ok(hres
== S_OK
, "CreateStreamOnHGlobal returned: %08x\n", hres
);
702 hres
= CoMarshalInterface(stream
, &IID_IInternetSecurityManager
, unk
, MSHCTX_INPROC
, NULL
, MSHLFLAGS_NORMAL
);
703 /* Not supported in W98 */
704 ok(hres
== S_OK
|| broken(hres
== REGDB_E_IIDNOTREG
),
705 "CoMarshalInterface returned: %08x\n", hres
);
707 IStream_Release(stream
);
708 IUnknown_Release(unk
);
709 IInternetSecurityManager_Release(secmgr
);
712 static void test_InternetGetSecurityUrl(void)
714 const WCHAR url5_out
[] = {'h','t','t','p',':','w','w','w','.','z','o','n','e','3',
715 '.','w','i','n','e','t','e','s','t',0};
716 const WCHAR url7_out
[] = {'f','t','p',':','z','o','n','e','3','.','w','i','n','e','t','e','s','t',0};
718 const WCHAR
*in
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
719 const WCHAR
*out_default
[] = {url2
, url3
, url4
, url5_out
, url7_out
, url8
, url5_out
, url10
};
720 const WCHAR
*out_securl
[] = {url2
, url3
, url4
, url5
, url7
, url8
, url9
, url10
};
726 for(i
=0; i
<sizeof(in
)/sizeof(WCHAR
*); i
++) {
727 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_DEFAULT
, 0);
728 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
730 ok(!strcmp_w(sec
, out_default
[i
]), "(%d) Got %s, expected %s\n",
731 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_default
[i
]));
735 hres
= pCoInternetGetSecurityUrl(in
[i
], &sec
, PSU_SECURITY_URL_ONLY
, 0);
736 ok(hres
== S_OK
, "(%d) CoInternetGetSecurityUrl returned: %08x\n", i
, hres
);
738 ok(!strcmp_w(sec
, out_securl
[i
]), "(%d) Got %s, expected %s\n",
739 i
, wine_dbgstr_w(sec
), wine_dbgstr_w(out_securl
[i
]));
745 static HRESULT WINAPI
InternetProtocolInfo_QueryInterface(IInternetProtocolInfo
*iface
,
746 REFIID riid
, void **ppv
)
748 ok(0, "unexpected call\n");
749 return E_NOINTERFACE
;
752 static ULONG WINAPI
InternetProtocolInfo_AddRef(IInternetProtocolInfo
*iface
)
757 static ULONG WINAPI
InternetProtocolInfo_Release(IInternetProtocolInfo
*iface
)
762 static HRESULT WINAPI
InternetProtocolInfo_ParseUrl(IInternetProtocolInfo
*iface
, LPCWSTR pwzUrl
,
763 PARSEACTION ParseAction
, DWORD dwParseFlags
, LPWSTR pwzResult
, DWORD cchResult
,
764 DWORD
*pcchResult
, DWORD dwReserved
)
766 switch(ParseAction
) {
767 case PARSE_SECURITY_URL
:
768 if(!strcmp_w(pwzUrl
, security_urlW
)) {
769 CHECK_EXPECT(ParseUrl_SECURITY_URL_input
);
771 ok(cchResult
== lstrlenW(security_urlW
)+1, "Got %d\n", cchResult
);
772 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
773 } else if(!strcmp_w(pwzUrl
, security_expectedW
)) {
774 CHECK_EXPECT(ParseUrl_SECURITY_URL_expected
);
776 ok(cchResult
== lstrlenW(security_expectedW
)+1, "Got %d\n", cchResult
);
777 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
779 ok(0, "Unexpected call, pwzUrl=%s\n", wine_dbgstr_w(pwzUrl
));
782 case PARSE_SECURITY_DOMAIN
:
783 CHECK_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
785 ok(!strcmp_w(pwzUrl
, security_expectedW
), "Expected %s but got %s\n",
786 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(pwzUrl
));
787 ok(!dwParseFlags
, "Expected 0, but got 0x%08x\n", dwParseFlags
);
788 ok(cchResult
== lstrlenW(security_expectedW
)+1, "Got %d\n", cchResult
);
792 ok(0, "Unexpected call, ParseAction=%d pwzUrl=%s\n", ParseAction
,
793 wine_dbgstr_w(pwzUrl
));
796 memcpy(pwzResult
, security_expectedW
, sizeof(security_expectedW
));
797 *pcchResult
= lstrlenW(security_expectedW
);
802 static HRESULT WINAPI
InternetProtocolInfo_CombineUrl(IInternetProtocolInfo
*iface
,
803 LPCWSTR pwzBaseUrl
, LPCWSTR pwzRelativeUrl
, DWORD dwCombineFlags
,
804 LPWSTR pwzResult
, DWORD cchResult
, DWORD
*pcchResult
, DWORD dwReserved
)
806 ok(0, "unexpected call\n");
810 static HRESULT WINAPI
InternetProtocolInfo_CompareUrl(IInternetProtocolInfo
*iface
,
811 LPCWSTR pwzUrl1
, LPCWSTR pwzUrl2
, DWORD dwCompareFlags
)
813 ok(0, "unexpected call\n");
817 static HRESULT WINAPI
InternetProtocolInfo_QueryInfo(IInternetProtocolInfo
*iface
,
818 LPCWSTR pwzUrl
, QUERYOPTION OueryOption
, DWORD dwQueryFlags
, LPVOID pBuffer
,
819 DWORD cbBuffer
, DWORD
*pcbBuf
, DWORD dwReserved
)
821 ok(0, "unexpected call\n");
825 static const IInternetProtocolInfoVtbl InternetProtocolInfoVtbl
= {
826 InternetProtocolInfo_QueryInterface
,
827 InternetProtocolInfo_AddRef
,
828 InternetProtocolInfo_Release
,
829 InternetProtocolInfo_ParseUrl
,
830 InternetProtocolInfo_CombineUrl
,
831 InternetProtocolInfo_CompareUrl
,
832 InternetProtocolInfo_QueryInfo
835 static IInternetProtocolInfo protocol_info
= { &InternetProtocolInfoVtbl
};
837 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
839 if(IsEqualGUID(&IID_IInternetProtocolInfo
, riid
)) {
840 *ppv
= &protocol_info
;
844 ok(0, "unexpected call\n");
845 return E_NOINTERFACE
;
848 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
853 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
858 static HRESULT WINAPI
ClassFactory_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
859 REFIID riid
, void **ppv
)
861 ok(0, "unexpected call\n");
865 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL dolock
)
867 ok(0, "unexpected call\n");
871 static const IClassFactoryVtbl ClassFactoryVtbl
= {
872 ClassFactory_QueryInterface
,
874 ClassFactory_Release
,
875 ClassFactory_CreateInstance
,
876 ClassFactory_LockServer
879 static IClassFactory protocol_cf
= { &ClassFactoryVtbl
};
881 static void register_protocols(void)
883 IInternetSession
*session
;
886 hres
= pCoInternetGetSession(0, &session
, 0);
887 ok(hres
== S_OK
, "CoInternetGetSession failed: %08x\n", hres
);
891 hres
= IInternetSession_RegisterNameSpace(session
, &protocol_cf
, &IID_NULL
,
892 winetestW
, 0, NULL
, 0);
893 ok(hres
== S_OK
, "RegisterNameSpace failed: %08x\n", hres
);
895 IInternetSession_Release(session
);
898 static void unregister_protocols(void) {
899 IInternetSession
*session
;
902 hr
= pCoInternetGetSession(0, &session
, 0);
903 ok(hr
== S_OK
, "CoInternetGetSession failed: 0x%08x\n", hr
);
907 hr
= IInternetSession_UnregisterNameSpace(session
, &protocol_cf
, winetestW
);
908 ok(hr
== S_OK
, "UnregisterNameSpace failed: 0x%08x\n", hr
);
910 IInternetSession_Release(session
);
913 static const struct {
916 const char *security_uri
;
917 HRESULT security_hres
;
918 const char *default_uri
;
919 HRESULT default_hres
;
921 } sec_url_ex_tests
[] = {
922 {"index.htm",Uri_CREATE_ALLOW_RELATIVE
,"*:index.html",S_OK
,"*:index.htm",S_OK
},
923 {"file://c:\\Index.htm",Uri_CREATE_FILE_USE_DOS_PATH
,"file:///c:/Index.htm",S_OK
,"file:///c:/Index.htm",S_OK
},
924 {"file:some%20file%2ejpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
925 {"file:some file.jpg",0,NULL
,E_INVALIDARG
,NULL
,E_INVALIDARG
},
926 {"http://www.zone3.winetest/",0,"http://www.zone3.winetest/",S_OK
,"http://www.zone3.winetest/",S_OK
},
927 {"about:blank",0,"about:blank",S_OK
,"about:blank",S_OK
},
928 {"ftp://zone3.winetest/file.test",0,"ftp://zone3.winetest/file.test",S_OK
,"ftp://zone3.winetest/file.test",S_OK
},
929 {"test:123abc",0,"test:123abc",S_OK
,"test:123abc",S_OK
},
930 {"http:google.com/test.file",0,"http:google.com/test.file",S_OK
,"http:google.com/test.file",S_OK
},
931 {"ftp://test@ftp.winehq.org/",0,"ftp://ftp.winehq.org/",S_OK
,"ftp://ftp.winehq.org/",S_OK
},
932 {"test://google@ftp.winehq.org/",0,"test://google@ftp.winehq.org/",S_OK
,"test://google@ftp.winehq.org/",S_OK
}
935 static void test_InternetGetSecurityUrlEx(void)
939 IUri
*uri
= NULL
, *result
= NULL
;
941 hr
= pCoInternetGetSecurityUrlEx(NULL
, NULL
, PSU_DEFAULT
, 0);
942 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
944 result
= (void*) 0xdeadbeef;
945 hr
= pCoInternetGetSecurityUrlEx(NULL
, &result
, PSU_DEFAULT
, 0);
946 ok(hr
== E_INVALIDARG
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected E_INVALIDARG\n", hr
);
947 ok(result
== (void*) 0xdeadbeef, "'result' was %p\n", result
);
949 for(i
= 0; i
< sizeof(sec_url_ex_tests
)/sizeof(sec_url_ex_tests
[0]); ++i
) {
950 LPWSTR uriW
= a2w(sec_url_ex_tests
[i
].uri
);
953 hr
= pCreateUri(uriW
, sec_url_ex_tests
[i
].create_flags
, 0, &uri
);
954 ok(hr
== S_OK
, "CreateUri returned 0x%08x on test %d\n", hr
, i
);
958 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
959 if(sec_url_ex_tests
[i
].todo
) {
961 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
962 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
963 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
965 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
966 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
967 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
972 hr
= IUri_GetDisplayUri(result
, &received
);
973 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
975 if(sec_url_ex_tests
[i
].todo
) {
977 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
978 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
979 wine_dbgstr_w(received
), i
);
981 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
982 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
983 wine_dbgstr_w(received
), i
);
986 SysFreeString(received
);
988 if(result
) IUri_Release(result
);
991 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
992 if(sec_url_ex_tests
[i
].todo
) {
994 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
995 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
996 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
998 ok(hr
== sec_url_ex_tests
[i
].default_hres
,
999 "CoInternetGetSecurityUrlEx returned 0x%08x, expected 0x%08x on test %d\n",
1000 hr
, sec_url_ex_tests
[i
].default_hres
, i
);
1005 hr
= IUri_GetDisplayUri(result
, &received
);
1006 ok(hr
== S_OK
, "GetDisplayUri returned 0x%08x on test %d\n", hr
, i
);
1008 if(sec_url_ex_tests
[i
].todo
) {
1010 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1011 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1012 wine_dbgstr_w(received
), i
);
1014 ok(!strcmp_aw(sec_url_ex_tests
[i
].default_uri
, received
),
1015 "Expected %s but got %s on test %d\n", sec_url_ex_tests
[i
].default_uri
,
1016 wine_dbgstr_w(received
), i
);
1019 SysFreeString(received
);
1021 if(result
) IUri_Release(result
);
1024 if(uri
) IUri_Release(uri
);
1029 static void test_InternetGetSecurityUrlEx_Pluggable(void)
1034 register_protocols();
1036 hr
= pCreateUri(security_urlW
, 0, 0, &uri
);
1037 ok(hr
== S_OK
, "CreateUri returned 0x%08x\n", hr
);
1039 IUri
*result
= NULL
;
1041 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1042 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1043 SET_EXPECT(ParseUrl_SECURITY_DOMAIN_expected
);
1045 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_DEFAULT
, 0);
1046 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1048 todo_wine
CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1049 todo_wine
CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1050 todo_wine
CHECK_CALLED(ParseUrl_SECURITY_DOMAIN_expected
);
1053 BSTR received
= NULL
;
1055 hr
= IUri_GetAbsoluteUri(result
, &received
);
1056 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1059 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1060 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1062 SysFreeString(received
);
1064 if(result
) IUri_Release(result
);
1068 SET_EXPECT(ParseUrl_SECURITY_URL_input
);
1069 SET_EXPECT(ParseUrl_SECURITY_URL_expected
);
1071 hr
= pCoInternetGetSecurityUrlEx(uri
, &result
, PSU_SECURITY_URL_ONLY
, 0);
1072 ok(hr
== S_OK
, "CoInternetGetSecurityUrlEx returned 0x%08x, expected S_OK\n", hr
);
1074 todo_wine
CHECK_CALLED(ParseUrl_SECURITY_URL_input
);
1075 todo_wine
CHECK_CALLED(ParseUrl_SECURITY_URL_expected
);
1078 BSTR received
= NULL
;
1080 hr
= IUri_GetAbsoluteUri(result
, &received
);
1081 ok(hr
== S_OK
, "GetAbsoluteUri returned 0x%08x\n", hr
);
1084 ok(!strcmp_w(security_expectedW
, received
), "Expected %s but got %s\n",
1085 wine_dbgstr_w(security_expectedW
), wine_dbgstr_w(received
));
1087 SysFreeString(received
);
1089 if(result
) IUri_Release(result
);
1091 if(uri
) IUri_Release(uri
);
1093 unregister_protocols();
1100 hurlmon
= GetModuleHandle("urlmon.dll");
1101 pCoInternetCreateSecurityManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateSecurityManager");
1102 pCoInternetCreateZoneManager
= (void*) GetProcAddress(hurlmon
, "CoInternetCreateZoneManager");
1103 pCoInternetGetSecurityUrl
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrl");
1104 pCoInternetGetSecurityUrlEx
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSecurityUrlEx");
1105 pCreateUri
= (void*) GetProcAddress(hurlmon
, "CreateUri");
1106 pCoInternetGetSession
= (void*) GetProcAddress(hurlmon
, "CoInternetGetSession");
1108 if (!pCoInternetCreateSecurityManager
|| !pCoInternetCreateZoneManager
||
1109 !pCoInternetGetSecurityUrl
) {
1110 win_skip("Various CoInternet* functions not present in IE 4.0\n");
1114 OleInitialize(NULL
);
1116 test_InternetGetSecurityUrl();
1118 if(!pCoInternetGetSecurityUrlEx
|| !pCreateUri
)
1119 win_skip("Skipping CoInternetGetSecurityUrlEx tests, IE too old\n");
1121 test_InternetGetSecurityUrlEx();
1122 test_InternetGetSecurityUrlEx_Pluggable();
1125 test_SecurityManager();
1127 test_CoInternetCreateZoneManager();
1128 test_CreateZoneEnumerator();
1129 test_GetZoneActionPolicy();
1131 test_GetZoneAttributes();
1132 test_InternetSecurityMarshalling();