Bug 1435296 Update the CSS Animations tests to handle our new Timer Precision decision
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
--- 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>