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