diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index c11f6d13dca..c77f2b7f3a0 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -1924,6 +1924,19 @@ static dispex_static_data_t DOMMouseEvent_dispex = { DOMMouseEvent_iface_tids }; +static const tid_t DOMKeyboardEvent_iface_tids[] = { + IDOMEvent_tid, + IDOMUIEvent_tid, + IDOMKeyboardEvent_tid, + 0 +}; + +static dispex_static_data_t DOMKeyboardEvent_dispex = { + NULL, + DispDOMKeyboardEvent_tid, + DOMKeyboardEvent_iface_tids +}; + static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id) { dispex_static_data_t *dispex_data = &DOMEvent_dispex; @@ -1972,7 +1985,9 @@ static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id) event->mouse_event = NULL; nsres = nsIDOMEvent_QueryInterface(nsevent, &IID_nsIDOMKeyEvent, (void**)&event->keyboard_event); - if(NS_FAILED(nsres)) + if(NS_SUCCEEDED(nsres)) + dispex_data = &DOMKeyboardEvent_dispex; + else event->keyboard_event = NULL; init_dispex(&event->dispex, (IUnknown*)&event->IDOMEvent_iface, dispex_data); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 79d0d6a2bf7..5ed626477fe 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -81,6 +81,7 @@ typedef struct EventTarget EventTarget; XDIID(DispCPlugins) \ XDIID(DispDOMChildrenCollection) \ XDIID(DispDOMEvent) \ + XDIID(DispDOMKeyboardEvent) \ XDIID(DispDOMMouseEvent) \ XDIID(DispDOMUIEvent) \ XDIID(DispHTMLAnchorElement) \ @@ -130,6 +131,7 @@ typedef struct EventTarget EventTarget; XDIID(HTMLDocumentEvents) \ XDIID(HTMLElementEvents2) \ XIID(IDOMEvent) \ + XIID(IDOMKeyboardEvent) \ XIID(IDOMMouseEvent) \ XIID(IDOMUIEvent) \ XIID(IDocumentEvent) \ diff --git a/dlls/mshtml/tests/events.js b/dlls/mshtml/tests/events.js index 7d88852d42b..bf37b3f2424 100644 --- a/dlls/mshtml/tests/events.js +++ b/dlls/mshtml/tests/events.js @@ -684,6 +684,25 @@ function test_ui_event() { next_test(); } +function test_keyboard_event() { + var e; + + e = document.createEvent("KeyboardEvent"); + + e.initEvent("test", true, true); + ok(e.key === "", "key = " + e.key); + ok(e.keyCode === 0, "keyCode = " + e.keyCode); + ok(e.charCode === 0, "charCode = " + e.charCode); + ok(e.repeat === false, "repeat = " + e.repeat); + ok(e.ctrlKey === false, "ctrlKey = " + e.ctrlKey); + ok(e.altKey === false, "altKey = " + e.altKey); + ok(e.shiftKey === false, "shiftKey = " + e.shiftKey); + ok(e.metaKey === false, "metaKey = " + e.metaKey); + ok(e.detail === 0, "detail = " + e.detail); + + next_test(); +} + var tests = [ test_content_loaded, test_add_remove_listener, @@ -698,6 +717,7 @@ var tests = [ test_recursive_dispatch, test_ui_event, test_mouse_event, + test_keyboard_event, test_time_stamp, test_listener_order ];