Tests: Make iframe tests wait after checking isReady

Ref gh-3040
This commit is contained in:
Dave Methvin
2016-04-08 12:00:17 -04:00
parent 755e7ccf01
commit 08d73d7f9c
15 changed files with 50 additions and 74 deletions

View File

@@ -232,37 +232,6 @@ this.ajaxTest = function( title, expect, options ) {
} );
};
this.testIframe = function( fileName, name, fn ) {
QUnit.test( name, function( assert ) {
var done = assert.async();
// load fixture in iframe
var iframe = loadFixture(),
win = iframe.contentWindow,
interval = setInterval( function() {
if ( win && win.jQuery && win.jQuery.isReady ) {
clearInterval( interval );
// call actual tests passing the correct jQuery instance to use
fn.call( this, win.jQuery, win, win.document, assert );
done();
document.body.removeChild( iframe );
iframe = null;
}
}, 15 );
} );
function loadFixture() {
var src = url( "./data/" + fileName + ".html" ),
iframe = jQuery( "<iframe />" ).appendTo( "body" )[ 0 ];
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; " +
"top: -600px; left: -600px; visibility: hidden;";
iframe.contentWindow.location = src;
return iframe;
}
};
this.testIframeWithCallback = function( title, fileName, func ) {
QUnit.test( title, 1, function( assert ) {
var iframe;