aboutsummaryrefslogtreecommitdiffstats
path: root/test/data/testinit.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/data/testinit.js')
-rw-r--r--test/data/testinit.js67
1 files changed, 27 insertions, 40 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js
index af19dc69d..06f33d19b 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -131,8 +131,8 @@ fireNative = document.createEvent ?
* @result "data/test.php?foo=bar&10538358345554"
*/
function url( value ) {
- return baseURL + value + (/\?/.test(value) ? "&" : "?") +
- new Date().getTime() + "" + parseInt(Math.random() * 100000, 10);
+ return baseURL + value + (/\?/.test( value ) ? "&" : "?") +
+ new Date().getTime() + "" + parseInt( Math.random() * 100000, 10 );
}
// Ajax testing helper
@@ -203,19 +203,17 @@ this.ajaxTest = function( title, expect, options ) {
this.testIframe = function( fileName, name, fn ) {
-
- test(name, function() {
- // pause execution for now
- stop();
+ asyncTest(name, function() {
// load fixture in iframe
var iframe = loadFixture(),
win = iframe.contentWindow,
- interval = setInterval( function() {
+ 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 );
@@ -225,9 +223,10 @@ this.testIframe = function( fileName, name, fn ) {
});
function loadFixture() {
- var src = url("./data/" + fileName + ".html"),
- iframe = jQuery("<iframe />").appendTo("body")[0];
+ var src = url( "./data/" + fileName + ".html" ),
+ iframe = jQuery( "<iframe />" ).appendTo( "body" )[ 0 ];
iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;";
+
iframe.contentWindow.location = src;
return iframe;
}
@@ -265,11 +264,12 @@ QUnit.config.autostart = false;
this.loadTests = function() {
var loadSwarm,
url = window.location.search;
- url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + "swarmURL=".length ) );
- loadSwarm = url && url.indexOf("http") === 0;
+
+ url = decodeURIComponent( url.slice( url.indexOf( "swarmURL=" ) + "swarmURL=".length ) );
+ loadSwarm = url && url.indexOf( "http" ) === 0;
// Get testSubproject from testrunner first
- require([ "data/testrunner.js" ], function( testSubproject ) {
+ require([ "data/testrunner.js" ], function() {
var tests = [
"unit/core.js",
"unit/callbacks.js",
@@ -294,39 +294,26 @@ this.loadTests = function() {
// Ensure load order (to preserve test numbers)
(function loadDep() {
var dep = tests.shift();
+
if ( dep ) {
require( [ dep ], loadDep );
- } else {
-
- // Subproject tests must be last because they replace our test fixture
- testSubproject( "Sizzle", "../src/sizzle/test/", /^unit\/.*\.js$/, function() {
- // Call load to build module filter select element
- QUnit.load();
-
- /**
- * Run in noConflict mode
- */
- jQuery.noConflict();
-
- // Expose Sizzle for Sizzle's selector tests
- // We remove Sizzle's globalization in jQuery
- window.Sizzle = window.Sizzle || jQuery.find;
+ } else {
+ QUnit.load();
- // For checking globals pollution despite auto-created globals in various environments
- supportjQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ], function( i, name ) {
- window[ name ] = window[ name ];
- });
+ /**
+ * Run in noConflict mode
+ */
+ jQuery.noConflict();
- // Load the TestSwarm listener if swarmURL is in the address.
- if ( loadSwarm ) {
- require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ], function() {
- QUnit.start();
- });
- } else {
+ // Load the TestSwarm listener if swarmURL is in the address.
+ if ( loadSwarm ) {
+ require( [ "http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() ], function() {
QUnit.start();
- }
- });
+ });
+ } else {
+ QUnit.start();
+ }
}
})();
});