Wed, 31 Dec 2014 06:55:46 +0100
Added tag TORBROWSER_REPLICA for changeset 6474c204b198
michael@0 | 1 | function getFileStream(filename) |
michael@0 | 2 | { |
michael@0 | 3 | // Get the location of this sjs file, and then use that to figure out where |
michael@0 | 4 | // to find where our other files are. |
michael@0 | 5 | var self = Components.classes["@mozilla.org/file/local;1"] |
michael@0 | 6 | .createInstance(Components.interfaces.nsILocalFile); |
michael@0 | 7 | self.initWithPath(getState("__LOCATION__")); |
michael@0 | 8 | var file = self.parent; |
michael@0 | 9 | file.append(filename); |
michael@0 | 10 | dump(file.path + "\n"); |
michael@0 | 11 | |
michael@0 | 12 | var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1'] |
michael@0 | 13 | .createInstance(Components.interfaces.nsIFileInputStream); |
michael@0 | 14 | fileStream.init(file, 1, 0, false); |
michael@0 | 15 | |
michael@0 | 16 | return fileStream; |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | var gTimer; |
michael@0 | 20 | |
michael@0 | 21 | function handleRequest(request, response) |
michael@0 | 22 | { |
michael@0 | 23 | response.processAsync(); |
michael@0 | 24 | response.setStatusLine(request.httpVersion, 200, "OK"); |
michael@0 | 25 | response.setHeader("Content-Type", "image/gif", false); |
michael@0 | 26 | |
michael@0 | 27 | var firststream = getFileStream("threeframes-start.gif"); |
michael@0 | 28 | response.bodyOutputStream.writeFrom(firststream, firststream.available()) |
michael@0 | 29 | firststream.close(); |
michael@0 | 30 | |
michael@0 | 31 | gTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer); |
michael@0 | 32 | gTimer.initWithCallback(function() |
michael@0 | 33 | { |
michael@0 | 34 | var secondstream = getFileStream("threeframes-end.gif"); |
michael@0 | 35 | response.bodyOutputStream.writeFrom(secondstream, secondstream.available()) |
michael@0 | 36 | secondstream.close(); |
michael@0 | 37 | response.finish(); |
michael@0 | 38 | |
michael@0 | 39 | // This time needs to be longer than the animation timer in |
michael@0 | 40 | // threeframes-start.gif. That's specified as 100ms; just use 5 seconds as |
michael@0 | 41 | // a reasonable upper bound. Since this is just a crashtest, timeouts |
michael@0 | 42 | // aren't a big deal. |
michael@0 | 43 | }, 5 * 1000 /* milliseconds */, Components.interfaces.nsITimer.TYPE_ONE_SHOT); |
michael@0 | 44 | } |