image/test/mochitest/test_bug466586.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

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=466586
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 466586</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 10 </head>
michael@0 11
michael@0 12 <body onload="loadSmall();">
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">Mozilla Bug 466586</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16 <img id="big" src="big.png"/>
michael@0 17 </div>
michael@0 18 <pre id="test">
michael@0 19 <script type="application/javascript">
michael@0 20
michael@0 21 SimpleTest.waitForExplicitFinish();
michael@0 22
michael@0 23 var jsBig = new Image();
michael@0 24
michael@0 25 // We have loaded the large png with id "big". We want to test if it will be
michael@0 26 // kicked out of the cache and thus have to be reloaded, but to ensure that, we
michael@0 27 // need to get the cache to look at what is there. So we load another image,
michael@0 28 // this one small.
michael@0 29 function loadSmall()
michael@0 30 {
michael@0 31 // Trivial check, for reference.
michael@0 32 is(document.getElementById("big").width, 3000,
michael@0 33 "HTML 'big' image width after page onload()");
michael@0 34
michael@0 35 var small = new Image();
michael@0 36 small.onload = smallLoaded;
michael@0 37 small.src = "red.png";
michael@0 38 }
michael@0 39
michael@0 40 function smallLoaded()
michael@0 41 {
michael@0 42 jsBig.src = document.getElementById("big").src;
michael@0 43 // Check that it is not needed to wait for onload().
michael@0 44 is(jsBig.width, 3000, "JS 'big' image width before its onload()");
michael@0 45 // Check again after onload(), for reference.
michael@0 46 jsBig.onload = jsBigLoaded;
michael@0 47 }
michael@0 48
michael@0 49 function jsBigLoaded()
michael@0 50 {
michael@0 51 is(jsBig.width, 3000, "JS 'big' image width after its onload()");
michael@0 52
michael@0 53 SimpleTest.finish();
michael@0 54 }
michael@0 55 </script>
michael@0 56 </pre>
michael@0 57 </body>
michael@0 58 </html>

mercurial