" ).appendTo( "#qunit-fixture" );
- $div
- .css( "--a", 3 )
- .css( "--line-height", 4 )
- .css( "--lineHeight", 5 );
+ $div
+ .css( "--a", 3 )
+ .css( "--line-height", 4 )
+ .css( "--lineHeight", 5 );
- assert.equal( $div.css( "--a" ), "3", "--a: 3" );
- assert.equal( $div.css( "--line-height" ), "4", "--line-height: 4" );
- assert.equal( $div.css( "--lineHeight" ), "5", "--lineHeight: 5" );
- } );
-} )();
-
-}
+ assert.equal( $div.css( "--a" ), "3", "--a: 3" );
+ assert.equal( $div.css( "--line-height" ), "4", "--line-height: 4" );
+ assert.equal( $div.css( "--lineHeight" ), "5", "--lineHeight: 5" );
+} );
// Support: IE 11+
-if ( document.documentMode ) {
+// This test requires Grid to be *not supported* to work.
+if ( QUnit.isIE ) {
// Make sure explicitly provided IE vendor prefix (`-ms-`) is not converted
// to a non-working `Ms` prefix in JavaScript.
QUnit.test( "IE vendor prefixes are not mangled", function( assert ) {
@@ -1836,3 +1810,5 @@ if ( document.documentMode ) {
assert.strictEqual( div.css( "-ms-grid-row" ), "1", "IE vendor prefixing" );
} );
}
+
+}
diff --git a/test/unit/data.js b/test/unit/data.js
index 07628bfd4..7e019a4ce 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -513,16 +513,14 @@ QUnit.test( ".removeData()", function( assert ) {
assert.equal( div.data( "test.foo" ), undefined, "Make sure data is intact" );
} );
-if ( window.JSON && window.JSON.stringify ) {
- QUnit.test( "JSON serialization (#8108)", function( assert ) {
- assert.expect( 1 );
+QUnit.test( "JSON serialization (#8108)", function( assert ) {
+ assert.expect( 1 );
- var obj = { "foo": "bar" };
- jQuery.data( obj, "hidden", true );
+ var obj = { "foo": "bar" };
+ jQuery.data( obj, "hidden", true );
- assert.equal( JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
- } );
-}
+ assert.equal( JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
+} );
QUnit.test( ".data should follow html5 specification regarding camel casing", function( assert ) {
assert.expect( 12 );
diff --git a/test/unit/deferred.js b/test/unit/deferred.js
index 936a57524..27a913216 100644
--- a/test/unit/deferred.js
+++ b/test/unit/deferred.js
@@ -543,25 +543,23 @@ QUnit.test( "jQuery.Deferred.then - spec compatibility", function( assert ) {
} catch ( _ ) {}
} );
-QUnit[ typeof Symbol === "function" && Symbol.toStringTag ? "test" : "skip" ](
- "jQuery.Deferred.then - IsCallable determination (gh-3596)",
+QUnit.testUnlessIE( "jQuery.Deferred.then - IsCallable determination (gh-3596)",
function( assert ) {
- assert.expect( 1 );
+ assert.expect( 1 );
- var done = assert.async(),
- defer = jQuery.Deferred();
+ var done = assert.async(),
+ defer = jQuery.Deferred();
- function faker() {
- assert.ok( true, "handler with non-'Function' @@toStringTag gets invoked" );
- }
- faker[ Symbol.toStringTag ] = "String";
-
- defer.then( faker ).then( done );
-
- defer.resolve();
+ function faker() {
+ assert.ok( true, "handler with non-'Function' @@toStringTag gets invoked" );
}
-);
+ faker[ Symbol.toStringTag ] = "String";
+
+ defer.then( faker ).then( done );
+
+ defer.resolve();
+} );
QUnit.test( "jQuery.Deferred.exceptionHook", function( assert ) {
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index fd920fb73..c0ebf19d6 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -41,29 +41,25 @@ QUnit.test( "delegate/undelegate", function( assert ) {
.remove();
} );
-if ( jQuery.fn.hover ) {
- QUnit.test( "hover() mouseenter mouseleave", function( assert ) {
- assert.expect( 1 );
+QUnit[ jQuery.fn.hover ? "test" : "skip" ]( "hover() mouseenter mouseleave", function( assert ) {
+ assert.expect( 1 );
- var times = 0,
- handler1 = function() { ++times; },
- handler2 = function() { ++times; };
+ var times = 0,
+ handler1 = function() { ++times; },
+ handler2 = function() { ++times; };
- jQuery( "#firstp" )
- .hover( handler1, handler2 )
- .mouseenter().mouseleave()
- .off( "mouseenter", handler1 )
- .off( "mouseleave", handler2 )
- .hover( handler1 )
- .mouseenter().mouseleave()
- .off( "mouseenter mouseleave", handler1 )
- .mouseenter().mouseleave();
-
- assert.equal( times, 4, "hover handlers fired" );
-
- } );
-}
+ jQuery( "#firstp" )
+ .hover( handler1, handler2 )
+ .mouseenter().mouseleave()
+ .off( "mouseenter", handler1 )
+ .off( "mouseleave", handler2 )
+ .hover( handler1 )
+ .mouseenter().mouseleave()
+ .off( "mouseenter mouseleave", handler1 )
+ .mouseenter().mouseleave();
+ assert.equal( times, 4, "hover handlers fired" );
+} );
QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( assert ) {
assert.expect( 5 );
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index 4a3ad5ecb..d20a56c3b 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -659,9 +659,9 @@ QUnit.test( "interaction with scrollbars (gh-3589)", function( assert ) {
parent = jQuery( "
" )
.css( { position: "absolute", width: "1000px", height: "1000px" } )
.appendTo( "#qunit-fixture" ),
- fraction = jQuery.support.boxSizingReliable() ?
- jQuery( "
" ).appendTo( parent ).width() % 1 :
- 0,
+
+ // Workarounds for IE kill fractional output here.
+ fraction = document.documentMode ? 0 : 0.5,
borderWidth = 1,
padding = 2,
size = 100 + fraction,
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 9f9f34514..c2e38fa86 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -221,6 +221,8 @@ supportjQuery.each( hideOptions, function( type, setup ) {
assert.expectJqData( this, $span, "olddisplay" );
} );
+ // Support: IE 11+, Edge 12 - 18+
+ // IE/Edge don't support Shadow DOM.
QUnit[ document.body.getRootNode ? "test" : "skip" ](
"Persist correct display value - " + type + " hidden, shadow child", function( assert ) {
assert.expect( 3 );
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index e5cf856ec..2ba802656 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -445,18 +445,16 @@ QUnit.test( "append HTML5 sectioning elements (Bug #6485)", function( assert ) {
assert.equal( aside.length, 1, "HTML5 elements do not collapse their children" );
} );
-if ( jQuery.css ) {
- QUnit.test( "HTML5 Elements inherit styles from style rules (Bug #10501)", function( assert ) {
+QUnit[ jQuery.fn.css ? "test" : "skip" ]( "HTML5 Elements inherit styles from style rules (Bug #10501)", function( assert ) {
- assert.expect( 1 );
+ assert.expect( 1 );
- jQuery( "#qunit-fixture" ).append( "
" );
- jQuery( "#article" ).append( "
This section should have a pink background." );
+ jQuery( "#qunit-fixture" ).append( "
" );
+ jQuery( "#article" ).append( "
This section should have a pink background." );
- // In IE, the missing background color will claim its value is "transparent"
- assert.notEqual( jQuery( "section" ).css( "background-color" ), "transparent", "HTML5 elements inherit styles" );
- } );
-}
+ // In IE, the missing background color will claim its value is "transparent"
+ assert.notEqual( jQuery( "section" ).css( "background-color" ), "transparent", "HTML5 elements inherit styles" );
+} );
QUnit.test( "html(String) with HTML5 (Bug #6485)", function( assert ) {
@@ -1767,9 +1765,9 @@ QUnit.test( "html(Function)", function( assert ) {
QUnit[
// Support: Edge 16 - 18+
// Edge sometimes doesn't execute module scripts so skip the test there.
- ( QUnit.moduleTypeSupported && !/edge\//i.test( navigator.userAgent ) ) ?
- "test" :
- "skip"
+ ( QUnit.isIE || /edge\//i.test( navigator.userAgent ) ) ?
+ "skip" :
+ "test"
]( "html(script type module)", function( assert ) {
assert.expect( 4 );
var done = assert.async(),
@@ -1794,18 +1792,17 @@ QUnit[
QUnit.test( "html(script nomodule)", function( assert ) {
- // Support: IE 9 - 11+
// `nomodule` scripts should be executed by legacy browsers only.
- assert.expect( QUnit.moduleTypeSupported ? 0 : 4 );
+ assert.expect( QUnit.isIE ? 4 : 0 );
var done = assert.async(),
$fixture = jQuery( "#qunit-fixture" );
$fixture.html(
[
- "",
+ "",
"",
"
",
- "",
+ "",
"",
"
"
].join( "" )
diff --git a/test/unit/queue.js b/test/unit/queue.js
index 6c8ad762d..df7eaf4ca 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -271,64 +271,61 @@ QUnit.test( ".promise(obj)", function( assert ) {
assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" );
} );
-if ( jQuery.fn.stop ) {
- QUnit.test( "delay() can be stopped", function( assert ) {
- var done = assert.async();
- assert.expect( 3 );
- var storage = {};
- jQuery( {} )
- .queue( "alternate", function( next ) {
- storage.alt1 = true;
- assert.ok( true, "This first function was dequeued" );
- next();
- } )
- .delay( 1000, "alternate" )
- .queue( "alternate", function() {
- storage.alt2 = true;
- assert.ok( true, "The function was dequeued immediately, the delay was stopped" );
- } )
- .dequeue( "alternate" )
+QUnit[ jQuery.fn.stop ? "test" : "skip" ]( "delay() can be stopped", function( assert ) {
+ var done = assert.async();
+ assert.expect( 3 );
+ var storage = {};
+ jQuery( {} )
+ .queue( "alternate", function( next ) {
+ storage.alt1 = true;
+ assert.ok( true, "This first function was dequeued" );
+ next();
+ } )
+ .delay( 1000, "alternate" )
+ .queue( "alternate", function() {
+ storage.alt2 = true;
+ assert.ok( true, "The function was dequeued immediately, the delay was stopped" );
+ } )
+ .dequeue( "alternate" )
- // stop( "alternate", false ) will NOT clear the queue, so it should automatically dequeue the next
- .stop( "alternate", false, false )
+ // stop( "alternate", false ) will NOT clear the queue, so it should automatically dequeue the next
+ .stop( "alternate", false, false )
- // this test
- .delay( 1 )
- .queue( function() {
- storage.default1 = true;
- assert.ok( false, "This queue should never run" );
- } )
+ // this test
+ .delay( 1 )
+ .queue( function() {
+ storage.default1 = true;
+ assert.ok( false, "This queue should never run" );
+ } )
- // stop( clearQueue ) should clear the queue
- .stop( true, false );
+ // stop( clearQueue ) should clear the queue
+ .stop( true, false );
- assert.deepEqual( storage, { alt1: true, alt2: true }, "Queue ran the proper functions" );
+ assert.deepEqual( storage, { alt1: true, alt2: true }, "Queue ran the proper functions" );
- setTimeout( function() {
+ setTimeout( function() {
+ done();
+ }, 1500 );
+} );
+
+QUnit[ jQuery.fn.stop ? "test" : "skip" ]( "queue stop hooks", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
+ var foo = jQuery( "#foo" );
+
+ foo.queue( function( next, hooks ) {
+ hooks.stop = function( gotoEnd ) {
+ assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" );
+ };
+ } );
+ foo.stop();
+
+ foo.queue( function( next, hooks ) {
+ hooks.stop = function( gotoEnd ) {
+ assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
done();
- }, 1500 );
+ };
} );
- QUnit.test( "queue stop hooks", function( assert ) {
- assert.expect( 2 );
- var done = assert.async();
- var foo = jQuery( "#foo" );
-
- foo.queue( function( next, hooks ) {
- hooks.stop = function( gotoEnd ) {
- assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" );
- };
- } );
- foo.stop();
-
- foo.queue( function( next, hooks ) {
- hooks.stop = function( gotoEnd ) {
- assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
- done();
- };
- } );
-
- foo.stop( false, true );
- } );
-
-} // if ( jQuery.fn.stop )
+ foo.stop( false, true );
+} );
diff --git a/test/unit/support.js b/test/unit/support.js
index e81e60c5d..266b02dd8 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -58,48 +58,12 @@ testIframe(
var expected,
userAgent = window.navigator.userAgent,
expectedMap = {
- edge: {
- boxSizingReliable: true,
- clearCloneStyle: true,
- noCloneChecked: true,
- optSelected: true,
- radioValue: true
- },
- ie_11: {
- boxSizingReliable: false,
- clearCloneStyle: false,
- noCloneChecked: false,
- optSelected: false,
- radioValue: false
- },
- chrome: {
- boxSizingReliable: true,
- clearCloneStyle: true,
- noCloneChecked: true,
- optSelected: true,
- radioValue: true
- },
- safari: {
- boxSizingReliable: true,
- clearCloneStyle: true,
- noCloneChecked: true,
- optSelected: true,
- radioValue: true
- },
- firefox: {
- boxSizingReliable: true,
- clearCloneStyle: true,
- noCloneChecked: true,
- optSelected: true,
- radioValue: true
- },
- ios: {
- boxSizingReliable: true,
- clearCloneStyle: true,
- noCloneChecked: true,
- optSelected: true,
- radioValue: true
- }
+ edge: {},
+ ie_11: {},
+ chrome: {},
+ safari: {},
+ firefox: {},
+ ios: {}
};
if ( /edge\//i.test( userAgent ) ) {
@@ -140,8 +104,8 @@ testIframe(
}
} );
- QUnit.test( "Verify most support tests are failing in one " +
- "of tested browsers", function( assert ) {
+ QUnit.test( "Verify support tests are failing in one of tested browsers",
+ function( assert ) {
var prop, browserKey, supportTestName,
i = 0,
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index e8d23536e..57273dece 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -773,7 +773,7 @@ QUnit.test( "contents() for
", function( assert ) {
assert.equal( contents.filter( "div" ).length, 3, "Count cloned elements from template" );
} );
-QUnit[ "content" in document.createElement( "template" ) ? "test" : "skip" ]( "contents() for
remains inert", function( assert ) {
+QUnit.testUnlessIE( "contents() for
remains inert", function( assert ) {
assert.expect( 2 );
Globals.register( "testScript" );