gecko/image/test/mochitest/test_bug733553.html

75 lines
2.0 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=733553
-->
<head>
<title>Test for Bug 733553</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="initializeOnload()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=733553">Mozilla Bug 733553</a>
<p id="display"></p>
<pre id="test">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var testIndex = -1;
var testParts = [
[1, "red.png"],
[40, "animated-gif2.gif"],
[1, "red.png"],
[100, "lime100x100.svg"],
[100, "lime100x100.svg"],
[40, "animated-gif2.gif"],
[1, "red.png"],
[80, "damon.jpg"],
[80, "damon.jpg"],
[80, "damon.jpg"]
];
// We'll append the part number to this, and tell the informant
const BASE_URL = "bug733553-informant.sjs?";
function initializeOnload() {
var firstimg = document.createElement('img');
firstimg.addEventListener("load", imageLoad, false);
firstimg.addEventListener("error", imageLoad, false);
firstimg.src = "bug733553.sjs";
document.getElementById('content').appendChild(firstimg);
// Really ready for first, but who's counting
readyForNext();
}
function readyForNext() {
var loader = document.getElementById("loader");
loader.src = BASE_URL + ++testIndex;
}
function imageLoad(aEvent) {
if (testParts.length > testIndex) {
var [width, fileName] = testParts[testIndex];
is(aEvent.target.width, width,
"Test " + testIndex + " " + fileName + " width correct");
readyForNext();
} else {
aEvent.target.removeEventListener("load", imageLoad, false);
aEvent.target.removeEventListener("error", imageLoad, false);
var loader = document.getElementById("loader");
readyForNext();
SimpleTest.finish();
}
}
</script>
</pre>
<div id="content"> <!-- style="display: none" -->
<iframe id="loader"></iframe>
</div>
</body>
</html>