1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/base/tests/test_bug394057.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html lang="en"> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=394057 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 394057</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + <style type="text/css"> 1.14 + 1.15 + #display { background: yellow; color: black; font-family: serif; } 1.16 + 1.17 + </style> 1.18 +</head> 1.19 +<body> 1.20 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=394057">Mozilla Bug 394057</a> 1.21 +<table id="display"><tr><td>MmMmMm...iiiIIIlll---</td></tr></table> 1.22 +<div id="content" style="display: none"> 1.23 + 1.24 +</div> 1.25 +<pre id="test"> 1.26 +<script class="testbody" type="text/javascript"> 1.27 + 1.28 +/** Test for Bug 394057 **/ 1.29 + 1.30 +SimpleTest.waitForExplicitFinish(); 1.31 + 1.32 +var tableElement = document.getElementById("display"); 1.33 + 1.34 +var CC = SpecialPowers.Cc; 1.35 +var CI = SpecialPowers.Ci; 1.36 + 1.37 +var fe = 1.38 + CC["@mozilla.org/gfx/fontenumerator;1"].createInstance(CI.nsIFontEnumerator); 1.39 +var serifFonts = fe.EnumerateFonts("x-western", "serif", {}); 1.40 +var monospaceFonts = fe.EnumerateFonts("x-western", "monospace", {}); 1.41 + 1.42 +function table_width_for_font(font) { 1.43 + tableElement.style.fontFamily = '"' + font + '"'; 1.44 + var result = tableElement.offsetWidth; 1.45 + tableElement.style.fontFamily = ""; 1.46 + return result; 1.47 +} 1.48 + 1.49 +var serifIdx = 0; 1.50 +var monospaceIdx = 0; 1.51 +var monospaceWidth, serifWidth; 1.52 +monospaceWidth = table_width_for_font(monospaceFonts[monospaceIdx]); 1.53 +for (serifIdx in serifFonts) { 1.54 + serifWidth = table_width_for_font(serifFonts[serifIdx]); 1.55 + if (serifWidth != monospaceWidth) 1.56 + break; 1.57 +} 1.58 +if (serifWidth == monospaceWidth) { 1.59 + for (monospaceIdx in monospaceFonts) { 1.60 + monospaceWidth = table_width_for_font(monospaceFonts[monospaceIdx]); 1.61 + if (serifWidth != monospaceWidth) 1.62 + break; 1.63 + } 1.64 +} 1.65 + 1.66 +isnot(serifWidth, monospaceWidth, 1.67 + "can't find serif and monospace fonts of different width"); 1.68 + 1.69 +SpecialPowers.pushPrefEnv({'set': [['font.name.serif.x-western', serifFonts[serifIdx]]]}, step2); 1.70 + 1.71 +var serifWidthFromPref; 1.72 +function step2() { 1.73 + serifWidthFromPref = tableElement.offsetWidth; 1.74 + SpecialPowers.pushPrefEnv({'set': [['font.name.serif.x-western', monospaceFonts[monospaceIdx]]]}, step3); 1.75 +} 1.76 +var monospaceWidthFromPref; 1.77 +function step3() { 1.78 + monospaceWidthFromPref = tableElement.offsetWidth; 1.79 + 1.80 + is(serifWidthFromPref, serifWidth, 1.81 + "changing font pref should change width of table (serif)"); 1.82 + is(monospaceWidthFromPref, monospaceWidth, 1.83 + "changing font pref should change width of table (monospace)"); 1.84 + SimpleTest.finish(); 1.85 +} 1.86 + 1.87 +</script> 1.88 +</pre> 1.89 +</body> 1.90 +</html> 1.91 +