Added test for #968
[jquery.git] / src / jquery / coreTest.js
index 7466c4c..77fd17e 100644 (file)
@@ -11,6 +11,99 @@ test("Basic requirements", function() {
        ok( $, "$()" );\r
 });\r
 \r
+test("$()", function() {\r
+       var main = $("#main");\r
+       isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );\r
+       \r
+       // make sure this is handled\r
+       $('<p>\r\n</p>');\r
+});\r
+\r
+test("isFunction", function() {\r
+       expect(21);\r
+\r
+       // Make sure that false values return false\r
+       ok( !jQuery.isFunction(), "No Value" );\r
+       ok( !jQuery.isFunction( null ), "null Value" );\r
+       ok( !jQuery.isFunction( undefined ), "undefined Value" );\r
+       ok( !jQuery.isFunction( "" ), "Empty String Value" );\r
+       ok( !jQuery.isFunction( 0 ), "0 Value" );\r
+\r
+       // Check built-ins\r
+       // Safari uses "(Internal Function)"\r
+       ok( jQuery.isFunction(String), "String Function" );\r
+       ok( jQuery.isFunction(Array), "Array Function" );\r
+       ok( jQuery.isFunction(Object), "Object Function" );\r
+       ok( jQuery.isFunction(Function), "Function Function" );\r
+\r
+       // When stringified, this could be misinterpreted\r
+       var mystr = "function";\r
+       ok( !jQuery.isFunction(mystr), "Function String" );\r
+\r
+       // When stringified, this could be misinterpreted\r
+       var myarr = [ "function" ];\r
+       ok( !jQuery.isFunction(myarr), "Function Array" );\r
+\r
+       // When stringified, this could be misinterpreted\r
+       var myfunction = { "function": "test" };\r
+       ok( !jQuery.isFunction(myfunction), "Function Object" );\r
+\r
+       // Make sure normal functions still work\r
+       var fn = function(){};\r
+       ok( jQuery.isFunction(fn), "Normal Function" );\r
+\r
+       var obj = document.createElement("object");\r
+\r
+       // Firefox says this is a function\r
+       ok( !jQuery.isFunction(obj), "Object Element" );\r
+\r
+       // IE says this is an object\r
+       ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );\r
+\r
+       var nodes = document.body.childNodes;\r
+\r
+       // Safari says this is a function\r
+       ok( !jQuery.isFunction(nodes), "childNodes Property" );\r
+\r
+       var first = document.body.firstChild;\r
+       \r
+       // Normal elements are reported ok everywhere\r
+       ok( !jQuery.isFunction(first), "A normal DOM Element" );\r
+\r
+       var input = document.createElement("input");\r
+       input.type = "text";\r
+       document.body.appendChild( input );\r
+\r
+       // IE says this is an object\r
+       ok( jQuery.isFunction(input.focus), "A default function property" );\r
+\r
+       document.body.removeChild( input );\r
+\r
+       var a = document.createElement("a");\r
+       a.href = "some-function";\r
+       document.body.appendChild( a );\r
+\r
+       // This serializes with the word 'function' in it\r
+       ok( !jQuery.isFunction(a), "Anchor Element" );\r
+\r
+       document.body.removeChild( a );\r
+\r
+       // Recursive function calls have lengths and array-like properties\r
+       function callme(callback){\r
+               function fn(response){\r
+                       callback(response);\r
+               }\r
+\r
+               ok( jQuery.isFunction(fn), "Recursive Function Call" );\r
+\r
+               fn({ some: "data" });\r
+       };\r
+\r
+       callme(function(){\r
+               callme(function(){});\r
+       });\r
+});\r
+\r
 test("length", function() {\r
        ok( $("div").length == 2, "Get Number of Elements Found" );\r
 });\r
@@ -27,6 +120,20 @@ test("get(Number)", function() {
        ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );\r
 });\r
 \r
