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

mshtml: Added IDOMEvent::get_timeStamp implementation.

parent d2213e20
...@@ -219,7 +219,8 @@ HRESULT get_class_typeinfo(const CLSID *clsid, ITypeInfo **typeinfo) ...@@ -219,7 +219,8 @@ HRESULT get_class_typeinfo(const CLSID *clsid, ITypeInfo **typeinfo)
CASE_VT(VT_VARIANT, VARIANT, *); \ CASE_VT(VT_VARIANT, VARIANT, *); \
CASE_VT(VT_PTR, void*, V_BYREF); \ CASE_VT(VT_PTR, void*, V_BYREF); \
CASE_VT(VT_UNKNOWN, IUnknown*, V_UNKNOWN); \ CASE_VT(VT_UNKNOWN, IUnknown*, V_UNKNOWN); \
CASE_VT(VT_DISPATCH, IDispatch*, V_DISPATCH) CASE_VT(VT_DISPATCH, IDispatch*, V_DISPATCH); \
CASE_VT(VT_UI8, ULONGLONG, V_UI8)
static BOOL is_arg_type_supported(VARTYPE vt) static BOOL is_arg_type_supported(VARTYPE vt)
{ {
......
...@@ -1054,8 +1054,11 @@ static HRESULT WINAPI DOMEvent_get_target(IDOMEvent *iface, IEventTarget **p) ...@@ -1054,8 +1054,11 @@ static HRESULT WINAPI DOMEvent_get_target(IDOMEvent *iface, IEventTarget **p)
static HRESULT WINAPI DOMEvent_get_timeStamp(IDOMEvent *iface, ULONGLONG *p) static HRESULT WINAPI DOMEvent_get_timeStamp(IDOMEvent *iface, ULONGLONG *p)
{ {
DOMEvent *This = impl_from_IDOMEvent(iface); DOMEvent *This = impl_from_IDOMEvent(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL; TRACE("(%p)->(%p)\n", This, p);
*p = This->time_stamp;
return S_OK;
} }
static HRESULT WINAPI DOMEvent_get_type(IDOMEvent *iface, BSTR *p) static HRESULT WINAPI DOMEvent_get_type(IDOMEvent *iface, BSTR *p)
...@@ -1208,6 +1211,10 @@ static dispex_static_data_t DOMEvent_dispex = { ...@@ -1208,6 +1211,10 @@ static dispex_static_data_t DOMEvent_dispex = {
static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id) static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id)
{ {
DOMEvent *event; DOMEvent *event;
FILETIME time;
/* 1601 to 1970 is 369 years plus 89 leap days */
const ULONGLONG time_epoch = (ULONGLONG)(369 * 365 + 89) * 86400 * 1000;
event = heap_alloc_zero(sizeof(*event)); event = heap_alloc_zero(sizeof(*event));
if(!event) if(!event)
...@@ -1227,6 +1234,11 @@ static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id) ...@@ -1227,6 +1234,11 @@ static DOMEvent *alloc_event(nsIDOMEvent *nsevent, eventid_t event_id)
event->cancelable = (event_info[event_id].flags & EVENT_CANCELABLE) != 0; event->cancelable = (event_info[event_id].flags & EVENT_CANCELABLE) != 0;
} }
nsIDOMEvent_AddRef(event->nsevent = nsevent); nsIDOMEvent_AddRef(event->nsevent = nsevent);
GetSystemTimeAsFileTime(&time);
event->time_stamp = (((ULONGLONG)time.dwHighDateTime<<32) + time.dwLowDateTime) / 10000
- time_epoch;
return event; return event;
} }
......
...@@ -67,6 +67,7 @@ typedef struct { ...@@ -67,6 +67,7 @@ typedef struct {
WCHAR *type; WCHAR *type;
EventTarget *target; EventTarget *target;
EventTarget *current_target; EventTarget *current_target;
ULONGLONG time_stamp;
BOOL bubbles; BOOL bubbles;
BOOL cancelable; BOOL cancelable;
BOOL prevent_default; BOOL prevent_default;
......
...@@ -295,10 +295,10 @@ function test_prevent_default() { ...@@ -295,10 +295,10 @@ function test_prevent_default() {
var calls; var calls;
div.addEventListener("click", function(e) { div.addEventListener("click", function(e) {
calls += "div,";
ok(e.defaultPrevented === false, "e.defaultPrevented = " + e.defaultPrevented); ok(e.defaultPrevented === false, "e.defaultPrevented = " + e.defaultPrevented);
e.preventDefault(); e.preventDefault();
ok(e.defaultPrevented === e.cancelable, "e.defaultPrevented = " + e.defaultPrevented); ok(e.defaultPrevented === e.cancelable, "e.defaultPrevented = " + e.defaultPrevented);
calls += "div,";
}, true); }, true);
a.addEventListener("click", function(e) { a.addEventListener("click", function(e) {
...@@ -551,6 +551,44 @@ function test_recursive_dispatch() { ...@@ -551,6 +551,44 @@ function test_recursive_dispatch() {
next_test(); next_test();
} }
function test_time_stamp() {
document.body.innerHTML = '<div></div>';
var elem = document.body.firstChild;
var calls, last_time_stamp;
elem.onclick = function(event) {
ok(event.timeStamp === last_time_stamp, "timeStamp = " + event.timeStamp);
calls++;
}
var e = document.createEvent("Event");
ok(typeof(e.timeStamp) === "number", "typeof(timeStamp) = " + typeof(e.timeStamp));
ok(e.timeStamp > 0, "timeStamp = " + e.timeStamp);
var now = (new Date()).getTime();
last_time_stamp = e.timeStamp;
ok(Math.abs(now - last_time_stamp) < 3, "timeStamp " + last_time_stamp + " != now " + now);
e.initEvent("click", true, true);
ok(e.timeStamp === last_time_stamp, "timeStamp = " + e.timeStamp);
calls = 0;
elem.dispatchEvent(e);
ok(calls === 1, "calls = " + calls);
ok(e.timeStamp === last_time_stamp, "timeStamp = " + e.timeStamp);
elem.onclick = function(event) {
ok(event.timeStamp > 0, "timeStamp = " + event.timeStamp);
trace("timestamp " + event.timeStamp);
calls++;
}
calls = 0;
elem.click();
ok(calls === 1, "calls = " + calls);
next_test();
}
var tests = [ var tests = [
test_content_loaded, test_content_loaded,
test_add_remove_listener, test_add_remove_listener,
...@@ -563,5 +601,6 @@ var tests = [ ...@@ -563,5 +601,6 @@ var tests = [
test_current_target, test_current_target,
test_dispatch_event, test_dispatch_event,
test_recursive_dispatch, test_recursive_dispatch,
test_time_stamp,
test_listener_order test_listener_order
]; ];
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