It’s been almost a week and a ton of things have happened since the last time I posted. The biggest change is that our tests were more or less assigned to students, which was fine because most if not all the implementation has been done. Incidentally, I was asked to be in charge of consolidating the mochitests. The tests are stored in my github branch mouselock-tests. I was pleasantly surprised by the number of people who managed to complete their tests by Saturday night.
That said, I’ve been only doing quick looks at the code and accepting them, going with the honour system until now. I’m aiming to run through all the tests as well as looking at the code to remove the use of setTimeouts and tests that aren’t quite working.Of course, I’ve had my own tests to write, number 17 and 18.
Writing a mochitest that checked for various mouse events like mousedown, mouseup, mouseover, mouseenter, mouseleave, mouseout, and click. For mouseover, mouseenter, mouseleave, and mouseout, we need to make sure that these events are no longer triggered when we are in mouselock. For mouseup, mousedown, and click, we want to make sure that only the element that is locked can receive these events.
What I’ve Tried:
So for the mouse position related events, I created a div within a div. I full screened and locked the mouse to the larger container div and moved the mouse around the contained div to check the values.
For the mouse click events, again I created a div within a div, but this time the inside div is places right in the middle of the div that is mouse locked. The idea is that when I do any mousedown, mouseup, mouseclick event, only the div that we locked our mouse to catches the event. The inner div that is placed in the middle shouldn’t.
It works! Compared to many of the tests so far that’s just 1 or 2 tests per file, mine is something like 24 tests. It seems so deceptively simple when you look at the original description but every mousedown and mouseup require a check for left, middle, and right mouse clicks, and having to keep track of the numbers can get really messy.
The final stretch is here now. The first implementation (where mouselock requires full screen) is almost complete, just one or two dangling things. I plan to look at how mozilla’s full screen api handles focus lost and seeing how we can implement that for mouse lock. As well, there are still some tests remaining that need to be done and I might help do some of those as well.