summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html')
-rw-r--r--testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html109
1 files changed, 109 insertions, 0 deletions
diff --git a/testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html b/testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html
new file mode 100644
index 0000000000..c61bcff9e9
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/undo-insertparagraph-after-moving-split-nodes.html
@@ -0,0 +1,109 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<meta name="timeout" content="long">
+<title>Undo after splitting nodes are moved</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+</head>
+<body>
+<div contenteditable></div>
+<script>
+"use strict";
+
+document.execCommand("defaultParagraphSeparator", false, "div");
+const utils =
+ new EditorTestUtils(document.querySelector("div[contenteditable]"));
+
+promise_test(async t => {
+ utils.setupEditingHost(
+ `<div>abc[]def</div><p>ghi</p>`
+ );
+ await utils.sendEnterKey();
+ const right = utils.editingHost.querySelector("div + div");
+ utils.editingHost.appendChild(right);
+ // Now, the right <div> is after the <p>, it should be merged into the left
+ // <div> before the <p>.
+ document.execCommand("undo");
+ assert_in_array(
+ utils.editingHost.innerHTML,
+ [
+ "<div>abcdef</div><p>ghi</p>",
+ "<div>abcdef<br></div><p>ghi</p>",
+ ]
+ );
+}, "Undo insertParagraph after moving right node to different paragraph");
+
+promise_test(async () => {
+ utils.setupEditingHost(
+ `<p>abc</p><div>def[]ghi</div>`
+ );
+ await utils.sendEnterKey();
+ const left = utils.editingHost.querySelector("div");
+ utils.editingHost.insertBefore(left, document.querySelector("p"));
+ // Now, the left <div> is before the <p>, the right <div> after the <p> should
+ // be merged into it.
+ document.execCommand("undo");
+ assert_in_array(
+ utils.editingHost.innerHTML,
+ [
+ "<div>defghi</div><p>abc</p>",
+ "<div>defghi<br></div><p>abc</p>",
+ ]
+ );
+}, "Undo insertParagraph after moving left node to different paragraph");
+
+promise_test(async () => {
+ utils.setupEditingHost(
+ `<div>abc[]def</div>`
+ );
+ await utils.sendEnterKey();
+ const left = utils.editingHost.querySelector("div");
+ const right = utils.editingHost.querySelector("div + div");
+ left.insertBefore(right, left.firstChild);
+ // Now, the right <div> is a child node of the left <div>. Its children
+ // should be merged to the parent.
+ document.execCommand("undo");
+ assert_in_array(
+ utils.editingHost.innerHTML,
+ [
+ "<div>abcdef</div>",
+ "<div>abcdef<br></div>",
+ ]
+ );
+}, "Undo insertParagraph after moving right node into the left node");
+
+promise_test(async () => {
+ utils.setupEditingHost(
+ `<div>abc[]def</div>`
+ );
+ await utils.sendEnterKey();
+ const left = utils.editingHost.querySelector("div");
+ const right = utils.editingHost.querySelector("div + div");
+ right.appendChild(left);
+ // Now, the right <div> is parent of the left <div>. The children of the
+ // right <div> should be moved to the child left <div>, but the right <div>
+ // should be removed.
+ document.execCommand("undo");
+ assert_equals(
+ utils.editingHost.innerHTML,
+ "",
+ "The right <div> containing the left <div> should be removed"
+ );
+ assert_in_array(
+ left.innerHTML,
+ [
+ "abcdef",
+ "abcdef<br>",
+ ],
+ "The left <div> which was disconnected should have the original content"
+ );
+}, "Undo insertParagraph after moving left node into the right node");
+</script>
+</body>
+</html>