Progress on HTML5 <video> and <audio> tag elements unit testing for Firefox 3.1

After struggling for a bit coming up with the actual implementation of different test cases, I have consulted aid from #QA and from the all knowing Mozilla Developer Center. I have now picked up the bat and am on my way to hitting the ball.

After juggling between the first of two subareas where testing is necessary: <source> tags or readonly attributes defined in nsIDOMHTMLMediaElement, I started with the latter.

The nsIDOMHTMLMediaElement interface is used to implement the audio and video media elements in HTML. Along with this interface are a supply of different attributes, many of which are readonly and are impossible to change or alter. The only way to guarantee this is through a unit test.

Let’s look at some of these attributes, the ones that currently need testing (seek, networkState, readyState excluded):

Attribute Type Description
currentSrc DOMString The absolute URL of the chosen media resource (if, for example, the server selects a media file based on the resolution of the user’s display), or an empty string if the networkState is EMPTY. Read only.
duration float The length of the media in seconds, or zero if no media data is available.  If the media data is available but the length is unknown, this value is NaN.  If the media is streamed and has no predefined length, the value is InfRead only.
ended boolean true if playback has finished.  Read only.
error nsIDOMHTMLMediaError The media’s error status.  Read only.
paused boolean true if the media playback is currently paused.  Read only.
totalBytes unsigned long The length, in bytes, of the media resource.  If the length is unknown, or the content is streamed and therefore has no specified length, this value is 0.  Read only.

A simple snippet example would try and alter the values for these readonly attributes and the test would determine if any of these values changed.

Simple test but nonetheless an important one. For example; I wouldn’t want a script changing the currentSrc, (i.e., current source) of my video to a binary file during execution and causing a crash of the browser. It’s important that these attributes never change.

Hope this provides some insight into what I am working on now at the moment.


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: