Bug 490384. (Dv1a) Improve and reenable test_bug466586.html. r=joe.
authorSerge Gautherie <sgautherie.bz@free.fr>
Tue, 24 Jan 2012 07:02:07 +0100
changeset 86338 c1fd381a7faa4bb3bfe606bebcdd1c0a0fc8ef74
parent 86337 3e6a0fe556508baf4b9c07578f82e181e65e267d
child 86339 965f4bc3fc210abfdd33f736b7565a10235c4185
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoe
bugs490384, 466586
milestone12.0a1
Bug 490384. (Dv1a) Improve and reenable test_bug466586.html. r=joe.
image/test/mochitest/test_bug466586.html
--- a/image/test/mochitest/test_bug466586.html
+++ b/image/test/mochitest/test_bug466586.html
@@ -3,47 +3,56 @@
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=466586
 -->
 <head>
   <title>Test for Bug 466586</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 </head>
-<body onload="loadSmall()">
+
+<body onload="loadSmall();">
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=89419">Mozilla Bug 466586</a>
 <p id="display"></p>
 <div id="content" style="display: none">
-<img src="big.png" width="100" height="100" id="big" />
+  <img id="big" src="big.png"/>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
-// We have loaded the large png with id "big". We want to test if it'll be
+var jsBig = new Image();
+
+// We have loaded the large png with id "big". We want to test if it will be
 // kicked out of the cache and thus have to be reloaded, but to ensure that, we
-// need to get the cache to look at what's there. So we load another image,
+// need to get the cache to look at what is there. So we load another image,
 // this one small.
 function loadSmall()
 {
-  var small = new Image();
+  // Trivial check, for reference.
+  is(document.getElementById("big").width, 3000,
+     "HTML 'big' image width after page onload()");
 
+  var small = new Image();
   small.onload = smallLoaded;
-  small.src="red.png";
+  small.src = "red.png";
 }
 
 function smallLoaded()
 {
-  // Make sure that we don't need another load.
-  var big = document.getElementById('big');
-  var img = new Image();
-  img.src = big.src;
-// temporarily disabled while we work out why it's failing (bug 490384)
-//  ok(img.width != 0);
-  ok(true);
+  jsBig.src = document.getElementById("big").src;
+  // Check that it is not needed to wait for onload().
+  is(jsBig.width, 3000, "JS 'big' image width before its onload()");
+  // Check again after onload(), for reference.
+  jsBig.onload = jsBigLoaded;
+}
+
+function jsBigLoaded()
+{
+  is(jsBig.width, 3000, "JS 'big' image width after its onload()");
 
   SimpleTest.finish();
 }
 </script>
 </pre>
 </body>
 </html>