Make the reset test in test_transitions.html deal with the possibility of massive skew between setTimeout and the clock. (Bug 539904)
authorL. David Baron <dbaron@dbaron.org>
Wed, 07 Apr 2010 12:06:15 -0700
changeset 40550 9d286aa986c83455dc1c9aa88f76ba34a9e6aee1
parent 40549 f5e415ecb75f120a0cabac04041394070277c4e9
child 40551 65e260adaf92bbbcc99127db041f55bdd6973e01
push id12662
push userdbaron@mozilla.com
push dateWed, 07 Apr 2010 19:07:30 +0000
treeherdermozilla-central@9d286aa986c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs539904
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Make the reset test in test_transitions.html deal with the possibility of massive skew between setTimeout and the clock. (Bug 539904)
layout/style/test/test_transitions.html
--- a/layout/style/test/test_transitions.html
+++ b/layout/style/test/test_transitions.html
@@ -197,25 +197,30 @@ for (var d = -4; d <= 4; ++d) {
     div.appendChild(p);
     is(getComputedStyle(p, "").marginLeft, "0px",
        "should be zero before changing value");
     delay_tests[d] = p;
 }
 
 // Test that changing the value on an already-running transition to the
 // value it currently happens to have resets the transition.
-var p = document.createElement("p");
-var t = document.createTextNode("transition-delay reset to starting point");
-p.appendChild(t);
-p.style.marginLeft = "0px";
-p.style.MozTransition = "4s margin-left ease-out 4s";
-div.appendChild(p);
-is(getComputedStyle(p, "").marginLeft, "0px",
-   "should be zero before changing value");
-var reset_test = p;
+function make_reset_test(transition, description)
+{
+    var p = document.createElement("p");
+    var t = document.createTextNode(description);
+    p.appendChild(t);
+    p.style.marginLeft = "0px";
+    p.style.MozTransition = transition;
+    div.appendChild(p);
+    is(getComputedStyle(p, "").marginLeft, "0px",
+       "should be zero before changing value");
+    return p;
+}
+var reset_test = make_reset_test("4s margin-left ease-out 4s", "transition-delay reset to starting point");
+var reset_test_reference = make_reset_test("4s margin-left linear -3s", "reference for previous test (reset test)");
 
 // Test that transitions on descendants do not trigger when the
 // inherited value is itself transitioning.  In other words, when
 // ancestor and descendant both have a transition for the same property,
 // and the descendant inherits the property from the ancestor, the
 // descendant's transition is ignored (as part of the idea of not
 // starting transitions on changes that result from animation).
 // See http://lists.w3.org/Archives/Public/www-style/2009Jun/0121.html
@@ -356,16 +361,17 @@ for (var test in interrupt_tests) {
     var p = interrupt_tests[test][0];
     p.style.textIndent = "100px";
 }
 for (var d in delay_tests) {
     var p = delay_tests[d];
     p.style.marginLeft = "100px";
 }
 reset_test.style.marginLeft = "100px";
+reset_test_reference.style.marginLeft = "100px";
 for (var i in descendant_tests) {
     var test = descendant_tests[i];
     test.parentNode.style.textIndent = "150px";
     test.parentNode.style.letterSpacing = "5px";
 }
 for (var i in number_tests) {
     var test = number_tests[i];
     test.node.style.marginLeft = "50px";
@@ -536,17 +542,23 @@ function reset_reset_test(time)
 {
     reset_test.style.marginLeft = "0px";
 }
 function check_reset_test(time)
 {
     is(getComputedStyle(reset_test, "").marginLeft, "0px",
        "reset test value at time " + time + "s.");
 }
-setTimeout(reset_reset_test, 1000); // must always run, even if late
+check_reset_test(0);
+// reset the reset test right now so we don't have to worry about clock skew
+// To make sure that this is valid, check that a pretty-much-identical test is
+// already transitioning.
+is(getComputedStyle(reset_test_reference, "").marginLeft, "75px",
+   "reset test reference value");
+reset_reset_test();
 check_reset_test(0);
 for (var i = 1; i <= 8; ++i) {
     (function(j) {
         add_future_call(j, function() { check_reset_test(j); });
     })(i);
 }
 
 check_descendant_tests();