1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/test/mochitest/test_bug466586.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,58 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=466586 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 466586</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 + 1.15 +<body onload="loadSmall();"> 1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">Mozilla Bug 466586</a> 1.17 +<p id="display"></p> 1.18 +<div id="content" style="display: none"> 1.19 + <img id="big" src="big.png"/> 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script type="application/javascript"> 1.23 + 1.24 +SimpleTest.waitForExplicitFinish(); 1.25 + 1.26 +var jsBig = new Image(); 1.27 + 1.28 +// We have loaded the large png with id "big". We want to test if it will be 1.29 +// kicked out of the cache and thus have to be reloaded, but to ensure that, we 1.30 +// need to get the cache to look at what is there. So we load another image, 1.31 +// this one small. 1.32 +function loadSmall() 1.33 +{ 1.34 + // Trivial check, for reference. 1.35 + is(document.getElementById("big").width, 3000, 1.36 + "HTML 'big' image width after page onload()"); 1.37 + 1.38 + var small = new Image(); 1.39 + small.onload = smallLoaded; 1.40 + small.src = "red.png"; 1.41 +} 1.42 + 1.43 +function smallLoaded() 1.44 +{ 1.45 + jsBig.src = document.getElementById("big").src; 1.46 + // Check that it is not needed to wait for onload(). 1.47 + is(jsBig.width, 3000, "JS 'big' image width before its onload()"); 1.48 + // Check again after onload(), for reference. 1.49 + jsBig.onload = jsBigLoaded; 1.50 +} 1.51 + 1.52 +function jsBigLoaded() 1.53 +{ 1.54 + is(jsBig.width, 3000, "JS 'big' image width after its onload()"); 1.55 + 1.56 + SimpleTest.finish(); 1.57 +} 1.58 +</script> 1.59 +</pre> 1.60 +</body> 1.61 +</html>