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">
12 SimpleTest
.waitForExplicitFinish();
14 function testFontShorthand(ctx
, font
) {
16 let w1
= ctx
.measureText("Hello World").width
;
19 let w2
= ctx
.measureText("Hello World").width
;
20 ok(w1
=== w2
, "serialization and re-setting of \"" +
21 font
+ "\" as \"" + f
+ "\" is idempotent");
30 "bold italic 12px serif",
31 "condensed bold italic 12px serif",
32 "500 italic 12px serif",
33 "italic 500 12px serif",
37 let canvas
= new OffscreenCanvas(100, 100);
38 let ctx
= canvas
.getContext("2d");
39 tests
.forEach((t
) => {
40 testFontShorthand(ctx
, t
);
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
);