Commit c6a0fa49 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[animation worklet] Fix tests to not rely on the console log from worklet

For worklet animations that run via the main thread, the console log
from the worklet may not get back to the main thread within 2 frames.
To fix this, we can either wait longer, i.e. wait an extra frame, or not
rely on the console log from the worklet as what we do in this patch.

Bug: 887659
Change-Id: Ifb8619f571f51a7f5abe132a2c65d7a58f59d600
Reviewed-on: https://chromium-review.googlesource.com/c/1289430Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601293}
parent cff3ea27
...@@ -5301,8 +5301,6 @@ crbug.com/886566 http/tests/csspaint/invalidation-content-image.html [ Pass Time ...@@ -5301,8 +5301,6 @@ crbug.com/886566 http/tests/csspaint/invalidation-content-image.html [ Pass Time
# Enable AnimationWorklet tests for mainthread # Enable AnimationWorklet tests for mainthread
crbug.com/887659 animations/animationworklet/animation-worklet-inside-iframe.html [ Failure ] crbug.com/887659 animations/animationworklet/animation-worklet-inside-iframe.html [ Failure ]
crbug.com/887659 animations/animationworklet/animator-animate.html [ Failure ]
crbug.com/887659 animations/animationworklet/animator-with-options.html [ Failure ]
crbug.com/887659 animations/animationworklet/worklet-animation-currentTime.html [ Failure ] crbug.com/887659 animations/animationworklet/worklet-animation-currentTime.html [ Failure ]
crbug.com/887659 animations/animationworklet/worklet-animation-local-time-after-duration.html [ Failure ] crbug.com/887659 animations/animationworklet/worklet-animation-local-time-after-duration.html [ Failure ]
......
CONSOLE MESSAGE: line 4: test animator constructor called. CONSOLE MESSAGE: line 36: opacity of target is 0.5
CONSOLE MESSAGE: line 8: test animator animate called.
...@@ -8,14 +8,8 @@ ...@@ -8,14 +8,8 @@
</style> </style>
<script id="simple_animate" type="text/worklet"> <script id="simple_animate" type="text/worklet">
registerAnimator("test_animator", class { registerAnimator("test_animator", class {
constructor() {
console.log("test animator constructor called.");
}
animate(currentTime, effect) { animate(currentTime, effect) {
if (!this.animated) effect.localTime = 500;
console.log("test animator animate called.");
effect.localTime = 0;
this.animated = true;
} }
}); });
</script> </script>
...@@ -32,12 +26,14 @@ if (window.testRunner) { ...@@ -32,12 +26,14 @@ if (window.testRunner) {
runInAnimationWorklet( runInAnimationWorklet(
document.getElementById('simple_animate').textContent document.getElementById('simple_animate').textContent
).then(_ => { ).then(_ => {
const effect = new KeyframeEffect(document.getElementById("target"), [{ opacity: 0 }], { duration: 1000 }); const target = document.getElementById('target');
const effect = new KeyframeEffect(target, [{ opacity: 0 }], { duration: 1000 });
const animation = new WorkletAnimation('test_animator', [effect], document.timeline, {}); const animation = new WorkletAnimation('test_animator', [effect], document.timeline, {});
animation.play(); animation.play();
if (window.testRunner) { if (window.testRunner) {
waitTwoAnimationFrames( _ => { waitTwoAnimationFrames( _ => {
console.log(`opacity of target is ${getComputedStyle(target).opacity}`);
testRunner.notifyDone(); testRunner.notifyDone();
}); });
} }
......
CONSOLE MESSAGE: line 4: animator constructor with options called. CONSOLE MESSAGE: line 44: opacity of target is 0.5
CONSOLE MESSAGE: line 5: options.dict.id = 1
CONSOLE MESSAGE: line 6: options.dict.name = test_name
CONSOLE MESSAGE: line 7: options.string = test_string
CONSOLE MESSAGE: line 11: test animator animate called.
...@@ -10,15 +10,10 @@ ...@@ -10,15 +10,10 @@
<script id="animate_with_options" type="text/worklet"> <script id="animate_with_options" type="text/worklet">
registerAnimator("test_animator", class { registerAnimator("test_animator", class {
constructor(options) { constructor(options) {
console.log("animator constructor with options called."); this.time_ = options.time;
console.log("options.dict.id = " + options.dict.id);
console.log("options.dict.name = " + options.dict.name);
console.log("options.string = " + options.string);
} }
animate(currentTime, effect) { animate(currentTime, effect) {
if (!this.animated) effect.localTime = this.time_;
console.log("test animator animate called.");
this.animated = true;
} }
}); });
</script> </script>
...@@ -35,10 +30,10 @@ if (window.testRunner) { ...@@ -35,10 +30,10 @@ if (window.testRunner) {
runInAnimationWorklet( runInAnimationWorklet(
document.getElementById('animate_with_options').textContent document.getElementById('animate_with_options').textContent
).then(_ => { ).then(_ => {
const effect = new KeyframeEffect(document.getElementById("target"), [{ opacity: 0 }], { duration: 1000 }); const target = document.getElementById('target');
const effect = new KeyframeEffect(target, [{ opacity: 0 }], { duration: 1000 });
const options = { const options = {
dict: { 'name': 'test_name', 'id': 1 }, 'time': 500
string: 'test_string'
}; };
const animation = new WorkletAnimation('test_animator', [effect], const animation = new WorkletAnimation('test_animator', [effect],
document.timeline, options); document.timeline, options);
...@@ -46,6 +41,7 @@ runInAnimationWorklet( ...@@ -46,6 +41,7 @@ runInAnimationWorklet(
if (window.testRunner) { if (window.testRunner) {
waitTwoAnimationFrames( _ => { waitTwoAnimationFrames( _ => {
console.log(`opacity of target is ${getComputedStyle(target).opacity}`);
testRunner.notifyDone(); testRunner.notifyDone();
}); });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment