');
ok( true, "Check for \\r and \\n in jQuery()" );
+ /* // Disabled until we add this functionality in
var pass = true;
try {
- var f = document.getElementById("iframe").contentDocument;
- f.open();
- f.write("");
- f.close();
- $("
Testing
").appendTo(f.body);
+ $("
Testing
").appendTo(document.getElementById("iframe").contentDocument.body);
} catch(e){
pass = false;
}
- ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );
+ ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
});
test("isFunction", function() {
@@ -119,31 +116,43 @@ test("isFunction", function() {
});
});
+test("$('html')", function() {
+ expect(2);
+
+ reset();
+ ok( $("")[0], "Creating a script" );
+
+ reset();
+ ok( $("")[0], "Creating a link" );
+
+ reset();
+});
+
test("length", function() {
expect(1);
- ok( $("div").length == 2, "Get Number of Elements Found" );
+ ok( $("p").length == 6, "Get Number of Elements Found" );
});
test("size()", function() {
expect(1);
- ok( $("div").size() == 2, "Get Number of Elements Found" );
+ ok( $("p").size() == 6, "Get Number of Elements Found" );
});
test("get()", function() {
expect(1);
- isSet( $("div").get(), q("main","foo"), "Get All Elements" );
+ isSet( $("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
});
test("get(Number)", function() {
expect(1);
- ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
+ ok( $("p").get(0) == document.getElementById("firstp"), "Get A Single Element" );
});
test("add(String|Element|Array)", function() {
expect(7);
isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
- ok( $([]).add($("#form")[0].elements).length > 13, "Check elements from array" );
+ ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
var x = $([]).add($("
xxx
")).add($("
xxx
"));
ok( x[0].id == "x1", "Check on-the-fly element1" );
@@ -197,17 +206,15 @@ test("attr(String)", function() {
ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' );
});
-if ( location.protocol != "file:" ) {
- test("attr(String) in XML Files", function() {
- expect(2);
- stop();
- $.get("data/dashboard.xml", function(xml) {
- ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
- ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );
- start();
- });
+test("attr(String) in XML Files", function() {
+ expect(2);
+ stop();
+ $.get("data/dashboard.xml", function(xml) {
+ ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
+ ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );
+ start();
});
-}
+});
test("attr(String, Function)", function() {
expect(2);
@@ -225,7 +232,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(7);
+ expect(8);
var div = $("div");
div.attr("foo", "bar");
var pass = true;
@@ -246,23 +253,23 @@ test("attr(String, Object)", function() {
ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
$("#text1").attr('readonly', false);
ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
+ $("#name").attr('maxlength', '5');
+ ok( document.getElementById('name').maxLength == '5', 'Set maxlength attribute' );
});
-if ( location.protocol != "file:" ) {
- test("attr(String, Object)x", function() {
- expect(2);
- stop();
- $.get('data/dashboard.xml', function(xml) {
- var titles = [];
- $('tab', xml).each(function() {
- titles.push($(this).attr('title'));
- });
- ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
- ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
- start();
- });
+test("attr(String, Object) - Loaded via XML document", function() {
+ expect(2);
+ stop();
+ $.get('data/dashboard.xml', function(xml) {
+ var titles = [];
+ $('tab', xml).each(function() {
+ titles.push($(this).attr('title'));
+ });
+ ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
+ ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
+ start();
});
-}
+});
test("css(String|Hash)", function() {
expect(19);
@@ -328,7 +335,7 @@ test("text()", function() {
});
test("wrap(String|Element)", function() {
- expect(7);
+ expect(6);
var defaultText = 'Try them out:'
var result = $('#first').wrap('
').text();
ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
@@ -341,22 +348,52 @@ test("wrap(String|Element)", function() {
ok( result.text() == defaultText, 'Check for element wrapping' );
reset();
- stop();
$('#check1').click(function() {
var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
$(checkbox).wrap( '' );
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
- // use a fade in to check state after this event handler has finished
- setTimeout(function() {
- ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
- start();
- }, 100);
}).click();
});
+test("wrapAll(String|Element)", function() {
+ expect(8);
+ var prev = $("#first")[0].previousSibling;
+ var p = $("#first")[0].parentNode;
+ var result = $('#first,#firstp').wrapAll('
');
+ equals( result.parent().length, 1, 'Check for wrapping of on-the-fly html' );
+ ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+ ok( $('#firstp').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
+ equals( $("#first").parent().parent()[0].previousSibling, prev, "Correct Previous Sibling" );
+ equals( $("#first").parent().parent()[0].parentNode, p, "Correct Parent" );
+
+ reset();
+ var prev = $("#first")[0].previousSibling;
+ var p = $("#first")[0].parentNode;
+ var result = $('#first,#firstp').wrapAll(document.getElementById('empty'));
+ equals( $("#first").parent()[0], $("#firstp").parent()[0], "Same Parent" );
+ equals( $("#first").parent()[0].previousSibling, prev, "Correct Previous Sibling" );
+ equals( $("#first").parent()[0].parentNode, p, "Correct Parent" );
+});
+
+test("wrapInner(String|Element)", function() {
+ expect(6);
+ var num = $("#first").children().length;
+ var result = $('#first').wrapInner('
');
+ equals( $("#first").children().length, 1, "Only one child" );
+ ok( $("#first").children().is(".red"), "Verify Right Element" );
+ equals( $("#first").children().children().children().length, num, "Verify Elements Intact" );
+
+ reset();
+ var num = $("#first").children().length;
+ var result = $('#first').wrapInner(document.getElementById('empty'));
+ equals( $("#first").children().length, 1, "Only one child" );
+ ok( $("#first").children().is("#empty"), "Verify Right Element" );
+ equals( $("#first").children().children().length, num, "Verify Elements Intact" );
+});
+
test("append(String|Element|Array<Element>|jQuery)", function() {
- expect(16);
+ expect(18);
var defaultText = 'Try them out:'
var result = $('#first').append('buga');
ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
@@ -405,7 +442,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() {
ok( pass, "Test for appending a DOM node to the contents of an IFrame" );
reset();
- $('