diff --git a/dlls/mshtml/htmllocation.c b/dlls/mshtml/htmllocation.c index e86cee60043..e991cf36c90 100644 --- a/dlls/mshtml/htmllocation.c +++ b/dlls/mshtml/htmllocation.c @@ -191,12 +191,31 @@ static HRESULT WINAPI HTMLLocation_put_protocol(IHTMLLocation *iface, BSTR v) static HRESULT WINAPI HTMLLocation_get_protocol(IHTMLLocation *iface, BSTR *p) { HTMLLocation *This = HTMLLOCATION_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); + URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW)}; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); if(!p) return E_POINTER; - return E_NOTIMPL; + url.dwSchemeLength = 1; + hres = get_url_components(This, &url); + if(FAILED(hres)) + return hres; + + if(!url.dwSchemeLength) { + FIXME("Unexpected blank protocol\n"); + return E_NOTIMPL; + }else { + WCHAR buf[url.dwSchemeLength + 1]; + memcpy(buf, url.lpszScheme, url.dwSchemeLength * sizeof(WCHAR)); + buf[url.dwSchemeLength] = ':'; + *p = SysAllocStringLen(buf, url.dwSchemeLength + 1); + } + if(!*p) + return E_OUTOFMEMORY; + return S_OK; } static HRESULT WINAPI HTMLLocation_put_host(IHTMLLocation *iface, BSTR v) diff --git a/dlls/mshtml/tests/htmllocation.c b/dlls/mshtml/tests/htmllocation.c index e271f00c510..57b6bcfb38f 100644 --- a/dlls/mshtml/tests/htmllocation.c +++ b/dlls/mshtml/tests/htmllocation.c @@ -57,7 +57,7 @@ static const struct location_test http_test = { "HTTP", http_url, "http://www.winehq.org/?search#hash", FALSE, - "http:", FALSE, + "http:", TRUE, "www.winehq.org:80", FALSE, "www.winehq.org", FALSE, "80", TRUE, @@ -71,7 +71,7 @@ static const struct location_test http_file_test = { "HTTP with file", http_file_url, "http://www.winehq.org/file?search#hash", TRUE, - "http:", FALSE, + "http:", TRUE, "www.winehq.org:80", FALSE, "www.winehq.org", FALSE, "80", TRUE, @@ -85,7 +85,7 @@ static const struct location_test ftp_test = { "FTP", ftp_url, "ftp://ftp.winehq.org/", TRUE, - "ftp:", FALSE, + "ftp:", TRUE, "ftp.winehq.org:21", FALSE, "ftp.winehq.org", FALSE, "21", TRUE, @@ -99,7 +99,7 @@ static const struct location_test ftp_file_test = { "FTP with file", ftp_file_url, "ftp://ftp.winehq.org/file", TRUE, - "ftp:", FALSE, + "ftp:", TRUE, "ftp.winehq.org:21", FALSE, "ftp.winehq.org", FALSE, "21", TRUE, @@ -113,7 +113,7 @@ static const struct location_test file_test = { "FILE", file_url, "file:///C:/windows/win.ini", FALSE, - "file:", FALSE, + "file:", TRUE, NULL, FALSE, NULL, FALSE, "", TRUE, @@ -171,7 +171,7 @@ static void test_protocol(IHTMLLocation *loc, const struct location_test *test) test->name, E_POINTER, hres); hres = IHTMLLocation_get_protocol(loc, &str); - todo_wine ok(hres == S_OK, "%s: get_protocol failed: 0x%08x\n", test->name, hres); + ok(hres == S_OK, "%s: get_protocol failed: 0x%08x\n", test->name, hres); if(hres == S_OK){ if(test->protocol_ok) ok(str_eq_wa(str, test->protocol),