summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_insertHTML_starting_with_multiple_comment_nodes.html
blob: c3b440659f7b904921f3eb5f63651432df87da11 (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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Insert HTML containing comment nodes</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script>
"use strict";

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(() => {
  const editor = document.querySelector("div[contenteditable]");
  getSelection().collapse(editor.querySelector("li").firstChild, 1);
  document.execCommand("insertHTML", false, "<!-- 1 --><!-- 2 -->b");
  is(
    editor.innerHTML,
    "<ul><li>a<!-- 1 --><!-- 2 -->bc</li></ul>",
    "The HTML fragment should be inserted as-is"
  );
  document.execCommand("undo");
  is(
    editor.innerHTML,
    "<ul><li>ac</li></ul>",
    "Undoing should work as expected"
  );
  document.execCommand("redo");
  is(
    editor.innerHTML,
    "<ul><li>a<!-- 1 --><!-- 2 -->bc</li></ul>",
    "Redoing should work as expected"
  );
  SimpleTest.finish();
});
</script>
</head>
<body>
<div contenteditable><ul><li>ac</li></ul></div>
</body>
</html>