Bug 512435 - Tests. r=dolske

This commit is contained in:
Bobby Holley 2009-09-12 16:44:19 -06:00
parent 698539c8df
commit f9b8d27445
5 changed files with 62 additions and 0 deletions

View File

@ -62,6 +62,9 @@ _TEST_FILES = imgutils.js \
bug496292-iframe-2.html \
bug496292-1.sjs \
bug496292-2.sjs \
test_bug512435.html \
damon.jpg \
shaver.png \
$(NULL)
libs:: $(_TEST_FILES)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -3,6 +3,15 @@
// Note that this is use by tests elsewhere in the source tree. When in doubt,
// check mxr before removing or changing functionality.
// Helper function to clear the image cache of content images
function clearImageCache()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var imageCache = Components.classes["@mozilla.org/image/cache;1"]
.getService(Components.interfaces.imgICache);
imageCache.clearCache(false); // true=chrome, false=content
}
// Helper function to determine if the frame is decoded for a given image id
function isFrameDecoded(id)
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -0,0 +1,50 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=512435
-->
<head>
<title>Test for Bug 512435</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/modules/libpr0n/test/mochitest/imgutils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=512435">Mozilla Bug 512435</a>
<img id="img_a">
<img id="img_b">
</div>
<pre id="test">
<script type="application/javascript">
// Boilerplate
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
const Ci = Components.interfaces;
const Cc = Components.classes;
SimpleTest.waitForExplicitFinish();
// We're relying on very particular behavior for certain images - clear the
// image cache, _then_ set src
clearImageCache();
document.getElementById("img_a").src = "damon.jpg";
document.getElementById("img_b").src = "shaver.png";
// Our handler
function loadHandler() {
// The two images should be decoded
ok(isFrameDecoded("img_a"), "img_a should be decoded before onload fires");
ok(isFrameDecoded("img_b"), "img_b should be decoded before onload fires");
// All done
SimpleTest.finish();
}
// Set our onload handler
window.onload = loadHandler;
</script>
</pre>
</body>
</html>