However, when I test KeyboardEvents in the latest Tor Browser, I only see rounding to 100 ms. With the debugger I observed that calling myKeyboardEvent.timeStamp in the browser console is calling Event::TimeStamp() instead of KeyboardEvent::TimeStamp. So we're apparently failing to properly override the Event::TimeStamp call.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
If we want to make sure that KeyboardEvent::timeStamp rounding to 250 ms is exposed to content JS, we can make Event::timeStamp virtual (and fix the return type of KeyboardEvent::timeStamp). Here's an example fixup, probably not for use.
But I'm not sure this is really useful, as it's still very easy to get 100-ms precision on keystroke times. Just ignore KeyboardEvent.timeStamp and use Date.now() on the KeyboardEvent handler:
document.addEventListener("keydown", e => console.log(e.key + ": " + Date.now()));
So I'm proposing the following patch instead, which simply removes our original change to KeyboardEvent.h. Then we would rely on the 100-ms rounding inside Event.cpp, which is already applied to KeyboardEvents. (If it looks like 100-ms is unsufficient jitter for KeyboardEvents, then we may want to increase the rounding for all JS timing sources.)
Looks good to me. And if that has always been as your patch proposes then we probably won't have a ton of users coming to us complaining about broken websites/games/whatever.
However, it bothers me a bit that we did not catch that earlier. Could we maybe have a test for that (a new ticket for it is fine)?
Looks good to me. And if that has always been as your patch proposes then we probably won't have a ton of users coming to us complaining about broken websites/games/whatever.
However, it bothers me a bit that we did not catch that earlier. Could we maybe have a test for that (a new ticket for it is fine)?
Agreed. I posted regression tests at ticket:19193#comment:1.