Bug 1300355 - Part 2: Don't track use counts in the reftest harness when the cache is disabled. r=dbaron, a=test-only
authorMatt Woodrow <mwoodrow@mozilla.com>
Sun, 26 Feb 2017 16:57:01 +1300
changeset 378940 3b911d0ad6beb6b1846cc9fa19562d287cdd80df
parent 378939 81deafbeaf6b2fc265e2c47f770fa8abba86b172
child 378941 c16cd2b0733e2aad9b0f80bf74d0c4fb59f7991f
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, test-only
bugs1300355
milestone53.0
Bug 1300355 - Part 2: Don't track use counts in the reftest harness when the cache is disabled. r=dbaron, a=test-only
layout/tools/reftest/reftest.jsm
--- a/layout/tools/reftest/reftest.jsm
+++ b/layout/tools/reftest/reftest.jsm
@@ -217,32 +217,34 @@ function FlushTestBuffer()
 function LogWidgetLayersFailure()
 {
   logger.error("USE_WIDGET_LAYERS disabled because the screen resolution is too low. This falls back to an alternate rendering path (that may not be representative) and is not implemented with e10s enabled.");
   logger.error("Consider increasing your screen resolution, or adding '--disable-e10s' to your './mach reftest' command");
 }
 
 function AllocateCanvas()
 {
-    if (gRecycledCanvases.length > 0)
+    if (gRecycledCanvases.length > 0) {
         return gRecycledCanvases.shift();
+    }
 
     var canvas = gContainingWindow.document.createElementNS(XHTML_NS, "canvas");
     var r = gBrowser.getBoundingClientRect();
     canvas.setAttribute("width", Math.ceil(r.width));
     canvas.setAttribute("height", Math.ceil(r.height));
 
     return canvas;
 }
 
 function ReleaseCanvas(canvas)
 {
     // store a maximum of 2 canvases, if we're not caching
-    if (!gNoCanvasCache || gRecycledCanvases.length < 2)
+    if (!gNoCanvasCache || gRecycledCanvases.length < 2) {
         gRecycledCanvases.push(canvas);
+    }
 }
 
 function IDForEventTarget(event)
 {
     try {
         return "'" + event.target.getAttribute('id') + "'";
     } catch (ex) {
         return "<unknown>";
@@ -1167,16 +1169,20 @@ function AddURIUseCount(uri)
         gURIUseCounts[spec]++;
     } else {
         gURIUseCounts[spec] = 1;
     }
 }
 
 function BuildUseCounts()
 {
+    if (gNoCanvasCache) {
+        return;
+    }
+
     gURIUseCounts = {};
     for (var i = 0; i < gURLs.length; ++i) {
         var url = gURLs[i];
         if (url.expected != EXPECTED_DEATH &&
             (url.type == TYPE_REFTEST_EQUAL ||
              url.type == TYPE_REFTEST_NOTEQUAL)) {
             if (url.prefSettings1.length == 0) {
                 AddURIUseCount(gURLs[i].url1);
@@ -1439,17 +1445,17 @@ function DoneTests()
 }
 
 function UpdateCanvasCache(url, canvas)
 {
     var spec = url.spec;
 
     --gURIUseCounts[spec];
 
-    if (gNoCanvasCache || gURIUseCounts[spec] == 0) {
+    if (gURIUseCounts[spec] == 0) {
         ReleaseCanvas(canvas);
         delete gURICanvases[spec];
     } else if (gURIUseCounts[spec] > 0) {
         gURICanvases[spec] = canvas;
     } else {
         throw "Use counts were computed incorrectly";
     }
 }
@@ -1749,21 +1755,26 @@ function RecordResult(testRunTime, error
                         message += (", max difference: " + extra.max_difference +
                                     ", number of differing pixels: " + differences);
                     } else {
                         extra.image1 = gCanvas1.toDataURL();
                     }
                 }
                 logger.testEnd(gURLs[0].identifier, output.s[0], output.s[1], message, null, extra);
 
-                if (gURLs[0].prefSettings1.length == 0) {
-                    UpdateCanvasCache(gURLs[0].url1, gCanvas1);
-                }
-                if (gURLs[0].prefSettings2.length == 0) {
-                    UpdateCanvasCache(gURLs[0].url2, gCanvas2);
+                if (gNoCanvasCache) {
+                    ReleaseCanvas(gCanvas1);
+                    ReleaseCanvas(gCanvas2);
+                } else {
+                    if (gURLs[0].prefSettings1.length == 0) {
+                        UpdateCanvasCache(gURLs[0].url1, gCanvas1);
+                    }
+                    if (gURLs[0].prefSettings2.length == 0) {
+                        UpdateCanvasCache(gURLs[0].url2, gCanvas2);
+                    }
                 }
             }
 
             if ((!test_passed && expected == EXPECTED_PASS) || (test_passed && expected == EXPECTED_FAIL)) {
                 FlushTestBuffer();
             }
 
             CleanUpCrashDumpFiles();