Skip to content

Firefox bug 702161 – part II

January 19, 2012

In my last post I described the work I have been doing on Firefox bug 702161.  I got ( what I think ) is a fix and I was ready to write some tests.  Personally I hate writing tests, as I’m sure everyone does, but they are essential ( especially in an open source project where many people are touching the code ).  The unit tests that I had to write this time weren’t so much annoying as most that I write are, but more just hard to figure out a good way to write tests for.  I have had a few ideas over the past 2 days how to test what I wrote and nothing seems to be easy or viable.

My initial idea was to get a reference to each element of the controls that I needed to test and get a list of all of the listeners attached to it.  Initially my problem was trying to get a list of those listeners, as currently there is no way to do so from the native javascript code.  After talking to Jon and Dave in irc a bit Jon linked me to a file that he thought I might find helpful.  The file showed how to include and use an interface that was setup to do what I needed to do.  There was a code that I had never seen before and had little to no idea what it actually did internally, but I used it non the less.  Including the interface gave me access to its methods, in particular getListenerInfoFor().  getListenerInfoFor would return me a list of all the listeners on a given element, which is exactly what I needed.  At this point all I needed to do was get a reference to each part of the controls and I was but a hop, skip, and a jump away from finishing my tests.  Sadly, this wasn’t the case.  After digging through various files and looking for a way to access the controls directly from JavaScript ( some how I ended up looking through XPCOM code? ).  After 5 hours of searching on Tuesday night I went to bed still wondering what I needed to do.  Earlier today I spoke with jaws in the #introduction channel on irc and asked him how I could get a reference to the controls.  I was then told it was not possible, and that the controls were designed so I couldn’t get a reference to them.  Sadly I accepted this and went back to the drawing board.

Another idea that I had, tho not as good as the above one, was to use some of the EventUtils tests that Firefox has to offer.  The one in particular that caught my eye was synthesizeMouseExpectEvent. From what I understood about this test method was that I could go to a x,y location, synthesize a click, and check to see if any events resulted from that click ( or mouse movement ). It would be perfect if I could do this because I can check to see if there is an event thrown initially, then somehow call the terminate method ( still haven’t figured that out either ), and check to make sure that no event is thrown the second time. The problem I ran into here was that I couldn’t get the test method to work properly with the video controls, which leads me to believe that what I want to do isn’t possible with this either. I set up a dummy test case with a button and on click listener and the test method worked fine. As soon as I tried a similar approach on the controls it didn’t work. What I’m guessing is the issue here is that the event that is being fired is being stopped from bubbling up to a point where I can catch it. I am going to have to do a bit of searching tomorrow on this theory and see if my assumption is correct.

Other than this I am pretty much at a standstill with this bug. I have thrown what I have done up for an initial look over and hope to get some good feedback. In the meantime I am going to take a break from this bug and start on one of my others in the meantime. I’ve got a few other cool ones, so I don’t feel bad about taking a break from this for a day or so :)

About these ads
One Comment

Trackbacks & Pingbacks

  1. OSD700 – First release! « David Seifried

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: