diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/editing/other/delete-in-last-list-item-when-parent-list-is-editing-host.html | |
parent | Initial commit. (diff) | |
download | firefox-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/delete-in-last-list-item-when-parent-list-is-editing-host.html')
-rw-r--r-- | testing/web-platform/tests/editing/other/delete-in-last-list-item-when-parent-list-is-editing-host.html | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/testing/web-platform/tests/editing/other/delete-in-last-list-item-when-parent-list-is-editing-host.html b/testing/web-platform/tests/editing/other/delete-in-last-list-item-when-parent-list-is-editing-host.html new file mode 100644 index 0000000000..7d15943935 --- /dev/null +++ b/testing/web-platform/tests/editing/other/delete-in-last-list-item-when-parent-list-is-editing-host.html @@ -0,0 +1,87 @@ +<!doctype html> +<html> +<head> +<meta charset="utf-8"> +<meta name="timeout" content="long"> +<meta name="variant" content="?list=ul&action=Backspace"> +<meta name="variant" content="?list=ul&action=Delete"> +<meta name="variant" content="?list=ol&action=Backspace"> +<meta name="variant" content="?list=ol&action=Delete"> +<title>Delete in last list item should not delete parent list if it's editing host</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> +<script> +"use strict"; + +const params = new URLSearchParams(location.search.substring(1)); +const backspace = params.get("action") == "Backspace"; +const list = params.get("list"); + +addEventListener("load", () => { + document.body.innerHTML =`<${list} contenteditable></${list}>`; + const editingHost = document.querySelector("[contenteditable]"); + const utils = new EditorTestUtils(editingHost); + + function addPromiseTest(aTest) { + promise_test(async () => { + editingHost.focus(); + utils.setupEditingHost(aTest.innerHTML); + await (backspace ? utils.sendBackspaceKey() : utils.sendDeleteKey()); + utils.normalizeStyleAttributeValues(); + if (Array.isArray(aTest.expectedResult)) { + assert_in_array(editingHost.innerHTML, aTest.expectedResult); + } else { + assert_equals(editingHost.innerHTML, aTest.expectedResult); + } + assert_equals( + document.body.childNodes.length, + 1, + `The editing host should be the only child of <body> (got: "${document.body.innerHTML}")` + ); + assert_equals( + document.body.firstChild, + editingHost, + `The editing host should be the only child of <body> (got: "${document.body.innerHTML}")` + ); + }, `${backspace ? "Backspace" : "Delete"} in "<${list} contenteditable>${aTest.innerHTML}</${list}>"`); + } + + addPromiseTest({ + innerHTML: "<li>{}</li>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); + addPromiseTest({ + innerHTML: "<li><ul><li>{}</li></ul></li>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); + addPromiseTest({ + innerHTML: "<li><ol><li>{}</li></ol></li>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); + // If only sub-list in the editing host list element, the sub-list should be + // replaced with a list item. + addPromiseTest({ + innerHTML: "<ul><li>{}</li></ul>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); + addPromiseTest({ + innerHTML: "<ol><li>{}</li></ol>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); + addPromiseTest({ + innerHTML: "<dl><dt>{}</dt></dl>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); + addPromiseTest({ + innerHTML: "<dl><dd>{}</dd></dl>", + expectedResult: ["<li></li>", "<li><br></li>"], + }); +}, {once:true}); +</script> +</head> +<body></body> +</html> |