db47856095e3a2f2ce98af219b3b24c083e7f2bb
[jquery.git] / src / jquery / coreTest.js
1 module("core");
2
3 test("Basic requirements", function() {
4         expect(7);
5         ok( Array.prototype.push, "Array.push()" );
6         ok( Function.prototype.apply, "Function.apply()" );
7         ok( document.getElementById, "getElementById" );
8         ok( document.getElementsByTagName, "getElementsByTagName" );
9         ok( RegExp, "RegExp" );
10         ok( jQuery, "jQuery" );
11         ok( $, "$()" );
12 });
13
14 test("$()", function() {
15         expect(5);
16         
17         var main = $("#main");
18         isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
19         
20         // make sure this is handled
21         $('<p>\r\n</p>');
22         ok( true, "Check for \\r and \\n in jQuery()" );
23         
24         /* // Disabled until we add this functionality in
25         var pass = true;
26         try {
27                 $("<div>Testing</div>").appendTo(document.getElementById("iframe").contentDocument.body);
28         } catch(e){
29                 pass = false;
30         }
31         ok( pass, "$('&lt;tag&gt;') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
32
33         var code = $("<code/>");
34         equals( code.length, 1, "Correct number of elements generated for code" );
35         var img = $("<img/>");
36         equals( img.length, 1, "Correct number of elements generated for img" );
37         var div = $("<div/><hr/><code/><b/>");
38         equals( div.length, 4, "Correct number of elements generated for div hr code b" );
39 });
40
41 test("isFunction", function() {
42         expect(21);
43
44         // Make sure that false values return false
45         ok( !jQuery.isFunction(), "No Value" );
46         ok( !jQuery.isFunction( null ), "null Value" );
47         ok( !jQuery.isFunction( undefined ), "undefined Value" );
48         ok( !jQuery.isFunction( "" ), "Empty String Value" );
49         ok( !jQuery.isFunction( 0 ), "0 Value" );
50
51         // Check built-ins
52         // Safari uses "(Internal Function)"
53         ok( jQuery.isFunction(String), "String Function" );
54         ok( jQuery.isFunction(Array), "Array Function" );
55         ok( jQuery.isFunction(Object), "Object Function" );
56         ok( jQuery.isFunction(Function), "Function Function" );
57
58         // When stringified, this could be misinterpreted
59         var mystr = "function";
60         ok( !jQuery.isFunction(mystr), "Function String" );
61
62         // When stringified, this could be misinterpreted
63         var myarr = [ "function" ];
64         ok( !jQuery.isFunction(myarr), "Function Array" );
65
66         // When stringified, this could be misinterpreted
67         var myfunction = { "function": "test" };
68         ok( !jQuery.isFunction(myfunction), "Function Object" );
69
70         // Make sure normal functions still work
71         var fn = function(){};
72         ok( jQuery.isFunction(fn), "Normal Function" );
73
74         var obj = document.createElement("object");
75
76         // Firefox says this is a function
77         ok( !jQuery.isFunction(obj), "Object Element" );
78
79         // IE says this is an object
80         ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );
81
82         var nodes = document.body.childNodes;
83
84         // Safari says this is a function
85         ok( !jQuery.isFunction(nodes), "childNodes Property" );
86
87         var first = document.body.firstChild;
88         
89         // Normal elements are reported ok everywhere
90         ok( !jQuery.isFunction(first), "A normal DOM Element" );
91
92         var input = document.createElement("input");
93         input.type = "text";
94         document.body.appendChild( input );
95
96         // IE says this is an object
97         ok( jQuery.isFunction(input.focus), "A default function property" );
98
99         document.body.removeChild( input );
100
101         var a = document.createElement("a");
102         a.href = "some-function";
103         document.body.appendChild( a );
104
105         // This serializes with the word 'function' in it
106         ok( !jQuery.isFunction(a), "Anchor Element" );
107
108         document.body.removeChild( a );
109
110         // Recursive function calls have lengths and array-like properties
111         function callme(callback){
112                 function fn(response){
113                         callback(response);
114                 }
115
116                 ok( jQuery.isFunction(fn), "Recursive Function Call" );
117
118         fn({ some: "data" });
119         };
120
121         callme(function(){
122         callme(function(){});
123         });
124 });
125
126 test("$('html')", function() {
127         expect(2);
128         
129         reset();
130         ok( $("<script>var foo='test';</script>")[0], "Creating a script" );
131         
132         reset();
133         ok( $("<link rel='stylesheet'/>")[0], "Creating a link" );
134         
135         reset();
136 });
137
138 test("length", function() {
139         expect(1);
140         ok( $("p").length == 6, "Get Number of Elements Found" );
141 });
142
143 test("size()", function() {
144         expect(1);
145         ok( $("p").size() == 6, "Get Number of Elements Found" );
146 });
147
148 test("get()", function() {
149         expect(1);
150         isSet( $("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
151 });
152
153 test("get(Number)", function() {
154         expect(1);
155         ok( $("p").get(0) == document.getElementById("firstp"), "Get A Single Element" );
156 });
157
158 test("add(String|Element|Array)", function() {
159         expect(7);
160         isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
161         isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
162         ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
163         
164         var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));
165         ok( x[0].id == "x1", "Check on-the-fly element1" );
166         ok( x[1].id == "x2", "Check on-the-fly element2" );
167         
168         var x = $([]).add("<p id='x1'>xxx</p>").add("<p id='x2'>xxx</p>");
169         ok( x[0].id == "x1", "Check on-the-fly element1" );
170         ok( x[1].id == "x2", "Check on-the-fly element2" );
171 });
172
173 test("each(Function)", function() {
174         expect(1);
175         var div = $("div");
176         div.each(function(){this.foo = 'zoo';});
177         var pass = true;
178         for ( var i = 0; i < div.size(); i++ ) {
179           if ( div.get(i).foo != "zoo" ) pass = false;
180         }
181         ok( pass, "Execute a function, Relative" );
182 });
183
184 test("index(Object)", function() {
185         expect(8);
186         ok( $([window, document]).index(window) == 0, "Check for index of elements" );
187         ok( $([window, document]).index(document) == 1, "Check for index of elements" );
188         var inputElements = $('#radio1,#radio2,#check1,#check2');
189         ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
190         ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
191         ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
192         ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
193         ok( inputElements.index(window) == -1, "Check for not found index" );
194         ok( inputElements.index(document) == -1, "Check for not found index" );
195 });
196
197 test("attr(String)", function() {
198         expect(13);
199         ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
200         ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
201         ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
202         ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
203         ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
204         ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
205         ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
206         ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
207         ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
208         ok( $('#name').attr('name') == "name", 'Check for name attribute' );
209         ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
210         ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
211         
212         $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path
213         ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' );
214 });
215
216 test("attr(String) in XML Files", function() {
217         expect(2);
218         stop();
219         $.get("data/dashboard.xml", function(xml) {
220                 ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
221                 ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );
222                 start();
223         });
224 });
225
226 test("attr(String, Function)", function() {
227         expect(2);
228         ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" );
229         ok( $('#text1').attr('title', function(i) { return i }).attr('title') == "0", "Set value with an index");
230 });
231
232 test("attr(Hash)", function() {
233         expect(1);
234         var pass = true;
235         $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
236           if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
237         });
238         ok( pass, "Set Multiple Attributes" );
239 });
240
241 test("attr(String, Object)", function() {
242         expect(12);
243         var div = $("div");
244         div.attr("foo", "bar");
245         var pass = true;
246         for ( var i = 0; i < div.size(); i++ ) {
247           if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
248         }
249         ok( pass, "Set Attribute" );
250
251         ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" );    
252         
253         $("#name").attr('name', 'something');
254         ok( $("#name").attr('name') == 'something', 'Set name attribute' );
255         $("#check2").attr('checked', true);
256         ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
257         $("#check2").attr('checked', false);
258         ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
259         $("#text1").attr('readonly', true);
260         ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
261         $("#text1").attr('readonly', false);
262         ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
263         $("#name").attr('maxlength', '5');
264         ok( document.getElementById('name').maxLength == '5', 'Set maxlength attribute' );
265
266         reset();
267
268         var type = $("#check2").attr('type');
269         var thrown = false;
270         try {
271                 $("#check2").attr('type','hidden');
272         } catch(e) {
273                 thrown = true;
274         }
275         ok( thrown, "Exception thrown when trying to change type property" );
276         equals( type, $("#check2").attr('type'), "Verify that you can't change the type of an input element" );
277
278         var check = document.createElement("input");
279         var thrown = true;
280         try {
281                 $(check).attr('type','checkbox');
282         } catch(e) {
283                 thrown = false;
284         }
285         ok( thrown, "Exception thrown when trying to change type property" );
286         equals( "checkbox", $(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
287 });
288
289 test("attr(String, Object) - Loaded via XML document", function() {
290         expect(2);
291         stop();
292         $.get('data/dashboard.xml', function(xml) { 
293                 var titles = [];
294                 $('tab', xml).each(function() {
295                         titles.push($(this).attr('title'));
296                 });
297                 ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
298                 ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
299                 start();
300         });
301 });
302
303 test("css(String|Hash)", function() {
304         expect(19);
305         
306         ok( $('#main').css("display") == 'none', 'Check for css property "display"');
307         
308         ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
309         $('#foo').css({display: 'none'});
310         ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
311         $('#foo').css({display: 'block'});
312         ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
313         
314         $('#floatTest').css({styleFloat: 'right'});
315         ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
316         $('#floatTest').css({cssFloat: 'left'});
317         ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
318         $('#floatTest').css({'float': 'right'});
319         ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
320         $('#floatTest').css({'font-size': '30px'});
321         ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
322         
323         $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
324                 $('#foo').css({opacity: n});
325                 ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
326                 $('#foo').css({opacity: parseFloat(n)});
327                 ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
328         });     
329         $('#foo').css({opacity: ''});
330         ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
331 });
332
333 test("css(String, Object)", function() {
334         expect(18);
335         ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
336         $('#foo').css('display', 'none');
337         ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
338         $('#foo').css('display', 'block');
339         ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
340         
341         $('#floatTest').css('styleFloat', 'left');
342         ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
343         $('#floatTest').css('cssFloat', 'right');
344         ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
345         $('#floatTest').css('float', 'left');
346         ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
347         $('#floatTest').css('font-size', '20px');
348         ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
349         
350         $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) {
351                 $('#foo').css('opacity', n);
352                 ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
353                 $('#foo').css('opacity', parseFloat(n));
354                 ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
355         });
356         $('#foo').css('opacity', '');
357         ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" );
358 });
359
360 test("text()", function() {
361         expect(1);
362         var expected = "This link has class=\"blog\": Simon Willison's Weblog";
363         ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
364 });
365
366 test("wrap(String|Element)", function() {
367         expect(6);
368         var defaultText = 'Try them out:'
369         var result = $('#first').wrap('<div class="red"><span></span></div>').text();
370         ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
371         ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
372
373         reset();
374         var defaultText = 'Try them out:'
375         var result = $('#first').wrap(document.getElementById('empty')).parent();
376         ok( result.is('ol'), 'Check for element wrapping' );
377         ok( result.text() == defaultText, 'Check for element wrapping' );
378         
379         reset();
380         $('#check1').click(function() {         
381                 var checkbox = this;            
382                 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
383                 $(checkbox).wrap( '<div id="c1" style="display:none;"></div>' );
384                 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
385         }).click();
386 });
387
388 test("wrapAll(String|Element)", function() {
389         expect(8);
390         var prev = $("#first")[0].previousSibling;
391         var p = $("#first")[0].parentNode;
392         var result = $('#first,#firstp').wrapAll('<div class="red"><div id="tmp"></div></div>');
393         equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
394         ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
395         ok( $('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
396         equals( $("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
397         equals( $("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
398
399         reset();
400         var prev = $("#first")[0].previousSibling;
401         var p = $("#first")[0].parentNode;
402         var result = $('#first,#firstp').wrapAll(document.getElementById('empty'));
403         equals( $("#first").parent()[0], $("#firstp").parent()[0], "Same Parent" );
404         equals( $("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
405         equals( $("#first").parent()[0].parentNode, p, "Correct Parent" );
406 });
407
408 test("wrapInner(String|Element)", function() {
409         expect(6);
410         var num = $("#first").children().length;
411         var result = $('#first').wrapInner('<div class="red"><div id="tmp"></div></div>');
412         equals( $("#first").children().length, 1, "Only one child" );
413         ok( $("#first").children().is(".red"), "Verify Right Element" );
414         equals( $("#first").children().children().children().length, num, "Verify Elements Intact" );
415
416         reset();
417         var num = $("#first").children().length;
418         var result = $('#first').wrapInner(document.getElementById('empty'));
419         equals( $("#first").children().length, 1, "Only one child" );
420         ok( $("#first").children().is("#empty"), "Verify Right Element" );
421         equals( $("#first").children().children().length, num, "Verify Elements Intact" );
422 });
423
424 test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
425         expect(18);
426         var defaultText = 'Try them out:'
427         var result = $('#first').append('<b>buga</b>');
428         ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
429         ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
430         
431         reset();
432         var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
433         $('#sap').append(document.getElementById('first'));
434         ok( expected == $('#sap').text(), "Check for appending of element" );
435         
436         reset();
437         expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
438         $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
439         ok( expected == $('#sap').text(), "Check for appending of array of elements" );
440         
441         reset();
442         expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
443         $('#sap').append($("#first, #yahoo"));
444         ok( expected == $('#sap').text(), "Check for appending of jQuery object" );
445
446         reset();
447         $("#sap").append( 5 );
448         ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );
449
450         reset();
451         $("#sap").append( " text with spaces " );
452         ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );
453
454         reset();
455         ok( $("#sap").append([]), "Check for appending an empty array." );
456         ok( $("#sap").append(""), "Check for appending an empty string." );
457         ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );
458         
459         reset();
460         $("#sap").append(document.getElementById('form'));
461         ok( $("#sap>form").size() == 1, "Check for appending a form" );  // Bug #910
462
463         reset();
464         var pass = true;
465         try {
466                 $( $("iframe")[0].contentWindow.document.body ).append("<div>test</div>");
467         } catch(e) {
468                 pass = false;
469         }
470
471         ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
472         
473         reset();
474         $('<fieldset/>').appendTo('#form').append('<legend id="legend">test</legend>');
475         t( 'Append legend', '#legend', ['legend'] );
476         
477         reset();
478         $('#select1').append('<OPTION>Test</OPTION>');
479         ok( $('#select1 option:last').text() == "Test", "Appending &lt;OPTION&gt; (all caps)" );
480         
481         $('#table').append('<colgroup></colgroup>');
482         ok( $('#table colgroup').length, "Append colgroup" );
483         
484         $('#table colgroup').append('<col/>');
485         ok( $('#table colgroup col').length, "Append col" );
486         
487         reset();
488         $('#table').append('<caption></caption>');
489         ok( $('#table caption').length, "Append caption" );
490
491         reset();
492         $('form:last')
493                 .append('<select id="appendSelect1"></select>')
494                 .append('<select id="appendSelect2"><option>Test</option></select>');
495         
496         t( "Append Select", "#appendSelect1, #appendSelect2", ["appendSelect1", "appendSelect2"] );
497 });
498
499 test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
500         expect(6);
501         var defaultText = 'Try them out:'
502         $('<b>buga</b>').appendTo('#first');
503         ok( $("#first").text() == defaultText + 'buga', 'Check if text appending works' );
504         ok( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
505         
506         reset();
507         var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
508         $(document.getElementById('first')).appendTo('#sap');
509         ok( expected == $('#sap').text(), "Check for appending of element" );
510         
511         reset();
512         expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
513         $([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
514         ok( expected == $('#sap').text(), "Check for appending of array of elements" );
515         
516         reset();
517         expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
518         $("#first, #yahoo").appendTo('#sap');
519         ok( expected == $('#sap').text(), "Check for appending of jQuery object" );
520         
521         reset();
522         $('#select1').appendTo('#foo');
523         t( 'Append select', '#foo select', ['select1'] );
524 });
525
526 test("prepend(String|Element|Array&lt;Element&gt;|jQuery)", function() {
527         expect(5);
528         var defaultText = 'Try them out:'
529         var result = $('#first').prepend('<b>buga</b>');
530         ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
531         ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
532         
533         reset();
534         var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
535         $('#sap').prepend(document.getElementById('first'));
536         ok( expected == $('#sap').text(), "Check for prepending of element" );
537
538         reset();
539         expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
540         $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
541         ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
542         
543         reset();
544         expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
545         $('#sap').prepend($("#first, #yahoo"));
546         ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );
547 });
548
549 test("prependTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
550         expect(6);
551         var defaultText = 'Try them out:'
552         $('<b>buga</b>').prependTo('#first');
553         ok( $('#first').text() == 'buga' + defaultText, 'Check if text prepending works' );
554         ok( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
555         
556         reset();
557         var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
558         $(document.getElementById('first')).prependTo('#sap');
559         ok( expected == $('#sap').text(), "Check for prepending of element" );
560
561         reset();
562         expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
563         $([document.getElementById('yahoo'), document.getElementById('first')]).prependTo('#sap');
564         ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
565         
566         reset();
567         expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
568         $("#yahoo, #first").prependTo('#sap');
569         ok( expected == $('#sap').text(), "Check for prepending of jQuery object" );
570         
571         reset();
572         $('<select id="prependSelect1"></select>').prependTo('form:last');
573         $('<select id="prependSelect2"><option>Test</option></select>').prependTo('form:last');
574         
575         t( "Prepend Select", "#prependSelect1, #prependSelect2", ["prependSelect1", "prependSelect2"] );
576 });
577
578 test("before(String|Element|Array&lt;Element&gt;|jQuery)", function() {
579         expect(4);
580         var expected = 'This is a normal link: bugaYahoo';
581         $('#yahoo').before('<b>buga</b>');
582         ok( expected == $('#en').text(), 'Insert String before' );
583         
584         reset();
585         expected = "This is a normal link: Try them out:Yahoo";
586         $('#yahoo').before(document.getElementById('first'));
587         ok( expected == $('#en').text(), "Insert element before" );
588         
589         reset();
590         expected = "This is a normal link: Try them out:diveintomarkYahoo";
591         $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
592         ok( expected == $('#en').text(), "Insert array of elements before" );
593         
594         reset();
595         expected = "This is a normal link: Try them out:diveintomarkYahoo";
596         $('#yahoo').before($("#first, #mark"));
597         ok( expected == $('#en').text(), "Insert jQuery before" );
598 });
599
600 test("insertBefore(String|Element|Array&lt;Element&gt;|jQuery)", function() {
601         expect(4);
602         var expected = 'This is a normal link: bugaYahoo';
603         $('<b>buga</b>').insertBefore('#yahoo');
604         ok( expected == $('#en').text(), 'Insert String before' );
605         
606         reset();
607         expected = "This is a normal link: Try them out:Yahoo";
608         $(document.getElementById('first')).insertBefore('#yahoo');
609         ok( expected == $('#en').text(), "Insert element before" );
610         
611         reset();
612         expected = "This is a normal link: Try them out:diveintomarkYahoo";
613         $([document.getElementById('first'), document.getElementById('mark')]).insertBefore('#yahoo');
614         ok( expected == $('#en').text(), "Insert array of elements before" );
615         
616         reset();
617         expected = "This is a normal link: Try them out:diveintomarkYahoo";
618         $("#first, #mark").insertBefore('#yahoo');
619         ok( expected == $('#en').text(), "Insert jQuery before" );
620 });
621
622 test("after(String|Element|Array&lt;Element&gt;|jQuery)", function() {
623         expect(4);
624         var expected = 'This is a normal link: Yahoobuga';
625         $('#yahoo').after('<b>buga</b>');
626         ok( expected == $('#en').text(), 'Insert String after' );
627         
628         reset();
629         expected = "This is a normal link: YahooTry them out:";
630         $('#yahoo').after(document.getElementById('first'));
631         ok( expected == $('#en').text(), "Insert element after" );
632
633         reset();
634         expected = "This is a normal link: YahooTry them out:diveintomark";
635         $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
636         ok( expected == $('#en').text(), "Insert array of elements after" );
637         
638         reset();
639         expected = "This is a normal link: YahooTry them out:diveintomark";
640         $('#yahoo').after($("#first, #mark"));
641         ok( expected == $('#en').text(), "Insert jQuery after" );
642 });
643
644 test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
645         expect(4);
646         var expected = 'This is a normal link: Yahoobuga';
647         $('<b>buga</b>').insertAfter('#yahoo');
648         ok( expected == $('#en').text(), 'Insert String after' );
649         
650         reset();
651         expected = "This is a normal link: YahooTry them out:";
652         $(document.getElementById('first')).insertAfter('#yahoo');
653         ok( expected == $('#en').text(), "Insert element after" );
654
655         reset();
656         expected = "This is a normal link: YahooTry them out:diveintomark";
657         $([document.getElementById('mark'), document.getElementById('first')]).insertAfter('#yahoo');
658         ok( expected == $('#en').text(), "Insert array of elements after" );
659         
660         reset();
661         expected = "This is a normal link: YahooTry them out:diveintomark";
662         $("#mark, #first").insertAfter('#yahoo');
663         ok( expected == $('#en').text(), "Insert jQuery after" );
664 });
665
666 test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
667         expect(10);
668         $('#yahoo').replaceWith('<b id="replace">buga</b>');
669         ok( $("#replace")[0], 'Replace element with string' );
670         ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
671         
672         reset();
673         $('#yahoo').replaceWith(document.getElementById('first'));
674         ok( $("#first")[0], 'Replace element with element' );
675         ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );
676
677         reset();
678         $('#yahoo').replaceWith([document.getElementById('first'), document.getElementById('mark')]);
679         ok( $("#first")[0], 'Replace element with array of elements' );
680         ok( $("#mark")[0], 'Replace element with array of elements' );
681         ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
682         
683         reset();
684         $('#yahoo').replaceWith($("#first, #mark"));
685         ok( $("#first")[0], 'Replace element with set of elements' );
686         ok( $("#mark")[0], 'Replace element with set of elements' );
687         ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
688 });
689
690 test("replaceAll(String|Element|Array&lt;Element&gt;|jQuery)", function() {
691         expect(10);
692         $('<b id="replace">buga</b>').replaceAll("#yahoo");
693         ok( $("#replace")[0], 'Replace element with string' );
694         ok( !$("#yahoo")[0], 'Verify that original element is gone, after string' );
695         
696         reset();
697         $(document.getElementById('first')).replaceAll("#yahoo");
698         ok( $("#first")[0], 'Replace element with element' );
699         ok( !$("#yahoo")[0], 'Verify that original element is gone, after element' );
700
701         reset();
702         $([document.getElementById('first'), document.getElementById('mark')]).replaceAll("#yahoo");
703         ok( $("#first")[0], 'Replace element with array of elements' );
704         ok( $("#mark")[0], 'Replace element with array of elements' );
705         ok( !$("#yahoo")[0], 'Verify that original element is gone, after array of elements' );
706         
707         reset();
708         $("#first, #mark").replaceAll("#yahoo");
709         ok( $("#first")[0], 'Replace element with set of elements' );
710         ok( $("#mark")[0], 'Replace element with set of elements' );
711         ok( !$("#yahoo")[0], 'Verify that original element is gone, after set of elements' );
712 });
713
714 test("end()", function() {
715         expect(3);
716         ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
717         ok( $('#yahoo').end(), 'Check for end with nothing to end' );
718         
719         var x = $('#yahoo');
720         x.parent();
721         ok( 'Yahoo' == $('#yahoo').text(), 'Check for non-destructive behaviour' );
722 });
723
724 test("find(String)", function() {
725         expect(1);
726         ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
727 });
728
729 test("clone()", function() {
730         expect(3);
731         ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
732         var clone = $('#yahoo').clone();
733         ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
734         ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
735 });
736
737 test("is(String)", function() {
738         expect(26);
739         ok( $('#form').is('form'), 'Check for element: A form must be a form' );
740         ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
741         ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
742         ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
743         ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
744         ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
745         ok( $('#en').is('[lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
746         ok( !$('#en').is('[lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
747         ok( $('#text1').is('[type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
748         ok( !$('#text1').is('[type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
749         ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
750         ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
751         ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
752         ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
753         ok( $('#foo').is(':has(p)'), 'Check for child: Expected a child "p" element' );
754         ok( !$('#foo').is(':has(ul)'), 'Check for child: Did not expect "ul" element' );
755         ok( $('#foo').is(':has(p):has(a):has(code)'), 'Check for childs: Expected "p", "a" and "code" child elements' );
756         ok( !$('#foo').is(':has(p):has(a):has(code):has(ol)'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
757         ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
758         ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
759         ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
760         ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
761         
762         // test is() with comma-seperated expressions
763         ok( $('#en').is('[lang="en"],[lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
764         ok( $('#en').is('[lang="de"],[lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
765         ok( $('#en').is('[lang="en"] , [lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
766         ok( $('#en').is('[lang="de"] , [lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' );
767 });
768
769 test("$.extend(Object, Object)", function() {
770         expect(10);
771
772         var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
773                 options =     { xnumber2: 1, xstring2: "x", xxx: "newstring" },
774                 optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
775                 merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
776                 deep1 = { foo: { bar: true } },
777                 deep1copy = { foo: { bar: true } },
778                 deep2 = { foo: { baz: true } },
779                 deep2copy = { foo: { baz: true } },
780                 deepmerged = { foo: { bar: true, baz: true } };
781
782         jQuery.extend(settings, options);
783         isObj( settings, merged, "Check if extended: settings must be extended" );
784         isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
785
786         jQuery.extend(settings, null, options);
787         isObj( settings, merged, "Check if extended: settings must be extended" );
788         isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
789
790         jQuery.extend(true, deep1, deep2);
791         isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
792         isObj( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
793
794         var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
795                 defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
796                 options1 =     { xnumber2: 1, xstring2: "x" },
797                 options1Copy = { xnumber2: 1, xstring2: "x" },
798                 options2 =     { xstring2: "xx", xxx: "newstringx" },
799                 options2Copy = { xstring2: "xx", xxx: "newstringx" },
800                 merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
801
802         var settings = jQuery.extend({}, defaults, options1, options2);
803         isObj( settings, merged2, "Check if extended: settings must be extended" );
804         isObj( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
805         isObj( options1, options1Copy, "Check if not modified: options1 must not be modified" );
806         isObj( options2, options2Copy, "Check if not modified: options2 must not be modified" );
807 });
808
809 test("val()", function() {
810         expect(2);
811         ok( $("#text1").val() == "Test", "Check for value of input element" );
812         ok( !$("#text1").val() == "", "Check for value of input element" );
813 });
814
815 test("val(String)", function() {
816         expect(2);
817         document.getElementById('text1').value = "bla";
818         ok( $("#text1").val() == "bla", "Check for modified value of input element" );
819         $("#text1").val('test');
820         ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
821 });
822
823 test("html(String)", function() {
824         expect(1);
825         var div = $("div");
826         div.html("<b>test</b>");
827         var pass = true;
828         for ( var i = 0; i < div.size(); i++ ) {
829           if ( div.get(i).childNodes.length == 0 ) pass = false;
830         }
831         ok( pass, "Set HTML" );
832
833         // Ccommented out until we can resolve it       
834         // $("#main").html('<script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script>').evalScripts();
835 });
836
837 test("filter()", function() {
838         expect(4);
839         isSet( $("#form input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
840         isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );
841         isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );
842         isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );
843 });
844
845 test("not()", function() {
846         expect(3);
847         ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );
848         isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );
849         isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
850 });
851
852 test("andSelf()", function() {
853         expect(4);
854         isSet( $("#en").siblings().andSelf().get(), q("sndp", "sap","en"), "Check for siblings and self" );
855         isSet( $("#foo").children().andSelf().get(), q("sndp", "en", "sap", "foo"), "Check for children and self" );
856         isSet( $("#en, #sndp").parent().andSelf().get(), q("foo","en","sndp"), "Check for parent and self" );
857         isSet( $("#groups").parents("p, div").andSelf().get(), q("ap", "main", "groups"), "Check for parents and self" );
858 });
859
860 test("siblings([String])", function() {
861         expect(5);
862         isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
863         isSet( $("#sndp").siblings(":has(code)").get(), q("sap"), "Check for filtered siblings (has code child element)" ); 
864         isSet( $("#sndp").siblings(":has(a)").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
865         isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "testForm", "floatTest"), "Check for multiple filters" );
866         isSet( $("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" );
867 });
868
869 test("children([String])", function() {
870         expect(3);
871         isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
872         isSet( $("#foo").children(":has(code)").get(), q("sndp", "sap"), "Check for filtered children" );
873         isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );
874 });
875
876 test("parent([String])", function() {
877         expect(5);
878         ok( $("#groups").parent()[0].id == "ap", "Simple parent check" );
879         ok( $("#groups").parent("p")[0].id == "ap", "Filtered parent check" );
880         ok( $("#groups").parent("div").length == 0, "Filtered parent check, no match" );
881         ok( $("#groups").parent("div, p")[0].id == "ap", "Check for multiple filters" );
882         isSet( $("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" );
883 });
884         
885 test("parents([String])", function() {
886         expect(5);
887         ok( $("#groups").parents()[0].id == "ap", "Simple parents check" );
888         ok( $("#groups").parents("p")[0].id == "ap", "Filtered parents check" );
889         ok( $("#groups").parents("div")[0].id == "main", "Filtered parents check2" );
890         isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );
891         isSet( $("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" );
892 });
893
894 test("next([String])", function() {
895         expect(4);
896         ok( $("#ap").next()[0].id == "foo", "Simple next check" );
897         ok( $("#ap").next("div")[0].id == "foo", "Filtered next check" );
898         ok( $("#ap").next("p").length == 0, "Filtered next check, no match" );
899         ok( $("#ap").next("div, p")[0].id == "foo", "Multiple filters" );
900 });
901         
902 test("prev([String])", function() {
903         expect(4);
904         ok( $("#foo").prev()[0].id == "ap", "Simple prev check" );
905         ok( $("#foo").prev("p")[0].id == "ap", "Filtered prev check" );
906         ok( $("#foo").prev("div").length == 0, "Filtered prev check, no match" );
907         ok( $("#foo").prev("p, div")[0].id == "ap", "Multiple filters" );
908 });
909
910 test("show()", function() {
911         expect(1);
912         var pass = true, div = $("div");
913         div.show().each(function(){
914           if ( this.style.display == "none" ) pass = false;
915         });
916         ok( pass, "Show" );
917 });
918
919 test("addClass(String)", function() {
920         expect(1);
921         var div = $("div");
922         div.addClass("test");
923         var pass = true;
924         for ( var i = 0; i < div.size(); i++ ) {
925          if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
926         }
927         ok( pass, "Add Class" );
928 });
929
930 test("removeClass(String) - simple", function() {
931         expect(3);
932         var div = $("div").addClass("test").removeClass("test"),
933                 pass = true;
934         for ( var i = 0; i < div.size(); i++ ) {
935                 if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
936         }
937         ok( pass, "Remove Class" );
938         
939         reset();
940         var div = $("div").addClass("test").addClass("foo").addClass("bar");
941         div.removeClass("test").removeClass("bar").removeClass("foo");
942         var pass = true;
943         for ( var i = 0; i < div.size(); i++ ) {
944          if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
945         }
946         ok( pass, "Remove multiple classes" );
947         
948         reset();
949         var div = $("div:eq(0)").addClass("test").removeClass("");
950         ok( div.is('.test'), "Empty string passed to removeClass" );
951         
952 });
953
954 test("toggleClass(String)", function() {
955         expect(3);
956         var e = $("#firstp");
957         ok( !e.is(".test"), "Assert class not present" );
958         e.toggleClass("test");
959         ok( e.is(".test"), "Assert class present" ); 
960         e.toggleClass("test");
961         ok( !e.is(".test"), "Assert class not present" );
962 });
963
964 test("removeAttr(String", function() {
965         expect(1);
966         ok( $('#mark').removeAttr("class")[0].className == "", "remove class" );
967 });
968
969 test("text(String)", function() {
970         expect(1);
971         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" );
972 });
973
974 test("$.each(Object,Function)", function() {
975         expect(8);
976         $.each( [0,1,2], function(i, n){
977                 ok( i == n, "Check array iteration" );
978         });
979         
980         $.each( [5,6,7], function(i, n){
981                 ok( i == n - 5, "Check array iteration" );
982         });
983          
984         $.each( { name: "name", lang: "lang" }, function(i, n){
985                 ok( i == n, "Check object iteration" );
986         });
987 });
988
989 test("$.prop", function() {
990         expect(2);
991         var handle = function() { return this.id };
992         ok( $.prop($("#ap")[0], handle) == "ap", "Check with Function argument" );
993         ok( $.prop($("#ap")[0], "value") == "value", "Check with value argument" );
994 });
995
996 test("$.className", function() {
997         expect(6);
998         var x = $("<p>Hi</p>")[0];
999         var c = $.className;
1000         c.add(x, "hi");
1001         ok( x.className == "hi", "Check single added class" );
1002         c.add(x, "foo bar");
1003         ok( x.className == "hi foo bar", "Check more added classes" );
1004         c.remove(x);
1005         ok( x.className == "", "Remove all classes" );
1006         c.add(x, "hi foo bar");
1007         c.remove(x, "foo");
1008         ok( x.className == "hi bar", "Check removal of one class" );
1009         ok( c.has(x, "hi"), "Check has1" );
1010         ok( c.has(x, "bar"), "Check has2" );
1011 });
1012
1013 test("remove()", function() {
1014         expect(4);
1015         $("#ap").children().remove();
1016         ok( $("#ap").text().length > 10, "Check text is not removed" );
1017         ok( $("#ap").children().length == 0, "Check remove" );
1018         
1019         reset();
1020         $("#ap").children().remove("a");
1021         ok( $("#ap").text().length > 10, "Check text is not removed" );
1022         ok( $("#ap").children().length == 1, "Check filtered remove" );
1023 });
1024
1025 test("empty()", function() {
1026         expect(2);
1027         ok( $("#ap").children().empty().text().length == 0, "Check text is removed" );
1028         ok( $("#ap").children().length == 4, "Check elements are not removed" );
1029 });
1030
1031 test("slice()", function() {
1032         expect(4);
1033         isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" );
1034         isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" );
1035         isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" );
1036         isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" );
1037 });
1038
1039 test("map()", function() {
1040         expect(2);
1041
1042         isSet(
1043                 $("#ap").map(function(){
1044                         return $(this).find("a").get();
1045                 }),
1046                 q("google", "groups", "anchor1", "mark"),
1047                 "Array Map"
1048         );
1049
1050         isSet(
1051                 $("#ap > a").map(function(){
1052                         return this.parentNode;
1053                 }),
1054                 q("ap","ap","ap"),
1055                 "Single Map"
1056         );
1057 });
1058
1059 test("contents()", function() {
1060         expect(2);
1061         equals( $("#ap").contents().length, 9, "Check element contents" );
1062         ok( $("#iframe").contents()[0], "Check existance of IFrame document" );
1063         // Disabled, randomly fails
1064         //ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" );
1065 });