]> source.dussan.org Git - jquery.git/commitdiff
Use requirejs to load the testswarm inject script
authorTimmy Willison <timmywillisn@gmail.com>
Fri, 6 Sep 2013 19:44:50 +0000 (15:44 -0400)
committerTimmy Willison <timmywillisn@gmail.com>
Fri, 6 Sep 2013 21:23:45 +0000 (17:23 -0400)
test/data/testrunner.js
test/index.html

index ea0eb014e7cc8576cbc62eaa971a58d12092bfb3..53d9f90174229834674da9f422e5df0e47edaef2 100644 (file)
@@ -373,17 +373,3 @@ QUnit.config.testTimeout = 20 * 1000; // 20 seconds
 
 // Enforce an "expect" argument or expect() call in all test bodies.
 QUnit.config.requireExpects = true;
-
-/**
- * Load the TestSwarm listener if swarmURL is in the address.
- */
-(function() {
-       var url = window.location.search;
-       url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + "swarmURL=".length ) );
-
-       if ( !url || url.indexOf("http") !== 0 ) {
-               return;
-       }
-
-       document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() + "'></scr" + "ipt>");
-})();
index 3636df4713e267e93677854821f1e2eed95744f0..49853c9ef9123a08621a299c7459d41c2f56c466 100644 (file)
@@ -19,7 +19,9 @@
        // Tests are always loaded async
        QUnit.config.autostart = false;
        function loadTests() {
-               var tests = [
+               var loadSwarm,
+                       url = window.location.search,
+                       tests = [
                        "data/testrunner.js",
                        "unit/core.js",
                        "unit/callbacks.js",
@@ -40,6 +42,9 @@
                        "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();
                                testSubproject( "Sizzle", "../bower_components/sizzle/test/", /^unit\/.*\.js$/, function() {
                                        // Call load to build module filter select element
                                        QUnit.load();
-                                       QUnit.start();
+
+                                       // 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();
+                                       }
                                });
                        }
                })();