hi john, your right that is where it should be done. the problem arises from the fact that we load the scripts for the test from the html itself, as part of the browser emulation process. this means that we can only affect the global scope before the html is loaded, onload, and after load. otherwise we would need to copy the script loading process outside of the native browser loading process and either duplicate the process (at best) and usually only approach something similar.
for example our old script for kick off the tests was:
// Init
load("build/runtest/env.js");
var isLocal;
window.onload = function(){
isLocal = !!(window.location.protocol == 'file:');
// Load the test runner
load("dist/jquery.js",
"build/runtest/testrunner.js");
// Load the tests
load(
"test/unit/core.js",
"test/unit/selector.js",
"test/unit/event.js",
"test/unit/fx.js",
"test/unit/dimensions.js",
"test/unit/data.js",
// offset relies on window.open, which is currently unimplemented in env.js
//"test/unit/offset.js",
// these tests require hitting a server, so we will need some clever env.js
// way of testing them
"test/unit/ajax.js"
);
// Display the results
results();
};
and now its just:
(function($env){
//let it load the script from the html
$env.scriptTypes = {
"text/javascript" :true
};
var count = 0;
window.console = {
log: function(result, message){
$env.log('(' + (count++) + ')[' + ((!!result) ? 'PASS' : 'FAIL') + '] ' + message);
}
};
window.onload = function(){
$env.warn('Defining QUnit.done');
QUnit.done = function(pass, fail){
$env.warn('Writing Results to File');
jQuery('script').each(function(){
this.type = 'text/envjs';
});
$env.writeToFile(
document.documentElement.xml,
$env.location('jqenv.html')
);
};
}
window.location = "test/index.html";
})(Envjs);
where i did modify the qunit to define QUnit.log as in the last email.
does this make sense? the latter approach lets the html essentially define everything we need to know and just load and go, setting up our hooks prior to setting window.location
thatcher