From e3c89685095cfabdd1060b5d9cb57a62f60b7f2f Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Tue, 22 Dec 2015 13:03:11 -0500 Subject: Revert "Misc: Drop support for older browsers; update support comments" This reverts commit 90d7cc1d8b2ea7ac75f0eacb42439349c9c73278. --- test/data/css/cssWidthBeforeDocReady.html | 1 + test/data/dimensions/documentSmall.html | 10 + test/data/testsuite.css | 12 +- test/unit/ajax.js | 18 +- test/unit/attributes.js | 17 +- test/unit/core.js | 2 +- test/unit/css.js | 37 +-- test/unit/effects.js | 356 +++++++++++++++------------ test/unit/event.js | 47 +++- test/unit/manipulation.js | 20 +- test/unit/offset.js | 83 ++++--- test/unit/selector.js | 6 +- test/unit/support.js | 396 +++++++++++++++++++++++++++--- 13 files changed, 720 insertions(+), 285 deletions(-) (limited to 'test') diff --git a/test/data/css/cssWidthBeforeDocReady.html b/test/data/css/cssWidthBeforeDocReady.html index c45b6811a..3bdd1b5ab 100644 --- a/test/data/css/cssWidthBeforeDocReady.html +++ b/test/data/css/cssWidthBeforeDocReady.html @@ -5,6 +5,7 @@
diff --git a/test/data/testsuite.css b/test/data/testsuite.css index de5f3fb00..d9909ddcc 100644 --- a/test/data/testsuite.css +++ b/test/data/testsuite.css @@ -1,7 +1,7 @@ /* for testing opacity set in styles in IE */ ol#empty { opacity: 0; - -ms-filter: "Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff')"; + filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); } div#fx-tests h4 { @@ -47,7 +47,7 @@ div.largeheight { } div.largeopacity { - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=100)"; + filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100); } div.medwidth { @@ -60,7 +60,7 @@ div.medheight { div.medopacity { opacity: 0.5; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=50)"; + filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50); } div.nowidth { @@ -73,7 +73,7 @@ div.noheight { div.noopacity { opacity: 0; - -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(opacity=0)"; + filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); } div.hidden { @@ -143,8 +143,8 @@ dfn { display: none; } /* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */ body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; } -/* #6652 Remove -ms-filter: "alpha(opacity=100)" after animation */ -#t6652 div { -ms-filter: "alpha(opacity=50)"; } +/* #6652 REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION */ +#t6652 div { filter: alpha(opacity=50); } /* #10501 */ section { background:#f0f; display:block; } diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 11cb902d2..9abc5e613 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1,8 +1,8 @@ -var isIE8 = /msie 8\.0/i.test( window.navigator.userAgent ); +var isoldIE = /msie [876]\.0/i.test( window.navigator.userAgent ); QUnit.module( "ajax", { setup: function() { - if ( !isIE8 ) { + if ( !isoldIE ) { return; } @@ -52,7 +52,7 @@ QUnit.module( "ajax", { ); ajaxTest( "jQuery.ajax() - success callbacks", 8, function( assert ) { - return { + return { setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess", assert ), url: url( "data/name.html" ), beforeSend: function() { @@ -820,7 +820,7 @@ QUnit.module( "ajax", { "jsonpCallback option is set back to default in callbacks" ); - if ( isIE8 ) { + if ( isoldIE ) { assert.ok( true, "IE8 can't remove property from the window" ); } else { @@ -1417,8 +1417,8 @@ QUnit.module( "ajax", { }; } ); - test( "#11743 - jQuery.ajax() - script, throws exception", 1, function() { - throws( function() { + QUnit.test( "#11743 - jQuery.ajax() - script, throws exception", 1, function(assert) { + assert.throws( function() { jQuery.ajax( { url: "data/badjson.js", dataType: "script", @@ -1430,10 +1430,10 @@ QUnit.module( "ajax", { // Global events get confused by the exception global: false, success: function() { - ok( false, "Success." ); + assert.ok( false, "Success." ); }, error: function() { - ok( false, "Error." ); + assert.ok( false, "Error." ); } } ); }, "exception bubbled" ); @@ -1656,7 +1656,7 @@ QUnit.module( "ajax", { url: url( "data/ajax/content-type.php" ), data: { "content-type": "test/jsontest", - "response": JSON.stringify( { test: "test" } ) + "response": "{ \"test\": \"test\" }" }, success: function( result ) { assert.strictEqual( diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 9f8502d5d..be905cfd6 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -46,7 +46,11 @@ QUnit.test( "jQuery.propFix integrity test", function( assert ) { "contenteditable": "contentEditable" }; - assert.deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" ); + if ( !jQuery.support.enctype ) { + props.enctype = "encoding"; + } + + deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" ); } ); QUnit.test( "attr(String)", function( assert ) { @@ -588,11 +592,12 @@ QUnit.test( "removeAttr(String)", function( assert ) { assert.ok( false, "Removing contenteditable threw an error (#10429)" ); } - $first = jQuery( "
" ); - assert.equal( $first.attr( "Case" ), "mixed", "case of attribute doesn't matter" ); - $first.removeAttr( "Case" ); - assert.equal( $first.attr( "Case" ), undefined, "mixed-case attribute was removed" ); -} ); + $first = jQuery("
"); + equal( $first.attr("Case"), "mixed", "case of attribute doesn't matter" ); + $first.removeAttr("Case"); + // IE 6/7 return empty string here, not undefined + ok( !$first.attr("Case"), "mixed-case attribute was removed" ); +}); QUnit.test( "removeAttr(String) in XML", function( assert ) { assert.expect( 7 ); diff --git a/test/unit/core.js b/test/unit/core.js index 9714b8685..81fbd4e54 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1541,7 +1541,7 @@ QUnit.test("jQuery.parseHTML", function( assert ) { assert.equal( jQuery.parseHTML( "" )[ 1 ].parentNode.nodeType, 11, "parentNode should be documentFragment" ); } ); -if ( jQuery.support.createHTMLDocument ) { +if ( jQuery.support.createHTMLDocument && !/opera.*version\/12\.1/i.test( navigator.userAgent ) ) { QUnit.asyncTest( "jQuery.parseHTML", function( assert ) { assert.expect( 1 ); diff --git a/test/unit/css.js b/test/unit/css.js index df4b800f0..adfc46cb8 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -209,7 +209,7 @@ QUnit.test( "css() explicit and relative values", function( assert ) { } ); QUnit.test( "css() non-px relative values (gh-1711)", function( assert ) { - assert.expect( 17 ); + assert.expect( 16 ); var cssCurrent, units = {}, @@ -271,7 +271,10 @@ QUnit.test( "css() non-px relative values (gh-1711)", function( assert ) { add( "lineHeight", 30, "pc" ); add( "lineHeight", 1, "cm" ); add( "lineHeight", -20, "mm" ); - add( "lineHeight", 50, "%" ); + + // Opera 12 does something funky for this one + // Just disabling for 1.12 + // add( "lineHeight", 50, "%" ); } ); QUnit.test( "css(String, Object)", function( assert ) { @@ -530,7 +533,7 @@ QUnit.test( "show();", function( assert ) { assert.expect( 18 ); - var hiddendiv, div, pass, test; + var hiddendiv, div, pass, old, test; hiddendiv = jQuery( "div.hidden" ); assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); @@ -553,7 +556,9 @@ QUnit.test( "show();", function( assert ) { assert.ok( pass, "Show" ); // #show-tests * is set display: none in CSS - jQuery( "#qunit-fixture" ).append( "

