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/removing-inline-style-specified-by-parent-block.tentative.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/removing-inline-style-specified-by-parent-block.tentative.html')
-rw-r--r-- | testing/web-platform/tests/editing/other/removing-inline-style-specified-by-parent-block.tentative.html | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/testing/web-platform/tests/editing/other/removing-inline-style-specified-by-parent-block.tentative.html b/testing/web-platform/tests/editing/other/removing-inline-style-specified-by-parent-block.tentative.html new file mode 100644 index 0000000000..c799819a38 --- /dev/null +++ b/testing/web-platform/tests/editing/other/removing-inline-style-specified-by-parent-block.tentative.html @@ -0,0 +1,125 @@ +<!doctype html> +<html> +<meta charset=utf-8> +<meta name="variant" content="?b"> +<meta name="variant" content="?i"> +<meta name="variant" content="?u"> +<title>Test removing inline style which is specified by parent block</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<body> +<div contenteditable></div> +</body> +<script> +"use strict"; + +const tag = location.search.substring(1); +const style = (() => { + switch (tag) { + case "b": + return "font-weight: bold"; + case "i": + return "font-style: italic"; + case "u": + return "text-decoration: underline"; + } +})(); +const cancelingStyle = (() => { + switch (tag) { + case "b": + return "font-weight: normal"; + case "i": + return "font-style: normal"; + case "u": + return ""; // Cannot delete parent underline + } +})(); +const command = (() => { + switch (tag) { + case "b": + return "bold"; + case "i": + return "italic"; + case "u": + return "underline"; + } +})(); +const editor = document.querySelector("div[contenteditable]"); + +promise_test(async () => { + await new Promise(resolve => { + addEventListener("load", () => { + assert_true(true, "The document is loaded"); + resolve(); + }, { once: true }); + }); +}, "Waiting for load..."); + +promise_test(async () => { + document.execCommand("styleWithCSS", false, "false"); + editor.innerHTML = `<p style="${style}">foo</p>`; + editor.focus(); + getSelection().selectAllChildren(editor.querySelector("p")); + document.execCommand(command); + assert_in_array( + editor.innerHTML, + [ + "<p>foo</p>", + "<p>foo<br></p>", + "<p style=\"\">foo</p>", + "<p style=\"\">foo<br></p>", + ]); +}, "Disabling style to text, it's applied to the parent block"); + +promise_test(async () => { + document.execCommand("styleWithCSS", false, "false"); + editor.innerHTML = `<p>foo</p>`; + editor.setAttribute("style", style); + editor.focus(); + getSelection().selectAllChildren(editor.querySelector("p")); + document.execCommand(command); + if (cancelingStyle !== "") { + assert_in_array( + editor.innerHTML, + [ + `<p><span style="${cancelingStyle};">foo</span></p>`, + `<p><span style="${cancelingStyle};">foo</span><br></p>`, + ]); + } else { + assert_in_array( + editor.innerHTML, + [ + "<p>foo</p>", + "<p>foo<br></p>", + ]); + } + assert_equals(editor.getAttribute("style"), style); + editor.removeAttribute("style"); +}, "Disabling style to text, it's applied to the editing host"); + +promise_test(async () => { + document.execCommand("styleWithCSS", false, "false"); + editor.innerHTML = `<p>foo</p>`; + document.body.setAttribute("style", style); + editor.focus(); + getSelection().selectAllChildren(editor.querySelector("p")); + document.execCommand(command); + if (cancelingStyle !== "") { + assert_in_array( + editor.innerHTML, + [ + `<p><span style="${cancelingStyle};">foo</span></p>`, + `<p><span style="${cancelingStyle};">foo</span><br></p>`, + ]); + } else { + assert_in_array( + editor.innerHTML, + [ + "<p>foo</p>", + "<p>foo<br></p>", + ]); + } + assert_equals(document.body.getAttribute("style"), style); + document.body.removeAttribute("style"); +}, "Disabling style to text, it's applied to the body"); +</script>
\ No newline at end of file |