layout/inspector/tests/chrome/test_bug695639.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial