Bug 1103652 - Make animSVGImage tests listen for FRAME_UPDATE or poll. r=tn
authorSeth Fowler <seth@mozilla.com>
Mon, 24 Nov 2014 23:42:44 -0800
changeset 217444 bb51e79ff4fa929f851817d78d0c7ed310100a0f
parent 217443 faa77ca026ea5330fda1f9b5b9a76410f63dcd95
child 217445 f5dd8eb32a32768de4d4017f2c5ec405e7a11dee
push id27882
push userryanvm@gmail.com
push dateTue, 25 Nov 2014 21:56:56 +0000
treeherdermozilla-central@ced1402861b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1103652
milestone36.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 1103652 - Make animSVGImage tests listen for FRAME_UPDATE or poll. r=tn
image/test/mochitest/test_animSVGImage.html
image/test/mochitest/test_animSVGImage2.html
--- a/image/test/mochitest/test_animSVGImage.html
+++ b/image/test/mochitest/test_animSVGImage.html
@@ -27,17 +27,17 @@ SimpleTest.waitForExplicitFinish();
 const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const gImg = document.getElementsByTagName("img")[0];
 
 var gMyDecoderObserver; // value will be set in main()
 var gReferenceSnapshot; // value will be set in takeReferenceSnapshot()
-var gOnStopFrameCounter = 0;
+var gPollCounter = 0;
 var gIsTestFinished = false;
 
 
 function takeReferenceSnapshot() {
   // Take a snapshot of the initial (essentially blank) page
   let blankSnapshot = snapshotWindow(window, false);
 
   // Show reference div, & take a snapshot
@@ -49,57 +49,57 @@ function takeReferenceSnapshot() {
 
   // Re-hide reference div, and take another snapshot to be sure it's gone
   referenceDiv.style.display = "none";
   let blankSnapshot2 = snapshotWindow(window, false);
   ok(compareSnapshots(blankSnapshot, blankSnapshot2, true)[0],
      "reference div should disappear when it becomes display:none");
 }
 
-function myOnStopFrame() {
-  gOnStopFrameCounter++;
-  ok(true, "myOnStopFrame called");
+function myPoll() {
+  gPollCounter++;
+  ok(true, "myPoll called");
   let currentSnapshot = snapshotWindow(window, false);
   if (compareSnapshots(currentSnapshot, gReferenceSnapshot, true)[0]) {
     // SUCCESS!
     ok(true, "Animated image looks correct, " +
-             "at call #" + gOnStopFrameCounter + " to onStopFrame");
+             "at call #" + gPollCounter + " to myPoll");
     cleanUpAndFinish();
   }
   else
-    setTimeout(myOnStopFrame, 1);
+    setTimeout(myPoll, 1);
 }
 
 function failTest() {
   ok(false, "timing out after " + FAILURE_TIMEOUT + "ms.  " +
             "Animated image still doesn't look correct, " +
-            "after call #" + gOnStopFrameCounter + " to onStopFrame");
+            "after call #" + gPollCounter + " to myPoll");
   cleanUpAndFinish();
 }
 
 function cleanUpAndFinish() {
-  // On the off chance that failTest and myOnStopFrame are triggered
+  // On the off chance that failTest and myPoll are triggered
   // back-to-back, use a flag to prevent multiple calls to SimpleTest.finish.
   if (gIsTestFinished) {
     return;
   }
   SimpleTest.finish();
   gIsTestFinished = true;
 }
 
 function main() {
   takeReferenceSnapshot();
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
   clearAllImageCaches();
 
-  setTimeout(myOnStopFrame, 1);
+  setTimeout(myPoll, 1);
 
-  // kick off image-loading! myOnStopFrame handles the rest.
+  // kick off image-loading! myPoll handles the rest.
   gImg.setAttribute("src", "lime-anim-100x100.svg");
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
   setTimeout(failTest, FAILURE_TIMEOUT);
 }
 
 window.onload = main;
