1871755-1.html (1554B)
1 <!DOCTYPE HTML> 2 <html class="reftest-wait"> 3 <head> 4 <title>Missing-font notifications from OffscreenCanvas2d</title> 5 </head> 6 <body> 7 </body> 8 <script> 9 // Workaround for bug 1962172: this will cause the CJK fallback order 10 // to be loaded on the main thread, before the worker tries to use it. 11 // (Can be removed when bug 1962172 is resolved.) 12 let canvas = new OffscreenCanvas(100, 100); 13 let ctx = canvas.getContext("2d"); 14 ctx.measureText("\u4567\u9876"); 15 16 // Try measuring a selection of characters from across the 17 // Unicode space; almost certainly this will hit some codepoints 18 // for which font support is lacking. 19 const blob = new Blob([` 20 self.onmessage = (evt) => { 21 let ctx = evt.data.canvas.getContext("2d"); 22 // Sampling planes 0 and 1 is enough; plane 2 just adds more CJK, not new scripts. 23 for (plane = 0; plane < 2; ++plane) { 24 let txt = "Plane " + plane + " text: "; 25 for (block = 0; block < 256; ++block) { 26 for (ch = 0; ch < 256; ch += 64) { 27 txt += String.fromCodePoint(plane * 0x10000 + block * 0x100 + ch); 28 } 29 } 30 ctx.measureText(txt); 31 postMessage(txt); 32 } 33 postMessage("Done"); 34 } 35 `], { 36 type: "application/typescript", 37 }); 38 39 const url = URL.createObjectURL(blob); 40 const worker = new Worker(url); 41 42 worker.onmessage = (msg) => { 43 console.log(msg.data); 44 if (msg.data == "Done") { 45 document.documentElement.classList.remove("reftest-wait") 46 } 47 }; 48 49 let offscreen = new OffscreenCanvas(100, 100); 50 worker.postMessage({ canvas: offscreen }, [offscreen]); 51 </script> 52 </html>