Skip to content

Commit 905ab09

Browse files
committed
Ajax: don't expect cross-origin tests run in envs which not support it
Cherry-picked from 39cdb8c Follow-up to b078a62
1 parent 3ced5ab commit 905ab09

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

test/unit/ajax.js

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,6 @@ QUnit.module( "ajax", {
8585
};
8686
} );
8787

88-
ajaxTest( "jQuery.ajax() - do not execute js (crossOrigin)", 2, function( assert ) {
89-
return {
90-
create: function( options ) {
91-
options.crossDomain = true;
92-
return jQuery.ajax( url( "data/script.php?header=ecma" ), options );
93-
},
94-
success: function() {
95-
assert.ok( true, "success" );
96-
},
97-
complete: function() {
98-
assert.ok( true, "complete" );
99-
}
100-
};
101-
} );
102-
10388
ajaxTest( "jQuery.ajax() - execute js for crossOrigin when dataType option is provided", 3,
10489
function( assert ) {
10590
return {
@@ -127,6 +112,11 @@ QUnit.module( "ajax", {
127112
success: function() {
128113
assert.ok( true, "success" );
129114
},
115+
fail: function() {
116+
if (jQuery.support.cors === false) {
117+
assert.ok( true, "fail" );
118+
}
119+
},
130120
complete: function() {
131121
assert.ok( true, "complete" );
132122
}
@@ -1613,22 +1603,21 @@ QUnit.module( "ajax", {
16131603
done: function( data ) {
16141604
assert.ok( false, "done: " + data );
16151605
},
1616-
fail: function( jqXHR, status, error ) {
1617-
assert.ok( true, "exception caught: " + error );
1618-
assert.strictEqual( jqXHR.status, 0, "proper status code" );
1619-
assert.strictEqual( status, "error", "proper status" );
1620-
}
1621-
}, {
1622-
url: "http://domain.org:80d",
1623-
done: function( data ) {
1624-
assert.ok( false, "done: " + data );
1625-
},
1626-
fail: function( _, status, error ) {
1627-
assert.ok( true, "fail: " + status + " - " + error );
1628-
}
1629-
} ];
1630-
}
1631-
);
1606+
fail: function( jqXHR, status, error ) {
1607+
assert.ok( true, "exception caught: " + error );
1608+
assert.strictEqual( jqXHR.status, 0, "proper status code" );
1609+
assert.strictEqual( status, "error", "proper status" );
1610+
}
1611+
}, {
1612+
url: "http://domain.org:80d",
1613+
done: function( data ) {
1614+
assert.ok( false, "done: " + data );
1615+
},
1616+
fail: function( _, status, error ) {
1617+
assert.ok( true, "fail: " + status + " - " + error );
1618+
}
1619+
} ];
1620+
} );
16321621

16331622
ajaxTest( "gh-2587 - when content-type not xml, but looks like one", 1, function( assert ) {
16341623
return {

0 commit comments

Comments
 (0)