Anonymous avatar Anonymous committed 517846a

No ticket: speedup test suite. Close gh-1020.

Comments (0)

Files changed (4)

test/unit/ajax.js

 		jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) {
 			equal( foobar, "bar", "Check if script was evaluated" );
 			strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" );
-			setTimeout(function() {
-				start();
-			}, 1000 );
+			start();
 		});
 	});
 
 	test( "jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
 		var passed = 0;
 
-		expect( 1 );
+		expect( 2 );
 
 		stop();
 
 		});
 
 		var pass = function() {
-			passed++;
+			ok( passed++ < 2, "Error callback executed" );
 			if ( passed == 2 ) {
-				ok( true, "Check local and global callbacks after timeout" );
 				jQuery("#qunit-fixture").unbind("ajaxError");
 				start();
 			}

test/unit/effects.js

 
 asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
 	expect( 3 );
-	var foo = jQuery( "#foo" ),
-		saved;
+	var saved,
+		foo = jQuery("#foo").css({ width: 200, height: 200 });
 
-	foo.css( "width", 200 ).css( "height", 200 );
 	foo.animate({
 		width: 400
 	},{
-		duration: 1000,
+		duration: 500,
 		complete: function() {
 			equal( parseFloat( foo.css("width") ), 400, "Animation completed for standard queue" );
 			equal( parseFloat( foo.css("height") ), saved, "Height was not changed after the second stop");
 	},{
 		duration: 1000,
 		queue: "height"
-	}).dequeue( "height" ).stop( "height", false, true );
+	}).dequeue("height").stop( "height", false, true );
 
 	equal( parseFloat( foo.css("height") ), 400, "Height was stopped with gotoEnd" );
 
 	ok( x.is(":visible"), "is visible again" );
 });
 
-jQuery.checkOverflowDisplay = function(){
-	var o = jQuery.css( this, "overflow" );
-
-	equal(o, "visible", "Overflow should be visible: " + o);
-	equal(jQuery.css( this, "display" ), "inline", "Display shouldn't be tampered with.");
-
-	jQuery(this).remove();
-	start();
-};
-
 test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
 	var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
 			color: "#ABC",
 	jQuery( div ).remove();
 });
 
-test("JS Overflow and Display", function() {
-	expect(2);
+test("Overflow and Display", function() {
+	expect(4);
 	stop();
-	jQuery.makeTest( "JS Overflow and Display" )
-		.addClass("widewidth")
-		.css({ overflow: "visible", display: "inline" })
-		.addClass("widewidth")
-		.text("Some sample text.")
-		.before("text before")
-		.after("text after")
-		.animate({ opacity: 0.5 }, "slow", jQuery.checkOverflowDisplay);
-});
 
-test("CSS Overflow and Display", function() {
-	expect(2);
-	stop();
-	jQuery.makeTest( "CSS Overflow and Display" )
-		.addClass("overflow inline")
+	var
+		testClass = jQuery.makeTest("Overflow and Display")
+			.addClass("overflow inline"),
+		testStyle = jQuery.makeTest("Overflow and Display (inline style)")
+			.css({ overflow: "visible", display: "inline" }),
+		remaining = 2,
+		done = function() {
+			equal( jQuery.css( this, "overflow" ), "visible", "Overflow should be 'visible'" );
+			equal( jQuery.css( this, "display" ), "inline", "Display should be 'inline'" );
+
+			if ( --remaining === 0 ) {
+				start();
+			}
+		};
+
+	testClass.add( testStyle )
 		.addClass("widewidth")
 		.text("Some sample text.")
 		.before("text before")
 		.after("text after")
-		.animate({ opacity: 0.5 }, "slow", jQuery.checkOverflowDisplay);
+		.animate({ opacity: 0.5 }, "slow", done );
 });
 
 jQuery.each({
 	});
 });
 
