Files
firefox/testing/web-platform/tests/css/css-paint-api/geometry-border-image-005.https.html
Xida Chen 361da058af Bug 1585142 [wpt PR 19413] - [OT-PW] Fixes crash when drawing patterns, a=testonly
Automatic update from web-platform-tests
[OT-PW] Fixes crash when drawing patterns

Right now the PaintWorkletDeferredImage keeps a scoped_refptr to the
PaintWorkletInput, and during the CreateShader function, the ownership
of that PaintWorkletInput is given to a PaintImage, which is then used
to create a PaintShader.

Notice that the CreateShader function can be called multiple times,
and in this case the PaintWorkletInput is nullptr after the first call.
And then it triggers a crash in PaintShader::MakeImage.

To fix this, we make the PaintWorkletDeferredImage keeps a PaintImage
which would always own the PaintWorkletInput that is passed to it.
When CreateShader is called, we can use the PaintImage to build the
shader.

A layout test is added to ensure there is no crash.

Bug: 1009450
Change-Id: I8fa5f45728884fe213176b4f5490329259a19a27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1831790
Reviewed-by: Stephen McGruer <[email protected]>
Reviewed-by: Rune Lillesveen <[email protected]>
Commit-Queue: Xida Chen <[email protected]>
Cr-Commit-Position: refs/heads/master@{#702392}

--

wpt-commits: 66a2fe2ae02b32e910ff091904653e62ec0c9060
wpt-pr: 19413
2019-10-14 11:23:42 +00:00

38 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html class="reftest-wait">
<link rel="help" href="https://drafts.css-houdini.org/css-paint-api/">
<link rel="match" href="geometry-border-image-005-ref.html">
<style>
html, body { margin: 0; padding: 0; }
.container {
width: 200px;
height: 200px;
border: 36px solid orange;
border-image: paint(foo) /* source */
1 / /* slice */
36px 36px 36px 36px / /* width */
18px 18px 18px 18px /* outset */
round;
}
</style>
<script src="/common/reftest-wait.js"></script>
<script src="/common/worklet-reftest.js"></script>
<body>
<div id="target" class="container"></div>
<script id="code" type="text/worklet">
registerPaint('foo', class {
paint(ctx, geom) {
// Both geom.width and height are 200 + 36 *3 = 308px;
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, geom.width, geom.height);
}
});
</script>
<script>
importWorkletAndTerminateTestAfterAsyncPaint(CSS.paintWorklet, document.getElementById('code').textContent);
</script>
</body>
</html>