Skip to content

Commit 3301a8e

Browse files
g-insnjulliard
authored andcommitted
mshtml: Only default to IE11 mode for Internet URL Zones when the app is IE.
For documents exposing a <!DOCTYPE> node but no specific X-UA-Compatible, mshtml defaults to IE7 compat mode, unless the app is Internet Explorer and is in Internet URL Zone. This checking for the `iexplore.exe` app name seems hardcoded into mshtml; the FeatureControl registry keys do not affect this directly, and none are set by default for iexplore.exe that would affect this, anyway. Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
1 parent 46bbcd6 commit 3301a8e

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

dlls/mshtml/mutation.c

+22-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "ole2.h"
2828
#include "shlguid.h"
2929
#include "wininet.h"
30+
#include "winternl.h"
3031

3132
#include "mshtml_private.h"
3233
#include "htmlscript.h"
@@ -52,6 +53,20 @@ static const IID NS_ICONTENTUTILS_CID =
5253

5354
static nsIContentUtils *content_utils;
5455

56+
static BOOL is_iexplore(void)
57+
{
58+
static volatile char cache = -1;
59+
BOOL ret = cache;
60+
if(ret == -1) {
61+
const WCHAR *p, *name = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
62+
if((p = wcsrchr(name, '/'))) name = p + 1;
63+
if((p = wcsrchr(name, '\\'))) name = p + 1;
64+
ret = !wcsicmp(name, L"iexplore.exe");
65+
cache = ret;
66+
}
67+
return ret;
68+
}
69+
5570
static PRUnichar *handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *comment)
5671
{
5772
unsigned majorv = 0, minorv = 0, compat_version;
@@ -823,7 +838,13 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,
823838

824839
TRACE("doctype node\n");
825840

826-
if(This->window && This->window->base.outer_window) {
841+
/* Native mshtml hardcodes special behavior for iexplore.exe here. The feature control registry
842+
keys under HKLM or HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl are not used
843+
in this case (neither in Wow6432Node), although FEATURE_BROWSER_EMULATION does override this,
844+
but it is not set by default on native, and the behavior is still different. This was tested
845+
by removing all iexplore.exe values from any FeatureControl subkeys, and renaming the test
846+
executable to iexplore.exe, which changed its default compat mode in such cases. */
847+
if(This->window && This->window->base.outer_window && is_iexplore()) {
827848
HTMLOuterWindow *window = This->window->base.outer_window;
828849
DWORD zone;
829850
HRESULT hres;

dlls/mshtml/tests/dom.c

+3
Original file line numberDiff line numberDiff line change
@@ -11449,6 +11449,9 @@ static void test_quirks_mode(void)
1144911449
expected_document_mode = 5;
1145011450
run_domtest("<html><body></body></html>", test_document_mode);
1145111451

11452+
expected_document_mode = 7;
11453+
run_domtest("<!DOCTYPE html>\n<html></html>", test_document_mode);
11454+
1145211455
if(!is_ie9plus)
1145311456
return;
1145411457

dlls/mshtml/tests/script.c

+23
Original file line numberDiff line numberDiff line change
@@ -3734,6 +3734,28 @@ static void run_script_as_http_with_mode(const char *script, const char *opt, co
37343734
run_from_path(L"/index.html", opt ? opt : script);
37353735
}
37363736

3737+
static void test_strict_mode(void)
3738+
{
3739+
sprintf(index_html_data,
3740+
"<!DOCTYPE html>\n"
3741+
"<html>\n"
3742+
" <head>\n"
3743+
" <script src=\"winetest.js\" type=\"text/javascript\"></script>\n"
3744+
" <script type=\"text/javascript\">\n"
3745+
" function test() {\n"
3746+
" ok(document.documentMode === 7, 'document mode = ' + document.documentMode);\n"
3747+
" next_test();\n"
3748+
" }\n"
3749+
" var tests = [ test ];\n"
3750+
" </script>\n"
3751+
" </head>\n"
3752+
" <body onload=\"run_tests();\">\n"
3753+
" </body>\n"
3754+
"</html>\n");
3755+
3756+
run_from_path(L"/index.html", "test_strict_mode");
3757+
}
3758+
37373759
static void init_protocol_handler(void)
37383760
{
37393761
IInternetSession *internet_session;
@@ -3767,6 +3789,7 @@ static void run_js_tests(void)
37673789

37683790
init_protocol_handler();
37693791

3792+
test_strict_mode();
37703793
run_script_as_http_with_mode("xhr.js", NULL, "9");
37713794
run_script_as_http_with_mode("xhr.js", NULL, "10");
37723795
run_script_as_http_with_mode("xhr.js", NULL, "11");

0 commit comments

Comments
 (0)