[PATCH v2 1/8] mshtml: Implement IHTMLElement::toString.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Sep 24 08:45:30 CDT 2021


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/mshtml/dispex.c              |  10 ++
 dlls/mshtml/htmlanchor.c          |   3 +-
 dlls/mshtml/htmlarea.c            |   3 +-
 dlls/mshtml/htmlbody.c            |   3 +-
 dlls/mshtml/htmlcomment.c         |   3 +-
 dlls/mshtml/htmlelem.c            | 163 +++++++++++++++++++++++++-----
 dlls/mshtml/htmlform.c            |   3 +-
 dlls/mshtml/htmlframe.c           |   6 +-
 dlls/mshtml/htmlhead.c            |  12 ++-
 dlls/mshtml/htmlimg.c             |   3 +-
 dlls/mshtml/htmlinput.c           |   9 +-
 dlls/mshtml/htmllink.c            |   3 +-
 dlls/mshtml/htmlobject.c          |   6 +-
 dlls/mshtml/htmlscript.c          |   3 +-
 dlls/mshtml/htmlselect.c          |   6 +-
 dlls/mshtml/htmlstyleelem.c       |   3 +-
 dlls/mshtml/htmltable.c           |   9 +-
 dlls/mshtml/htmltextarea.c        |   3 +-
 dlls/mshtml/mshtml_private.h      |   2 +
 dlls/mshtml/tests/documentmode.js | 142 ++++++++++++++++++++++++++
 20 files changed, 341 insertions(+), 54 deletions(-)

diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index 64ead8f..797f024 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -1482,6 +1482,16 @@ compat_mode_t dispex_compat_mode(DispatchEx *dispex)
         : dispex->info->desc->vtbl->get_compat_mode(dispex);
 }
 
