Search code examples
javascriptdomdom-eventsdom4

Why is event.timeStamp 0 in firefox?


http://jsfiddle.net/wDddR/3/

var input = document.createElement("input");
input.onclick = function (ev) {
    console.log(ev.timeStamp === 0 ? "WHY IS IT ZERO" : "It's not broken");
};
input.click()

var ev = document.createEvent("Event");
console.log(ev.timeStamp === 0 ? "THIS IS MADNESS" : "At least this works");

In firefox the first timeStamp is 0 and in chrome the timestamp is a sensible number.

In both firefox and chrome the second timeStamp is a sensible number.


Solution

  • http://api.jquery.com/event.timeStamp/

    Note: Due to a bug open since 2004, this value is not populated correctly in Firefox and it is not possible to know the time the event was created in that browser.

    Bug #238041 - nsDOMEvent::AllocateEvent assigns a PR_Now() into a PRUint32