From bbffabf1b1c8d3fe78861912a14e3ddf78ebe913 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 2 Nov 2017 16:47:53 +0100 Subject: [PATCH] mshtml: Added IDOMEvent::get_defaultPrevented implementation. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmlevent.c | 7 +++++-- dlls/mshtml/tests/events.js | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index d57ff19ee22..9e232bebe72 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -995,8 +995,11 @@ static HRESULT WINAPI DOMEvent_get_currentTarget(IDOMEvent *iface, IEventTarget static HRESULT WINAPI DOMEvent_get_defaultPrevented(IDOMEvent *iface, VARIANT_BOOL *p) { DOMEvent *This = impl_from_IDOMEvent(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, p); + + *p = variant_bool(This->prevent_default); + return S_OK; } static HRESULT WINAPI DOMEvent_get_eventPhase(IDOMEvent *iface, USHORT *p) diff --git a/dlls/mshtml/tests/events.js b/dlls/mshtml/tests/events.js index 4a064f98329..4c552b65085 100644 --- a/dlls/mshtml/tests/events.js +++ b/dlls/mshtml/tests/events.js @@ -267,6 +267,31 @@ function test_stop_propagation() { next_test(); } +function test_prevent_default() { + document.body.innerHTML = '
'; + var div = document.body.firstChild; + var a = div.firstChild; + var calls; + + div.addEventListener("click", function(e) { + calls += "div,"; + ok(e.defaultPrevented === false, "e.defaultPrevented = " + e.defaultPrevented); + e.preventDefault(); + ok(e.defaultPrevented === true, "e.defaultPrevented = " + e.defaultPrevented); + }, true); + + a.addEventListener("click", function(e) { + calls += "a,"; + ok(e.defaultPrevented === true, "e.defaultPrevented = " + e.defaultPrevented); + }, true); + + calls = ""; + a.click(); + ok(calls === "div,a,", "calls = " + calls); + + next_test(); +} + var tests = [ test_content_loaded, test_add_remove_listener, @@ -274,5 +299,6 @@ var tests = [ test_remove_listener_in_listener, test_event_phase, test_stop_propagation, + test_prevent_default, test_listener_order ];