+const WCHAR *dispex_tostring(DispatchEx *dispex)
+{
+    const WCHAR *str = dispex->info->desc->tostring_name;
+
+    /* Empty string is special for all modes */
+    if((!str || str[0]) && dispex_compat_mode(dispex) < COMPAT_MODE_IE9)
+        str = L"[object]";
+    return str;
+}
+
 static dispex_data_t *ensure_dispex_info(dispex_static_data_t *desc, compat_mode_t compat_mode)
 {
     if(!desc->info_cache[compat_mode]) {
diff --git a/dlls/mshtml/htmlanchor.c b/dlls/mshtml/htmlanchor.c
index da48601..5a402ad 100644
--- a/dlls/mshtml/htmlanchor.c
+++ b/dlls/mshtml/htmlanchor.c
@@ -860,7 +860,8 @@ static dispex_static_data_t HTMLAnchorElement_dispex = {
     NULL,
     DispHTMLAnchorElement_tid,
     HTMLAnchorElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L""
 };
 
 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlarea.c b/dlls/mshtml/htmlarea.c
index a0708c4..4e4eed3 100644
--- a/dlls/mshtml/htmlarea.c
+++ b/dlls/mshtml/htmlarea.c
@@ -452,7 +452,8 @@ static dispex_static_data_t HTMLAreaElement_dispex = {
     NULL,
     DispHTMLAreaElement_tid,
     HTMLAreaElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L""
 };
 
 HRESULT HTMLAreaElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c
index 32c49fe..63f92a0 100644
--- a/dlls/mshtml/htmlbody.c
+++ b/dlls/mshtml/htmlbody.c
@@ -1011,7 +1011,8 @@ static dispex_static_data_t HTMLBodyElement_dispex = {
     NULL,
     DispHTMLBody_tid,
     HTMLBodyElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLBodyElement]"
 };
 
 HRESULT HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlcomment.c b/dlls/mshtml/htmlcomment.c
index 85eceef..b628cf8 100644
--- a/dlls/mshtml/htmlcomment.c
+++ b/dlls/mshtml/htmlcomment.c
@@ -202,7 +202,8 @@ static dispex_static_data_t HTMLCommentElement_dispex = {
     NULL,
     DispHTMLCommentElement_tid,
     HTMLCommentElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLCommentElement]"
 };
 
 HRESULT HTMLCommentElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index d9554f4..8546c19 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -47,31 +47,116 @@ typedef struct {
 } tag_desc_t;
 
 static const tag_desc_t tag_descs[] = {
-    {L"A",         HTMLAnchorElement_Create},
-    {L"AREA",      HTMLAreaElement_Create},
-    {L"BODY",      HTMLBodyElement_Create},
-    {L"BUTTON",    HTMLButtonElement_Create},
-    {L"EMBED",     HTMLEmbedElement_Create},
-    {L"FORM",      HTMLFormElement_Create},
-    {L"FRAME",     HTMLFrameElement_Create},
-    {L"HEAD",      HTMLHeadElement_Create},
-    {L"HTML",      HTMLHtmlElement_Create},
-    {L"IFRAME",    HTMLIFrame_Create},
-    {L"IMG",       HTMLImgElement_Create},
-    {L"INPUT",     HTMLInputElement_Create},
-    {L"LABEL",     HTMLLabelElement_Create},
-    {L"LINK",      HTMLLinkElement_Create},
-    {L"META",      HTMLMetaElement_Create},
-    {L"OBJECT",    HTMLObjectElement_Create},
-    {L"OPTION",    HTMLOptionElement_Create},
-    {L"SCRIPT",    HTMLScriptElement_Create},
-    {L"SELECT",    HTMLSelectElement_Create},
-    {L"STYLE",     HTMLStyleElement_Create},
-    {L"TABLE",     HTMLTable_Create},
-    {L"TD",        HTMLTableCell_Create},
-    {L"TEXTAREA",  HTMLTextAreaElement_Create},
-    {L"TITLE",     HTMLTitleElement_Create},
-    {L"TR",        HTMLTableRow_Create}
+    {L"A",              HTMLAnchorElement_Create},
+    {L"ABBR",           NULL},
+    {L"ACRONYM",        NULL},
+    {L"ADDRESS",        NULL},
+    {L"APPLET",         NULL},
+    {L"AREA",           HTMLAreaElement_Create},
+    {L"ARTICLE",        NULL},
+    {L"ASIDE",          NULL},
+    {L"AUDIO",          NULL},
+    {L"B",              NULL},
+    {L"BASE",           NULL},
+    {L"BASEFONT",       NULL},
+    {L"BDO",            NULL},
+    {L"BIG",            NULL},
+    {L"BLOCKQUOTE",     NULL},
+    {L"BODY",           HTMLBodyElement_Create},
+    {L"BR",             NULL},
+    {L"BUTTON",         HTMLButtonElement_Create},
+    {L"CANVAS",         NULL},
+    {L"CAPTION",        NULL},
+    {L"CENTER",         NULL},
+    {L"CITE",           NULL},
+    {L"CODE",           NULL},
+    {L"COL",            NULL},
+    {L"COLGROUP",       NULL},
+    {L"DATALIST",       NULL},
+    {L"DD",             NULL},
+    {L"DEL",            NULL},
+    {L"DFN",            NULL},
+    {L"DIR",            NULL},
+    {L"DIV",            NULL},
+    {L"DL",             NULL},
+    {L"DT",             NULL},
+    {L"EM",             NULL},
+    {L"EMBED",          HTMLEmbedElement_Create},
+    {L"FIELDSET",       NULL},
+    {L"FIGCAPTION",     NULL},
+    {L"FIGURE",         NULL},
+    {L"FONT",           NULL},
+    {L"FOOTER",         NULL},
+    {L"FORM",           HTMLFormElement_Create},
+    {L"FRAME",          HTMLFrameElement_Create},
+    {L"FRAMESET",       NULL},
+    {L"H1",             NULL},
+    {L"H2",             NULL},
+    {L"H3",             NULL},
+    {L"H4",             NULL},
+    {L"H5",             NULL},
+    {L"H6",             NULL},
+    {L"HEAD",           HTMLHeadElement_Create},
+    {L"HEADER",         NULL},
+    {L"HR",             NULL},
+    {L"HTML",           HTMLHtmlElement_Create},
+    {L"I",              NULL},
+    {L"IFRAME",         HTMLIFrame_Create},
+    {L"IMG",            HTMLImgElement_Create},
+    {L"INPUT",          HTMLInputElement_Create},
+    {L"INS",            NULL},
+    {L"KBD",            NULL},
+    {L"LABEL",          HTMLLabelElement_Create},
+    {L"LEGEND",         NULL},
+    {L"LI",             NULL},
+    {L"LINK",           HTMLLinkElement_Create},
+    {L"MAP",            NULL},
+    {L"MARK",           NULL},
+    {L"META",           HTMLMetaElement_Create},
+    {L"NAV",            NULL},
+    {L"NOFRAMES",       NULL},
+    {L"NOSCRIPT",       NULL},
+    {L"OBJECT",         HTMLObjectElement_Create},
+    {L"OL",             NULL},
+    {L"OPTGROUP",       NULL},
+    {L"OPTION",         HTMLOptionElement_Create},
+    {L"P",              NULL},
+    {L"PARAM",          NULL},
+    {L"PRE",            NULL},
+    {L"PROGRESS",       NULL},
+    {L"Q",              NULL},
+    {L"RP",             NULL},
+    {L"RT",             NULL},
+    {L"RUBY",           NULL},
+    {L"S",              NULL},
+    {L"SAMP",           NULL},
+    {L"SCRIPT",         HTMLScriptElement_Create},
+    {L"SECTION",        NULL},
+    {L"SELECT",         HTMLSelectElement_Create},
+    {L"SMALL",          NULL},
+    {L"SOURCE",         NULL},
+    {L"SPAN",           NULL},
+    {L"STRIKE",         NULL},
+    {L"STRONG",         NULL},
+    {L"STYLE",          HTMLStyleElement_Create},
+    {L"SUB",            NULL},
+    {L"SUP",            NULL},
+    {L"TABLE",          HTMLTable_Create},
+    {L"TBODY",          NULL},
+    {L"TD",             HTMLTableCell_Create},
+    {L"TEXTAREA",       HTMLTextAreaElement_Create},
+    {L"TFOOT",          NULL},
+    {L"TH",             NULL},
+    {L"THEAD",          NULL},
+    {L"TITLE",          HTMLTitleElement_Create},
+    {L"TR",             HTMLTableRow_Create},
+    {L"TRACK",          NULL},
+    {L"TT",             NULL},
+    {L"U",              NULL},
+    {L"UL",             NULL},
+    {L"VAR",            NULL},
+    {L"VIDEO",          NULL},
+    {L"WBR",            NULL}
 };
 
 static const tag_desc_t *get_tag_desc(const WCHAR *tag_name)
