]> source.dussan.org Git - jquery.git/commitdiff
No ticket: Fix subproject iframe tests
authorRichard Gibson <richard.gibson@gmail.com>
Fri, 11 Oct 2013 19:08:07 +0000 (15:08 -0400)
committerRichard Gibson <richard.gibson@gmail.com>
Fri, 11 Oct 2013 19:08:58 +0000 (15:08 -0400)
(cherry picked from commit 13d58a9bec67356ecae0d6902cb634e52cebcf19)

test/.jshintrc
test/data/testinit.js
test/data/testrunner.js

index b702f6fa57639ec8c795a8310f0a02bb3886d3f0..65c224f0e653a16d79c3281212b5c6179ee02cf9 100644 (file)
@@ -60,6 +60,7 @@
                "originaljQuery": true,
                "$": true,
                "original$": true,
+               "baseURL": true,
                "externalHost": true
        }
 }
index c35383c6b98a0635f4c66de148ef8289ace7253a..d4b2abc16e25c520c4cccfdcd2f87486eee1c18d 100644 (file)
@@ -1,6 +1,7 @@
 /*jshint multistr:true, quotmark:false */
 
 var fireNative, originaljQuery, original$,
+       baseURL = "",
        supportjQuery = this.jQuery,
        // see RFC 2606
        externalHost = "example.com";
@@ -130,7 +131,8 @@ fireNative = document.createEvent ?
  * @result "data/test.php?foo=bar&10538358345554"
  */
 function url( value ) {
-       return 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
@@ -236,6 +238,9 @@ this.testIframeWithCallback = function( title, fileName, func ) {
        test( title, function() {
                var iframe;
 
+               // Expect one assertion, but allow overrides
+               expect( 1 );
+
                stop();
                window.iframeCallback = function() {
                        var self = this,
@@ -248,12 +253,12 @@ this.testIframeWithCallback = function( title, fileName, func ) {
                                start();
                        }, 0 );
                };
-               iframe = jQuery( "<div/>" ).append(
-                       jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) )
-               ).appendTo( "body" );
+               iframe = jQuery( "<div/>" ).css({ position: "absolute", width: "500px", left: "-600px" })
+                       .append( jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) ) )
+                       .appendTo( "#qunit-fixture" );
        });
 };
-this.iframeCallback = undefined;
+window.iframeCallback = undefined;
 
 // Tests are always loaded async
 QUnit.config.autostart = false;
index 3f1a85a03558287c4f0577adce55bd7ee5a6ae22..34f47381e0f05cbbc736b0c2e0c4ae2a77cb7f45 100644 (file)
@@ -238,7 +238,7 @@ window.Globals = (function() {
  * @param {String} url Test folder location
  * @param {RegExp} risTests To filter script sources
  */
-function testSubproject( label, url, risTests, complete ) {
+function testSubproject( label, subProjectURL, risTests, complete ) {
        var sub, fixture, fixtureHTML,
                fixtureReplaced = false;
 
@@ -280,11 +280,11 @@ function testSubproject( label, url, risTests, complete ) {
 
        // Load tests and fixture from subproject
        // Test order matters, so we must be synchronous and throw an error on load failure
-       supportjQuery.ajax( url, {
+       supportjQuery.ajax( subProjectURL, {
                async: false,
                dataType: "html",
                error: function( jqXHR, status ) {
-                       throw new Error( "Could not load: " + url + " (" + status + ")" );
+                       throw new Error( "Could not load: " + subProjectURL + " (" + status + ")" );
                },
                success: function( data, status, jqXHR ) {
                        var sources = [],
@@ -312,7 +312,7 @@ function testSubproject( label, url, risTests, complete ) {
                        (function loadDep() {
                                var dep = sources.shift();
                                if ( dep ) {
-                                       require( [ url + dep ], loadDep );
+                                       require( [ subProjectURL + dep ], loadDep );
                                } else if ( complete ) {
                                        complete();
                                }
@@ -338,6 +338,9 @@ function testSubproject( label, url, risTests, complete ) {
                                        return;
                                }
 
+                               // Update helper function behavior
+                               baseURL = subProjectURL;
+
                                // Replace the current fixture, including content outside of #qunit-fixture
                                var oldFixture = supportjQuery("#qunit-fixture");
                                while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) {