From 9dc29a2b130e6bbcdbcaf8fdc1433a41e6b7a585 Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Mon, 16 Jun 2014 02:59:41 +0400 Subject: Effects: Improve raf logic * Make animation behave as if jQuery.fx.off = true if document is hidden * Use cancelAnimationFrame in jQuery.fx.stop Ref 708764f47b0c8de152bbb444d0f608db558b76ed --- test/unit/effects.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test') diff --git a/test/unit/effects.js b/test/unit/effects.js index 30d58ccd3..8e1f914cf 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -2239,4 +2239,32 @@ test( "Respect display value on inline elements (#14824)", 2, function() { clock.tick( 800 ); }); +test( "Animation should go to its end state if document.hidden = true", 1, function() { + var height; + if ( Object.defineProperty ) { + + // Can't rewrite document.hidden property if its host property + try { + Object.defineProperty( document, "hidden", { + get: function() { + return true; + } + }); + } catch ( e ) {} + } else { + document.hidden = true; + } + + if ( document.hidden ) { + height = jQuery( "#qunit-fixture" ).animate({ height: 500 } ).height(); + + equal( height, 500, "Animation should happen immediately if document.hidden = true" ); + jQuery( document ).removeProp( "hidden" ); + + } else { + ok( true, "Can't run the test since we can't reproduce correct environment for it" ); + } +}); + + })(); -- cgit v1.2.3