@@ -2112,8 +2197,30 @@ static HRESULT WINAPI HTMLElement_get_ondragstart(IHTMLElement *iface, VARIANT *
 static HRESULT WINAPI HTMLElement_toString(IHTMLElement *iface, BSTR *String)
 {
     HTMLElement *This = impl_from_IHTMLElement(iface);
-    FIXME("(%p)->(%p)\n", This, String);
-    return E_NOTIMPL;
+    const PRUnichar *str;
+    nsAString tag_str;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, String);
+
+    if(!String)
+        return E_INVALIDARG;
+
+    str = dispex_tostring(&This->node.event_target.dispex);
+    if(!str) {
+        nsAString_Init(&tag_str, NULL);
+        nsres = nsIDOMElement_GetTagName(This->dom_element, &tag_str);
+        if(NS_FAILED(nsres)) {
+            nsAString_Finish(&tag_str);
+            return map_nsresult(nsres);
+        }
+        nsAString_GetData(&tag_str, &str);
+        str = get_tag_desc(str) ? L"[object HTMLElement]" : L"[object HTMLUnknownElement]";
+        nsAString_Finish(&tag_str);
+    }
+
+    *String = SysAllocString(str);
+    return *String ? S_OK : E_OUTOFMEMORY;
 }
 
 static HRESULT WINAPI HTMLElement_put_onbeforeupdate(IHTMLElement *iface, VARIANT v)
