1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

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.
This commit is contained in:
Andrew Kaster 2024-02-15 16:47:29 -07:00 committed by Tim Flynn
parent f5266e0096
commit 5d2a36f244
5 changed files with 91 additions and 10 deletions

View file

@ -0,0 +1,32 @@
<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>