aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2017-04-25 16:22:35 -0400
committerGitHub <noreply@github.com>2017-04-25 16:22:35 -0400
commitbb757213b270d07b535848a6d5a9b27650101285 (patch)
tree2c9914431a5917b21d40d753beb8bdd056075887
parentbb79f728b089c60338a4c336afd6ff89e739e15a (diff)
downloadjquery-bb757213b270d07b535848a6d5a9b27650101285.tar.gz
jquery-bb757213b270d07b535848a6d5a9b27650101285.zip
Tests: Allow a mock QUnit.test for perfect testIframe fidelity
Ref 1d2df772b4d6e5dbf91df6e75f4a1809f7879ab0 Closes gh-3647
-rw-r--r--test/data/testinit.js7
-rw-r--r--test/unit/offset.js23
2 files changed, 16 insertions, 14 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js
index c55ebd1bb..78136cbbc 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -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" } )
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 2acfd71af..c202b1d20 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -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 ) {