Bug 1259344 - Move play()/cancel()/playstate tests to web platform tests. r=birtles
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Mon, 04 Apr 2016 21:57:00 +0200
changeset 315681 3a1f7178cc4813b9b03f0642297ec93528d02002
parent 315680 7e41f1773b7882306b5228c114f1f01bd7d9ea4f
child 315682 fabbda4a082a27cd6a9b04d8ab198b160b13871d
push id9480
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 17:12:58 +0000
treeherdermozilla-aurora@0d6a91c76a9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1259344
milestone48.0a1
Bug 1259344 - Move play()/cancel()/playstate tests to web platform tests. r=birtles
dom/animation/test/css-animations/file_animation-play.html
dom/animation/test/css-animations/file_animation-playstate.html
dom/animation/test/css-animations/test_animation-play.html
dom/animation/test/mochitest.ini
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-animations/animation/cancel.html
testing/web-platform/tests/web-animations/animation/play.html
testing/web-platform/tests/web-animations/animation/playState.html
deleted file mode 100644
--- a/dom/animation/test/css-animations/file_animation-play.html
+++ /dev/null
@@ -1,35 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<script src="../testcommon.js"></script>
-<style>
-@keyframes abc {
-  to { transform: translate(10px) }
-}
-</style>
-<body>
-<script>
-'use strict';
-
-async_test(function(t) {
-  var div = addDiv(t, { style: 'animation: abc 100s infinite' });
-  var animation = div.getAnimations()[0];
-
-  animation.ready.then(t.step_func(function() {
-    // Seek to a time outside the active range so that play() will have to
-    // snap back to the start
-    animation.currentTime = -5000;
-    animation.playbackRate = -1;
-
-    assert_throws('InvalidStateError',
-                  function () { animation.play(); },
-                  'Expect InvalidStateError exception on calling play() ' +
-                  'with a negative playbackRate and infinite-duration ' +
-                  'animation');
-    t.done();
-  }));
-}, 'play() throws when seeking an infinite-duration animation played in ' +
-   'reverse');
-
-done();
-</script>
-</body>
--- a/dom/animation/test/css-animations/file_animation-playstate.html
+++ b/dom/animation/test/css-animations/file_animation-playstate.html
@@ -68,22 +68,11 @@ test(function(t) {
   var div = addDiv(t);
   div.style.animation = 'anim 1000s';
 
   var animation = div.getAnimations()[0];
   animation.cancel();
   assert_equals(animation.playState, 'idle');
 }, 'Animation returns correct playState when cancelled');
 
-test(function(t) {
-  var div = addDiv(t);
-  div.style.animation = 'anim 1000s';
-
-  var animation = div.getAnimations()[0];
-  animation.cancel();
-  animation.currentTime = 50 * 1000;
-  assert_equals(animation.playState, 'paused',
-                'After seeking an idle animation, it is effectively paused');
-}, 'After cancelling an animation, seeking it makes it paused');
-
 done();
 </script>
 </body>
deleted file mode 100644
--- a/dom/animation/test/css-animations/test_animation-play.html
+++ /dev/null
@@ -1,15 +0,0 @@
-<!doctype html>
-<meta charset=utf-8>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<script>
-'use strict';
-setup({explicit_done: true});
-SpecialPowers.pushPrefEnv(
-  { "set": [["dom.animations-api.core.enabled", true]]},
-  function() {
-    window.open("file_animation-play.html");
-  });
-</script>
-</html>
--- a/dom/animation/test/mochitest.ini
+++ b/dom/animation/test/mochitest.ini
@@ -7,17 +7,16 @@ support-files =
   css-animations/file_animation-computed-timing.html
   css-animations/file_animation-currenttime.html
   css-animations/file_animation-finish.html
   css-animations/file_animation-finished.html
   css-animations/file_animation-id.html
   css-animations/file_animation-oncancel.html
   css-animations/file_animation-onfinish.html
   css-animations/file_animation-pausing.html
-  css-animations/file_animation-play.html
   css-animations/file_animation-playstate.html
   css-animations/file_animation-ready.html
   css-animations/file_animation-reverse.html
   css-animations/file_animation-starttime.html
   css-animations/file_animations-dynamic-changes.html
   css-animations/file_cssanimation-animationname.html
   css-animations/file_document-get-animations.html
   css-animations/file_effect-target.html
@@ -48,17 +47,16 @@ support-files =
 [css-animations/test_animation-computed-timing.html]
 [css-animations/test_animation-currenttime.html]
 [css-animations/test_animation-finish.html]
 [css-animations/test_animation-finished.html]
 [css-animations/test_animation-id.html]
 [css-animations/test_animation-oncancel.html]
 [css-animations/test_animation-onfinish.html]
 [css-animations/test_animation-pausing.html]
