Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmltextnode.c | 30 +++++++++++++++++++++++++++--- dlls/mshtml/tests/documentmode.js | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmltextnode.c b/dlls/mshtml/htmltextnode.c index 56a0572..be20be5 100644 --- a/dlls/mshtml/htmltextnode.c +++ b/dlls/mshtml/htmltextnode.c @@ -128,8 +128,31 @@ static HRESULT WINAPI HTMLDOMTextNode_get_data(IHTMLDOMTextNode *iface, BSTR *p) static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *String) { HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface); - FIXME("(%p)->(%p)\n", This, String); - return E_NOTIMPL; + const PRUnichar *str; + + TRACE("(%p)->(%p)\n", This, String); + + if(!String) + return E_INVALIDARG; + + str = dispex_tostring(&This->node.event_target.dispex); + if(!wcscmp(str, L"[object]")) { + nsAString nsstr; + nsresult nsres; + + nsAString_Init(&nsstr, NULL); + nsres = nsIDOMText_GetData(This->nstext, &nsstr); + if(NS_FAILED(nsres)) { + nsAString_Finish(&nsstr); + return map_nsresult(nsres); + } + nsAString_GetData(&nsstr, &str); + *String = SysAllocString(str); + nsAString_Finish(&nsstr); + }else { + *String = SysAllocString(str); + } + return *String ? S_OK : E_OUTOFMEMORY; }
static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p) @@ -361,7 +384,8 @@ static dispex_static_data_t HTMLDOMTextNode_dispex = { NULL, DispHTMLDOMTextNode_tid, HTMLDOMTextNode_iface_tids, - HTMLDOMNode_init_dispex_info + HTMLDOMNode_init_dispex_info, + L"[object Text]" };
HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **node) diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 037631b..5f78791 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -166,6 +166,8 @@ sync_test("builtin_toString", function() { ok(s === (v < 9 ? "[object]" : (v < 11 ? "[object Document]" : "[object HTMLDocument]")), "document.toString returned " + s); s = document.body.style.toString(); ok(s === (v < 9 ? "[object]" : "[object MSStyleCSSProperties]"), "document.body.style.toString returned " + s); + s = document.createTextNode("testNode").toString(); + ok(s === (v < 9 ? "testNode" : "[object Text]"), "text node 'testNode' toString returned " + s); });
sync_test("elem_props", function() {