Bug 1167519 - Part 2: A mochitest to check a new transform position replaced by old transform transition is close to the old one. r?birtles
MozReview-Commit-ID: 1s8ZH3KPf9a
new file mode 100644
--- /dev/null
+++ b/layout/style/test/file_transitions_replacement_on_busy_frame.html
@@ -0,0 +1,92 @@
+<!doctype html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1167519
+-->
+<head>
+ <meta charset=utf-8>
+ <script type="application/javascript"
+ src="/tests/SimpleTest/paint_listener.js"></script>
+ <script type="application/javascript" src="animation_utils.js"></script>
+ <style>
+ #target {
+ height: 100px;
+ width: 100px;
+ background: green;
+ transition: transform 100s linear;
+ }
+ </style>
+</head>
+<body>
+<div id="target"></div>
+<script>
+'use strict';
+
+var ok = opener.ok.bind(opener);
+var info = opener.info.bind(opener);
+
+function finish() {
+ var o = opener;
+ self.close();
+ o.SimpleTest.finish();
+}
+
+var OMTAPrefKey = "layers.offmainthreadcomposition.async-animations";
+var omtaEnabled = SpecialPowers.DOMWindowUtils.layerManagerRemote &&
+ opener.SpecialPowers.getBoolPref(OMTAPrefKey);
+window.addEventListener("load", function() {
+ if (!omtaEnabled) {
+ info("Skipping the test since OMTA is disabled");
+ finish();
+ return;
+ }
+
+ var div = document.getElementById("target");
+ // Start first transition
+ div.style.transform = "translateX(300px)";
+ getComputedStyle(div);
+
+ // Wait for a paint to ensure that the first transition has started.
+ waitForAllPaints(function() {
+ var previousMatrix;
+ requestAnimationFrame(function() {
+ // Start second transition
+ div.style.transform = "translateX(0px)";
+ previousMatrix =
+ convertTo3dMatrix(getComputedStyle(div).transform);
+ });
+
+ requestAnimationFrame(function() {
+ // Tie up main thread for 300ms. In the meantime, the first transition
+ // will continue running on the compositor. If we don't update the start
+ // point of the second transition, it will appear to jump when it starts.
+ var startTime = performance.now();
+ while (performance.now() - startTime < 300);
+
+ // Ensure that our paint process has been done.
+ // Note that requestAnimationFrame is not suitable here since on Android
+ // there is a case where the paint process has not completed even when the
+ // requestAnimationFrame callback is run (and it is during the paint
+ // process that we update the transition start point).
+ waitForAllPaints(function() {
+ var anim = div.getAnimations()[0];
+ anim.pause();
+
+ // Wait for being animated style updated by animation.pause().
+ anim.ready.then(function() {
+ var currentMatrix =
+ convertTo3dMatrix(getComputedStyle(div).transform);
+ // Now the position on x-axis should be at least 300ms ahead.
+ var difference = 0.9; // 300px / (100s / 300ms)
+ ok(currentMatrix[3][0] - previousMatrix[3][0] >= difference,
+ currentMatrix + " should be advanced ahead of " + previousMatrix);
+ finish();
+ });
+ });
+ });
+ });
+});
+
+</script>
+</body>
+</html>
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -267,16 +267,18 @@ skip-if = (toolkit == 'gonk' && debug) |
[test_transitions_computed_value_combinations.html]
[test_transitions_events.html]
[test_transitions.html]
skip-if = (android_version == '18' && debug) # bug 1159532
[test_transitions_bug537151.html]
[test_transitions_dynamic_changes.html]
[test_transitions_per_property.html]
skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 775227 # b2g(times out, needs more time + various failures) b2g-debug(times out, needs more time + various failures) b2g-desktop(times out, needs more time + various failures)
+[test_transitions_replacement_on_busy_frame.html]
+support-files = file_transitions_replacement_on_busy_frame.html
[test_transitions_step_functions.html]
[test_transitions_with_displaynone.html]
[test_transitions_with_disabled_properties.html]
support-files = file_transitions_with_disabled_properties.html
[test_unclosed_parentheses.html]
[test_unicode_range_loading.html]
support-files = ../../reftests/fonts/markA.woff ../../reftests/fonts/markB.woff ../../reftests/fonts/markC.woff ../../reftests/fonts/markD.woff
[test_units_angle.html]
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_transitions_replacement_on_busy_frame.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1167519
+-->
+<head>
+ <title>Test for bug 1167519</title>
+ <script type="application/javascript"
+ src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank"
+ href="https://bugzilla.mozilla.org/show_bug.cgi?id=1167519">Mozilla Bug
+ 1167519</a>
+<pre id="test">
+<script>
+'use strict';
+
+SimpleTest.waitForExplicitFinish();
+
+SpecialPowers.pushPrefEnv(
+ { 'set': [[ 'dom.animations-api.core.enabled', true ]] },
+ function() {
+ window.open('file_transitions_replacement_on_busy_frame.html');
+ });
+</script>
+</pre>
+</body>
+</html>