michael@0: function getFileStream(filename) michael@0: { michael@0: // Get the location of this sjs file, and then use that to figure out where michael@0: // to find where our other files are. michael@0: var self = Components.classes["@mozilla.org/file/local;1"] michael@0: .createInstance(Components.interfaces.nsILocalFile); michael@0: self.initWithPath(getState("__LOCATION__")); michael@0: var file = self.parent; michael@0: file.append(filename); michael@0: dump(file.path + "\n"); michael@0: michael@0: var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1'] michael@0: .createInstance(Components.interfaces.nsIFileInputStream); michael@0: fileStream.init(file, 1, 0, false); michael@0: michael@0: return fileStream; michael@0: } michael@0: michael@0: var gTimer; michael@0: michael@0: function handleRequest(request, response) michael@0: { michael@0: response.processAsync(); michael@0: response.setStatusLine(request.httpVersion, 200, "OK"); michael@0: response.setHeader("Content-Type", "image/gif", false); michael@0: michael@0: var firststream = getFileStream("threeframes-start.gif"); michael@0: response.bodyOutputStream.writeFrom(firststream, firststream.available()) michael@0: firststream.close(); michael@0: michael@0: gTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer); michael@0: gTimer.initWithCallback(function() michael@0: { michael@0: var secondstream = getFileStream("threeframes-end.gif"); michael@0: response.bodyOutputStream.writeFrom(secondstream, secondstream.available()) michael@0: secondstream.close(); michael@0: response.finish(); michael@0: michael@0: // This time needs to be longer than the animation timer in michael@0: // threeframes-start.gif. That's specified as 100ms; just use 5 seconds as michael@0: // a reasonable upper bound. Since this is just a crashtest, timeouts michael@0: // aren't a big deal. michael@0: }, 5 * 1000 /* milliseconds */, Components.interfaces.nsITimer.TYPE_ONE_SHOT); michael@0: }