mshtml: Use user agent string in IOmNavigator::get_appVersion.

This commit is contained in:
Jacek Caban 2010-03-13 16:46:18 +01:00 committed by Alexandre Julliard
parent 42a80aeac0
commit 115efbed69
2 changed files with 26 additions and 7 deletions

View File

@ -160,19 +160,28 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
{
OmNavigator *This = OMNAVIGATOR_THIS(iface);
/* FIXME: Should we return something smarter? */
static const WCHAR app_verW[] =
{'4','.','0',' ','(','c','o','m','p','a','t','i','b','l','e',';',
' ','M','S','I','E',' ','7','.','0',';',
' ','W','i','n','d','o','w','s',' ','N','T',' ','5','.','1',';',
' ','M','o','z','i','l','l','a','/','4','.','0',')',0};
char user_agent[512];
DWORD size;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
*p = SysAllocString(app_verW);
size = sizeof(user_agent);
hres = ObtainUserAgentString(0, user_agent, &size);
if(FAILED(hres))
return hres;
if(strncmp(user_agent, "Mozilla/", 8)) {
FIXME("Unsupported user agent\n");
return E_FAIL;
}
size = MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, NULL, 0);
*p = SysAllocStringLen(NULL, size-1);
if(!*p)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, user_agent+8, -1, *p, size);
return S_OK;
}

View File

@ -3173,6 +3173,16 @@ static void test_navigator(IHTMLDocument2 *doc)
ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
SysFreeString(bstr);
if(!strncmp(buf, "Mozilla/", 8)) {
bstr = NULL;
hres = IOmNavigator_get_appVersion(navigator, &bstr);
ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
ok(!strcmp_wa(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf+8);
SysFreeString(bstr);
}else {
skip("nonstandard user agent\n");
}
ref = IOmNavigator_Release(navigator);
ok(!ref, "navigator should be destroyed here\n");
}