-[css-animations/test_animation-play.html]
 [css-animations/test_animation-playstate.html]
 [css-animations/test_animation-ready.html]
 [css-animations/test_animation-reverse.html]
 [css-animations/test_animation-starttime.html]
 [css-animations/test_cssanimation-animationname.html]
 [css-animations/test_document-get-animations.html]
 [css-animations/test_effect-target.html]
 [css-animations/test_element-get-animations.html]
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -28425,28 +28425,40 @@
         "path": "web-animations/animation-timeline/document-timeline.html",
         "url": "/web-animations/animation-timeline/document-timeline.html"
       },
       {
         "path": "web-animations/animation-timeline/idlharness.html",
         "url": "/web-animations/animation-timeline/idlharness.html"
       },
       {
+        "path": "web-animations/animation/cancel.html",
+        "url": "/web-animations/animation/cancel.html"
+      },
+      {
         "path": "web-animations/animation/constructor.html",
         "url": "/web-animations/animation/constructor.html"
       },
       {
         "path": "web-animations/animation/finish.html",
         "url": "/web-animations/animation/finish.html"
       },
       {
+        "path": "web-animations/animation/play.html",
+        "url": "/web-animations/animation/play.html"
+      },
+      {
         "path": "web-animations/animation/playbackRate.html",
         "url": "/web-animations/animation/playbackRate.html"
       },
       {
+        "path": "web-animations/animation/playState.html",
+        "url": "/web-animations/animation/playState.html"
+      },
+      {
         "path": "web-animations/keyframe-effect/constructor.html",
         "url": "/web-animations/keyframe-effect/constructor.html"
       },
       {
         "path": "web-animations/keyframe-effect/effect-easing.html",
         "url": "/web-animations/keyframe-effect/effect-easing.html"
       },
       {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/web-animations/animation/cancel.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Animation.cancel()</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-cancel">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<link rel="stylesheet" href="/resources/testharness.css">
+<body>
+<div id="log"></div>
+<script>
+'use strict';
+
+promise_test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({transform: ['none', 'translate(100px)']},
+                              100 * MS_PER_SEC);
+  return animation.ready.then(function() {
+    assert_not_equals(getComputedStyle(div).transform, 'none',
+                      'transform style is animated before cancelling');
+    animation.cancel();
+    assert_equals(getComputedStyle(div).transform, 'none',
+                  'transform style is no longer animated after cancelling');
+  });
+}, 'Animated style is cleared after calling Animation.cancel()');
+
+test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({marginLeft: ['0px', '100px']},
+                              100 * MS_PER_SEC);
+  animation.effect.timing.easing = 'linear';
+  animation.cancel();
+  assert_equals(getComputedStyle(div).marginLeft, '0px',
+                'margin-left style is not animated after cancelling');
+ 
+  animation.currentTime = 50 * MS_PER_SEC;
+  assert_equals(getComputedStyle(div).marginLeft, '50px',
+                'margin-left style is updated when cancelled animation is'
+                + ' seeked');
+}, 'After cancelling an animation, it can still be seeked');
+ 
+promise_test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({marginLeft:['100px', '200px']},
+                              100 * MS_PER_SEC);
+  return animation.ready.then(function() {
+    animation.cancel();
+    assert_equals(getComputedStyle(div).marginLeft, '0px',
+                  'margin-left style is not animated after cancelling');
+    animation.play();
+    assert_equals(getComputedStyle(div).marginLeft, '100px',
+                  'margin-left style is animated after re-starting animation');
+    return animation.ready;
+  }).then(function() {
+    assert_equals(animation.playState, 'running',
+                  'Animation succeeds in running after being re-started');
+  });
+}, 'After cancelling an animation, it can still be re-used');
+
+</script>
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/web-animations/animation/play.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Animation.play()</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-play">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<link rel="stylesheet" href="/resources/testharness.css">
+<body>
+<div id="log"></div>
+<script>
+'use strict';
+
+promise_test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({ transform: ['none', 'translate(10px)']},
+                              { duration : 100 * MS_PER_SEC,
+                                iterations : Infinity});
+  return animation.ready.then(function() {
+    // Seek to a time outside the active range so that play() will have to
+    // snap back to the start
+    animation.currentTime = -5 * MS_PER_SEC;
+    animation.playbackRate = -1;
+
+    assert_throws('InvalidStateError',
+                  function () { animation.play(); },
+                  'Expected InvalidStateError exception on calling play() ' +
+                  'with a negative playbackRate and infinite-duration ' +
+                  'animation');
+  });
+}, 'play() throws when seeking an infinite-duration animation played in ' +
+   'reverse');
+
+</script>
+</body>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/web-animations/animation/playState.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>Animation.playState</title>
+<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playstate">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../testcommon.js"></script>
+<link rel="stylesheet" href="/resources/testharness.css">
+<body>
+<div id="log"></div>
+<script>
+'use strict';
+
+promise_test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({}, 100 * MS_PER_SEC);
+ 
+  assert_equals(animation.playState, 'pending');
+  return animation.ready.then(function() {
+    assert_equals(animation.playState, 'running');
+  });
+}, 'Animation.playState reports \'pending\'->\'running\' when initially ' +
+   'played');
+
+promise_test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({}, 100 * MS_PER_SEC);
+  animation.pause();
+
+  assert_equals(animation.playState, 'pending');
+  return animation.ready.then(function() {
+    assert_equals(animation.playState, 'paused');
+  });
+}, 'Animation.playState reports \'pending\'->\'paused\' when pausing');
+
+test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({}, 100 * MS_PER_SEC);
+  animation.cancel();
+  assert_equals(animation.playState, 'idle');
+}, 'Animation.playState is \'idle\' when canceled.');
+
+test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({}, 100 * MS_PER_SEC);
+  animation.cancel();
+  animation.currentTime = 50 * MS_PER_SEC;
+  assert_equals(animation.playState, 'paused',
+                'After seeking an idle animation, it is effectively paused');
+}, 'Animation.playState is \'paused\' after cancelling an animation, ' +
+   'seeking it makes it paused');
+
+</script>
+</body>