[PATCH v2 3/8] mshtml: Implement IHTMLDocument::toString properly.
Gabriel Ivăncescu
gabrielopcode at gmail.com
Fri Sep 24 08:45:32 CDT 2021
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
dlls/mshtml/htmldoc.c | 15 +++++++++++++--
dlls/mshtml/tests/documentmode.js | 2 ++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 9faf987..bc56792 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1700,13 +1700,23 @@ static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARI
static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
{
HTMLDocument *This = impl_from_IHTMLDocument2(iface);
+ compat_mode_t compat_mode;
+ DispatchEx *dispex;
+ const WCHAR *str;
TRACE("(%p)->(%p)\n", This, String);
if(!String)
return E_INVALIDARG;
- *String = SysAllocString(L"[object]");
+ dispex = &This->doc_node->node.event_target.dispex;
+ compat_mode = dispex_compat_mode(dispex);
+ if(COMPAT_MODE_IE9 <= compat_mode && compat_mode <= COMPAT_MODE_IE10)
+ str = L"[object Document]";
+ else
+ str = dispex_tostring(dispex);
+
+ *String = SysAllocString(str);
return *String ? S_OK : E_OUTOFMEMORY;
}
@@ -5657,7 +5667,8 @@ static dispex_static_data_t HTMLDocumentNode_dispex = {
&HTMLDocumentNode_event_target_vtbl.dispex_vtbl,
DispHTMLDocument_tid,
HTMLDocumentNode_iface_tids,
- HTMLDocumentNode_init_dispex_info
+ HTMLDocumentNode_init_dispex_info,
+ L"[object HTMLDocument]"
};
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 546e66e..26f2373 100644
--- a/dlls/mshtml/tests/documentmode.js
+++ b/dlls/mshtml/tests/documentmode.js
@@ -162,6 +162,8 @@ sync_test("builtin_toString", function() {
s = window.toString();
ok(s === "[object Window]", "window.toString returned " + s);
+ s = document.toString();
+ ok(s === (v < 9 ? "[object]" : (v < 11 ? "[object Document]" : "[object HTMLDocument]")), "document.toString returned " + s);
});
sync_test("elem_props", function() {
--
2.31.1
More information about the wine-devel
mailing list