[javascript] fix test_ajax.js implementation
In cubicweb.ajax.js, we maintain two lists (cw.loaded_src and cw.loaded_href)
to keep track of already included CSS and JS. (see discussion about
jQuery and $('foo').appendTo($head) in _loadAjaxHtmlHead.)
Since all tests are executed in the "same page", those two
variables need to be reinitialized before each test.
--- a/web/test/jstests/test_ajax.js Mon Sep 13 10:00:05 2010 +0200
+++ b/web/test/jstests/test_ajax.js Mon Sep 13 09:56:10 2010 +0200
@@ -3,7 +3,12 @@
module("ajax", {
setup: function() {
this.scriptsLength = $('head script[src]').length-1;
- this.cssLength = $('head link[rel=stylesheet]').length-1;
+ this.cssLength = $('head link[rel=stylesheet]').length-1;
+ // re-initialize cw loaded cache so that each tests run in a
+ // clean environment, have a lookt at _loadAjaxHtmlHead implementation
+ // in cubicweb.ajax.js for more information.
+ cw.loaded_src = [];
+ cw.loaded_href = [];
},
teardown: function() {
$('head script[src]:gt(' + this.scriptsLength + ')').remove();