@@ -6806,7 +6913,7 @@ HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_g
     nsAString_GetData(&tag_name_str, &tag_name);
 
     tag = get_tag_desc(tag_name);
-    if(tag) {
+    if(tag && tag->constructor) {
         hres = tag->constructor(doc, nselem, &elem);
     }else {
         nsIDOMSVGElement *svg_element;
diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c
index 5d0928e..5846f46 100644
--- a/dlls/mshtml/htmlform.c
+++ b/dlls/mshtml/htmlform.c
@@ -830,7 +830,8 @@ static dispex_static_data_t HTMLFormElement_dispex = {
     NULL,
     DispHTMLFormElement_tid,
     HTMLFormElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLFormElement]"
 };
 
 HRESULT HTMLFormElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlframe.c b/dlls/mshtml/htmlframe.c
index 7118ea8..5f17b8d 100644
--- a/dlls/mshtml/htmlframe.c
+++ b/dlls/mshtml/htmlframe.c
@@ -1026,7 +1026,8 @@ static dispex_static_data_t HTMLFrameElement_dispex = {
     NULL,
     DispHTMLFrameElement_tid,
     HTMLFrameElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLFrameElement]"
 };
 
 HRESULT HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -1606,7 +1607,8 @@ static dispex_static_data_t HTMLIFrame_dispex = {
     NULL,
     DispHTMLIFrame_tid,
     HTMLIFrame_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLIFrameElement]"
 };
 
 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlhead.c b/dlls/mshtml/htmlhead.c
index 5dbf8d6..85958e1 100644
--- a/dlls/mshtml/htmlhead.c
+++ b/dlls/mshtml/htmlhead.c
@@ -172,7 +172,8 @@ static dispex_static_data_t HTMLTitleElement_dispex = {
     NULL,
     DispHTMLTitleElement_tid,
     HTMLTitleElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLTitleElement]"
 };
 
 HRESULT HTMLTitleElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -355,7 +356,8 @@ static dispex_static_data_t HTMLHtmlElement_dispex = {
     NULL,
     DispHTMLHtmlElement_tid,
     HTMLHtmlElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLHtmlElement]"
 };
 
 HRESULT HTMLHtmlElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -591,7 +593,8 @@ static dispex_static_data_t HTMLMetaElement_dispex = {
     NULL,
     DispHTMLMetaElement_tid,
     HTMLMetaElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLMetaElement]"
 };
 
 HRESULT HTMLMetaElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -754,7 +757,8 @@ static dispex_static_data_t HTMLHeadElement_dispex = {
     NULL,
     DispHTMLHeadElement_tid,
     HTMLHeadElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLHeadElement]"
 };
 
 HRESULT HTMLHeadElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index f89e8e5..6859425 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -733,7 +733,8 @@ static dispex_static_data_t HTMLImgElement_dispex = {
     NULL,
     DispHTMLImg_tid,
     HTMLImgElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLImageElement]"
 };
 
 HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c
index 1a0a739..d92e299 100644
--- a/dlls/mshtml/htmlinput.c
+++ b/dlls/mshtml/htmlinput.c
@@ -1444,7 +1444,8 @@ static dispex_static_data_t HTMLInputElement_dispex = {
     NULL,
     DispHTMLInputElement_tid,
     HTMLInputElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLInputElement]"
 };
 
 HRESULT HTMLInputElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -1640,7 +1641,8 @@ static dispex_static_data_t HTMLLabelElement_dispex = {
     NULL,
     DispHTMLLabelElement_tid,
     HTMLLabelElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLLabelElement]"
 };
 
 HRESULT HTMLLabelElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -1986,7 +1988,8 @@ static dispex_static_data_t HTMLButtonElement_dispex = {
     NULL,
     DispHTMLButtonElement_tid,
     HTMLButtonElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLButtonElement]"
 };
 
 HRESULT HTMLButtonElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmllink.c b/dlls/mshtml/htmllink.c
