test_bug695639.xhtml (2426B)
1 <?xml version="1.0"?> 2 <?xml-stylesheet type="text/css" href="chrome://global/skin"?> 3 <?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> 4 <?xml-stylesheet type="text/css" href="test_bug695639.css"?> 5 <!-- 6 https://bugzilla.mozilla.org/show_bug.cgi?id=695639 7 --> 8 <window title="Mozilla Bug 695639" 9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 10 onload="RunTest();"> 11 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 12 <script type="application/javascript"> 13 <![CDATA[ 14 /** Test for Bug 695639 - check that GetFontFacesForText handles wrapped lines properly */ 15 16 SimpleTest.waitForExplicitFinish(); 17 18 function RunTest() { 19 var rng = document.createRange(); 20 var elem, fonts, f; 21 22 elem = document.getElementById("test").childNodes[0]; 23 rng.setStart(elem, 0); 24 rng.setEnd(elem, 14); 25 fonts = InspectorUtils.getUsedFontFaces(rng); 26 is(fonts.length, 2, "number of fonts used for entire text"); 27 28 // initial latin substring... 29 rng.setStart(elem, 0); 30 rng.setEnd(elem, 5); // "Hello" 31 fonts = InspectorUtils.getUsedFontFaces(rng); 32 is(fonts.length, 1, "number of fonts (1)"); 33 f = fonts[0]; 34 is(f.name, "Gentium Plus", "font name (1)"); 35 36 // the space (where the line wraps) should also be Gentium 37 rng.setStart(elem, 5); 38 rng.setEnd(elem, 6); // space 39 fonts = InspectorUtils.getUsedFontFaces(rng); 40 is(fonts.length, 1, "number of fonts (2)"); 41 f = fonts[0]; 42 is(f.name, "Gentium Plus", "font name (2)"); 43 44 // the Chinese text "ni hao" should NOT be in Gentium 45 rng.setStart(elem, 6); 46 rng.setEnd(elem, 8); // two Chinese characters on second line 47 fonts = InspectorUtils.getUsedFontFaces(rng); 48 is(fonts.length, 1, "number of fonts (3)"); 49 f = fonts[0]; 50 isnot(f.name, "Gentium Plus", "font name (3)"); 51 52 // space and "world" should be Gentium again 53 rng.setStart(elem, 8); 54 rng.setEnd(elem, 14); 55 fonts = InspectorUtils.getUsedFontFaces(rng); 56 is(fonts.length, 1, "number of fonts (4)"); 57 f = fonts[0]; 58 is(f.name, "Gentium Plus", "font name (4)"); 59 60 SimpleTest.finish(); 61 } 62 ]]> 63 </script> 64 65 <style type="text/css"> 66 </style> 67 68 <body xmlns="http://www.w3.org/1999/xhtml"> 69 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=695639" 70 target="_blank">Mozilla Bug 695639</a> 71 <div style="width: 2em;" class="test" id="test">Hello 你好 world</div> 72 </body> 73 74 </window>