aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
Diffstat (limited to 'test/data')
-rw-r--r--test/data/test.js2
-rw-r--r--test/data/testinit.js55
-rw-r--r--test/data/testrunner.js16
3 files changed, 40 insertions, 33 deletions
diff --git a/test/data/test.js b/test/data/test.js
index 69f492dcc..a18815315 100644
--- a/test/data/test.js
+++ b/test/data/test.js
@@ -1,3 +1,3 @@
-var foobar = "bar";
+var testBar = "bar";
jQuery('#ap').html('bar');
ok( true, "test.js executed");
diff --git a/test/data/testinit.js b/test/data/testinit.js
index a866d3227..2088407a6 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -158,39 +158,46 @@ function ajaxTest( title, expect, options ) {
if ( options.setup ) {
options.setup();
}
- var aborted = false,
- abort = function( reason ) {
- if ( !aborted ) {
- aborted = true;
+
+ var completed = false,
+ complete = function() {
+ completed = true;
+ delete ajaxTest.abort;
+ },
+ abort = ajaxTest.abort = function( reason ) {
+ if ( !completed ) {
+ complete();
ok( false, "unexpected " + reason );
jQuery.each( requests, function( _, request ) {
- request.abort();
+ if ( request && request.abort ) {
+ request.abort();
+ }
});
}
},
- requests = jQuery.map( requestOptions, function( options ) {
- var request = ( options.create || jQuery.ajax )( options );
+ requests = jQuery.map( requestOptions, function( options, index ) {
+ var request = ( options.create || jQuery.ajax )( options ),
+ callIfDefined = function( deferType, optionType ) {
+ var handler = options[ deferType ] || !!options[ optionType ];
+ return handler ?
+ function() {
+ if ( !completed && jQuery.isFunction( handler ) ) {
+ handler.apply( this, arguments );
+ }
+ } :
+ function() {
+ abort( optionType );
+ };
+ };
+
if ( options.afterSend ) {
options.afterSend( request );
}
- return request;
+
+ return request.then( callIfDefined( "done", "success" ), callIfDefined( "fail", "error" ) );
});
- jQuery.when.apply( jQuery, jQuery.map( requests, function( request, index ) {
- function callIfDefined( deferType, optionType ) {
- var handler = requestOptions[ index ][ deferType ] || !!requestOptions[ index ][ optionType ];
- return handler ? function() {
- if ( !aborted && jQuery.isFunction( handler ) ) {
- handler.apply( this, arguments );
- }
- } : function() {
- abort( optionType );
- }
- }
- return request.then( callIfDefined( "done", "success" ), callIfDefined( "fail", "error" ) );
- }) ).always(
- options.teardown,
- start
- );
+
+ jQuery.when.apply( jQuery, requests ).always( complete, options.teardown, start);
});
};
diff --git a/test/data/testrunner.js b/test/data/testrunner.js
index b17bf265f..085203c96 100644
--- a/test/data/testrunner.js
+++ b/test/data/testrunner.js
@@ -3,10 +3,10 @@
*/
jQuery.noConflict();
-// For checking globals pollution
-window[ jQuery.expando ] = undefined;
-// ...in Gecko
-this.getInterface = this.getInterface;
+// For checking globals pollution despite auto-created globals in various environments
+jQuery.each( [ jQuery.expando, "getInterface", "Packages", "java", "netscape" ], function( i, name ) {
+ window[ name ] = window[ name ];
+});
// Expose Sizzle for Sizzle's selector tests
// We remove Sizzle's globalization in jQuery
@@ -138,7 +138,7 @@ function testSubproject( label, url, risTests ) {
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
var Globals = (function() {
var globals = {};
- return QUnit.config.noglobals ? {
+ return {
register: function( name ) {
globals[ name ] = true;
jQuery.globalEval( "var " + name );
@@ -153,9 +153,6 @@ var Globals = (function() {
"; } catch( x ) {}" );
}
}
- } : {
- register: jQuery.noop,
- cleanup: jQuery.noop
};
})();
@@ -312,6 +309,9 @@ var Globals = (function() {
}
if ( jQuery.active !== undefined && jQuery.active !== oldActive ) {
equal( jQuery.active, 0, "No AJAX requests are still active" );
+ if ( ajaxTest.abort ) {
+ ajaxTest.abort("active request");
+ }
oldActive = jQuery.active;
}
};