Css: Fix tests

It's not easy to find a CSS property that is implemented even in
ancient browsers and that returns a consistent result among browsers
when passed through .css(). color didn't work since Firefox normalizes
it an empty value to rgb(0, 0, 0).

(cherry-picked from 0c12cb3910)
This commit is contained in:
Michał Gołębiowski 2014-03-10 19:53:50 +01:00
parent b5050dc489
commit 7ade83391e

View File

@ -988,16 +988,19 @@ test( "Keep the last style if the new one isn't recognized by the browser (#1483
expect( 2 ); expect( 2 );
var el; var el;
el = jQuery( "<div></div>" ).css( "color", "black" ).css( "color", "fake value" ); el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "fake value" );
equal( el.css( "color" ), "black", "The old style is kept when setting an unrecognized value" ); equal( el.css( "position" ), "absolute", "The old style is kept when setting an unrecognized value" );
el = jQuery( "<div></div>" ).css( "color", "black" ).css( "color", " " ); el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", " " );
equal( el.css( "color" ), "black", "The old style is kept when setting to a space" ); equal( el.css( "position" ), "absolute", "The old style is kept when setting to a space" );
}); });
test( "Reset the style if set to an empty string", function() { test( "Reset the style if set to an empty string", function() {
expect( 1 ); expect( 1 );
var el = jQuery( "<div></div>" ).css( "color", "black" ).css( "color", "" ); var el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "" );
equal( el.css( "color" ), "", "The style can be reset by setting to an empty string" ); // Some browsers return an empty string; others "static". Both those cases mean the style
// was reset successfully so accept them both.
equal( el.css( "position" ) || "static", "static",
"The style can be reset by setting to an empty string" );
}); });
asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() { asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() {