mshtml: Expose IEventTarget to scripts.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-11-01 16:44:02 +01:00 committed by Alexandre Julliard
parent 0c0dd3d582
commit 1366b33c81
6 changed files with 67 additions and 3 deletions

View File

@ -2205,6 +2205,12 @@ HRESULT EventTarget_QI(EventTarget *event_target, REFIID riid, void **ppv)
return E_NOINTERFACE;
}
void EventTarget_init_dispex_info(dispex_data_t *dispex_info, compat_mode_t compat_mode)
{
if(compat_mode >= COMPAT_MODE_IE9)
dispex_info_add_interface(dispex_info, IEventTarget_tid, NULL);
}
static int event_id_cmp(const void *key, const struct wine_rb_entry *entry)
{
return (INT_PTR)key - WINE_RB_ENTRY_VALUE(entry, listener_container_t, entry)->event_id;

View File

@ -1425,6 +1425,8 @@ void HTMLDOMNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
{
if(mode >= COMPAT_MODE_IE9)
dispex_info_add_interface(info, IHTMLDOMNode3_tid, NULL);
EventTarget_init_dispex_info(info, mode);
}
static const cpc_entry_t HTMLDOMNode_cpc[] = {{NULL}};

View File

@ -3016,6 +3016,14 @@ static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD
return hres;
}
static compat_mode_t HTMLWindow_get_compat_mode(DispatchEx *dispex)
{
HTMLInnerWindow *This = impl_from_DispatchEx(dispex);
This->doc->document_mode_locked = TRUE;
return This->doc->document_mode;
}
static void HTMLWindow_bind_event(DispatchEx *dispex, eventid_t eid)
{
HTMLInnerWindow *This = impl_from_DispatchEx(dispex);
@ -3025,6 +3033,7 @@ static void HTMLWindow_bind_event(DispatchEx *dispex, eventid_t eid)
static void HTMLWindow_init_dispex_info(dispex_data_t *info, compat_mode_t compat_mode)
{
dispex_info_add_interface(info, IHTMLWindow5_tid, NULL);
EventTarget_init_dispex_info(info, compat_mode);
}
static IHTMLEventObj *HTMLWindow_set_current_event(DispatchEx *dispex, IHTMLEventObj *event)
@ -3038,7 +3047,7 @@ static const event_target_vtbl_t HTMLWindow_event_target_vtbl = {
NULL,
NULL,
HTMLWindow_invoke,
NULL,
HTMLWindow_get_compat_mode,
NULL
},
HTMLWindow_bind_event,

View File

@ -129,6 +129,7 @@ typedef struct EventTarget EventTarget;
XIID(IDocumentSelector) \
XIID(IElementSelector) \
XIID(IElementTraversal) \
XIID(IEventTarget) \
XIID(IHTMLAnchorElement) \
XIID(IHTMLAreaElement) \
XIID(IHTMLAttributeCollection) \
@ -1041,6 +1042,7 @@ void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,disp
void EventTarget_Init(EventTarget*,IUnknown*,dispex_static_data_t*,compat_mode_t) DECLSPEC_HIDDEN;
HRESULT EventTarget_QI(EventTarget*,REFIID,void**) DECLSPEC_HIDDEN;
void EventTarget_init_dispex_info(dispex_data_t*,compat_mode_t) DECLSPEC_HIDDEN;
HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**) DECLSPEC_HIDDEN;
void HTMLDOMNode_destructor(HTMLDOMNode*) DECLSPEC_HIDDEN;

View File

@ -38,6 +38,9 @@ function test_elem_props() {
test_exposed("onsubmit", v >= 9);
test_exposed("getElementsByClassName", v >= 9);
test_exposed("removeAttributeNS", v >= 9);
test_exposed("addEventListener", v >= 9);
test_exposed("removeEventListener", v >= 9);
test_exposed("dispatchEvent", v >= 9);
next_test();
}
@ -56,6 +59,9 @@ function test_doc_props() {
test_exposed("prefix", v >= 9);
test_exposed("defaultView", v >= 9);
test_exposed("head", v >= 9);
test_exposed("addEventListener", v >= 9);
test_exposed("removeEventListener", v >= 9);
test_exposed("dispatchEvent", v >= 9);
test_exposed("parentWindow", true);
if(v >= 9) ok(document.defaultView === document.parentWindow, "defaultView != parentWindow");
@ -63,6 +69,42 @@ function test_doc_props() {
next_test();
}
function test_window_props() {
function test_exposed(prop, expect) {
if(expect)
ok(prop in window, prop + " not found in window.");
else
ok(!(prop in window), prop + " found in window.");
}
var v = document.documentMode;
test_exposed("addEventListener", v >= 9);
test_exposed("removeEventListener", v >= 9);
test_exposed("dispatchEvent", v >= 9);
next_test();
}
function test_xhr_props() {
var xhr = new XMLHttpRequest();
function test_exposed(prop, expect) {
if(expect)
ok(prop in xhr, prop + " not found in XMLHttpRequest.");
else
ok(!(prop in xhr), prop + " found in XMLHttpRequest.");
}
var v = document.documentMode;
test_exposed("addEventListener", v >= 9);
test_exposed("removeEventListener", v >= 9);
test_exposed("dispatchEvent", v >= 9);
next_test();
}
function test_elem_by_id() {
document.body.innerHTML = '<form id="testid" name="testname"></form>';
@ -156,6 +198,8 @@ var tests = [
test_iframe_doc_mode,
test_elem_props,
test_doc_props,
test_window_props,
test_xhr_props,
test_elem_by_id,
test_conditional_comments
];

View File

@ -785,7 +785,8 @@ static const tid_t HTMLXMLHttpRequest_iface_tids[] = {
static dispex_static_data_t HTMLXMLHttpRequest_dispex = {
&HTMLXMLHttpRequest_event_target_vtbl.dispex_vtbl,
DispHTMLXMLHttpRequest_tid,
HTMLXMLHttpRequest_iface_tids
HTMLXMLHttpRequest_iface_tids,
EventTarget_init_dispex_info
};
@ -898,7 +899,7 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor
ret->IHTMLXMLHttpRequest_iface.lpVtbl = &HTMLXMLHttpRequestVtbl;
ret->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfo2Vtbl;
EventTarget_Init(&ret->event_target, (IUnknown*)&ret->IHTMLXMLHttpRequest_iface,
&HTMLXMLHttpRequest_dispex, COMPAT_MODE_NONE);
&HTMLXMLHttpRequest_dispex, This->window->doc->document_mode);
ret->ref = 1;
*p = &ret->IHTMLXMLHttpRequest_iface;