From: Timmy Willison Date: Fri, 6 Sep 2013 20:23:20 +0000 (-0400) Subject: Move test loader to testinit.js. Fix race condition with dependency loading. X-Git-Tag: 1.11.0-beta1~48 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d14904d0831efaeb2c290aef0dcaaec48c13be03;p=jquery.git Move test loader to testinit.js. Fix race condition with dependency loading. --- diff --git a/test/data/testinit.js b/test/data/testinit.js index 8cb57d5f5..f7d8f2c0c 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -254,3 +254,70 @@ this.testIframeWithCallback = function( title, fileName, func ) { }); }; this.iframeCallback = undefined; + +// Tests are always loaded async +QUnit.config.autostart = false; +this.loadTests = function() { + var loadSwarm, + url = window.location.search, + tests = [ + "data/testrunner.js", + "unit/core.js", + "unit/callbacks.js", + "unit/deferred.js", + "unit/support.js", + "unit/data.js", + "unit/queue.js", + "unit/attributes.js", + "unit/event.js", + "unit/selector.js", + "unit/traversing.js", + "unit/manipulation.js", + "unit/wrap.js", + "unit/css.js", + "unit/serialize.js", + "unit/ajax.js", + "unit/effects.js", + "unit/offset.js", + "unit/dimensions.js" + ]; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + "swarmURL=".length ) ); + loadSwarm = url && url.indexOf("http") === 0; + + // 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", "../bower_components/sizzle/test/", /^unit\/.*\.js$/, function() { + // Call load to build module filter select element + QUnit.load(); + + // 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(); + } + + /** + * 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; + + // 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 ]; + }); + }); + } + })(); +}; diff --git a/test/data/testrunner.js b/test/data/testrunner.js index 53d9f9017..8f42d12d5 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -1,18 +1,3 @@ -if ( typeof jQuery !== "undefined" ) { - /** - * Allow the test suite to run with other libs or jQuery's. - */ - jQuery.noConflict(); - - // Expose Sizzle for Sizzle's selector tests - // We remove Sizzle's globalization in jQuery - this.Sizzle = this.Sizzle || jQuery.find; -} - -// 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 ]; -}); // Allow subprojects to test against their own fixtures var qunitModule = QUnit.module, diff --git a/test/index.html b/test/index.html index 49853c9ef..070624036 100644 --- a/test/index.html +++ b/test/index.html @@ -13,62 +13,9 @@ + -