4 // Store the old count so that we only assert on tests that have actually leaked,
5 // instead of asserting every time a test has leaked sometime in the past
9 ajaxSettings = jQuery.ajaxSettings;
15 // Max time for done() to fire in an async test.
16 QUnit.config.testTimeout = 60e3; // 1 minute
18 // Enforce an "expect" argument or expect() call in all test bodies.
19 QUnit.config.requireExpects = true;
22 * Ensures that tests have cleaned up properly after themselves. Should be passed as the
23 * teardown function on all modules' lifecycle object.
25 window.moduleTeardown = function( assert ) {
27 // Check for (and clean up, if possible) incomplete animations/requests/etc.
28 if ( jQuery.timers && jQuery.timers.length !== 0 ) {
29 assert.equal( jQuery.timers.length, 0, "No timers are still running" );
30 splice.call( jQuery.timers, 0, jQuery.timers.length );
33 if ( jQuery.active !== undefined && jQuery.active !== oldActive ) {
34 assert.equal( jQuery.active, oldActive, "No AJAX requests are still active" );
35 if ( ajaxTest.abort ) {
36 ajaxTest.abort( "active requests" );
38 oldActive = jQuery.active;
44 QUnit.done( function() {
46 // Remove our own fixtures outside #qunit-fixture
47 supportjQuery( "#qunit ~ *" ).remove();
50 QUnit.testDone( function() {
52 // Ensure jQuery events and data on the fixture are properly removed
53 jQuery( "#qunit-fixture" ).empty();
55 // ...even if the jQuery under test has a broken .empty()
56 supportjQuery( "#qunit-fixture" ).empty();
58 // Remove the iframe fixture
59 supportjQuery( "#qunit-fixture-iframe" ).remove();
61 // Reset internal jQuery state
63 jQuery.ajaxSettings = jQuery.extend( true, {}, ajaxSettings );
65 delete jQuery.ajaxSettings;
72 // Register globals for cleanup and the cleanup code itself
73 window.Globals = ( function() {
77 register: function( name ) {
78 window[ name ] = globals[ name ] = true;
84 for ( name in globals ) {
85 delete window[ name ];