Commit 1e6bdd8e 1e6bdd8e13c4f055006147c62e1d310856240abb by Laurent Jouanneau

Refs #482: selftest server should read png as binary file

PhantomJS has a strange behavior on fs.read: it seems it reads
file always as binary file. However SlimerJS's fs.read strictly
respect the 'b' flag. So the web server of selftest should
return content of binary files as... binary data. Else images
are not sent correctly to the browser and Gecko cannot display
them. and then some tests fail, like tests on assertVisible.
1 parent 5e127143
......@@ -26,12 +26,21 @@ service = server.listen(testServerPort, function(request, response) {
response.write("404 - NOT FOUND");
} else {
var headers = {};
var binMode = false;
if (/js$/.test(pageFile)) {
headers['Content-Type'] = "application/javascript";
}
else if (/png$/.test(pageFile)) {
binMode = true;
}
response.writeHead(200, headers);
if (binMode) {
response.write(fs.read(pageFile, 'b'));
}
else {
response.write(fs.read(pageFile));
}
}
response.close();
});
......