test_bug745685.html (2834B)
1 <!doctype html> 2 <!-- 3 https://bugzilla.mozilla.org/show_bug.cgi?id=745685 4 --> 5 <title>Test for Bug 745685</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 8 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=745685">Mozilla Bug 745685</a> 9 <font>Test text</font> 10 <font size=1>1</font> 11 <font size=2>2</font> 12 <font size=3>3</font> 13 <font size=4>4</font> 14 <font size=5>5</font> 15 <font size=6>6</font> 16 <font size=7>7</font> 17 <script> 18 /** Test for Bug 745685 */ 19 20 var referenceSizes = {}; 21 for (var i = 1; i <= 7; i++) { 22 referenceSizes[i] = 23 getComputedStyle(document.querySelector('[size="' + i + '"]')) 24 .fontSize; 25 if (i > 1) { 26 isnot(referenceSizes[i], referenceSizes[i - 1], 27 "Sanity check: different <font size>s give different .fontSize"); 28 } 29 } 30 31 function testFontSize(input, expected) { 32 var font = document.querySelector("font"); 33 font.setAttribute("size", input); 34 is(font.getAttribute("size"), input, 35 "Setting doesn't round-trip (.getAttribute)"); 36 is(font.size, input, 37 "Setting doesn't round-trip (.size)"); 38 is(getComputedStyle(font).fontSize, referenceSizes[expected], 39 'Incorrect size for "' + input + '" : expected the same as ' + expected); 40 } 41 42 function testFontSizes(input, expected) { 43 testFontSize(input, expected); 44 // Leading whitespace 45 testFontSize(" " + input, expected); 46 testFontSize("\t" + input, expected); 47 testFontSize("\n" + input, expected); 48 testFontSize("\f" + input, expected); 49 testFontSize("\r" + input, expected); 50 // Trailing garbage 51 testFontSize(input + "abcd", expected); 52 testFontSize(input + ".5", expected); 53 testFontSize(input + "e2", expected); 54 } 55 56 // Parse error 57 testFontSizes("", 3); 58 59 // No sign 60 testFontSizes("0", 1); 61 testFontSizes("1", 1); 62 testFontSizes("2", 2); 63 testFontSizes("3", 3); 64 testFontSizes("4", 4); 65 testFontSizes("5", 5); 66 testFontSizes("6", 6); 67 testFontSizes("7", 7); 68 testFontSizes("8", 7); 69 testFontSizes("9", 7); 70 testFontSizes("10", 7); 71 testFontSizes("10000000000000000000000", 7); 72 73 // Minus sign 74 testFontSizes("-0", 3); 75 testFontSizes("-1", 2); 76 testFontSizes("-2", 1); 77 testFontSizes("-3", 1); 78 testFontSizes("-4", 1); 79 testFontSizes("-5", 1); 80 testFontSizes("-6", 1); 81 testFontSizes("-7", 1); 82 testFontSizes("-8", 1); 83 testFontSizes("-9", 1); 84 testFontSizes("-10", 1); 85 testFontSizes("-10000000000000000000000", 1); 86 87 // Plus sign 88 testFontSizes("+0", 3); 89 testFontSizes("+1", 4); 90 testFontSizes("+2", 5); 91 testFontSizes("+3", 6); 92 testFontSizes("+4", 7); 93 testFontSizes("+5", 7); 94 testFontSizes("+6", 7); 95 testFontSizes("+7", 7); 96 testFontSizes("+8", 7); 97 testFontSizes("+9", 7); 98 testFontSizes("+10", 7); 99 testFontSizes("+10000000000000000000000", 7); 100 101 // Non-HTML5 whitespace 102 testFontSize("\b1", 3); 103 testFontSize("\v1", 3); 104 testFontSize("\0u00a01", 3); 105 </script>