Bug 1267937 - Part 2: A reftest which checks mProgressOnLastCompose is surely cleared in before phase. r=birtles
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Sat, 30 Apr 2016 07:08:14 +0900
changeset 295613 c358aa5441c953188a2fd2bc6ae0eeb813285d98
parent 295612 15070beaee3548018781299762f6c15995e05924
child 295614 d14dc334734adccc6741093c388e13c7099a8a38
push id19015
push usercbook@mozilla.com
push dateMon, 02 May 2016 09:39:23 +0000
treeherderfx-team@2080375bc69d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1267937
milestone49.0a1
Bug 1267937 - Part 2: A reftest which checks mProgressOnLastCompose is surely cleared in before phase. r=birtles
layout/reftests/web-animations/1267937-1.html
layout/reftests/web-animations/1267937-ref.html
layout/reftests/web-animations/reftest.list
new file mode 100644
--- /dev/null
+++ b/layout/reftests/web-animations/1267937-1.html
@@ -0,0 +1,58 @@
+<!doctype html>
+<html class="reftest-wait reftest-no-flush">
+<head>
+<meta charset=utf-8>
+<title>Bug 1267937</title>
+<style>
+#target {
+  width: 100px;
+  height: 100px;
+  background: green;
+}
+</style>
+</head>
+<body>
+<div id="target"></div>
+<script>
+  var target = document.getElementById("target");
+  var anim = target.animate(
+    { marginLeft: [ "0px", "10px" ] },
+    { duration: 100000 /* 100s */, easing: "steps(2, start)" });
+
+  anim.ready.then(function() {
+    // Set currentTime in before phase, i.e., GetComputedTimingAt() returns
+    // null progress in the phase so that we can skip ComposeStyle().
+    // This currentTime value should be far from zero in order to skip
+    // restyles requested by setting currentTime or frames in a next tick.
+    // If this value is near by zero, say -1, the restyles will be processed in
+    // the next tick and current time in the next tick must be greater than
+    // zero at that point, that means the animation with new frame values will
+    // be painted.  As a result, this test will be useless.
+    anim.currentTime = -500;
+
+    // Setting another frame does not cause any visual changes because
+    // the animation is still in the before phase.
+    anim.effect.setFrames({ marginLeft: [ "0px", "400px" ] });
+
+    var beforePhaseFrames = 0;
+    window.requestAnimationFrame(function handleFrame() {
+      if (anim.effect.getComputedTiming().progress === null) {
+        beforePhaseFrames++;
+      }
+      if (anim.effect.getComputedTiming().progress !== null) {
+        if (beforePhaseFrames == 0) {
+          console.log("WARNING: We never got frames in the before phase. " +
+                      "This test is going to be passed accidentally. " +
+                      "Consider setting smaller current time, e.g. -1000ms.");
+        }
+        // After starting the animation, progress should be 0.5, that means
+        // margin-left is 200px.
+        document.documentElement.classList.remove("reftest-wait");
+        return;
+      }
+      window.requestAnimationFrame(handleFrame);
+    });
+  });
+</script>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/web-animations/1267937-ref.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+<head>
+<meta charset=utf-8>
+<title>Reference of bug 1267937</title>
+<style>
+#target {
+  width: 100px;
+  height: 100px;
+  background: green;
+  margin-left: 200px;
+}
+</style>
+</head>
+<body>
+<div id="target"></div>
+</body>
+</html>
--- a/layout/reftests/web-animations/reftest.list
+++ b/layout/reftests/web-animations/reftest.list
@@ -1,1 +1,2 @@
 test-pref(dom.animations-api.core.enabled,true) == 1246046-1.html green-box.html
+test-pref(dom.animations-api.core.enabled,true) == 1267937-1.html 1267937-ref.html