" ); + jQuery( "#qunit-fixture" ).append( "

" ); + old = jQuery( "#test-table" ).show().css( "display" ) !== "table"; + jQuery( "#test-table" ).remove(); test = { "div": "block", @@ -562,14 +567,14 @@ QUnit.test( "show();", function( assert ) { "code": "inline", "pre": "block", "span": "inline", - "table": "table", - "thead": "table-header-group", - "tbody": "table-row-group", - "tr": "table-row", - "th": "table-cell", - "td": "table-cell", + "table": old ? "block" : "table", + "thead": old ? "block" : "table-header-group", + "tbody": old ? "block" : "table-row-group", + "tr": old ? "block" : "table-row", + "th": old ? "block" : "table-cell", + "td": old ? "block" : "table-cell", "ul": "block", - "li": "list-item" + "li": old ? "block" : "list-item" }; jQuery.each( test, function( selector, expected ) { @@ -1021,13 +1026,13 @@ QUnit.test( "css opacity consistency across browsers (#12685)", function( assert fixture = jQuery( "#qunit-fixture" ); // Append style element - jQuery( "" ).appendTo( fixture ); + jQuery( "" ).appendTo( fixture ); el = jQuery( "
" ).appendTo( fixture ); - assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (-ms-filter:alpha with spaces)" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (filter:alpha with spaces)" ); el.removeClass( "opacityWithSpaces_t12685" ).addClass( "opacityNoSpaces_t12685" ); - assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (-ms-filter:alpha without spaces)" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (filter:alpha without spaces)" ); el.css( "opacity", 0.3 ); assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" ); el.css( "opacity", "" ); @@ -1275,7 +1280,7 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function( } } ); -QUnit.test( "get upper case alpha opacity in IE8", function( assert ) { +QUnit[/msie 8\.0/.test(navigator.userAgent) ? "test" : "skip"]( "get upper case alpha opacity in IE8", function( assert ) { assert.expect( 1 ); var div = document.createElement( "div" ), @@ -1295,7 +1300,7 @@ QUnit.test( "get upper case alpha opacity in IE8", function( assert ) { function resetCssPropsFor( name ) { delete jQuery.cssProps[ name ]; jQuery.each( vendorPrefixes, function( index, prefix ) { - delete jQuery.cssProps[ prefix + name[ 0 ].toUpperCase() + name.slice( 1 ) ]; + delete jQuery.cssProps[ prefix + name.charAt( 0 ).toUpperCase() + name.slice( 1 ) ]; } ); } diff --git a/test/unit/effects.js b/test/unit/effects.js index 78dbe9dca..c1d67b651 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -24,7 +24,7 @@ QUnit.test( "sanity check", function( assert ) { assert.equal( jQuery( "#dl:visible, #qunit-fixture:visible, #foo:visible" ).length, 3, "QUnit state is correct for testing effects" ); } ); -test( "show() basic", 2, function() { +QUnit.test( "show() basic", 2, function() { var div, hiddendiv = jQuery( "div.hidden" ); @@ -42,8 +42,8 @@ test( "show() basic", 2, function() { QUnit.expectJqData( this, hiddendiv, "olddisplay" ); } ); -test( "show()", 27, function() { - var div, speeds, test, +QUnit.test( "show()", 27, function() { + var div, speeds, test, old, displaysActual, displaysExpected, hiddendiv = jQuery( "div.hidden" ); @@ -93,7 +93,11 @@ test( "show()", 27, function() { QUnit.expectJqData( this, div, "olddisplay" ); // #show-tests * is set display: none in CSS - jQuery( "#qunit-fixture" ).append( "

" ); + jQuery( "#qunit-fixture" ) + .append( "

" ); + + old = jQuery( "#test-table" ).show().css( "display" ) !== "table"; + jQuery( "#test-table" ).remove(); test = { "div": "block", @@ -102,14 +106,14 @@ test( "show()", 27, function() { "code": "inline", "pre": "block", "span": "inline", - "table": "table", - "thead": "table-header-group", - "tbody": "table-row-group", - "tr": "table-row", - "th": "table-cell", - "td": "table-cell", + "table": old ? "block" : "table", + "thead": old ? "block" : "table-header-group", + "tbody": old ? "block" : "table-row-group", + "tr": old ? "block" : "table-row", + "th": old ? "block" : "table-cell", + "td": old ? "block" : "table-cell", "ul": "block", - "li": "list-item" + "li": old ? "block" : "list-item" }; jQuery.each( test, function( selector, expected ) { @@ -124,31 +128,35 @@ test( "show()", 27, function() { jQuery( "
test
text test" ).hide().remove(); } ); -test( "show(Number) - other displays", function() { +QUnit.test( "show(Number) - other displays", function() { expect( 15 ); // #show-tests * is set display: none in CSS - jQuery( "#qunit-fixture" ).append( "

" ); + jQuery( "#qunit-fixture" ).append( "

" ); + + var test, + old = jQuery("#test-table").show().css("display") !== "table"; + jQuery("#test-table").remove(); // Note: inline elements are expected to be inline-block // because we're showing width/height // Can't animate width/height inline // See #14344 - var test = { + test = { "div": "block", "p": "block", "a": "inline-block", "code": "inline-block", "pre": "block", "span": "inline-block", - "table": "table", - "thead": "table-header-group", - "tbody": "table-row-group", - "tr": "table-row", - "th": "table-cell", - "td": "table-cell", + "table": old ? "block" : "table", + "thead": old ? "block" : "table-header-group", + "tbody": old ? "block" : "table-row-group", + "tr": old ? "block" : "table-row", + "th": old ? "block" : "table-cell", + "td": old ? "block" : "table-cell", "ul": "block", - "li": "list-item" + "li": old ? "block" : "list-item" }; jQuery.each( test, function( selector, expected ) { @@ -162,7 +170,7 @@ test( "show(Number) - other displays", function() { } ); // Supports #7397 -test( "Persist correct display value", function() { +QUnit.test( "Persist correct display value", function() { expect( 3 ); // #show-tests * is set display: none in CSS @@ -194,7 +202,7 @@ test( "Persist correct display value", function() { QUnit.expectJqData( this, $span, "olddisplay" ); } ); -test( "animate(Hash, Object, Function)", function() { +QUnit.test( "animate(Hash, Object, Function)", function() { expect( 1 ); var hash = { opacity: "show" }, hashCopy = jQuery.extend( {}, hash ); @@ -203,7 +211,7 @@ test( "animate(Hash, Object, Function)", function() { } ); } ); -test( "animate relative values", function() { +QUnit.test( "animate relative values", function() { var value = 40, clock = this.clock, @@ -242,7 +250,7 @@ test( "animate relative values", function() { } ); } ); -test( "animate negative height", function() { +QUnit.test( "animate negative height", function() { expect( 1 ); jQuery( "#foo" ).animate( { height: -100 }, 100, function() { equal( this.offsetHeight, 0, "Verify height." ); @@ -250,7 +258,7 @@ test( "animate negative height", function() { this.clock.tick( 100 ); } ); -test( "animate negative margin", function() { +QUnit.test( "animate negative margin", function() { expect( 1 ); jQuery( "#foo" ).animate( { "marginTop": -100 }, 100, function() { equal( jQuery( this ).css( "marginTop" ), "-100px", "Verify margin." ); @@ -258,7 +266,7 @@ test( "animate negative margin", function() { this.clock.tick( 100 ); } ); -test( "animate negative margin with px", function() { +QUnit.test( "animate negative margin with px", function() { expect( 1 ); jQuery( "#foo" ).animate( { marginTop: "-100px" }, 100, function() { equal( jQuery( this ).css( "marginTop" ), "-100px", "Verify margin." ); @@ -266,7 +274,7 @@ test( "animate negative margin with px", function() { this.clock.tick( 100 ); } ); -test( "animate negative padding", function() { +QUnit.test( "animate negative padding", function() { expect( 1 ); jQuery( "#foo" ).animate( { "paddingBottom": -100 }, 100, function() { equal( jQuery( this ).css( "paddingBottom" ), "0px", "Verify paddingBottom." ); @@ -274,42 +282,59 @@ test( "animate negative padding", function() { this.clock.tick( 100 ); } ); -test( "animate block as inline width/height", function() { +QUnit.test( "animate block as inline width/height", function() { expect( 3 ); - var span = jQuery( "" ).css( "display", "inline-block" ).appendTo( "body" ); + var span = jQuery("").css("display", "inline-block").appendTo("body"), + expected = span.css("display"); span.remove(); - jQuery( "#foo" ).css( { display: "inline", width: "", height: "" } ).animate( { width: 42, height: 42 }, 100, function() { - equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); - equal( this.offsetWidth, 42, "width was animated" ); - equal( this.offsetHeight, 42, "height was animated" ); - } ); + if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) { + + jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() { + equal( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); + equal( this.offsetWidth, 42, "width was animated" ); + equal( this.offsetHeight, 42, "height was animated" ); + }); + // Browser doesn't support inline-block + } else { + ok( true, "Browser doesn't support inline-block" ); + ok( true, "Browser doesn't support inline-block" ); + ok( true, "Browser doesn't support inline-block" ); + } this.clock.tick( 100 ); } ); -test( "animate native inline width/height", function() { +QUnit.test( "animate native inline width/height", function() { expect( 3 ); - var span = jQuery( "" ).css( "display", "inline-block" ).appendTo( "body" ); + var span = jQuery("").css("display", "inline-block").appendTo("body"), + expected = span.css("display"); span.remove(); - jQuery( "#foo" ).css( { display: "", width: "", height: "" } ) - .append( "text" ) - .children( "span" ) - .animate( { width: 42, height: 42 }, 100, function() { - equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); - equal( this.offsetWidth, 42, "width was animated" ); - equal( this.offsetHeight, 42, "height was animated" ); - } ); - + if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) { + jQuery("#foo").css({ display: "", width: "", height: "" }) + .append("text") + .children("span") + .animate({ width: 42, height: 42 }, 100, function() { + equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); + equal( this.offsetWidth, 42, "width was animated" ); + equal( this.offsetHeight, 42, "height was animated" ); + }); + + // Browser doesn't support inline-block + } else { + ok( true, "Browser doesn't support inline-block" ); + ok( true, "Browser doesn't support inline-block" ); + ok( true, "Browser doesn't support inline-block" ); + } this.clock.tick( 100 ); } ); -test( "animate block width/height", function() { +QUnit.test( "animate block width/height", function() { expect( 3 ); jQuery( "
" ).appendTo( "#qunit-fixture" ).css( { @@ -336,47 +361,56 @@ test( "animate block width/height", function() { this.clock.tick( 100 ); } ); -test( "animate table width/height", function() { +QUnit.test("animate table width/height", function() { expect( 1 ); + var displayMode = jQuery( "#table" ).css( "display" ) !== "table" ? "block" : "table"; + jQuery( "#table" ).animate( { width: 42, height: 42 }, 100, function() { - equal( jQuery( this ).css( "display" ), "table", "display mode is correct" ); + equal( jQuery( this ).css( "display" ), displayMode, "display mode is correct" ); } ); this.clock.tick( 100 ); } ); -test( "animate table-row width/height", function() { +QUnit.test("animate table-row width/height", function() { expect( 3 ); - var tr = jQuery( "#table" ) + var displayMode, + tr = jQuery( "#table" ) .attr( { "cellspacing": 0, "cellpadding": 0, "border": 0 } ) .html( "
" ) .find( "tr" ); + // IE<8 uses "block" instead of the correct display type + displayMode = tr.css( "display" ) !== "table-row" ? "block" : "table-row"; + tr.animate( { width: 10, height: 10 }, 100, function() { - equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" ); + equal( jQuery( this ).css( "display" ), displayMode, "display mode is correct" ); equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); } ); this.clock.tick( 100 ); } ); -test( "animate table-cell width/height", function() { +QUnit.test( "animate table-cell width/height", function() { expect( 3 ); - - var td = jQuery( "#table" ) - .attr( { "cellspacing": 0, "cellpadding": 0, "border": 0 } ) + var displayMode, + td = jQuery( "#table" ) + .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) .html( "
" ) .find( "td" ); + // IE<8 uses "block" instead of the correct display type + displayMode = td.css( "display" ) !== "table-cell" ? "block" : "table-cell"; + td.animate( { width: 10, height: 10 }, 100, function() { - equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" ); + equal( jQuery( this ).css( "display" ), displayMode, "display mode is correct" ); equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); } ); this.clock.tick( 100 ); } ); -test( "animate percentage(%) on width/height", function() { +QUnit.test( "animate percentage(%) on width/height", function() { expect( 2 ); var $div = jQuery( "
" ) @@ -390,7 +424,7 @@ test( "animate percentage(%) on width/height", function() { this.clock.tick( 20 ); } ); -test( "animate resets overflow-x and overflow-y when finished", function() { +QUnit.test( "animate resets overflow-x and overflow-y when finished", function() { expect( 2 ); jQuery( "#foo" ) .css( { display: "block", width: 20, height: 20, overflowX: "visible", overflowY: "auto" } ) @@ -402,7 +436,7 @@ test( "animate resets overflow-x and overflow-y when finished", function() { } ); /* // This test ends up being flaky depending upon the CPU load -test("animate option (queue === false)", function () { +QUnit.test("animate option (queue === false)", function () { expect(1); stop(); @@ -422,7 +456,7 @@ test("animate option (queue === false)", function () { }); */ -test( "animate option { queue: false }", function() { +QUnit.test( "animate option { queue: false }", function() { expect( 2 ); var foo = jQuery( "#foo" ); @@ -440,7 +474,7 @@ test( "animate option { queue: false }", function() { equal( foo.queue().length, 0, "Queue is empty" ); } ); -test( "animate option { queue: true }", function() { +QUnit.test( "animate option { queue: true }", function() { expect( 2 ); var foo = jQuery( "#foo" ); @@ -460,7 +494,7 @@ test( "animate option { queue: true }", function() { this.clock.tick( 10 ); } ); -test( "animate option { queue: 'name' }", function() { +QUnit.test( "animate option { queue: 'name' }", function() { expect( 5 ); var foo = jQuery( "#foo" ), origWidth = parseFloat( foo.css( "width" ) ), @@ -492,7 +526,7 @@ test( "animate option { queue: 'name' }", function() { } ); -test( "animate with no properties", function() { +QUnit.test( "animate with no properties", function() { expect( 2 ); var foo, @@ -514,7 +548,7 @@ test( "animate with no properties", function() { this.clock.tick( 100 ); } ); -test( "animate duration 0", function() { +QUnit.test( "animate duration 0", function() { expect( 11 ); var $elem, @@ -564,7 +598,7 @@ test( "animate duration 0", function() { $elem.remove(); } ); -test( "animate hyphenated properties", function() { +QUnit.test( "animate hyphenated properties", function() { expect( 1 ); jQuery( "#foo" ) @@ -578,7 +612,7 @@ test( "animate hyphenated properties", function() { } ); -test( "animate non-element", function() { +QUnit.test( "animate non-element", function() { expect( 1 ); var obj = { test: 0 }; @@ -589,7 +623,7 @@ test( "animate non-element", function() { this.clock.tick( 200 ); } ); -test( "stop()", function() { +QUnit.test( "stop()", function() { expect( 4 ); var $one, $two, @@ -629,7 +663,7 @@ test( "stop()", function() { this.clock.tick( 100 ); } ); -test( "stop() - several in queue", function() { +QUnit.test( "stop() - several in queue", function() { expect( 5 ); var nw, $foo = jQuery( "#foo" ); @@ -659,7 +693,7 @@ test( "stop() - several in queue", function() { equal( $foo.queue().length, 0, "0 in the queue" ); } ); -test( "stop(clearQueue)", function() { +QUnit.test( "stop(clearQueue)", function() { expect( 4 ); var $foo = jQuery( "#foo" ), @@ -683,7 +717,7 @@ test( "stop(clearQueue)", function() { equal( nw, $foo.css( "width" ), "The animation didn't continue" ); } ); -test( "stop(clearQueue, gotoEnd)", function() { +QUnit.test( "stop(clearQueue, gotoEnd)", function() { expect( 1 ); var $foo = jQuery( "#foo" ), @@ -712,7 +746,7 @@ test( "stop(clearQueue, gotoEnd)", function() { $foo.stop( true ); } ); -test( "stop( queue, ..., ... ) - Stop single queues", function() { +QUnit.test( "stop( queue, ..., ... ) - Stop single queues", function() { expect( 3 ); var saved, foo = jQuery( "#foo" ).css( { width: 200, height: 200 } ); @@ -743,10 +777,10 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() { queue: "height" } ).dequeue( "height" ).stop( "height", false, false ); saved = parseFloat( foo.css( "height" ) ); - this.clock.tick( 500 ); + this.clock.tick( 500 ); } ); -test( "toggle()", function() { +QUnit.test( "toggle()", function() { expect( 6 ); var x = jQuery( "#foo" ); ok( x.is( ":visible" ), "is visible" ); @@ -763,7 +797,7 @@ test( "toggle()", function() { ok( x.is( ":visible" ), "is visible again" ); } ); -test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() { +QUnit.test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() { var div = jQuery( "
" ).appendTo( "#qunit-fixture" ).css( { color: "#ABC", border: "5px solid black", @@ -817,7 +851,7 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() { jQuery( div ).remove(); } ); -test( "Overflow and Display", function() { +QUnit.test( "Overflow and Display", function() { expect( 4 ); var @@ -896,7 +930,7 @@ jQuery.each( { return 0; } }, function( tn, t ) { - test( fn + " to " + tn, function() { + QUnit.test( fn + " to " + tn, function() { var num, anim, elem = jQuery.makeTest( fn + " to " + tn ), t_w = t( elem, "width" ), @@ -1013,12 +1047,12 @@ jQuery.each( { } ); } ); -test( "Effects chaining", function() { +QUnit.test( "Effects chaining", function() { var remaining = 16, props = [ "opacity", "height", "width", "display", "overflow" ], setup = function( name, selector ) { var $el = jQuery( selector ); - return $el.data( getProps( $el[ 0 ] ) ).data( "name", name ); + return $el.data( getProps( $el[0] ) ).data( "name", name ); }, assert = function() { var data = jQuery.data( this ), @@ -1041,39 +1075,39 @@ test( "Effects chaining", function() { setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut( "fast" ).fadeIn( "fast", assert ); setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn( "fast" ).fadeOut( "fast", assert ); - setup( ".hide().show()", "#show div" ).hide( "fast" ).show( "fast", assert ); - setup( ".show().hide()", "#hide div" ).show( "fast" ).hide( "fast", assert ); - setup( ".show().hide(easing)", "#easehide div" ).show( "fast" ).hide( "fast", "linear", assert ); - setup( ".toggle().toggle() - in", "#togglein div" ).toggle( "fast" ).toggle( "fast", assert ); - setup( ".toggle().toggle() - out", "#toggleout div" ).toggle( "fast" ).toggle( "fast", assert ); - setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle( "fast" ).toggle( "fast", "linear", assert ); - setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown( "fast" ).slideUp( "fast", assert ); - setup( ".slideUp().slideDown()", "#slideup div" ).slideUp( "fast" ).slideDown( "fast", assert ); - setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp( "fast" ).slideDown( "fast", "linear", assert ); - setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle( "fast" ).slideToggle( "fast", assert ); - setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle( "fast" ).slideToggle( "fast", assert ); + setup( ".hide().show()", "#show div" ).hide("fast").show( "fast", assert ); + setup( ".show().hide()", "#hide div" ).show("fast").hide( "fast", assert ); + setup( ".show().hide(easing)", "#easehide div" ).show("fast").hide( "fast", "linear", assert ); + setup( ".toggle().toggle() - in", "#togglein div" ).toggle("fast").toggle( "fast", assert ); + setup( ".toggle().toggle() - out", "#toggleout div" ).toggle("fast").toggle( "fast", assert ); + setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle("fast").toggle( "fast", "linear", assert ); + setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown("fast").slideUp( "fast", assert ); + setup( ".slideUp().slideDown()", "#slideup div" ).slideUp("fast").slideDown( "fast", assert ); + setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp("fast").slideDown( "fast", "linear", assert ); + setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle("fast").slideToggle( "fast", assert ); + setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle("fast").slideToggle( "fast", assert ); setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert ); setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert ); setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", assert ); - this.clock.tick( 400 ); + this.clock.tick( 400 ); } ); jQuery.makeTest = function( text ) { - var elem = jQuery( "
" ) - .attr( "id", "test" + jQuery.makeTest.id++ ) - .addClass( "box" ); + var elem = jQuery( "
" ) + .attr( "id", "test" + jQuery.makeTest.id++ ) + .addClass( "box" ); - jQuery( "

" ) - .text( text ) - .appendTo( "#fx-tests" ) - .after( elem ); + jQuery( "

" ) + .text( text ) + .appendTo( "#fx-tests" ) + .after( elem ); - return elem; + return elem; }; jQuery.makeTest.id = 1; -test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function() { +QUnit.test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function() { expect( 4 ); var $checkedtest = jQuery( "#checkedtest" ); @@ -1086,7 +1120,7 @@ test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function() this.clock.tick( 200 ); } ); -test( "interrupt toggle", function() { +QUnit.test( "interrupt toggle", function() { expect( 24 ); var env = this, @@ -1148,7 +1182,7 @@ test( "interrupt toggle", function() { // FIXME untangle the set timeouts } ); -test( "animate with per-property easing", function() { +QUnit.test( "animate with per-property easing", function() { expect( 5 ); @@ -1188,7 +1222,7 @@ test( "animate with per-property easing", function() { this.clock.tick( 400 ); } ); -test( "animate with CSS shorthand properties", function() { +QUnit.test( "animate with CSS shorthand properties", function() { expect( 11 ); var easeAnimation_count = 0, @@ -1234,7 +1268,7 @@ test( "animate with CSS shorthand properties", function() { this.clock.tick( 400 ); } ); -test( "hide hidden elements, with animation (bug #7141)", function() { +QUnit.test( "hide hidden elements, with animation (bug #7141)", function() { expect( 3 ); var div = jQuery( "
" ).appendTo( "#qunit-fixture" ); @@ -1248,7 +1282,7 @@ test( "hide hidden elements, with animation (bug #7141)", function() { this.clock.tick( 10 ); } ); -test( "animate unit-less properties (#4966)", 2, function() { +QUnit.test( "animate unit-less properties (#4966)", 2, function() { var div = jQuery( "
" ).appendTo( "#qunit-fixture" ); equal( div.css( "z-index" ), "0", "z-index is 0" ); div.animate( { zIndex: 2 }, function() { @@ -1257,7 +1291,7 @@ test( "animate unit-less properties (#4966)", 2, function() { this.clock.tick( 400 ); } ); -test( "animate properties missing px w/ opacity as last (#9074)", 2, function() { +QUnit.test( "animate properties missing px w/ opacity as last (#9074)", 2, function() { expect( 6 ); var ml, l, div = jQuery( "
" ) @@ -1284,7 +1318,7 @@ test( "animate properties missing px w/ opacity as last (#9074)", 2, function() div.stop().remove(); } ); -test( "callbacks should fire in correct order (#9100)", function() { +QUnit.test( "callbacks should fire in correct order (#9100)", function() { expect( 1 ); var a = 1, @@ -1304,7 +1338,7 @@ test( "callbacks should fire in correct order (#9100)", function() { this.clock.tick( 20 ); } ); -test( "callbacks that throw exceptions will be removed (#5684)", function() { +QUnit.test( "callbacks that throw exceptions will be removed (#5684)", function() { expect( 2 ); var foo = jQuery( "#foo" ); @@ -1332,7 +1366,7 @@ test( "callbacks that throw exceptions will be removed (#5684)", function() { } ); -test( "animate will scale margin properties individually", function() { +QUnit.test( "animate will scale margin properties individually", function() { expect( 2 ); var foo = jQuery( "#foo" ).css( { @@ -1357,7 +1391,7 @@ test( "animate will scale margin properties individually", function() { } ); } ); -test( "Do not append px to 'fill-opacity' #9548", 1, function() { +QUnit.test( "Do not append px to 'fill-opacity' #9548", 1, function() { var $div = jQuery( "
" ).appendTo( "#qunit-fixture" ); $div.css( "fill-opacity", 0 ).animate( { "fill-opacity": 1.0 }, 0, function() { @@ -1372,7 +1406,7 @@ test( "Do not append px to 'fill-opacity' #9548", 1, function() { } ); } ); -test( "line-height animates correctly (#13855)", 12, function() { +QUnit.test( "line-height animates correctly (#13855)", 12, function() { var t0, clock = this.clock, longDuration = 2000, @@ -1434,7 +1468,7 @@ clock.tick( 50 ); } ); // Start 1.8 Animation tests -test( "jQuery.Animation( object, props, opts )", 4, function() { +QUnit.test( "jQuery.Animation( object, props, opts )", 4, function() { var animation, testObject = { "foo": 0, @@ -1459,7 +1493,7 @@ test( "jQuery.Animation( object, props, opts )", 4, function() { this.clock.tick( 10 ); } ); -test( "Animate Option: step: function( percent, tween )", 1, function() { +QUnit.test( "Animate Option: step: function( percent, tween )", 1, function() { var counter = {}; jQuery( "#foo" ).animate( { prop1: 1, @@ -1485,7 +1519,7 @@ test( "Animate Option: step: function( percent, tween )", 1, function() { this.clock.tick( 10 ); } ); -test( "Animate callbacks have correct context", 2, function() { +QUnit.test( "Animate callbacks have correct context", 2, function() { var foo = jQuery( "#foo" ); foo.animate( { height: 10 @@ -1500,7 +1534,7 @@ test( "Animate callbacks have correct context", 2, function() { this.clock.tick( 10 ); } ); -test( "User supplied callback called after show when fx off (#8892)", 2, function() { +QUnit.test( "User supplied callback called after show when fx off (#8892)", 2, function() { var foo = jQuery( "#foo" ); jQuery.fx.off = true; foo.hide(); @@ -1514,7 +1548,7 @@ test( "User supplied callback called after show when fx off (#8892)", 2, functio this.clock.tick( 1000 ); } ); -test( "animate should set display for disconnected nodes", function() { +QUnit.test( "animate should set display for disconnected nodes", function() { expect( 18 ); var env = this, @@ -1563,10 +1597,10 @@ test( "animate should set display for disconnected nodes", function() { jQuery.fn[ name ].apply( this, opt.concat( callback ) ); } ); } ); - clock.tick( 400 ); + clock.tick( 400 ); } ); -test( "Animation callback should not show animated element as :animated (#7157)", 1, function() { +QUnit.test( "Animation callback should not show animated element as :animated (#7157)", 1, function() { var foo = jQuery( "#foo" ); foo.animate( { @@ -1577,7 +1611,7 @@ test( "Animation callback should not show animated element as :animated (#7157)" this.clock.tick( 100 ); } ); -test( "Initial step callback should show element as :animated (#14623)", 1, function() { +QUnit.test( "Initial step callback should show element as :animated (#14623)", 1, function() { var foo = jQuery( "#foo" ); foo.animate( { @@ -1592,7 +1626,7 @@ test( "Initial step callback should show element as :animated (#14623)", 1, func foo.stop(); } ); -test( "hide called on element within hidden parent should set display to none (#10045)", 3, function() { +QUnit.test( "hide called on element within hidden parent should set display to none (#10045)", 3, function() { var hidden = jQuery( ".hidden" ), elems = jQuery( "
hide
hide0
hide1
" ); @@ -1612,7 +1646,7 @@ test( "hide called on element within hidden parent should set display to none (# this.clock.tick( 10 ); } ); -test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", 5, function() { +QUnit.test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", 5, function() { var foo = jQuery( "#foo" ), i = 0, elems = jQuery(); @@ -1641,7 +1675,7 @@ test( "hide, fadeOut and slideUp called on element width height and width = 0 sh this.clock.tick( 400 ); } ); -test( "hide should not leave hidden inline elements visible (#14848)", 2, function() { +QUnit.test( "hide should not leave hidden inline elements visible (#14848)", 2, function() { var el = jQuery( "#simon1" ); el.hide( 1, function() { @@ -1654,7 +1688,7 @@ test( "hide should not leave hidden inline elements visible (#14848)", 2, functi this.clock.tick( 100 ); } ); -test( "Handle queue:false promises", 10, function() { +QUnit.test( "Handle queue:false promises", 10, function() { var foo = jQuery( "#foo" ).clone().addBack(), step = 1; @@ -1705,7 +1739,7 @@ test( "Handle queue:false promises", 10, function() { this.clock.tick( 10 ); } ); -test( "multiple unqueued and promise", 4, function() { +QUnit.test( "multiple unqueued and promise", 4, function() { var foo = jQuery( "#foo" ), step = 1; foo.animate( { @@ -1738,7 +1772,7 @@ test( "multiple unqueued and promise", 4, function() { this.clock.tick( 1000 ); } ); -test( "animate does not change start value for non-px animation (#7109)", 1, function() { +QUnit.test( "animate does not change start value for non-px animation (#7109)", 1, function() { var parent = jQuery( "
" ).css( { width: 284, height: 1 } ).appendTo( "#qunit-fixture" ), child = parent.children().css( { fontSize: "98.6in", width: "0.01em", height: 1 } ), actual = parseFloat( child.css( "width" ) ), @@ -1758,7 +1792,7 @@ test( "animate does not change start value for non-px animation (#7109)", 1, fun this.clock.tick( 10 ); } ); -test( "non-px animation handles non-numeric start (#11971)", 2, function() { +QUnit.test( "non-px animation handles non-numeric start (#11971)", 2, function() { var foo = jQuery( "#foo" ), initial = foo.css( "backgroundPositionX" ); @@ -1875,7 +1909,7 @@ QUnit.test( "Animation callbacks (#11797)", function( assert ) { this.clock.tick( 10 ); } ); -test( "Animate properly sets overflow hidden when animating width/height (#12117)", 8, function() { +QUnit.test( "Animate properly sets overflow hidden when animating width/height (#12117)", 8, function() { jQuery.each( [ "height", "width" ], function( _, prop ) { jQuery.each( [ 100, 0 ], function( _, value ) { var div = jQuery( "
" ).css( "overflow", "auto" ), @@ -1891,7 +1925,7 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117 } ); } ); -test( "Each tick of the timer loop uses a fresh time (#12837)", function() { +QUnit.test( "Each tick of the timer loop uses a fresh time (#12837)", function() { var lastVal, tmp = jQuery( { test: 0 @@ -1916,7 +1950,7 @@ test( "Each tick of the timer loop uses a fresh time (#12837)", function() { tmp.stop(); } ); -test( "Animations with 0 duration don't ease (#12273)", 1, function() { +QUnit.test( "Animations with 0 duration don't ease (#12273)", 1, function() { jQuery.easing.test = function() { ok( false, "Called easing" ); }; @@ -1939,7 +1973,7 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { // this test would look a lot better if we were using something to override // the default timers var duration = 1500; - test( "toggle state tests: " + method + " (#8685)", function() { + QUnit.test( "toggle state tests: " + method + " (#8685)", function() { function secondToggle() { var stopped = parseFloat( element.css( check ) ); tested = false; @@ -1983,7 +2017,7 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { } ); } ); -test( "jQuery.fx.start & jQuery.fx.stop hook points", function() { +QUnit.test( "jQuery.fx.start & jQuery.fx.stop hook points", function() { var oldStart = jQuery.fx.start, oldStop = jQuery.fx.stop, foo = jQuery( { foo: 0 } ); @@ -2012,7 +2046,7 @@ test( "jQuery.fx.start & jQuery.fx.stop hook points", function() { jQuery.fx.stop = oldStop; } ); -test( ".finish() completes all queued animations", function() { +QUnit.test( ".finish() completes all queued animations", function() { var animations = { top: 100, left: 100, @@ -2047,7 +2081,7 @@ test( ".finish() completes all queued animations", function() { jQuery.fx.tick(); } ); -test( ".finish( false ) - unqueued animations", function() { +QUnit.test( ".finish( false ) - unqueued animations", function() { var animations = { top: 100, left: 100, @@ -2082,7 +2116,7 @@ test( ".finish( false ) - unqueued animations", function() { jQuery.fx.tick(); } ); -test( ".finish( \"custom\" ) - custom queue animations", function() { +QUnit.test( ".finish( \"custom\" ) - custom queue animations", function() { var animations = { top: 100, left: 100, @@ -2121,7 +2155,7 @@ test( ".finish( \"custom\" ) - custom queue animations", function() { jQuery.fx.tick(); } ); -test( ".finish() calls finish of custom queue functions", function() { +QUnit.test( ".finish() calls finish of custom queue functions", function() { function queueTester( next, hooks ) { hooks.stop = function( gotoEnd ) { inside++; @@ -2147,7 +2181,7 @@ test( ".finish() calls finish of custom queue functions", function() { div.remove(); } ); -test( ".finish() is applied correctly when multiple elements were animated (#13937)", function() { +QUnit.test( ".finish() is applied correctly when multiple elements were animated (#13937)", function() { expect( 3 ); var elems = jQuery( "012" ); @@ -2164,38 +2198,38 @@ test( ".finish() is applied correctly when multiple elements were animated (#139 this.clock.tick( 1500 ); } ); -test( "slideDown() after stop() (#13483)", 2, function() { - var ul = jQuery( "
    " ) - .appendTo( "#qunit-fixture" ), - origHeight = ul.height(), - clock = this.clock; +QUnit.test( "slideDown() after stop() (#13483)", 2, function() { + var ul = jQuery( "
      " ) + .appendTo( "#qunit-fixture" ), + origHeight = ul.height(), + clock = this.clock; + + // First test. slideUp() -> stop() in the middle -> slideDown() until the end + ul.slideUp( 1000 ); + clock.tick( 500 ); + ul.stop( true ); + ul.slideDown( 1, function() { + equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" ); - // First test. slideUp() -> stop() in the middle -> slideDown() until the end - ul.slideUp( 1000 ); + // Second test. slideDown() -> stop() in the middle -> slideDown() until the end + ul.slideUp( 1 ); + clock.tick( 10 ); + ul.slideDown( 1000 ); clock.tick( 500 ); ul.stop( true ); - ul.slideDown( 1, function() { - equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" ); - - // Second test. slideDown() -> stop() in the middle -> slideDown() until the end - ul.slideUp( 1 ); - clock.tick( 10 ); - ul.slideDown( 1000 ); - clock.tick( 500 ); - ul.stop( true ); - ul.slideDown( 1 ); - equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" ); - - // Cleanup - ul.remove(); - clock.tick( 10 ); - - } ); + ul.slideDown( 1 ); + equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" ); + // Cleanup + ul.remove(); clock.tick( 10 ); + + } ); + + clock.tick( 10 ); } ); -test( "Respect display value on inline elements (#14824)", 2, function() { +QUnit.test( "Respect display value on inline elements (#14824)", 2, function() { var clock = this.clock, fromStyleSheet = jQuery( "" ), fromStyleAttr = jQuery( "" ); diff --git a/test/unit/event.js b/test/unit/event.js index ab768439f..525a72d13 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1422,7 +1422,7 @@ QUnit.test( "Submit event can be stopped (#11049)", function( assert ) { form.remove(); } ); -// Test beforeunload event only if it supported. +// Test beforeunload event only if it supported (i.e. not Opera) // Support: iOS 7+, Android<4.0 // iOS & old Android have the window.onbeforeunload field but don't support the beforeunload // handler making it impossible to feature-detect the support. @@ -1430,6 +1430,7 @@ if ( window.onbeforeunload === null && !/(ipad|iphone|ipod|android 2\.3)/i.test( navigator.userAgent ) ) { QUnit.asyncTest( "on(beforeunload)", 4, function( assert ) { var win, + forIE6 = 0, fired = false, iframe = jQuery( "