Bug 1361663 - Part 2: Add tolerance because we use different ways for interpolation on the main/compositor thread. draft
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 24 May 2017 17:07:10 +0800
changeset 583623 e51a9ffcfc93604451e2ca6143a6b93bac26cf4a
parent 583611 a1f70ce9f05a2b9f10b47ff821256a01c2e15575
child 630135 dd58a846b56e6ef9c25eac1849d59a6cbe96c3bd
push id60475
push userbmo:boris.chiou@gmail.com
push dateWed, 24 May 2017 10:01:51 +0000
bugs1361663
milestone55.0a1
Bug 1361663 - Part 2: Add tolerance because we use different ways for interpolation on the main/compositor thread. On the main thread, we use Servo backend, and the type of computed::Length is |app_units::Au| (i.e. i32). However, on the compositor thread, we use Gecko backend, and the type of the length in nsCSSValue is |float|, so there might be some difference. Use "0.5 / 60" because we round the interpolated result to the nearest integer, and convert it into an app unit value, so the tolerance could be this value. MozReview-Commit-ID: EBceiO7keH1
layout/style/test/animation_utils.js
layout/style/test/stylo-failures.md
--- a/layout/style/test/animation_utils.js
+++ b/layout/style/test/animation_utils.js
@@ -398,16 +398,25 @@ const RunningOn = {
   TodoMainThread: 3
 };
 
 const ExpectComparisonTo = {
   Pass: 1,
   Fail: 2
 };
 
+// FIXME: Bug 1340005: We use |RawServoAnimationValue| on the main thread if
+// enabling Servo style backend, and still use |StyleAnimationValue| on the
+// compositor thread. |RawServoAnimationValue| rounds the interpolated results
+// to a nearest |app_units::Au| (i.e. i32), so we might have a tiny difference
+// between the results from getOMTAStyle() and getComputedStyle().
+// Note: 1 AU ~= 60 CSS pixel unit.
+const isServo = SpecialPowers.getBoolPref('layout.css.servo.enabled');
+const toleranceForServoBackend = isServo ? 0.5 / 60.0 : 0.0;
+
 (function() {
   window.omta_todo_is = function(elem, property, expected, runningOn, desc,
                                  pseudo) {
     return omta_is_approx(elem, property, expected, 0, runningOn, desc,
                           ExpectComparisonTo.Fail, pseudo);
   };
 
   window.omta_is = function(elem, property, expected, runningOn, desc,
@@ -500,17 +509,17 @@ const ExpectComparisonTo = {
     // the value calculated on the main thread
     if (actualStr === compositorStr) {
       var computedValue = normalize(computedStr);
       if (computedValue === null) {
         ok(false, desc + ": test framework should parse computed style" +
                   " - got " + computedStr);
         return;
       }
-      okOrTodo(compare(computedValue, actualValue, 0),
+      okOrTodo(compare(computedValue, actualValue, toleranceForServoBackend),
                desc + ": OMTA style and computed style should be equal" +
                " - OMTA " + actualStr + ", computed " + computedStr);
     }
   };
 
   window.matricesRoughlyEqual = function(a, b, tolerance) {
     tolerance = tolerance || 0.00011;
     for (var i = 0; i < 4; i++) {
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -32,17 +32,17 @@ to mochitest command.
 * Media query support:
   * test_media_queries.html [38]
   * test_media_queries_dynamic.html [6]
   * test_media_queries_dynamic_xbl.html [2]
   * test_webkit_device_pixel_ratio.html: -webkit-device-pixel-ratio [3]
   * browser_bug453896.js [8]
 * Animation support:
   * OMTA
-    * test_animations_omta.html: bug 1361938, bug 1361663 [*]
+    * test_animations_omta.html: bug 1361938, bug 1340005 [*]
   * SMIL Animation
     * test_restyles_in_smil_animation.html [2]
 * CSSOM support:
   * \@import bug 1352968
     * test_bug221428.html [1]
     * test_css_eof_handling.html [1]
 * test_bug397427.html: @import issue bug 1331291 and CSSOM support of @import [1]
 * console support bug 1352669