Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | <!DOCTYPE html> |
michael@0 | 2 | <!-- |
michael@0 | 3 | https://bugzilla.mozilla.org/show_bug.cgi?id=480647 |
michael@0 | 4 | --> |
michael@0 | 5 | <title>Test for Bug 480647</title> |
michael@0 | 6 | <script src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 7 | <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> |
michael@0 | 8 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=480647">Mozilla Bug 480647</a> |
michael@0 | 9 | <div contenteditable></div> |
michael@0 | 10 | <script> |
michael@0 | 11 | /** Test for Bug 480647 **/ |
michael@0 | 12 | |
michael@0 | 13 | var div = document.querySelector("div"); |
michael@0 | 14 | |
michael@0 | 15 | function parseFontSize(input, expected) { |
michael@0 | 16 | parseFontSizeInner(input, expected, is); |
michael@0 | 17 | } |
michael@0 | 18 | |
michael@0 | 19 | function parseFontSizeTodo(input, expected) { |
michael@0 | 20 | parseFontSizeInner(input, expected, todo_is); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function parseFontSizeInner(input, expected, fn) { |
michael@0 | 24 | div.innerHTML = "foo"; |
michael@0 | 25 | getSelection().selectAllChildren(div); |
michael@0 | 26 | document.execCommand("fontSize", false, input); |
michael@0 | 27 | if (expected === null) { |
michael@0 | 28 | fn(div.innerHTML, "foo", |
michael@0 | 29 | 'execCommand("fontSize", false, "' + input + '") should be no-op'); |
michael@0 | 30 | } else { |
michael@0 | 31 | fn(div.innerHTML, '<font size="' + expected + '">foo</font>', |
michael@0 | 32 | 'execCommand("fontSize", false, "' + input + '") should parse to ' + |
michael@0 | 33 | expected); |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | // Parse errors |
michael@0 | 38 | parseFontSize("", null); |
michael@0 | 39 | parseFontSize("abc", null); |
michael@0 | 40 | parseFontSize("larger", null); |
michael@0 | 41 | parseFontSize("smaller", null); |
michael@0 | 42 | parseFontSize("xx-small", null); |
michael@0 | 43 | parseFontSize("x-small", null); |
michael@0 | 44 | parseFontSize("small", null); |
michael@0 | 45 | parseFontSize("medium", null); |
michael@0 | 46 | parseFontSize("large", null); |
michael@0 | 47 | parseFontSize("x-large", null); |
michael@0 | 48 | parseFontSize("xx-large", null); |
michael@0 | 49 | parseFontSize("xxx-large", null); |
michael@0 | 50 | // Bug 747879 |
michael@0 | 51 | parseFontSizeTodo("1.2em", null); |
michael@0 | 52 | parseFontSizeTodo("8px", null); |
michael@0 | 53 | parseFontSizeTodo("-1.2em", null); |
michael@0 | 54 | parseFontSizeTodo("-8px", null); |
michael@0 | 55 | parseFontSizeTodo("+1.2em", null); |
michael@0 | 56 | parseFontSizeTodo("+8px", null); |
michael@0 | 57 | |
michael@0 | 58 | // Numbers |
michael@0 | 59 | parseFontSize("0", 1); |
michael@0 | 60 | parseFontSize("1", 1); |
michael@0 | 61 | parseFontSize("2", 2); |
michael@0 | 62 | parseFontSize("3", 3); |
michael@0 | 63 | parseFontSize("4", 4); |
michael@0 | 64 | parseFontSize("5", 5); |
michael@0 | 65 | parseFontSize("6", 6); |
michael@0 | 66 | parseFontSize("7", 7); |
michael@0 | 67 | parseFontSize("8", 7); |
michael@0 | 68 | parseFontSize("9", 7); |
michael@0 | 69 | parseFontSize("10", 7); |
michael@0 | 70 | parseFontSize("1000000000000000000000", 7); |
michael@0 | 71 | parseFontSize("2.72", 2); |
michael@0 | 72 | parseFontSize("2.72e9", 2); |
michael@0 | 73 | |
michael@0 | 74 | // Minus sign |
michael@0 | 75 | parseFontSize("-0", 3); |
michael@0 | 76 | parseFontSize("-1", 2); |
michael@0 | 77 | parseFontSize("-2", 1); |
michael@0 | 78 | parseFontSize("-3", 1); |
michael@0 | 79 | parseFontSize("-4", 1); |
michael@0 | 80 | parseFontSize("-5", 1); |
michael@0 | 81 | parseFontSize("-6", 1); |
michael@0 | 82 | parseFontSize("-7", 1); |
michael@0 | 83 | parseFontSize("-8", 1); |
michael@0 | 84 | parseFontSize("-9", 1); |
michael@0 | 85 | parseFontSize("-10", 1); |
michael@0 | 86 | parseFontSize("-1000000000000000000000", 1); |
michael@0 | 87 | parseFontSize("-1.72", 2); |
michael@0 | 88 | parseFontSize("-1.72e9", 2); |
michael@0 | 89 | |
michael@0 | 90 | // Plus sign |
michael@0 | 91 | parseFontSize("+0", 3); |
michael@0 | 92 | parseFontSize("+1", 4); |
michael@0 | 93 | parseFontSize("+2", 5); |
michael@0 | 94 | parseFontSize("+3", 6); |
michael@0 | 95 | parseFontSize("+4", 7); |
michael@0 | 96 | parseFontSize("+5", 7); |
michael@0 | 97 | parseFontSize("+6", 7); |
michael@0 | 98 | parseFontSize("+7", 7); |
michael@0 | 99 | parseFontSize("+8", 7); |
michael@0 | 100 | parseFontSize("+9", 7); |
michael@0 | 101 | parseFontSize("+10", 7); |
michael@0 | 102 | parseFontSize("+1000000000000000000000", 7); |
michael@0 | 103 | parseFontSize("+1.72", 4); |
michael@0 | 104 | parseFontSize("+1.72e9", 4); |
michael@0 | 105 | |
michael@0 | 106 | // Whitespace |
michael@0 | 107 | parseFontSize(" \t\n\r\f5 \t\n\r\f", 5); |
michael@0 | 108 | parseFontSize("\u00a05", null); |
michael@0 | 109 | parseFontSize("\b5", null); |
michael@0 | 110 | </script> |