Module: wine Branch: master Commit: 1366b33c81527b5d4762da6b3f7083058eb910a7 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1366b33c81527b5d4762da6b3f...
Author: Jacek Caban jacek@codeweavers.com Date: Wed Nov 1 16:44:02 2017 +0100
mshtml: Expose IEventTarget to scripts.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmlevent.c | 6 ++++++ dlls/mshtml/htmlnode.c | 2 ++ dlls/mshtml/htmlwindow.c | 11 +++++++++- dlls/mshtml/mshtml_private.h | 2 ++ dlls/mshtml/tests/documentmode.js | 44 +++++++++++++++++++++++++++++++++++++++ dlls/mshtml/xmlhttprequest.c | 5 +++-- 6 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index ee85eca..d57ff19 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -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; diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index 8f03b4a..70b0d0d 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -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}}; diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index b174de2..759f1b6 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -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, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 2098b78..98daa65 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -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; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index aaf052b..beee493 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -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 ]; diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index bbe2833..393a569 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -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;