[FIX] web: change qweb to work around phantomjs bug

This commit does not actually fix qweb2.js, but it works around a
phantomjs bug.  The problem with phantomjs is that in some situations,
the xmlhttprequests are dropped with a status 0.  It is most likely
related to the issue:

    https://github.com/ariya/phantomjs/issues/11195

In our testing framework, it seems to appear when requests sent before
the 'load' event of phantomjs are received after, and also when those
requests are listened with the onreadystatechange handler.

The bug does not appear if we use addEventListener with the 'load' event (at
least, not for a few builds)

This commit does not worsen qweb, and it is also a small improvement in
style (in my opinion).
This commit is contained in:
Géry Debongnie
2016-01-26 14:22:56 +01:00
parent 31efb0c198
commit 06e583e1fd
+6 -8
View File
@@ -295,15 +295,13 @@ QWeb2.Engine = (function() {
}
req.open('GET', s, async);
if (async) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
callback(null, self._parse_from_request(req));
} else {
callback(new Error("Can't load template " + s + ", http status " + req.status));
}
req.addEventListener("load", function() {
if (req.status == 200) {
callback(null, self._parse_from_request(req));
} else {
callback(new Error("Can't load template " + s + ", http status " + req.status));
}
};
});
}
req.send(null);
if (!async) {