Fixed #1750 by adding a url that starts with "//" and is a dataType "script" will...
[jquery.git] / test / unit / ajax.js
index 84d3518..35f87a8 100644 (file)
@@ -372,6 +372,7 @@ test("$.get(String, Hash, Function) - parse xml and use text() on nodes", functi
 test("$.getScript(String, Function) - with callback", function() {
        expect(2);
        stop();
+       window.foobar = null;
        $.getScript(url("data/test.js"), function() {
                equals( foobar, "bar", 'Check if script was evaluated' );
                setTimeout(start, 100);
@@ -398,6 +399,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, no callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, no callback)" );
+                       plus();
                }
        });
 
@@ -407,6 +412,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, url callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, url callback)" );
+                       plus();
                }
        });
 
@@ -417,6 +426,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, data callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, data callback)" );
+                       plus();
                }
        });
 
@@ -427,6 +440,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, data obj callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, data obj callback)" );
+                       plus();
                }
        });
 
@@ -437,6 +454,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (POST, no callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, data obj callback)" );
+                       plus();
                }
        });
 
@@ -448,6 +469,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (POST, data callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (POST, data callback)" );
+                       plus();
                }
        });
 
@@ -459,6 +484,10 @@ test("$.ajax() - JSONP, Local", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (POST, data obj callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (POST, data obj callback)" );
+                       plus();
                }
        });
 });
@@ -479,6 +508,10 @@ test("$.ajax() - JSONP, Remote", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, no callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, no callback)" );
+                       plus();
                }
        });
 
@@ -488,6 +521,10 @@ test("$.ajax() - JSONP, Remote", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, url callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, url callback)" );
+                       plus();
                }
        });
 
@@ -498,6 +535,10 @@ test("$.ajax() - JSONP, Remote", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, data callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, data callback)" );
+                       plus();
                }
        });
 
@@ -508,6 +549,10 @@ test("$.ajax() - JSONP, Remote", function() {
                success: function(data){
                        ok( data.data, "JSON results returned (GET, data obj callback)" );
                        plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, data obj callback)" );
+                       plus();
                }
        });
 });
@@ -519,6 +564,46 @@ test("$.ajax() - script, Remote", function() {
 
        stop();
 
+       window.foobar = null;
+       $.ajax({
+               url: base + "data/test.js",
+               dataType: "script",
+               success: function(data){
+                       ok( foobar, "Script results returned (GET, no callback)" );
+                       start();
+               }
+       });
+});
+
+test("$.ajax() - script, Remote with POST", function() {
+       expect(3);
+
+       var base = window.location.href.replace(/\?.*$/, "");
+
+       stop();
+
+       window.foobar = null;
+       $.ajax({
+               url: base + "data/test.js",
+               type: "POST",
+               dataType: "script",
+               success: function(data, status){
+                       ok( foobar, "Script results returned (GET, no callback)" );
+                       equals( status, "success", "Script results returned (GET, no callback)" );
+                       start();
+               }
+       });
+});
+
+test("$.ajax() - script, Remote with scheme-less URL", function() {
+       expect(2);
+
+       var base = window.location.href.replace(/\?.*$/, "");
+       base = base.replace(/^.*?\/\//, "//");
+
+       stop();
+
+       window.foobar = null;
        $.ajax({
                url: base + "data/test.js",
                dataType: "script",