image/test/mochitest/test_bug435296.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/test/mochitest/test_bug435296.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=435296
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 435296</title>
    1.11 +  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
    1.12 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <script type="application/javascript" src="imgutils.js"></script>
    1.14 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +</head>
    1.16 +<body>
    1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435296">Mozilla Bug 435296</a>
    1.18 +<img id="testimage" style="display: none;">
    1.19 +<pre id="test">
    1.20 +<script type="application/javascript">
    1.21 +
    1.22 +// Boilerplate
    1.23 +SimpleTest.waitForExplicitFinish();
    1.24 +
    1.25 +// Assert that discarding isn't enabled, which might make this test go orange.
    1.26 +ok(!getImagePref(DISCARD_ENABLED_PREF), "discarding should NOT be enabled here");
    1.27 +
    1.28 +// We want to make sure d-o-d is enabled, since that's what we're testing
    1.29 +var oldDODPref = getImagePref(DECODEONDRAW_ENABLED_PREF);
    1.30 +setImagePref(DECODEONDRAW_ENABLED_PREF, true);
    1.31 +
    1.32 +// We're relying on very particular behavior for certain images - clear the
    1.33 +// image cache.
    1.34 +clearImageCache();
    1.35 +
    1.36 +// In order to work around the effects introduced in bug 512435, we only load
    1.37 +// the image after window onload fires
    1.38 +function windowLoadHandler()
    1.39 +{
    1.40 +  // Set the source and an onload handler
    1.41 +  var image = document.getElementById("testimage");
    1.42 +  image.src = "schrep.png";
    1.43 +  image.onload = imageLoadHandler;
    1.44 +}
    1.45 +
    1.46 +function imageLoadHandler()
    1.47 +{
    1.48 +  // The image is hidden, so it should not be decoded
    1.49 +  ok(!isFrameDecoded("testimage"), "image should not be decoded");
    1.50 +
    1.51 +  // Make the image visible
    1.52 +  var image = document.getElementById("testimage");
    1.53 +  image.style.display = "inline";
    1.54 +
    1.55 +  // Wait for the image to decode
    1.56 +  setTimeout("tryToFinish();", 500);
    1.57 +}
    1.58 +
    1.59 +function tryToFinish()
    1.60 +{
    1.61 +  // If it hasn't happened yet, wait longer. If it never happens, this test
    1.62 +  // will timeout after 300 seconds...
    1.63 +  if (!isFrameDecoded("testimage")) {
    1.64 +    setTimeout("tryToFinish();", 500);
    1.65 +    return;
    1.66 +  }
    1.67 +
    1.68 +  // By definition, the image is decoded here. Give ourselves a pat on the back.
    1.69 +  ok(isFrameDecoded("testimage"), "image should be decoded");
    1.70 +
    1.71 +  // Restore the decode-on-draw pref
    1.72 +  setImagePref(DECODEONDRAW_ENABLED_PREF, oldDODPref);
    1.73 +
    1.74 +  // All done
    1.75 +  SimpleTest.finish();
    1.76 +}
    1.77 +
    1.78 +// Set our onload handler, making sure we have focus
    1.79 +window.onload = SimpleTest.waitForFocus(windowLoadHandler);
    1.80 +
    1.81 +</script>
    1.82 +</pre>
    1.83 +</body>
    1.84 +</html>

mercurial