Showing with 253 additions and 283 deletions.
  1. +3 −1 src/effects.js
  2. +3 −6 test/unit/ajax.js
  3. +99 −93 test/unit/effects.js
  4. +138 −174 test/unit/manipulation.js
  5. +10 −9 test/unit/queue.js
@@ -81,7 +81,9 @@ function Animation( elem, properties, options ) {
tick = function() {
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
percent = 1 - ( remaining / animation.duration || 0 ),
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
temp = remaining / animation.duration || 0,
percent = 1 - temp,
index = 0,
length = animation.tweens.length;

@@ -1481,9 +1481,7 @@
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();
});
});

@@ -2221,7 +2219,7 @@
test( "jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() {
var passed = 0;

expect( 1 );
expect( 2 );

stop();

@@ -2230,9 +2228,8 @@
});

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();
}
@@ -603,28 +603,37 @@ test("stop()", function() {
});

test("stop() - several in queue", function() {
expect(3);
stop();
expect( 5 );

var $foo = jQuery("#foo");
var w = 0;
$foo.hide( 1000 ).css( "width", 200 ).css("width");
var nw, time,
$foo = jQuery( "#foo" ),
w = 0;

$foo.animate({ "width": "show" }, 1500);
$foo.animate({ "width": "hide" }, 1000);
$foo.animate({ "width": "show" }, 1000);
setTimeout(function(){
equal( $foo.queue().length, 3, "All 3 still in the queue" );
var nw = $foo.css("width");
notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px");
$foo.stop();
// default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms
$foo.hide().css( "width", 800 );

nw = $foo.css("width");
notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px");
$foo.animate({ "width": "show" }, 400, "linear");
$foo.animate({ "width": "hide" });
$foo.animate({ "width": "show" });

$foo.stop(true);
start();
}, 200);
// could be replaced by something nicer using sinon.
time = jQuery.now();
while( time === jQuery.now() ) {}

jQuery.fx.tick();
equal( $foo.queue().length, 3, "3 in the queue" );

nw = $foo.css( "width" );
notEqual( parseFloat( nw ), 1, "An animation occurred " + nw );
$foo.stop();

equal( $foo.queue().length, 2, "2 in the queue" );
nw = $foo.css( "width" );
notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw );

$foo.stop( true );

equal( $foo.queue().length, 0, "0 in the queue" );
});

test("stop(clearQueue)", function() {
@@ -686,14 +695,13 @@ test("stop(clearQueue, gotoEnd)", function() {

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");
@@ -706,7 +714,7 @@ asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
},{
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" );

@@ -736,16 +744,6 @@ test("toggle()", function() {
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",
@@ -800,29 +798,31 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
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({
@@ -1117,57 +1117,63 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
});
});

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 );
});
});

@@ -1310,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" );
div.stop().remove();
start();
}, 1000);
}, 500);
});

test("callbacks should fire in correct order (#9100)", function() {
@@ -1654,7 +1660,7 @@ asyncTest( "multiple unqueued and promise", 4, function() {
}).animate({
top: 100
}, {
duration: 1500,
duration: 1000,
queue: false,
complete: function() {
strictEqual( step++, 3, "Step 3" );