tor-browser

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

test_bug830600.html (2991B)


      1 <!DOCTYPE HTML>
      2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
      3   - License, v. 2.0. If a copy of the MPL was not distributed with this
      4   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
      5 <html>
      6 <!--
      7 https://bugzilla.mozilla.org/show_bug.cgi?id=830600
      8 -->
      9 <head>
     10  <title>Test for Bug 830600</title>
     11  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     12  <script src="/tests/SimpleTest/EventUtils.js"></script>
     13  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
     14 </head>
     15 
     16 <body>
     17  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=830600">Mozilla Bug 830600</a>
     18  <p id="display"></p>
     19  <div id="content" style="display: none">
     20  </div>
     21  <input type="text" id="t1" />
     22  <pre id="test">
     23    <script type="application/javascript">
     24 
     25      /** Test for Bug 830600 */
     26      SimpleTest.waitForExplicitFinish();
     27      SimpleTest.waitForFocus(function() {
     28        const Ci = SpecialPowers.Ci;
     29        function test(str, expected, callback) {
     30          var t = document.getElementById("t1");
     31          t.focus();
     32          t.value = "";
     33          var editor = SpecialPowers.wrap(t).editor;
     34          editor.newlineHandling = Ci.nsIEditor.eNewlinesStripSurroundingWhitespace;
     35          SimpleTest.waitForClipboard(str,
     36            function() {
     37              SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]
     38                        .getService(Ci.nsIClipboardHelper)
     39                        .copyString(str);
     40            },
     41            function() {
     42              synthesizeKey("V", {accelKey: true});
     43              is(t.value, expected, "New line handling works correctly");
     44              t.value = "";
     45              callback();
     46            },
     47            function() {
     48              ok(false, "Failed to copy the string");
     49              SimpleTest.finish();
     50            }
     51          );
     52        }
     53 
     54        function runNextTest() {
     55          if (tests.length) {
     56            var currentTest = tests.shift();
     57            test(currentTest[0], currentTest[1], runNextTest);
     58          } else {
     59            SimpleTest.finish();
     60          }
     61        }
     62 
     63        var tests = [
     64          ["abc", "abc"],
     65          ["\n", ""],
     66          [" \n", ""],
     67          ["\n ", ""],
     68          [" \n ", ""],
     69          [" a", " a"],
     70          ["a ", "a "],
     71          [" a ", " a "],
     72          [" \nabc", "abc"],
     73          ["\n abc", "abc"],
     74          [" \n abc", "abc"],
     75          [" \nabc ", "abc "],
     76          ["\n abc ", "abc "],
     77          [" \n abc ", "abc "],
     78          ["abc\n ", "abc"],
     79          ["abc \n", "abc"],
     80          ["abc \n ", "abc"],
     81          [" abc\n ", " abc"],
     82          [" abc \n", " abc"],
     83          [" abc \n ", " abc"],
     84          [" abc  \n  def \n ", " abcdef"],
     85          ["\n abc  \n  def \n ", "abcdef"],
     86          [" \n abc  \n  def ", "abcdef "],
     87          [" abc\n\ndef ", " abcdef "],
     88          [" abc \n\n def ", " abcdef "],
     89        ];
     90 
     91        runNextTest();
     92      });
     93 
     94   </script>
     95  </pre>
     96 </body>
     97 </html>