-jQuery.expandedEach = jQuery.each;
-jQuery.expandedEach({
-	"slideToggle": function( $elem ) {
-		return parseFloat( $elem.css("height") );
-	},
-	"fadeToggle": function( $elem ) {
-		return $elem.css("opacity");
-	},
-	"toggle": function( $elem ) {
-		return parseFloat( $elem.css("width") );
-	}
-},
-function( method, defProp ) {
-	test( method + "().stop()." + method + "()", function() {
-		expect( 8 );
+test( "interrupt toggle", function() {
+	expect( 24 );
+	stop();
 
-		var animTime = 2000;
+	var longDuration = 2000,
+		shortDuration = 500,
+		remaining = 0,
+		$elems = jQuery(".chain-test"),
+		finish = function() {
+			if ( !(--remaining) ) {
+				start();
+			}
+		};
 
-		jQuery.each([ "in", "out" ], function( i, type ) {
-			var $elem = jQuery( "#" + method.toLowerCase() + type ),
-				startVal = defProp( $elem );
+	jQuery.each( { slideToggle: "height", fadeToggle: "opacity", toggle: "width" }, function( method, prop ) {
+		var $methodElems = $elems.filter( "[id^='" + method.toLowerCase() + "']" ).each(function() {
+			// Don't end test until we're done with this element
+			remaining++;
 
-			$elem[ method ]( animTime );
-			stop();
+			// Save original property value for comparison
+			jQuery.data( this, "startVal", jQuery( this ).css( prop ) );
 
-			setTimeout( function() {
-				$elem.stop();
+			// Expect olddisplay data from our .hide() call below
+			QUnit.expectJqData( this, "olddisplay" );
+		});
 
-				notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
+		// Interrupt a hiding toggle
+		$methodElems[ method ]( longDuration );
+		setTimeout(function() {
+			$methodElems.stop().each(function() {
+				notEqual( jQuery( this ).css( prop ), jQuery.data( this, "startVal" ), ".stop() before completion of hiding ." + method + "() - #" + this.id );
+			});
 
-				$elem[ method ](animTime, function() {
-					equal( defProp( $elem ), startVal, "After doing .stop() halfway through hide, check that state has been saved for returning to original property value." );
+			// Restore
+			$methodElems[ method ]( shortDuration, function() {
+				var id = this.id,
+					$elem = jQuery( this ),
+					startVal = $elem.data("startVal");
 
-					// Start from hidden position to show this time
-					$elem.hide()[ method ]( animTime );
-					setTimeout( function() {
-						$elem.stop();
+				$elem.removeData("startVal");
 
-						notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
+				equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
 
-						$elem[ method ](animTime, function() {
-							equal( defProp( $elem ), startVal, "After doing .stop() halfway through show, check that state has been saved for returning to original property value." );
+				// Interrupt a showing toggle
+				$elem.hide()[ method ]( longDuration );
+				setTimeout(function() {
+					$elem.stop();
+					notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id );
 
-							// Tolerate olddisplay data from .hide() call
-							QUnit.expectJqData( this, "olddisplay" );
-							start();
-						});
-					}, animTime / 2);
-				});
-			}, animTime / 2);
-		});
+					// Restore
+					$elem[ method ]( shortDuration, function() {
+						equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
+						finish();
+					});
+				}, shortDuration );
+			});
+		}, shortDuration );
 	});
 });
 
 		notEqual( l, 200, "Left is not 200 after partial animate" );
 		div.stop().remove();
 		start();
-	}, 1000);
+	}, 500);
 });
 
 test("callbacks should fire in correct order (#9100)", function() {
 	}).animate({
 		top: 100
 	}, {
-		duration: 1500,
+		duration: 1000,
 		queue: false,
 		complete: function() {
 			strictEqual( step++, 3, "Step 3" );

test/unit/manipulation.js

 	jQuery("body > span.unwrap").remove();
 });
 
-var getWrappedElement = function() {
-	return jQuery("#sap");
-};
-
-var getWrappedDocumentFragment = function() {
-	var f = document.createDocumentFragment();
-
-	// copy contents of #sap into new fragment
-	var clone = jQuery("#sap")[0].cloneNode(true);
-	var childs = clone.childNodes;
-	while (clone.childNodes.length) {
-		f.appendChild(clone.childNodes[0]);
-	}
-
-	clone = null;
-	return jQuery(f);
-};
-
 var testAppendForObject = function(valueObj, isFragment) {
-	var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
-	var objType = " " + (isFragment ? "(DocumentFragment)" : "(Element)");
-	var getObj = isFragment ? getWrappedDocumentFragment : getWrappedElement;
-
-	var obj = getObj();
-	obj.append(valueObj(document.getElementById("first")));
-	equal( obj.text(), expected, "Check for appending of element" + objType);
+	var $base,
+		type = isFragment ? " (DocumentFragment)" : " (Element)",
+		text = "This link has class=\"blog\": Simon Willison's Weblog",
+		el = document.getElementById("sap").cloneNode( true ),
+		first = document.getElementById("first"),
+		yahoo = document.getElementById("yahoo");
+
+	if ( isFragment ) {
+		$base = document.createDocumentFragment();
+		jQuery( el ).contents().each(function() {
+			$base.appendChild( this );
+		});
+		$base = jQuery( $base );
+	} else {
+		$base = jQuery( el );
+	}
 
-	QUnit.reset();
-	expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
-	obj = getObj();
-	obj.append(valueObj([document.getElementById("first"), document.getElementById("yahoo")]));
-	equal( obj.text(), expected, "Check for appending of array of elements" + objType );
+	equal( $base.clone().append( valueObj( first.cloneNode(true) ) ).text(),
+		text + "Try them out:",
+		"Check for appending of element" + type
+	);
 
-	QUnit.reset();
-	expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:";
-	obj = getObj();
-	obj.append(valueObj(jQuery("#yahoo, #first")));
-	equal( obj.text(), expected, "Check for appending of jQuery object" + objType );
+	equal( $base.clone().append( valueObj([ first.cloneNode(true), yahoo.cloneNode(true) ]) ).text(),
+		text + "Try them out:Yahoo",
+		"Check for appending of array of elements" + type
+	);
 
-	QUnit.reset();
-	obj = getObj();
-	obj.append(valueObj( 5 ));
-	ok( obj.text().match( /5$/ ), "Check for appending a number" + objType );
+	equal( $base.clone().append( valueObj( jQuery("#yahoo, #first").clone() ) ).text(),
+		text + "YahooTry them out:",
+		"Check for appending of jQuery object" + type
+	);
 
-	QUnit.reset();
-	expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:GoogleYahoo";
-	obj = getObj();
-	obj.append( valueObj( [ jQuery("#first"), jQuery("#yahoo, #google") ] ) );
-	equal( obj.text(), expected, "Check for appending of array of jQuery objects" );
+	equal( $base.clone().append( valueObj(5) ).text(),
+		text + "5",
+		"Check for appending a number" + type
+	);
 
-	QUnit.reset();
-	obj = getObj();
-	obj.append(valueObj( " text with spaces " ));
-	ok( obj.text().match(/ text with spaces $/), "Check for appending text with spaces" + objType );
+	equal( $base.clone().append( valueObj( [ jQuery("#first").clone(), jQuery("#yahoo, #google").clone() ] ) ).text(),
+		text + "Try them out:GoogleYahoo",
+		"Check for appending of array of jQuery objects"
+	);
 
-	QUnit.reset();
-	obj = getObj();
-	ok( obj.append(valueObj( [] )), "Check for appending an empty array." + objType );
-	ok( obj.append(valueObj( "" )), "Check for appending an empty string." + objType );
-	ok( obj.append(valueObj( document.getElementsByTagName("foo") )), "Check for appending an empty nodelist." + objType );
+	equal( $base.clone().append( valueObj(" text with spaces ") ).text(),
+		text + " text with spaces ",
+		"Check for appending text with spaces" + type
+	);
 
-	QUnit.reset();
-	obj = getObj();
-	obj.append(valueObj( document.getElementById("form") ));
-	equal( obj.children("form").size(), 1, "Check for appending a form" + objType ); // Bug #910
+	equal( $base.clone().append( valueObj([]) ).text(),
+		text,
+		"Check for appending an empty array" + type
+	);
 
-	QUnit.reset();
-	obj = getObj();
+	equal( $base.clone().append( valueObj("") ).text(),
+		text,
+		"Check for appending an empty string" + type
+	);
 
-	var prev = obj.children().length;
+	equal( $base.clone().append( valueObj( document.getElementsByTagName("foo") ) ).text(),
+		text,
+		"Check for appending an empty nodelist" + type
+	);
 
-	obj.append(
-		"<span></span>",
-		"<span></span>",
-		"<span></span>"
+	equal( $base.clone().append( "<span></span>", "<span></span>", "<span></span>").children().length,
+		$base.children().length + 3,
+		"Make sure that multiple arguments works." + type
 	);
 
-	equal( obj.children().length, prev + 3, "Make sure that multiple arguments works." + objType );
-	QUnit.reset();
+	equal( $base.clone().append( valueObj( document.getElementById("form").cloneNode(true) ) ).children("form").length,
+		1,
+		"Check for appending a form (#910)" + type
+	);
 };
 
 var testAppend = function(valueObj) {
 	equal( result.text(), defaultText + "buga", "Check if text appending works" );
 	equal( jQuery("#select3").append(valueObj("<option value='appendTest'>Append Test</option>")).find("option:last-child").attr("value"), "appendTest", "Appending html options to select element");
 
-	QUnit.reset();
 	jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked='checked' />"));
 	jQuery("form input[name=radiotest]").each(function(){
 		ok( jQuery(this).is(":checked"), "Append checked radio");
 	}).remove();
 
-	QUnit.reset();
-	jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked    =   'checked' />"));
-	jQuery("form input[name=radiotest]").each(function(){
+	jQuery("form").append(valueObj("<input name='radiotest2' type='radio' checked    =   'checked' />"));
+	jQuery("form input[name=radiotest2]").each(function(){
 		ok( jQuery(this).is(":checked"), "Append alternately formated checked radio");
 	}).remove();
 
-	QUnit.reset();
-	jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked />"));
-	jQuery("form input[name=radiotest]").each(function(){
+	jQuery("form").append(valueObj("<input name='radiotest3' type='radio' checked />"));
+	jQuery("form input[name=radiotest3]").each(function(){
 		ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio");
 	}).remove();
 
-	QUnit.reset();
-	jQuery("form").append(valueObj("<input type='radio' checked='checked' name='radiotest' />"));
-	jQuery("form input[name=radiotest]").each(function(){
+	jQuery("form").append(valueObj("<input type='radio' checked='checked' name='radiotest4' />"));
+	jQuery("form input[name=radiotest4]").each(function(){
 		ok( jQuery(this).is(":checked"), "Append with name attribute after checked attribute");
 	}).remove();
 
-	QUnit.reset();
-	var pass = true;
+	var message = "Test for appending a DOM node to the contents of an iframe",
+		iframe = jQuery("#iframe")[0],
+		iframeDoc = iframe.contentDocument || iframe.contentWindow && iframe.contentWindow.document;
 	try {
-		var body = jQuery("#iframe")[0].contentWindow.document.body;
-
-		pass = false;
-		jQuery( body ).append(valueObj( "<div>test</div>" ));
-		pass = true;
-	} catch(e) {}
-
-	ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
+		if ( iframeDoc && iframeDoc.body ) {
+			equal( jQuery( iframeDoc.body ).append( valueObj("<div id='success'>test</div>") )[0].lastChild.id, "success", message );
+		} else {
+			ok( true, message + " - can't test" );
+		}
+	} catch(e) {
+		strictEqual( e.message || e, undefined, message );
+	}
 
-	QUnit.reset();
-	jQuery("<fieldset/>").appendTo("#form").append(valueObj( "<legend id='legend'>test</legend>" ));
+	jQuery("<fieldset/>").appendTo("#form").append( valueObj("<legend id='legend'>test</legend>") );
 	t( "Append legend", "#legend", ["legend"] );
 
-	QUnit.reset();
-	jQuery("#select1").append(valueObj( "<OPTION>Test</OPTION>" ));
-	equal( jQuery("#select1 option:last").text(), "Test", "Appending &lt;OPTION&gt; (all caps)" );
+	jQuery("#select1").append( valueObj("<OPTION>Test</OPTION>") );
+	equal( jQuery("#select1 option:last").text(), "Test", "Appending OPTION (all caps)" );
 
-	jQuery("#table").append(valueObj( "<colgroup></colgroup>" ));
-	ok( jQuery("#table colgroup").length, "Append colgroup" );
+	jQuery("#table").append( valueObj("<colgroup></colgroup>") );
+	equal( jQuery("#table colgroup").length, 1, "Append colgroup" );
 
-	jQuery("#table colgroup").append(valueObj( "<col/>" ));
-	ok( jQuery("#table colgroup col").length, "Append col" );
+	jQuery("#table colgroup").append( valueObj("<col/>") );
+	equal( jQuery("#table colgroup col").length, 1, "Append col" );
 
-	QUnit.reset();
-	jQuery("#table").append(valueObj( "<caption></caption>" ));
-	ok( jQuery("#table caption").length, "Append caption" );
-
-	QUnit.reset();
-	jQuery("form:last")
-		.append(valueObj( "<select id='appendSelect1'></select>" ))
-		.append(valueObj( "<select id='appendSelect2'><option>Test</option></select>" ));
+	jQuery("#table").append( valueObj("<caption></caption>") );
+	equal( jQuery("#table caption").length, 1, "Append caption" );
 
+	jQuery("#form")
+		.append( valueObj("<select id='appendSelect1'></select>") )
+		.append( valueObj("<select id='appendSelect2'><option>Test</option></select>") );
 	t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
 
 	equal( "Two nodes", jQuery("<div />").append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
 	var j = jQuery("#nonnodes").contents();
 	var d = jQuery("<div/>").appendTo("#nonnodes").append(j);
 	equal( jQuery("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
-	ok( d.contents().length >= 2, "Check node,textnode,comment append works" );
+	equal( d.contents().length, 3, "Check node,textnode,comment append works" );
 	d.contents().appendTo("#nonnodes");
 	d.remove();
-	ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" );
+	equal( jQuery("#nonnodes").contents().length, 3, "Check node,textnode,comment append cleanup worked" );
 
-	QUnit.reset();
 	var $input = jQuery("<input />").attr({ "type": "checkbox", "checked": true }).appendTo("#testForm");
 	equal( $input[0].checked, true, "A checked checkbox that is appended stays checked" );
 
-	QUnit.reset();
-	var $radios = jQuery("input:radio[name='R1']"),
-		$radioNot = jQuery("<input type='radio' name='R1' checked='checked'/>").insertAfter( $radios ),
-		$radio = $radios.eq(1).click();
-	$radioNot[0].checked = false;
-	$radios.parent().wrap("<div></div>");
-	equal( $radio[0].checked, true, "Reappending radios uphold which radio is checked" );
-	equal( $radioNot[0].checked, false, "Reappending radios uphold not being checked" );
-	QUnit.reset();
+	var $radioChecked = jQuery("input:radio[name='R1']").eq(1),
+		$radioParent = $radioChecked.parent(),
+		$radioUnchecked = jQuery("<input type='radio' name='R1' checked='checked'/>").appendTo( $radioParent );
+	$radioChecked.click();
+	$radioUnchecked[0].checked = false;
+	$radioParent.wrap("<div></div>");
+	equal( $radioChecked[0].checked, true, "Reappending radios uphold which radio is checked" );
+	equal( $radioUnchecked[0].checked, false, "Reappending radios uphold not being checked" );
 };
 
 test("append(String|Element|Array<Element>|jQuery)", function() {
 });
 
 test("clone()", function() {
-	expect( 44 );
-
-	equal( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" );
-	var clone = jQuery("#yahoo").clone();
-	equal( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" );
-	equal( "This is a normal link: Yahoo", jQuery("#en").text(), "Reassert text for #en" );
-
-	var cloneTags = [
-		"<table/>", "<tr/>", "<td/>", "<div/>",
-		"<button/>", "<ul/>", "<ol/>", "<li/>",
-		"<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
-		"<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>"
-	];
-	for (var i = 0; i < cloneTags.length; i++) {
-		var j = jQuery(cloneTags[i]);
-		equal( j[0].tagName, j.clone()[0].tagName, "Clone a " + cloneTags[i]);
-	}
+	expect( 45 );
+	var div, clone;
 
-	// using contents will get comments regular, text, and comment nodes
-	var cl = jQuery("#nonnodes").contents().clone();
-	ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
+	equal( jQuery("#en").text(), "This is a normal link: Yahoo", "Assert text for #en" );
+	equal( jQuery("#first").append( jQuery("#yahoo").clone() ).text(), "Try them out:Yahoo", "Check for clone" );
+	equal( jQuery("#en").text(), "This is a normal link: Yahoo", "Reassert text for #en" );
 
-	var div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
-		ok( true, "Bound event still exists." );
+	jQuery.each( "table thead tbody tfoot tr td div button ul ol li select option textarea iframe".split(" "), function( i, nodeName ) {
+		equal( jQuery( "<" + nodeName + "/>" ).clone()[0].nodeName.toLowerCase(), nodeName, "Clone a " + nodeName );
 	});
+	equal( jQuery("<input type='checkbox' />").clone()[0].nodeName.toLowerCase(), "input", "Clone a <input type='checkbox' />" );
 
-	clone = div.clone(true);
-
-	// manually clean up detached elements
-	div.remove();
-
-	div = clone.clone(true);
+	// Check cloning non-elements
+	equal( jQuery("#nonnodes").contents().clone().length, 3, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
 
-	// manually clean up detached elements
-	clone.remove();
+	// Verify that clones of clones can keep event listeners
+	div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
+		ok( true, "Bound event still exists." );
+	});
+	clone = div.clone(true); div.remove();
+	div = clone.clone(true); clone.remove();
 
 	equal( div.length, 1, "One element cloned" );
 	equal( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
 	div.trigger("click");
 
-	// manually clean up detached elements
+	// Manually clean up detached elements
 	div.remove();
 
+	// Verify that cloned children can keep event listeners
 	div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
 	div.find("table").click(function(){
 		ok( true, "Bound event still exists." );
 	clone = div.clone(true);
 	equal( clone.length, 1, "One element cloned" );
 	equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
-	clone.find("table:last").trigger("click");
+	clone.find("table").trigger("click");
 
-	// manually clean up detached elements
+	// Manually clean up detached elements
 	div.remove();
 	clone.remove();
 
-	var divEvt = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
+	// Make sure that doing .clone() doesn't clone event listeners
+	div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
 		ok( false, "Bound event still exists after .clone()." );
-	}),
-		cloneEvt = divEvt.clone();
+	});
+	clone = div.clone();
 
-	// Make sure that doing .clone() doesn't clone events
-	cloneEvt.trigger("click");
+	clone.trigger("click");
 
-	cloneEvt.remove();
-	divEvt.remove();
+	// Manually clean up detached elements
+	clone.remove();
+	div.remove();
 
-	// Test both html() and clone() for <embed and <object types
+	// Test both html() and clone() for <embed> and <object> types
 	div = jQuery("<div/>").html("<embed height='355' width='425' src='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'></embed>");
 
 	clone = div.clone(true);
 
 	clone = div.clone(true);
 	equal( clone.length, 1, "One element cloned" );
-	(function checkForAttributes( $ ) {
-		// IE6/7 adds some extra parameters so just test for existance of a defined set
-		var parameters = ["height", "width", "classid"],
-			$divObject = div.find("object"),
-			$cloneObject = clone.find("object");
-
-		$.each( parameters, function(index, parameter)  {
-			equal( $cloneObject.attr(parameter), $divObject.attr(parameter), "Element attributes cloned: " + parameter );
-		});
-	})( jQuery );
-	(function checkForParams() {
-		// IE6/7/8 adds a bunch of extram param elements so just test for those that are trying to clone
+	equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
+	div = div.find("object");
+	clone = clone.find("object");
+	// oldIE adds extra attributes and <param> elements, so just test for existence of the defined set
+	jQuery.each([ "height", "width", "classid" ], function( i, attr ) {
+		equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr );
+	});
+	(function() {
 		var params = {};
 
 		clone.find("param").each(function(index, param) {
-			params[param.attributes.name.nodeValue.toLowerCase()] =
+			params[ param.attributes.name.nodeValue.toLowerCase() ] =
 				param.attributes.value.nodeValue.toLowerCase();
 		});
 
 		div.find("param").each(function(index, param) {
-			var actualValue = params[param.attributes.name.nodeValue.toLowerCase()],
-				expectedValue = param.attributes.value.nodeValue.toLowerCase();
-
-			equal( actualValue, expectedValue, "Param cloned: " + param.attributes.name.nodeValue );
+			var key = param.attributes.name.nodeValue.toLowerCase();
+			equal( params[ key ], param.attributes.value.nodeValue.toLowerCase(), "<param> cloned: " + key );
 		});
 	})();
-	equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
 
 	// and here's a valid one.
 	div = jQuery("<div/>").html("<object height='355' width='425' type='application/x-shockwave-flash' data='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'>  <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&amp;hl=en'>  <param name='wmode' value='transparent'> </object>");

test/unit/queue.js

 		expect( 3 );
 		stop();
 
-		var foo = jQuery({}), run = 0;
-
-		foo
+		var done = {};
+		jQuery({})
 			.queue( "alternate", function( next ) {
-				run++;
+				done.alt1 = true;
 				ok( true, "This first function was dequeued" );
 				next();
 			})
 			.delay( 1000, "alternate" )
 			.queue( "alternate", function() {
-				run++;
+				done.alt2 = true;
 				ok( true, "The function was dequeued immediately, the delay was stopped" );
 			})
 			.dequeue( "alternate" )
 			.stop( "alternate", false, false )
 
 			// this test
-			.delay( 1000 )
+			.delay( 1 )
 			.queue(function() {
-				run++;
+				done.default1 = true;
 				ok( false, "This queue should never run" );
 			})
 
 			// stop( clearQueue ) should clear the queue
 			.stop( true, false );
 
-		equal( run, 2, "Queue ran the proper functions" );
+		deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" );
 
-		setTimeout( start, 2000 );
+		setTimeout(function() {
+			start();
+		}, 1500 );
 	});
 
 	asyncTest( "queue stop hooks", 2, function() {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.