summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_join_split_node_direction_change_command.html
blob: a68396b70054cfd509278d3a0d002c0b45576245 (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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
  let iframe = document.querySelector("iframe");
  async function resetIframe() {
    iframe?.remove();
    iframe = document.createElement("iframe");
    document.body.appendChild(iframe);
    iframe.srcdoc = "<body></body>";
    if (iframe.contentDocument?.readyState != "complete") {
      await new Promise(resolve => iframe.addEventListener("load", resolve, {once: true}));
    }
    iframe.contentWindow.focus();
  }

  await resetIframe();
  iframe.contentDocument.body.innerHTML = "<div contenteditable><br></div>";
  ok(
    iframe.contentDocument.queryCommandSupported("enableCompatibleJoinSplitDirection"),
    "command should be supported"
  );
  ok(
    iframe.contentDocument.queryCommandEnabled("enableCompatibleJoinSplitDirection"),
    "command should be enabled"
  );
  ok(
    iframe.contentDocument.queryCommandState("enableCompatibleJoinSplitDirection"),
    "command state should be true"
  );
  is(
    iframe.contentDocument.queryCommandValue("enableCompatibleJoinSplitDirection"),
    "",
    "command value should be empty string"
  );
  ok(
    !iframe.contentDocument.execCommand("enableCompatibleJoinSplitDirection", false, "false"),
    "command to disable it should return false"
  );
  ok(
    iframe.contentDocument.queryCommandState("enableCompatibleJoinSplitDirection"),
    "command state should be true even after executing the command to disable it"
  );

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