ladybird/Tests/LibWeb/Text/input/Editing/execCommand-is-a-noop.html
Andrew Kaster 5d2a36f244 LibWeb: Stub out all the functions from the execCommand spec
Per the specification, it's ok if we say that nothing is supported.

It's not ok if we say something is supported but do nothing, apparently.
2024-02-16 19:31:54 -05:00

32 lines
1.3 KiB
HTML

<script src="../include.js"></script>
<div id="text" contenteditable="true"></div>
<script>
test(() => {
let text = document.getElementById("text");
text.focus();
let hello = text.appendChild(document.createTextNode("Hello, world!"));
let boldText = document.createTextNode("I'm totally bold rn");
let boldTag = text.appendChild(document.createElement("b"));
boldTag.appendChild(boldText);
// select the text
let range = document.createRange();
range.selectNodeContents(hello);
let selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
let e = document.execCommand("bold", false, "on");
println(`execCommand("bold") returned ${e}`);
let allTheText = text.innerHTML;
println(allTheText);
println(`queryCommandEnabled("bold") returned ${document.queryCommandEnabled("bold")}`);
println(`queryCommandIndeterm("bold") returned ${document.queryCommandIndeterm("bold")}`);
println(`queryCommandState("bold") returned ${document.queryCommandState("bold")}`);
println(`queryCommandSupported("bold") returned ${document.queryCommandSupported("bold")}`);
println(`queryCommandValue("bold") returned "${document.queryCommandValue("bold")}"`);
});
</script>