File: test_bug695639.xhtml

package info (click to toggle)
firefox 145.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,653,528 kB
  • sloc: cpp: 7,594,999; javascript: 6,459,658; ansic: 3,752,909; python: 1,403,455; xml: 629,809; asm: 438,679; java: 186,421; sh: 67,287; makefile: 19,169; objc: 13,086; perl: 12,982; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (74 lines) | stat: -rw-r--r-- 2,427 bytes parent folder | download | duplicates (30)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<?xml-stylesheet type="text/css" href="test_bug695639.css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=695639
-->
<window title="Mozilla Bug 695639"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        onload="RunTest();">
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
  <script type="application/javascript">
  <![CDATA[
  /** Test for Bug 695639 - check that GetFontFacesForText handles wrapped lines properly **/

SimpleTest.waitForExplicitFinish();

function RunTest() {
  var rng = document.createRange();
  var elem, fonts, f;

  elem = document.getElementById("test").childNodes[0];
  rng.setStart(elem, 0);
  rng.setEnd(elem, 14);
  fonts = InspectorUtils.getUsedFontFaces(rng);
  is(fonts.length, 2, "number of fonts used for entire text");

  // initial latin substring...
  rng.setStart(elem, 0);
  rng.setEnd(elem, 5); // "Hello"
  fonts = InspectorUtils.getUsedFontFaces(rng);
  is(fonts.length, 1, "number of fonts (1)");
  f = fonts[0];
  is(f.name, "Gentium Plus", "font name (1)");

  // the space (where the line wraps) should also be Gentium
  rng.setStart(elem, 5);
  rng.setEnd(elem, 6); // space
  fonts = InspectorUtils.getUsedFontFaces(rng);
  is(fonts.length, 1, "number of fonts (2)");
  f = fonts[0];
  is(f.name, "Gentium Plus", "font name (2)");

  // the Chinese text "ni hao" should NOT be in Gentium
  rng.setStart(elem, 6);
  rng.setEnd(elem, 8); // two Chinese characters on second line
  fonts = InspectorUtils.getUsedFontFaces(rng);
  is(fonts.length, 1, "number of fonts (3)");
  f = fonts[0];
  isnot(f.name, "Gentium Plus", "font name (3)");

  // space and "world" should be Gentium again
  rng.setStart(elem, 8);
  rng.setEnd(elem, 14);
  fonts = InspectorUtils.getUsedFontFaces(rng);
  is(fonts.length, 1, "number of fonts (4)");
  f = fonts[0];
  is(f.name, "Gentium Plus", "font name (4)");

  SimpleTest.finish();
}
  ]]>
  </script>

  <style type="text/css">
  </style>

  <body xmlns="http://www.w3.org/1999/xhtml">
  <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=695639"
     target="_blank">Mozilla Bug 695639</a>
  <div style="width: 2em;" class="test" id="test">Hello &#x4F60;&#x597D; world</div>
  </body>

</window>