[MSHTML_WINETEST]
[reactos.git] / rostests / winetests / mshtml / protocol.c
1 /*
2 * Copyright 2005 Jacek Caban
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 #define COBJMACROS
20
21 #include <wine/test.h>
22 //#include <stdarg.h>
23 #include <stdio.h>
24
25 //#include "windef.h"
26 //#include "winbase.h"
27 //#include "ole2.h"
28 #include <urlmon.h>
29 #include <shlwapi.h>
30 #include <wininet.h>
31
32 #include <initguid.h>
33
34 #define DEFINE_EXPECT(func) \
35 static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
36
37 #define SET_EXPECT(func) \
38 expect_ ## func = TRUE
39
40 #define CHECK_EXPECT(func) \
41 do { \
42 ok(expect_ ##func, "unexpected call " #func "\n"); \
43 expect_ ## func = FALSE; \
44 called_ ## func = TRUE; \
45 }while(0)
46
47 #define CHECK_EXPECT2(func) \
48 do { \
49 ok(expect_ ##func, "unexpected call " #func "\n"); \
50 called_ ## func = TRUE; \
51 }while(0)
52
53 #define CHECK_CALLED(func) \
54 do { \
55 ok(called_ ## func, "expected " #func "\n"); \
56 expect_ ## func = called_ ## func = FALSE; \
57 }while(0)
58
59 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
60 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
61 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
62
63 DEFINE_EXPECT(GetBindInfo);
64 DEFINE_EXPECT(ReportProgress);
65 DEFINE_EXPECT(ReportData);
66 DEFINE_EXPECT(ReportResult);
67
68 static HRESULT expect_hrResult;
69 static BOOL expect_hr_win32err = FALSE;
70 static DWORD bindf;
71
72 static const WCHAR about_blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
73 static const WCHAR about_test_url[] = {'a','b','o','u','t',':','t','e','s','t',0};
74 static const WCHAR about_res_url[] = {'r','e','s',':','b','l','a','n','k',0};
75 static const WCHAR javascript_test_url[] = {'j','a','v','a','s','c','r','i','p','t',':','t','e','s','t','(',')',0};
76
77 static WCHAR res_url_base[INTERNET_MAX_URL_LENGTH] = {'r','e','s',':','/','/'};
78 static unsigned res_url_base_len;
79
80 static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
81 {
82 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetProtocolSink, riid)) {
83 *ppv = iface;
84 return S_OK;
85 }
86
87 *ppv = NULL;
88 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
89 return E_NOINTERFACE;
90 }
91
92 static ULONG WINAPI ProtocolSink_AddRef(IInternetProtocolSink *iface)
93 {
94 return 2;
95 }
96
97 static ULONG WINAPI ProtocolSink_Release(IInternetProtocolSink *iface)
98 {
99 return 1;
100 }
101
102 static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOLDATA *pProtocolData)
103 {
104 ok(0, "unexpected call\n");
105 return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
109 LPCWSTR szStatusText)
110 {
111 static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
112
113 CHECK_EXPECT(ReportProgress);
114
115 ok(ulStatusCode == BINDSTATUS_MIMETYPEAVAILABLE
116 || ulStatusCode == BINDSTATUS_VERIFIEDMIMETYPEAVAILABLE,
117 "ulStatusCode=%d\n", ulStatusCode);
118 ok(!lstrcmpW(szStatusText, text_html), "szStatusText != text/html\n");
119
120 return S_OK;
121 }
122
123 static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress,
124 ULONG ulProgressMax)
125 {
126 CHECK_EXPECT(ReportData);
127
128 ok(ulProgress == ulProgressMax, "ulProgress != ulProgressMax\n");
129 ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE),
130 "grcf = %08x\n", grfBSCF);
131
132 return S_OK;
133 }
134
135 static HRESULT WINAPI ProtocolSink_ReportResult(IInternetProtocolSink *iface, HRESULT hrResult, DWORD dwError,
136 LPCWSTR szResult)
137 {
138 CHECK_EXPECT(ReportResult);
139
140 if(expect_hr_win32err) {
141 ok((hrResult&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || expect_hrResult,
142 "expected win32 err or %08x got: %08x\n", expect_hrResult, hrResult);
143 }else {
144 ok(hrResult == expect_hrResult || (expect_hrResult == E_INVALIDARG && hrResult == MK_E_SYNTAX)
145 || (expect_hrResult == HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND) &&
146 (hrResult == MK_E_SYNTAX || hrResult == HRESULT_FROM_WIN32(ERROR_DLL_NOT_FOUND))),
147 "expected: %08x got: %08x\n", expect_hrResult, hrResult);
148 expect_hrResult = hrResult;
149 }
150 ok(dwError == 0, "dwError = %d\n", dwError);
151 ok(!szResult, "szResult != NULL\n");
152
153 return S_OK;
154 }
155
156 static IInternetProtocolSinkVtbl protocol_sink_vtbl = {
157 ProtocolSink_QueryInterface,
158 ProtocolSink_AddRef,
159 ProtocolSink_Release,
160 ProtocolSink_Switch,
161 ProtocolSink_ReportProgress,
162 ProtocolSink_ReportData,
163 ProtocolSink_ReportResult
164 };
165
166 static IInternetProtocolSink protocol_sink = {
167 &protocol_sink_vtbl
168 };
169
170 static HRESULT WINAPI BindInfo_QueryInterface(IInternetBindInfo *iface, REFIID riid, void **ppv)
171 {
172 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetBindInfo, riid)) {
173 *ppv = iface;
174 return S_OK;
175 }
176
177 *ppv = NULL;
178 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
179 return E_NOINTERFACE;
180 }
181
182 static ULONG WINAPI BindInfo_AddRef(IInternetBindInfo *iface)
183 {
184 return 2;
185 }
186
187 static ULONG WINAPI BindInfo_Release(IInternetBindInfo *iface)
188 {
189 return 1;
190 }
191
192 static HRESULT WINAPI BindInfo_GetBindInfo(IInternetBindInfo *iface, DWORD *grfBINDF, BINDINFO *pbindinfo)
193 {
194 CHECK_EXPECT(GetBindInfo);
195
196 ok(grfBINDF != NULL, "grfBINDF == NULL\n");
197 ok(pbindinfo != NULL, "pbindinfo == NULL\n");
198 ok(pbindinfo->cbSize == sizeof(BINDINFO), "wrong size of pbindinfo: %d\n", pbindinfo->cbSize);
199
200 *grfBINDF = bindf;
201 return S_OK;
202 }
203
204 static HRESULT WINAPI BindInfo_GetBindString(IInternetBindInfo *iface, ULONG ulStringType, LPOLESTR *ppwzStr,
205 ULONG cEl, ULONG *pcElFetched)
206 {
207 ok(0, "unexpected call\n");
208 return E_NOTIMPL;
209 }
210
211 static IInternetBindInfoVtbl bind_info_vtbl = {
212 BindInfo_QueryInterface,
213 BindInfo_AddRef,
214 BindInfo_Release,
215 BindInfo_GetBindInfo,
216 BindInfo_GetBindString
217 };
218
219 static IInternetBindInfo bind_info = {
220 &bind_info_vtbl
221 };
222
223 static void test_protocol_fail(IInternetProtocol *protocol, LPCWSTR url, HRESULT expected_hres,
224 BOOL expect_win32err)
225 {
226 HRESULT hres;
227
228 SET_EXPECT(GetBindInfo);
229 SET_EXPECT(ReportResult);
230
231 expect_hrResult = expected_hres;
232 expect_hr_win32err = expect_win32err;
233 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
234 if(expect_win32err)
235 ok((hres&0xffff0000) == ((FACILITY_WIN32 << 16)|0x80000000) || hres == expect_hrResult,
236 "expected win32 err or %08x got: %08x\n", expected_hres, hres);
237 else
238 ok(hres == expect_hrResult, "expected: %08x got: %08x\n", expect_hrResult, hres);
239
240 CHECK_CALLED(GetBindInfo);
241 CHECK_CALLED(ReportResult);
242 }
243
244 static void protocol_start(IInternetProtocol *protocol, const WCHAR *url)
245 {
246 HRESULT hres;
247
248 SET_EXPECT(GetBindInfo);
249 SET_EXPECT(ReportResult);
250 SET_EXPECT(ReportProgress);
251 SET_EXPECT(ReportData);
252 expect_hrResult = S_OK;
253 expect_hr_win32err = FALSE;
254
255 hres = IInternetProtocol_Start(protocol, url, &protocol_sink, &bind_info, 0, 0);
256 ok(hres == S_OK, "Start failed: %08x\n", hres);
257
258 CHECK_CALLED(GetBindInfo);
259 CHECK_CALLED(ReportProgress);
260 CHECK_CALLED(ReportData);
261 CHECK_CALLED(ReportResult);
262 }
263
264 static void test_res_url(const char *url_suffix)
265 {
266 WCHAR url[INTERNET_MAX_URL_LENGTH];
267 IInternetProtocol *protocol;
268 ULONG size, ref;
269 BYTE buf[100];
270 HRESULT hres;
271
272 memcpy(url, res_url_base, res_url_base_len*sizeof(WCHAR));
273 MultiByteToWideChar(CP_ACP, 0, url_suffix, -1, url+res_url_base_len, sizeof(url)/sizeof(WCHAR)-res_url_base_len);
274
275 hres = CoCreateInstance(&CLSID_ResProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&protocol);
276 ok(hres == S_OK, "Could not create ResProtocol instance: %08x\n", hres);
277
278 protocol_start(protocol, url);
279
280 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &size);
281 ok(hres == S_OK, "Read failed: %08x\n", hres);
282
283 hres = IInternetProtocol_Terminate(protocol, 0);
284 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
285
286
287 ref = IInternetProtocol_Release(protocol);
288 ok(!ref, "ref=%u\n", ref);
289 }
290
291 static void res_sec_url_cmp(LPCWSTR url, DWORD size, LPCWSTR file)
292 {
293 WCHAR buf[MAX_PATH];
294 DWORD len;
295
296 static const WCHAR fileW[] = {'f','i','l','e',':','/','/'};
297
298 if(size < sizeof(fileW)/sizeof(WCHAR) || memcmp(url, fileW, sizeof(fileW))) {
299 ok(0, "wrong URL protocol\n");
300 return;
301 }
302
303 SetLastError(0xdeadbeef);
304 len = SearchPathW(NULL, file, NULL, sizeof(buf)/sizeof(WCHAR), buf, NULL);
305 if(!len) {
306 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
307 win_skip("SearchPathW is not implemented\n");
308 else
309 ok(0, "SearchPath failed: %u\n", GetLastError());
310 return;
311 }
312
313 len += sizeof(fileW)/sizeof(WCHAR)+1;
314 ok(len == size, "wrong size %u, expected %u\n", size, len);
315 ok(!lstrcmpW(url + sizeof(fileW)/sizeof(WCHAR), buf), "wrong file part %s\n", wine_dbgstr_w(url));
316 }
317
318 static void test_res_protocol(void)
319 {
320 IInternetProtocolInfo *protocol_info;
321 IUnknown *unk;
322 IClassFactory *factory;
323 HRESULT hres;
324
325 static const WCHAR blank_url[] =
326 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
327 static const WCHAR test_part_url[] = {'r','e','s',':','/','/','C','S','S','/','t','e','s','t',0};
328 static const WCHAR wrong_url1[] =
329 {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0};
330 static const WCHAR wrong_url2[] =
331 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0};
332 static const WCHAR wrong_url3[] =
333 {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0};
334 static const WCHAR wrong_url4[] =
335 {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
336 static const WCHAR wrong_url5[] =
337 {'r','e','s',':','/','/','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
338 static const WCHAR wrong_url6[] =
339 {'r','e','s',':','/','/','c',':','\\','d','i','r','\\','f','i','l','e','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0};
340 static const WCHAR mshtml_dllW[] = {'m','s','h','t','m','l','.','d','l','l',0};
341
342 hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
343 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
344 if(FAILED(hres))
345 return;
346
347 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
348 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres);
349 if(SUCCEEDED(hres)) {
350 WCHAR buf[128];
351 DWORD size, expected_size;
352 int i;
353
354 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
355 if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
356 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf,
357 sizeof(buf)/sizeof(buf[0]), &size, 0);
358 ok(hres == INET_E_DEFAULT_ACTION,
359 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres);
360 }
361 }
362
363 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
364 sizeof(buf)/sizeof(buf[0]), &size, 0);
365 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
366 res_sec_url_cmp(buf, size, mshtml_dllW);
367 ok(size == lstrlenW(buf)+1, "size = %d\n", size);
368 expected_size = size;
369
370 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
371 expected_size, &size, 0);
372 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
373 res_sec_url_cmp(buf, size, mshtml_dllW);
374 ok(size == expected_size, "size = %d\n", size);
375
376 size = 0;
377 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf,
378 3, &size, 0);
379 ok(hres == S_FALSE, "ParseUrl failed: %08x, expected S_FALSE\n", hres);
380 ok(size == expected_size, "size = %d\n", size);
381
382 hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf,
383 sizeof(buf)/sizeof(buf[0]), &size, 0);
384 ok(hres == MK_E_SYNTAX || hres == E_INVALIDARG,
385 "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
386
387 hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url5, PARSE_SECURITY_URL, 0, buf,
388 sizeof(buf)/sizeof(buf[0]), &size, 0);
389 ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
390
391 hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url6, PARSE_SECURITY_URL, 0, buf,
392 sizeof(buf)/sizeof(buf[0]), &size, 0);
393 ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres);
394
395 size = 0xdeadbeef;
396 buf[0] = '?';
397 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
398 sizeof(buf)/sizeof(buf[0]), &size, 0);
399 ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
400 ok(buf[0] == '?', "buf changed\n");
401 ok(size == sizeof(blank_url)/sizeof(WCHAR) ||
402 size == sizeof(buf)/sizeof(buf[0]), /* IE8 */
403 "size=%d\n", size);
404
405 size = 0xdeadbeef;
406 hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf,
407 sizeof(buf)/sizeof(buf[0]), &size, 0);
408 ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
409 ok(buf[0] == '?', "buf changed\n");
410 ok(size == sizeof(wrong_url1)/sizeof(WCHAR) ||
411 size == sizeof(buf)/sizeof(buf[0]), /* IE8 */
412 "size=%d\n", size);
413
414 if (0)
415 {
416 /* Crashes on windows */
417 size = 0xdeadbeef;
418 buf[0] = '?';
419 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
420 sizeof(buf)/sizeof(buf[0]), &size, 0);
421 ok(hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
422 ok(buf[0] == '?', "buf changed\n");
423 ok(size == 1, "size=%u, expected 1\n", size);
424
425 buf[0] = '?';
426 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf,
427 sizeof(buf)/sizeof(buf[0]), NULL, 0);
428 ok(hres == E_POINTER, "ParseUrl failed: %08x\n", hres);
429 ok(buf[0] == '?', "buf changed\n");
430
431 buf[0] = '?';
432 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
433 sizeof(buf)/sizeof(buf[0]), NULL, 0);
434 ok(hres == E_POINTER, "ParseUrl failed: %08x\n", hres);
435 ok(buf[0] == '?', "buf changed\n");
436 }
437
438 buf[0] = '?';
439 hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf,
440 sizeof(buf)/sizeof(buf[0]), &size, 0);
441 ok(hres == INET_E_DEFAULT_ACTION,
442 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres);
443 ok(buf[0] == '?', "buf changed\n");
444
445 size = 0xdeadbeef;
446 hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url,
447 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
448 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
449 ok(size == 0xdeadbeef, "size=%d\n", size);
450
451 size = 0xdeadbeef;
452 hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url,
453 URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
454 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
455 ok(size == 0xdeadbeef, "size=%d\n", size);
456
457 size = 0xdeadbeef;
458 hres = IInternetProtocolInfo_CombineUrl(protocol_info, NULL, NULL,
459 URL_FILE_USE_PATHURL, NULL, 0xdeadbeef, NULL, 0);
460 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
461 ok(size == 0xdeadbeef, "size=%d\n", size);
462
463 hres = IInternetProtocolInfo_CompareUrl(protocol_info, blank_url, blank_url, 0);
464 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
465
466 hres = IInternetProtocolInfo_CompareUrl(protocol_info, NULL, NULL, 0xdeadbeef);
467 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
468
469 for(i=0; i<30; i++) {
470 if(i == QUERY_USES_NETWORK || i == QUERY_IS_SECURE || i == QUERY_IS_SAFE)
471 continue;
472
473 hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, i, 0,
474 buf, sizeof(buf), &size, 0);
475 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
476 "QueryInfo(%d) returned: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", i, hres);
477 }
478
479 size = 0xdeadbeef;
480 memset(buf, '?', sizeof(buf));
481 hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0,
482 buf, sizeof(buf), &size, 0);
483 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
484 ok(size == sizeof(DWORD), "size=%d\n", size);
485 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
486
487 memset(buf, '?', sizeof(buf));
488 hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0,
489 buf, sizeof(buf), NULL, 0);
490 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
491 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
492
493 hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0,
494 buf, 3, &size, 0);
495 ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres);
496
497 size = 0xdeadbeef;
498 memset(buf, '?', sizeof(buf));
499 hres = IInternetProtocolInfo_QueryInfo(protocol_info, NULL, QUERY_USES_NETWORK, 0,
500 buf, sizeof(buf), &size, 0);
501 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
502 ok(size == sizeof(DWORD), "size=%d\n", size);
503 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
504
505 hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0,
506 NULL, sizeof(buf), &size, 0);
507 ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres);
508
509 hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, 60, 0,
510 NULL, sizeof(buf), &size, 0);
511 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
512 "QueryInfo failed: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres);
513
514 IInternetProtocolInfo_Release(protocol_info);
515 }
516
517 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
518 ok(hres == S_OK, "Could not get IClassFactory interface\n");
519 if(SUCCEEDED(hres)) {
520 IInternetProtocol *protocol;
521 BYTE buf[512];
522 ULONG cb;
523 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
524 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
525
526 if(SUCCEEDED(hres)) {
527 IInternetPriority *priority;
528
529 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
530 ok(hres == E_NOINTERFACE,
531 "QueryInterface(IInternetPriority) returned %08x, expected E_NOINTEFACE\n", hres);
532
533 test_protocol_fail(protocol, wrong_url1, E_INVALIDARG, FALSE);
534 test_protocol_fail(protocol, wrong_url2,
535 HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), FALSE);
536 test_protocol_fail(protocol, wrong_url3, E_FAIL, TRUE);
537 test_protocol_fail(protocol, wrong_url4, E_FAIL, TRUE);
538
539 cb = 0xdeadbeef;
540 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
541 ok(hres == E_FAIL, "Read returned %08x expected E_FAIL\n", hres);
542 ok(cb == 0xdeadbeef, "cb=%u expected 0xdeadbeef\n", cb);
543
544 protocol_start(protocol, blank_url);
545 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
546 ok(hres == S_OK, "Read failed: %08x\n", hres);
547 ok(cb == 2, "cb=%u expected 2\n", cb);
548 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
549 ok(hres == S_OK, "Read failed: %08x\n", hres);
550 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
551 ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres);
552 ok(cb == 0, "cb=%u expected 0\n", cb);
553 hres = IInternetProtocol_UnlockRequest(protocol);
554 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
555
556 protocol_start(protocol, blank_url);
557 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
558 ok(hres == S_OK, "Read failed: %08x\n", hres);
559 hres = IInternetProtocol_LockRequest(protocol, 0);
560 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
561 hres = IInternetProtocol_UnlockRequest(protocol);
562 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
563 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
564 ok(hres == S_OK, "Read failed: %08x\n", hres);
565
566 protocol_start(protocol, blank_url);
567 hres = IInternetProtocol_LockRequest(protocol, 0);
568 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
569 hres = IInternetProtocol_Terminate(protocol, 0);
570 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
571 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
572 ok(hres == S_OK, "Read failed: %08x\n\n", hres);
573 hres = IInternetProtocol_UnlockRequest(protocol);
574 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
575 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
576 ok(hres == S_OK, "Read failed: %08x\n", hres);
577 hres = IInternetProtocol_Terminate(protocol, 0);
578 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
579 hres = IInternetProtocol_Read(protocol, buf, 2, &cb);
580 ok(hres == S_OK, "Read failed: %08x\n", hres);
581 ok(cb == 2, "cb=%u expected 2\n", cb);
582
583 protocol_start(protocol, blank_url);
584 hres = IInternetProtocol_LockRequest(protocol, 0);
585 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
586 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
587 ok(hres == S_OK, "Read failed: %08x\n", hres);
588 protocol_start(protocol, blank_url);
589 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
590 ok(hres == S_OK, "Read failed: %08x\n", hres);
591 hres = IInternetProtocol_Terminate(protocol, 0);
592 ok(hres == S_OK, "Terminate failed: %08x\n", hres);
593
594 IInternetProtocol_Release(protocol);
595 }
596
597 IClassFactory_Release(factory);
598 }
599
600 IUnknown_Release(unk);
601
602 test_res_url("/jstest.html");
603 test_res_url("/Test/res.html");
604 test_res_url("/test/dir/dir2/res.html");
605
606 if(GetProcAddress(LoadLibraryA("urlmon.dll"), "CreateUri")) {
607 test_res_url("/test/dir/dir2/res.html?query_part");
608 test_res_url("/test/dir/dir2/res.html#hash_part");
609 test_res_url("/#123");
610 test_res_url("/#23/#123");
611 test_res_url("/#123#456");
612 }else {
613 win_skip("IUri not supported\n");
614 }
615 }
616
617 static void do_test_about_protocol(IClassFactory *factory, DWORD bf)
618 {
619 IInternetProtocol *protocol;
620 IInternetPriority *priority;
621 BYTE buf[512];
622 ULONG cb;
623 HRESULT hres;
624
625 static const WCHAR blank_html[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0};
626 static const WCHAR test_html[] =
627 {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0};
628
629 bindf = bf;
630
631 hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol);
632 ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres);
633 if(FAILED(hres))
634 return;
635
636 hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority);
637 ok(hres == E_NOINTERFACE,
638 "QueryInterface(IInternetPriority) returned %08x, expected E_NOINTEFACE\n", hres);
639
640 protocol_start(protocol, about_blank_url);
641 hres = IInternetProtocol_LockRequest(protocol, 0);
642 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
643 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
644 ok(hres == S_OK, "Read failed: %08x\n", hres);
645 ok(cb == sizeof(blank_html), "cb=%d\n", cb);
646 ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n");
647 hres = IInternetProtocol_UnlockRequest(protocol);
648 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
649
650 protocol_start(protocol, about_test_url);
651 hres = IInternetProtocol_LockRequest(protocol, 0);
652 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
653 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
654 ok(hres == S_OK, "Read failed: %08x\n", hres);
655 ok(cb == sizeof(test_html), "cb=%d\n", cb);
656 ok(!memcmp(buf, test_html, cb), "Readed wrong data\n");
657 hres = IInternetProtocol_UnlockRequest(protocol);
658 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
659
660 protocol_start(protocol, about_res_url);
661 hres = IInternetProtocol_LockRequest(protocol, 0);
662 ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
663 hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb);
664 ok(hres == S_OK, "Read failed: %08x\n", hres);
665 ok(cb == sizeof(blank_html), "cb=%d\n", cb);
666 ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n");
667 hres = IInternetProtocol_UnlockRequest(protocol);
668 ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
669
670 IInternetProtocol_Release(protocol);
671 }
672
673 static void test_about_protocol(void)
674 {
675 IInternetProtocolInfo *protocol_info;
676 IUnknown *unk;
677 IClassFactory *factory;
678 HRESULT hres;
679
680 hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
681 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
682 if(FAILED(hres))
683 return;
684
685 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
686 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres);
687 if(SUCCEEDED(hres)) {
688 WCHAR buf[128];
689 DWORD size;
690 int i;
691
692 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
693 if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
694 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_blank_url, i, 0, buf,
695 sizeof(buf)/sizeof(buf[0]), &size, 0);
696 ok(hres == INET_E_DEFAULT_ACTION,
697 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres);
698 }
699 }
700
701 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_blank_url, PARSE_SECURITY_URL, 0, buf,
702 sizeof(buf)/sizeof(buf[0]), &size, 0);
703 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
704 ok(!lstrcmpW(about_blank_url, buf), "buf != blank_url\n");
705
706 size = 0xdeadbeef;
707 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_blank_url, PARSE_SECURITY_URL, 0, buf,
708 3, &size, 0);
709 ok(hres == S_FALSE, "ParseUrl failed: %08x, expected S_FALSE\n", hres);
710 ok(size == 12, "size = %d\n", size);
711
712 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_test_url, PARSE_SECURITY_URL, 0, buf,
713 sizeof(buf)/sizeof(buf[0]), &size, 0);
714 ok(hres == S_OK, "ParseUrl failed: %08x\n", hres);
715 ok(!lstrcmpW(about_test_url, buf), "buf != test_url\n");
716 ok(size == 11, "size = %d\n", size);
717
718 size = 0xdeadbeef;
719 buf[0] = '?';
720 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_blank_url, PARSE_DOMAIN, 0, buf,
721 sizeof(buf)/sizeof(buf[0]), &size, 0);
722 ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
723 ok(buf[0] == '?', "buf changed\n");
724 ok(size == sizeof(about_blank_url)/sizeof(WCHAR) ||
725 size == sizeof(buf)/sizeof(buf[0]), /* IE8 */
726 "size=%d\n", size);
727
728 if (0)
729 {
730 /* Crashes on windows */
731 size = 0xdeadbeef;
732 buf[0] = '?';
733 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
734 sizeof(buf)/sizeof(buf[0]), &size, 0);
735 ok(hres == E_FAIL, "ParseUrl failed: %08x\n", hres);
736 ok(buf[0] == '?', "buf changed\n");
737 ok(size == 1, "size=%u, expected 1\n", size);
738
739 buf[0] = '?';
740 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_blank_url, PARSE_DOMAIN, 0, buf,
741 sizeof(buf)/sizeof(buf[0]), NULL, 0);
742 ok(hres == E_POINTER, "ParseUrl failed: %08x\n", hres);
743 ok(buf[0] == '?', "buf changed\n");
744
745 buf[0] = '?';
746 hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf,
747 sizeof(buf)/sizeof(buf[0]), NULL, 0);
748 ok(hres == E_POINTER, "ParseUrl failed: %08x\n", hres);
749 ok(buf[0] == '?', "buf changed\n");
750 }
751
752 hres = IInternetProtocolInfo_ParseUrl(protocol_info, about_blank_url, PARSE_UNESCAPE+1, 0, buf,
753 sizeof(buf)/sizeof(buf[0]), &size, 0);
754 ok(hres == INET_E_DEFAULT_ACTION,
755 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres);
756
757 size = 0xdeadbeef;
758 hres = IInternetProtocolInfo_CombineUrl(protocol_info, about_blank_url, about_test_url,
759 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
760 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
761 ok(size == 0xdeadbeef, "size=%d\n", size);
762
763 size = 0xdeadbeef;
764 hres = IInternetProtocolInfo_CombineUrl(protocol_info, about_blank_url, about_test_url,
765 URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
766 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
767 ok(size == 0xdeadbeef, "size=%d\n", size);
768
769 size = 0xdeadbeef;
770 hres = IInternetProtocolInfo_CombineUrl(protocol_info, NULL, NULL,
771 URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
772 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
773 ok(size == 0xdeadbeef, "size=%d\n", size);
774
775 hres = IInternetProtocolInfo_CompareUrl(protocol_info, about_blank_url, about_blank_url, 0);
776 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
777
778 hres = IInternetProtocolInfo_CompareUrl(protocol_info, NULL, NULL, 0xdeadbeef);
779 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
780
781 for(i=0; i<30; i++) {
782 switch(i) {
783 case QUERY_CAN_NAVIGATE:
784 case QUERY_USES_NETWORK:
785 case QUERY_IS_CACHED:
786 case QUERY_IS_INSTALLEDENTRY:
787 case QUERY_IS_CACHED_OR_MAPPED:
788 case QUERY_IS_SECURE:
789 case QUERY_IS_SAFE:
790 case QUERY_USES_HISTORYFOLDER:
791 case QUERY_IS_CACHED_AND_USABLE_OFFLINE:
792 break;
793 default:
794 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, i, 0,
795 buf, sizeof(buf), &size, 0);
796 ok(hres == E_FAIL, "QueryInfo(%d) returned: %08x, expected E_FAIL\n", i, hres);
797 }
798 }
799
800 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, QUERY_CAN_NAVIGATE, 0,
801 buf, sizeof(buf), &size, 0);
802 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER ||
803 hres == E_FAIL, /* win2k */
804 "QueryInfo returned: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER or E_FAIL\n", hres);
805
806 size = 0xdeadbeef;
807 memset(buf, '?', sizeof(buf));
808 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, QUERY_USES_NETWORK, 0,
809 buf, sizeof(buf), &size, 0);
810 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
811 ok(size == sizeof(DWORD), "size=%d\n", size);
812 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
813
814 memset(buf, '?', sizeof(buf));
815 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, QUERY_USES_NETWORK, 0,
816 buf, sizeof(buf), NULL, 0);
817 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
818 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
819
820 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, QUERY_USES_NETWORK, 0,
821 buf, 3, &size, 0);
822 ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres);
823
824 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, QUERY_USES_NETWORK, 0,
825 NULL, sizeof(buf), &size, 0);
826 ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres);
827
828 hres = IInternetProtocolInfo_QueryInfo(protocol_info, about_blank_url, 60, 0,
829 NULL, sizeof(buf), &size, 0);
830 ok(hres == E_FAIL, "QueryInfo failed: %08x, expected E_FAIL\n", hres);
831
832 IInternetProtocolInfo_Release(protocol_info);
833 }
834
835 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
836 ok(hres == S_OK, "Could not get IClassFactory interface\n");
837 if(SUCCEEDED(hres)) {
838 do_test_about_protocol(factory, 0);
839 do_test_about_protocol(factory,
840 BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | BINDF_PULLDATA | BINDF_FROMURLMON | BINDF_NEEDFILE);
841
842 IClassFactory_Release(factory);
843 }
844
845 IUnknown_Release(unk);
846 }
847
848 static void test_javascript_protocol(void)
849 {
850 IInternetProtocolInfo *protocol_info;
851 IUnknown *unk;
852 IClassFactory *factory;
853 HRESULT hres;
854
855 hres = CoGetClassObject(&CLSID_JSProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk);
856 ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres);
857 if(FAILED(hres))
858 return;
859
860 hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info);
861 ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres);
862 if(SUCCEEDED(hres)) {
863 WCHAR buf[128];
864 DWORD size;
865 int i;
866
867 for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) {
868 if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) {
869 hres = IInternetProtocolInfo_ParseUrl(protocol_info, javascript_test_url, i, 0, buf,
870 sizeof(buf)/sizeof(buf[0]), &size, 0);
871 ok(hres == INET_E_DEFAULT_ACTION,
872 "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres);
873 }
874 }
875
876 hres = IInternetProtocolInfo_ParseUrl(protocol_info, javascript_test_url, PARSE_UNESCAPE+1, 0, buf,
877 sizeof(buf)/sizeof(buf[0]), &size, 0);
878 ok(hres == INET_E_DEFAULT_ACTION,
879 "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres);
880
881 size = 0xdeadbeef;
882 hres = IInternetProtocolInfo_CombineUrl(protocol_info, javascript_test_url, javascript_test_url,
883 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0);
884 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres);
885 ok(size == 0xdeadbeef, "size=%d\n", size);
886
887 hres = IInternetProtocolInfo_CompareUrl(protocol_info, javascript_test_url, javascript_test_url, 0);
888 ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres);
889
890 for(i=0; i<30; i++) {
891 switch(i) {
892 case QUERY_USES_NETWORK:
893 case QUERY_IS_SECURE:
894 break;
895 default:
896 hres = IInternetProtocolInfo_QueryInfo(protocol_info, javascript_test_url, i, 0,
897 buf, sizeof(buf), &size, 0);
898 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
899 "QueryInfo(%d) returned: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", i, hres);
900 }
901 }
902
903
904 memset(buf, '?', sizeof(buf));
905 hres = IInternetProtocolInfo_QueryInfo(protocol_info, javascript_test_url, QUERY_USES_NETWORK, 0,
906 buf, sizeof(buf), &size, 0);
907 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
908 ok(size == sizeof(DWORD), "size=%d\n", size);
909 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
910
911 memset(buf, '?', sizeof(buf));
912 hres = IInternetProtocolInfo_QueryInfo(protocol_info, javascript_test_url, QUERY_USES_NETWORK, 0,
913 buf, sizeof(buf), NULL, 0);
914 ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres);
915 ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf);
916
917 hres = IInternetProtocolInfo_QueryInfo(protocol_info, javascript_test_url, QUERY_USES_NETWORK, 0,
918 buf, 3, &size, 0);
919 ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres);
920
921 hres = IInternetProtocolInfo_QueryInfo(protocol_info, javascript_test_url, QUERY_USES_NETWORK, 0,
922 NULL, sizeof(buf), &size, 0);
923 ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres);
924
925 hres = IInternetProtocolInfo_QueryInfo(protocol_info, javascript_test_url, 60, 0,
926 NULL, sizeof(buf), &size, 0);
927 ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER,
928 "QueryInfo failed: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres);
929
930 /* FIXME: test QUERY_IS_SECURE */
931
932 IInternetProtocolInfo_Release(protocol_info);
933 }
934
935 hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory);
936 ok(hres == S_OK, "Could not get IClassFactory interface\n");
937 if(SUCCEEDED(hres))
938 IClassFactory_Release(factory);
939
940 IUnknown_Release(unk);
941 }
942
943 START_TEST(protocol)
944 {
945 res_url_base_len = 6 + GetModuleFileNameW(NULL, res_url_base + 6 /* strlen("res://") */, sizeof(res_url_base)/sizeof(WCHAR)-6);
946
947 OleInitialize(NULL);
948
949 test_res_protocol();
950 test_about_protocol();
951 test_javascript_protocol();
952
953 OleUninitialize();
954 }