Tests: Allow a mock QUnit.test for perfect testIframe fidelity

Ref 1d2df772b4
Closes gh-3647
This commit is contained in:
Richard Gibson 2017-04-25 16:22:35 -04:00 committed by GitHub
parent bb79f728b0
commit bb757213b2
2 changed files with 16 additions and 14 deletions

View File

@ -231,8 +231,11 @@ this.ajaxTest = function( title, expect, options ) {
} ); } );
}; };
this.testIframe = function( title, fileName, func ) { this.testIframe = function( title, fileName, func, wrapper ) {
QUnit.test( title, function( assert ) { if ( !wrapper ) {
wrapper = QUnit.test;
}
wrapper.call( QUnit, title, function( assert ) {
var done = assert.async(), var done = assert.async(),
$iframe = supportjQuery( "<iframe/>" ) $iframe = supportjQuery( "<iframe/>" )
.css( { position: "absolute", width: "500px", left: "-600px" } ) .css( { position: "absolute", width: "500px", left: "-600px" } )

View File

@ -26,18 +26,17 @@ var supportsFixedPosition, supportsScroll, alwaysScrollable,
// Support: iOS <=7 // Support: iOS <=7
// Hijack the iframe test infrastructure to detect viewport scrollability // Hijack the iframe test infrastructure to detect viewport scrollability
// for pages with position:fixed document element // for pages with position:fixed document element
var done = assert.async(), var done = assert.async();
$iframe = supportjQuery( "<iframe/>" ) testIframe(
.css( { position: "absolute", width: "50px", left: "-60px" } ) null,
.attr( "src", url( "./data/offset/boxes.html" ) ); "offset/boxes.html",
window.iframeCallback = function( $, win, doc ) { function( assert, $, win, doc ) {
doc.documentElement.style.position = "fixed"; doc.documentElement.style.position = "fixed";
alwaysScrollable = win.pageXOffset !== 0; alwaysScrollable = win.pageXOffset !== 0;
window.iframeCallback = undefined;
$iframe.remove();
done(); done();
}; },
$iframe.appendTo( document.body ); function( _, mockTest ) { mockTest( assert ); }
);
}; };
QUnit.module( "offset", { setup: function( assert ) { QUnit.module( "offset", { setup: function( assert ) {