From f36568324d1b68101cc6e8933b94db3bc8591fad Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Thu, 23 Feb 2012 15:48:12 -0500 Subject: [PATCH] fixes #10693, generalizes the "test something in an iframe" code when a callback isn't needed --- test/data/testinit.js | 32 +++++++++++++++++++++++++++++ test/unit/offset.js | 48 ++++++++----------------------------------- test/unit/selector.js | 48 ++++--------------------------------------- 3 files changed, 44 insertions(+), 84 deletions(-) diff --git a/test/data/testinit.js b/test/data/testinit.js index 83d9db1f6..850e19c27 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -119,4 +119,36 @@ function url(value) { oldActive = jQuery.active; } }; + + this.testIframe = function( fileName, name, fn ) { + + test(name, function() { + // pause execution for now + stop(); + + // load fixture in iframe + var iframe = loadFixture(), + win = iframe.contentWindow, + interval = setInterval( function() { + if ( win && win.jQuery && win.jQuery.isReady ) { + clearInterval( interval ); + // continue + start(); + // call actual tests passing the correct jQuery instance to use + fn.call( this, win.jQuery, win, win.document ); + document.body.removeChild( iframe ); + iframe = null; + } + }, 15 ); + }); + + function loadFixture() { + var src = "./data/" + fileName + ".html?" + parseInt( Math.random()*1000, 10 ), + iframe = jQuery("