Skip to content

Commit

Permalink
Tests: Allow a mock QUnit.test for perfect testIframe fidelity
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored Apr 25, 2017
1 parent bb79f72 commit bb75721
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
7 changes: 5 additions & 2 deletions test/data/testinit.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ this.ajaxTest = function( title, expect, options ) {
} );
};

this.testIframe = function( title, fileName, func ) {
QUnit.test( title, function( assert ) {
this.testIframe = function( title, fileName, func, wrapper ) {
if ( !wrapper ) {
wrapper = QUnit.test;
}
wrapper.call( QUnit, title, function( assert ) {
var done = assert.async(),
$iframe = supportjQuery( "<iframe/>" )
.css( { position: "absolute", width: "500px", left: "-600px" } )
Expand Down
23 changes: 11 additions & 12 deletions test/unit/offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@ var supportsFixedPosition, supportsScroll, alwaysScrollable,
// Support: iOS <=7
// Hijack the iframe test infrastructure to detect viewport scrollability
// for pages with position:fixed document element
var done = assert.async(),
$iframe = supportjQuery( "<iframe/>" )
.css( { position: "absolute", width: "50px", left: "-60px" } )
.attr( "src", url( "./data/offset/boxes.html" ) );
window.iframeCallback = function( $, win, doc ) {
doc.documentElement.style.position = "fixed";
alwaysScrollable = win.pageXOffset !== 0;
window.iframeCallback = undefined;
$iframe.remove();
done();
};
$iframe.appendTo( document.body );
var done = assert.async();
testIframe(
null,
"offset/boxes.html",
function( assert, $, win, doc ) {
doc.documentElement.style.position = "fixed";
alwaysScrollable = win.pageXOffset !== 0;
done();
},
function( _, mockTest ) { mockTest( assert ); }
);
};

QUnit.module( "offset", { setup: function( assert ) {
Expand Down

0 comments on commit bb75721

Please sign in to comment.