aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/attributes.js136
-rw-r--r--test/unit/core.js37
-rw-r--r--test/unit/css.js25
-rw-r--r--test/unit/data.js70
-rw-r--r--test/unit/effects.js35
-rw-r--r--test/unit/event.js7
-rw-r--r--test/unit/manipulation.js11
-rw-r--r--test/unit/offset.js16
-rw-r--r--test/unit/queue.js19
-rw-r--r--test/unit/support.js9
-rw-r--r--test/unit/traversing.js20
11 files changed, 297 insertions, 88 deletions
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index b0fe2b4aa..eaaaa6235 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -6,7 +6,7 @@ var functionReturningObj = function(value) { return (function() { return value;
test("jQuery.attrFix/jQuery.propFix integrity test", function() {
expect(2);
-
+
// This must be maintained and equal jQuery.attrFix when appropriate
// Ensure that accidental or erroneous property
// overwrites don't occur
@@ -24,16 +24,11 @@ test("jQuery.attrFix/jQuery.propFix integrity test", function() {
usemap: "useMap",
frameborder: "frameBorder",
contenteditable: "contentEditable"
- },
- propsShouldBe;
-
- if ( !jQuery.support.getSetAttribute ) {
- propsShouldBe = props;
- } else {
- propsShouldBe = {
- tabindex: "tabIndex"
};
- }
+
+ var propsShouldBe = {
+ tabindex: "tabIndex"
+ };
deepEqual(propsShouldBe, jQuery.attrFix, "jQuery.attrFix passes integrity check");
deepEqual(props, jQuery.propFix, "jQuery.propFix passes integrity check");
@@ -57,7 +52,7 @@ test("attr(String)", function() {
equals( jQuery("<div value='t'></div>").attr("value"), "t", "Check setting custom attr named 'value' on a div" );
equals( jQuery("#form").attr("blah", "blah").attr("blah"), "blah", "Set non-existant attribute on a form" );
equals( jQuery("#foo").attr("height"), undefined, "Non existent height attribute should return undefined" );
-
+
// [7472] & [3113] (form contains an input with name="action" or name="id")
var extras = jQuery("<input name='id' name='name' /><input id='target' name='target' />").appendTo("#testForm");
equals( jQuery("#form").attr("action","newformaction").attr("action"), "newformaction", "Check that action attribute was changed" );
@@ -67,7 +62,7 @@ test("attr(String)", function() {
// Bug #3685 (form contains input with name="name")
equals( jQuery("#testForm").attr("name"), undefined, "Retrieving name does not retrieve input with name=name" );
extras.remove();
-
+
equals( jQuery("#text1").attr("maxlength"), "30", "Check for maxlength attribute" );
equals( jQuery("#text1").attr("maxLength"), "30", "Check for maxLength attribute" );
equals( jQuery("#area1").attr("maxLength"), "30", "Check for maxLength attribute" );
@@ -162,7 +157,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(73);
+ expect(75);
var div = jQuery("div").attr("foo", "bar"),
fail = false;
@@ -244,9 +239,13 @@ test("attr(String, Object)", function() {
equal( $details.attr("open"), "open", "open attribute presense indicates true" );
equal( $details.attr("open", false).attr("open"), undefined, "Setting open attribute to false removes it" );
- equals( $text.attr("data-something", true).data("something"), true, "Setting data attributes are not affected by boolean settings");
- equals( $text.attr("data-another", false).data("another"), false, "Setting data attributes are not affected by boolean settings" );
- equals( $text.attr("aria-disabled", false).attr("aria-disabled"), "false", "Setting aria attributes are not affected by boolean settings");
+ $text.attr("data-something", true);
+ equal( $text.attr("data-something"), "true", "Set data attributes");
+ equal( $text.data("something"), true, "Setting data attributes are not affected by boolean settings");
+ $text.attr("data-another", false);
+ equal( $text.attr("data-another"), "false", "Set data attributes");
+ equal( $text.data("another"), false, "Setting data attributes are not affected by boolean settings" );
+ equal( $text.attr("aria-disabled", false).attr("aria-disabled"), "false", "Setting aria attributes are not affected by boolean settings");
$text.removeData("something").removeData("another").removeAttr("aria-disabled");
jQuery("#foo").attr("contenteditable", true);
@@ -256,7 +255,7 @@ test("attr(String, Object)", function() {
commentNode = document.createComment("some comment"),
textNode = document.createTextNode("some text"),
obj = {};
-
+
jQuery.each( [commentNode, textNode, attributeNode], function( i, elem ) {
var $elem = jQuery( elem );
$elem.attr( "nonexisting", "foo" );
@@ -296,7 +295,7 @@ test("attr(String, Object)", function() {
j.removeAttr("name");
QUnit.reset();
-
+
// Type
var type = jQuery("#check2").attr("type");
var thrown = false;
@@ -458,7 +457,7 @@ test("removeAttr(String)", function() {
equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
-
+
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
equals( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
jQuery("#text1").prop("readOnly", true).removeAttr("readonly");
@@ -527,6 +526,61 @@ test("prop(String, Object)", function() {
jQuery( document ).removeProp("nonexisting");
});
+test("prop('tabindex')", function() {
+ expect(8);
+
+ // elements not natively tabbable
+ equals(jQuery("#listWithTabIndex").prop("tabindex"), 5, "not natively tabbable, with tabindex set to 0");
+ equals(jQuery("#divWithNoTabIndex").prop("tabindex"), undefined, "not natively tabbable, no tabindex set");
+
+ // anchor with href
+ equals(jQuery("#linkWithNoTabIndex").prop("tabindex"), 0, "anchor with href, no tabindex set");
+ equals(jQuery("#linkWithTabIndex").prop("tabindex"), 2, "anchor with href, tabindex set to 2");
+ equals(jQuery("#linkWithNegativeTabIndex").prop("tabindex"), -1, "anchor with href, tabindex set to -1");
+
+ // anchor without href
+ equals(jQuery("#linkWithNoHrefWithNoTabIndex").prop("tabindex"), undefined, "anchor without href, no tabindex set");
+ equals(jQuery("#linkWithNoHrefWithTabIndex").prop("tabindex"), 1, "anchor without href, tabindex set to 2");
+ equals(jQuery("#linkWithNoHrefWithNegativeTabIndex").prop("tabindex"), -1, "anchor without href, no tabindex set");
+});
+
+test("prop('tabindex', value)", function() {
+ expect(9);
+
+ var element = jQuery("#divWithNoTabIndex");
+ equals(element.prop("tabindex"), undefined, "start with no tabindex");
+
+ // set a positive string
+ element.prop("tabindex", "1");
+ equals(element.prop("tabindex"), 1, "set tabindex to 1 (string)");
+
+ // set a zero string
+ element.prop("tabindex", "0");
+ equals(element.prop("tabindex"), 0, "set tabindex to 0 (string)");
+
+ // set a negative string
+ element.prop("tabindex", "-1");
+ equals(element.prop("tabindex"), -1, "set tabindex to -1 (string)");
+
+ // set a positive number
+ element.prop("tabindex", 1);
+ equals(element.prop("tabindex"), 1, "set tabindex to 1 (number)");
+
+ // set a zero number
+ element.prop("tabindex", 0);
+ equals(element.prop("tabindex"), 0, "set tabindex to 0 (number)");
+
+ // set a negative number
+ element.prop("tabindex", -1);
+ equals(element.prop("tabindex"), -1, "set tabindex to -1 (number)");
+
+ element = jQuery("#linkWithTabIndex");
+ equals(element.prop("tabindex"), 2, "start with tabindex 2");
+
+ element.prop("tabindex", -1);
+ equals(element.prop("tabindex"), -1, "set negative tabindex");
+});
+
test("removeProp(String)", function() {
expect(6);
var attributeNode = document.createAttribute("irrelevant"),
@@ -615,11 +669,11 @@ test("val()", function() {
var $button = jQuery("<button value='foobar'>text</button>").insertAfter("#button");
equals( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" );
equals( $button.val("baz").html(), "text", "Setting the value does not change innerHTML" );
-
+
equals( jQuery("<option/>").val("test").attr("value"), "test", "Setting value sets the value attribute" );
});
-if ( "value" in document.createElement("meter") &&
+if ( "value" in document.createElement("meter") &&
"value" in document.createElement("progress") ) {
test("val() respects numbers without exception (Bug #9319)", function() {
@@ -766,7 +820,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" );
jQuery("#kk").remove();
-});
+});
var testAddClass = function(valueObj) {
expect(9);
@@ -798,7 +852,7 @@ var testAddClass = function(valueObj) {
div.attr("class", "foo");
div.addClass( valueObj("bar baz") );
equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." );
-
+
div.removeClass();
div.addClass( valueObj("foo") ).addClass( valueObj("foo") )
equal( div.attr("class"), "foo", "Do not add the same class twice in separate calls." );
@@ -822,11 +876,11 @@ test("addClass(Function)", function() {
});
test("addClass(Function) with incoming value", function() {
- expect(45);
+ expect(48);
var div = jQuery("div"), old = div.map(function(){
return jQuery(this).attr("class") || "";
});
-
+
div.addClass(function(i, val) {
if ( this.id !== "_firebugConsole") {
equals( val, old[i], "Make sure the incoming value is correct." );
@@ -894,7 +948,7 @@ test("removeClass(Function) - simple", function() {
});
test("removeClass(Function) with incoming value", function() {
- expect(45);
+ expect(48);
var $divs = jQuery("div").addClass("test"), old = $divs.map(function(){
return jQuery(this).attr("class");
@@ -977,7 +1031,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
ok( !e.is(".test"), "Assert class not present" );
e.toggleClass(function(i, val) {
- equals( val, old, "Make sure the incoming value is correct." );
+ equal( old, val, "Make sure the incoming value is correct." );
return "test";
});
ok( e.is(".test"), "Assert class present" );
@@ -985,26 +1039,26 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
old = e.attr("class");
e.toggleClass(function(i, val) {
- equals( val, old, "Make sure the incoming value is correct." );
+ equal( old, val, "Make sure the incoming value is correct." );
return "test";
});
ok( !e.is(".test"), "Assert class not present" );
- old = e.attr("class");
+ old = e.attr("class") || "";
// class name with a boolean
e.toggleClass(function(i, val, state) {
- equals( val, old, "Make sure the incoming value is correct." );
- equals( state, false, "Make sure that the state is passed in." );
+ equal( old, val, "Make sure the incoming value is correct." );
+ equal( state, false, "Make sure that the state is passed in." );
return "test";
}, false );
ok( !e.is(".test"), "Assert class not present" );
- old = e.attr("class");
+ old = e.attr("class") || "";
e.toggleClass(function(i, val, state) {
- equals( val, old, "Make sure the incoming value is correct." );
- equals( state, true, "Make sure that the state is passed in." );
+ equal( old, val, "Make sure the incoming value is correct." );
+ equal( state, true, "Make sure that the state is passed in." );
return "test";
}, true );
ok( e.is(".test"), "Assert class present" );
@@ -1012,8 +1066,8 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() {
old = e.attr("class");
e.toggleClass(function(i, val, state) {
- equals( val, old, "Make sure the incoming value is correct." );
- equals( state, false, "Make sure that the state is passed in." );
+ equal( old, val, "Make sure the incoming value is correct." );
+ equal( state, false, "Make sure that the state is passed in." );
return "test";
}, false );
ok( !e.is(".test"), "Assert class not present" );
@@ -1062,3 +1116,13 @@ test("addClass, removeClass, hasClass", function() {
jq.removeClass("class4");
ok( jq.hasClass("class4")==false, "Check the class has been properly removed" );
});
+
+test("contents().hasClass() returns correct values", function() {
+ expect(2);
+
+ var $div = jQuery("<div><span class='foo'></span><!-- comment -->text</div>"),
+ $contents = $div.contents();
+
+ ok( $contents.hasClass("foo"), "Found 'foo' in $contents" );
+ ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" );
+});
diff --git a/test/unit/core.js b/test/unit/core.js
index 7599455df..fdf0ceb5e 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -474,6 +474,24 @@ test("isXMLDoc - HTML", function() {
document.body.removeChild( iframe );
});
+test("XSS via location.hash", function() {
+ expect(1);
+
+ stop();
+ jQuery._check9521 = function(x){
+ ok( x, "script called from #id-like selector with inline handler" );
+ jQuery("#check9521").remove();
+ delete jQuery._check9521;
+ start();
+ };
+ try {
+ // This throws an error because it's processed like an id
+ jQuery( '#<img id="check9521" src="no-such-.gif" onerror="jQuery._check9521(false)">' ).appendTo("#qunit-fixture");
+ } catch (err) {
+ jQuery._check9521(true);
+ };
+});
+
if ( !isLocal ) {
test("isXMLDoc - XML", function() {
expect(3);
@@ -923,6 +941,16 @@ test("jQuery.makeArray", function(){
same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly.");
});
+test("jQuery.inArray", function(){
+ expect(3);
+
+ equals( jQuery.inArray( 0, false ), -1 , "Search in 'false' as array returns -1 and doesn't throw exception" );
+
+ equals( jQuery.inArray( 0, null ), -1 , "Search in 'null' as array returns -1 and doesn't throw exception" );
+
+ equals( jQuery.inArray( 0, undefined ), -1 , "Search in 'undefined' as array returns -1 and doesn't throw exception" );
+});
+
test("jQuery.isEmptyObject", function(){
expect(2);
@@ -1136,10 +1164,15 @@ test("jQuery.camelCase()", function() {
var tests = {
"foo-bar": "fooBar",
- "foo-bar-baz": "fooBarBaz"
+ "foo-bar-baz": "fooBarBaz",
+ "girl-u-want": "girlUWant",
+ "the-4th-dimension": "the4thDimension",
+ "-o-tannenbaum": "OTannenbaum",
+ "-moz-illa": "MozIlla",
+ "-ms-take": "msTake"
};
- expect(2);
+ expect(7);
jQuery.each( tests, function( key, val ) {
equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );
diff --git a/test/unit/css.js b/test/unit/css.js
index f421f7bd4..acad497eb 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -109,7 +109,7 @@ test("css(String|Hash)", function() {
});
test("css() explicit and relative values", function() {
- expect(27);
+ expect(29);
var $elem = jQuery("#nothiddendiv");
$elem.css({ width: 1, height: 1, paddingLeft: "1px", opacity: 1 });
@@ -141,6 +141,12 @@ test("css() explicit and relative values", function() {
$elem.css( "width", "-=9px" );
equals( $elem.width(), 1, "'-=9px' on width (params)" );
+ $elem.css( "width", "-=-9px" );
+ equals( $elem.width(), 10, "'-=-9px' on width (params)" );
+
+ $elem.css( "width", "+=-9px" );
+ equals( $elem.width(), 1, "'+=-9px' on width (params)" );
+
$elem.css({ paddingLeft: "+=4" });
equals( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
@@ -259,6 +265,23 @@ if ( !jQuery.support.opacity ) {
jQuery("#foo").css("filter", filterVal3).css("opacity", 1);
ok( jQuery("#foo").css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" );
});
+
+ test( "Setting opacity to 1 properly removes filter: style (#6652)", function() {
+ var rfilter = /filter:[^;]*/i,
+ test = jQuery( "#t6652" ).css( "opacity", 1 ),
+ test2 = test.find( "div" ).css( "opacity", 1 );
+
+ function hasFilter( elem ) {
+ var match = rfilter.exec( elem[0].style.cssText );
+ if ( match ) {
+ return true;
+ }
+ return false;
+ }
+ expect( 2 );
+ ok( !hasFilter( test ), "Removed filter attribute on element without filter in stylesheet" );
+ ok( hasFilter( test2 ), "Filter attribute remains on element that had filter in stylesheet" );
+ });
}
test("css(String, Function)", function() {
diff --git a/test/unit/data.js b/test/unit/data.js
index 87a3de339..06c6c2d57 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -525,3 +525,73 @@ test("jQuery.data should not miss data with preset hyphenated property names", f
equal( div.data(k), k, "data with property '"+k+"' was correctly found");
});
});
+
+test("jQuery.data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {
+
+ var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
+ datas = {
+ "non-empty": "a string",
+ "empty-string": "",
+ "one-value": 1,
+ "zero-value": 0,
+ "an-array": [],
+ "an-object": {},
+ "bool-true": true,
+ "bool-false": false,
+ "some-json": '{ "foo": "bar" }',
+ "num-1-middle": true,
+ "num-end-2": true,
+ "2-num-start": true
+ };
+
+ expect( 24 );
+
+ jQuery.each( datas, function( key, val ) {
+ div.data( key, val );
+
+ deepEqual( div.data( key ), val, "get: " + key );
+ deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
+ });
+});
+
+test("jQuery.data supports interoperable removal of hyphenated/camelCase properties", function() {
+ var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
+ datas = {
+ "non-empty": "a string",
+ "empty-string": "",
+ "one-value": 1,
+ "zero-value": 0,
+ "an-array": [],
+ "an-object": {},
+ "bool-true": true,
+ "bool-false": false,
+ "some-json": '{ "foo": "bar" }'
+ };
+
+ expect( 27 );
+
+ jQuery.each( datas, function( key, val ) {
+ div.data( key, val );
+
+ deepEqual( div.data( key ), val, "get: " + key );
+ deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) );
+
+ div.removeData( key );
+
+ equal( div.data( key ), undefined, "get: " + key );
+
+ });
+});
+
+// Test originally by Moschel
+test("Triggering the removeData should not throw exceptions. (#10080)", function() {
+ expect(1);
+ stop();
+ var frame = jQuery("#loadediframe");
+ jQuery(frame[0].contentWindow).bind("unload", function() {
+ ok(true, "called unload");
+ start();
+ });
+ // change the url to trigger unload
+ frame.attr("src", "data/iframe.html?param=true");
+});
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 864c4a400..3afc37f69 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -169,7 +169,7 @@ test("Persist correct display value", function() {
test("show() resolves correct default display #8099", function() {
expect(7);
- var tt8099 = jQuery("<tt/>").appendTo("body"),
+ var tt8099 = jQuery("<tt/>").appendTo("body"),
dfn8099 = jQuery("<dfn/>", { html: "foo"}).appendTo("body");
equals( tt8099.css("display"), "none", "default display override for all tt" );
@@ -727,6 +727,10 @@ jQuery.each( {
var t_o = t( elem, "opacity" );
var f_o = f( elem, "opacity" );
+ if ( f_o === "" ) {
+ f_o = 1;
+ }
+
var num = 0;
if ( t_h == "show" ) num++;
@@ -750,22 +754,41 @@ jQuery.each( {
elem = elem[ 0 ];
- if ( t_w == "show" )
+ if ( t_w == "show" ) {
equals( elem.style.display, "block", "Showing, display should block: " + elem.style.display);
+ }
- if ( t_w == "hide"||t_w == "show" )
+ if ( t_w == "hide"||t_w == "show" ) {
ok(f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf(f_w) === 0, "Width must be reset to " + f_w + ": " + elem.style.width);
+ }
- if ( t_h == "hide"||t_h == "show" )
+ if ( t_h == "hide"||t_h == "show" ) {
ok(f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf(f_h) === 0, "Height must be reset to " + f_h + ": " + elem.style.height);
+ }
var cur_o = jQuery.style(elem, "opacity");
- if ( t_o == "hide" || t_o == "show" )
+ if ( f_o !== jQuery.css(elem, "opacity") ) {
+ f_o = f( elem, "opacity" );
+ }
+
+ // The only time an _empty_string_ will be matched is in IE
+ // otherwise, the correct values will be tested as usual
+ if ( f_o === "" ) {
+ f_o = 1;
+ }
+ // See above
+ if ( cur_o === "" ) {
+ cur_o = 1;
+ }
+
+ if ( t_o == "hide" || t_o == "show" ) {
equals(cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o);
+ }
- if ( t_w == "hide" )
+ if ( t_w == "hide" ) {
equals(elem.style.display, "none", "Hiding, display should be none: " + elem.style.display);
+ }
if ( t_o.constructor == Number ) {
equals(cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o);
diff --git a/test/unit/event.js b/test/unit/event.js
index 7c628880b..4e475da06 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -922,7 +922,7 @@ test("trigger(type, [data], [fn])", function() {
ok( true, "Native call was triggered" );
};
-
+
$elem.live('mouseenter', function(){
ok( true, 'Trigger mouseenter bound by live' );
});
@@ -938,7 +938,7 @@ test("trigger(type, [data], [fn])", function() {
$elem.die('mouseenter');
$elem.die('mouseleave');
-
+
// Triggers handlrs and native
// Trigger 5
$elem.bind("click", handler).trigger("click", [1, "2", "abc"]);
@@ -994,9 +994,6 @@ test("trigger(type, [data], [fn])", function() {
form.remove();
});
-test("jQuery.Event.currentTarget", function(){
-});
-
test("trigger(eventObject, [data], [fn])", function() {
expect(25);
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index b9bc75873..4017cf196 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1465,3 +1465,14 @@ test("jQuery.buildFragment - plain objects are not a document #8950", function()
} catch (e) {}
});
+
+test("jQuery.clone - no exceptions for object elements #9587", function() {
+ expect(1);
+
+ try {
+ jQuery("#no-clone-exception").clone();
+ ok( true, "cloned with no exceptions" );
+ } catch( e ) {
+ ok( false, e.message );
+ }
+});
diff --git a/test/unit/offset.js b/test/unit/offset.js
index ea1a49332..79a0f3606 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -11,7 +11,7 @@ test("disconnected node", function() {
var supportsScroll = false;
-testoffset("absolute"/* in iframe */, function($, iframe) {
+testoffset("absolute", function($, iframe) {
expect(4);
var doc = iframe.document, tests;
@@ -390,7 +390,7 @@ testoffset("scroll", function( jQuery, win ) {
equals( jQuery(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
equals( jQuery(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
equals( jQuery(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
-
+
// Tests scrollTop/Left with empty jquery objects
notEqual( jQuery().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
notEqual( jQuery().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
@@ -443,12 +443,12 @@ test("offsetParent", function(){
test("fractions (see #7730 and #7885)", function() {
expect(2);
-
+
jQuery('body').append('<div id="fractions"/>');
-
+
var expected = { top: 1000, left: 1000 };
var div = jQuery('#fractions');
-
+
div.css({
position: 'absolute',
left: '1000.7432222px',
@@ -456,14 +456,14 @@ test("fractions (see #7730 and #7885)", function() {
width: 100,
height: 100
});
-
+
div.offset(expected);
-
+
var result = div.offset();
equals( result.top, expected.top, "Check top" );
equals( result.left, expected.left, "Check left" );
-
+
div.remove();
});
diff --git a/test/unit/queue.js b/test/unit/queue.js
index c5c387a48..b5c058caa 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -66,25 +66,6 @@ test("queue(name) passes in the next item in the queue as a parameter", function
div.dequeue("foo");
});
-test("queue(name) passes in the next item in the queue as a parameter", function() {
- expect(2);
-
- var div = jQuery({});
- var counter = 0;
-
- div.queue("foo", function(next) {
- equals(++counter, 1, "Dequeueing");
- next();
- }).queue("foo", function(next) {
- equals(++counter, 2, "Next was called");
- next();
- }).queue("bar", function() {
- equals(++counter, 3, "Other queues are not triggered by next()")
- });
-
- div.dequeue("foo");
-});
-
test("queue() passes in the next item in the queue as a parameter to fx queues", function() {
expect(3);
stop();
diff --git a/test/unit/support.js b/test/unit/support.js
index 36dc3553e..4733b2529 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -42,14 +42,19 @@ supportIFrameTest( "body background is not lost if set prior to loading jQuery (
for ( i in jQuery.support ) {
if ( jQuery.support[ i ] !== support[ i ] ) {
passed = false;
- strictEquals( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
+ strictEqual( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
}
}
for ( i in support ) {
if ( !( i in jQuery.support ) ) {
ok = false;
- strictEquals( src[ i ], dest[ i ], "Unexpected property: " + i );
+ strictEqual( src[ i ], dest[ i ], "Unexpected property: " + i );
}
}
ok( passed, "Same support properties" );
});
+
+supportIFrameTest( "A background on the testElement does not cause IE8 to crash (#9823)", "testElementCrash", function() {
+ expect(1);
+ ok( true, "IE8 does not crash" );
+});
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 5216ae752..37ac20e82 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -15,7 +15,7 @@ test("find(String)", function() {
test("find(node|jQuery object)", function() {
expect( 11 );
-
+
var $foo = jQuery("#foo"),
$blog = jQuery(".blogTest"),
$first = jQuery("#first"),
@@ -29,12 +29,12 @@ test("find(node|jQuery object)", function() {
ok( $foo.find( $two ).is(".blogTest"), "Find returns only nodes within #foo" );
ok( $fooTwo.find( $blog ).is(".blogTest"), "Blog is part of the collection, but also within foo" );
ok( $fooTwo.find( $blog[0] ).is(".blogTest"), "Blog is part of the collection, but also within foo(node)" );
-
+
equals( $two.find( $foo ).length, 0, "Foo is not in two elements" );
equals( $two.find( $foo[0] ).length, 0, "Foo is not in two elements(node)" );
equals( $two.find( $first ).length, 0, "first is in the collection and not within two" );
equals( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
-
+
});
test("is(String|undefined)", function() {
@@ -63,7 +63,7 @@ test("is(String|undefined)", function() {
ok( !jQuery("#foo").is(""), "Expected false for an invalid expression - \"\"" );
ok( !jQuery("#foo").is(undefined), "Expected false for an invalid expression - undefined" );
ok( !jQuery("#foo").is({ plain: "object" }), "Check passing invalid object" );
-
+
// test is() with comma-seperated expressions
ok( jQuery("#en").is("[lang=\"en\"],[lang=\"de\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
ok( jQuery("#en").is("[lang=\"de\"],[lang=\"en\"]"), "Comma-seperated; Check for lang attribute: Expect en or de" );
@@ -88,7 +88,7 @@ test("is(jQuery)", function() {
ok( !jQuery("#radio1").is( jQuery("input:checked") ), "Check for pseudoclass: Expected not checked" );
ok( jQuery("#foo").is( jQuery("div:has(p)") ), "Check for child: Expected a child 'p' element" );
ok( !jQuery("#foo").is( jQuery("div:has(ul)") ), "Check for child: Did not expect 'ul' element" );
-
+
// Some raw elements
ok( jQuery("#form").is( jQuery("form")[0] ), "Check for element: A form is a form" );
ok( !jQuery("#form").is( jQuery("div")[0] ), "Check for element: A form is not a div" );
@@ -99,9 +99,11 @@ test("is(jQuery)", function() {
});
test("index()", function() {
- expect(1);
+ expect( 2 );
+
+ equal( jQuery("#text2").index(), 2, "Returns the index of a child amongst its siblings" );
- equals( jQuery("#text2").index(), 2, "Returns the index of a child amongst its siblings" )
+ equal( jQuery("<div/>").index(), -1, "Node without parent returns -1" );
});
test("index(Object|String|undefined)", function() {
@@ -140,7 +142,7 @@ test("filter(Selector|undefined)", function() {
same( jQuery("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
same( jQuery("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
same( jQuery("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
-
+
same( jQuery("p").filter(null).get(), [], "filter(null) should return an empty jQuery object");
same( jQuery("p").filter(undefined).get(), [], "filter(undefined) should return an empty jQuery object");
same( jQuery("p").filter(0).get(), [], "filter(0) should return an empty jQuery object");
@@ -530,7 +532,7 @@ test("add(String|Element|Array|undefined)", function() {
test("add(String, Context)", function() {
expect(6);
-
+
deepEqual( jQuery( "#firstp" ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add selector to selector " );
deepEqual( jQuery( document.getElementById("firstp") ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add gEBId to selector" );
deepEqual( jQuery( document.getElementById("firstp") ).add( document.getElementById("ap") ).get(), q( "firstp", "ap" ), "Add gEBId to gEBId" );