1 description('This tests that the width of textareas and inputs is correctly calculated based on the metrics of the SVG font.');
3 var styleElement = document.createElement('style');
4 // FIXME: Is there a better way to create a font-face from JS?
5 styleElement.innerText = '@font-face { font-family: "SVGraffiti"; src: url("resources/graffiti.svg#SVGraffiti") format(svg) }';
6 document.getElementsByTagName('head')[0].appendChild(styleElement);
8 var textarea = document.createElement('textarea');
9 textarea.style.fontFamily = 'SVGraffiti';
10 textarea.style.fontSize = '11px';
11 textarea.style.padding = 0;
13 document.body.appendChild(textarea);
15 var input = document.createElement('input');
16 input.style.fontFamily = 'SVGraffiti';
17 input.style.fontSize = '11px';
18 input.style.padding = 0;
20 document.body.appendChild(input);
22 // Force a layout to ensure SVGGraffiti gets loaded.
23 // Needs to happen before onLoad.
24 document.body.offsetWidth;
26 // Need to wait for the load event to make sure the font is loaded.
27 window.addEventListener('load', function()
29 debug("Textarea offsetWidth: " + textarea.offsetWidth);
30 debug("Input offsetWidth: " + input.offsetWidth);
33 var successfullyParsed = true;