diff options
author | jeresig <jeresig@gmail.com> | 2011-04-10 15:41:51 -0400 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2011-04-10 15:41:51 -0400 |
commit | b92d2f0bc96d65c83252fa3033c37b92eb32d442 (patch) | |
tree | ac8545d23de62865406703eb3eb7ff3bd7401d75 /test | |
parent | d4e4414451e15d23d7174e8eeddaa952ed0e4d73 (diff) | |
parent | 3a1b4661f5b8249ce7a741084824ec5445c75719 (diff) | |
download | jquery-b92d2f0bc96d65c83252fa3033c37b92eb32d442.tar.gz jquery-b92d2f0bc96d65c83252fa3033c37b92eb32d442.zip |
Merge branch 'attrhooks.1.6v2' of https://github.com/timmywil/jquery into timmywil-attrhooks.1.6v2
Conflicts:
src/attributes.js
Diffstat (limited to 'test')
-rw-r--r-- | test/data/offset/fixed.html | 1 | ||||
-rw-r--r-- | test/index.html | 4 | ||||
m--------- | test/qunit | 0 | ||||
-rw-r--r-- | test/unit/ajax.js | 12 | ||||
-rw-r--r-- | test/unit/attributes.js | 227 | ||||
-rw-r--r-- | test/unit/css.js | 12 | ||||
-rw-r--r-- | test/unit/event.js | 44 | ||||
-rw-r--r-- | test/unit/manipulation.js | 13 | ||||
-rw-r--r-- | test/unit/offset.js | 17 |
9 files changed, 233 insertions, 97 deletions
diff --git a/test/data/offset/fixed.html b/test/data/offset/fixed.html index 3181718da..81ba4ca7d 100644 --- a/test/data/offset/fixed.html +++ b/test/data/offset/fixed.html @@ -35,6 +35,7 @@ <body> <div id="fixed-1" class="fixed"></div> <div id="fixed-2" class="fixed"></div> + <div id="fixed-no-top-left" class="fixed"></div> <div id="forceScroll"></div> <div id="marker"></div> <p class="instructions">Click the white box to move the marker to it.</p> diff --git a/test/index.html b/test/index.html index c7c2ae55d..a10655089 100644 --- a/test/index.html +++ b/test/index.html @@ -203,6 +203,10 @@ Z</textarea> <select name="D4" disabled="disabled"> <option selected="selected" value="NO">NO</option> </select> + <input id="list-test" type="text" /> + <datalist id="datalist"> + <option value="option"></option> + </datalist> </form> <div id="moretests"> <form> diff --git a/test/qunit b/test/qunit new file mode 160000 +Subproject d404faf8f587fcbe6b8907943022e6318dd51e0 diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 2a2ac46a1..7c572a32c 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -492,7 +492,7 @@ test(".ajax() - hash", function() { test("jQuery ajax - cross-domain detection", function() { - expect( 5 ); + expect( 6 ); var loc = document.location, otherPort = loc.port === 666 ? 667 : 666, @@ -508,6 +508,7 @@ test("jQuery ajax - cross-domain detection", function() { }); jQuery.ajax({ + dataType: "jsonp", url: 'app:/path', beforeSend: function( _ , s ) { ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" ); @@ -535,6 +536,15 @@ test("jQuery ajax - cross-domain detection", function() { jQuery.ajax({ dataType: "jsonp", + url: "about:blank", + beforeSend: function( _ , s ) { + ok( s.crossDomain , "Test about:blank is detected as cross-domain" ); + return false; + } + }); + + jQuery.ajax({ + dataType: "jsonp", url: loc.protocol + "//" + loc.host, crossDomain: true, beforeSend: function( _ , s ) { diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 8cf47bed6..fa30ff042 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -3,38 +3,81 @@ module("attributes", { teardown: moduleTeardown }); var bareObj = function(value) { return value; }; var functionReturningObj = function(value) { return (function() { return value; }); }; -test("jQuery.props: itegrity test", function() { - - expect(1); - - // This must be maintained and equal jQuery.props - // Ensure that accidental or erroneous property - // overwrites don't occur - // This is simply for better code coverage and future proofing. - var propsShouldBe = { - "for": "htmlFor", - "class": "className", - readonly: "readOnly", - maxlength: "maxLength", - cellspacing: "cellSpacing", - rowspan: "rowSpan", - colspan: "colSpan", - tabindex: "tabIndex", - usemap: "useMap", - frameborder: "frameBorder" - }; - - same(propsShouldBe, jQuery.props, "jQuery.props passes integrity check"); +test("jQuery.attrFix integrity test", function() { + expect(1); + + // This must be maintained and equal jQuery.attrFix when appropriate + // Ensure that accidental or erroneous property + // overwrites don't occur + // This is simply for better code coverage and future proofing. + var propsShouldBe; + if ( !jQuery.support.getSetAttribute ) { + propsShouldBe = { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder" + }; + } else { + propsShouldBe = { + tabindex: "tabIndex", + readonly: "readOnly" + }; + } + + same(propsShouldBe, jQuery.attrFix, "jQuery.attrFix passes integrity check"); }); -test("attr(String)", function() { - expect(37); +test("prop(String, Object)", function() { + expect(19); + equals( jQuery('#text1').prop('value'), "Test", 'Check for value attribute' ); + equals( jQuery('#text1').prop('value', "Test2").prop('defaultValue'), "Test", 'Check for defaultValue attribute' ); + equals( jQuery('#select2').prop('selectedIndex'), 3, 'Check for selectedIndex attribute' ); + equals( jQuery('#foo').prop('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' ); + equals( jQuery('#foo').prop('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' ); + equals( jQuery("<option/>").prop("selected"), false, "Check selected attribute on disconnected element." ); + + var body = document.body, $body = jQuery( body ); + ok( $body.prop('nextSibling') === null, 'Make sure a null expando returns null' ); + body.foo = 'bar'; + equals( $body.prop('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' ); + body.foo = undefined; + ok( $body.prop('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' ); + + var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option"); + optgroup.appendChild( option ); + select.appendChild( optgroup ); + + equals( jQuery(option).prop("selected"), true, "Make sure that a single option is selected, even when in an optgroup." ); + equals( jQuery(document).prop("nodeName"), "#document", "prop works correctly on document nodes (bug #7451)." ); + + var attributeNode = document.createAttribute("irrelevant"), + commentNode = document.createComment("some comment"), + textNode = document.createTextNode("some text"), + obj = {}; + jQuery.each( [document, attributeNode, commentNode, textNode, obj, "#firstp"], function( i, ele ) { + strictEqual( jQuery(ele).prop("nonexisting"), undefined, "prop works correctly for non existing attributes (bug #7500)." ); + }); + + var obj = {}; + jQuery.each( [document, obj], function( i, ele ) { + var $ele = jQuery( ele ); + $ele.prop( "nonexisting", "foo" ); + equal( $ele.prop("nonexisting"), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." ); + }); + jQuery( document ).removeProp("nonexisting"); +}); - // This one sometimes fails randomly ?! - equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' ); +test("attr(String)", function() { + expect(32); - equals( jQuery('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' ); equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' ); equals( jQuery('#radio1').attr('type'), "radio", 'Check for type attribute' ); equals( jQuery('#check1').attr('type'), "checkbox", 'Check for type attribute' ); @@ -46,60 +89,58 @@ test("attr(String)", function() { equals( jQuery('#name').attr('name'), "name", 'Check for name attribute' ); equals( jQuery('#text1').attr('name'), "action", 'Check for name attribute' ); ok( jQuery('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' ); - // Temporarily disabled. See: #4299 - // ok( jQuery('#form').attr('action','newformaction').attr('action').indexOf("newformaction") >= 0, 'Check that action attribute was changed' ); + 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' ); + equals( jQuery('#testForm').attr('target'), undefined, 'Retrieving target does not equal the input with name=target' ); + equals( jQuery('#testForm').attr('target', 'newTarget').attr('target'), 'newTarget', 'Set target successfully on a form' ); + equals( jQuery('#testForm').removeAttr('id').attr('id'), undefined, 'Retrieving id does not equal the input with name=id after id is removed [#7472]' ); + // 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' ); - equals( jQuery('#select2').attr('selectedIndex'), 3, 'Check for selectedIndex attribute' ); - equals( jQuery('#foo').attr('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' ); - equals( jQuery('#foo').attr('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' ); // using innerHTML in IE causes href attribute to be serialized to the full path jQuery('<a/>').attr({ 'id': 'tAnchor5', 'href': '#5' }).appendTo('#main'); equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' ); - equals( jQuery("<option/>").attr("selected"), false, "Check selected attribute on disconnected element." ); - + // list attribute is readonly by default in browsers that support it + jQuery('#list-test').attr('list', 'datalist'); + equals( jQuery('#list-test').attr('list'), 'datalist', 'Check setting list attribute' ); // Related to [5574] and [5683] var body = document.body, $body = jQuery(body); - ok( $body.attr('foo') === undefined, 'Make sure that a non existent attribute returns undefined' ); - ok( $body.attr('nextSibling') === null, 'Make sure a null expando returns null' ); + strictEqual( $body.attr('foo'), undefined, 'Make sure that a non existent attribute returns undefined' ); body.setAttribute('foo', 'baz'); equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' ); - body.foo = 'bar'; - equals( $body.attr('foo'), 'bar', 'Make sure the expando is preferred over the dom attribute' ); - $body.attr('foo','cool'); equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' ); - body.foo = undefined; - ok( $body.attr('foo') === undefined, 'Make sure the expando is preferred over the dom attribute, even if undefined' ); - body.removeAttribute('foo'); // Cleanup var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option"); optgroup.appendChild( option ); select.appendChild( optgroup ); - equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." ); + var $img = jQuery('<img style="display:none" width="215" height="53" src="http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif"/>').appendTo('body'); + equals( $img.attr('width'), "215", "Retrieve width attribute an an element with display:none." ); + equals( $img.attr('height'), "53", "Retrieve height attribute an an element with display:none." ); + + // Check for style support + ok( !!~jQuery('#dl').attr('style').indexOf('position'), 'Check style attribute getter, also normalize css props to lowercase' ); + ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('position'), 'Check style setter' ); ok( jQuery("<div/>").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." ); - - equals( jQuery(document).attr("nodeName"), "#document", "attr works correctly on document nodes (bug #7451)." ); - - var attributeNode = document.createAttribute("irrelevant"), - commentNode = document.createComment("some comment"), - textNode = document.createTextNode("some text"), - obj = {}; - jQuery.each( [document, attributeNode, commentNode, textNode, obj, "#firstp"], function( i, ele ) { - strictEqual( jQuery(ele).attr("nonexisting"), undefined, "attr works correctly for non existing attributes (bug #7500)." ); - }); }); if ( !isLocal ) { @@ -116,8 +157,8 @@ if ( !isLocal ) { test("attr(String, Function)", function() { expect(2); - equals( jQuery('#text1').attr('value', function() { return this.id ;})[0].value, "text1", "Set value from id" ); - equals( jQuery('#text1').attr('title', function(i) { return i }).attr('title'), "0", "Set value with an index"); + equals( jQuery('#text1').attr('value', function() { return this.id; })[0].value, "text1", "Set value from id" ); + equals( jQuery('#text1').attr('title', function(i) { return i; }).attr('title'), "0", "Set value with an index"); }); test("attr(Hash)", function() { @@ -133,7 +174,7 @@ test("attr(Hash)", function() { }); test("attr(String, Object)", function() { - expect(30); + expect(29); var div = jQuery("div").attr("foo", "bar"), fail = false; @@ -153,7 +194,7 @@ test("attr(String, Object)", function() { jQuery("#name").attr('name', 'something'); equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' ); jQuery("#name").attr('name', null); - equals( jQuery("#name").attr('title'), '', 'Remove name attribute' ); + equals( jQuery("#name").attr('name'), undefined, 'Remove name attribute' ); jQuery("#check2").attr('checked', true); equals( document.getElementById('check2').checked, true, 'Set checked attribute' ); jQuery("#check2").attr('checked', false); @@ -163,28 +204,22 @@ test("attr(String, Object)", function() { jQuery("#text1").attr('readonly', false); equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' ); jQuery("#name").attr('maxlength', '5'); - equals( document.getElementById('name').maxLength, '5', 'Set maxlength attribute' ); + equals( document.getElementById('name').maxLength, 5, 'Set maxlength attribute' ); jQuery("#name").attr('maxLength', '10'); - equals( document.getElementById('name').maxLength, '10', 'Set maxlength attribute' ); - + equals( document.getElementById('name').maxLength, 10, 'Set maxlength attribute' ); + var $p = jQuery('#firstp').attr('nonexisting', 'foo'); + equals( $p.attr('nonexisting'), 'foo', "attr(name, value) works correctly for non existing attributes (bug #7500)."); + $p.removeAttr('nonexisting'); + var attributeNode = document.createAttribute("irrelevant"), commentNode = document.createComment("some comment"), - textNode = document.createTextNode("some text"), - obj = {}; - jQuery.each( [document, obj, "#firstp"], function( i, ele ) { - var $ele = jQuery( ele ); - $ele.attr( "nonexisting", "foo" ); - equal( $ele.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500)." ); - }); + textNode = document.createTextNode("some text"); + jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) { var $ele = jQuery( ele ); $ele.attr( "nonexisting", "foo" ); strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." ); }); - //cleanup - jQuery.each( [document, "#firstp"], function( i, ele ) { - jQuery( ele ).removeAttr("nonexisting"); - }); var table = jQuery('#table').append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"), td = table.find('td:first'); @@ -193,15 +228,15 @@ test("attr(String, Object)", function() { td.attr("colspan", "2"); equals( td[0].colSpan, 2, "Check colspan is correctly set" ); table.attr("cellspacing", "2"); - equals( table[0].cellSpacing, 2, "Check cellspacing is correctly set" ); + equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" ); // for #1070 jQuery("#name").attr('someAttr', '0'); equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' ); jQuery("#name").attr('someAttr', 0); - equals( jQuery("#name").attr('someAttr'), 0, 'Set attribute to the number 0' ); + equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to the number 0' ); jQuery("#name").attr('someAttr', 1); - equals( jQuery("#name").attr('someAttr'), 1, 'Set attribute to the number 1' ); + equals( jQuery("#name").attr('someAttr'), '1', 'Set attribute to the number 1' ); // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); @@ -211,7 +246,8 @@ test("attr(String, Object)", function() { j.removeAttr("name"); QUnit.reset(); - + + // Type var type = jQuery("#check2").attr('type'); var thrown = false; try { @@ -251,6 +287,13 @@ test("attr(String, Object)", function() { } ok( thrown, "Exception thrown when trying to change type property" ); equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" ); + + // Setting attributes on svg elements (bug #3116) + var $svg = jQuery('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" width="3000" height="3000">' + + '<circle cx="200" cy="200" r="150" />' + + '</svg>').appendTo('body'); + equals( $svg.attr('cx', 100).attr('cx'), "100", "Set attribute on svg element" ); + $svg.remove(); }); test("attr(jquery_method)", function(){ @@ -356,25 +399,32 @@ test("attr('tabindex', value)", function() { }); test("removeAttr(String)", function() { - expect(7); + expect(5); equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" ); + equals( jQuery('#form').removeAttr('id').attr('id'), undefined, 'Remove id' ); + 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' ); +}); +test("removeProp(String)", function() { + expect(6); var attributeNode = document.createAttribute("irrelevant"), commentNode = document.createComment("some comment"), textNode = document.createTextNode("some text"), obj = {}; - //removeAttr only really removes on DOM element nodes handle all other seperatyl - strictEqual( jQuery( "#firstp" ).attr( "nonexisting", "foo" ).removeAttr( "nonexisting" )[0].nonexisting, undefined, "removeAttr works correctly on DOM element nodes" ); + + strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[0].nonexisting, undefined, "removeprop works correctly on DOM element nodes" ); jQuery.each( [document, obj], function( i, ele ) { var $ele = jQuery( ele ); - $ele.attr( "nonexisting", "foo" ).removeAttr( "nonexisting" ); - strictEqual( ele.nonexisting, "", "removeAttr works correctly on non DOM element nodes (bug #7500)." ); + $ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" ); + strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." ); }); jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) { $ele = jQuery( ele ); - $ele.attr( "nonexisting", "foo" ).removeAttr( "nonexisting" ); - strictEqual( ele.nonexisting, undefined, "removeAttr works correctly on non DOM element nodes (bug #7500)." ); + $ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" ); + strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." ); }); }); @@ -604,21 +654,20 @@ test("addClass(Function)", function() { test("addClass(Function) with incoming value", function() { expect(45); - var div = jQuery("div"), old = div.map(function(){ - return jQuery(this).attr("class"); + return jQuery(this).attr("class") || ""; }); - + div.addClass(function(i, val) { - if ( this.id !== "_firebugConsole" ) { + if ( this.id !== "_firebugConsole") { equals( val, old[i], "Make sure the incoming value is correct." ); return "test"; } }); var pass = true; - for ( var i = 0; i < div.size(); i++ ) { - if ( div.get(i).className.indexOf("test") == -1 ) pass = false; + for ( var i = 0; i < div.length; i++ ) { + if ( div.get(i).className.indexOf("test") == -1 ) pass = false; } ok( pass, "Add Class" ); }); @@ -843,4 +892,4 @@ test("addClass, removeClass, hasClass", function() { ok( jq.hasClass("cla.ss3")==false, "Check the dotted class has been removed" ); jq.removeClass("class4"); ok( jq.hasClass("class4")==false, "Check the class has been properly removed" ); -}); +});
\ No newline at end of file diff --git a/test/unit/css.js b/test/unit/css.js index 555f13575..8ae8fcb34 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -333,3 +333,15 @@ test("internal ref to elem.runtimeStyle (bug #7608)", function () { ok( result, "elem.runtimeStyle does not throw exception" ); }); + +test("marginRight computed style (bug #3333)", function() { + expect(1); + + var $div = jQuery("#foo"); + $div.css({ + width: "1px", + marginRight: 0 + }); + + equals($div.css("marginRight"), "0px"); +}); diff --git a/test/unit/event.js b/test/unit/event.js index b7b260462..2a6d8a669 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -683,6 +683,20 @@ test("hover()", function() { equals( times, 4, "hover handlers fired" ); }); +test("mouseover triggers mouseenter", function() { + expect(1); + + var count = 0, + elem = jQuery("<a />"); + elem.mouseenter(function () { + count++; + }); + elem.trigger('mouseover'); + equals(count, 1, "make sure mouseover triggers a mouseenter" ); + + elem.remove(); +}); + test("trigger() shortcuts", function() { expect(6); @@ -1966,6 +1980,36 @@ test("window resize", function() { ok( !jQuery._data(window, "__events__"), "Make sure all the events are gone." ); }); +test("focusin bubbles", function() { + expect(5); + + var input = jQuery( '<input type="text" />' ).prependTo( "body" ), + order = 0; + + jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){ + equals( 1, order++, "focusin on the body second" ); + }); + + input.bind( "focusin.focusinBubblesTest", function(){ + equals( 0, order++, "focusin on the element first" ); + }); + + // DOM focus method + input[0].focus(); + + // To make the next focus test work, we need to take focus off the input. + // This will fire another focusin event, so set order to reflect that. + order = 1; + jQuery("#text1")[0].focus(); + + // jQuery trigger, which calls DOM focus + order = 0; + input.trigger( "focus" ); + + input.remove(); + jQuery( "body" ).unbind( "focusin.focusinBubblesTest" ); +}); + /* test("jQuery(function($) {})", function() { stop(); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 34425ed3a..e972a4792 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -739,7 +739,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() { }); var testReplaceWith = function(val) { - expect(20); + expect(21); jQuery('#yahoo').replaceWith(val( '<b id="replace">buga</b>' )); ok( jQuery("#replace")[0], 'Replace element with string' ); ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after string' ); @@ -800,6 +800,9 @@ var testReplaceWith = function(val) { equals( set[0].nodeName.toLowerCase(), "span", "Replace the disconnected node." ); equals( set.length, 1, "Replace the disconnected node." ); + var non_existant = jQuery('#does-not-exist').replaceWith( val("<b>should not throw an error</b>") ); + equals( non_existant.length, 0, "Length of non existant element." ); + var $div = jQuery("<div class='replacewith'></div>").appendTo("body"); // TODO: Work on jQuery(...) inline script execution //$div.replaceWith("<div class='replacewith'></div><script>" + @@ -827,7 +830,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() { test("replaceWith(Function)", function() { testReplaceWith(functionReturningObj); - expect(21); + expect(22); var y = jQuery("#yahoo")[0]; @@ -1006,7 +1009,7 @@ test("clone()", function() { }); test("clone(form element) (Bug #3879, #6655)", function() { - expect(6); + expect(5); var element = jQuery("<select><option>Foo</option><option selected>Bar</option></select>"); equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" ); @@ -1016,7 +1019,9 @@ test("clone(form element) (Bug #3879, #6655)", function() { equals( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" ); equals( clone[0].defaultValue, "foo", "Checked input defaultValue cloned correctly" ); - equals( clone[0].defaultChecked, !jQuery.support.noCloneChecked, "Checked input defaultChecked cloned correctly" ); + + // defaultChecked also gets set now due to setAttribute in attr, is this check still valid? + // equals( clone[0].defaultChecked, !jQuery.support.noCloneChecked, "Checked input defaultChecked cloned correctly" ); element = jQuery("<input type='text' value='foo'>"); clone = element.clone(); diff --git a/test/unit/offset.js b/test/unit/offset.js index 329d69f95..ae0518849 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -265,7 +265,7 @@ testoffset("static", function( jQuery ) { }); testoffset("fixed", function( jQuery ) { - expect(28); + expect(30); jQuery.offset.initialize(); @@ -320,6 +320,17 @@ testoffset("fixed", function( jQuery ) { ok( true, 'Fixed position is not supported' ); } }); + + // Bug 8316 + var $noTopLeft = jQuery('#fixed-no-top-left'); + if ( jQuery.offset.supportsFixedPosition ) { + equals( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" ); + equals( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" ); + } else { + // need to have same number of assertions + ok( true, 'Fixed position is not supported' ); + ok( true, 'Fixed position is not supported' ); + } }); testoffset("table", function( jQuery ) { @@ -422,7 +433,7 @@ test("offsetParent", function(){ equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); }); -function testoffset(name, fn) { +function testoffset( name, fn ) { test(name, function() { // pause execution for now @@ -447,7 +458,7 @@ function testoffset(name, fn) { function loadFixture() { var src = './data/offset/' + name + '.html?' + parseInt( Math.random()*1000, 10 ), iframe = jQuery('<iframe />').css({ - width: 500, height: 500, position: 'absolute', top: -600, left: -600, visiblity: 'hidden' + width: 500, height: 500, position: 'absolute', top: -600, left: -600, visibility: 'hidden' }).appendTo('body')[0]; iframe.contentWindow.location = src; return iframe; |