image/test/mochitest/test_bug733553.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/image/test/mochitest/test_bug733553.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=733553
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 733553</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 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body onload="initializeOnload()">
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=733553">Mozilla Bug 733553</a>
    1.17 +<p id="display"></p>
    1.18 +<pre id="test">
    1.19 +<script type="application/javascript">
    1.20 +
    1.21 +SimpleTest.waitForExplicitFinish();
    1.22 +
    1.23 +var testIndex = -1;
    1.24 +var testParts = [
    1.25 +  [1, "red.png"],
    1.26 +  [40, "animated-gif2.gif"],
    1.27 +  [1, "red.png"],
    1.28 +  [100, "lime100x100.svg"],
    1.29 +  [100, "lime100x100.svg"],
    1.30 +  [40, "animated-gif2.gif"],
    1.31 +  [1, "red.png"],
    1.32 +  // Note a failure of the next 'red.png' may indicate failure of resniffing on
    1.33 +  // this part ('shaver.png'); see bug 907575.
    1.34 +  [177, "shaver.png"],
    1.35 +  [1, "red.png"],
    1.36 +  [80, "damon.jpg"],
    1.37 +  [80, "damon.jpg"],
    1.38 +  [80, "damon.jpg"],
    1.39 +  // An invalid image (from bug 787899) that is further delivered with a
    1.40 +  // "special" bad MIME type that indicates that the necko
    1.41 +  // multipart/x-mixed-replace parser wasn't able to parse it.
    1.42 +  [0, "rillybad.jpg"],
    1.43 +  [80, "damon.jpg"],
    1.44 +  [0, "bad.jpg"],
    1.45 +  [1, "red.png"],
    1.46 +  [0, "invalid.jpg"],
    1.47 +  [40, "animated-gif2.gif"]
    1.48 +];
    1.49 +
    1.50 +// We'll append the part number to this, and tell the informant
    1.51 +const BASE_URL = "bug733553-informant.sjs?";
    1.52 +
    1.53 +function initializeOnload() {
    1.54 +  var firstimg = document.createElement('img');
    1.55 +  firstimg.addEventListener("load", imageLoad, false);
    1.56 +  firstimg.addEventListener("error", imageLoad, false);
    1.57 +  firstimg.alt = "";
    1.58 +  firstimg.src = "bug733553.sjs";
    1.59 +  document.getElementById('content').appendChild(firstimg);
    1.60 +
    1.61 +  // Really ready for first, but who's counting
    1.62 +  readyForNext();
    1.63 +}
    1.64 +
    1.65 +function readyForNext() {
    1.66 +  var loader = document.getElementById("loader");
    1.67 +  loader.src = BASE_URL + ++testIndex;
    1.68 +}
    1.69 +
    1.70 +function imageLoad(aEvent) {
    1.71 +  var [width, fileName] = testParts[testIndex];
    1.72 +  is(aEvent.target.width, width,
    1.73 +     "Test " + testIndex + " " + fileName + " width correct");
    1.74 +
    1.75 +  // Always call readyForNext here, as it's the closest we have to a cleanup
    1.76 +  readyForNext();
    1.77 +  if (testParts.length == testIndex) {
    1.78 +    var firstimg = document.getElementsByTagName('img')[0];
    1.79 +    firstimg.removeEventListener("load", imageLoad, false);
    1.80 +    firstimg.removeEventListener("error", imageLoad, false);
    1.81 +    SimpleTest.finish();
    1.82 +  }
    1.83 +}
    1.84 +
    1.85 +</script>
    1.86 +</pre>
    1.87 +<div id="content"> <!-- style="display: none" -->
    1.88 +<iframe id="loader"></iframe>
    1.89 +</div>
    1.90 +</body>
    1.91 +</html>

mercurial