Bug 1527487 [wpt PR 15344] - [Animation Worklet] Clean up animator registration logic for wpt test, a=testonly
authorYi Gu <yigu@chromium.org>
Tue, 05 Mar 2019 11:09:42 +0000
changeset 522399 6aeb4c5cd8ebce41df1d315a73f039dc415f8189
parent 522398 d81d788e3b76106dbf290db46e7515c8ecb9cc45
child 522400 edd5fd41dac0ab66f5f45562afc8c4ac939774b2
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1527487, 15344, 923881, 1466145, 631287
milestone67.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 1527487 [wpt PR 15344] - [Animation Worklet] Clean up animator registration logic for wpt test, a=testonly Automatic update from web-platform-tests [Animation Worklet] Clean up animator registration logic for wpt test Similar to [1], we should register the animator only once in the setup for test current-time.https.html. Given that DocumentTimeline does not always move forward, this test also replaces waitForNextFrame with waitForDocumentTimelineAdvance. [1] https://cs.chromium.org/chromium/src/third_party/blink/web_tests/external/wpt/animation-worklet/scroll-timeline-writing-modes.https.html Bug: 923881 Change-Id: Iabc6c7c1cea520e3dd81ed8a781cc072e2d8e20b Reviewed-on: https://chromium-review.googlesource.com/c/1466145 Commit-Queue: Yi Gu <yigu@chromium.org> Reviewed-by: Majid Valipour <majidvp@chromium.org> Cr-Commit-Position: refs/heads/master@{#631287} -- wpt-commits: 109654d2560bf74830e483fdf15cbbc67208a877 wpt-pr: 15344
testing/web-platform/tests/animation-worklet/current-time.https.html
--- a/testing/web-platform/tests/animation-worklet/current-time.https.html
+++ b/testing/web-platform/tests/animation-worklet/current-time.https.html
@@ -1,48 +1,64 @@
 <!DOCTYPE html>
 <meta charset=utf-8>
 <title>The current time of a worklet animation</title>
 <link rel="help" href="https://drafts.css-houdini.org/css-animationworklet/">
+
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="/web-animations/testcommon.js"></script>
 <script src="common.js"></script>
-<body>
-<div id="log"></div>
+
+<div id="box"></div>
+
 <script>
 'use strict';
 
-const DURATION = 10000; // ms
-const KEYFRAMES = { height : ['100px', '50px'] };
+function CreateAnimation() {
+  const box = document.getElementById('box');
+  const effect = new KeyframeEffect(
+      box,
+      { height: ['100px', '50px'] },
+      10000);
+
+  return new WorkletAnimation('passthrough', effect);
+}
 
-promise_test(async t => {
-  await registerPassthroughAnimator();
-  const animation =
-    new WorkletAnimation('passthrough', new KeyframeEffect(createDiv(t),
-        KEYFRAMES, DURATION), document.timeline);
+setup(setupAndRegisterTests, {explicit_done: true});
 
-  animation.play();
-  assert_equals(animation.currentTime, 0,
-    'Current time returns the hold time set when entering the play-pending' +
-    'state');
-}, 'The current time returns the hold time when set');
+function setupAndRegisterTests() {
+  registerPassthroughAnimator().then(() => {
+    promise_test(async t => {
+      const animation = CreateAnimation();
+      animation.play();
+
+      assert_equals(animation.currentTime, 0,
+        'Current time returns the hold time set when entering the play-pending' +
+        'state');
 
-promise_test(async t => {
-  await registerPassthroughAnimator();
-  const animation =
-    new WorkletAnimation('passthrough', new KeyframeEffect(createDiv(t),
-        KEYFRAMES, DURATION), document.timeline);
+      animation.cancel();
+    }, 'The current time returns the hold time when set');
+
+    promise_test(async t => {
+      const animation = CreateAnimation();
+      animation.play();
 
-  // TODO(majidvp): We should use Animation.startTime here because the
-  // animation may not immediately start.
-  const startTime = document.timeline.currentTime;
-  animation.play();
-  await waitForNextFrame();
-  const timelineTime = document.timeline.currentTime;
-  assert_times_equal(animation.currentTime, (timelineTime - startTime));
-}, 'The current time is calculated from the timeline time and start time');
+      // Allow one async animation frame to pass so that animation is running.
+      await waitForAsyncAnimationFrames(1);
+      assert_equals(animation.playState, "running");
+      // Allow time to advance so that we have a non-zero current time.
+      await waitForDocumentTimelineAdvance();
+      const timelineTime = document.timeline.currentTime;
+      assert_greater_than(animation.currentTime, 0);
+      assert_times_equal(animation.currentTime, (timelineTime - animation.startTime));
+
+      animation.cancel();
+    }, 'The current time is calculated from the timeline time and start time');
+
+    done();
+  });
+}
 
 // TODO(majidvp): Add tests for playbackRate and animations that are not
 // associated with a timeline once these are supported in  WorkletAnimation.
 // http://crbug.com/833846
 </script>
-</body>