зеркало из https://github.com/mozilla/pjs.git
81 строка
2.3 KiB
HTML
81 строка
2.3 KiB
HTML
<!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>
|
|
<script type="text/javascript" src="imgutils.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=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">
|
|
|
|
/** Test for Bug 399925. **/
|
|
var pngResults = new Array();
|
|
var oldTimeoutPref;
|
|
var oldDiscardPref;
|
|
SimpleTest.waitForExplicitFinish();
|
|
window.onload = runTest;
|
|
|
|
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);
|
|
}
|
|
|
|
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");
|
|
setImagePref(DISCARD_TIMEOUT_PREF, oldTimeoutPref);
|
|
setImagePref(DISCARD_ENABLED_PREF, oldDiscardPref);
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
</script>
|
|
</pre>
|
|
</body>
|
|
</html>
|
|
|