static void do_test_about_protocol(IClassFactory *factory, DWORD bf) { IInternetProtocol *protocol; IInternetPriority *priority; BYTE buf[512]; ULONG cb; HRESULT hres; static const WCHAR blank_html[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0}; static const WCHAR test_html[] = {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0}; bindf = bf; hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(FAILED(hres)) return; hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority); ok(hres == E_NOINTERFACE, "QueryInterface(IInternetPriority) returned %08x, expected E_NOINTEFACE\n", hres); protocol_start(protocol, about_blank_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == sizeof(blank_html), "cb=%d\n", cb); ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n"); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); protocol_start(protocol, about_test_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == sizeof(test_html), "cb=%d\n", cb); ok(!memcmp(buf, test_html, cb), "Readed wrong data\n"); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); protocol_start(protocol, about_res_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == sizeof(blank_html), "cb=%d\n", cb); ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n"); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); IInternetProtocol_Release(protocol); }
static void test_res_url(const char *url_suffix) { WCHAR url[INTERNET_MAX_URL_LENGTH]; IInternetProtocol *protocol; ULONG size, ref; BYTE buf[100]; HRESULT hres; memcpy(url, res_url_base, res_url_base_len*sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, url_suffix, -1, url+res_url_base_len, sizeof(url)/sizeof(WCHAR)-res_url_base_len); hres = CoCreateInstance(&CLSID_ResProtocol, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not create ResProtocol instance: %08x\n", hres); protocol_start(protocol, url); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &size); ok(hres == S_OK, "Read failed: %08x\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08x\n", hres); ref = IInternetProtocol_Release(protocol); ok(!ref, "ref=%u\n", ref); }
static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead) { BindProtocol *This = PROTOCOLHANDLER_THIS(iface); ULONG read = 0; HRESULT hres = S_OK; TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); if(This->buf_size) { read = min(cb, This->buf_size); memcpy(pv, This->buf, read); if(read == This->buf_size) { heap_free(This->buf); This->buf = NULL; }else { memmove(This->buf, This->buf+cb, This->buf_size-cb); } This->buf_size -= read; } if(read < cb) { ULONG cread = 0; hres = IInternetProtocol_Read(This->protocol, (BYTE*)pv+read, cb-read, &cread); read += cread; } *pcbRead = read; return hres; }
static HRESULT WINAPI ProtocolStream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead) { ProtocolStream *This = impl_from_IStream(iface); DWORD read = 0; HRESULT hres; TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbRead); if(This->buf->file == INVALID_HANDLE_VALUE) { hres = This->buf->hres = IInternetProtocol_Read(This->buf->protocol, (PBYTE)pv, cb, &read); }else { hres = ReadFile(This->buf->file, pv, cb, &read, NULL) ? S_OK : INET_E_DOWNLOAD_FAILURE; } if (pcbRead) *pcbRead = read; if(hres == E_PENDING) return E_PENDING; else if(FAILED(hres)) FIXME("Read failed: %08x\n", hres); return read ? S_OK : S_FALSE; }
static HRESULT report_data(BindProtocol *This, DWORD bscf, ULONG progress, ULONG progress_max) { if(!This->protocol_sink) return S_OK; if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) { BYTE buf[BUFFER_SIZE]; DWORD read = 0; LPWSTR mime; HRESULT hres; do { read = 0; hres = IInternetProtocol_Read(This->protocol, buf, sizeof(buf)-This->buf_size, &read); if(FAILED(hres) && hres != E_PENDING) return hres; if(!This->buf) { This->buf = heap_alloc(BUFFER_SIZE); if(!This->buf) return E_OUTOFMEMORY; }else if(read + This->buf_size > BUFFER_SIZE) { BYTE *tmp; tmp = heap_realloc(This->buf, read+This->buf_size); if(!tmp) return E_OUTOFMEMORY; This->buf = tmp; } memcpy(This->buf+This->buf_size, buf, read); This->buf_size += read; }while(This->buf_size < MIME_TEST_SIZE && hres == S_OK); if(This->buf_size < MIME_TEST_SIZE && hres != S_FALSE) return S_OK; bscf = BSCF_FIRSTDATANOTIFICATION; if(hres == S_FALSE) bscf |= BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE; if(!This->reported_mime) { hres = FindMimeFromData(NULL, This->url, This->buf, min(This->buf_size, MIME_TEST_SIZE), This->mime, 0, &mime, 0); if(FAILED(hres)) return hres; mime_available(This, mime, TRUE); CoTaskMemFree(mime); } } if(!This->protocol_sink) return S_OK; return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress, progress_max); }
static void read_protocol_data(stgmed_buf_t *stgmed_buf) { BYTE buf[8192]; DWORD read; HRESULT hres; do hres = IInternetProtocol_Read(stgmed_buf->protocol, buf, sizeof(buf), &read); while(hres == S_OK); }
static HRESULT WINAPI ProtocolProxy_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead) { ProtocolProxy *This = PROTOCOL_THIS(iface); TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); return IInternetProtocol_Read(This->protocol, pv, cb, pcbRead); }
static HRESULT WINAPI BindProtocol_Read(IInternetProtocolEx *iface, void *pv, ULONG cb, ULONG *pcbRead) { BindProtocol *This = impl_from_IInternetProtocolEx(iface); TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); if(pcbRead) *pcbRead = 0; return IInternetProtocol_Read(This->protocol_handler, pv, cb, pcbRead); }
static void fill_stgmed_buffer(stgmed_buf_t *buf) { DWORD read = 0; if(sizeof(buf->buf) == buf->size) return; buf->hres = IInternetProtocol_Read(buf->protocol, buf->buf+buf->size, sizeof(buf->buf)-buf->size, &read); buf->size += read; if(read > 0) buf->init = TRUE; }
static HRESULT WINAPI BindProtocol_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead) { BindProtocol *This = PROTOCOL_THIS(iface); ULONG read = 0; HRESULT hres; TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); hres = IInternetProtocol_Read(This->protocol, pv, cb, &read); *pcbRead = read; return hres; }
static HRESULT WINAPI ProtocolStream_Read(IStream *iface, void *pv, ULONG cb, ULONG *pcbRead) { ProtocolStream *This = STREAM_THIS(iface); DWORD read = 0, pread = 0; HRESULT hres; TRACE("(%p)->(%p %d %p)\n", This, pv, cb, pcbRead); if(This->buf->file != INVALID_HANDLE_VALUE) { if (!ReadFile(This->buf->file, pv, cb, &read, NULL)) return INET_E_DOWNLOAD_FAILURE; if(pcbRead) *pcbRead = read; return read ? S_OK : S_FALSE; } if(This->buf->size) { read = cb; if(read > This->buf->size) read = This->buf->size; memcpy(pv, This->buf->buf, read); if(read < This->buf->size) memmove(This->buf->buf, This->buf->buf+read, This->buf->size-read); This->buf->size -= read; } if(read == cb) { if (pcbRead) *pcbRead = read; return S_OK; } hres = This->buf->hres = IInternetProtocol_Read(This->buf->protocol, (PBYTE)pv+read, cb-read, &pread); if (pcbRead) *pcbRead = read + pread; if(hres == E_PENDING) return E_PENDING; else if(FAILED(hres)) FIXME("Read failed: %08x\n", hres); return read || pread ? S_OK : S_FALSE; }
static HRESULT WINAPI ProtocolHandler_Read(IInternetProtocol *iface, void *pv, ULONG cb, ULONG *pcbRead) { BindProtocol *This = impl_from_IInternetProtocol(iface); ULONG read = 0; HRESULT hres = S_OK; TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead); if(This->buf_size) { read = min(cb, This->buf_size); memcpy(pv, This->buf, read); if(read == This->buf_size) { heap_free(This->buf); This->buf = NULL; }else { memmove(This->buf, This->buf+cb, This->buf_size-cb); } This->buf_size -= read; } if(read < cb) { ULONG cread = 0; if(is_apartment_thread(This)) This->continue_call++; hres = IInternetProtocol_Read(This->protocol, (BYTE*)pv+read, cb-read, &cread); if(is_apartment_thread(This)) This->continue_call--; read += cread; } *pcbRead = read; return hres; }
static HRESULT WINAPI ProtocolSink_ReportData(IInternetProtocolSink *iface, DWORD grfBSCF, ULONG ulProgress, ULONG ulProgressMax) { CHECK_EXPECT(ReportData); ok(ulProgress == ulProgressMax, "ulProgress != ulProgressMax\n"); if(test_protocol == ITS_PROTOCOL) ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_DATAFULLYAVAILABLE), "grcf = %08x\n", grfBSCF); else ok(grfBSCF == (BSCF_FIRSTDATANOTIFICATION | BSCF_LASTDATANOTIFICATION), "grcf = %08x\n", grfBSCF); if(read_protocol) { BYTE buf[100]; DWORD cb = 0xdeadbeef; HRESULT hres; hres = IInternetProtocol_Read(read_protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 13, "cb=%u expected 13\n", cb); ok(!memcmp(buf, "<html></html>", 13), "unexpected data\n"); } return S_OK; }
static void test_protocol_url(IClassFactory *factory, LPCWSTR url, BOOL expect_mime) { IInternetProtocol *protocol; BYTE buf[512]; ULONG cb, ref; HRESULT hres; hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(FAILED(hres)) return; hres = protocol_start(protocol, url, expect_mime); if(FAILED(hres)) { IInternetProtocol_Release(protocol); return; } hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 13, "cb=%u expected 13\n", cb); ok(!memcmp(buf, "<html></html>", 13), "unexpected data\n"); ref = IInternetProtocol_Release(protocol); ok(!ref, "protocol ref=%d\n", ref); hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(FAILED(hres)) return; cb = 0xdeadbeef; hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == (test_protocol == ITS_PROTOCOL ? INET_E_DATA_NOT_AVAILABLE : E_FAIL), "Read returned %08x\n", hres); ok(cb == 0xdeadbeef, "cb=%u expected 0xdeadbeef\n", cb); protocol_start(protocol, url, expect_mime); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 2, "cb=%u expected 2\n", cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 11, "cb=%u, expected 11\n", cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres); ok(cb == 0, "cb=%u expected 0\n", cb); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); ref = IInternetProtocol_Release(protocol); ok(!ref, "protocol ref=%d\n", ref); hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(FAILED(hres)) return; protocol_start(protocol, url, expect_mime); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 11, "cb=%u, expected 11\n", cb); ref = IInternetProtocol_Release(protocol); ok(!ref, "protocol ref=%d\n", ref); hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(FAILED(hres)) return; protocol_start(protocol, url, expect_mime); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 2, "cb=%u, expected 2\n", cb); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 2, "cb=%u, expected 2\n", cb); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 2, "cb=%u expected 2\n", cb); ref = IInternetProtocol_Release(protocol); ok(!ref, "protocol ref=%d\n", ref); hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&read_protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(FAILED(hres)) return; protocol_start(read_protocol, url, expect_mime); ref = IInternetProtocol_Release(read_protocol); ok(!ref, "protocol ref=%d\n", ref); read_protocol = NULL; }
static HRESULT WINAPI ProtocolSinkHandler_ReportData(IInternetProtocolSink *iface, DWORD bscf, ULONG progress, ULONG progress_max) { BindProtocol *This = impl_from_IInternetProtocolSinkHandler(iface); TRACE("(%p)->(%x %u %u)\n", This, bscf, progress, progress_max); This->bscf = bscf; This->progress = progress; This->progress_max = progress_max; if(!This->protocol_sink) return S_OK; if((This->pi & PI_MIMEVERIFICATION) && !This->reported_mime) { BYTE buf[BUFFER_SIZE]; DWORD read = 0; LPWSTR mime; HRESULT hres; do { read = 0; if(is_apartment_thread(This)) This->continue_call++; hres = IInternetProtocol_Read(This->protocol, buf, sizeof(buf)-This->buf_size, &read); if(is_apartment_thread(This)) This->continue_call--; if(FAILED(hres) && hres != E_PENDING) return hres; if(!This->buf) { This->buf = heap_alloc(BUFFER_SIZE); if(!This->buf) return E_OUTOFMEMORY; }else if(read + This->buf_size > BUFFER_SIZE) { BYTE *tmp; tmp = heap_realloc(This->buf, read+This->buf_size); if(!tmp) return E_OUTOFMEMORY; This->buf = tmp; } memcpy(This->buf+This->buf_size, buf, read); This->buf_size += read; }while(This->buf_size < MIME_TEST_SIZE && hres == S_OK); if(This->buf_size < MIME_TEST_SIZE && hres != S_FALSE) return S_OK; bscf = BSCF_FIRSTDATANOTIFICATION; if(hres == S_FALSE) bscf |= BSCF_LASTDATANOTIFICATION|BSCF_DATAFULLYAVAILABLE; if(!This->reported_mime) { BSTR raw_uri; hres = IUri_GetRawUri(This->uri, &raw_uri); if(FAILED(hres)) return hres; hres = FindMimeFromData(NULL, raw_uri, This->buf, min(This->buf_size, MIME_TEST_SIZE), This->mime, 0, &mime, 0); SysFreeString(raw_uri); if(FAILED(hres)) return hres; heap_free(This->mime); This->mime = heap_strdupW(mime); CoTaskMemFree(mime); This->reported_mime = TRUE; if(This->protocol_sink) IInternetProtocolSink_ReportProgress(This->protocol_sink, BINDSTATUS_MIMETYPEAVAILABLE, This->mime); } } if(!This->protocol_sink) return S_OK; return IInternetProtocolSink_ReportData(This->protocol_sink, bscf, progress, progress_max); }
static void test_res_protocol(void) { IInternetProtocolInfo *protocol_info; IUnknown *unk; IClassFactory *factory; HRESULT hres; static const WCHAR blank_url[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0}; static const WCHAR test_part_url[] = {'r','e','s',':','/','/','C','S','S','/','t','e','s','t',0}; static const WCHAR wrong_url1[] = {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0}; static const WCHAR wrong_url2[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0}; static const WCHAR wrong_url3[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0}; static const WCHAR wrong_url4[] = {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0}; hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk); ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres); if(!SUCCEEDED(hres)) return; hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres); if(SUCCEEDED(hres)) { WCHAR buf[128]; DWORD size; int i; for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) { if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) { hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_DEFAULT_ACTION, "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres); } } hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres); hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, 3, &size, 0); ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres); hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08lx, expected MK_E_SYNTAX\n", hres); size = 0xdeadbeef; buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == sizeof(blank_url)/sizeof(WCHAR), "size=%ld\n", size); size = 0xdeadbeef; hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == sizeof(wrong_url1)/sizeof(WCHAR), "size=%ld\n", size); #if 0 /* Crashes on win9x */ size = 0xdeadbeef; buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == E_FAIL, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == 1, "size=%ld, ezpected 1\n", size); buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), NULL, 0); ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), NULL, 0); ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); #endif buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_DEFAULT_ACTION, "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres); ok(buf[0] == '?', "buf changed\n"); size = 0xdeadbeef; hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08lx\n", hres); size = 0xdeadbeef; hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url, URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08lx\n", hres); size = 0xdeadbeef; hres = IInternetProtocolInfo_CombineUrl(protocol_info, NULL, NULL, URL_FILE_USE_PATHURL, NULL, 0xdeadbeef, NULL, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08lx\n", hres); IInternetProtocolInfo_Release(protocol_info); } hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); ok(hres == S_OK, "Could not get IClassFactory interface\n"); if(SUCCEEDED(hres)) { IInternetProtocol *protocol; BYTE buf[512]; ULONG cb; hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres); if(SUCCEEDED(hres)) { test_protocol_fail(protocol, wrong_url1, MK_E_SYNTAX, FALSE); test_protocol_fail(protocol, wrong_url2, MK_E_SYNTAX, FALSE); test_protocol_fail(protocol, wrong_url3, E_FAIL, TRUE); test_protocol_fail(protocol, wrong_url4, E_FAIL, TRUE); cb = 0xdeadbeef; hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == E_FAIL, "Read returned %08lx expected E_FAIL\n", hres); ok(cb == 0xdeadbeef, "cb=%lu expected 0xdeadbeef\n", cb); protocol_start(protocol, blank_url); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(cb == 2, "cb=%lu expected 2\n", cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_FALSE, "Read failed: %08lx expected S_FALSE\n", hres); ok(cb == 0, "cb=%lu expected 0\n", cb); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); protocol_start(protocol, blank_url); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); protocol_start(protocol, blank_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08lx\n\n", hres); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(cb == 2, "cb=%lu expected 2\n", cb); protocol_start(protocol, blank_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); protocol_start(protocol, blank_url); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08lx\n", hres); IInternetProtocol_Release(protocol); } IClassFactory_Release(factory); } IUnknown_Release(unk); }
static void test_res_protocol(void) { IInternetProtocolInfo *protocol_info; IUnknown *unk; IClassFactory *factory; HRESULT hres; static const WCHAR blank_url[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0}; static const WCHAR test_part_url[] = {'r','e','s',':','/','/','C','S','S','/','t','e','s','t',0}; static const WCHAR wrong_url1[] = {'m','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','m','t','h',0}; static const WCHAR wrong_url2[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l',0}; static const WCHAR wrong_url3[] = {'r','e','s',':','/','/','m','s','h','t','m','l','.','d','l','l','/','x','x','.','h','t','m',0}; static const WCHAR wrong_url4[] = {'r','e','s',':','/','/','x','x','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0}; static const WCHAR wrong_url5[] = {'r','e','s',':','/','/','s','h','t','m','l','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0}; static const WCHAR wrong_url6[] = {'r','e','s',':','/','/','c',':','\\','d','i','r','\\','f','i','l','e','.','d','l','l','/','b','l','a','n','k','.','h','t','m',0}; static const WCHAR mshtml_dllW[] = {'m','s','h','t','m','l','.','d','l','l',0}; hres = CoGetClassObject(&CLSID_ResProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk); ok(hres == S_OK, "CoGetClassObject failed: %08x\n", hres); if(FAILED(hres)) return; hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08x\n", hres); if(SUCCEEDED(hres)) { WCHAR buf[128]; DWORD size, expected_size; int i; for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) { if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) { hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_DEFAULT_ACTION, "[%d] failed: %08x, expected INET_E_DEFAULT_ACTION\n", i, hres); } } hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK, "ParseUrl failed: %08x\n", hres); res_sec_url_cmp(buf, size, mshtml_dllW); ok(size == lstrlenW(buf)+1, "size = %d\n", size); expected_size = size; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, expected_size, &size, 0); ok(hres == S_OK, "ParseUrl failed: %08x\n", hres); res_sec_url_cmp(buf, size, mshtml_dllW); ok(size == expected_size, "size = %d\n", size); size = 0; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, 3, &size, 0); ok(hres == S_FALSE, "ParseUrl failed: %08x, expected S_FALSE\n", hres); ok(size == expected_size, "size = %d\n", size); hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == MK_E_SYNTAX || hres == E_INVALIDARG, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres); hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url5, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres); hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url6, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == MK_E_SYNTAX, "ParseUrl failed: %08x, expected MK_E_SYNTAX\n", hres); size = 0xdeadbeef; buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == sizeof(blank_url)/sizeof(WCHAR) || size == sizeof(buf)/sizeof(buf[0]), /* IE8 */ "size=%d\n", size); size = 0xdeadbeef; hres = IInternetProtocolInfo_ParseUrl(protocol_info, wrong_url1, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08x\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == sizeof(wrong_url1)/sizeof(WCHAR) || size == sizeof(buf)/sizeof(buf[0]), /* IE8 */ "size=%d\n", size); if (0) { /* Crashes on windows */ size = 0xdeadbeef; buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == E_FAIL, "ParseUrl failed: %08x\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == 1, "size=%u, expected 1\n", size); buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), NULL, 0); ok(hres == E_POINTER, "ParseUrl failed: %08x\n", hres); ok(buf[0] == '?', "buf changed\n"); buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), NULL, 0); ok(hres == E_POINTER, "ParseUrl failed: %08x\n", hres); ok(buf[0] == '?', "buf changed\n"); } buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_DEFAULT_ACTION, "ParseUrl failed: %08x, expected INET_E_DEFAULT_ACTION\n", hres); ok(buf[0] == '?', "buf changed\n"); size = 0xdeadbeef; hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres); ok(size == 0xdeadbeef, "size=%d\n", size); size = 0xdeadbeef; hres = IInternetProtocolInfo_CombineUrl(protocol_info, blank_url, test_part_url, URL_FILE_USE_PATHURL, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres); ok(size == 0xdeadbeef, "size=%d\n", size); size = 0xdeadbeef; hres = IInternetProtocolInfo_CombineUrl(protocol_info, NULL, NULL, URL_FILE_USE_PATHURL, NULL, 0xdeadbeef, NULL, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "CombineUrl failed: %08x\n", hres); ok(size == 0xdeadbeef, "size=%d\n", size); hres = IInternetProtocolInfo_CompareUrl(protocol_info, blank_url, blank_url, 0); ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres); hres = IInternetProtocolInfo_CompareUrl(protocol_info, NULL, NULL, 0xdeadbeef); ok(hres == E_NOTIMPL, "CompareUrl failed: %08x\n", hres); for(i=0; i<30; i++) { if(i == QUERY_USES_NETWORK || i == QUERY_IS_SECURE || i == QUERY_IS_SAFE) continue; hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, i, 0, buf, sizeof(buf), &size, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "QueryInfo(%d) returned: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", i, hres); } size = 0xdeadbeef; memset(buf, '?', sizeof(buf)); hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), &size, 0); ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres); ok(size == sizeof(DWORD), "size=%d\n", size); ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf); memset(buf, '?', sizeof(buf)); hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0, buf, sizeof(buf), NULL, 0); ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres); ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf); hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0, buf, 3, &size, 0); ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres); size = 0xdeadbeef; memset(buf, '?', sizeof(buf)); hres = IInternetProtocolInfo_QueryInfo(protocol_info, NULL, QUERY_USES_NETWORK, 0, buf, sizeof(buf), &size, 0); ok(hres == S_OK, "QueryInfo(QUERY_USES_NETWORK) failed: %08x\n", hres); ok(size == sizeof(DWORD), "size=%d\n", size); ok(!*(DWORD*)buf, "buf=%d\n", *(DWORD*)buf); hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, QUERY_USES_NETWORK, 0, NULL, sizeof(buf), &size, 0); ok(hres == E_FAIL, "QueryInfo(QUERY_USES_NETWORK) failed: %08x, expected E_FAIL\n", hres); hres = IInternetProtocolInfo_QueryInfo(protocol_info, blank_url, 60, 0, NULL, sizeof(buf), &size, 0); ok(hres == INET_E_USE_DEFAULT_PROTOCOLHANDLER, "QueryInfo failed: %08x, expected INET_E_USE_DEFAULT_PROTOCOLHANDLER\n", hres); IInternetProtocolInfo_Release(protocol_info); } hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); ok(hres == S_OK, "Could not get IClassFactory interface\n"); if(SUCCEEDED(hres)) { IInternetProtocol *protocol; BYTE buf[512]; ULONG cb; hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08x\n", hres); if(SUCCEEDED(hres)) { IInternetPriority *priority; hres = IInternetProtocol_QueryInterface(protocol, &IID_IInternetPriority, (void**)&priority); ok(hres == E_NOINTERFACE, "QueryInterface(IInternetPriority) returned %08x, expected E_NOINTEFACE\n", hres); test_protocol_fail(protocol, wrong_url1, E_INVALIDARG, FALSE); test_protocol_fail(protocol, wrong_url2, HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), FALSE); test_protocol_fail(protocol, wrong_url3, E_FAIL, TRUE); test_protocol_fail(protocol, wrong_url4, E_FAIL, TRUE); cb = 0xdeadbeef; hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == E_FAIL, "Read returned %08x expected E_FAIL\n", hres); ok(cb == 0xdeadbeef, "cb=%u expected 0xdeadbeef\n", cb); protocol_start(protocol, blank_url); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 2, "cb=%u expected 2\n", cb); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_FALSE, "Read failed: %08x expected S_FALSE\n", hres); ok(cb == 0, "cb=%u expected 0\n", cb); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); protocol_start(protocol, blank_url); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); protocol_start(protocol, blank_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n\n", hres); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, 2, &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); ok(cb == 2, "cb=%u expected 2\n", cb); protocol_start(protocol, blank_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08x\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); protocol_start(protocol, blank_url); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08x\n", hres); hres = IInternetProtocol_Terminate(protocol, 0); ok(hres == S_OK, "Terminate failed: %08x\n", hres); IInternetProtocol_Release(protocol); } IClassFactory_Release(factory); } IUnknown_Release(unk); test_res_url("/jstest.html"); test_res_url("/Test/res.html"); test_res_url("/test/dir/dir2/res.html"); if(GetProcAddress(LoadLibraryA("urlmon.dll"), "CreateUri")) { test_res_url("/test/dir/dir2/res.html?query_part"); test_res_url("/test/dir/dir2/res.html#hash_part"); test_res_url("/#123"); test_res_url("/#23/#123"); test_res_url("/#123#456"); }else { win_skip("IUri not supported\n"); } }
static void test_about_protocol(void) { IInternetProtocolInfo *protocol_info; IUnknown *unk; IClassFactory *factory; HRESULT hres; static const WCHAR blank_url[] = {'a','b','o','u','t',':','b','l','a','n','k',0}; static const WCHAR test_url[] = {'a','b','o','u','t',':','t','e','s','t',0}; static const WCHAR res_url[] = {'r','e','s',':','b','l','a','n','k',0}; static const WCHAR blank_html[] = {0xfeff,'<','H','T','M','L','>','<','/','H','T','M','L','>',0}; static const WCHAR test_html[] = {0xfeff,'<','H','T','M','L','>','t','e','s','t','<','/','H','T','M','L','>',0}; hres = CoGetClassObject(&CLSID_AboutProtocol, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)&unk); ok(hres == S_OK, "CoGetClassObject failed: %08lx\n", hres); if(!SUCCEEDED(hres)) return; hres = IUnknown_QueryInterface(unk, &IID_IInternetProtocolInfo, (void**)&protocol_info); ok(hres == S_OK, "Could not get IInternetProtocolInfo interface: %08lx\n", hres); if(SUCCEEDED(hres)) { WCHAR buf[128]; DWORD size; int i; for(i = PARSE_CANONICALIZE; i <= PARSE_UNESCAPE; i++) { if(i != PARSE_SECURITY_URL && i != PARSE_DOMAIN) { hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, i, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_DEFAULT_ACTION, "[%d] failed: %08lx, expected INET_E_DEFAULT_ACTION\n", i, hres); } } hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres); ok(!lstrcmpW(blank_url, buf), "buf != blank_url\n"); hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_SECURITY_URL, 0, buf, 3, &size, 0); ok(hres == S_FALSE, "ParseUrl failed: %08lx, expected S_FALSE\n", hres); hres = IInternetProtocolInfo_ParseUrl(protocol_info, test_url, PARSE_SECURITY_URL, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK, "ParseUrl failed: %08lx\n", hres); ok(!lstrcmpW(test_url, buf), "buf != test_url\n"); size = 0xdeadbeef; buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == S_OK || hres == E_FAIL, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == sizeof(blank_url)/sizeof(WCHAR), "size=%ld\n", size); #if 0 /* Crashes on win9x */ size = 0xdeadbeef; buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == E_FAIL, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); ok(size == 1, "size=%ld, ezpected 1\n", size); buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), NULL, 0); ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); buf[0] = '?'; hres = IInternetProtocolInfo_ParseUrl(protocol_info, NULL, PARSE_DOMAIN, 0, buf, sizeof(buf)/sizeof(buf[0]), NULL, 0); ok(hres == E_POINTER, "ParseUrl failed: %08lx\n", hres); ok(buf[0] == '?', "buf changed\n"); #endif hres = IInternetProtocolInfo_ParseUrl(protocol_info, blank_url, PARSE_UNESCAPE+1, 0, buf, sizeof(buf)/sizeof(buf[0]), &size, 0); ok(hres == INET_E_DEFAULT_ACTION, "ParseUrl failed: %08lx, expected INET_E_DEFAULT_ACTION\n", hres); IInternetProtocolInfo_Release(protocol_info); } hres = IUnknown_QueryInterface(unk, &IID_IClassFactory, (void**)&factory); ok(hres == S_OK, "Could not get IClassFactory interface\n"); if(SUCCEEDED(hres)) { IInternetProtocol *protocol; BYTE buf[512]; ULONG cb; hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocol, (void**)&protocol); ok(hres == S_OK, "Could not get IInternetProtocol: %08lx\n", hres); if(SUCCEEDED(hres)) { protocol_start(protocol, blank_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(cb == sizeof(blank_html), "cb=%ld\n", cb); ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n"); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); protocol_start(protocol, test_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(cb == sizeof(test_html), "cb=%ld\n", cb); ok(!memcmp(buf, test_html, cb), "Readed wrong data\n"); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); protocol_start(protocol, res_url); hres = IInternetProtocol_LockRequest(protocol, 0); ok(hres == S_OK, "LockRequest failed: %08lx\n", hres); hres = IInternetProtocol_Read(protocol, buf, sizeof(buf), &cb); ok(hres == S_OK, "Read failed: %08lx\n", hres); ok(cb == sizeof(blank_html), "cb=%ld\n", cb); ok(!memcmp(buf, blank_html, cb), "Readed wrong data\n"); hres = IInternetProtocol_UnlockRequest(protocol); ok(hres == S_OK, "UnlockRequest failed: %08lx\n", hres); IInternetProtocol_Release(protocol); } IClassFactory_Release(factory); } IUnknown_Release(unk); }