From b244182bae54d7c46e7a4f46a2868c6983c4b9f7 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 12 Sep 2017 13:15:37 +0200 Subject: [PATCH] mshtml: Added IHTMLDocument7::head property implementation. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmldoc.c | 34 ++++++++++++++++++++++++++++++++-- dlls/mshtml/tests/elements.js | 11 ++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index db6ee575cb3..413b0bdbf3d 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -4038,8 +4038,38 @@ static HRESULT WINAPI HTMLDocument7_get_body(IHTMLDocument7 *iface, IHTMLElement static HRESULT WINAPI HTMLDocument7_get_head(IHTMLDocument7 *iface, IHTMLElement **p) { HTMLDocument *This = impl_from_IHTMLDocument7(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsIDOMHTMLHeadElement *nshead; + nsIDOMElement *nselem; + HTMLElement *elem; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->doc_node->nsdoc) { + FIXME("No document\n"); + return E_FAIL; + } + + nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &nshead); + assert(nsres == NS_OK); + + if(!nshead) { + *p = NULL; + return S_OK; + } + + nsres = nsIDOMHTMLHeadElement_QueryInterface(nshead, &IID_nsIDOMElement, (void**)&nselem); + nsIDOMHTMLHeadElement_Release(nshead); + assert(nsres == NS_OK); + + hres = get_elem(This->doc_node, nselem, &elem); + nsIDOMElement_Release(nselem); + if(FAILED(hres)) + return hres; + + *p = &elem->IHTMLElement_iface; + return S_OK; } static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = { diff --git a/dlls/mshtml/tests/elements.js b/dlls/mshtml/tests/elements.js index ac1e2d030e0..56c4e2f5649 100644 --- a/dlls/mshtml/tests/elements.js +++ b/dlls/mshtml/tests/elements.js @@ -96,8 +96,17 @@ function test_ElementTraversal() { next_test(); } +function test_head() { + var h = document.head; + ok(h.tagName === "HEAD", "h.tagName = " + h.tagName); + ok(h === document.getElementsByTagName("head")[0], "unexpected head element"); + + next_test(); +} + var tests = [ test_input_selection, test_textContent, - test_ElementTraversal + test_ElementTraversal, + test_head ];