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

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-02-08 17:37:25 +01:00 committed by Alexandre Julliard
parent 71750bd80d
commit 91321d97cf
2 changed files with 18 additions and 5 deletions

View file

@ -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;
}

View file

@ -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);