X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=77fd17e52cf03fc227afaca6d97c006a204abfe2;hb=4903872c17f8809bd0c027092fc55d139d8ae789;hp=4370e9da82391c08b696eab9a66cf3354180b406;hpb=3728a8ac0494de7ccab48bfc69f5d71496ba64c2;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 4370e9d..77fd17e 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -159,7 +159,7 @@ test("index(Object)", function() { }); test("attr(String)", function() { - expect(15); + expect(13); ok( $('#text1').attr('value') == "Test", 'Check for value attribute' ); ok( $('#text1').attr('type') == "text", 'Check for type attribute' ); ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' ); @@ -175,15 +175,20 @@ test("attr(String)", function() { $('').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' ); - - 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(); - }); }); +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, Function)", function() { expect(2); ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" ); @@ -261,9 +266,9 @@ test("css(String|Hash)", function() { $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { $('#foo').css({opacity: n}); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); $('#foo').css({opacity: parseFloat(n)}); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); }); $('#foo').css({opacity: ''}); ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); @@ -288,9 +293,9 @@ test("css(String, Object)", function() { $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { $('#foo').css('opacity', n); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); $('#foo').css('opacity', parseFloat(n)); - ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" ); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); }); $('#foo').css('opacity', ''); ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); @@ -316,7 +321,7 @@ test("wrap(String|Element)", function() { }); test("append(String|Element|Array<Element>|jQuery)", function() { - expect(11); + expect(12); var defaultText = 'Try them out:' var result = $('#first').append('buga'); ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); @@ -353,6 +358,16 @@ test("append(String|Element|Array<Element>|jQuery)", function() { reset(); $("#sap").append(document.getElementById('form')); ok( $("#sap>form").size() == 1, "Check for appending a form" ); // Bug #910 + + reset(); + var pass = true; + try { + $( $("iframe")[0].contentWindow.document.body ).append("
test
"); + } catch(e) { + pass = false; + } + + ok( pass, "Test for appending a DOM node to the contents of an IFrame" ); }); @@ -561,10 +576,10 @@ test("is(String)", function() { ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' ); // test is() with comma-seperated expressions - ok( $('#en').is('[@lang="en"],[@lang="de"]'), 'Check for lang attribute: Expecte en or de' ); - ok( $('#en').is('[@lang="de"],[@lang="en"]'), 'Check for lang attribute: Expecte en or de' ); - ok( $('#en').is('[@lang="en"] , [@lang="de"]'), 'Check for lang attribute: Expecte en or de' ); - ok( $('#en').is('[@lang="de"] , [@lang="en"]'), 'Check for lang attribute: Expecte en or de' ); + ok( $('#en').is('[@lang="en"],[@lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' ); + ok( $('#en').is('[@lang="de"],[@lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' ); + ok( $('#en').is('[@lang="en"] , [@lang="de"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' ); + ok( $('#en').is('[@lang="de"] , [@lang="en"]'), 'Comma-seperated; Check for lang attribute: Expect en or de' ); }); test("$.extend(Object, Object)", function() { @@ -806,3 +821,17 @@ test("click() context", function() { return false; }).click(); }); + +test("$().html().evalScripts() Eval's Scripts Twice in Firefox, see #975", function() { + expect(1); + $("#main").html('').evalScripts(); +}); + +test("$('') needs optional document parameter to ease cross-frame DOM wrangling, see #968", function() { + var f = frames["iframe"].document; + f.open(); + f.write(""); + f.close(); + $("
Testing
").appendTo(f.body); + ok( true, "passed" ); +}); \ No newline at end of file