Bug 1435296 Update the CSS Animations tests to handle our new Timer Precision decision r=baku a=ritu
☠☠ backed out by e9416c0efa81 ☠ ☠
authorTom Ritter <tom@mozilla.com>
Wed, 07 Feb 2018 20:35:38 -0600
changeset 454859 9012bf881e43f794e40ef930d888660407c9ea08
parent 454858 576378b59e73dd5dd65a7349bd7e4bf89b04df1c
child 454860 24cb1a9d9b2357a508cbeeb94fa5c207cd4a8064
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku, ritu
bugs1435296
milestone59.0
Bug 1435296 Update the CSS Animations tests to handle our new Timer Precision decision r=baku a=ritu This commit does several subtle things. 1: It changes ok() to opener.ok() ok is not defined, we have to use opener.ok. This was not caught before because this call is used to provide additional debugging information when a test fails. Test didn't fail, didn't hit that line. 2: It disables the call to opener.ok() we just fixed. As the comment there describes, we expect that function to fail, so we don't want to assert(false). 3: It inverts failures to successes if only the reduceTimerPrecision pref is set MozReview-Commit-ID: lpKKhJoDs6
browser/components/resistfingerprinting/test/mochitest/file_animation_api.html
--- a/browser/components/resistfingerprinting/test/mochitest/file_animation_api.html
+++ b/browser/components/resistfingerprinting/test/mochitest/file_animation_api.html
@@ -47,37 +47,49 @@
       // We check that the timer is not sub-millisecond by assuming it is not if it
       // returns an even number of milliseconds
       if (expectedPrecision < 1 && Math.round(x) == x) {
         if (Math.round(rounded) == x) {
           return true;
         }
       }
 
-      ok(false, "Looming Test Failure, Additional Debugging Info: Expected Precision: " + expectedPrecision + " Measured Value: " + x +
-        " Rounded Vaue: " + rounded + " Fuzzy1: " + Math.abs(rounded - x + expectedPrecision) +
-        " Fuzzy 2: " + Math.abs(rounded - x));
+      // We are temporarily disabling this extra debugging failure because we expect to return false in some instances
+      // When we correct things we will re-enable it for debugging assistance
+      // opener.ok(false, "Looming Test Failure, Additional Debugging Info: Expected Precision: " + expectedPrecision + " Measured Value: " + x +
+      //   " Rounded Vaue: " + rounded + " Fuzzy1: " + Math.abs(rounded - x + expectedPrecision) +
+      //   " Fuzzy 2: " + Math.abs(rounded - x));
 
       return false;
     };
     const testDiv = document.getElementById("testDiv");
     const animation = testDiv.animate({ opacity: [0, 1] }, 100000);
     animation.play();
 
     waitForCondition(
       () => animation.currentTime > 100,
         () => {
-          opener.ok(isRounded(animation.startTime),
+
+          // We have disabled Time Precision Reduction for CSS Animations, so we expect those tests to fail.
+          // If we are testing that preference, turn failures into successes and successes into failures
+          var maybeInvert = function(value) {
+            if (opener.prefName.includes("privacy.reduceTimerPrecision") &&
+                !opener.prefName.includes("privacy.resistFingerprinting"))
+              return !value;
+            return value;
+          };
+
+          opener.ok(maybeInvert(isRounded(animation.startTime)),
              "pref: " + opener.prefName + " - animation.startTime with precision " + expectedPrecision + " is not rounded: " + animation.startTime);
-          opener.ok(isRounded(animation.currentTime),
+          opener.ok(maybeInvert(isRounded(animation.currentTime)),
              "pref: " + opener.prefName + " - animation.currentTime with precision " + expectedPrecision + " is not rounded: " + animation.currentTime);
-          opener.ok(isRounded(animation.timeline.currentTime),
+          opener.ok(maybeInvert(isRounded(animation.timeline.currentTime)),
              "pref: " + opener.prefName + " - animation.timeline.currentTime with precision " + expectedPrecision + " is not rounded: " + animation.timeline.currentTime);
           if (document.timeline) {
-            opener.ok(isRounded(document.timeline.currentTime),
+            opener.ok(maybeInvert(isRounded(document.timeline.currentTime)),
                "pref: " + opener.prefName + " - document.timeline.currentTime with precision " + expectedPrecision + " is not rounded: " + document.timeline.currentTime);
           }
           opener.done();
           window.close();
         },
         "animation failed to start");
   }
 </script>