From 05dc7eac8d21297f6eed0508a9e38b9d990a50ce Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 13 Sep 2012 12:29:17 +0200 Subject: [PATCH] mshtml: Added IHTMLDocument4::fireEvent implementation. --- dlls/mshtml/htmldoc3.c | 6 ++++-- dlls/mshtml/htmlevent.c | 11 ++++------- dlls/mshtml/tests/events.html | 29 +++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c index 62564505d46..f34f0a2032e 100644 --- a/dlls/mshtml/htmldoc3.c +++ b/dlls/mshtml/htmldoc3.c @@ -777,8 +777,10 @@ static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEv VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled) { HTMLDocument *This = impl_from_IHTMLDocument4(iface); - FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled); - return E_NOTIMPL; + + TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled); + + return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled); } static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v, diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 6f1260a78a7..12ff2ffa3a9 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -364,13 +364,10 @@ static HRESULT WINAPI HTMLEventObj_get_srcElement(IHTMLEventObj *iface, IHTMLEle TRACE("(%p)->(%p)\n", This, p); - if(!This->target) { - *p = NULL; - return S_OK; - } - - return IHTMLDOMNode_QueryInterface(&This->target->IHTMLDOMNode_iface, &IID_IHTMLElement, - (void**)p); + *p = NULL; + if(This->target) + IHTMLDOMNode_QueryInterface(&This->target->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p); + return S_OK; } static HRESULT WINAPI HTMLEventObj_get_altKey(IHTMLEventObj *iface, VARIANT_BOOL *p) diff --git a/dlls/mshtml/tests/events.html b/dlls/mshtml/tests/events.html index fbac741c14d..ad9db3f9ff6 100644 --- a/dlls/mshtml/tests/events.html +++ b/dlls/mshtml/tests/events.html @@ -20,6 +20,16 @@ function ondataavailable_test() { ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type); } + function ondataavailableDocHandler() { + b = true; + ok(window.event === evobj, "window.event != evobj"); + + ok(evobj.srcElement === null, "evobj.srcElement = " + evobj.srcElement); + ok(evobj.fromElement === null, "evobj.srcElement = " + evobj.fromElement); + ok(evobj.toElement === null, "evobj.srcElement = " + evobj.toElement); + ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type); + } + div.attachEvent("ondataavailable", ondataavailableHandler); evobj = document.createEventObject(); @@ -33,6 +43,25 @@ function ondataavailable_test() { ok(evobj.srcElement === div, "evobj.srcElement = " + evobj.srcElement); ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type); + + div.detachEvent("ondataavailable", ondataavailableHandler); + + b = false; + div.fireEvent("ondataavailable", evobj); + ok(!b, "ondataavailable handler called?"); + + ok(evobj.srcElement === div, "evobj.srcElement = " + evobj.srcElement); + ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type); + + document.attachEvent("ondataavailable", ondataavailableDocHandler); + + evobj = document.createEventObject(); + + document.fireEvent("ondataavailable", evobj); + ok(b, "ondataavailable handler not called?"); + + ok(evobj.srcElement === null, "evobj.srcElement = " + evobj.srcElement); + ok(evobj.type === "dataavailable", "evobj.type = " + evobj.type); } function runTests() {