mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
mshtml: Report user agent matching current compat mode.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5d11104689
commit
bbb46e819d
3 changed files with 37 additions and 12 deletions
|
@ -1157,6 +1157,27 @@ static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static unsigned int get_ua_version(OmNavigator *navigator)
|
||||
{
|
||||
switch(dispex_compat_mode(&navigator->dispex)) {
|
||||
case COMPAT_MODE_QUIRKS:
|
||||
return UAS_EXACTLEGACY | 7;
|
||||
case COMPAT_MODE_IE5:
|
||||
case COMPAT_MODE_IE7:
|
||||
return 7;
|
||||
case COMPAT_MODE_IE8:
|
||||
return 8;
|
||||
case COMPAT_MODE_IE9:
|
||||
return 9;
|
||||
case COMPAT_MODE_IE10:
|
||||
return 10;
|
||||
case COMPAT_MODE_IE11:
|
||||
return 11;
|
||||
}
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
|
||||
{
|
||||
OmNavigator *This = impl_from_IOmNavigator(iface);
|
||||
|
@ -1169,7 +1190,7 @@ static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
|
|||
TRACE("(%p)->(%p)\n", This, p);
|
||||
|
||||
size = sizeof(user_agent);
|
||||
hres = ObtainUserAgentString(0, user_agent, &size);
|
||||
hres = ObtainUserAgentString(get_ua_version(This), user_agent, &size);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
@ -1197,7 +1218,7 @@ static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
|
|||
TRACE("(%p)->(%p)\n", This, p);
|
||||
|
||||
size = sizeof(user_agent);
|
||||
hres = ObtainUserAgentString(0, user_agent, &size);
|
||||
hres = ObtainUserAgentString(get_ua_version(This), user_agent, &size);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
|
|
|
@ -360,3 +360,15 @@ async_test("script_load", function() {
|
|||
elem.src = "jsstream.php?simple";
|
||||
external.writeStream("simple", "ready_states += 'exec,';");
|
||||
});
|
||||
|
||||
sync_test("navigator", function() {
|
||||
var v = document.documentMode, re;
|
||||
var app = navigator.appVersion;
|
||||
ok(navigator.userAgent === "Mozilla/" + app,
|
||||
"userAgent = " + navigator.userAgent + " appVersion = " + app);
|
||||
|
||||
re = v < 11
|
||||
? "^" + (v < 9 ? "4" : "5") + "\\.0 \\(compatible; MSIE " + (v < 7 ? 7 : v) + "\\.0; Windows NT [^\\)]*\\)$"
|
||||
: "^5.0 \\(Windows NT [0-9].[0-9]; .*Trident/[678]\\.0.*rv:11.0\\) like Gecko$";
|
||||
ok(new RegExp(re).test(app), "appVersion = " + app);
|
||||
});
|
||||
|
|
|
@ -6383,25 +6383,17 @@ static void test_navigator(IHTMLDocument2 *doc)
|
|||
bstr = NULL;
|
||||
hres = IOmNavigator_get_userAgent(navigator, &bstr);
|
||||
ok(hres == S_OK, "get_userAgent failed: %08x\n", hres);
|
||||
todo_wine
|
||||
ok(!lstrcmpW(bstr, buf), "userAgent returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), wine_dbgstr_w(buf));
|
||||
SysFreeString(bstr);
|
||||
|
||||
if(!wcsncmp(buf, L"Mozilla/", 8)) {
|
||||
bstr = NULL;
|
||||
hres = IOmNavigator_get_appVersion(navigator, &bstr);
|
||||
ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
|
||||
ok(!lstrcmpW(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), wine_dbgstr_w(buf+8));
|
||||
SysFreeString(bstr);
|
||||
}else {
|
||||
skip("nonstandard user agent\n");
|
||||
}
|
||||
|
||||
hres = UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ua, sizeof(ua), 0);
|
||||
ok(hres == S_OK, "UrlMkSetSessionOption failed: %08x\n", hres);
|
||||
MultiByteToWideChar(CP_ACP, 0, ua, -1, buf, ARRAY_SIZE(buf));
|
||||
|
||||
hres = IOmNavigator_get_appVersion(navigator, &bstr);
|
||||
ok(hres == S_OK, "get_appVersion failed: %08x\n", hres);
|
||||
todo_wine
|
||||
ok(!lstrcmpW(bstr, buf+8), "appVersion returned %s, expected \"%s\"\n", wine_dbgstr_w(bstr), wine_dbgstr_w(buf+8));
|
||||
SysFreeString(bstr);
|
||||
|
||||
|
|
Loading…
Reference in a new issue