tor-browser

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

test_input_number_l10n.html (2184B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=844744
      5 -->
      6 <head>
      7  <title>Test localization of number control input</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <script type="text/javascript" src="test_input_number_data.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12  <meta charset="UTF-8">
     13 </head>
     14 <body>
     15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=844744">Mozilla Bug 844744</a>
     16 <p id="display"></p>
     17 <div id="content">
     18  <input id="input" type="number" step="any">
     19 </div>
     20 <pre id="test">
     21 <script type="application/javascript">
     22 
     23 /**
     24 * Test for Bug 844744
     25 * This test checks that localized input that is typed into <input type=number>
     26 * is correctly handled.
     27 */
     28 SimpleTest.waitForExplicitFinish();
     29 
     30 SimpleTest.waitForFocus(function() {
     31  startTests();
     32  SimpleTest.finish();
     33 });
     34 
     35 var elem;
     36 
     37 function runTest(test) {
     38  elem.lang = test.langTag;
     39  elem.value = 0;
     40  elem.focus();
     41  elem.select();
     42  sendString(test.inputWithGrouping);
     43  is(elem.value, "", "Test " + test.desc + " ('" + test.langTag +
     44                     "') localization with grouping separator");
     45  elem.value = 0;
     46  elem.select();
     47  sendString(test.inputWithoutGrouping);
     48  is(elem.valueAsNumber, test.value, "Test " + test.desc + " ('" + test.langTag +
     49                                     "') localization without grouping separator");
     50  is(elem.value, String(test.value), "Test " + test.desc + " ('" + test.langTag +
     51                                     "') localization without grouping separator as string");
     52 }
     53 
     54 function runInvalidInputTest(test) {
     55  elem.lang = test.langTag;
     56  elem.value = 0;
     57  elem.focus();
     58  elem.select();
     59  sendString(test.input);
     60  is(elem.value, "", "Test " + test.desc + " ('" + test.langTag +
     61                             "') with invalid input: " + test.input);
     62 }
     63 
     64 function startTests() {
     65  elem = document.getElementById("input");
     66  for (var test of tests) {
     67    runTest(test, elem);
     68  }
     69  for (var test of invalidTests) {
     70    runInvalidInputTest(test, elem);
     71  }
     72 }
     73 
     74 </script>
     75 </pre>
     76 </body>
     77 </html>