I've had problems getting the tests to run consistently in IE.
2 issues:
- the test is reported to have timed out even though the frame loaded it
- Operation aborted message appears when running some tests.
I have found that the timing issues is something to do with the the onload
listener in the frame either not being called or being called before the js file
is loaded to set the load flag to false. I added a setTimeout to call the
onload function
The operation aborted problem occurs when a tests uses appendChild before the
dom object is truly ready. The frame reported it was ready too soon.
I have fixed this using a setTimeout on the setTestPage and on the _callback to
add a small buffer to guarantee the frame is ready. while my tests run a bit
slower, at least they don't randomly fail anymore.
I suspect these issue might be more prevalent when loading up some the larger js
libraries.
I thought I'd share the code in case it helps someone before MS fixes IE.
//Force the onload event to happen again for IE timing issues, sometimes it
either fires before the initial setting of the variable to false
// or the load is done and setting a new listenere never happens
var isIE = navigator.userAgent.indexOf ("MSIE") > -1;
if (isIE) {
setTimeout(newOnLoadEvent, 1000);
}
jsUnitTestManager.prototype.loadPage = function (testFileName)
{
this._testFileName = testFileName;
this._loadAttemptStartTime = new Date();
this.setStatus('Opening Test Page "' + this._testFileName + '"');
// IE is being optimistic about its reporting, I have seen that there are
timing problems running the onload handlers and returning before its ready
// These timeouts are making sure things are really ready. If tests use
appendChild, then that can cause the browser to die with operation aborted.
if (isIE) {
var func_test_name = 'func_test_name'+(new Date()).getTime();
var that = this
// Create some unique functions to call after setTimeout
window[func_test_name] = function()
{that.containerController.setTestPage(that._testFileName);
var funcname = 'testfunc'+(new Date()).getTime();
window[funcname] = function () {that._callBackWhenPageIsLoaded();};
setTimeout('window.'+funcname+'();', 500);
};
setTimeout('window.'+func_test_name+'();', 50);
}
else {
this.containerController.setTestPage(this._testFileName);
this._callBackWhenPageIsLoaded();
}
// - END
}