Bug 1354499. Fix test_discardAnimatedImage.html to not call finish multiple times.
☠☠ backed out by 21062cd63dd7 ☠ ☠
authorTimothy Nikkel <tnikkel@gmail.com>
Fri, 07 Apr 2017 16:11:14 -0500
changeset 351979 17d681fd2b32864ddc6a1c7182998abafa3af936
parent 351978 d16bffb1859d7120bc82c0b39bb7d9fc664e8816
child 351980 50aee6c869012859a3395ddfda2aa4fd62fff1c5
push id31624
push userarchaeopteryx@coole-files.de
push dateSat, 08 Apr 2017 20:49:20 +0000
treeherdermozilla-central@2a3ecdb7d1ea [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1354499
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1354499. Fix test_discardAnimatedImage.html to not call finish multiple times. We can have multiple setTimeouts from multiple frame update notifications in flight at the same time. If one of them reaches the finishing conditions the rest will too. So just guard calling finish with a global bool.
image/test/mochitest/test_discardAnimatedImage.html
--- a/image/test/mochitest/test_discardAnimatedImage.html
+++ b/image/test/mochitest/test_discardAnimatedImage.html
@@ -23,16 +23,18 @@ https://bugzilla.mozilla.org/show_bug.cg
   </div>
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 686905. **/
 SimpleTest.waitForExplicitFinish();
 
+var gFinished = false;
+
 var gNumDiscards = 0;
 
 window.onload = function() {
   // Enable discarding for the test.
   SpecialPowers.pushPrefEnv({
     'set':[['image.mem.discardable',true]]
   }, runTest);
 }
@@ -95,21 +97,26 @@ function step4() {
 
   // Draw the images to canvas to force them to be decoded again.
   for (var i = 0; i < gImgs.length; i++) {
     drawCanvas(document.getElementById(gImgs[i]));
   }
 }
 
 function checkIfFinished() {
+  if (gFinished) {
+    return;
+  }
+
   if ((gNumFrameUpdates[0] >= kNumFrameUpdatesToExpect) &&
       (gNumFrameUpdates[1] >= kNumFrameUpdatesToExpect) &&
       (gNumSnapShotChanges[0] >= kNumFrameUpdatesToExpect) &&
       (gNumSnapShotChanges[1] >= kNumFrameUpdatesToExpect)) {
     ok(true, "got expected frame updates");
+    gFinished = true;
     SimpleTest.finish();
   }
 }
 
 // arrayIndex is the index into the arrays gNumFrameUpdates and gNumDecodes
 // to increment when a frame update notification is received.
 function addCallbacks(anImage, arrayIndex) {
   var observer = new ImageDecoderObserverStub();