--- a/image/test/mochitest/test_animSVGImage2.html
+++ b/image/test/mochitest/test_animSVGImage2.html
@@ -27,19 +27,18 @@ SimpleTest.waitForExplicitFinish();
 const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const gImg = document.getElementsByTagName("img")[0];
 
 var gMyDecoderObserver; // value will be set in main()
 var gReferenceSnapshot; // value will be set in takeReferenceSnapshot()
-var gOnStopFrameCounter = 0;
+var gOnFrameUpdateCounter = 0;
 var gIsTestFinished = false;
-var gTimer = null;
 
 
 function takeReferenceSnapshot() {
   // Take a snapshot of the initial (essentially blank) page
   let blankSnapshot = snapshotWindow(window, false);
 
   // Show reference div, & take a snapshot
   let referenceDiv = document.getElementById("referenceDiv");
@@ -50,67 +49,70 @@ function takeReferenceSnapshot() {
 
   // Re-hide reference div, and take another snapshot to be sure it's gone
   referenceDiv.style.display = "none";
   let blankSnapshot2 = snapshotWindow(window, false);
   ok(compareSnapshots(blankSnapshot, blankSnapshot2, true)[0],
      "reference div should disappear when it becomes display:none");
 }
 
-function myOnStopFrame(aRequest) {
-  gOnStopFrameCounter++;
-  ok(true, "myOnStopFrame called");
+function myOnFrameUpdate(aRequest) {
+  if (gIsTestFinished) {
+    return;
+  }
+  gOnFrameUpdateCounter++;
+  ok(true, "myOnFrameUpdate called");
   let currentSnapshot = snapshotWindow(window, false);
   if (compareSnapshots(currentSnapshot, gReferenceSnapshot, true)[0]) {
     // SUCCESS!
     ok(true, "Animated image looks correct, " +
-             "at call #" + gOnStopFrameCounter + " to onStopFrame");
+             "at call #" + gOnFrameUpdateCounter + " to myOnFrameUpdate");
     cleanUpAndFinish();
   }
-  if (!gTimer)
-    gTimer = setTimeout(function() { gTimer = null; myOnStopFrame(0, 0); }, 1000);
 }
 
 function failTest() {
+  if (gIsTestFinished) {
+    return;
+  }
   ok(false, "timing out after " + FAILURE_TIMEOUT + "ms.  " +
             "Animated image still doesn't look correct, " +
-            "after call #" + gOnStopFrameCounter + " to onStopFrame");
+            "after call #" + gOnFrameUpdateCounter + " to myOnFrameUpdate");
   cleanUpAndFinish();
 }
 
 function cleanUpAndFinish() {
-  clearTimeout(gTimer);
-  // On the off chance that failTest and myOnStopFrame are triggered
+  // On the off chance that failTest and myOnFrameUpdate are triggered
   // back-to-back, use a flag to prevent multiple calls to SimpleTest.finish.
   if (gIsTestFinished) {
     return;
   }
   let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
   imgLoadingContent.removeObserver(gMyDecoderObserver);
   SimpleTest.finish();
   gIsTestFinished = true;
 }
 
 function main() {
   takeReferenceSnapshot();
 
   // Create, customize & attach decoder observer
   observer = new ImageDecoderObserverStub();
-  observer.frameComplete = myOnStopFrame;
+  observer.frameUpdate = myOnFrameUpdate;
   gMyDecoderObserver =
     Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
       .createScriptedObserver(observer);
   let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
   imgLoadingContent.addObserver(gMyDecoderObserver);
 
   // We want to test the cold loading behavior, so clear cache in case an
   // earlier test got our image in there already.
   clearAllImageCaches();
 
-  // kick off image-loading! myOnStopFrame handles the rest.
+  // kick off image-loading! myOnFrameUpdate handles the rest.
   gImg.setAttribute("src", "lime-anim-100x100-2.svg");
 
   // In case something goes wrong, fail earlier than mochitest timeout,
   // and with more information.
   setTimeout(failTest, FAILURE_TIMEOUT);
 }
 
 window.onload = main;