Tests: Skip CSS custom properties tests in non-supporting browsers

Ref 619bf98d5b
This commit is contained in:
Michał Gołębiowski 2017-03-07 16:13:26 +01:00
parent 619bf98d5b
commit bcec54ee72

View File

@ -1556,8 +1556,14 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
} )(); } )();
( function() {
var supportsCssVars,
div = jQuery( "<div>" ).appendTo( "#qunit-fixture" )[ 0 ];
QUnit.test( "css(--customProperty)", function( assert ) { div.style.setProperty( "--prop", "value" );
supportsCssVars = getComputedStyle( div ).getPropertyValue( "--prop" );
QUnit[ supportsCssVars ? "test" : "skip" ]( "css(--customProperty)", function( assert ) {
jQuery( "#qunit-fixture" ).append( jQuery( "#qunit-fixture" ).append(
"<style>\n" + "<style>\n" +
" .test__customProperties {\n" + " .test__customProperties {\n" +
@ -1571,12 +1577,14 @@ QUnit.test( "css(--customProperty)", function( assert ) {
); );
var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ), var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ),
$elem = jQuery( "<div>" ).addClass( "test__customProperties" ).appendTo( "#qunit-fixture" ), $elem = jQuery( "<div>" ).addClass( "test__customProperties" )
.appendTo( "#qunit-fixture" ),
webkit = /\bsafari\b/i.test( navigator.userAgent ) && webkit = /\bsafari\b/i.test( navigator.userAgent ) &&
!/\firefox\b/i.test( navigator.userAgent ) && !/\firefox\b/i.test( navigator.userAgent ) &&
!/\edge\b/i.test( navigator.userAgent ), !/\edge\b/i.test( navigator.userAgent ),
oldSafari = webkit && ( /\b9\.\d(\.\d+)* safari/i.test( navigator.userAgent ) || oldSafari = webkit && ( /\b9\.\d(\.\d+)* safari/i.test( navigator.userAgent ) ||
/\b10\.0(\.\d+)* safari/i.test( navigator.userAgent ) ), /\b10\.0(\.\d+)* safari/i.test( navigator.userAgent ) ||
/iphone os (?:9|10)_/i.test( navigator.userAgent ) ),
expected = 10; expected = 10;
if ( webkit ) { if ( webkit ) {
@ -1597,10 +1605,12 @@ QUnit.test( "css(--customProperty)", function( assert ) {
assert.equal( div.css( "--color" ), "red", "Modified CSS custom property using object" ); assert.equal( div.css( "--color" ), "red", "Modified CSS custom property using object" );
div.css( { "--mixedCase": "green" } ); div.css( { "--mixedCase": "green" } );
assert.equal( div.css( "--mixedCase" ), "green", "Modified CSS custom property with mixed case" ); assert.equal( div.css( "--mixedCase" ), "green",
"Modified CSS custom property with mixed case" );
div.css( { "--theme-dark": "purple" } ); div.css( { "--theme-dark": "purple" } );
assert.equal( div.css( "--theme-dark" ), "purple", "Modified CSS custom property with dashed name" ); assert.equal( div.css( "--theme-dark" ), "purple",
"Modified CSS custom property with dashed name" );
assert.equal( $elem.css( "--prop1" ), "val1", "Basic CSS custom property" ); assert.equal( $elem.css( "--prop1" ), "val1", "Basic CSS custom property" );
@ -1618,6 +1628,7 @@ QUnit.test( "css(--customProperty)", function( assert ) {
assert.equal( $elem.css( "--prop4" ), "\"val4\"", "Works with double quotes" ); assert.equal( $elem.css( "--prop4" ), "\"val4\"", "Works with double quotes" );
assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" ); assert.equal( $elem.css( "--prop5" ), "'val5'", "Works with single quotes" );
} }
} ); } );
} )();
} }