layout/generic/test/test_bug904810.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=904810
     5 -->
     6 <head>
     7   <title>Test for Bug 904810</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=904810">Mozilla Bug 904810</a>
    14 <p id="display">
    15 <textarea dir="ltr" id="textarea904810">
    16 first line
    17 second line
    18 third line
    19 </textarea></p>
    20 <div id="content" style="display: none">
    22 </div>
    23 <pre id="test">
    24 <script type="application/javascript">
    26 /** Test for Bug 904810 **/
    28 SimpleTest.waitForExplicitFinish();
    29 SimpleTest.waitForFocus(function test() {
    30   function shiftLeft(i) {
    31     for ( ; i > 0; --i)
    32       synthesizeKey("VK_LEFT", {shiftKey:true});
    33   }
    35   function shiftRight(i) {
    36     for ( ; i > 0; --i)
    37       synthesizeKey("VK_RIGHT", {shiftKey:true});
    38   }
    40   const isWindows = /WINNT/.test(SpecialPowers.OS);
    42   var textarea = document.getElementById('textarea904810');
    43   textarea.focus();
    45   // Testing VK_DOWN with forward selection
    46   textarea.selectionStart = 1;
    47   textarea.selectionEnd = 1;
    48   shiftRight(7);
    49   synthesizeKey("VK_DOWN", {});
    50   if (isWindows) {
    51     is(textarea.selectionStart, 19, "caret moved to next line below selection end");
    52     is(textarea.selectionEnd, 19, "caret moved to next line below selection end");
    53   } else {
    54     is(textarea.selectionStart, 8, "caret moved to visual end of selection");
    55     is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
    56   }
    58   // Testing VK_DOWN with backward selection
    59   textarea.selectionStart = 8;
    60   textarea.selectionEnd = 8;
    61   shiftLeft(7);
    62   synthesizeKey("VK_DOWN", {});
    63   if (isWindows) {
    64     is(textarea.selectionStart, 12, "caret moved to next line below selection start");
    65     is(textarea.selectionEnd, 12, "caret moved to next line below selection start");
    66   } else {
    67     is(textarea.selectionStart, 8, "caret moved to visual end of selection");
    68     is(textarea.selectionEnd, 8, "caret moved to visual end of selection");
    69   }
    71   // Testing VK_UP with forward selection
    72   textarea.selectionStart = 12;
    73   textarea.selectionEnd = 12;
    74   shiftRight(7);
    75   synthesizeKey("VK_UP", {});
    76   var result = textarea.selectionEnd
    77   if (isWindows) {
    78     is(textarea.selectionStart, 8, "caret moved to previous line above selection end");
    79     is(textarea.selectionEnd, 8, "caret moved to previous line above selection end");
    80   } else {
    81     is(textarea.selectionStart, 12, "caret moved to visual start of selection");
    82     is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
    83   }
    85   // Testing VK_UP with backward selection
    86   textarea.selectionStart = 19;
    87   textarea.selectionEnd = 19;
    88   shiftLeft(7);
    89   synthesizeKey("VK_UP", {});
    90   var result = textarea.selectionEnd
    91   if (isWindows) {
    92     is(textarea.selectionStart, 1, "caret moved to previous line above selection start");
    93     is(textarea.selectionEnd, 1, "caret moved to previous line above selection start");
    94   } else {
    95     is(textarea.selectionStart, 12, "caret moved to visual start of selection");
    96     is(textarea.selectionEnd, 12, "caret moved to visual start of selection");
    97   }
   101   SimpleTest.finish();
   102 });
   107 </script>
   108 </pre>
   109 </body>
   110 </html>

mercurial