Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!DOCTYPE HTML>
2 <html lang="en">
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=394057
5 -->
6 <head>
7 <title>Test for Bug 394057</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 <style type="text/css">
12 #display { background: yellow; color: black; font-family: serif; }
14 </style>
15 </head>
16 <body>
17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=394057">Mozilla Bug 394057</a>
18 <table id="display"><tr><td>MmMmMm...iiiIIIlll---</td></tr></table>
19 <div id="content" style="display: none">
21 </div>
22 <pre id="test">
23 <script class="testbody" type="text/javascript">
25 /** Test for Bug 394057 **/
27 SimpleTest.waitForExplicitFinish();
29 var tableElement = document.getElementById("display");
31 var CC = SpecialPowers.Cc;
32 var CI = SpecialPowers.Ci;
34 var fe =
35 CC["@mozilla.org/gfx/fontenumerator;1"].createInstance(CI.nsIFontEnumerator);
36 var serifFonts = fe.EnumerateFonts("x-western", "serif", {});
37 var monospaceFonts = fe.EnumerateFonts("x-western", "monospace", {});
39 function table_width_for_font(font) {
40 tableElement.style.fontFamily = '"' + font + '"';
41 var result = tableElement.offsetWidth;
42 tableElement.style.fontFamily = "";
43 return result;
44 }
46 var serifIdx = 0;
47 var monospaceIdx = 0;
48 var monospaceWidth, serifWidth;
49 monospaceWidth = table_width_for_font(monospaceFonts[monospaceIdx]);
50 for (serifIdx in serifFonts) {
51 serifWidth = table_width_for_font(serifFonts[serifIdx]);
52 if (serifWidth != monospaceWidth)
53 break;
54 }
55 if (serifWidth == monospaceWidth) {
56 for (monospaceIdx in monospaceFonts) {
57 monospaceWidth = table_width_for_font(monospaceFonts[monospaceIdx]);
58 if (serifWidth != monospaceWidth)
59 break;
60 }
61 }
63 isnot(serifWidth, monospaceWidth,
64 "can't find serif and monospace fonts of different width");
66 SpecialPowers.pushPrefEnv({'set': [['font.name.serif.x-western', serifFonts[serifIdx]]]}, step2);
68 var serifWidthFromPref;
69 function step2() {
70 serifWidthFromPref = tableElement.offsetWidth;
71 SpecialPowers.pushPrefEnv({'set': [['font.name.serif.x-western', monospaceFonts[monospaceIdx]]]}, step3);
72 }
73 var monospaceWidthFromPref;
74 function step3() {
75 monospaceWidthFromPref = tableElement.offsetWidth;
77 is(serifWidthFromPref, serifWidth,
78 "changing font pref should change width of table (serif)");
79 is(monospaceWidthFromPref, monospaceWidth,
80 "changing font pref should change width of table (monospace)");
81 SimpleTest.finish();
82 }
84 </script>
85 </pre>
86 </body>
87 </html>