@@ -122,7 +122,7 @@ asyncTest('sends CSRF token in custom header', 1, function() {
122122 } ) ;
123123} ) ;
124124
125- asyncTest ( 'intelligently guesses crossDomain behavior when target URL is a different domain ' , 1 , function ( e , xhr ) {
125+ asyncTest ( 'intelligently guesses crossDomain behavior when target URL has a different protocol and/or hostname ' , 1 , function ( e , xhr ) {
126126
127127 // Don't set data-cross-domain here, just set action to be a different domain than localhost
128128 buildForm ( { action : 'http://www.alfajango.com' } ) ;
@@ -140,4 +140,23 @@ asyncTest('intelligently guesses crossDomain behavior when target URL is a diffe
140140
141141 setTimeout ( function ( ) { start ( ) ; } , 13 ) ;
142142} ) ;
143+
144+ asyncTest ( 'intelligently guesses crossDomain behavior when target URL consists of only a path' , 1 , function ( e , xhr ) {
145+
146+ // Don't set data-cross-domain here, just set action to be a different domain than localhost
147+ buildForm ( { action : '/just/a/path' } ) ;
148+ $ ( '#qunit-fixture' ) . append ( '<meta name="csrf-token" content="cf50faa3fe97702ca1ae" />' ) ;
149+
150+ $ ( '#qunit-fixture' ) . find ( 'form' )
151+ . bind ( 'ajax:beforeSend' , function ( e , xhr , settings ) {
152+
153+ equal ( settings . crossDomain , false , 'crossDomain should be set to false' ) ;
154+
155+ // prevent request from actually getting sent off-domain
156+ return false ;
157+ } )
158+ . trigger ( 'submit' ) ;
159+
160+ setTimeout ( function ( ) { start ( ) ; } , 13 ) ;
161+ } ) ;
143162} ) ( ) ;
0 commit comments