Commit 91321d97 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Support custom user agent strings in IOmNavigator::get_appVersion.

parent 71750bd8
......@@ -1008,6 +1008,7 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
char user_agent[512];
DWORD size;
HRESULT hres;
const unsigned skip_prefix = 8; /* strlen("Mozilla/") */
TRACE("(%p)->(%p)\n", This, p);
......@@ -1016,17 +1017,17 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
if(FAILED(hres))
return hres;
if(strncmp(user_agent, "Mozilla/", 8)) {
FIXME("Unsupported user agent\n");
return E_FAIL;
if(size <= skip_prefix) {
*p = NULL;
return S_OK;
}
size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
size = MultiByteToWideChar(CP_ACP, 0, user_agent + skip_prefix, -1, NULL, 0);
*p = SysAllocStringLen(NULL, size-1);
if(!*p)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
MultiByteToWideChar(CP_ACP, 0, user_agent + skip_prefix, -1, *p, size);
return S_OK;
}
......
......@@ -6228,6 +6228,7 @@ static void test_navigator(IHTMLDocument2 *doc)
HRESULT hres;
static const WCHAR v40[] = {'4','.','0'};
static char ua[] = "1234567890xxxABC";
hres = IHTMLDocument2_get_parentWindow(doc, &window);
ok(hres == S_OK, "parentWidnow failed: %08x\n", hres);
......@@ -6336,6 +6337,17 @@ static void test_navigator(IHTMLDocument2 *doc)
skip("nonstandard user agent\n");
}
hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ua, sizeof(ua), 0);
ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
hres = IOmNavigator_get_appVersion(navigator, &bstr);
ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
ok(!strcmp_wa(bstr, ua+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
SysFreeString(bstr);
hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, buf, strlen(buf), 0);
ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
bstr = NULL;
hres = IOmNavigator_get_appMinorVersion(navigator, &bstr);
ok(hres == S_OK, "get_appMonorVersion failed: %08x\n", hres);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment