Lightweight Test Framework, fixing how to handle

Published on Mar 24, 2009

As I mentioned in a previous post I have been playing with the Microsoft Lightweight Test Automation Framework.

The Lightweight framework handle alert and confirms without any problem, both in IE and Firefox out of the box. I guess it won’t be an issue on the Mac either. Now is another issue, a JavaScript error was thrown in both browsers.

So here is how I fix it so far (so far because I still need to deal with a nasty bug on Firefox). is not working (and a solution).

After digging around and thanks to Firebug (and at a lesser degree, the new Developer tools for IE8) I found that the problem seems to be in two places. Wait until the end of the post to change anything on your files.

My first approach.

First open the following file (in the source code solution for the framework).


We will change the following line:



Search for openWindowAndRegister: this is the function that will be assigned to by the framework to handle the calls get a new window object and add it to the browser windows collection of the TestExecutor object.

We will change the following line:

with the following code:

The temp variables are there just to help when debugging. Notice that we are calling _originalOpen on activeFrame and not activeFrame.get_jsFrame()

Now this will make functions work in IE but not in Firefox where I get an “Illegal operation on WrappedNative prototype object” exception, this seems to be a known regression on Firefox since at least version 1.07.

Upon thinking about this I notice that we should be able to actual use directly inside openWindowAndRegister.

So here goes the solution that works, I kept the changes to BrowserFrame.js but the changes to TestExecutorBase are now as follow replace :

with the following code: returns a windows object and them we can register it to the _windowCollection internal array of the TestExecutor. So far I like this solution, now I need to figure out how to write test against this new window. I guess I will leave that for another post.