Bug 686026 - test_mozGetAsFile.html runs finish three times, instead of once; r=joedrew
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 09 Sep 2011 18:17:50 -0400
changeset 76852 67e54020dce568e2c2ba7590b54f285863ed7371
parent 76851 52550df07858516ff527f7507b8289bbeca9b979
child 76853 d04d43c81294ce6073b9cb6c622886e575a27d1f
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjoedrew
bugs686026
milestone9.0a1
Bug 686026 - test_mozGetAsFile.html runs finish three times, instead of once; r=joedrew
content/canvas/test/test_mozGetAsFile.html
--- a/content/canvas/test/test_mozGetAsFile.html
+++ b/content/canvas/test/test_mozGetAsFile.html
@@ -2,26 +2,30 @@
 <title>Canvas test: mozGetAsFile</title>
 <script src="/MochiKit/MochiKit.js"></script>
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 <body>
 <canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
 <script>
 
+var gCompares = 0;
+
 function compareAsync(file, canvas, type)
 {
-  SimpleTest.waitForExplicitFinish();
+  ++gCompares;
 
   var reader = new FileReader();
   reader.onload = 
     function(e) {
       is(e.target.result, canvas.toDataURL(type),
  "<canvas>.mozGetAsFile().getAsDataURL() should equal <canvas>.toDataURL()");
-      SimpleTest.finish();
+      if (--gCompares == 0) {
+        SimpleTest.finish();
+      }
     };
   reader.readAsDataURL(file);
 }
 
 SimpleTest.waitForExplicitFinish();
 addLoadEvent(function () {
 
 var canvas = document.getElementById('c');
@@ -35,14 +39,12 @@ compareAsync(pngfile, canvas, "image/png
 is(pngfile.name, "foo.png", "File name should be what we passed in");
 
 var jpegfile = canvas.mozGetAsFile("bar.jpg", "image/jpeg");
 is(jpegfile.type, "image/jpeg",
    "When a valid type is specified that should be returned");
 compareAsync(jpegfile, canvas, "image/jpeg");
 is(jpegfile.name, "bar.jpg", "File name should be what we passed in");
 
-SimpleTest.finish();
-
 });
 </script>
 <img src="image_yellow75.png" id="yellow75.png" class="resource">