2008-03-29 06:53:25 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=399925
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 399925</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
2010-07-13 17:30:39 +00:00
|
|
|
<script type="text/javascript" src="imgutils.js"></script>
|
2008-03-29 06:53:25 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
2010-07-13 17:30:39 +00:00
|
|
|
<body>
|
2008-03-29 06:53:25 +00:00
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=399925">Mozilla Bug 399925</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
<img src="bug399925.gif" id="gif" />
|
|
|
|
<canvas id="canvas" width="100" height="100"> </canvas>
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2010-07-13 17:30:39 +00:00
|
|
|
/** Test for Bug 399925. **/
|
|
|
|
var pngResults = new Array();
|
|
|
|
var oldTimeoutPref;
|
|
|
|
var oldDiscardPref;
|
2008-03-29 06:53:25 +00:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
2010-07-13 17:30:39 +00:00
|
|
|
window.onload = runTest;
|
2008-03-29 06:53:25 +00:00
|
|
|
|
2010-07-13 17:30:39 +00:00
|
|
|
function runTest()
|
|
|
|
{
|
|
|
|
// Get the old discard timeout
|
|
|
|
oldTimeoutPref = getImagePref(DISCARD_TIMEOUT_PREF);
|
|
|
|
|
|
|
|
// We're testing discarding here, so we should make sure it's flipped on
|
|
|
|
oldDiscardPref = getImagePref(DISCARD_ENABLED_PREF);
|
|
|
|
|
|
|
|
// Enable Discarding
|
|
|
|
setImagePref(DISCARD_ENABLED_PREF, true);
|
|
|
|
|
|
|
|
// Sets the discard timer to 500ms so we don't have to wait so long. The
|
|
|
|
// actual time is nondeterministic, but is bounded by 2 * timer = 1 second.
|
|
|
|
setImagePref(DISCARD_TIMEOUT_PREF, 1000);
|
|
|
|
|
|
|
|
// Create the image _after_ setting the discard timer pref
|
|
|
|
var image = new Image();
|
|
|
|
image.setAttribute("id", "gif");
|
|
|
|
image.src = "bug399925.gif";
|
|
|
|
document.getElementById("content").appendChild(image);
|
|
|
|
|
|
|
|
// draw the canvas once
|
|
|
|
drawCanvas();
|
|
|
|
|
|
|
|
// Set the timeout to draw it after discard
|
|
|
|
setTimeout('drawCanvas(); allDone();', 3000);
|
|
|
|
}
|
2008-03-29 06:53:25 +00:00
|
|
|
|
|
|
|
function drawCanvas()
|
|
|
|
{
|
|
|
|
var canvas = document.getElementById('canvas');
|
|
|
|
var context = canvas.getContext('2d');
|
|
|
|
var gif = document.getElementById('gif');
|
|
|
|
|
|
|
|
context.drawImage(gif, 0, 0);
|
|
|
|
ok(true, "we got through the drawImage call without an exception being thrown");
|
|
|
|
pngResults.push(canvas.toDataURL);
|
|
|
|
}
|
|
|
|
|
|
|
|
function allDone()
|
|
|
|
{
|
|
|
|
is(pngResults[0], pngResults[1], "got different rendered results");
|
2010-07-13 17:30:39 +00:00
|
|
|
setImagePref(DISCARD_TIMEOUT_PREF, oldTimeoutPref);
|
|
|
|
setImagePref(DISCARD_ENABLED_PREF, oldDiscardPref);
|
2008-03-29 06:53:25 +00:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|