tor-browser

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

test_cmd_paragraphState.html (1854B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title>Testing "cmd_paragraphState" behavior</title>
      6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <div contenteditable></div>
     11 <script>
     12 "use strict";
     13 
     14 SimpleTest.waitForExplicitFinish();
     15 SimpleTest.waitForFocus(() => {
     16  const editor = document.querySelector("div[contenteditable]");
     17 
     18  editor.innerHTML = "<div><p>abc</p></div>";
     19  editor.focus();
     20  getSelection().collapse(editor.querySelector("p").firstChild, 1);
     21  editor.getBoundingClientRect();
     22  SpecialPowers.doCommand(window, "cmd_paragraphState", "");
     23  is(
     24    editor.innerHTML,
     25    "<div>abc</div>",
     26    "cmd_paragraphState with empty string should remove the parent block element"
     27  );
     28 
     29  editor.innerHTML = "<div><div contenteditable=\"false\"><p contenteditable>abc</p></div></div>";
     30  editor.focus();
     31  getSelection().collapse(editor.querySelector("p").firstChild, 1);
     32  editor.getBoundingClientRect();
     33  SpecialPowers.doCommand(window, "cmd_paragraphState", "");
     34  is(
     35    editor.innerHTML,
     36    "<div><div contenteditable=\"false\"><p contenteditable=\"\">abc</p></div></div>",
     37    "cmd_paragraphState with empty string should not remove editing host"
     38  );
     39 
     40  editor.innerHTML = "<div><div contenteditable=\"false\"><p><span contenteditable>abc</span></p></div></div>";
     41  editor.focus();
     42  getSelection().collapse(editor.querySelector("span").firstChild, 1);
     43  editor.getBoundingClientRect();
     44  SpecialPowers.doCommand(window, "cmd_paragraphState", "");
     45  is(
     46    editor.innerHTML,
     47    "<div><div contenteditable=\"false\"><p><span contenteditable=\"\">abc</span></p></div></div>",
     48    "cmd_paragraphState with empty string should not remove parents of inline editing host"
     49  );
     50 
     51  SimpleTest.finish();
     52 });
     53 </script>
     54 </body>
     55 </html>