tor-browser

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

test_bug578771.html (2148B)


      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 file,
      4   - You can obtain one at http://mozilla.org/MPL/2.0/.  -->
      5 <html>
      6 <!--
      7 https://bugzilla.mozilla.org/show_bug.cgi?id=578771
      8 -->
      9 
     10 <head>
     11  <title>Test for Bug 578771</title>
     12  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     13  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     14  <script src="/tests/SimpleTest/EventUtils.js"></script>  
     15 </head>
     16 
     17 <body>
     18  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=578771">Mozilla Bug 578771</a>
     19  <p id="display"></p>
     20  <div id="content" style="display: none">
     21  </div>
     22 
     23  <pre id="test">
     24    <script type="application/javascript">
     25 
     26      /** Test for Bug 578771 */
     27      SimpleTest.waitForExplicitFinish();
     28 
     29      function testElem(elem, elemTag) {
     30        var ce = document.getElementById("ce");
     31        ce.focus();
     32 
     33        synthesizeMouse(elem, 5, 5, {clickCount: 2 });
     34        is(elem.selectionStart, 0, `${elemTag} selectionStart after double-click`);
     35        is(elem.selectionEnd, 7, `${elemTag} selectionEnd after double-click`);
     36 
     37        ce.focus();
     38        synthesizeMouse(elem, 5, 5, {clickCount: 3 });
     39        is(elem.selectionStart, 0, `${elemTag} selectionStart after triple-click`);
     40        is(elem.selectionEnd, 14, `${elemTag} selectionEnd after triple-click`);
     41      }
     42      // Avoid platform selection differences
     43      SimpleTest.waitForFocus(function() {
     44         SpecialPowers.pushPrefEnv({"set": [["layout.word_select.eat_space_to_next_word", false]]}, startTest);
     45      });
     46 
     47      function startTest() {
     48         var input = document.getElementById("ip");
     49         testElem(input, "input");
     50 
     51         var textarea = document.getElementById("ta");
     52         testElem(textarea, "textarea");
     53 
     54         SimpleTest.finish();
     55      }
     56   </script>
     57  </pre>
     58 
     59  <input id="ip" type="text" value="Mozilla editor" />
     60  <textarea id="ta">Mozilla editor</textarea>
     61  <div id="ce" contenteditable="true">Contenteditable div that could interfere with focus</div>
     62 </body>
     63 </html>