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