mirror of
https://github.com/jquery/jquery.git
synced 2024-12-09 08:04:24 +00:00
No ticket: speedup test suite. Close gh-1020.
This commit is contained in:
parent
877306738f
commit
517846aad2
@ -1481,9 +1481,7 @@
|
|||||||
jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) {
|
jQuery.getScript( url("data/test.js"), function( data, _, jqXHR ) {
|
||||||
equal( foobar, "bar", "Check if script was evaluated" );
|
equal( foobar, "bar", "Check if script was evaluated" );
|
||||||
strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" );
|
strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" );
|
||||||
setTimeout(function() {
|
|
||||||
start();
|
start();
|
||||||
}, 1000 );
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2221,7 +2219,7 @@
|
|||||||
test( "jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
test( "jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
|
||||||
var passed = 0;
|
var passed = 0;
|
||||||
|
|
||||||
expect( 1 );
|
expect( 2 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
@ -2230,9 +2228,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var pass = function() {
|
var pass = function() {
|
||||||
passed++;
|
ok( passed++ < 2, "Error callback executed" );
|
||||||
if ( passed == 2 ) {
|
if ( passed == 2 ) {
|
||||||
ok( true, "Check local and global callbacks after timeout" );
|
|
||||||
jQuery("#qunit-fixture").unbind("ajaxError");
|
jQuery("#qunit-fixture").unbind("ajaxError");
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
153
test/unit/effects.js
vendored
153
test/unit/effects.js
vendored
@ -695,14 +695,13 @@ test("stop(clearQueue, gotoEnd)", function() {
|
|||||||
|
|
||||||
asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
|
asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
|
||||||
expect( 3 );
|
expect( 3 );
|
||||||
var foo = jQuery( "#foo" ),
|
var saved,
|
||||||
saved;
|
foo = jQuery("#foo").css({ width: 200, height: 200 });
|
||||||
|
|
||||||
foo.css( "width", 200 ).css( "height", 200 );
|
|
||||||
foo.animate({
|
foo.animate({
|
||||||
width: 400
|
width: 400
|
||||||
},{
|
},{
|
||||||
duration: 1000,
|
duration: 500,
|
||||||
complete: function() {
|
complete: function() {
|
||||||
equal( parseFloat( foo.css("width") ), 400, "Animation completed for standard queue" );
|
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");
|
equal( parseFloat( foo.css("height") ), saved, "Height was not changed after the second stop");
|
||||||
@ -745,16 +744,6 @@ test("toggle()", function() {
|
|||||||
ok( x.is(":visible"), "is visible again" );
|
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() {
|
test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
|
||||||
var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
|
var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
|
||||||
color: "#ABC",
|
color: "#ABC",
|
||||||
@ -809,29 +798,31 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
|
|||||||
jQuery( div ).remove();
|
jQuery( div ).remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("JS Overflow and Display", function() {
|
test("Overflow and Display", function() {
|
||||||
expect(2);
|
expect(4);
|
||||||
stop();
|
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() {
|
var
|
||||||
expect(2);
|
testClass = jQuery.makeTest("Overflow and Display")
|
||||||
stop();
|
.addClass("overflow inline"),
|
||||||
jQuery.makeTest( "CSS Overflow and Display" )
|
testStyle = jQuery.makeTest("Overflow and Display (inline style)")
|
||||||
.addClass("overflow inline")
|
.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")
|
.addClass("widewidth")
|
||||||
.text("Some sample text.")
|
.text("Some sample text.")
|
||||||
.before("text before")
|
.before("text before")
|
||||||
.after("text after")
|
.after("text after")
|
||||||
.animate({ opacity: 0.5 }, "slow", jQuery.checkOverflowDisplay);
|
.animate({ opacity: 0.5 }, "slow", done );
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery.each({
|
jQuery.each({
|
||||||
@ -1126,57 +1117,63 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery.expandedEach = jQuery.each;
|
test( "interrupt toggle", function() {
|
||||||
jQuery.expandedEach({
|
expect( 24 );
|
||||||
"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 );
|
|
||||||
|
|
||||||
var animTime = 2000;
|
|
||||||
|
|
||||||
jQuery.each([ "in", "out" ], function( i, type ) {
|
|
||||||
var $elem = jQuery( "#" + method.toLowerCase() + type ),
|
|
||||||
startVal = defProp( $elem );
|
|
||||||
|
|
||||||
$elem[ method ]( animTime );
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
setTimeout( function() {
|
var longDuration = 2000,
|
||||||
$elem.stop();
|
shortDuration = 500,
|
||||||
|
remaining = 0,
|
||||||
notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
|
$elems = jQuery(".chain-test"),
|
||||||
|
finish = function() {
|
||||||
$elem[ method ](animTime, function() {
|
if ( !(--remaining) ) {
|
||||||
equal( defProp( $elem ), startVal, "After doing .stop() halfway through hide, check that state has been saved for returning to original property value." );
|
|
||||||
|
|
||||||
// Start from hidden position to show this time
|
|
||||||
$elem.hide()[ method ]( animTime );
|
|
||||||
setTimeout( function() {
|
|
||||||
$elem.stop();
|
|
||||||
|
|
||||||
notEqual( defProp( $elem ), startVal, ".stop() is called about halfway through animation." );
|
|
||||||
|
|
||||||
$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." );
|
|
||||||
|
|
||||||
// Tolerate olddisplay data from .hide() call
|
|
||||||
QUnit.expectJqData( this, "olddisplay" );
|
|
||||||
start();
|
start();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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++;
|
||||||
|
|
||||||
|
// Save original property value for comparison
|
||||||
|
jQuery.data( this, "startVal", jQuery( this ).css( prop ) );
|
||||||
|
|
||||||
|
// Expect olddisplay data from our .hide() call below
|
||||||
|
QUnit.expectJqData( this, "olddisplay" );
|
||||||
});
|
});
|
||||||
}, animTime / 2);
|
|
||||||
|
// 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 );
|
||||||
});
|
});
|
||||||
}, animTime / 2);
|
|
||||||
|
// Restore
|
||||||
|
$methodElems[ method ]( shortDuration, function() {
|
||||||
|
var id = this.id,
|
||||||
|
$elem = jQuery( this ),
|
||||||
|
startVal = $elem.data("startVal");
|
||||||
|
|
||||||
|
$elem.removeData("startVal");
|
||||||
|
|
||||||
|
equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
|
||||||
|
|
||||||
|
// Interrupt a showing toggle
|
||||||
|
$elem.hide()[ method ]( longDuration );
|
||||||
|
setTimeout(function() {
|
||||||
|
$elem.stop();
|
||||||
|
notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id );
|
||||||
|
|
||||||
|
// Restore
|
||||||
|
$elem[ method ]( shortDuration, function() {
|
||||||
|
equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
|
||||||
|
finish();
|
||||||
});
|
});
|
||||||
|
}, shortDuration );
|
||||||
|
});
|
||||||
|
}, shortDuration );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1319,7 +1316,7 @@ test( "animate properties missing px w/ opacity as last (#9074)", 2, function()
|
|||||||
notEqual( l, 200, "Left is not 200 after partial animate" );
|
notEqual( l, 200, "Left is not 200 after partial animate" );
|
||||||
div.stop().remove();
|
div.stop().remove();
|
||||||
start();
|
start();
|
||||||
}, 1000);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("callbacks should fire in correct order (#9100)", function() {
|
test("callbacks should fire in correct order (#9100)", function() {
|
||||||
@ -1663,7 +1660,7 @@ asyncTest( "multiple unqueued and promise", 4, function() {
|
|||||||
}).animate({
|
}).animate({
|
||||||
top: 100
|
top: 100
|
||||||
}, {
|
}, {
|
||||||
duration: 1500,
|
duration: 1000,
|
||||||
queue: false,
|
queue: false,
|
||||||
complete: function() {
|
complete: function() {
|
||||||
strictEqual( step++, 3, "Step 3" );
|
strictEqual( step++, 3, "Step 3" );
|
||||||
|
@ -281,85 +281,78 @@ test("unwrap()", function() {
|
|||||||
jQuery("body > span.unwrap").remove();
|
jQuery("body > span.unwrap").remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
var getWrappedElement = function() {
|
var testAppendForObject = function(valueObj, isFragment) {
|
||||||
return jQuery("#sap");
|
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");
|
||||||
|
|
||||||
var getWrappedDocumentFragment = function() {
|
if ( isFragment ) {
|
||||||
var f = document.createDocumentFragment();
|
$base = document.createDocumentFragment();
|
||||||
|
jQuery( el ).contents().each(function() {
|
||||||
// copy contents of #sap into new fragment
|
$base.appendChild( this );
|
||||||
var clone = jQuery("#sap")[0].cloneNode(true);
|
});
|
||||||
var childs = clone.childNodes;
|
$base = jQuery( $base );
|
||||||
while (clone.childNodes.length) {
|
} else {
|
||||||
f.appendChild(clone.childNodes[0]);
|
$base = jQuery( el );
|
||||||
}
|
}
|
||||||
|
|
||||||
clone = null;
|
equal( $base.clone().append( valueObj( first.cloneNode(true) ) ).text(),
|
||||||
return jQuery(f);
|
text + "Try them out:",
|
||||||
};
|
"Check for appending of element" + type
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
QUnit.reset();
|
|
||||||
obj = getObj();
|
|
||||||
obj.append(valueObj( 5 ));
|
|
||||||
ok( obj.text().match( /5$/ ), "Check for appending a number" + objType );
|
|
||||||
|
|
||||||
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" );
|
|
||||||
|
|
||||||
QUnit.reset();
|
|
||||||
obj = getObj();
|
|
||||||
obj.append(valueObj( " text with spaces " ));
|
|
||||||
ok( obj.text().match(/ text with spaces $/), "Check for appending text with spaces" + objType );
|
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
QUnit.reset();
|
|
||||||
obj = getObj();
|
|
||||||
obj.append(valueObj( document.getElementById("form") ));
|
|
||||||
equal( obj.children("form").size(), 1, "Check for appending a form" + objType ); // Bug #910
|
|
||||||
|
|
||||||
QUnit.reset();
|
|
||||||
obj = getObj();
|
|
||||||
|
|
||||||
var prev = obj.children().length;
|
|
||||||
|
|
||||||
obj.append(
|
|
||||||
"<span></span>",
|
|
||||||
"<span></span>",
|
|
||||||
"<span></span>"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
equal( obj.children().length, prev + 3, "Make sure that multiple arguments works." + objType );
|
equal( $base.clone().append( valueObj([ first.cloneNode(true), yahoo.cloneNode(true) ]) ).text(),
|
||||||
QUnit.reset();
|
text + "Try them out:Yahoo",
|
||||||
|
"Check for appending of array of elements" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( valueObj( jQuery("#yahoo, #first").clone() ) ).text(),
|
||||||
|
text + "YahooTry them out:",
|
||||||
|
"Check for appending of jQuery object" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( valueObj(5) ).text(),
|
||||||
|
text + "5",
|
||||||
|
"Check for appending a number" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
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"
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( valueObj(" text with spaces ") ).text(),
|
||||||
|
text + " text with spaces ",
|
||||||
|
"Check for appending text with spaces" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( valueObj([]) ).text(),
|
||||||
|
text,
|
||||||
|
"Check for appending an empty array" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( valueObj("") ).text(),
|
||||||
|
text,
|
||||||
|
"Check for appending an empty string" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( valueObj( document.getElementsByTagName("foo") ) ).text(),
|
||||||
|
text,
|
||||||
|
"Check for appending an empty nodelist" + type
|
||||||
|
);
|
||||||
|
|
||||||
|
equal( $base.clone().append( "<span></span>", "<span></span>", "<span></span>").children().length,
|
||||||
|
$base.children().length + 3,
|
||||||
|
"Make sure that multiple arguments works." + type
|
||||||
|
);
|
||||||
|
|
||||||
|
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) {
|
var testAppend = function(valueObj) {
|
||||||
@ -372,65 +365,57 @@ var testAppend = function(valueObj) {
|
|||||||
equal( result.text(), defaultText + "buga", "Check if text appending works" );
|
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");
|
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").append(valueObj("<input name='radiotest' type='radio' checked='checked' />"));
|
||||||
jQuery("form input[name=radiotest]").each(function(){
|
jQuery("form input[name=radiotest]").each(function(){
|
||||||
ok( jQuery(this).is(":checked"), "Append checked radio");
|
ok( jQuery(this).is(":checked"), "Append checked radio");
|
||||||
}).remove();
|
}).remove();
|
||||||
|
|
||||||
QUnit.reset();
|
jQuery("form").append(valueObj("<input name='radiotest2' type='radio' checked = 'checked' />"));
|
||||||
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked = 'checked' />"));
|
jQuery("form input[name=radiotest2]").each(function(){
|
||||||
jQuery("form input[name=radiotest]").each(function(){
|
|
||||||
ok( jQuery(this).is(":checked"), "Append alternately formated checked radio");
|
ok( jQuery(this).is(":checked"), "Append alternately formated checked radio");
|
||||||
}).remove();
|
}).remove();
|
||||||
|
|
||||||
QUnit.reset();
|
jQuery("form").append(valueObj("<input name='radiotest3' type='radio' checked />"));
|
||||||
jQuery("form").append(valueObj("<input name='radiotest' type='radio' checked />"));
|
jQuery("form input[name=radiotest3]").each(function(){
|
||||||
jQuery("form input[name=radiotest]").each(function(){
|
|
||||||
ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio");
|
ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio");
|
||||||
}).remove();
|
}).remove();
|
||||||
|
|
||||||
QUnit.reset();
|
jQuery("form").append(valueObj("<input type='radio' checked='checked' name='radiotest4' />"));
|
||||||
jQuery("form").append(valueObj("<input type='radio' checked='checked' name='radiotest' />"));
|
jQuery("form input[name=radiotest4]").each(function(){
|
||||||
jQuery("form input[name=radiotest]").each(function(){
|
|
||||||
ok( jQuery(this).is(":checked"), "Append with name attribute after checked attribute");
|
ok( jQuery(this).is(":checked"), "Append with name attribute after checked attribute");
|
||||||
}).remove();
|
}).remove();
|
||||||
|
|
||||||
QUnit.reset();
|
var message = "Test for appending a DOM node to the contents of an iframe",
|
||||||
var pass = true;
|
iframe = jQuery("#iframe")[0],
|
||||||
|
iframeDoc = iframe.contentDocument || iframe.contentWindow && iframe.contentWindow.document;
|
||||||
try {
|
try {
|
||||||
var body = jQuery("#iframe")[0].contentWindow.document.body;
|
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 );
|
||||||
|
}
|
||||||
|
|
||||||
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" );
|
|
||||||
|
|
||||||
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"] );
|
t( "Append legend", "#legend", ["legend"] );
|
||||||
|
|
||||||
QUnit.reset();
|
|
||||||
jQuery("#select1").append( valueObj("<OPTION>Test</OPTION>") );
|
jQuery("#select1").append( valueObj("<OPTION>Test</OPTION>") );
|
||||||
equal( jQuery("#select1 option:last").text(), "Test", "Appending <OPTION> (all caps)" );
|
equal( jQuery("#select1 option:last").text(), "Test", "Appending OPTION (all caps)" );
|
||||||
|
|
||||||
jQuery("#table").append( valueObj("<colgroup></colgroup>") );
|
jQuery("#table").append( valueObj("<colgroup></colgroup>") );
|
||||||
ok( jQuery("#table colgroup").length, "Append colgroup" );
|
equal( jQuery("#table colgroup").length, 1, "Append colgroup" );
|
||||||
|
|
||||||
jQuery("#table colgroup").append( valueObj("<col/>") );
|
jQuery("#table colgroup").append( valueObj("<col/>") );
|
||||||
ok( jQuery("#table colgroup col").length, "Append col" );
|
equal( jQuery("#table colgroup col").length, 1, "Append col" );
|
||||||
|
|
||||||
QUnit.reset();
|
|
||||||
jQuery("#table").append( valueObj("<caption></caption>") );
|
jQuery("#table").append( valueObj("<caption></caption>") );
|
||||||
ok( jQuery("#table caption").length, "Append caption" );
|
equal( jQuery("#table caption").length, 1, "Append caption" );
|
||||||
|
|
||||||
QUnit.reset();
|
jQuery("#form")
|
||||||
jQuery("form:last")
|
|
||||||
.append( valueObj("<select id='appendSelect1'></select>") )
|
.append( valueObj("<select id='appendSelect1'></select>") )
|
||||||
.append( valueObj("<select id='appendSelect2'><option>Test</option></select>") );
|
.append( valueObj("<select id='appendSelect2'><option>Test</option></select>") );
|
||||||
|
|
||||||
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
|
t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
|
||||||
|
|
||||||
equal( "Two nodes", jQuery("<div />").append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
|
equal( "Two nodes", jQuery("<div />").append("Two", " nodes").text(), "Appending two text nodes (#4011)" );
|
||||||
@ -439,24 +424,22 @@ var testAppend = function(valueObj) {
|
|||||||
var j = jQuery("#nonnodes").contents();
|
var j = jQuery("#nonnodes").contents();
|
||||||
var d = jQuery("<div/>").appendTo("#nonnodes").append(j);
|
var d = jQuery("<div/>").appendTo("#nonnodes").append(j);
|
||||||
equal( jQuery("#nonnodes").length, 1, "Check node,textnode,comment append moved leaving just the div" );
|
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.contents().appendTo("#nonnodes");
|
||||||
d.remove();
|
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");
|
var $input = jQuery("<input />").attr({ "type": "checkbox", "checked": true }).appendTo("#testForm");
|
||||||
equal( $input[0].checked, true, "A checked checkbox that is appended stays checked" );
|
equal( $input[0].checked, true, "A checked checkbox that is appended stays checked" );
|
||||||
|
|
||||||
QUnit.reset();
|
var $radioChecked = jQuery("input:radio[name='R1']").eq(1),
|
||||||
var $radios = jQuery("input:radio[name='R1']"),
|
$radioParent = $radioChecked.parent(),
|
||||||
$radioNot = jQuery("<input type='radio' name='R1' checked='checked'/>").insertAfter( $radios ),
|
$radioUnchecked = jQuery("<input type='radio' name='R1' checked='checked'/>").appendTo( $radioParent );
|
||||||
$radio = $radios.eq(1).click();
|
$radioChecked.click();
|
||||||
$radioNot[0].checked = false;
|
$radioUnchecked[0].checked = false;
|
||||||
$radios.parent().wrap("<div></div>");
|
$radioParent.wrap("<div></div>");
|
||||||
equal( $radio[0].checked, true, "Reappending radios uphold which radio is checked" );
|
equal( $radioChecked[0].checked, true, "Reappending radios uphold which radio is checked" );
|
||||||
equal( $radioNot[0].checked, false, "Reappending radios uphold not being checked" );
|
equal( $radioUnchecked[0].checked, false, "Reappending radios uphold not being checked" );
|
||||||
QUnit.reset();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
test("append(String|Element|Array<Element>|jQuery)", function() {
|
test("append(String|Element|Array<Element>|jQuery)", function() {
|
||||||
@ -1272,49 +1255,36 @@ test("clone() (#8070)", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("clone()", function() {
|
test("clone()", function() {
|
||||||
expect( 44 );
|
expect( 45 );
|
||||||
|
var div, clone;
|
||||||
|
|
||||||
equal( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" );
|
equal( jQuery("#en").text(), "This is a normal link: Yahoo", "Assert text for #en" );
|
||||||
var clone = jQuery("#yahoo").clone();
|
equal( jQuery("#first").append( jQuery("#yahoo").clone() ).text(), "Try them out:Yahoo", "Check for clone" );
|
||||||
equal( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" );
|
equal( jQuery("#en").text(), "This is a normal link: Yahoo", "Reassert text for #en" );
|
||||||
equal( "This is a normal link: Yahoo", jQuery("#en").text(), "Reassert text for #en" );
|
|
||||||
|
|
||||||
var cloneTags = [
|
jQuery.each( "table thead tbody tfoot tr td div button ul ol li select option textarea iframe".split(" "), function( i, nodeName ) {
|
||||||
"<table/>", "<tr/>", "<td/>", "<div/>",
|
equal( jQuery( "<" + nodeName + "/>" ).clone()[0].nodeName.toLowerCase(), nodeName, "Clone a " + nodeName );
|
||||||
"<button/>", "<ul/>", "<ol/>", "<li/>",
|
});
|
||||||
"<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>",
|
equal( jQuery("<input type='checkbox' />").clone()[0].nodeName.toLowerCase(), "input", "Clone a <input type='checkbox' />" );
|
||||||
"<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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// using contents will get comments regular, text, and comment nodes
|
// Check cloning non-elements
|
||||||
var cl = jQuery("#nonnodes").contents().clone();
|
equal( jQuery("#nonnodes").contents().clone().length, 3, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
|
||||||
ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
|
|
||||||
|
|
||||||
var div = jQuery("<div><ul><li>test</li></ul></div>").click(function(){
|
// 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." );
|
ok( true, "Bound event still exists." );
|
||||||
});
|
});
|
||||||
|
clone = div.clone(true); div.remove();
|
||||||
clone = div.clone(true);
|
div = clone.clone(true); clone.remove();
|
||||||
|
|
||||||
// manually clean up detached elements
|
|
||||||
div.remove();
|
|
||||||
|
|
||||||
div = clone.clone(true);
|
|
||||||
|
|
||||||
// manually clean up detached elements
|
|
||||||
clone.remove();
|
|
||||||
|
|
||||||
equal( div.length, 1, "One element cloned" );
|
equal( div.length, 1, "One element cloned" );
|
||||||
equal( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
equal( div[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
||||||
div.trigger("click");
|
div.trigger("click");
|
||||||
|
|
||||||
// manually clean up detached elements
|
// Manually clean up detached elements
|
||||||
div.remove();
|
div.remove();
|
||||||
|
|
||||||
|
// Verify that cloned children can keep event listeners
|
||||||
div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
|
div = jQuery("<div/>").append([ document.createElement("table"), document.createElement("table") ]);
|
||||||
div.find("table").click(function(){
|
div.find("table").click(function(){
|
||||||
ok( true, "Bound event still exists." );
|
ok( true, "Bound event still exists." );
|
||||||
@ -1323,24 +1293,25 @@ test("clone()", function() {
|
|||||||
clone = div.clone(true);
|
clone = div.clone(true);
|
||||||
equal( clone.length, 1, "One element cloned" );
|
equal( clone.length, 1, "One element cloned" );
|
||||||
equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV 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();
|
div.remove();
|
||||||
clone.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()." );
|
ok( false, "Bound event still exists after .clone()." );
|
||||||
}),
|
});
|
||||||
cloneEvt = divEvt.clone();
|
clone = div.clone();
|
||||||
|
|
||||||
// Make sure that doing .clone() doesn't clone events
|
clone.trigger("click");
|
||||||
cloneEvt.trigger("click");
|
|
||||||
|
|
||||||
cloneEvt.remove();
|
// Manually clean up detached elements
|
||||||
divEvt.remove();
|
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&hl=en'></embed>");
|
div = jQuery("<div/>").html("<embed height='355' width='425' src='http://www.youtube.com/v/3KANI2dpXLw&hl=en'></embed>");
|
||||||
|
|
||||||
clone = div.clone(true);
|
clone = div.clone(true);
|
||||||
@ -1355,18 +1326,14 @@ test("clone()", function() {
|
|||||||
|
|
||||||
clone = div.clone(true);
|
clone = div.clone(true);
|
||||||
equal( clone.length, 1, "One element cloned" );
|
equal( clone.length, 1, "One element cloned" );
|
||||||
(function checkForAttributes( $ ) {
|
equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
||||||
// IE6/7 adds some extra parameters so just test for existance of a defined set
|
div = div.find("object");
|
||||||
var parameters = ["height", "width", "classid"],
|
clone = clone.find("object");
|
||||||
$divObject = div.find("object"),
|
// oldIE adds extra attributes and <param> elements, so just test for existence of the defined set
|
||||||
$cloneObject = clone.find("object");
|
jQuery.each([ "height", "width", "classid" ], function( i, attr ) {
|
||||||
|
equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr );
|
||||||
$.each( parameters, function(index, parameter) {
|
|
||||||
equal( $cloneObject.attr(parameter), $divObject.attr(parameter), "Element attributes cloned: " + parameter );
|
|
||||||
});
|
});
|
||||||
})( jQuery );
|
(function() {
|
||||||
(function checkForParams() {
|
|
||||||
// IE6/7/8 adds a bunch of extram param elements so just test for those that are trying to clone
|
|
||||||
var params = {};
|
var params = {};
|
||||||
|
|
||||||
clone.find("param").each(function(index, param) {
|
clone.find("param").each(function(index, param) {
|
||||||
@ -1375,13 +1342,10 @@ test("clone()", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
div.find("param").each(function(index, param) {
|
div.find("param").each(function(index, param) {
|
||||||
var actualValue = params[param.attributes.name.nodeValue.toLowerCase()],
|
var key = param.attributes.name.nodeValue.toLowerCase();
|
||||||
expectedValue = param.attributes.value.nodeValue.toLowerCase();
|
equal( params[ key ], param.attributes.value.nodeValue.toLowerCase(), "<param> cloned: " + key );
|
||||||
|
|
||||||
equal( actualValue, expectedValue, "Param cloned: " + param.attributes.name.nodeValue );
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
|
|
||||||
|
|
||||||
// and here's a valid one.
|
// 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&hl=en'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='wmode' value='transparent'> </object>");
|
div = jQuery("<div/>").html("<object height='355' width='425' type='application/x-shockwave-flash' data='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='wmode' value='transparent'> </object>");
|
||||||
|
@ -259,17 +259,16 @@ if ( jQuery.fn.stop ) {
|
|||||||
expect( 3 );
|
expect( 3 );
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
var foo = jQuery({}), run = 0;
|
var done = {};
|
||||||
|
jQuery({})
|
||||||
foo
|
|
||||||
.queue( "alternate", function( next ) {
|
.queue( "alternate", function( next ) {
|
||||||
run++;
|
done.alt1 = true;
|
||||||
ok( true, "This first function was dequeued" );
|
ok( true, "This first function was dequeued" );
|
||||||
next();
|
next();
|
||||||
})
|
})
|
||||||
.delay( 1000, "alternate" )
|
.delay( 1000, "alternate" )
|
||||||
.queue( "alternate", function() {
|
.queue( "alternate", function() {
|
||||||
run++;
|
done.alt2 = true;
|
||||||
ok( true, "The function was dequeued immediately, the delay was stopped" );
|
ok( true, "The function was dequeued immediately, the delay was stopped" );
|
||||||
})
|
})
|
||||||
.dequeue( "alternate" )
|
.dequeue( "alternate" )
|
||||||
@ -278,18 +277,20 @@ if ( jQuery.fn.stop ) {
|
|||||||
.stop( "alternate", false, false )
|
.stop( "alternate", false, false )
|
||||||
|
|
||||||
// this test
|
// this test
|
||||||
.delay( 1000 )
|
.delay( 1 )
|
||||||
.queue(function() {
|
.queue(function() {
|
||||||
run++;
|
done.default1 = true;
|
||||||
ok( false, "This queue should never run" );
|
ok( false, "This queue should never run" );
|
||||||
})
|
})
|
||||||
|
|
||||||
// stop( clearQueue ) should clear the queue
|
// stop( clearQueue ) should clear the queue
|
||||||
.stop( true, false );
|
.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() {
|
asyncTest( "queue stop hooks", 2, function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user