diff --git a/test/data/testinit.js b/test/data/testinit.js index dd06f86be..c55ebd1bb 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -233,8 +233,10 @@ this.ajaxTest = function( title, expect, options ) { this.testIframe = function( title, fileName, func ) { QUnit.test( title, function( assert ) { - var iframe; - var done = assert.async(); + var done = assert.async(), + $iframe = supportjQuery( "" ) + .css( { position: "absolute", width: "500px", left: "-600px" } ) + .attr( { id: "qunit-fixture-iframe", src: url( "./data/" + fileName ) } ); // Test iframes are expected to invoke this via startIframeTest (cf. iframeTest.js) window.iframeCallback = function() { @@ -247,13 +249,14 @@ this.testIframe = function( title, fileName, func ) { func.apply( this, args ); func = function() {}; - iframe.remove(); + $iframe.remove(); done(); } ); }; - iframe = jQuery( "
" ).css( { position: "absolute", width: "500px", left: "-600px" } ) - .append( jQuery( "" ).attr( "src", url( "./data/" + fileName ) ) ) - .appendTo( "#qunit-fixture" ); + + // Attach iframe to the body for visibility-dependent code + // It will be removed by either the above code, or the testDone callback in testrunner.js + $iframe.appendTo( document.body ); } ); }; this.iframeCallback = undefined; diff --git a/test/data/testrunner.js b/test/data/testrunner.js index 0784ae0a8..b8f1127ab 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -167,6 +167,9 @@ QUnit.testDone( function() { // ...even if the jQuery under test has a broken .empty() supportjQuery( "#qunit-fixture" ).empty(); + // Remove the iframe fixture + supportjQuery( "#qunit-fixture-iframe" ).remove(); + // Reset internal jQuery state jQuery.event.global = {}; if ( ajaxSettings ) {