2012-04-21 15:49:11 +00:00
|
|
|
(function( QUnit ) {
|
|
|
|
|
|
|
|
QUnit.extend( QUnit, {
|
|
|
|
testSuites: function( suites ) {
|
|
|
|
QUnit.begin(function() {
|
|
|
|
QUnit.initIframe();
|
|
|
|
});
|
|
|
|
|
|
|
|
for ( var i = 0; i < suites.length; i++ ) {
|
2012-04-22 10:47:33 +00:00
|
|
|
QUnit.runSuite( suites[i] );
|
2012-04-21 15:49:11 +00:00
|
|
|
}
|
2012-04-22 10:47:33 +00:00
|
|
|
|
2012-04-21 15:49:11 +00:00
|
|
|
QUnit.done(function() {
|
|
|
|
this.iframe.style.display = "none";
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
runSuite: function( suite ) {
|
2012-04-22 10:47:33 +00:00
|
|
|
asyncTest( suite, function() {
|
|
|
|
QUnit.iframe.setAttribute( "src", suite );
|
|
|
|
});
|
2012-04-21 15:49:11 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
initIframe: function() {
|
|
|
|
var body = document.body,
|
|
|
|
iframe = this.iframe = document.createElement( "iframe" ),
|
|
|
|
iframeWin;
|
|
|
|
|
|
|
|
iframe.className = "qunit-subsuite";
|
|
|
|
body.appendChild( iframe );
|
|
|
|
|
|
|
|
function onIframeLoad() {
|
|
|
|
var module, test,
|
|
|
|
count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
iframeWin.QUnit.moduleStart(function( data ) {
|
|
|
|
// capture module name for messages
|
|
|
|
module = data.name;
|
|
|
|
});
|
|
|
|
|
|
|
|
iframeWin.QUnit.testStart(function( data ) {
|
|
|
|
// capture test name for messages
|
|
|
|
test = data.name;
|
|
|
|
});
|
|
|
|
iframeWin.QUnit.testDone(function() {
|
|
|
|
test = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
iframeWin.QUnit.log(function( data ) {
|
|
|
|
if (test === null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// pass all test details through to the main page
|
|
|
|
var message = module + ": " + test + ": " + data.message;
|
|
|
|
expect( ++count );
|
|
|
|
QUnit.push( data.result, data.actual, data.expected, message );
|
|
|
|
});
|
|
|
|
|
|
|
|
iframeWin.QUnit.done(function() {
|
|
|
|
// start the wrapper test from the main page
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
QUnit.addEvent( iframe, "load", onIframeLoad );
|
|
|
|
|
|
|
|
iframeWin = iframe.contentWindow;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.testStart(function( data ) {
|
|
|
|
// update the test status to show which test suite is running
|
|
|
|
QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br> ";
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.testDone(function() {
|
2012-04-22 10:47:33 +00:00
|
|
|
var i,
|
|
|
|
current = QUnit.id( this.config.current.id ),
|
2012-04-21 15:49:11 +00:00
|
|
|
children = current.children,
|
|
|
|
src = this.iframe.src;
|
|
|
|
|
|
|
|
// undo the auto-expansion of failed tests
|
2012-04-22 10:47:33 +00:00
|
|
|
for ( i = 0; i < children.length; i++ ) {
|
2012-04-21 15:49:11 +00:00
|
|
|
if ( children[i].nodeName === "OL" ) {
|
|
|
|
children[i].style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QUnit.addEvent(current, "dblclick", function( e ) {
|
|
|
|
var target = e && e.target ? e.target : window.event.srcElement;
|
2012-04-22 10:47:33 +00:00
|
|
|
if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) {
|
2012-04-21 15:49:11 +00:00
|
|
|
target = target.parentNode;
|
|
|
|
}
|
|
|
|
if ( window.location && target.nodeName.toLowerCase() === "strong" ) {
|
|
|
|
window.location = src;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
current.getElementsByTagName("a")[0].href = src;
|
2012-04-21 15:49:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}( QUnit ) );
|