Bug 627015 - Add a crashtest for an image that takes a very long time to download the next frame, giving our animation timer a chance to fire. r=jrmuizel

This commit is contained in:
Joe Drew 2011-08-03 15:22:47 -04:00
parent c33a3e4697
commit 2dab1263e5
4 changed files with 46 additions and 0 deletions

View File

@ -22,3 +22,7 @@ load 256-height.ico
# GIFs with LZW data that isn't terminated properly.
load invalid-lzw-end1.gif
load invalid-lzw-end2.gif
# A 3-frame animated GIF with an inordinate delay between the second and third
# frame.
HTTP load delayedframe.sjs

View File

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

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B