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/inert/inert-inlines-around-selection-range-in-contenteditable.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/inert/inert-inlines-around-selection-range-in-contenteditable.html')
-rw-r--r-- | testing/web-platform/tests/inert/inert-inlines-around-selection-range-in-contenteditable.html | 190 |
1 files changed, 190 insertions, 0 deletions
diff --git a/testing/web-platform/tests/inert/inert-inlines-around-selection-range-in-contenteditable.html b/testing/web-platform/tests/inert/inert-inlines-around-selection-range-in-contenteditable.html new file mode 100644 index 0000000000..c22c798084 --- /dev/null +++ b/testing/web-platform/tests/inert/inert-inlines-around-selection-range-in-contenteditable.html @@ -0,0 +1,190 @@ +<!doctype html> +<html> +<head> +<meta charset="utf-8"> +<title>Delete editable range around elements having inert attribute</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../editing/include/editor-test-utils.js"></script> +<script> +document.addEventListener("DOMContentLoaded", () => { + const editingHost = document.querySelector("div[contenteditable]"); + const utils = new EditorTestUtils(editingHost); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, "<span inert>a[bc</span><span>de]f</span>"); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + !!editingHost.querySelector("span[inert]"), + true, + `${desc}: <span inert> should not be deleted` + ); + assert_equals( + editingHost.querySelector("span[inert]").textContent, + "def", + `${desc}: <span inert> content should not be deleted` + ); + assert_not_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should be deleted (but how to handle it is not tested here)` + ); + }, "<span>a[bc</span><span inert>de]f</span>"); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent-reverse" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name} (selection range direction is inverted)` + assert_equals( + !!editingHost.querySelector("span[inert]"), + true, + `${desc}: <span inert> should not be deleted` + ); + assert_equals( + editingHost.querySelector("span[inert]").textContent, + "def", + `${desc}: <span inert> content should not be deleted` + ); + assert_not_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should be deleted (but how to handle it is not tested here)` + ); + }, "<span inert>d[ef</span><span>ab]c</span>"); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent-reverse" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name} (selection range direction is inverted)` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, "<span>d[ef</span><span inert>ab]c</span>"); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals(editingHost.innerHTML, "af", `${desc}: <span inert> should be deleted`); + }, "a[bc<span inert>XYZ</span>de]f"); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert style="display:contents">a[bc</span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert style="display:contents">{abc</span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert><span style="display:contents">a[bc</span></span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert><span style="display:contents">{abc</span></span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert style="display:none">a[bc</span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert style="display:none">{abc</span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert><span style="display:none">a[bc</span></span><span>de]f</span>`); + + test(t => { + utils.setupEditingHost(t.name, { selection: "setBaseAndExtent" }); + const initialInnerHTML = editingHost.innerHTML; + document.execCommand("delete"); + const desc = `execCommand("delete") at ${t.name}` + assert_equals( + editingHost.innerHTML, + initialInnerHTML, + `${desc}: <span> content should not be deleted because anchor node of Selection is in the <span inert>` + ); + }, `<span inert><span style="display:none">{abc</span></span><span>de]f</span>`); +}); +</script> +</head> +<body> +<div contenteditable></div> +</body> +</html> |