From 4e77355f3a94e00a826fd91c564c1a524d0b7093 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Mon, 2 May 2016 15:39:28 +0200 Subject: [PATCH] mshtml: Fix HTMLWindow3_setInterval behavior on 0 msec intervals. Signed-off-by: Piotr Caban Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/mshtml_private.h | 2 +- dlls/mshtml/task.c | 5 ++++- dlls/mshtml/tests/events.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 9fe8a750832..8c522c253e3 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -1096,7 +1096,7 @@ HRESULT push_task(task_t*,task_proc_t,task_proc_t,LONG) DECLSPEC_HIDDEN; void remove_target_tasks(LONG) DECLSPEC_HIDDEN; void flush_pending_tasks(LONG) DECLSPEC_HIDDEN; -HRESULT set_task_timer(HTMLInnerWindow*,DWORD,BOOL,IDispatch*,LONG*) DECLSPEC_HIDDEN; +HRESULT set_task_timer(HTMLInnerWindow*,LONG,BOOL,IDispatch*,LONG*) DECLSPEC_HIDDEN; HRESULT clear_task_timer(HTMLInnerWindow*,BOOL,DWORD) DECLSPEC_HIDDEN; const char *debugstr_mshtml_guid(const GUID*) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/task.c b/dlls/mshtml/task.c index a8210311432..2a520b72405 100644 --- a/dlls/mshtml/task.c +++ b/dlls/mshtml/task.c @@ -183,7 +183,7 @@ static BOOL queue_timer(thread_data_t *thread_data, task_timer_t *timer) return FALSE; } -HRESULT set_task_timer(HTMLInnerWindow *window, DWORD msec, BOOL interval, IDispatch *disp, LONG *id) +HRESULT set_task_timer(HTMLInnerWindow *window, LONG msec, BOOL interval, IDispatch *disp, LONG *id) { thread_data_t *thread_data; task_timer_t *timer; @@ -199,6 +199,9 @@ HRESULT set_task_timer(HTMLInnerWindow *window, DWORD msec, BOOL interval, IDisp if(!timer) return E_OUTOFMEMORY; + if(msec < 1) + msec = 1; + timer->id = id_cnt++; timer->window = window; timer->time = tc + msec; diff --git a/dlls/mshtml/tests/events.c b/dlls/mshtml/tests/events.c index 78fdb70c947..c9dedf32f98 100644 --- a/dlls/mshtml/tests/events.c +++ b/dlls/mshtml/tests/events.c @@ -2259,6 +2259,25 @@ static void test_timeout(IHTMLDocument2 *doc) hres = IHTMLWindow2_clearTimeout(window, id); ok(hres == S_OK, "clearTimeout failed: %08x\n", hres); + V_VT(&expr) = VT_DISPATCH; + V_DISPATCH(&expr) = (IDispatch*)&timeoutFunc; + V_VT(&var) = VT_EMPTY; + id = 0; + hres = IHTMLWindow3_setInterval(win3, &expr, 1, &var, &id); + ok(hres == S_OK, "setInterval failed: %08x\n", hres); + ok(id, "id = 0\n"); + + SET_EXPECT(timeout); + pump_msgs(&called_timeout); + CHECK_CALLED(timeout); + + SET_EXPECT(timeout); + pump_msgs(&called_timeout); + CHECK_CALLED(timeout); + + hres = IHTMLWindow2_clearInterval(window, id); + ok(hres == S_OK, "clearTimeout failer: %08x\n", hres); + IHTMLWindow3_Release(win3); }