summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/editing/other/extra-text-nodes.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/editing/other/extra-text-nodes.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/editing/other/extra-text-nodes.html')
-rw-r--r--testing/web-platform/tests/editing/other/extra-text-nodes.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/testing/web-platform/tests/editing/other/extra-text-nodes.html b/testing/web-platform/tests/editing/other/extra-text-nodes.html
new file mode 100644
index 0000000000..2cd1232d00
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/extra-text-nodes.html
@@ -0,0 +1,43 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Editor should not create unnecessary text nodes</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div contenteditable></div>
+<script>
+var div = document.querySelector("div");
+var walker = document.createTreeWalker(div, NodeFilter.SHOW_TEXT);
+function testInput(html, callback, desc) {
+ test(() => {
+ div.innerHTML = html;
+ div.focus();
+ callback();
+
+ walker.currentNode = walker.root;
+ var node;
+ while (node = walker.nextNode()) {
+ if (node.nextSibling) {
+ assert_not_equals(node.nextSibling.nodeType, Node.TEXT_NODE,
+ 'text node "' + node.nodeValue + '" is next to "' +
+ node.nextSibling.nodeValue + '"');
+ }
+ }
+ }, desc);
+}
+
+[
+ ['<img src="#">foo<img src="#">',
+ () => {
+ getSelection().collapse(div, 1);
+ document.execCommand("inserttext", false, "x");
+ },
+ "Simple insertText"],
+ ['<p>editor</p>',
+ () => {
+ getSelection().collapse(div.firstChild.firstChild, 3);
+ document.execCommand("insertlinebreak", false, "");
+ document.execCommand("inserttext", false, "x");
+ },
+ "insertText after insertLineBreak"],
+].forEach(([a, b, c]) => testInput(a, b, c));
+</script>