diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html')
-rw-r--r-- | testing/web-platform/tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html b/testing/web-platform/tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html new file mode 100644 index 0000000000..7a88c032ad --- /dev/null +++ b/testing/web-platform/tests/html/canvas/offscreen/manual/draw-generic-family/2d.text.draw.generic.family.w.html @@ -0,0 +1,52 @@ +<!DOCTYPE html> +<title>OffscreenCanvas test: 2d.text.draw.generic.family.w</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/canvas/resources/canvas-tests.js"></script> +<script id='myWorker' type='text/worker'> +self.onmessage = function(e) { + let oc = new OffscreenCanvas(88, 24); + let ctx = oc.getContext('2d'); + ctx.font = '32px ' + e.data.family; + ctx.fillText(e.data.family, 0, 16); + self.postMessage(ctx.getImageData(0, 0, 88, 24).data); +}; +</script> +<script> +function testDrawGenericFamily(t, family) +{ + let blob = new Blob([document.getElementById('myWorker').textContent]); + let worker = new Worker(URL.createObjectURL(blob)); + worker.addEventListener('message', msg => { + let ctx = document.createElement('canvas').getContext('2d'); + ctx.font = '32px ' + family; + ctx.fillText(family, 0, 16); + assert_array_equals(ctx.getImageData(0, 0, 88, 24).data, msg.data, + "The image data generated by drawing generic font family '" + family + + "' should be the same for both OffscreenCanvas and regular canvas"); + t.done(); + }); + worker.postMessage({family: family}); +} + +async_test(function(t) { + testDrawGenericFamily(t, 'sans-serif'); +}, "Test that drawing sans-serif produces the same result between canvas and OffscreenCanvas in a Worker"); + +async_test(function(t) { + testDrawGenericFamily(t, 'serif'); +}, "Test that drawing serif produces the same result between canvas and OffscreenCanvas in a Worker"); + +async_test(function(t) { + testDrawGenericFamily(t, 'cursive'); +}, "Test that drawing cursive produces the same result between canvas and OffscreenCanvas in a Worker"); + +async_test(function(t) { + testDrawGenericFamily(t, 'fantasy'); +}, "Test that drawing fantasy produces the same result between canvas and OffscreenCanvas in a Worker"); + +async_test(function(t) { + testDrawGenericFamily(t, 'monospace'); +}, "Test that drawing monospace produces the same result between canvas and OffscreenCanvas in a Worker"); +</script> + |