mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 01:08:21 +00:00
Bug 767779 - Test slow-loading GIF with trailing garbage. r=joe
This commit is contained in:
parent
9d7a44f0bf
commit
dd7b3481e3
@ -12,6 +12,7 @@ relativesrcdir = image/test/mochitest
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MOCHITEST_FILES = imgutils.js \
|
||||
animationPolling.js \
|
||||
lime100x100.svg \
|
||||
test_bug399925.html \
|
||||
bug399925.gif \
|
||||
@ -57,6 +58,9 @@ MOCHITEST_FILES = imgutils.js \
|
||||
bug733553-iframe.html \
|
||||
bug733553.sjs \
|
||||
animated-gif2.gif \
|
||||
test_bug767779.html \
|
||||
bug767779.sjs \
|
||||
animated-gif_trailing-garbage.gif \
|
||||
test_error_events.html \
|
||||
error-early.png \
|
||||
test_drawDiscardedImage.html \
|
||||
|
BIN
image/test/mochitest/animated-gif_trailing-garbage.gif
Normal file
BIN
image/test/mochitest/animated-gif_trailing-garbage.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
56
image/test/mochitest/bug767779.sjs
Normal file
56
image/test/mochitest/bug767779.sjs
Normal file
@ -0,0 +1,56 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
var timer = Components.classes["@mozilla.org/timer;1"];
|
||||
var partTimer = timer.createInstance(Components.interfaces.nsITimer);
|
||||
|
||||
function getFileAsInputStream(aFilename) {
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties)
|
||||
.get("CurWorkD", Components.interfaces.nsIFile);
|
||||
|
||||
file.append("tests");
|
||||
file.append("image");
|
||||
file.append("test");
|
||||
file.append("mochitest");
|
||||
file.append(aFilename);
|
||||
|
||||
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.setHeader("Content-Type", "image/gif", false);
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
response.setStatusLine(request.httpVersion, 200, "OK");
|
||||
// We're sending data off in a delayed fashion
|
||||
response.processAsync();
|
||||
var inputStream = getFileAsInputStream("animated-gif_trailing-garbage.gif");
|
||||
var available = inputStream.available(); // = 4029 bytes
|
||||
// Send the good data at once
|
||||
response.bodyOutputStream.writeFrom(inputStream, 285);
|
||||
sendParts(inputStream, response);
|
||||
}
|
||||
|
||||
function sendParts(inputStream, response) {
|
||||
// 3744 left, send in 8 chunks of 468 each
|
||||
partTimer.initWithCallback(getSendNextPart(inputStream, response), 500,
|
||||
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
||||
|
||||
function getSendNextPart(inputStream, response) {
|
||||
return function () {
|
||||
response.bodyOutputStream.writeFrom(inputStream, 468);
|
||||
if (!inputStream.available()) {
|
||||
inputStream.close();
|
||||
response.finish();
|
||||
} else {
|
||||
sendParts(inputStream, response);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
44
image/test/mochitest/test_bug767779.html
Normal file
44
image/test/mochitest/test_bug767779.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=767779
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 767779</title>
|
||||
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/WindowSnapshot.js"></script>
|
||||
<script type="application/javascript" src="imgutils.js"></script>
|
||||
<script type="application/javascript" src="animationPolling.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=767779">Mozilla Bug 767779</a>
|
||||
<p id="display"></p>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
const FAILURE_TIMEOUT = 30000; // Fail early after 30 seconds
|
||||
|
||||
function main()
|
||||
{
|
||||
// referenceDiv's size and color correspond to the last frame of the GIF
|
||||
var animTest = new AnimationTest(20, FAILURE_TIMEOUT, 'referenceDiv',
|
||||
'animatedGif', 'debug');
|
||||
animTest.beginTest();
|
||||
}
|
||||
|
||||
window.onload = main;
|
||||
</script>
|
||||
</pre>
|
||||
<div id="content"> <!-- style="display: none" -->
|
||||
<div id="referenceDiv" style="height: 40px; width: 40px;
|
||||
display: none; background: #18ff00;"></div>
|
||||
<div id="animatedImage">
|
||||
<img id="animatedGif" src="bug767779.sjs" style="display: none;"/>
|
||||
<div id="text-descr"></div>
|
||||
</div>
|
||||
<div id="debug" style="display:none">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user