Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/offscreen/text/2d.text.shape.fillGlyphRuns-shadow.tentative.w.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<html class="reftest-wait">
<link rel="match" href="2d.text.shape.fillGlyphRuns-shadow.tentative-expected.html">
<script src="/common/reftest-wait.js"></script>
<title>Canvas test: 2d.text.shape.fillGlyphRuns-shadow.tentative</title>
<h1>2d.text.shape.fillGlyphRuns-shadow.tentative</h1>
<p class="desc">Test that a multi-word glyph run with a shadow renders like fillText(), with no word's shadow painted over the glyphs of the previous word.</p>
<canvas id="canvas" width="300" height="100">
<p class="fallback">FAIL (fallback content)</p>
</canvas>
<script id='myWorker' type='text/worker'>
self.onmessage = function(e) {
try {
const canvas = new OffscreenCanvas(300, 100);
const ctx = canvas.getContext('2d');
ctx.font = '24px sans-serif';
const st = ctx.shapeText('Wave fi 12');
ctx.shadowColor = '#0a0';
ctx.shadowOffsetX = -15;
ctx.shadowOffsetY = 2;
ctx.fillGlyphRuns(st.glyphRuns(), 40, 50);
const bitmap = canvas.transferToImageBitmap();
self.postMessage({ type: 'bitmap', bitmap }, [bitmap]);
} catch (error) {
self.postMessage({ type: 'error', message: error });
}
};
</script>
<script>
const blob = new Blob([document.getElementById('myWorker').textContent]);
const worker = new Worker(URL.createObjectURL(blob));
worker.onerror = failOnError;
worker.onmessage = reftestStep(msg => {
if (msg.data.type === 'error') {
failOnError(msg.data.message);
return;
}
const outputCtx = document.getElementById("canvas").getContext('2d');
outputCtx.drawImage(msg.data.bitmap, 0, 0);
takeScreenshot();
});
worker.postMessage(null);
</script>
</html>