Tests: Attach test iframes to the body for visibility-dependent code

Ref 1d2df772b4
Closes gh-3645
This commit is contained in:
Richard Gibson
2017-04-25 15:39:41 -04:00
committed by GitHub
parent 87a2d3aae7
commit bb79f728b0
2 changed files with 12 additions and 6 deletions

View File

@@ -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( "<iframe/>" )
.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( "<div/>" ).css( { position: "absolute", width: "500px", left: "-600px" } )
.append( jQuery( "<iframe/>" ).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;