Skip to content

Commit

Permalink
mshtml: Only default to IE11 mode for Internet URL Zones when the app…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
g-insn authored and julliard committed Jul 15, 2022
1 parent 46bbcd6 commit 3301a8e
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
23 changes: 22 additions & 1 deletion dlls/mshtml/mutation.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ole2.h"
#include "shlguid.h"
#include "wininet.h"
#include "winternl.h"

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

static nsIContentUtils *content_utils;

static BOOL is_iexplore(void)
{
static volatile char cache = -1;
BOOL ret = cache;
if(ret == -1) {
const WCHAR *p, *name = NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer;
if((p = wcsrchr(name, '/'))) name = p + 1;
if((p = wcsrchr(name, '\\'))) name = p + 1;
ret = !wcsicmp(name, L"iexplore.exe");
cache = ret;
}
return ret;
}

static PRUnichar *handle_insert_comment(HTMLDocumentNode *doc, const PRUnichar *comment)
{
unsigned majorv = 0, minorv = 0, compat_version;
Expand Down Expand Up @@ -823,7 +838,13 @@ static void NSAPI nsDocumentObserver_BindToDocument(nsIDocumentObserver *iface,

TRACE("doctype node\n");

if(This->window && This->window->base.outer_window) {
/* Native mshtml hardcodes special behavior for iexplore.exe here. The feature control registry
keys under HKLM or HKCU\Software\Microsoft\Internet Explorer\Main\FeatureControl are not used
in this case (neither in Wow6432Node), although FEATURE_BROWSER_EMULATION does override this,
but it is not set by default on native, and the behavior is still different. This was tested
by removing all iexplore.exe values from any FeatureControl subkeys, and renaming the test
executable to iexplore.exe, which changed its default compat mode in such cases. */
if(This->window && This->window->base.outer_window && is_iexplore()) {
HTMLOuterWindow *window = This->window->base.outer_window;
DWORD zone;
HRESULT hres;
Expand Down
3 changes: 3 additions & 0 deletions dlls/mshtml/tests/dom.c
Original file line number Diff line number Diff line change
Expand Up @@ -11449,6 +11449,9 @@ static void test_quirks_mode(void)
expected_document_mode = 5;
run_domtest("<html><body></body></html>", test_document_mode);

expected_document_mode = 7;
run_domtest("<!DOCTYPE html>\n<html></html>", test_document_mode);

if(!is_ie9plus)
return;

Expand Down
23 changes: 23 additions & 0 deletions dlls/mshtml/tests/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -3734,6 +3734,28 @@ static void run_script_as_http_with_mode(const char *script, const char *opt, co
run_from_path(L"/index.html", opt ? opt : script);
}

static void test_strict_mode(void)
{
sprintf(index_html_data,
"<!DOCTYPE html>\n"
"<html>\n"
" <head>\n"
" <script src=\"winetest.js\" type=\"text/javascript\"></script>\n"
" <script type=\"text/javascript\">\n"
" function test() {\n"
" ok(document.documentMode === 7, 'document mode = ' + document.documentMode);\n"
" next_test();\n"
" }\n"
" var tests = [ test ];\n"
" </script>\n"
" </head>\n"
" <body onload=\"run_tests();\">\n"
" </body>\n"
"</html>\n");

run_from_path(L"/index.html", "test_strict_mode");
}

static void init_protocol_handler(void)
{
IInternetSession *internet_session;
Expand Down Expand Up @@ -3767,6 +3789,7 @@ static void run_js_tests(void)

init_protocol_handler();

test_strict_mode();
run_script_as_http_with_mode("xhr.js", NULL, "9");
run_script_as_http_with_mode("xhr.js", NULL, "10");
run_script_as_http_with_mode("xhr.js", NULL, "11");
Expand Down

0 comments on commit 3301a8e

Please sign in to comment.