+test("add(String|Element|Array)", function() {\r
+       isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );\r
+       isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );\r
+       ok( $([]).add($("#form")[0].elements).length > 13, "Check elements from array" );\r
+       \r
+       var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));\r
+       ok( x[0].id == "x1", "Check on-the-fly element1" );\r
+       ok( x[1].id == "x2", "Check on-the-fly element2" );\r
+       \r
+       var x = $([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");\r
+       ok( x[0].id == "x1", "Check on-the-fly element1" );\r
+       ok( x[1].id == "x2", "Check on-the-fly element2" );\r
+});\r
+\r
 test("each(Function)", function() {\r
        expect(1);\r
        var div = $("div");\r
@@ -52,7 +159,7 @@ test("index(Object)", function() {
 });\r
 \r
 test("attr(String)", function() {\r
-       expect(12);\r
+       expect(13);\r
        ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );\r
        ok( $('#text1').attr('type') == "text", 'Check for type attribute' );\r
        ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );\r
@@ -65,11 +172,27 @@ test("attr(String)", function() {
        ok( $('#name').attr('name') == "name", 'Check for name attribute' );\r
        ok( $('#text1').attr('name') == "action", 'Check for name attribute' );\r
        ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
+       \r
+       $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path\r
+       ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' );\r
 });\r
 \r
+if ( location.protocol != "file:" ) {\r
+       test("attr(String) in XML Files", function() {\r
+               expect(2);\r
+               stop();\r
+               $.get("data/dashboard.xml", function(xml) {\r
+                       ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );\r
+                       ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );\r
+                       start();\r
+               });\r
+       });\r
+}\r
+\r
 test("attr(String, Function)", function() {\r
-       expect(1);\r
+       expect(2);\r
        ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" );\r
+       ok( $('#text1').attr('title', function(i) { return i }).attr('title') == "0", "Set value with an index");\r
 });\r
 \r
 test("attr(Hash)", function() {\r
@@ -82,7 +205,7 @@ test("attr(Hash)", function() {
 });\r
 \r
 test("attr(String, Object)", function() {\r
-       expect(6);\r
+       expect(7);\r
        var div = $("div");\r
        div.attr("foo", "bar");\r
        var pass = true;\r
@@ -90,6 +213,8 @@ test("attr(String, Object)", function() {
          if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;\r
        }\r
        ok( pass, "Set Attribute" );\r
+\r
+       ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" );    \r
        \r
        $("#name").attr('name', 'something');\r
        ok( $("#name").attr('name') == 'something', 'Set name attribute' );\r
@@ -120,7 +245,7 @@ if ( location.protocol != "file:" ) {
 }\r
 \r
 test("css(String|Hash)", function() {\r
-       expect(8);\r
+       expect(19);\r
        \r
        ok( $('#main').css("display") == 'none', 'Check for css property "display"');\r
        \r
@@ -138,10 +263,19 @@ test("css(String|Hash)", function() {
        ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');\r
        $('#floatTest').css({'font-size': '30px'});\r
        ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');\r
+       \r
+       $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {\r
+               $('#foo').css({opacity: n});\r
+               ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );\r
+               $('#foo').css({opacity: parseFloat(n)});\r
+               ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );\r
+       });     \r
+       $('#foo').css({opacity: ''});\r
+       ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );\r
 });\r
 \r
 test("css(String, Object)", function() {\r
-       expect(7);\r
+       expect(18);\r
        ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');\r
        $('#foo').css('display', 'none');\r
        ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');\r
@@ -156,6 +290,15 @@ test("css(String, Object)", function() {
        ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');\r
        $('#floatTest').css('font-size', '20px');\r
        ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');\r
+       \r
+       $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {\r
+               $('#foo').css('opacity', n);\r
+               ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );\r
+               $('#foo').css('opacity', parseFloat(n));\r
+               ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );\r
+       });\r
+       $('#foo').css('opacity', '');\r
+       ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );\r
 });\r
 \r
 test("text()", function() {\r
@@ -178,7 +321,7 @@ test("wrap(String|Element)", function() {
 });\r
 \r
 test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
-       expect(5);\r
+       expect(12);\r
        var defaultText = 'Try them out:'\r
        var result = $('#first').append('<b>buga</b>');\r
        ok( result.text() == defaultText + 'buga', 'Check if text appending works' );\r
@@ -198,6 +341,57 @@ test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
        $('#sap').append($("#first, #yahoo"));\r
        ok( expected == $('#sap').text(), "Check for appending of jQuery object" );\r
+\r
+       reset();\r
+       $("#sap").append( 5 );\r
+       ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
+\r
+       reset();\r
+       $("#sap").append( " text with spaces " );\r
+       ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );\r
+\r
+       reset();\r
+       ok( $("#sap").append([]), "Check for appending an empty array." );\r
+       ok( $("#sap").append(""), "Check for appending an empty string." );\r
+       ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
+       \r
+       reset();\r
+       $("#sap").append(document.getElementById('form'));\r
+       ok( $("#sap>form").size() == 1, "Check for appending a form" );  // Bug #910\r
+\r
+       reset();\r
+       var pass = true;\r
+       try {\r
+               $( $("iframe")[0].contentWindow.document.body ).append("<div>test</div>");\r
+       } catch(e) {\r
+               pass = false;\r
+       }\r
+\r
+       ok( pass, "Test for appending a DOM node to the contents of an IFrame" );\r
+       \r
+});\r
+\r
+test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
+       expect(5);\r
+       var defaultText = 'Try them out:'\r
+       $('<b>buga</b>').appendTo('#first');\r
+       ok( $("#first").text() == defaultText + 'buga', 'Check if text appending works' );\r
+       ok( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');\r
+       \r
+       reset();\r
+       expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";\r
+       $(document.getElementById('first')).appendTo('#sap');\r
+       ok( expected == $('#sap').text(), "Check for appending of element" );\r
+       \r
+       reset();\r
+       expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
+       $([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');\r
+       ok( expected == $('#sap').text(), "Check for appending of array of elements" );\r
+       \r
+       reset();\r
+       expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
+       $("#first, #yahoo").appendTo('#sap');\r
+       ok( expected == $('#sap').text(), "Check for appending of jQuery object" );\r
 });\r
 \r
 test("prepend(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
@@ -223,6 +417,29 @@ test("prepend(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );\r
 });\r
 \r
+test("prependTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
+       expect(5);\r
+       var defaultText = 'Try them out:'\r
+       $('<b>buga</b>').prependTo('#first');\r
+       ok( $('#first').text() == 'buga' + defaultText, 'Check if text prepending works' );\r
+       ok( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');\r
+       \r
+       reset();\r
+       expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";\r
+       $(document.getElementById('first')).prependTo('#sap');\r
+       ok( expected == $('#sap').text(), "Check for prepending of element" );\r
+\r
+       reset();\r
+       expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
+       $([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');\r
+       ok( expected == $('#sap').text(), "Check for prepending of array of elements" );\r
+       \r
+       reset();\r
+       expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";\r
+       $("#yahoo, #first").prependTo('#sap');\r
+       ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );\r
+});\r
+\r
 test("before(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
        expect(4);\r
        var expected = 'This is a normal link: bugaYahoo';\r
@@ -245,6 +462,28 @@ test("before(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        ok( expected == $('#en').text(), "Insert jQuery before" );\r
 });\r
 \r
+test("insertBefore(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
+       expect(4);\r
+       var expected = 'This is a normal link: bugaYahoo';\r
+       $('<b>buga</b>').insertBefore('#yahoo');\r
+       ok( expected == $('#en').text(), 'Insert String before' );\r
+       \r
+       reset();\r
+       expected = "This is a normal link: Try them out:Yahoo";\r
+       $(document.getElementById('first')).insertBefore('#yahoo');\r
+       ok( expected == $('#en').text(), "Insert element before" );\r
+       \r
+       reset();\r
+       expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
+       $([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');\r
+       ok( expected == $('#en').text(), "Insert array of elements before" );\r
+       \r
+       reset();\r
+       expected = "This is a normal link: Try them out:diveintomarkYahoo";\r
+       $("#first, #mark").insertBefore('#yahoo');\r
+       ok( expected == $('#en').text(), "Insert jQuery before" );\r
+});\r
+\r
 test("after(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
        expect(4);\r
        var expected = 'This is a normal link: Yahoobuga';\r
@@ -267,10 +506,36 @@ test("after(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        ok( expected == $('#en').text(), "Insert jQuery after" );\r
 });\r
 \r
+test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
+       expect(4);\r
+       var expected = 'This is a normal link: Yahoobuga';\r
+       $('<b>buga</b>').insertAfter('#yahoo');\r
+       ok( expected == $('#en').text(), 'Insert String after' );\r
+       \r
+       reset();\r
+       expected = "This is a normal link: YahooTry them out:";\r
+       $(document.getElementById('first')).insertAfter('#yahoo');\r
+       ok( expected == $('#en').text(), "Insert element after" );\r
+\r
+       reset();\r
+       expected = "This is a normal link: YahooTry them out:diveintomark";\r
+       $([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');\r
+       ok( expected == $('#en').text(), "Insert array of elements after" );\r
+       \r
+       reset();\r
+       expected = "This is a normal link: YahooTry them out:diveintomark";\r
+       $("#mark, #first").insertAfter('#yahoo');\r
+       ok( expected == $('#en').text(), "Insert jQuery after" );\r
+});\r
+\r
 test("end()", function() {\r
-       expect(2);\r
+       expect(3);\r
        ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );\r
        ok( $('#yahoo').end(), 'Check for end with nothing to end' );\r
+       \r
+       var x = $('#yahoo');\r
+       x.parent();\r
+       ok( 'Yahoo' == $('#yahoo').text(), 'Check for non-destructive behaviour' );\r
 });\r
 \r
 test("find(String)", function() {\r
@@ -286,7 +551,7 @@ test("clone()", function() {
 });\r
 \r
 test("is(String)", function() {\r
-       expect(22);\r
+       expect(26);\r
        ok( $('#form').is('form'), 'Check for element: A form must be a form' );\r
        ok( !$('#form').is('div'), 'Check for element: A form is not a div' );\r
        ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );\r
@@ -309,6 +574,12 @@ test("is(String)", function() {
        ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );\r
        ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );\r
        ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );\r
+       \r
+       // test is() with comma-seperated expressions\r
+       ok( $('#en').is('[@lang="en"],[@lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+       ok( $('#en').is('[@lang="de"],[@lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+       ok( $('#en').is('[@lang="en"] , [@lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
+       ok( $('#en').is('[@lang="de"] , [@lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );\r
 });\r
 \r
 test("$.extend(Object, Object)", function() {\r
@@ -364,18 +635,18 @@ test("html(String)", function() {
 });\r
 \r
 test("filter()", function() {\r
-       expect(5);\r
+       expect(4);\r
        isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
-       isSet( $("p").filter(["#ap", "#sndp"]).get(), q("ap", "sndp"), "filter(Array&lt;String&gt;)" );\r
        isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );\r
        isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );\r
        isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
 });\r
 \r
-test("not(String)", function() {\r
-       expect(2);\r
+test("not()", function() {\r
+       expect(3);\r
        ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );\r
-       isSet( $("p").not("#ap, #sndp").get(), q("firstp", "en", "sap", "first", "result"), "not('selector, selector')" );\r
+       isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );\r
+       isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );\r
 });\r
 \r
 \r
@@ -478,3 +749,89 @@ test("text(String)", function() {
        expect(1);\r
        ok( $("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML == "&lt;div&gt;&lt;b&gt;Hello&lt;/b&gt; cruel world!&lt;/div&gt;", "Check escaped text" );\r
 });\r
+\r
+test("$.each(Object,Function)", function() {\r
+       expect(8);\r
+       $.each( [0,1,2], function(i, n){\r
+               ok( i == n, "Check array iteration" );\r
+       });\r
+       \r
+       $.each( [5,6,7], function(i, n){\r
+               ok( i == n - 5, "Check array iteration" );\r
+       });\r
+        \r
+       $.each( { name: "name", lang: "lang" }, function(i, n){\r
+               ok( i == n, "Check object iteration" );\r
+       });\r
+});\r
+\r
+test("$.prop", function() {\r
+       expect(2);\r
+       var handle = function() { return this.id };\r
+       ok( $.prop($("#ap")[0], handle) == "ap", "Check with Function argument" );\r
+       ok( $.prop($("#ap")[0], "value") == "value", "Check with value argument" );\r
+});\r
+\r
+test("$.className", function() {\r
+       expect(6);\r
+       var x = $("<p>Hi</p>")[0];\r
+       var c = $.className;\r
+       c.add(x, "hi");\r
+       ok( x.className == "hi", "Check single added class" );\r
+       c.add(x, "foo bar");\r
+       ok( x.className == "hi foo bar", "Check more added classes" );\r
+       c.remove(x);\r
+       ok( x.className == "", "Remove all classes" );\r
+       c.add(x, "hi foo bar");\r
+       c.remove(x, "foo");\r
+       ok( x.className == "hi bar", "Check removal of one class" );\r
+       ok( c.has(x, "hi"), "Check has1" );\r
+       ok( c.has(x, "bar"), "Check has2" );\r
+});\r
+\r
+test("remove()", function() {\r
+       $("#ap").children().remove();\r
+       ok( $("#ap").text().length > 10, "Check text is not removed" );\r
+       ok( $("#ap").children().length == 0, "Check remove" );\r
+       \r
+       reset();\r
+       $("#ap").children().remove("a");\r
+       ok( $("#ap").text().length > 10, "Check text is not removed" );\r
+       ok( $("#ap").children().length == 1, "Check filtered remove" );\r
+});\r
+\r
+test("empty()", function() {\r
+       ok( $("#ap").children().empty().text().length == 0, "Check text is removed" );\r
+       ok( $("#ap").children().length == 4, "Check elements are not removed" );\r
+});\r
+\r
+test("eq(), gt(), lt(), contains()", function() {\r
+       ok( $("#ap a").eq(1)[0].id == "groups", "eq()" );\r
+       isSet( $("#ap a").gt(0).get(), q("groups", "anchor1", "mark"), "gt()" );\r
+       isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" );\r
+       isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" );\r
+});\r
+\r
+test("click() context", function() {\r
+       $('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {\r
+           var close = $('spanx', this); // same with $(this).find('span');\r
+           ok( close.length == 0, "Element does not exist, length must be zero" );\r
+           ok( !close[0], "Element does not exist, direct access to element must return undefined" );\r
+           //console.log( close[0]); // it's the <a> and not a <span> element\r
+           return false;\r
+       }).click();\r
+});\r
+\r
+test("$().html().evalScripts() Eval's Scripts Twice in Firefox, see #975", function() {\r
+       expect(1);\r
+       $("#main").html('<script type="text/javascript">ok( true, "execute script" );</script>').evalScripts();\r
+});\r
+\r
+test("$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968", function() {\r
+       var f = frames["iframe"].document;\r
+    f.open();\r
+    f.write("<html><body></body></html>");\r
+    f.close();\r
+    $("<div>Testing</div>").appendTo(f.body);\r
+    ok( true, "passed" );\r
+});
\ No newline at end of file