From d631268fa1ae03ce124fec9934043d98a24cd940 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 24 Aug 2017 12:29:17 +0200 Subject: [PATCH] mshtml: Properly expose IHTMLDocument6 interface to scripts. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmldoc.c | 19 ++++++++++++++++--- dlls/mshtml/tests/documentmode.js | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 8d48e1896b8..ed3075b4dbc 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -4887,19 +4887,32 @@ static const tid_t HTMLDocumentNode_iface_tids[] = { IHTMLDOMNode_tid, IHTMLDOMNode2_tid, IHTMLDocument2_tid, - IHTMLDocument3_tid, IHTMLDocument4_tid, IHTMLDocument5_tid, - IHTMLDocument6_tid, IDocumentSelector_tid, 0 }; +void HTMLDocumentNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode) +{ + HTMLDOMNode_init_dispex_info(info, mode); + + /* Depending on compatibility version, we add interfaces in different order + * so that the right getElementById implementation is used. */ + if(mode < COMPAT_MODE_IE8) { + dispex_info_add_interface(info, IHTMLDocument3_tid, NULL); + dispex_info_add_interface(info, IHTMLDocument6_tid, NULL); + }else { + dispex_info_add_interface(info, IHTMLDocument6_tid, NULL); + dispex_info_add_interface(info, IHTMLDocument3_tid, NULL); + } +} + static dispex_static_data_t HTMLDocumentNode_dispex = { &HTMLDocumentNode_dispex_vtbl, DispHTMLDocument_tid, HTMLDocumentNode_iface_tids, - HTMLDOMNode_init_dispex_info + HTMLDocumentNode_init_dispex_info }; static HTMLDocumentNode *alloc_doc_node(HTMLDocumentObj *doc_obj, HTMLInnerWindow *window) diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 4224dfe68f5..9453bdc167e 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -55,6 +55,21 @@ function test_doc_props() { next_test(); } +function test_elem_by_id() { + document.body.innerHTML = '
'; + + var id_elem = document.getElementById("testid"); + ok(id_elem.tagName === "FORM", "id_elem.tagName = " + id_elem.tagName); + + var name_elem = document.getElementById("testname"); + if(document.documentMode < 8) + ok(id_elem === name_elem, "id_elem != id_elem"); + else + ok(name_elem === null, "name_elem != null"); + + next_test(); +} + function test_doc_mode() { compat_version = parseInt(document.location.search.substring(1)); @@ -116,5 +131,6 @@ var tests = [ test_doc_mode, test_elem_props, test_doc_props, + test_elem_by_id, test_conditional_comments ];