tor-browser

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

move-by-word-with-symbol.html (2994B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <title>Include symbols while moving forward/backward by word</title>
      4 <script src=/resources/testharness.js></script>
      5 <script src=/resources/testharnessreport.js></script>
      6 <script src="/resources/testdriver.js"></script>
      7 <script src="/resources/testdriver-vendor.js"></script>
      8 <script src="/resources/testdriver-actions.js"></script>
      9 <script src="../editing/include/editor-test-utils.js"></script>
     10 
     11 <div contenteditable id="target">~>>>>>p+++</div>
     12 <textarea id="textareaTarget">$$$$q~~~</textarea>
     13 <input id="inputTarget" value="||||r=====">
     14 
     15 <script>
     16  const selection = getSelection();
     17  const textNode = document.getElementById("target").childNodes[0];
     18  const textareaNode = document.getElementById("textareaTarget");
     19  const inputNode = document.getElementById("inputTarget");
     20 
     21  test(() => {
     22    selection.collapse(textNode, 6); // Start just before 'p'
     23    selection.modify("move", "backward", "word");
     24    assert_equals(selection.focusNode, textNode);
     25    assert_equals(selection.focusOffset, 0, "Caret should move to the beginning");
     26  }, "Symbols should be included while moving backward by word");
     27 
     28  test(() => {
     29    selection.collapse(textNode, 7); // Start just after 'p'
     30    selection.modify("move", "forward", "word");
     31    assert_equals(selection.focusNode, textNode);
     32    assert_equals(selection.focusOffset, 10, "Caret should move to the end");
     33  }, "Symbols should be included while moving forward by word");
     34 
     35  promise_test(async () => {
     36    textareaNode.focus();
     37    textareaNode.setSelectionRange(4, 4); // Start just before 'q'
     38    const utils = new EditorTestUtils(textareaNode);
     39    await utils.sendMoveWordLeftKey();
     40    assert_equals(textareaNode.selectionStart, 0, "Caret should move to the beginning");
     41  }, "Symbols should be included while moving backward by word in textarea element");
     42 
     43  promise_test(async () => {
     44    textareaNode.focus();
     45    textareaNode.setSelectionRange(5, 5); // Start just after 'q'
     46    const utils = new EditorTestUtils(textareaNode);
     47    await utils.sendMoveWordRightKey();
     48    assert_equals(textareaNode.selectionStart, 8, "Caret should move to the end");
     49  }, "Symbols should be included while moving forward by word in textarea element");
     50 
     51  promise_test(async () => {
     52    inputNode.focus();
     53    inputNode.setSelectionRange(4, 4); // Start just before 'r'
     54    const utils = new EditorTestUtils(inputNode);
     55    await utils.sendMoveWordLeftKey();
     56    assert_equals(inputNode.selectionStart, 0, "Caret should move to the beginning");
     57  }, "Symbols should be included while moving backward by word in input element");
     58 
     59  promise_test(async () => {
     60    inputNode.focus();
     61    inputNode.setSelectionRange(5, 5); // Start just after 'r'
     62    const utils = new EditorTestUtils(inputNode);
     63    await utils.sendMoveWordRightKey();
     64    assert_equals(inputNode.selectionStart, 10, "Caret should move to the end");
     65  }, "Symbols should be included while moving forward by word in input element");
     66 
     67 </script>