diff options
author | Mike Sherov <mike.sherov@gmail.com> | 2012-06-10 21:54:16 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-06-10 21:54:16 -0400 |
commit | 5f35b3d9f90d07ee084d59702a54051ee51fb0d3 (patch) | |
tree | 7c412b9602b6a3a48435f5adb1d3c84b97bd20dc /test | |
parent | 1bb1432fe995881821f433c5b7bf86c61f3b3f50 (diff) | |
download | jquery-5f35b3d9f90d07ee084d59702a54051ee51fb0d3.tar.gz jquery-5f35b3d9f90d07ee084d59702a54051ee51fb0d3.zip |
Fix #11857. Modularize css.js, add dependency management. Closes gh-816.
See the pull request for more info on the dependency management details.
Diffstat (limited to 'test')
-rw-r--r-- | test/data/testinit.js | 5 | ||||
-rw-r--r-- | test/unit/attributes.js | 25 | ||||
-rw-r--r-- | test/unit/core.js | 15 | ||||
-rw-r--r-- | test/unit/css.js | 4 | ||||
-rw-r--r-- | test/unit/event.js | 10 | ||||
-rw-r--r-- | test/unit/manipulation.js | 22 | ||||
-rw-r--r-- | test/unit/selector.js | 42 | ||||
-rw-r--r-- | test/unit/support.js | 44 |
8 files changed, 96 insertions, 71 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js index f2898e0ba..23bdb9163 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -198,9 +198,8 @@ function url( value ) { function loadFixture() { var src = url("./data/" + fileName + ".html"), - iframe = jQuery("<iframe />").css({ - width: 500, height: 500, position: "absolute", top: -600, left: -600, visibility: "hidden" - }).appendTo("body")[0]; + iframe = jQuery("<iframe />").appendTo("body")[0]; + iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;"; iframe.contentWindow.location = src; return iframe; } diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 33551ba94..6062bc7c9 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -371,10 +371,8 @@ test("attr(jquery_method)", function(){ var $elem = jQuery("<div />"), elem = $elem[0], - expected = 5, - attrObj = { - css: { paddingLeft: 1, paddingRight: 1 } - }; + expected = 2, + attrObj = {}; if ( jQuery.fn.width ) { expected += 2; @@ -386,6 +384,11 @@ test("attr(jquery_method)", function(){ attrObj.offset = { top: 1, left: 0 }; } + if ( jQuery.css ) { + expected += 3; + attrObj.css = { paddingLeft: 1, paddingRight: 1 }; + } + expect( expected ); // one at a time @@ -395,9 +398,6 @@ test("attr(jquery_method)", function(){ $elem.attr( { text: "bar" }, true ); equal( elem.innerHTML, "bar", "attr(text)" ); - $elem.attr( { css: { color: "red" } }, true ); - ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" ); - // Multiple attributes $elem.attr( attrObj, true ); @@ -415,8 +415,13 @@ test("attr(jquery_method)", function(){ equal( elem.style.left, "1px", "attr(offset)" ); } - equal( elem.style.paddingLeft, "1px", "attr({css:})" ); - equal( elem.style.paddingRight, "1px", "attr({css:})" ); + if ( jQuery.css ) { + equal( elem.style.paddingLeft, "1px", "attr({css:})" ); + equal( elem.style.paddingRight, "1px", "attr({css:})" ); + + $elem.attr( { css: { color: "red" } }, true ); + ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" ); + } }); test("attr(String, Object) - Loaded via XML document", function() { @@ -494,7 +499,7 @@ test("removeAttr(String)", function() { equal( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" ); equal( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" ); equal( jQuery("<div style='position: absolute'></div>").appendTo("#foo").removeAttr("style").prop("style").cssText, "", "Check removing style attribute (#9699 Webkit)" ); - equal( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" ); + equal( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").get(0).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" ); jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked"); equal( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" ); diff --git a/test/unit/core.js b/test/unit/core.js index 2daf5d24d..88c470104 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -27,9 +27,8 @@ test("jQuery()", function() { div = jQuery("<div/><hr/><code/><b/>"), exec = false, long = "", - expected = 28, + expected = 26, attrObj = { - css: { paddingLeft: 1, paddingRight: 1 }, click: function() { ok( exec, "Click executed." ); }, text: "test", "class": "test2", @@ -46,6 +45,11 @@ test("jQuery()", function() { attrObj.offset = { top: 1, left: 1 }; } + if ( jQuery.css ) { + expected += 2; + attrObj.css = { paddingLeft: 1, paddingRight: 1 }; + } + expect( expected ); // Basic constructor's behavior @@ -103,8 +107,11 @@ test("jQuery()", function() { equal( elem[0].style.top, "1px", "jQuery() quick setter offset"); } - equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css"); - equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css"); + if ( jQuery.css ) { + equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css"); + equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css"); + } + equal( elem[0].childNodes.length, 1, "jQuery quick setter text"); equal( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text"); equal( elem[0].className, "test2", "jQuery() quick setter class"); diff --git a/test/unit/css.js b/test/unit/css.js index b030569fb..ea57c9abe 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1,3 +1,5 @@ +if ( jQuery.css ) { + module("css", { teardown: moduleTeardown }); test("css(String|Hash)", function() { @@ -779,3 +781,5 @@ test( "cssHooks - expand", function() { }); }); + +} diff --git a/test/unit/event.js b/test/unit/event.js index db7065fd1..36cb53aec 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1020,9 +1020,11 @@ test("trigger(type, [data], [fn])", function() { // Triggers 5 equal( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" ); - var pass = true; + var pass = true, elem2; try { - jQuery("#form input:first").hide().trigger("focus"); + elem2 = jQuery("#form input:first"); + elem2.get(0).style.display = "none"; + elem2.trigger("focus"); } catch(e) { pass = false; } @@ -1133,9 +1135,11 @@ test( "change event bubbles on copied forms (#11796)", function(){ test("trigger(eventObject, [data], [fn])", function() { expect(28); - var $parent = jQuery("<div id='par' />").hide().appendTo("body"), + var $parent = jQuery("<div id='par' />").appendTo("body"), $child = jQuery("<p id='child'>foo</p>").appendTo( $parent ); + $parent.get( 0 ).style.display = "none"; + var event = jQuery.Event("noNew"); ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" ); equal( event.type, "noNew", "Verify its type" ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 0e419a8bb..e8c183f3c 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -533,19 +533,21 @@ test("append HTML5 sectioning elements (Bug #6485)", function () { var article = jQuery("article"), aside = jQuery("aside"); - equal( article.css("fontSize"), "10px", "HTML5 elements are styleable"); + equal( article.get( 0 ).style.fontSize, "10px", "HTML5 elements are styleable"); equal( aside.length, 1, "HTML5 elements do not collapse their children") }); -test("HTML5 Elements inherit styles from style rules (Bug #10501)", function () { - expect(1); +if ( jQuery.css ) { + test("HTML5 Elements inherit styles from style rules (Bug #10501)", function () { + expect(1); - jQuery("#qunit-fixture").append("<article id='article'></article>"); - jQuery("#article").append("<section>This section should have a pink background.</section>"); + jQuery("#qunit-fixture").append("<article id='article'></article>"); + jQuery("#article").append("<section>This section should have a pink background.</section>"); - // In IE, the missing background color will claim its value is "transparent" - notEqual( jQuery("section").css("background-color"), "transparent", "HTML5 elements inherit styles"); -}); + // In IE, the missing background color will claim its value is "transparent" + notEqual( jQuery("section").css("background-color"), "transparent", "HTML5 elements inherit styles"); + }); +} test("html5 clone() cannot use the fragment cache in IE (#6485)", function () { expect(1); @@ -1653,8 +1655,8 @@ test("jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function $wraptarget.wrapAll("<aside style='background-color:green'></aside>"); - notEqual( $wraptarget.parent("aside").css("background-color"), "transparent", "HTML5 elements created with wrapAll inherit styles" ); - notEqual( $section.css("background-color"), "transparent", "HTML5 elements create with jQuery( string ) inherit styles" ); + notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" ); + notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" ); }); test("Cloned, detached HTML5 elems (#10667,10670)", function() { diff --git a/test/unit/selector.js b/test/unit/selector.js index f4a5f4954..5bea3215e 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -34,26 +34,28 @@ test("attributes - jQuery only", function() { t( "Find elements with a tabindex attribute", "[tabindex]", ["listWithTabIndex", "foodWithNegativeTabIndex", "linkWithTabIndex", "linkWithNegativeTabIndex", "linkWithNoHrefWithTabIndex", "linkWithNoHrefWithNegativeTabIndex"] ); }); -test("pseudo - visibility", function() { - expect( 9 ); - - t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] ); - t( "Is Not Hidden", "#qunit-fixture:hidden", [] ); - t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] ); - - var $div = jQuery('<div/>').appendTo("body"); - $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0 - $div.css( "width", 1 ).css( "height", 0 ); - t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); - t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); - $div.css( "width", 0 ).css( "height", 1 ); - t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); - t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); - $div.css( "width", 1 ).css( "height", 1 ); - t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); - t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); - $div.remove(); -}); +if ( jQuery.css ) { + test("pseudo - visibility", function() { + expect( 9 ); + + t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] ); + t( "Is Not Hidden", "#qunit-fixture:hidden", [] ); + t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] ); + + var $div = jQuery('<div/>').appendTo("body"); + $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0 + $div.css( "width", 1 ).css( "height", 0 ); + t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); + t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); + $div.css( "width", 0 ).css( "height", 1 ); + t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); + t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); + $div.css( "width", 1 ).css( "height", 1 ); + t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); + t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); + $div.remove(); + }); +} test("disconnected nodes", function() { expect( 4 ); diff --git a/test/unit/support.js b/test/unit/support.js index bb4887921..e733d520d 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -6,30 +6,32 @@ test("boxModel", function() { equal( jQuery.support.boxModel, document.compatMode === "CSS1Compat" , "jQuery.support.boxModel is sort of tied to quirks mode but unstable since 1.8" ); }); -testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9238)", "support/bodyBackground", function( color, support ) { - expect( 2 ); - var i, - passed = true, - okValue = { - "#000000": true, - "rgb(0, 0, 0)": true - }; - ok( okValue[ color ], "color was not reset (" + color + ")" ); +if ( jQuery.css ) { + testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9238)", "support/bodyBackground", function( color, support ) { + expect( 2 ); + var i, + passed = true, + okValue = { + "#000000": true, + "rgb(0, 0, 0)": true + }; + ok( okValue[ color ], "color was not reset (" + color + ")" ); - for ( i in jQuery.support ) { - if ( jQuery.support[ i ] !== support[ i ] ) { - passed = false; - strictEqual( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" ); + for ( i in jQuery.support ) { + if ( jQuery.support[ i ] !== support[ i ] ) { + passed = false; + strictEqual( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" ); + } } - } - for ( i in support ) { - if ( !( i in jQuery.support ) ) { - passed = false; - strictEqual( jQuery.support[ i ], support[ i ], "Unexpected property: " + i ); + for ( i in support ) { + if ( !( i in jQuery.support ) ) { + passed = false; + strictEqual( jQuery.support[ i ], support[ i ], "Unexpected property: " + i ); + } } - } - ok( passed, "Same support properties" ); -}); + ok( passed, "Same support properties" ); + }); +} testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash", function() { expect(1); |