Commit e3e17965 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Implement IDOMMessageEvent::data property.

parent 223704aa
......@@ -2150,6 +2150,7 @@ static void DOMCustomEvent_destroy(DOMEvent *event)
typedef struct {
DOMEvent event;
IDOMMessageEvent IDOMMessageEvent_iface;
WCHAR *data;
} DOMMessageEvent;
static inline DOMMessageEvent *impl_from_IDOMMessageEvent(IDOMMessageEvent *iface)
......@@ -2209,10 +2210,9 @@ static HRESULT WINAPI DOMMessageEvent_get_data(IDOMMessageEvent *iface, BSTR *p)
{
DOMMessageEvent *This = impl_from_IDOMMessageEvent(iface);
FIXME("(%p)->(%p)\n", This, p);
TRACE("(%p)->(%p)\n", This, p);
*p = NULL;
return S_OK;
return (*p = SysAllocString(This->data)) ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI DOMMessageEvent_get_origin(IDOMMessageEvent *iface, BSTR *p)
......@@ -2268,6 +2268,8 @@ static void *DOMMessageEvent_query_interface(DOMEvent *event, REFIID riid)
static void DOMMessageEvent_destroy(DOMEvent *event)
{
DOMMessageEvent *message_event = DOMMessageEvent_from_DOMEvent(event);
heap_free(message_event->data);
}
static const tid_t DOMEvent_iface_tids[] = {
......@@ -2513,6 +2515,26 @@ HRESULT create_document_event(HTMLDocumentNode *doc, eventid_t event_id, DOMEven
return S_OK;
}
HRESULT create_message_event(HTMLDocumentNode *doc, BSTR data, DOMEvent **ret)
{
DOMMessageEvent *message_event;
DOMEvent *event;
HRESULT hres;
hres = create_document_event(doc, EVENTID_MESSAGE, &event);
if(FAILED(hres))
return hres;
message_event = DOMMessageEvent_from_DOMEvent(event);
if(!(message_event->data = heap_strdupW(data))) {
IDOMEvent_Release(&event->IDOMEvent_iface);
return E_OUTOFMEMORY;
}
*ret = event;
return S_OK;
}
static HRESULT call_disp_func(IDispatch *disp, DISPPARAMS *dp, VARIANT *retv)
{
IDispatchEx *dispex;
......
......@@ -112,6 +112,7 @@ void dispatch_event(EventTarget*,DOMEvent*) DECLSPEC_HIDDEN;
HRESULT create_document_event(HTMLDocumentNode*,eventid_t,DOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_document_event_str(HTMLDocumentNode*,const WCHAR*,IDOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_event_from_nsevent(nsIDOMEvent*,compat_mode_t,DOMEvent**) DECLSPEC_HIDDEN;
HRESULT create_message_event(HTMLDocumentNode*,BSTR,DOMEvent**) DECLSPEC_HIDDEN;
void init_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void release_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
......
......@@ -2207,7 +2207,7 @@ static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VAR
return E_FAIL;
}
hres = create_document_event(This->inner_window->doc, EVENTID_MESSAGE, &event);
hres = create_message_event(This->inner_window->doc, msg, &event);
if(FAILED(hres))
return hres;
......
......@@ -796,3 +796,19 @@ async_test("detached_img_error_event", function() {
}
img.src = "about:blank";
});
async_test("message event", function() {
var listener_called = false;
window.addEventListener("message", function(e) {
listener_called = true;
ok(e.data === "test", "e.data = " + e.data);
ok(e.bubbles === false, "bubbles = " + e.bubbles);
ok(e.cancelable === false, "cancelable = " + e.cancelable);
next_test();
});
window.postMessage("test", "http://winetest.example.org");
todo_wine.
ok(listener_called == false, "listener already called");
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment