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