Bug 1159532 - Make reference transitions in test_transitions.html run for 16s instead of 8s. r=birtles, a=test-only
authorL. David Baron <dbaron@dbaron.org>
Tue, 14 Feb 2017 12:29:56 -0800
changeset 376186 e1ce5ca55bfd8b41d71adb8987c76132d5ffad39
parent 376185 da3502add096266361b9d7bf6adc667a27847296
child 376187 c2b8bf0302f8a81396e47892ccfc6537a3a90249
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles, test-only
bugs1159532
milestone53.0a2
Bug 1159532 - Make reference transitions in test_transitions.html run for 16s instead of 8s. r=birtles, a=test-only This is needed because check_descendant_tests tests a transition that changes through 16s. MozReview-Commit-ID: EYX79SuNZ76
layout/style/test/test_transitions.html
--- a/layout/style/test/test_transitions.html
+++ b/layout/style/test/test_transitions.html
@@ -116,22 +116,24 @@ var timingFunctions = {
 
 };
 
 var div = document.getElementById("display");
 
 // Set up all the elements on which we are going to initiate transitions.
 
 // We have two reference elements to check the expected timing range.
-// They both have 8s linear transitions from 0 to 1000px.
+// They both have 16s linear transitions from 0 to 1000px.
+// This means they move through 62.5 pixels per second.
+const REF_PX_PER_SEC = 62.5;
 function make_reference_p() {
     var p = document.createElement("p");
     p.appendChild(document.createTextNode("reference"));
     p.style.textIndent = "0px";
-    p.style.transition = "8s text-indent linear";
+    p.style.transition = "16s text-indent linear";
     div.appendChild(p);
     return p;
 }
 var earlyref = make_reference_p();
 var earlyrefcs = getComputedStyle(earlyref, "");
 
 // Test all timing functions using a set of 8-second transitions, which
 // we check at times 0, 2s, 4s, 6s, and 8s.
@@ -471,18 +473,18 @@ function check_transition_value(func, st
         time_range = [0, 0];
         if (start_time < 0) {
             uns_range = [ value_at(0, -1), value_at(0, 1) ];
         } else {
             var val = value_at(0, 0);
             uns_range = [val, val];
         }
     } else {
-        time_range = [ px_to_num(earlyrefcs.textIndent) / 125,
-                       px_to_num(laterefcs.textIndent) / 125 ];
+        time_range = [ px_to_num(earlyrefcs.textIndent) / REF_PX_PER_SEC,
+                       px_to_num(laterefcs.textIndent) / REF_PX_PER_SEC ];
         // seconds
         uns_range = [ value_at(time_range[0], -1),
                       value_at(time_range[1], 1) ];
     }
     var range = uns_range.concat(). /* concat to clone array */
                   sort(function compareNumbers(a,b) { return a - b; });
     var actual = px_to_num(cval);
 
@@ -496,33 +498,34 @@ function check_transition_value(func, st
        "px at time between " + time_range[0] + "s and " + time_range[1] + "s.");
 }
 
 function check_ref_range()
 {
     // This is the only test where we compare the progress of the
     // transitions to an actual time; we need considerable tolerance at
     // the low end (we are using half a second).
-    var expected_range = [ (gCurrentTime - gStartTime2 - 40) / 8,
-                           (Date.now() - gStartTime1 + 20) / 8 ];
+    var expected_range = [ (gCurrentTime - gStartTime2 - 40) / 16,
+                           (Date.now() - gStartTime1 + 20) / 16 ];
     if (expected_range[0] > 1000) {
         expected_range[0] = 1000;
     }
     if (expected_range[1] > 1000) {
         expected_range[1] = 1000;
     }
     function check(desc, value) {
         // The timing on the unit test VMs is not reliable, so make this
         // test report PASS when it succeeds and TODO when it fails.
         var passed = expected_range[0] <= value && value <= expected_range[1];
         (passed ? ok : todo)(passed,
            desc + ": computed value " + value + "px should be between " +
            expected_range[0].toFixed(6) + "px and " +
            expected_range[1].toFixed(6) + "px at time between " +
-           expected_range[0]/125 + "s and " + expected_range[1]/125 + "s.");
+           expected_range[0]/REF_PX_PER_SEC + "s and " +
+           expected_range[1]/REF_PX_PER_SEC + "s.");
     }
     check("early reference", px_to_num(earlyrefcs.textIndent));
     check("late reference", px_to_num(laterefcs.textIndent));
 }
 
 for (var i = 1; i <= 8; ++i) {
     add_future_call(i, check_ref_range);
 }
@@ -583,18 +586,18 @@ for (var i = 1; i <= 8; ++i) {
     add_future_call(i, check_delay_test);
 }
 
 function check_delay_zero_test(time)
 {
     for (var d in delay_zero_tests) {
         var p = delay_zero_tests[d];
 
-        time_range = [ px_to_num(earlyrefcs.textIndent) / 125,
-                       px_to_num(laterefcs.textIndent) / 125 ];
+        time_range = [ px_to_num(earlyrefcs.textIndent) / REF_PX_PER_SEC,
+                       px_to_num(laterefcs.textIndent) / REF_PX_PER_SEC ];
         var m = getComputedStyle(p, "").marginLeft;
         var desc = "delay_zero test for delay " + d + "s";
         if (time_range[0] < d && time_range[1] < d) {
             is(m, "0px", desc);
         } else if ((time_range[0] > d && time_range[1] > d) ||
                    (d == 0 && time == 0)) {
             is(m, "100px", desc);
         }
@@ -636,17 +639,17 @@ add_future_call(6, check_descendant_test
 function check_descendant_tests() {
     // text-indent: transition from 50px to 150px
     // letter-spacing: transition from 10px to 5px
     var values = {};
     values["text-indent"] = [ 50, 150 ];
     values["letter-spacing"] = [ 10, 5 ];
     var tf = timingFunctions["ease"];
 
-    var time = px_to_num(earlyrefcs.textIndent) / 125;
+    var time = px_to_num(earlyrefcs.textIndent) / REF_PX_PER_SEC;
 
     for (var i in descendant_tests) {
         var test = descendant_tests[i];
 
         /* ti=text-indent, ls=letter-spacing */
         var child_ti_duration = 0;
         var child_ls_duration = 0;
         var child_ti_delay = 0;