Commit 24c10e70 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Post messages asynchronously in IE9+ modes.

parent e3e17965
......@@ -2194,6 +2194,25 @@ static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *ifac
return E_NOTIMPL;
}
struct post_message_task {
task_t header;
HTMLInnerWindow *window;
DOMEvent *event;
} ;
static void post_message_proc(task_t *_task)
{
struct post_message_task *task = (struct post_message_task *)_task;
dispatch_event(&task->window->event_target, task->event);
}
static void post_message_destr(task_t *_task)
{
struct post_message_task *task = (struct post_message_task *)_task;
IDOMEvent_Release(&task->event->IDOMEvent_iface);
IHTMLWindow2_Release(&task->window->base.IHTMLWindow2_iface);
}
static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
{
HTMLWindow *This = impl_from_IHTMLWindow6(iface);
......@@ -2211,6 +2230,20 @@ static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VAR
if(FAILED(hres))
return hres;
if(dispex_compat_mode(&This->inner_window->event_target.dispex) >= COMPAT_MODE_IE9) {
struct post_message_task *task;
if(!(task = heap_alloc(sizeof(*task)))) {
IDOMEvent_Release(&event->IDOMEvent_iface);
return E_OUTOFMEMORY;
}
task->event = event;
task->window = This->inner_window;
IHTMLWindow2_AddRef(&task->window->base.IHTMLWindow2_iface);
return push_task(&task->header, post_message_proc, post_message_destr,
This->inner_window->task_magic);
}
dispatch_event(&This->inner_window->event_target, event);
IDOMEvent_Release(&event->IDOMEvent_iface);
return S_OK;
......
......@@ -1331,3 +1331,14 @@ sync_test("__proto__", function() {
r = Object.getPrototypeOf(x);
ok(r === ctor.prototype, "x.__proto__ after delete = " + r);
});
async_test("postMessage", function() {
var v = document.documentMode;
var onmessage_called = false;
window.onmessage = function() {
onmessage_called = true;
next_test();
}
window.postMessage("test", "*");
ok(onmessage_called == (v < 9 ? true : false), "onmessage not called");
});
......@@ -809,6 +809,5 @@ async_test("message event", function() {
});
window.postMessage("test", "http://winetest.example.org");
todo_wine.
ok(listener_called == false, "listener already called");
});
......@@ -365,20 +365,6 @@ function test_xhr() {
ok(typeof(xhr) === "object", "typeof(xhr) = " + typeof(xhr));
}
function test_postMessage() {
if(!("postMessage" in window)) {
win_skip("postMessage not available");
return;
}
var onmessage_called = false;
window.onmessage = function() {
onmessage_called = true;
}
window.postMessage("test", "*");
ok(onmessage_called, "onmessage not called");
}
var globalVar = false;
function runTests() {
......@@ -405,7 +391,6 @@ function runTests() {
test_language_attribute();
test_text_node();
test_xhr();
test_postMessage();
var r = window.execScript("globalVar = true;");
ok(r === undefined, "execScript returned " + r);
......
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