mshtml: Added IOmNavigator::get_userAgent implementation.

This commit is contained in:
Jacek Caban 2009-09-02 12:28:07 +02:00 committed by Alexandre Julliard
parent 4eead9d092
commit c4bc5be262
2 changed files with 30 additions and 2 deletions

View File

@ -179,8 +179,24 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
{
OmNavigator *This = OMNAVIGATOR_THIS(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
char user_agent[512];
DWORD size;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
size = sizeof(user_agent);
hres = ObtainUserAgentString(0, user_agent, &size);
if(FAILED(hres))
return hres;
size = MultiByteToWideChar(CP_ACP, 0, user_agent, -1, NULL, 0);
*p = SysAllocStringLen(NULL, size-1);
if(!*p)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, user_agent, -1, *p, size);
return S_OK;
}
static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)

View File

@ -2444,6 +2444,8 @@ static void test_navigator(IHTMLDocument2 *doc)
{
IHTMLWindow2 *window;
IOmNavigator *navigator, *navigator2;
char buf[512];
DWORD size;
ULONG ref;
BSTR bstr;
HRESULT hres;
@ -2501,6 +2503,16 @@ static void test_navigator(IHTMLDocument2 *doc)
ok(!strcmp_wa(bstr, "[object]"), "toString returned %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
size = sizeof(buf);
hres = ObtainUserAgentString(0, buf, &size);
ok(hres == S_OK, "ObtainUserAgentString failed: %08x\n", hres);
bstr = NULL;
hres = IOmNavigator_get_userAgent(navigator, &bstr);
ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
ok(!strcmp_wa(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), buf);
SysFreeString(bstr);
ref = IOmNavigator_Release(navigator);
ok(!ref, "navigator should be destroyed here\n");
}