test_bug733553.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=733553
  5. -->
  6. <head>
  7. <title>Test for Bug 733553</title>
  8. <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. </head>
  12. <body onload="initializeOnload()">
  13. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=733553">Mozilla Bug 733553</a>
  14. <p id="display"></p>
  15. <pre id="test">
  16. <script type="application/javascript">
  17. SimpleTest.waitForExplicitFinish();
  18. var testIndex = -1;
  19. var testParts = [
  20. [1, "red.png"],
  21. [40, "animated-gif2.gif"],
  22. [1, "red.png"],
  23. [100, "lime100x100.svg"],
  24. [100, "lime100x100.svg"],
  25. [40, "animated-gif2.gif"],
  26. [1, "red.png"],
  27. // Note a failure of the next 'red.png' may indicate failure of resniffing on
  28. // this part ('shaver.png'); see bug 907575.
  29. [177, "shaver.png"],
  30. [1, "red.png"],
  31. [80, "damon.jpg"],
  32. [80, "damon.jpg"],
  33. [80, "damon.jpg"],
  34. // An invalid image (from bug 787899) that is further delivered with a
  35. // "special" bad MIME type that indicates that the necko
  36. // multipart/x-mixed-replace parser wasn't able to parse it.
  37. // We use a width of 80 because MultipartImage will just drop rillybad.jpg
  38. // and re-present damon.jpg.
  39. [80, "rillybad.jpg"],
  40. [80, "damon.jpg"],
  41. // Similarly, we'll drop bad.jpg, so we use damon.jpg's width.
  42. [80, "bad.jpg"],
  43. [1, "red.png"],
  44. // We also drop invalid.jpg, so we use red.png's width.
  45. [1, "invalid.jpg"],
  46. [40, "animated-gif2.gif"]
  47. ];
  48. // We'll append the part number to this, and tell the informant
  49. const BASE_URL = "bug733553-informant.sjs?";
  50. function initializeOnload() {
  51. var firstimg = document.createElement('img');
  52. firstimg.addEventListener("load", imageLoad, false);
  53. firstimg.addEventListener("error", imageLoad, false);
  54. firstimg.alt = "";
  55. firstimg.src = "bug733553.sjs";
  56. document.getElementById('content').appendChild(firstimg);
  57. // Really ready for first, but who's counting
  58. readyForNext();
  59. }
  60. function readyForNext() {
  61. var loader = document.getElementById("loader");
  62. loader.src = BASE_URL + ++testIndex;
  63. }
  64. function imageLoad(aEvent) {
  65. var [width, fileName] = testParts[testIndex];
  66. is(aEvent.target.width, width,
  67. "Test " + testIndex + " " + fileName + " width correct");
  68. // Always call readyForNext here, as it's the closest we have to a cleanup
  69. readyForNext();
  70. if (testParts.length == testIndex) {
  71. var firstimg = document.getElementsByTagName('img')[0];
  72. firstimg.removeEventListener("load", imageLoad, false);
  73. firstimg.removeEventListener("error", imageLoad, false);
  74. SimpleTest.finish();
  75. }
  76. }
  77. </script>
  78. </pre>
  79. <div id="content"> <!-- style="display: none" -->
  80. <iframe id="loader"></iframe>
  81. </div>
  82. </body>
  83. </html>