Bug 1478643 - Add test cases checking finished opacity animation on the compositor. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 30 Jul 2018 10:44:47 +0900
changeset 823941 5d67f9167df796939151cb78bddb8a99028a6f98
parent 823872 0be4463d29159905dded07f1dbddc5bb7dfaa336
child 823942 1ef094e620ba5bb54c00d9b6e214921aa09eac93
push id117826
push userhikezoe@mozilla.com
push dateMon, 30 Jul 2018 02:16:01 +0000
reviewersbirtles
bugs1478643
milestone63.0a1
Bug 1478643 - Add test cases checking finished opacity animation on the compositor. r?birtles All test cases here pass without any changes on the current trunk, but all counter part test cases for transform introducing in a subsequent patch will fail without the proper fix. MozReview-Commit-ID: 3hgsVfFJPrZ
dom/animation/test/mochitest.ini
dom/animation/test/mozilla/test_style_after_finished_on_compositor.html
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -55,16 +55,18 @@ skip-if = (toolkit == 'android' && debug
 [mozilla/test_distance_of_transform.html]
 [mozilla/test_document_timeline_origin_time_range.html]
 [mozilla/test_hide_and_show.html]
 [mozilla/test_moz_prefixed_properties.html]
 [mozilla/test_pending_animation_tracker.html]
 [mozilla/test_restyles.html]
 [mozilla/test_restyling_xhr_doc.html]
 [mozilla/test_set_easing.html]
+[mozilla/test_style_after_finished_on_compositor.html]
+skip-if = webrender # bug 1479133
 [mozilla/test_transform_limits.html]
 [mozilla/test_transition_finish_on_compositor.html]
 skip-if = toolkit == 'android'
 [mozilla/test_underlying_discrete_value.html]
 [mozilla/test_event_listener_leaks.html]
 [style/test_animation-seeking-with-current-time.html]
 [style/test_animation-seeking-with-start-time.html]
 [style/test_animation-setting-effect.html]
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/mozilla/test_style_after_finished_on_compositor.html
@@ -0,0 +1,80 @@
+<!doctype html>
+<head>
+<meta charset=utf-8>
+<title>Test for styles after finished on the compositor</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<style>
+.compositor {
+  /* Element needs geometry to be eligible for layerization */
+  width: 100px;
+  height: 100px;
+  background-color: green;
+}
+</style>
+</head>
+<body>
+<div id="log"></div>
+<script>
+"use strict";
+
+promise_test(async t => {
+  const div = addDiv(t, { 'class': 'compositor' });
+  const anim = div.animate([ { offset: 0, opacity: 1 },
+                             { offset: 1, opacity: 0 } ],
+                           { delay: 10,
+                             duration: 100 });
+
+  await anim.finished;
+
+  await waitForNextFrame();
+
+  const opacity = SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
+
+  assert_equals(opacity, '', 'No opacity animation runs on the compositor');
+}, 'Opacity animation with positive delay is removed from compositor when ' +
+   'finished');
+
+promise_test(async t => {
+  const div = addDiv(t, { 'class': 'compositor' });
+  const anim = div.animate([ { offset: 0,   opacity: 1 },
+                             { offset: 0.9, opacity: 1 },
+                             { offset: 1,   opacity: 0 } ],
+                           { duration: 100 });
+
+  await anim.finished;
+
+  await waitForNextFrame();
+
+  const opacity = SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
+
+  assert_equals(opacity, '', 'No opacity animation runs on the compositor');
+}, 'Opacity animation initially opacity: 1 is removed from compositor when ' +
+   'finished');
+
+promise_test(async t => {
+  const div = addDiv(t, { 'class': 'compositor' });
+  const anim = div.animate([ { offset: 0,    opacity: 0 },
+                             { offset: 0.5,  opacity: 1 },
+                             { offset: 0.51, opacity: 1 },
+                             { offset: 1,    opacity: 0 } ],
+                           { delay: 10, duration: 100 });
+
+  await waitForAnimationFrames(2);
+
+  // Setting the current time at the offset generating opacity: 1.
+  anim.currentTime = 60;
+
+  await anim.finished;
+
+  await waitForNextFrame();
+
+  const opacity = SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
+
+  assert_equals(opacity, '', 'No opacity animation runs on the compositor');
+}, 'Opacity animation is removed from compositor even when it only visits ' +
+   'exactly the point where the opacity: 1 value was set');
+
+</script>
+</body>