2d.text.measure.fontBoundingBox.ahem.worker.js (1144B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.text.measure.fontBoundingBox.ahem 3 // Description:Testing fontBoundingBox for font ahem 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 promise_test(async t => { 10 var canvas = new OffscreenCanvas(100, 50); 11 var ctx = canvas.getContext('2d'); 12 13 var f = new FontFace("Ahem", "url('/fonts/Ahem.ttf')"); 14 f.load(); 15 self.fonts.add(f); 16 await self.fonts.ready; 17 ctx.font = '50px Ahem'; 18 ctx.direction = 'ltr'; 19 ctx.align = 'left' 20 _assertSame(ctx.measureText('A').fontBoundingBoxAscent, 40, "ctx.measureText('A').fontBoundingBoxAscent", "40"); 21 _assertSame(ctx.measureText('A').fontBoundingBoxDescent, 10, "ctx.measureText('A').fontBoundingBoxDescent", "10"); 22 _assertSame(ctx.measureText('ABCD').fontBoundingBoxAscent, 40, "ctx.measureText('ABCD').fontBoundingBoxAscent", "40"); 23 _assertSame(ctx.measureText('ABCD').fontBoundingBoxDescent, 10, "ctx.measureText('ABCD').fontBoundingBoxDescent", "10"); 24 }, "Testing fontBoundingBox for font ahem"); 25 done();