From 1075118cdbdc261011bf3af46dd21101f0f42ace Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 1 Oct 2012 15:06:32 +0400 Subject: [PATCH] mshtml: Implement IHTMLFrameBase_put_name(). --- dlls/mshtml/htmlframebase.c | 24 ++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 25 ++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmlframebase.c b/dlls/mshtml/htmlframebase.c index 55a56db5d80..acb493a7fa1 100644 --- a/dlls/mshtml/htmlframebase.c +++ b/dlls/mshtml/htmlframebase.c @@ -148,8 +148,28 @@ static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p) static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v) { HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString name_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + if(!This->nsframe && !This->nsiframe) { + ERR("No attached ns frame object\n"); + return E_UNEXPECTED; + } + + nsAString_InitDepend(&name_str, v); + if(This->nsframe) + nsres = nsIDOMHTMLFrameElement_SetName(This->nsframe, &name_str); + else + nsres = nsIDOMHTMLIFrameElement_SetName(This->nsiframe, &name_str); + nsAString_Finish(&name_str); + if(NS_FAILED(nsres)) { + ERR("SetName failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index d6fbd64cc0f..08ea83e78ca 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -4227,6 +4227,25 @@ static void _test_framebase_name(unsigned line, IHTMLElement *elem, const char * IHTMLFrameBase_Release(fbase); } +#define test_framebase_put_name(a,b) _test_framebase_put_name(__LINE__,a,b) +static void _test_framebase_put_name(unsigned line, IHTMLElement *elem, const char *name) +{ + IHTMLFrameBase *fbase; + HRESULT hres; + BSTR str; + + hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLFrameBase, (void**)&fbase); + ok(hres == S_OK, "Could not get IHTMLFrameBase interface: 0x%08x\n", hres); + + str = name ? a2bstr(name) : NULL; + hres = IHTMLFrameBase_put_name(fbase, str); + ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres); + SysFreeString(str); + + _test_framebase_name(line, elem, name); + IHTMLFrameBase_Release(fbase); +} + static void test_framebase(IUnknown *unk) { IHTMLFrameBase *fbase; @@ -6273,12 +6292,16 @@ static void test_frameset(IHTMLDocument2 *doc) test_framebase((IUnknown*)elem); test_framebase_name(elem, "nm1"); - + test_framebase_put_name(elem, "frame name"); + test_framebase_put_name(elem, NULL); + test_framebase_put_name(elem, "nm1"); IHTMLElement_Release(elem); /* get_name with no name attr */ elem = get_doc_elem_by_id(doc, "fr3"); test_framebase_name(elem, NULL); + test_framebase_put_name(elem, "frame name"); + test_framebase_put_name(elem, NULL); IHTMLElement_Release(elem); IHTMLWindow2_Release(window);