1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/editor/libeditor/html/tests/test_bug480647.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,110 @@ 1.4 +<!DOCTYPE html> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=480647 1.7 +--> 1.8 +<title>Test for Bug 480647</title> 1.9 +<script src="/tests/SimpleTest/SimpleTest.js"></script> 1.10 +<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 1.11 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=480647">Mozilla Bug 480647</a> 1.12 +<div contenteditable></div> 1.13 +<script> 1.14 +/** Test for Bug 480647 **/ 1.15 + 1.16 +var div = document.querySelector("div"); 1.17 + 1.18 +function parseFontSize(input, expected) { 1.19 + parseFontSizeInner(input, expected, is); 1.20 +} 1.21 + 1.22 +function parseFontSizeTodo(input, expected) { 1.23 + parseFontSizeInner(input, expected, todo_is); 1.24 +} 1.25 + 1.26 +function parseFontSizeInner(input, expected, fn) { 1.27 + div.innerHTML = "foo"; 1.28 + getSelection().selectAllChildren(div); 1.29 + document.execCommand("fontSize", false, input); 1.30 + if (expected === null) { 1.31 + fn(div.innerHTML, "foo", 1.32 + 'execCommand("fontSize", false, "' + input + '") should be no-op'); 1.33 + } else { 1.34 + fn(div.innerHTML, '<font size="' + expected + '">foo</font>', 1.35 + 'execCommand("fontSize", false, "' + input + '") should parse to ' + 1.36 + expected); 1.37 + } 1.38 +} 1.39 + 1.40 +// Parse errors 1.41 +parseFontSize("", null); 1.42 +parseFontSize("abc", null); 1.43 +parseFontSize("larger", null); 1.44 +parseFontSize("smaller", null); 1.45 +parseFontSize("xx-small", null); 1.46 +parseFontSize("x-small", null); 1.47 +parseFontSize("small", null); 1.48 +parseFontSize("medium", null); 1.49 +parseFontSize("large", null); 1.50 +parseFontSize("x-large", null); 1.51 +parseFontSize("xx-large", null); 1.52 +parseFontSize("xxx-large", null); 1.53 +// Bug 747879 1.54 +parseFontSizeTodo("1.2em", null); 1.55 +parseFontSizeTodo("8px", null); 1.56 +parseFontSizeTodo("-1.2em", null); 1.57 +parseFontSizeTodo("-8px", null); 1.58 +parseFontSizeTodo("+1.2em", null); 1.59 +parseFontSizeTodo("+8px", null); 1.60 + 1.61 +// Numbers 1.62 +parseFontSize("0", 1); 1.63 +parseFontSize("1", 1); 1.64 +parseFontSize("2", 2); 1.65 +parseFontSize("3", 3); 1.66 +parseFontSize("4", 4); 1.67 +parseFontSize("5", 5); 1.68 +parseFontSize("6", 6); 1.69 +parseFontSize("7", 7); 1.70 +parseFontSize("8", 7); 1.71 +parseFontSize("9", 7); 1.72 +parseFontSize("10", 7); 1.73 +parseFontSize("1000000000000000000000", 7); 1.74 +parseFontSize("2.72", 2); 1.75 +parseFontSize("2.72e9", 2); 1.76 + 1.77 +// Minus sign 1.78 +parseFontSize("-0", 3); 1.79 +parseFontSize("-1", 2); 1.80 +parseFontSize("-2", 1); 1.81 +parseFontSize("-3", 1); 1.82 +parseFontSize("-4", 1); 1.83 +parseFontSize("-5", 1); 1.84 +parseFontSize("-6", 1); 1.85 +parseFontSize("-7", 1); 1.86 +parseFontSize("-8", 1); 1.87 +parseFontSize("-9", 1); 1.88 +parseFontSize("-10", 1); 1.89 +parseFontSize("-1000000000000000000000", 1); 1.90 +parseFontSize("-1.72", 2); 1.91 +parseFontSize("-1.72e9", 2); 1.92 + 1.93 +// Plus sign 1.94 +parseFontSize("+0", 3); 1.95 +parseFontSize("+1", 4); 1.96 +parseFontSize("+2", 5); 1.97 +parseFontSize("+3", 6); 1.98 +parseFontSize("+4", 7); 1.99 +parseFontSize("+5", 7); 1.100 +parseFontSize("+6", 7); 1.101 +parseFontSize("+7", 7); 1.102 +parseFontSize("+8", 7); 1.103 +parseFontSize("+9", 7); 1.104 +parseFontSize("+10", 7); 1.105 +parseFontSize("+1000000000000000000000", 7); 1.106 +parseFontSize("+1.72", 4); 1.107 +parseFontSize("+1.72e9", 4); 1.108 + 1.109 +// Whitespace 1.110 +parseFontSize(" \t\n\r\f5 \t\n\r\f", 5); 1.111 +parseFontSize("\u00a05", null); 1.112 +parseFontSize("\b5", null); 1.113 +</script>