2012-04-20 14:55:07 +00:00
|
|
|
/**
|
|
|
|
* Allow the test suite to run with other libs or jQuery's.
|
|
|
|
*/
|
|
|
|
jQuery.noConflict();
|
2010-03-23 16:19:47 +00:00
|
|
|
|
2012-12-03 04:32:16 +00:00
|
|
|
// 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 ];
|
|
|
|
});
|
2012-11-03 04:06:50 +00:00
|
|
|
|
2012-06-04 22:04:11 +00:00
|
|
|
// Expose Sizzle for Sizzle's selector tests
|
|
|
|
// We remove Sizzle's globalization in jQuery
|
2013-04-09 15:45:09 +00:00
|
|
|
var Sizzle = Sizzle || jQuery.find,
|
2012-06-04 22:04:11 +00:00
|
|
|
|
2012-07-20 02:02:37 +00:00
|
|
|
// Allow subprojects to test against their own fixtures
|
2013-04-09 15:45:09 +00:00
|
|
|
qunitModule = QUnit.module,
|
2012-07-23 01:49:39 +00:00
|
|
|
qunitTest = QUnit.test;
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
|
2013-04-09 15:45:09 +00:00
|
|
|
this.testSubproject = function( label, url, risTests ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
var sub, fixture, fixtureHTML,
|
|
|
|
fixtureReplaced = false;
|
2012-07-20 02:02:37 +00:00
|
|
|
|
2012-07-23 01:49:39 +00:00
|
|
|
// Don't let subproject tests jump the gun
|
|
|
|
QUnit.config.reorder = false;
|
|
|
|
|
|
|
|
// Create module
|
|
|
|
module( label );
|
|
|
|
|
|
|
|
// Duckpunch QUnit
|
2012-11-01 04:40:27 +00:00
|
|
|
// TODO restore parent fixture on teardown to support reordering
|
2012-07-20 02:02:37 +00:00
|
|
|
module = QUnit.module = function( name ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
var args = arguments;
|
|
|
|
|
|
|
|
// Remember subproject-scoped module name
|
|
|
|
sub = name;
|
|
|
|
|
|
|
|
// Override
|
|
|
|
args[0] = label;
|
|
|
|
return qunitModule.apply( this, args );
|
2012-07-20 02:02:37 +00:00
|
|
|
};
|
2012-07-23 01:49:39 +00:00
|
|
|
test = function( name ) {
|
|
|
|
var args = arguments,
|
|
|
|
i = args.length - 1;
|
|
|
|
|
|
|
|
// Prepend subproject-scoped module name to test name
|
|
|
|
args[0] = sub + ": " + name;
|
|
|
|
|
|
|
|
// Find test function and wrap to require subproject fixture
|
|
|
|
for ( ; i >= 0; i-- ) {
|
2012-11-01 04:40:27 +00:00
|
|
|
if ( originaljQuery.isFunction( args[i] ) ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
args[i] = requireFixture( args[i] );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-07-20 02:02:37 +00:00
|
|
|
|
2012-07-23 01:49:39 +00:00
|
|
|
return qunitTest.apply( this, args );
|
|
|
|
};
|
2012-07-20 02:02:37 +00:00
|
|
|
|
2012-07-23 01:49:39 +00:00
|
|
|
// Load tests and fixture from subproject
|
|
|
|
// Test order matters, so we must be synchronous and throw an error on load failure
|
2012-11-01 04:40:27 +00:00
|
|
|
originaljQuery.ajax( url, {
|
2012-07-23 01:49:39 +00:00
|
|
|
async: false,
|
|
|
|
dataType: "html",
|
|
|
|
error: function( jqXHR, status ) {
|
|
|
|
throw new Error( "Could not load: " + url + " (" + status + ")" );
|
|
|
|
},
|
|
|
|
success: function( data, status, jqXHR ) {
|
2012-11-01 04:40:27 +00:00
|
|
|
var page = originaljQuery.parseHTML(
|
2012-07-23 01:49:39 +00:00
|
|
|
// replace html/head with dummy elements so they are represented in the DOM
|
2012-10-17 19:20:15 +00:00
|
|
|
( data || "" ).replace( /<\/?((!DOCTYPE|html|head)\b.*?)>/gi, "[$1]" ),
|
2012-07-23 01:49:39 +00:00
|
|
|
document,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( !page || !page.length ) {
|
|
|
|
this.error( jqXHR, "no data" );
|
|
|
|
}
|
2012-11-01 04:40:27 +00:00
|
|
|
page = originaljQuery( page );
|
2012-07-23 01:49:39 +00:00
|
|
|
|
|
|
|
// Include subproject tests
|
|
|
|
page.filter("script[src]").add( page.find("script[src]") ).each(function() {
|
2012-11-01 04:40:27 +00:00
|
|
|
var src = originaljQuery( this ).attr("src"),
|
2012-07-23 01:49:39 +00:00
|
|
|
html = "<script src='" + url + src + "'></script>";
|
|
|
|
if ( risTests.test( src ) ) {
|
2012-11-01 04:40:27 +00:00
|
|
|
if ( originaljQuery.isReady ) {
|
|
|
|
originaljQuery("head").first().append( html );
|
2012-07-23 01:49:39 +00:00
|
|
|
} else {
|
|
|
|
document.write( html );
|
2012-07-20 02:02:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-07-23 01:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Get the fixture, including content outside of #qunit-fixture
|
|
|
|
fixture = page.find("[id='qunit-fixture']");
|
|
|
|
fixtureHTML = fixture.html();
|
|
|
|
fixture.empty();
|
2012-12-11 00:07:07 +00:00
|
|
|
while ( fixture.length && !fixture.prevAll("[id='qunit']").length ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
fixture = fixture.parent();
|
2012-07-20 02:02:37 +00:00
|
|
|
}
|
2012-07-23 01:49:39 +00:00
|
|
|
fixture = fixture.add( fixture.nextAll() );
|
|
|
|
}
|
2012-07-20 02:02:37 +00:00
|
|
|
});
|
2012-07-23 01:49:39 +00:00
|
|
|
|
2012-11-03 04:06:50 +00:00
|
|
|
function requireFixture( fn ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
return function() {
|
|
|
|
if ( !fixtureReplaced ) {
|
|
|
|
// Make sure that we retrieved a fixture for the subproject
|
|
|
|
if ( !fixture.length ) {
|
|
|
|
ok( false, "Found subproject fixture" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Replace the current fixture, including content outside of #qunit-fixture
|
2012-11-01 04:40:27 +00:00
|
|
|
var oldFixture = originaljQuery("#qunit-fixture");
|
2012-12-11 00:07:07 +00:00
|
|
|
while ( oldFixture.length && !oldFixture.prevAll("[id='qunit']").length ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
oldFixture = oldFixture.parent();
|
|
|
|
}
|
|
|
|
oldFixture.nextAll().remove();
|
|
|
|
oldFixture.replaceWith( fixture );
|
|
|
|
|
|
|
|
// WARNING: UNDOCUMENTED INTERFACE
|
|
|
|
QUnit.config.fixture = fixtureHTML;
|
|
|
|
QUnit.reset();
|
2012-11-01 04:40:27 +00:00
|
|
|
if ( originaljQuery("#qunit-fixture").html() !== fixtureHTML ) {
|
2012-07-23 01:49:39 +00:00
|
|
|
ok( false, "Copied subproject fixture" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fixtureReplaced = true;
|
|
|
|
}
|
|
|
|
|
2012-11-03 04:06:50 +00:00
|
|
|
fn.apply( this, arguments );
|
2012-10-09 23:48:37 +00:00
|
|
|
};
|
2012-07-23 01:49:39 +00:00
|
|
|
}
|
2013-04-09 15:45:09 +00:00
|
|
|
};
|
2012-07-20 02:02:37 +00:00
|
|
|
|
2012-11-26 02:31:19 +00:00
|
|
|
// Register globals for cleanup and the cleanup code itself
|
|
|
|
// Explanation at http://perfectionkills.com/understanding-delete/#ie_bugs
|
2013-04-09 15:45:09 +00:00
|
|
|
this.Globals = (function() {
|
2012-11-26 02:31:19 +00:00
|
|
|
var globals = {};
|
2012-12-03 04:32:16 +00:00
|
|
|
return {
|
2012-11-26 02:31:19 +00:00
|
|
|
register: function( name ) {
|
|
|
|
globals[ name ] = true;
|
2012-12-03 05:49:40 +00:00
|
|
|
jQuery.globalEval( "var " + name + " = undefined;" );
|
2012-11-26 02:31:19 +00:00
|
|
|
},
|
|
|
|
cleanup: function() {
|
|
|
|
var name,
|
|
|
|
current = globals;
|
|
|
|
globals = {};
|
|
|
|
for ( name in current ) {
|
|
|
|
jQuery.globalEval( "try { " +
|
|
|
|
"delete " + ( jQuery.support.deleteExpando ? "window['" + name + "']" : name ) +
|
|
|
|
"; } catch( x ) {}" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
2012-11-27 01:39:08 +00:00
|
|
|
// Sandbox start for great justice
|
|
|
|
(function() {
|
|
|
|
var oldStart = window.start;
|
|
|
|
window.start = function() {
|
|
|
|
oldStart();
|
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
2012-04-20 14:55:07 +00:00
|
|
|
/**
|
|
|
|
* QUnit hooks
|
|
|
|
*/
|
2010-07-27 10:50:08 +00:00
|
|
|
(function() {
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
// Store the old counts so that we only assert on tests that have actually leaked,
|
|
|
|
// instead of asserting every time a test has leaked sometime in the past
|
|
|
|
var oldCacheLength = 0,
|
|
|
|
oldFragmentsLength = 0,
|
|
|
|
oldActive = 0,
|
|
|
|
|
|
|
|
expectedDataKeys = {},
|
|
|
|
|
2013-02-19 04:52:29 +00:00
|
|
|
splice = [].splice,
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
reset = QUnit.reset,
|
2011-04-28 20:31:51 +00:00
|
|
|
ajaxSettings = jQuery.ajaxSettings;
|
|
|
|
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
function keys(o) {
|
|
|
|
var ret, key;
|
|
|
|
if ( Object.keys ) {
|
|
|
|
ret = Object.keys( o );
|
|
|
|
} else {
|
|
|
|
ret = [];
|
|
|
|
for ( key in o ) {
|
|
|
|
ret.push( key );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret.sort();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {jQuery|HTMLElement|Object|Array} elems Target (or array of targets) for jQuery.data.
|
|
|
|
* @param {string} key
|
|
|
|
*/
|
|
|
|
QUnit.expectJqData = function( elems, key ) {
|
|
|
|
var i, elem, expando;
|
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
// As of jQuery 2.0, there will be no "cache"-data is
|
|
|
|
// stored and managed completely below the API surface
|
|
|
|
if ( jQuery.cache ) {
|
|
|
|
QUnit.current_testEnvironment.checkJqData = true;
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
if ( elems.jquery && elems.toArray ) {
|
|
|
|
elems = elems.toArray();
|
|
|
|
}
|
|
|
|
if ( !jQuery.isArray( elems ) ) {
|
|
|
|
elems = [ elems ];
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
}
|
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
for ( i = 0; i < elems.length; i++ ) {
|
|
|
|
elem = elems[i];
|
|
|
|
|
|
|
|
// jQuery.data only stores data for nodes in jQuery.cache,
|
|
|
|
// for other data targets the data is stored in the object itself,
|
|
|
|
// in that case we can't test that target for memory leaks.
|
|
|
|
// But we don't have to since in that case the data will/must will
|
|
|
|
// be available as long as the object is not garbage collected by
|
|
|
|
// the js engine, and when it is, the data will be removed with it.
|
|
|
|
if ( !elem.nodeType ) {
|
|
|
|
// Fixes false positives for dataTests(window), dataTests({}).
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
expando = elem[ jQuery.expando ];
|
|
|
|
|
|
|
|
if ( expando === undefined ) {
|
|
|
|
// In this case the element exists fine, but
|
|
|
|
// jQuery.data (or internal data) was never (in)directly
|
|
|
|
// called.
|
|
|
|
// Since this method was called it means some data was
|
|
|
|
// expected to be found, but since there is nothing, fail early
|
|
|
|
// (instead of in teardown).
|
|
|
|
notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
} else {
|
2013-02-03 20:27:55 +00:00
|
|
|
if ( expectedDataKeys[expando] ) {
|
|
|
|
expectedDataKeys[expando].push( key );
|
|
|
|
} else {
|
|
|
|
expectedDataKeys[expando] = [ key ];
|
|
|
|
}
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-03 20:27:55 +00:00
|
|
|
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
};
|
|
|
|
QUnit.config.urlConfig.push( {
|
2012-11-25 19:30:16 +00:00
|
|
|
id: "jqdata",
|
|
|
|
label: "Always check jQuery.data",
|
|
|
|
tooltip: "Trigger QUnit.expectJqData detection for all tests instead of just the ones that call it"
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that tests have cleaned up properly after themselves. Should be passed as the
|
|
|
|
* teardown function on all modules' lifecycle object.
|
|
|
|
*/
|
|
|
|
this.moduleTeardown = function() {
|
|
|
|
var i,
|
|
|
|
expectedKeys, actualKeys,
|
|
|
|
fragmentsLength = 0,
|
|
|
|
cacheLength = 0;
|
|
|
|
|
2013-01-04 01:39:15 +00:00
|
|
|
// Only look for jQuery data problems if this test actually
|
|
|
|
// provided some information to compare against.
|
|
|
|
if ( QUnit.urlParams.jqdata || this.checkJqData ) {
|
|
|
|
for ( i in jQuery.cache ) {
|
|
|
|
expectedKeys = expectedDataKeys[i];
|
|
|
|
actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
|
|
|
|
if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
|
|
|
|
deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
}
|
2013-01-04 01:39:15 +00:00
|
|
|
delete jQuery.cache[i];
|
|
|
|
delete expectedDataKeys[i];
|
|
|
|
}
|
|
|
|
// In case it was removed from cache before (or never there in the first place)
|
|
|
|
for ( i in expectedDataKeys ) {
|
|
|
|
deepEqual( expectedDataKeys[i], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
|
|
|
|
delete expectedDataKeys[i];
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-04 01:39:15 +00:00
|
|
|
// Reset data register
|
|
|
|
expectedDataKeys = {};
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
|
2013-02-19 04:52:29 +00:00
|
|
|
// Check for (and clean up, if possible) incomplete animations/requests/etc.
|
|
|
|
if ( jQuery.timers && jQuery.timers.length !== 0 ) {
|
|
|
|
equal( jQuery.timers.length, 0, "No timers are still running" );
|
|
|
|
splice.call( jQuery.timers, 0, jQuery.timers.length );
|
|
|
|
jQuery.fx.stop();
|
|
|
|
}
|
|
|
|
if ( jQuery.active !== undefined && jQuery.active !== oldActive ) {
|
|
|
|
equal( jQuery.active, oldActive, "No AJAX requests are still active" );
|
|
|
|
if ( ajaxTest.abort ) {
|
|
|
|
ajaxTest.abort("active requests");
|
|
|
|
}
|
|
|
|
oldActive = jQuery.active;
|
|
|
|
}
|
|
|
|
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
// Allow QUnit.reset to clean up any attached elements before checking for leaks
|
|
|
|
QUnit.reset();
|
|
|
|
|
2013-01-04 01:39:15 +00:00
|
|
|
for ( i in jQuery.cache ) {
|
|
|
|
++cacheLength;
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.fragments = {};
|
|
|
|
|
|
|
|
for ( i in jQuery.fragments ) {
|
|
|
|
++fragmentsLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Because QUnit doesn't have a mechanism for retrieving the number of expected assertions for a test,
|
|
|
|
// if we unconditionally assert any of these, the test will fail with too many assertions :|
|
|
|
|
if ( cacheLength !== oldCacheLength ) {
|
|
|
|
equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
|
|
|
|
oldCacheLength = cacheLength;
|
|
|
|
}
|
|
|
|
if ( fragmentsLength !== oldFragmentsLength ) {
|
|
|
|
equal( fragmentsLength, oldFragmentsLength, "No unit tests leak memory in jQuery.fragments" );
|
|
|
|
oldFragmentsLength = fragmentsLength;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-12-10 21:38:50 +00:00
|
|
|
QUnit.done(function() {
|
2012-12-16 17:37:20 +00:00
|
|
|
// Remove our own fixtures outside #qunit-fixture
|
|
|
|
jQuery("#qunit ~ *").remove();
|
2012-12-10 21:38:50 +00:00
|
|
|
});
|
|
|
|
|
Implement expectation test instead of using _removeData. Close gh-997.
* Removed inline usage of QUnit.reset() because it is messing with the
expectation model as reset does .empty() which does a recursive cleanData
on everything in #qunit-fixture, so any expectJqData above .reset() would
fail negatively.
Instead of calling reset inline, either updated the following assertions to
take previous assertions' state into account, or broke the test() up into
2 tests at the point where it would call QUnit.reset.
* After introducing the new memory leak discovery a whole bunch of tests were
failing as they didn't clean up everything. However I didn't (yet) add
QUnit.expectJqData calls all over the place because in most if not all of
these cases it is valid data storage. For example in test "data()", there
will be an internal data key for "parsedAttrs". This particular test isn't
intending to test for memory leaks, so therefor I made the new discovery
system only push failures when the test contains at least 1 call to
QUnit.expectJqData.
When not, we'll assume that whatever data is being stored is acceptable
because the relevant elements still exist in the DOM anyway (QUnit.reset
will remove the elements and clean up the data automatically).
I did add a "Always check jQuery.data" mode in the test suite that will
trigger it everywhere. Maybe one day we'll include a call to everywhere,
but for now I'm keeping the status quo: Only consider data left in storage
to be a problem if the test says so ("opt-in").
* Had to move #fx-tests inside the fixture because ".remove()" test would
otherwise remove stuff permanently and cause random other tests to fail
as "#hide div" would yield an empty collection.
(Why wasn't this in the fixture in the first place?)
As a result moving fx-tests into the fixture a whole bunch of tests failed
that relied on arbitrary stuff about the document-wide or fixture-wide
state (e.g. number of divs etc.). So I had to adjust various tests to
limit their sample data to not be so variable and unlimited...
* Moved out tests for expando cleanup into a separate test.
* Fixed implied global variable 'pass' in effects.js that was causing
"TypeError: boolean is not a function" in *UNRELATED* dimensions.js that
uses a global variable "pass = function () {};" ...
* Removed spurious calls to _removeData. The new test exposed various failures
e.g. where div[0] isn't being assigned any data anyway.
(queue.js and attributes.js toggleClass).
* Removed spurious clean up at the bottom of test() functions that are
already covered by the teardown (calling QUnit.reset or removeClass to
supposedly undo any changes).
* Documented the parentheses-less magic line in toggleClass. It appeared that
it would always keep the current class name if there was any (since the
assignment started with "this.className || ...".
Adding parentheses + spacing is 8 bytes (though only 1 in gzip apparently).
Only added the comment for now, though I prefer clarity with logical
operators, I'd rather not face the yayMinPD[1] in this test-related commit.
* Updated QUnit urlConfig to the new format (raw string is deprecated).
* Clean up odd htmlentities in test titles, QUnit escapes this.
(^\s+test\(.*)(>\;) → $1>
(^\s+test\(.*)(<\;) → $1<
[1] jQuery MinJsGz Release Police Department (do the same, download less)
2012-10-17 08:33:47 +00:00
|
|
|
// jQuery-specific QUnit.reset
|
2010-07-27 10:50:08 +00:00
|
|
|
QUnit.reset = function() {
|
2012-08-20 01:09:13 +00:00
|
|
|
|
|
|
|
// Ensure jQuery events and data on the fixture are properly removed
|
|
|
|
jQuery("#qunit-fixture").empty();
|
|
|
|
|
|
|
|
// Reset internal jQuery state
|
2010-07-27 10:50:08 +00:00
|
|
|
jQuery.event.global = {};
|
2012-11-01 04:40:27 +00:00
|
|
|
if ( ajaxSettings ) {
|
2012-11-26 02:31:19 +00:00
|
|
|
jQuery.ajaxSettings = jQuery.extend( true, {}, ajaxSettings );
|
2012-11-01 04:40:27 +00:00
|
|
|
} else {
|
|
|
|
delete jQuery.ajaxSettings;
|
|
|
|
}
|
2013-02-03 20:27:55 +00:00
|
|
|
|
2012-11-26 02:31:19 +00:00
|
|
|
// Cleanup globals
|
|
|
|
Globals.cleanup();
|
2012-08-20 01:09:13 +00:00
|
|
|
|
|
|
|
// Let QUnit reset the fixture
|
|
|
|
reset.apply( this, arguments );
|
2010-07-27 10:50:08 +00:00
|
|
|
};
|
|
|
|
})();
|
|
|
|
|
2012-04-20 14:55:07 +00:00
|
|
|
/**
|
|
|
|
* QUnit configuration
|
|
|
|
*/
|
|
|
|
// Max time for stop() and asyncTest() until it aborts test
|
|
|
|
// and start()'s the next test.
|
|
|
|
QUnit.config.testTimeout = 20 * 1000; // 20 seconds
|
|
|
|
|
2012-10-15 16:31:27 +00:00
|
|
|
// Enforce an "expect" argument or expect() call in all test bodies.
|
|
|
|
QUnit.config.requireExpects = true;
|
|
|
|
|
2012-04-20 14:55:07 +00:00
|
|
|
/**
|
|
|
|
* Load the TestSwarm listener if swarmURL is in the address.
|
|
|
|
*/
|
2010-03-23 16:19:47 +00:00
|
|
|
(function() {
|
|
|
|
var url = window.location.search;
|
2012-04-20 14:55:07 +00:00
|
|
|
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + "swarmURL=".length ) );
|
|
|
|
|
2010-03-23 16:19:47 +00:00
|
|
|
if ( !url || url.indexOf("http") !== 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
2010-03-24 20:04:10 +00:00
|
|
|
|
2012-11-25 19:30:16 +00:00
|
|
|
document.write("<scr" + "ipt src='http://swarm.jquery.org/js/inject.js?" + (new Date()).getTime() + "'></scr" + "ipt>");
|
2010-03-23 16:19:47 +00:00
|
|
|
})();
|