image/test/crashtests/delayedframe.sjs

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/test/crashtests/delayedframe.sjs	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +function getFileStream(filename)
     1.5 +{
     1.6 +  // Get the location of this sjs file, and then use that to figure out where
     1.7 +  // to find where our other files are.
     1.8 +  var self = Components.classes["@mozilla.org/file/local;1"]
     1.9 +                       .createInstance(Components.interfaces.nsILocalFile);
    1.10 +  self.initWithPath(getState("__LOCATION__"));
    1.11 +  var file = self.parent;
    1.12 +  file.append(filename);
    1.13 +  dump(file.path + "\n");
    1.14 +
    1.15 +  var fileStream = Components.classes['@mozilla.org/network/file-input-stream;1']
    1.16 +                     .createInstance(Components.interfaces.nsIFileInputStream);
    1.17 +  fileStream.init(file, 1, 0, false);
    1.18 +
    1.19 +  return fileStream;
    1.20 +}
    1.21 +
    1.22 +var gTimer;
    1.23 +
    1.24 +function handleRequest(request, response)
    1.25 +{
    1.26 +  response.processAsync();
    1.27 +  response.setStatusLine(request.httpVersion, 200, "OK");
    1.28 +  response.setHeader("Content-Type", "image/gif", false);
    1.29 +
    1.30 +  var firststream = getFileStream("threeframes-start.gif");
    1.31 +  response.bodyOutputStream.writeFrom(firststream, firststream.available())
    1.32 +  firststream.close();
    1.33 +
    1.34 +  gTimer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
    1.35 +  gTimer.initWithCallback(function()
    1.36 +  {
    1.37 +    var secondstream = getFileStream("threeframes-end.gif");
    1.38 +    response.bodyOutputStream.writeFrom(secondstream, secondstream.available())
    1.39 +    secondstream.close();
    1.40 +    response.finish();
    1.41 +
    1.42 +    // This time needs to be longer than the animation timer in
    1.43 +    // threeframes-start.gif. That's specified as 100ms; just use 5 seconds as
    1.44 +    // a reasonable upper bound. Since this is just a crashtest, timeouts
    1.45 +    // aren't a big deal.
    1.46 +  }, 5 * 1000 /* milliseconds */, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
    1.47 +}

mercurial