test_bug435296.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=435296
  5. -->
  6. <head>
  7. <title>Test for Bug 435296</title>
  8. <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <script type="application/javascript" src="imgutils.js"></script>
  11. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  12. </head>
  13. <body>
  14. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=435296">Mozilla Bug 435296</a>
  15. <img id="testimage" style="display: none;">
  16. <pre id="test">
  17. <script type="application/javascript">
  18. // Boilerplate
  19. SimpleTest.waitForExplicitFinish();
  20. // Assert that discarding isn't enabled, which might make this test go orange.
  21. ok(!getImagePref(DISCARD_ENABLED_PREF), "discarding should NOT be enabled here");
  22. // We want to make sure d-o-d is enabled, since that's what we're testing
  23. var oldDODPref = getImagePref(DECODEONDRAW_ENABLED_PREF);
  24. setImagePref(DECODEONDRAW_ENABLED_PREF, true);
  25. // We're relying on very particular behavior for certain images - clear the
  26. // image cache.
  27. clearImageCache();
  28. // In order to work around the effects introduced in bug 512435, we only load
  29. // the image after window onload fires
  30. function windowLoadHandler()
  31. {
  32. // Set the source and an onload handler
  33. var image = document.getElementById("testimage");
  34. image.src = "schrep.png";
  35. image.onload = imageLoadHandler;
  36. }
  37. function imageLoadHandler()
  38. {
  39. // The image is hidden, so it should not be decoded
  40. ok(!isFrameDecoded("testimage"), "image should not be decoded");
  41. // Make the image visible
  42. var image = document.getElementById("testimage");
  43. image.style.display = "inline";
  44. // Wait for the image to decode
  45. setTimeout("tryToFinish();", 500);
  46. }
  47. function tryToFinish()
  48. {
  49. // If it hasn't happened yet, wait longer. If it never happens, this test
  50. // will timeout after 300 seconds...
  51. if (!isFrameDecoded("testimage")) {
  52. setTimeout("tryToFinish();", 500);
  53. return;
  54. }
  55. // By definition, the image is decoded here. Give ourselves a pat on the back.
  56. ok(isFrameDecoded("testimage"), "image should be decoded");
  57. // Restore the decode-on-draw pref
  58. setImagePref(DECODEONDRAW_ENABLED_PREF, oldDODPref);
  59. // All done
  60. SimpleTest.finish();
  61. }
  62. // Set our onload handler, making sure we have focus
  63. window.onload = SimpleTest.waitForFocus(windowLoadHandler);
  64. </script>
  65. </pre>
  66. </body>
  67. </html>