web/test/jstests/test_ajax.js
branchstable
changeset 6215 759cf097f5aa
parent 6214 e03808843325
child 7017 cd2ea273007a
equal deleted inserted replaced
6214:e03808843325 6215:759cf097f5aa
   121             equals(arg2, 'world');
   121             equals(arg2, 'world');
   122         },
   122         },
   123         'Hello', 'world');
   123         'Hello', 'world');
   124     });
   124     });
   125 
   125 
   126     test('test addErrback', function() {
   126   test('test addErrback', function() {
   127         expect(1);
   127         expect(1);
   128         stop();
   128         stop();
   129         var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
   129         var d = jQuery('#main').loadxhtml('/../ajax_url0.html');
   130         d.addCallback(function() {
   130         d.addCallback(function() {
   131             // throw an exception to start errback chain
   131             // throw an exception to start errback chain
   163             // should be executed after the first errback
   163             // should be executed after the first errback
   164             equals(++counter, 4);
   164             equals(++counter, 4);
   165         });
   165         });
   166     });
   166     });
   167 
   167 
   168     test('test already included resources are ignored (ajax_url2.html)', function() {
   168     test('test already included resources are ignored (ajax_url1.html)', function() {
   169         expect(10);
   169         expect(10);
   170         var scriptsIncluded = jsSources();
   170         var scriptsIncluded = jsSources();
   171         equals(jQuery.inArray('http://foo.js', scriptsIncluded), - 1);
   171         // NOTE:
       
   172         equals(jQuery.inArray('http://foo.js', scriptsIncluded), -1);
   172         equals(jQuery('head link').length, 1);
   173         equals(jQuery('head link').length, 1);
   173         /* use endswith because in pytest context we have an absolute path */
   174         /* use endswith because in pytest context we have an absolute path */
   174         ok(jQuery('head link').attr('href').endswith('/qunit.css'));
   175         ok(jQuery('head link').attr('href').endswith('/qunit.css'));
   175         stop();
   176         stop();
   176         jQuery('#main').loadxhtml('/../ajax_url1.html', {
   177         jQuery('#main').loadxhtml('/../ajax_url1.html', {
   177             callback: function() {
   178             callback: function() {
   178                 var origLength = scriptsIncluded.length;
   179                 var origLength = scriptsIncluded.length;
   179                 scriptsIncluded = jsSources();
   180                 scriptsIncluded = jsSources();
   180 		try {
   181                 try {
   181                     // check that foo.js has been inserted in <head>
   182                     // check that foo.js has been inserted in <head>
   182                     equals(scriptsIncluded.length, origLength + 1);
   183                     equals(scriptsIncluded.length, origLength + 1);
   183                     equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
   184                     equals(scriptsIncluded[origLength].indexOf('http://foo.js'), 0);
   184                     // check that <div class="ajaxHtmlHead"> has been removed
   185                     // check that <div class="ajaxHtmlHead"> has been removed
   185                     equals(jQuery('#main').children().length, 1);
   186                     equals(jQuery('#main').children().length, 1);
   189                     equals(jQuery('head link').length, 1);
   190                     equals(jQuery('head link').length, 1);
   190                     /* use endswith because in pytest context we have an absolute path */
   191                     /* use endswith because in pytest context we have an absolute path */
   191                     ok(jQuery('head link').attr('href').endswith('/qunit.css'));
   192                     ok(jQuery('head link').attr('href').endswith('/qunit.css'));
   192                 } finally {
   193                 } finally {
   193                     start();
   194                     start();
   194 		}
   195                 }
   195             }
   196             }
   196         });
   197         });
   197     });
   198     });
   198 
   199 
   199     test('test synchronous request loadRemote', function() {
   200     test('test synchronous request loadRemote', function() {