Bug 927349 part 24 - Add a test that empty animations still start; r=heycam
authorBrian Birtles <birtles@gmail.com>
Thu, 25 Dec 2014 16:28:24 +0900
changeset 221987 413db6659fef3370473fc2511b7cc819c10999f9
parent 221986 37343347ab6a63330a335a6745dac1f093b6d902
child 221988 48523f909ffb989ea6db0938b0e3648bb902a2f7
push id28055
push userkwierso@gmail.com
push dateTue, 06 Jan 2015 00:19:38 +0000
treeherdermozilla-central@72d7ae169b09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs927349
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 927349 part 24 - Add a test that empty animations still start; r=heycam
dom/animation/test/mochitest.ini
dom/animation/test/mozilla/test_deferred_start.html
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -13,8 +13,9 @@ skip-if = buildapp == 'mulet'
 [css-animations/test_element-get-animation-players.html]
 skip-if = buildapp == 'mulet'
 [css-transitions/test_animation-effect-name.html]
 [css-transitions/test_animation-pausing.html]
 [css-transitions/test_animation-player-ready.html]
 [css-transitions/test_animation-target.html]
 [css-transitions/test_element-get-animation-players.html]
 skip-if = buildapp == 'mulet'
+[mozilla/test_deferred_start.html]
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/mozilla/test_deferred_start.html
@@ -0,0 +1,61 @@
+<!doctype html>
+<meta charset=utf-8>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<div id="log"></div>
+<style>
+@keyframes empty { }
+</style>
+<script>
+'use strict';
+
+function waitForDocLoad() {
+  return new Promise(function(resolve, reject) {
+    if (document.readyState === 'complete') {
+      resolve();
+    } else {
+      window.addEventListener('load', resolve);
+    }
+  });
+}
+
+async_test(function(t) {
+  var div = addDiv(t);
+  var cs = window.getComputedStyle(div);
+
+  // Test that empty animations actually start.
+  //
+  // Normally we tie the start of animations to when their first frame of
+  // the animation is rendered. However, for animations that don't actually
+  // trigger a paint (e.g. because they are empty, or are animating something
+  // that doesn't render or is offscreen) we want to make sure they still
+  // start.
+  //
+  // Before we start, wait for the document to finish loading. This is because
+  // during loading we will have other paint events taking place which might,
+  // by luck, happen to trigger animations that otherwise would not have been
+  // triggered, leading to false positives.
+  //
+  // As a result, it's better to wait until we have a more stable state before
+  // continuing.
+  var promiseCallbackDone = false;
+  waitForDocLoad().then(function() {
+    div.style.animation = 'empty 1000s';
+    var player = div.getAnimationPlayers()[0];
+
+    player.ready.then(function() {
+      promiseCallbackDone = true;
+    }).catch(function() {
+      assert_unreached('ready promise was rejected');
+    });
+
+  }).then(waitForFrame).then(t.step_func(function() {
+    assert_true(promiseCallbackDone,
+                'ready promise callback was called before the next'
+                + ' requestAnimationFrame callback');
+    t.done();
+  }));
+}, 'AnimationPlayer.ready is resolved for an empty animation');
+
+</script>