Bug 1244641 - Part 4: Add duration tests in dom/animation/test/chrome. r=hiro
authorRyo Motozawa <motozawa@mozilla-japan.org>
Sat, 27 Feb 2016 06:39:58 +0900
changeset 324216 57a37a771e9af2b94f5d7b0f7da1b35724e0ab13
parent 324215 0907eee5c44aa77a04d667a2ac458de5d2f63f5d
child 324217 adc86cbfeb50c343216d67d4726d54cc46e1113d
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1244641
milestone47.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 1244641 - Part 4: Add duration tests in dom/animation/test/chrome. r=hiro MozReview-Commit-ID: H2XbCfrzn8o
dom/animation/test/chrome/test_animation_observers.html
dom/animation/test/chrome/test_restyles.html
dom/animation/test/chrome/test_running_on_compositor.html
--- a/dom/animation/test/chrome/test_animation_observers.html
+++ b/dom/animation/test/chrome/test_animation_observers.html
@@ -1465,16 +1465,57 @@ addAsyncAnimTest("tree_ordering", { obse
                  "records after finishing");
 
   // Clean up
   div.style = "";
   childA.remove();
   childB.remove();
 });
 
+
+addAsyncAnimTest("change_duration_and_currenttime",
+                 { observe: div, subtree: true }, function*() {
+  var anim = div.animate({ opacity: [ 0, 1 ] }, 100000);
+  yield await_frame();
+  assert_records([{ added: [anim], changed: [], removed: [] }],
+                 "records after animation is added");
+
+  anim.effect.timing.duration = 10000;
+  yield await_frame();
+
+  assert_records([{ added: [], changed: [anim], removed: [] }],
+                 "records after duration is changed");
+
+  anim.effect.timing.duration = 10000;
+  yield await_frame();
+  assert_records([], "records after assigning same value");
+
+  anim.currentTime = 50000;
+  yield await_frame();
+  assert_records([{ added: [], changed: [], removed: [anim] }],
+                 "records after animation end");
+
+  anim.effect.timing.duration = 100000;
+  yield await_frame();
+  assert_records([{ added: [anim], changed: [], removed: [] }],
+                 "records after animation restarted");
+
+  anim.effect.timing.duration = "auto";
+  yield await_frame();
+  assert_records([{ added: [], changed: [], removed: [anim] }],
+                 "records after duration set \"auto\"");
+
+  anim.effect.timing.duration = "auto";
+  yield await_frame();
+  assert_records([], "records after assigning same value \"auto\"");
+
+  anim.cancel();
+  yield await_frame();
+});
+
 // Run the tests.
 SimpleTest.requestLongerTimeout(2);
 SimpleTest.waitForExplicitFinish();
 
 runAllAsyncTests().then(function() {
   SimpleTest.finish();
 }, function(aError) {
   ok(false, "Something failed: " + aError);
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -341,12 +341,32 @@ waitForAllPaints(function() {
 
     var markers = yield observeStyling(5);
     is(markers.length, 1,
        'Bug 1235478: Animations running on the compositor should only once ' +
        'update style when currentTime is set to middle of duration time');
     yield ensureElementRemoval(div);
   });
 
+  add_task_if_omta_enabled(function* change_duration_and_currenttime() {
+    var div = addDiv(null);
+    var animation = div.animate({ opacity: [ 0, 1 ] }, 10000);
+
+    yield animation.ready;
+    ok(animation.isRunningOnCompositor);
+
+    animation.currentTime = 50000;
+
+    ok(!animation.isRunningOnCompositor);
+
+    animation.effect.timing.duration = 100000;
+    var markers = yield observeStyling(5);
+    is(markers.length, 1,
+       'Animations running on the compositor should update style' +
+       'when timing.duration is made longer than the current time');
+
+    yield ensureElementRemoval(div);
+  });
+
 });
 
 </script>
 </body>
--- a/dom/animation/test/chrome/test_running_on_compositor.html
+++ b/dom/animation/test/chrome/test_running_on_compositor.html
@@ -280,11 +280,53 @@ promise_test(function(t) {
        'If an animation has a property that can run on the compositor and a '
        + 'property that cannot (due to Gecko limitations) but where the latter'
        + 'property is overridden in the CSS cascade, the animation should '
        + 'still report that it is running on the compositor');
   }));
 }, 'isRunningOnCompositor is true when a property that would otherwise block ' +
    'running on the compositor is overridden in the CSS cascade');
 
+promise_test(function(t) {
+  var div = addDiv(t);
+  var animation = div.animate({ opacity: [ 0, 1 ] }, 100000);
+
+  return animation.ready.then(t.step_func(function() {
+    assert_equals(animation.isRunningOnCompositor, omtaEnabled,
+      'Animation reports that it is running on the compositor');
+
+    animation.currentTime = 50000;
+    animation.effect.timing.duration = 10000;
+
+    assert_equals(animation.isRunningOnCompositor, false,
+       'Animation reports that it is NOT running on the compositor'
+       + ' when the animation is set a shorter duration than current time');
+  }));
+}, 'animation is immediately removed from compositor' +
+   'when timing.duration is made shorter than the current time');
+
+promise_test(function(t) {
+  var div = addDiv(t);
+  var animation = div.animate({ opacity: [ 0, 1 ] }, 10000);
+
+  return animation.ready.then(t.step_func(function() {
+    assert_equals(animation.isRunningOnCompositor, omtaEnabled,
+      'Animation reports that it is running on the compositor');
+
+    animation.currentTime = 50000;
+
+    assert_equals(animation.isRunningOnCompositor, false,
+      'Animation reports that it is NOT running on the compositor'
+      + ' when finished');
+
+    animation.effect.timing.duration = 100000;
+    return waitForFrame();
+  })).then(t.step_func(function() {
+    assert_equals(animation.isRunningOnCompositor, omtaEnabled,
+      'Animation reports that it is running on the compositor'
+      + ' when restarted');
+  }));
+}, 'animation is added to compositor' +
+   ' when timing.duration is made longer than the current time');
+
 </script>
 </script>
 </body>