summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_inlineTableEditing.html
blob: 411b5f65101d05a2a123575dfc30cf298096dd59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div contenteditable></div>
<pre id="test">

<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
  const editableInnerHTML =
`<table>
  <tr><td>ABCDEFG</td><td>HIJKLMN</td></tr>
  <tr><td>ABCDEFG</td><td>HIJKLMN</td></tr>
  <tr><td>ABCDEFG</td><td>HIJKLMN</td></tr>
</table>`;

  document.execCommand("enableObjectResizing", false, "false");
  document.execCommand("enableInlineTableEditing", false, "true");

  function doTest(aDescription, aTable) {
    synthesizeMouseAtCenter(aTable, {});
    isnot(
      aTable.getAttribute("_moz_resizing"),
      "true",
      `${aDescription}: _moz_resizing attribute shouldn't be true without object resizing`
    );

    const tr2 = aTable.querySelector("tr + tr");
    synthesizeMouse(tr2, 0, tr2.clientHeight / 2, {});
    ok(
      !tr2.isConnected,
      `${aDescription}: The second <tr> element should've been removed by a click`
    );
  }

  const editingHost = document.querySelector("div[contenteditable]");
  editingHost.innerHTML = editableInnerHTML;
  doTest("Testing in Light DOM", editingHost.querySelector("table"));

  editingHost.remove();

  const shadowHost = document.createElement("div");
  document.body.insertBefore(shadowHost, document.body.firstChild);
  const shadowRoot = shadowHost.attachShadow({mode: "open"});
  shadowRoot.appendChild(document.createElement("div"));
  shadowRoot.firstChild.setAttribute("contenteditable", "");
  shadowRoot.firstChild.innerHTML = editableInnerHTML;
  doTest("Testing in Shadow DOM", shadowRoot.firstChild.querySelector("table"));

  shadowHost.remove();

  SimpleTest.finish();
});
</script>
</pre>
</body>
</html>