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.
Showing
1 changed file
with
9 additions
and
0 deletions
... | @@ -26,12 +26,21 @@ service = server.listen(testServerPort, function(request, response) { | ... | @@ -26,12 +26,21 @@ service = server.listen(testServerPort, function(request, response) { |
26 | response.write("404 - NOT FOUND"); | 26 | response.write("404 - NOT FOUND"); |
27 | } else { | 27 | } else { |
28 | var headers = {}; | 28 | var headers = {}; |
29 | var binMode = false; | ||
29 | if (/js$/.test(pageFile)) { | 30 | if (/js$/.test(pageFile)) { |
30 | headers['Content-Type'] = "application/javascript"; | 31 | headers['Content-Type'] = "application/javascript"; |
31 | } | 32 | } |
33 | else if (/png$/.test(pageFile)) { | ||
34 | binMode = true; | ||
35 | } | ||
32 | response.writeHead(200, headers); | 36 | response.writeHead(200, headers); |
37 | if (binMode) { | ||
38 | response.write(fs.read(pageFile, 'b')); | ||
39 | } | ||
40 | else { | ||
33 | response.write(fs.read(pageFile)); | 41 | response.write(fs.read(pageFile)); |
34 | } | 42 | } |
43 | } | ||
35 | response.close(); | 44 | response.close(); |
36 | }); | 45 | }); |
37 | 46 | ... | ... |
-
Please register or sign in to post a comment