]> source.dussan.org Git - jquery.git/commitdiff
Move test loader to testinit.js. Fix race condition with dependency loading.
authorTimmy Willison <timmywillisn@gmail.com>
Fri, 6 Sep 2013 20:23:20 +0000 (16:23 -0400)
committerTimmy Willison <timmywillisn@gmail.com>
Fri, 6 Sep 2013 20:23:20 +0000 (16:23 -0400)
test/data/testinit.js
test/data/testrunner.js
test/index.html

index 8cb57d5f54c1214097120f9960142e70906d7bc9..f7d8f2c0c80f179fc61f0458c52c8f61eb7ee23b 100644 (file)
@@ -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 ];
+                               });
+                       });
+               }
+       })();
+};
index 21ed2a3fa830936d73faaacbb78801344b3af375..c766e13cad097c25e8ddb1ee8673f9c32e2ddb2a 100644 (file)
@@ -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,
index 49853c9ef9123a08621a299c7459d41c2f56c466..070624036257bc4d4b3ea2a9555c33fd6ca8aeae 100644 (file)
 
        <script src="../bower_components/qunit/qunit/qunit.js"></script>
        <script src="../bower_components/requirejs/require.js"></script>
+       <!-- See testinit for the list of tests -->
        <script src="data/testinit.js"></script>
 
-       <script>
-       // Tests are always loaded async
-       QUnit.config.autostart = false;
-       function loadTests() {
-               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();
-                                       }
-                               });
-                       }
-               })();
-       }
-       </script>
        <!-- A script that includes jQuery min, dev, or AMD -->
        <!-- Adds "basic" URL option, even to iframes -->
        <!-- iframes will not load AMD as loading needs to be synchronous for some tests -->