fune/testing/web-platform/tests/css/css-paint-api/one-custom-property-animation-half-opaque.https.html
Xida Chen 7af64c2e74 Bug 1730519 [wpt PR 30695] - Deflake a paint worklet test, a=testonly
Automatic update from web-platform-tests
Deflake a paint worklet test

This CL Deflakes a paint worklet test. The root cause of the
flakiness is that the ref.html is finishing too early and
therefore trigger a crash.

The reason of changing the div to be 500*500px is to avoid
having a scrollbar in the result. Having the scrollbar
seems to cause a difference in the result.

I have ran this test locally with --repeat-each=1000 -f, and
there is no crash at all.

Let's change this one test first, and if this works, I will
change all other ref html to use canvas instead of a simple div.

Bug: 1123886
Change-Id: Icacfd6e80b7392360646284a25469b65f4c180b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3158166
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#920859}

--

wpt-commits: 1d7ca04cbb1a2f0a9e7016f368104a7ff46a67ea
wpt-pr: 30695
2021-09-29 09:24:10 +00:00

65 lines
2 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.css-houdini.org/css-paint-api/">
<link rel="match" href="one-custom-property-animation-half-opaque-ref.html">
<style>
.container {
width: 500px;
height: 500px;
}
@keyframes expand {
0% { --foo: rgba(0, 200, 0, 1); }
100% { --foo: rgba(200, 0, 0, 0.6); }
}
.animate {
background-image: paint(geometry);
/* Use a long animation that start at 50% progress where the slope of the
selected timing function is zero. By setting up the animation in this way,
we accommodate lengthy delays in running the test without a potential drift
in the animated property value. This is important for avoiding flakes,
especially on debug builds. The screenshots are taken as soon as the
animation is ready, thus the long animation duration has no bearing on
the actual duration of the test. */
animation: expand 1000000s cubic-bezier(0,1,1,0) -500000s;
will-change: transform;
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<body>
<div id="canvas-geometry" class="container"></div>
<script id="code" type="text/worklet">
registerPaint('geometry', class {
static get inputProperties() { return ['--foo']; }
paint(ctx, geom, properties) {
ctx.fillStyle = properties.get('--foo').toString();
ctx.fillRect(0, 0, geom.width, geom.height);
}
});
</script>
<script>
CSS.registerProperty({
name: '--foo',
syntax: '<color>',
initialValue: 'rgb(0, 0, 0)',
inherits: false
});
</script>
<script>
var blob = new Blob([document.getElementById('code').textContent],
{type: 'text/javascript'});
CSS.paintWorklet.addModule(URL.createObjectURL(blob)).then(function() {
document.getElementById('canvas-geometry').classList.add('animate');
const animations = document.getAnimations();
// Wait for the animation to start before completing the test.
document.getAnimations()[0].ready.then(() => {
takeScreenshot();
});
});
</script>
</body>
</html>