index ddf67ca..b11a7ca 100644
--- a/dlls/mshtml/htmllink.c
+++ b/dlls/mshtml/htmllink.c
@@ -449,7 +449,8 @@ static dispex_static_data_t HTMLLinkElement_dispex = {
     NULL,
     DispHTMLLinkElement_tid,
     HTMLLinkElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLLinkElement]"
 };
 
 HRESULT HTMLLinkElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlobject.c b/dlls/mshtml/htmlobject.c
index 6702548..814b70e 100644
--- a/dlls/mshtml/htmlobject.c
+++ b/dlls/mshtml/htmlobject.c
@@ -769,7 +769,8 @@ static dispex_static_data_t HTMLObjectElement_dispex = {
     NULL,
     DispHTMLObjectElement_tid,
     HTMLObjectElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLObjectElement]"
 };
 
 HRESULT HTMLObjectElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -1031,7 +1032,8 @@ static dispex_static_data_t HTMLEmbedElement_dispex = {
     NULL,
     DispHTMLEmbed_tid,
     HTMLEmbedElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLEmbedElement]"
 };
 
 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c
index 9b7f95e..47987e5 100644
--- a/dlls/mshtml/htmlscript.c
+++ b/dlls/mshtml/htmlscript.c
@@ -482,7 +482,8 @@ static dispex_static_data_t HTMLScriptElement_dispex = {
     NULL,
     DispHTMLScriptElement_tid,
     HTMLScriptElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLScriptElement]"
 };
 
 HRESULT HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c
index ad801f8..93a831e 100644
--- a/dlls/mshtml/htmlselect.c
+++ b/dlls/mshtml/htmlselect.c
@@ -419,7 +419,8 @@ static dispex_static_data_t HTMLOptionElement_dispex = {
     NULL,
     DispHTMLOptionElement_tid,
     HTMLOptionElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLOptionElement]"
 };
 
 HRESULT HTMLOptionElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -1284,7 +1285,8 @@ static dispex_static_data_t HTMLSelectElement_dispex = {
     NULL,
     DispHTMLSelectElement_tid,
     HTMLSelectElement_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLSelectElement]"
 };
 
 HRESULT HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmlstyleelem.c b/dlls/mshtml/htmlstyleelem.c
index d2a4a75..1b85231 100644
--- a/dlls/mshtml/htmlstyleelem.c
+++ b/dlls/mshtml/htmlstyleelem.c
@@ -465,7 +465,8 @@ static dispex_static_data_t HTMLStyleElement_dispex = {
     NULL,
     DispHTMLStyleElement_tid,
     HTMLStyleElement_iface_tids,
-    HTMLStyleElement_init_dispex_info
+    HTMLStyleElement_init_dispex_info,
+    L"[object HTMLStyleElement]"
 };
 
 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c
index 178e9e5..6367999 100644
--- a/dlls/mshtml/htmltable.c
+++ b/dlls/mshtml/htmltable.c
@@ -523,7 +523,8 @@ static dispex_static_data_t HTMLTableCell_dispex = {
     NULL,
     DispHTMLTableCell_tid,
     HTMLTableCell_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLTableDataCellElement]"
 };
 
 HRESULT HTMLTableCell_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -967,7 +968,8 @@ static dispex_static_data_t HTMLTableRow_dispex = {
     NULL,
     DispHTMLTableRow_tid,
     HTMLTableRow_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLTableRowElement]"
 };
 
 HRESULT HTMLTableRow_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
@@ -1999,7 +2001,8 @@ static dispex_static_data_t HTMLTable_dispex = {
     NULL,
     DispHTMLTable_tid,
     HTMLTable_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLTableElement]"
 };
 
 HRESULT HTMLTable_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/htmltextarea.c b/dlls/mshtml/htmltextarea.c
