tor-browser

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

test_editing_UI_in_plaintext-only.html (3010B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4 <meta charset="utf-8">
      5 <title></title>
      6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7 <script src="/tests/SimpleTest/EventUtils.js"></script>
      8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      9 <script>
     10 "use strict";
     11 
     12 SimpleTest.waitForExplicitFinish();
     13 SimpleTest.waitForFocus(async () => {
     14  function waitForTick() {
     15    return new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
     16  }
     17  await (async () => {
     18    const editingHost = document.getElementById("testAbs");
     19    editingHost.contentEditable = "plaintext-only";
     20    editingHost.focus();
     21    document.execCommand("enableAbsolutePositionEditing", false, "true");
     22    const target = editingHost.querySelector("div[style]");
     23    synthesizeMouseAtCenter(target, {});
     24    await waitForTick();
     25    is(
     26      getHTMLEditor().isAbsolutePositioningActive,
     27      false,
     28      "The absolutely positioned element positioner UI should not be visible"
     29    );
     30    document.execCommand("enableAbsolutePositionEditing", false, "false");
     31    editingHost.remove();
     32    await waitForTick();
     33  })();
     34  await (async () => {
     35    const editingHost = document.getElementById("testTable");
     36    editingHost.contentEditable = "plaintext-only";
     37    editingHost.focus();
     38    document.execCommand("enableInlineTableEditing", false, "true");
     39    const target = editingHost.querySelector("td");
     40    synthesizeMouseAtCenter(target, {});
     41    await waitForTick();
     42    is(
     43      getHTMLEditor().isInlineTableEditingActive,
     44      false,
     45      "The inline table editing UI should not be visible"
     46    );
     47    document.execCommand("enableInlineTableEditing", false, "false");
     48    editingHost.remove();
     49    await waitForTick();
     50  })();
     51  await (async () => {
     52    const editingHost = document.getElementById("testResizer");
     53    editingHost.contentEditable = "plaintext-only";
     54    editingHost.focus();
     55    document.execCommand("enableObjectResizing", false, "true");
     56    const target = editingHost.querySelector("img");
     57    synthesizeMouseAtCenter(target, {});
     58    await waitForTick();
     59    is(
     60      getHTMLEditor().isObjectResizingActive,
     61      false,
     62      "The image resizer UI should not be visible"
     63    );
     64    document.execCommand("enableObjectResizing", false, "false");
     65    editingHost.remove();
     66    await waitForTick();
     67  })();
     68  SimpleTest.finish();
     69 });
     70 
     71 function getHTMLEditor() {
     72  const Ci = SpecialPowers.Ci;
     73  const editingSession = SpecialPowers.wrap(window).docShell.editingSession;
     74  return editingSession.getEditorForWindow(window)
     75    .QueryInterface(Ci.nsIHTMLAbsPosEditor)
     76    .QueryInterface(Ci.nsIHTMLInlineTableEditor)
     77    .QueryInterface(Ci.nsIHTMLObjectResizer);
     78 }
     79 </script>
     80 </head>
     81 <body>
     82 <div id="testAbs" style="position: absolute; width: 150px; height: 150px">
     83  <div style="position: absolute; width: 100px; height: 100px"><br></div>
     84 </div>
     85 <div id="testTable">
     86  <table><td><br></td></table>
     87 </div>
     88 <div id="testResizer">
     89  <img src="green.png">
     90 </div>
     91 </body>
     92 </html>