tor-browser

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

test_bug370436.html (2695B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4  https://bugzilla.mozilla.org/show_bug.cgi?id=370436
      5 -->
      6 <head>
      7  <title>Test for Bug 370436</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11 </head>
     12 <body>
     13 
     14 <script class="testbody" type="application/javascript">
     15 words = new Array()
     16 
     17 function expandStringOffsetToWord(data, offset)
     18 {
     19  if (data == undefined) return "";
     20 
     21  var m1 = data.substr(0, offset).match(/\w+$/) || "";
     22  var m2 = data.substr(offset).match(/^\w+/) || "";
     23  return m1 + m2;
     24 }
     25 
     26 function onContextMenu(e)
     27 {
     28  var node = SpecialPowers.wrap(e).rangeParent;
     29  var offset = e.rangeOffset;
     30 
     31  var word = expandStringOffsetToWord(node.data, offset);
     32  words.push(word);
     33 }
     34 
     35 function startTest()
     36 {
     37  var ta = document.getElementById('blah');
     38  ta.focus();
     39  ta.selectionStart = ta.selectionEnd = ta.value.length;
     40 
     41  // Note: This test, intentionally or by accident, relies on sending button '0'
     42  // with contextMenu, which triggers some key-equiv stuff in
     43  // PresShell::AdjustContextMenuKeyEvent.
     44  var mouseParams = { type: 'contextmenu', button: 0 };
     45 
     46  /* Put cursor at start and middle of "sheep" */
     47  synthesizeKey("KEY_ArrowUp")
     48  synthesizeMouse(ta, 0, 0, mouseParams);
     49  synthesizeKey("KEY_ArrowRight")
     50  synthesizeMouse(ta, 0, 0, mouseParams);
     51  synthesizeKey("KEY_ArrowRight")
     52  synthesizeMouse(ta, 0, 0, mouseParams);
     53 
     54  /* Put cursor at the end of "hello" */
     55  synthesizeKey("KEY_ArrowUp")
     56  synthesizeMouse(ta, 0, 0, mouseParams);
     57  synthesizeKey("KEY_ArrowRight")
     58  synthesizeKey("KEY_ArrowRight")
     59  synthesizeKey("KEY_ArrowRight")
     60  synthesizeMouse(ta, 0, 0, mouseParams);
     61  synthesizeKey("KEY_ArrowRight")
     62  synthesizeMouse(ta, 0, 0, mouseParams);
     63 
     64  /* Put cursor on "welcome" */
     65  synthesizeKey("KEY_ArrowUp")
     66  synthesizeMouse(ta, 0, 0, mouseParams);
     67 
     68  is(words.pop(), "welcome", "Word 1 selected correctly");
     69  is(words.pop(), "world"  , "Word 2 selected correctly");
     70  is(words.pop(), "hello"  , "Word 3 selected correctly");
     71  is(words.pop(), "hello"  , "Word 4 selected correctly");
     72  is(words.pop(), "sheep"  , "Word 5 selected correctly");
     73  is(words.pop(), "sheep"  , "Word 6 selected correctly");
     74  is(words.pop(), "sheep"  , "Word 7 selected correctly");
     75 
     76  SimpleTest.finish();
     77 }
     78 
     79 SimpleTest.waitForExplicitFinish()
     80 SimpleTest.waitForFocus(startTest)
     81 </script>
     82 
     83 <p><a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=370436">Mozilla Bug 370436</a></p>
     84 
     85 <textarea id="blah" rows="10" cols="80" oncontextmenu="onContextMenu(event); return false;">
     86 welcome
     87 hello world
     88 sheep
     89 </textarea>
     90 </body>
     91 </html>