Added a fix for bug #1698, in which injected scripts were executed out of order,...
[jquery.git] / test / unit / core.js
index eee1740..7280ab9 100644 (file)
@@ -834,8 +834,10 @@ test("val(String)", function() {
        ok( $("#select1").val() == "3", "Check for modified (via val(String)) value of select element" );
 });
 
+var scriptorder = 0;
+
 test("html(String)", function() {
-       expect(3);
+       expect(9);
        var div = $("div");
        div.html("<b>test</b>");
        var pass = true;
@@ -850,6 +852,8 @@ test("html(String)", function() {
 
        $("#main").html('foo <form><script type="text/javascript">ok( true, "$().html().evalScripts() Evals Scripts Twice in Firefox, see #975" );</script></form>');
 
+       $("#main").html("<script>ok(scriptorder++ == 0, 'Script is executed in order');ok($('#scriptorder').length == 0,'Execute before html')<\/script><span id='scriptorder'><script>ok(scriptorder++ == 1, 'Script is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script></span><script>ok(scriptorder++ == 2, 'Script is executed in order');ok($('#scriptorder').length == 1,'Execute after html')<\/script>");
+
        setTimeout( start, 100 );
 });