diff --git a/dlls/mshtml/omnavigator.c b/dlls/mshtml/omnavigator.c index e6ce680f08b..30333347e64 100644 --- a/dlls/mshtml/omnavigator.c +++ b/dlls/mshtml/omnavigator.c @@ -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; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index b079042afff..76c9b828805 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -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); +}); diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 3c9deec7d0b..de33e6c73a5 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -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);