index 57f3373..71f0e3e 100644
--- a/dlls/mshtml/htmltextarea.c
+++ b/dlls/mshtml/htmltextarea.c
@@ -482,7 +482,8 @@ static dispex_static_data_t HTMLTextAreaElement_dispex = {
     NULL,
     DispHTMLTextAreaElement_tid,
     HTMLTextAreaElement_iface_tids,
-    HTMLElement_init_dispex_info
+    HTMLElement_init_dispex_info,
+    L"[object HTMLTextAreaElement]"
 };
 
 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index c1e7e78..67ea0ad 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -331,6 +331,7 @@ typedef struct {
     const tid_t disp_tid;
     const tid_t* const iface_tids;
     void (*init_info)(dispex_data_t*,compat_mode_t);
+    const WCHAR *tostring_name;
     dispex_data_t *info_cache[COMPAT_MODE_CNT];
     dispex_data_t *delayed_init_info;
 } dispex_static_data_t;
@@ -393,6 +394,7 @@ HRESULT get_class_typeinfo(const CLSID*,ITypeInfo**) DECLSPEC_HIDDEN;
 const void *dispex_get_vtbl(DispatchEx*) DECLSPEC_HIDDEN;
 void dispex_info_add_interface(dispex_data_t*,tid_t,const dispex_hook_t*) DECLSPEC_HIDDEN;
 compat_mode_t dispex_compat_mode(DispatchEx*) DECLSPEC_HIDDEN;
