tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug480647.html (2950B)


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