tor-browser

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

move-paragraphboundary-cross-editing-boundary.tentative.html (998B)


      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/179">
      5 <link rel="help" href="https://issues.chromium.org/issues/41484126">
      6 <title>Selection.modify(): move by paragraphboundary cross editing boundary</title>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <div contenteditable>this <a contenteditable="false">link</a> after</div>
     10 <script>
     11 const selection = getSelection();
     12 const editable = document.querySelector('div');
     13 function runTest() {
     14  selection.collapse(editable.childNodes[2], 6);
     15  selection.modify('move', 'backward', 'paragraphboundary');
     16  assert_equals(selection.anchorNode.nodeValue, 'this ');
     17  assert_equals(selection.anchorOffset, 0);
     18 }
     19 
     20 test(() => {
     21  runTest();
     22 }, 'cross editing boundary');
     23 
     24 test(() => {
     25  editable.setAttribute('contenteditable', true);
     26  runTest();
     27 });
     28 </script>