+const WCHAR *dispex_tostring(DispatchEx*) DECLSPEC_HIDDEN;
 
 typedef enum {
     DISPEXPROP_CUSTOM,
diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js
index c20f6ee..16764a5 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -19,6 +19,148 @@
 var compat_version;
 var tests = [];
 
+sync_test("builtin_toString", function() {
+    var tags = [
+        [ "a",               null ],
+        [ "abbr",            "Phrase" ],
+        [ "acronym",         "Phrase" ],
+        [ "address",         "Block" ],
+     // [ "applet",          "Applet" ],  // makes Windows pop up a dialog box
+        [ "area",            null ],
+        [ "article",         "" ],
+        [ "aside",           "" ],
+        [ "audio",           "Audio" ],
+        [ "b",               "Phrase" ],
+        [ "base",            "Base" ],
+        [ "basefont",        "BaseFont" ],
+        [ "bdi",             "Unknown" ],
+        [ "bdo",             "Phrase" ],
+        [ "big",             "Phrase" ],
+        [ "blockquote",      "Block" ],
+        [ "body",            "Body" ],
+        [ "br",              "BR" ],
+        [ "button",          "Button" ],
+        [ "canvas",          "Canvas" ],
+        [ "caption",         "TableCaption" ],
+        [ "center",          "Block" ],
+        [ "cite",            "Phrase" ],
+        [ "code",            "Phrase" ],
+        [ "col",             "TableCol" ],
+        [ "colgroup",        "TableCol" ],
+        [ "data",            "Unknown" ],
+        [ "datalist",        "DataList", 10 ],
+        [ "dd",              "DD" ],
+        [ "del",             "Mod" ],
+        [ "details",         "Unknown" ],
+        [ "dfn",             "Phrase" ],
+        [ "dialog",          "Unknown" ],
+        [ "dir",             "Directory" ],
+        [ "div",             "Div" ],
+        [ "dl",              "DList" ],
+        [ "dt",              "DT" ],
+        [ "em",              "Phrase" ],
+        [ "embed",           "Embed" ],
+        [ "fieldset",        "FieldSet" ],
+        [ "figcaption",      "" ],
+        [ "figure",          "" ],
+        [ "font",            "Font" ],
+        [ "footer",          "" ],
+        [ "form",            "Form" ],
+        [ "frame",           "Frame" ],
+        [ "frameset",        "FrameSet" ],
+        [ "h1",              "Heading" ],
+        [ "h2",              "Heading" ],
+        [ "h3",              "Heading" ],
+        [ "h4",              "Heading" ],
+        [ "h5",              "Heading" ],
+        [ "h6",              "Heading" ],
+        [ "h7",              "Unknown" ],
+        [ "head",            "Head" ],
+        [ "header",          "" ],
+        [ "hr",              "HR" ],
+        [ "html",            "Html" ],
+        [ "i",               "Phrase" ],
+        [ "iframe",          "IFrame" ],
+        [ "img",             "Image" ],
+        [ "input",           "Input" ],
+        [ "ins",             "Mod" ],
+        [ "kbd",             "Phrase" ],
+        [ "label",           "Label" ],
+        [ "legend",          "Legend" ],
+        [ "li",              "LI" ],
+        [ "link",            "Link" ],
+        [ "main",            "Unknown" ],
+        [ "map",             "Map" ],
+        [ "mark",            "" ],
+        [ "meta",            "Meta" ],
+        [ "meter",           "Unknown" ],
+        [ "nav",             "" ],
+        [ "noframes",        "" ],
+        [ "noscript",        "" ],
+        [ "object",          "Object" ],
+        [ "ol",              "OList" ],
+        [ "optgroup",        "OptGroup" ],
+        [ "option",          "Option" ],
+        [ "output",          "Unknown" ],
+        [ "p",               "Paragraph" ],
+        [ "param",           "Param" ],
+        [ "picture",         "Unknown" ],
+        [ "pre",             "Pre" ],
+        [ "progress",        "Progress", 10 ],
+        [ "q",               "Quote" ],
+        [ "rp",              "Phrase" ],
+        [ "rt",              "Phrase" ],
+        [ "ruby",            "Phrase" ],
+        [ "s",               "Phrase" ],
+        [ "samp",            "Phrase" ],
+        [ "script",          "Script" ],
+        [ "section",         "" ],
+        [ "select",          "Select" ],
+        [ "small",           "Phrase" ],
+        [ "source",          "Source" ],
+        [ "span",            "Span" ],
+        [ "strike",          "Phrase" ],
+        [ "strong",          "Phrase" ],
+        [ "style",           "Style" ],
+        [ "sub",             "Phrase" ],
+        [ "summary",         "Unknown" ],
+        [ "sup",             "Phrase" ],
+        [ "svg",             "Unknown" ],
+        [ "table",           "Table" ],
+        [ "tbody",           "TableSection" ],
+        [ "td",              "TableDataCell" ],
+        [ "template",        "Unknown" ],
+        [ "textarea",        "TextArea" ],
+        [ "tfoot",           "TableSection" ],
+        [ "th",              "TableHeaderCell" ],
+        [ "thead",           "TableSection" ],
+        [ "time",            "Unknown" ],
+        [ "title",           "Title" ],
+        [ "tr",              "TableRow" ],
+        [ "track",           "Track", 10 ],
+        [ "tt",              "Phrase" ],
+        [ "u",               "Phrase" ],
+        [ "ul",              "UList" ],
+        [ "var",             "Phrase" ],
+        [ "video",           "Video" ],
+        [ "wbr",             "" ],
+        [ "winetest",        "Unknown" ]
+    ];
+    var v = document.documentMode;
+
+    for(var i = 0; i < tags.length; i++) {
+        var s = document.createElement(tags[i][0]).toString();
+        if(tags[i][1] === null)
+            ok(s === "", "tag '" + tags[i][0] + "' toString returned " + s);
+        else if(v < 9)
+            ok(s === "[object]", "tag '" + tags[i][0] + "' toString returned " + s);
+        else if(tags[i].length < 3 || v >= tags[i][2]) {
+            todo_wine_if(tags[i][1] !== "" && s === "[object HTMLElement]").
+            ok(s === "[object HTML" + tags[i][1] + "Element]", "tag '" + tags[i][0] + "' toString returned " + s);
+        }
+    }
+});
+
 sync_test("elem_props", function() {
     var elem = document.documentElement;
 
-- 
2.31.1




More information about the wine-devel mailing list