| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 // test 77: external SVG fonts, from Erik Dahlstrom | 2 // test 77: external SVG fonts, from Erik Dahlstrom |
| 3 // | 3 // |
| 4 // SVGFonts are described here[3], and the relevant DOM methods | 4 // SVGFonts are described here[3], and the relevant DOM methods |
| 5 // used in the test are defined here[4]. | 5 // used in the test are defined here[4]. |
| 6 // | 6 // |
| 7 // Note that in order to be more predictable the svg should be | 7 // Note that in order to be more predictable the svg should be |
| 8 // visible, so that clause "For non-rendering environments, the | 8 // visible, so that clause "For non-rendering environments, the |
| 9 // user agent shall make reasonable assumptions about glyph | 9 // user agent shall make reasonable assumptions about glyph |
| 10 // metrics." doesn't influence the results. We use 'opacity:0' | 10 // metrics." doesn't influence the results. We use 'opacity:0' |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 <html> | 24 <html> |
| 25 <head> | 25 <head> |
| 26 <script src="../../fast/js/resources/js-test-pre.js"></script> | 26 <script src="../../fast/js/resources/js-test-pre.js"></script> |
| 27 </head> | 27 </head> |
| 28 <body> | 28 <body> |
| 29 <p id="description"></p> | 29 <p id="description"></p> |
| 30 <div id="console"></div> | 30 <div id="console"></div> |
| 31 <script> | 31 <script> |
| 32 description("Acid3 test 77, checking text metric functionality"); | 32 description("Acid3 test 77, checking text metric functionality"); |
| 33 | 33 |
| 34 window.jsTestIsAsync = true; |
| 34 if (window.testRunner) | 35 if (window.testRunner) |
| 35 testRunner.waitUntilDone(); | 36 testRunner.waitUntilDone(); |
| 36 | 37 |
| 37 var text; | 38 var text; |
| 38 var iframe; | 39 var iframe; |
| 39 | 40 |
| 40 function startTest() { | 41 function startTest() { |
| 41 iframe = document.createElement("iframe"); | 42 iframe = document.createElement("iframe"); |
| 42 iframe.onload = fontLoaded; | 43 iframe.onload = fontLoaded; |
| 43 iframe.src = "resources/Acid3Font-loader.svg"; | 44 iframe.src = "resources/Acid3Font-loader.svg"; |
| 44 document.documentElement.appendChild(iframe); | 45 document.documentElement.appendChild(iframe); |
| 45 } | 46 } |
| 46 | 47 |
| 47 var fontLoaded = function() { | 48 var fontLoaded = function() { |
| 48 var svg = iframe.getSVGDocument().documentElement; | 49 var svg = iframe.getSVGDocument().documentElement; |
| 49 text = iframe.getSVGDocument().getElementsByTagName('text')[0]; | 50 text = iframe.getSVGDocument().getElementsByTagName('text')[0]; |
| 50 text.textContent = "abc"; | 51 text.textContent = "abc"; |
| 51 text.setAttribute("y", "1em"); | 52 text.setAttribute("y", "1em"); |
| 52 text.setAttribute("font-size", "4000"); | 53 text.setAttribute("font-size", "4000"); |
| 53 executeTest(); | 54 executeTest(); |
| 54 } | 55 } |
| 55 | 56 |
| 56 function executeTest() { | 57 function executeTest() { |
| 57 // The font-size 4000 was chosen because that matches the unitsPerEm value i
n the svgfont, | 58 // The font-size 4000 was chosen because that matches the unitsPerEm value i
n the svgfont, |
| 58 // which makes it easy to check the glyph advances since they will then be e
xactly what was specified in the svgfont. | 59 // which makes it easy to check the glyph advances since they will then be e
xactly what was specified in the svgfont. |
| 59 shouldBe("text.getNumberOfChars()", "3"); | 60 shouldBe("text.getNumberOfChars()", "3"); |
| 60 shouldBe("text.getComputedTextLength()", "4711+42+23"); | 61 shouldBe("text.getComputedTextLength()", "4711+42+23"); |
| 61 shouldBe("text.getSubStringLength(0,1)", "42"); | 62 shouldBe("text.getSubStringLength(0,1)", "42"); |
| 62 shouldBe("text.getSubStringLength(0,2)", "42+23"); | 63 shouldBe("text.getSubStringLength(0,2)", "42+23"); |
| 63 shouldBe("text.getSubStringLength(1,1)", "23"); | 64 shouldBe("text.getSubStringLength(1,1)", "23"); |
| 64 shouldBe("text.getSubStringLength(1,0)", "0"); | 65 shouldBe("text.getSubStringLength(1,0)", "0"); |
| 65 shouldBe("text.getSubStringLength(1, 3)", "4734"); | 66 shouldBe("text.getSubStringLength(1, 3)", "4734"); |
| 66 shouldBe("text.getSubStringLength(0, 4)", "4776"); | 67 shouldBe("text.getSubStringLength(0, 4)", "4776"); |
| 67 shouldThrow("text.getSubStringLength(3, 0)"); | 68 shouldThrow("text.getSubStringLength(3, 0)"); |
| 68 shouldThrow("text.getSubStringLength(-17, 20)"); | 69 shouldThrow("text.getSubStringLength(-17, 20)"); |
| 69 shouldBe("text.getStartPositionOfChar(0).x", "0"); | 70 shouldBe("text.getStartPositionOfChar(0).x", "0"); |
| 70 shouldBe("text.getStartPositionOfChar(1).x", "42"); | 71 shouldBe("text.getStartPositionOfChar(1).x", "42"); |
| 71 shouldBe("text.getStartPositionOfChar(2).x", "42+23"); | 72 shouldBe("text.getStartPositionOfChar(2).x", "42+23"); |
| 72 shouldBe("text.getStartPositionOfChar(0).y", "4000"); | 73 shouldBe("text.getStartPositionOfChar(0).y", "4000"); |
| 73 shouldThrow("text.getEndPositionOfChar(-1)"); | 74 shouldThrow("text.getEndPositionOfChar(-1)"); |
| 74 shouldThrow("text.getEndPositionOfChar(4)"); | 75 shouldThrow("text.getEndPositionOfChar(4)"); |
| 75 shouldBe("text.getEndPositionOfChar(0).x", "42"); | 76 shouldBe("text.getEndPositionOfChar(0).x", "42"); |
| 76 shouldBe("text.getEndPositionOfChar(1).x", "42+23"); | 77 shouldBe("text.getEndPositionOfChar(1).x", "42+23"); |
| 77 shouldBe("text.getEndPositionOfChar(2).x", "42+23+4711"); | 78 shouldBe("text.getEndPositionOfChar(2).x", "42+23+4711"); |
| 78 shouldThrow("text.getEndPositionOfChar(-17)"); | 79 shouldThrow("text.getEndPositionOfChar(-17)"); |
| 79 shouldThrow("text.getEndPositionOfChar(4)"); | 80 shouldThrow("text.getEndPositionOfChar(4)"); |
| 80 | 81 |
| 81 var script = document.createElement('script'); | 82 finishJSTest(); |
| 82 script.onload = completeTest; | |
| 83 script.src = "../../fast/js/resources/js-test-post.js"; | |
| 84 document.body.appendChild(script); | |
| 85 } | |
| 86 | |
| 87 function completeTest() { | |
| 88 if (window.testRunner) | |
| 89 testRunner.notifyDone(); | |
| 90 } | 83 } |
| 91 | 84 |
| 92 startTest(); | 85 startTest(); |
| 93 </script> | 86 </script> |
| 94 </body> | 87 </body> |
| 95 </html> | 88 </html> |
| OLD | NEW |