PageRenderTime 31ms CodeModel.GetById 14ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/image/test/mochitest/test_bug399925.html

http://github.com/zpao/v8monkey
HTML | 80 lines | 64 code | 13 blank | 3 comment | 0 complexity | cc388589a2523051e660d031871280bc MD5 | raw file
 1<!DOCTYPE HTML>
 2<html>
 3<!--
 4https://bugzilla.mozilla.org/show_bug.cgi?id=399925
 5-->
 6<head>
 7  <title>Test for Bug 399925</title>
 8  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 9  <script type="text/javascript" src="imgutils.js"></script>
10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
11</head>
12<body>
13<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=399925">Mozilla Bug 399925</a>
14<p id="display"></p>
15<div id="content" style="display: none">
16<img src="bug399925.gif" id="gif" />
17<canvas id="canvas" width="100" height="100"> </canvas>  
18</div>
19<pre id="test">
20<script class="testbody" type="text/javascript">
21
22/** Test for Bug 399925. **/
23var pngResults = new Array();
24var oldTimeoutPref;
25var oldDiscardPref;
26SimpleTest.waitForExplicitFinish();
27window.onload = runTest;
28
29function runTest()
30{
31  // Get the old discard timeout
32  oldTimeoutPref = getImagePref(DISCARD_TIMEOUT_PREF);
33
34  // We're testing discarding here, so we should make sure it's flipped on
35  oldDiscardPref = getImagePref(DISCARD_ENABLED_PREF);
36
37  // Enable Discarding
38  setImagePref(DISCARD_ENABLED_PREF, true);
39
40  // Sets the discard timer to 500ms so we don't have to wait so long. The
41  // actual time is nondeterministic, but is bounded by 2 * timer = 1 second.
42  setImagePref(DISCARD_TIMEOUT_PREF, 1000);
43
44  // Create the image _after_ setting the discard timer pref
45  var image = new Image();
46  image.setAttribute("id", "gif");
47  image.src = "bug399925.gif";
48  document.getElementById("content").appendChild(image);
49
50  // draw the canvas once
51  drawCanvas();
52
53  // Set the timeout to draw it after discard
54  setTimeout('drawCanvas(); allDone();', 3000);
55}
56
57function drawCanvas()
58{
59    var canvas = document.getElementById('canvas');
60    var context = canvas.getContext('2d');
61    var gif = document.getElementById('gif');
62
63    context.drawImage(gif, 0, 0);
64    ok(true, "we got through the drawImage call without an exception being thrown");
65    pngResults.push(canvas.toDataURL);
66}
67
68function allDone()
69{
70    is(pngResults[0], pngResults[1], "got different rendered results");
71    setImagePref(DISCARD_TIMEOUT_PREF, oldTimeoutPref);
72    setImagePref(DISCARD_ENABLED_PREF, oldDiscardPref);
73    SimpleTest.finish();
74}
75
76</script>
77</pre>
78</body>
79</html>
80