Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / canvas / test / test_offscreencanvas_font.html
blobad70e95b930602bbda0a62f11aab9b4968ed8634
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Serialization of font on OffscreenCanvas2d</title>
5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
7 </head>
8 <body>
9 <canvas id="c">
10 <script>
12 SimpleTest.waitForExplicitFinish();
14 function testFontShorthand(ctx, font) {
15 ctx.font = font;
16 let w1 = ctx.measureText("Hello World").width;
17 let f = ctx.font;
18 ctx.font = f;
19 let w2 = ctx.measureText("Hello World").width;
20 ok(w1 === w2, "serialization and re-setting of \"" +
21 font + "\" as \"" + f + "\" is idempotent");
24 const tests = [
25 "12px serif",
26 "12px/1.4 serif",
27 "italic 12px serif",
28 "oblique 12px serif",
29 "bold 12px serif",
30 "bold italic 12px serif",
31 "condensed bold italic 12px serif",
32 "500 italic 12px serif",
33 "italic 500 12px serif",
36 function runTest() {
37 let canvas = new OffscreenCanvas(100, 100);
38 let ctx = canvas.getContext("2d");
39 tests.forEach((t) => {
40 testFontShorthand(ctx, t);
41 });
43 // Although the bug that motivated this test was specific to offscreen canvas,
44 // let's also check that it works with a <canvas> element.
45 ctx = document.getElementById("c").getContext("2d");
46 tests.forEach((t) => {
47 testFontShorthand(ctx, t);
48 });
50 SimpleTest.finish();
53 runTest();
55 </script>
56 </body>
57 </html>