tor-browser

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

move-paragraph-cross-editing-boundary.tentative.html (1201B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <link rel="author" title="Peng Zhou" href="mailto:zhoupeng.1996@bytedance.com">
      4 <link rel="help" href="https://github.com/w3c/selection-api/issues/173">
      5 <link rel="help" href="https://issues.chromium.org/issues/326554272">
      6 <title>Selection.modify(): move by paragraph cross editing boundary</title>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <div contenteditable style="width: 140px; font-size: 14px;">
     10  <p>P1</p>
     11  <p>
     12    Line 1: Hello World
     13    Line 2: <span contenteditable="false">Hello</span> <span id="end">World</span>
     14  </p>
     15 </div>
     16 <script>
     17 const selection = getSelection();
     18 const end = document.querySelector('#end');
     19 function runTest() {
     20  selection.collapse(end.childNodes[0], 5);
     21  selection.modify('move', 'backward', 'paragraph');
     22  assert_equals(selection.anchorNode.nodeValue, 'P1');
     23  assert_equals(selection.anchorOffset, 2);
     24 }
     25 
     26 test(() => {
     27  runTest();
     28 }, 'cross editing boundary');
     29 
     30 test(() => {
     31  const editable = document.querySelector('span[contenteditable=false]');
     32  editable.setAttribute('contenteditable', true);
     33  runTest();
     34 }, 'not cross editing boundary');
     35 </script>