ladybird/Tests/LibWeb/Text/input/HTML/unsigned-long-reflection.html
Tim Ledbetter 45a2823e08 LibWeb: Implement the HTMLInputElement.width attribute
This allows the width of an image button input to be set and queried.
2024-11-30 11:01:33 +01:00

54 lines
2.9 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
test(() => {
function testProperty(elementNameOrFactory, propertyName, propertyGetter, propertySetter) {
const attributeName = propertyName.toLowerCase();
function setValue(value) {
let element;
let elementName;
if (typeof elementNameOrFactory === "string") {
element = document.createElement(elementNameOrFactory);
elementName = elementNameOrFactory;
} else {
element = elementNameOrFactory();
elementName = element.tagName.toLowerCase();
}
element.setAttribute(attributeName, value.toString());
println(`${elementName}.getAttribute("${attributeName}") after ${elementName}.setAttribute("${propertyName}", "${value}"): ${element.getAttribute(`${attributeName}`)}`);
println(`${elementName}.${propertyName} after ${elementName}.setAttribute("${attributeName}", "${value}"): ${propertyGetter(element)}`);
element = document.createElement(elementName);
try {
propertySetter(element, value);
println(`${elementName}.getAttribute("${attributeName}") after ${elementName}.${propertyName} = ${value}: ${element.getAttribute(attributeName)}`);
println(`${elementName}.${propertyName} after ${elementName}.${propertyName} = ${value}: ${propertyGetter(element)}`);
} catch (e) {
println(`${elementName}.${propertyName} = ${value} threw exception of type ${e.name}`);
}
}
setValue(0);
setValue(1);
setValue(2147483647);
setValue(2147483648);
setValue(4294967295);
}
const imageButtonInputFactory = () => {
const input = document.createElement("input");
input.type = "image";
return input;
}
testProperty("img", "hspace", (img) => img.hspace, (img, value) => img.hspace = value);
testProperty("input", "size", (input) => input.size, (input, value) => input.size = value);
testProperty(imageButtonInputFactory, "width", (input) => input.width, (input, value) => input.width = value);
testProperty("marquee", "scrollAmount", (marquee) => marquee.scrollAmount, (marquee, value) => marquee.scrollAmount = value);
testProperty("marquee", "scrollDelay", (marquee) => marquee.scrollDelay, (marquee, value) => marquee.scrollDelay = value);
testProperty("select", "size", (select) => select.size, (select, value) => select.size = value);
testProperty("textarea", "rows", (textarea) => textarea.rows, (textarea, value) => textarea.rows = value);
testProperty("textarea", "cols", (textarea) => textarea.cols, (textarea, value) => textarea.cols = value);
});
</script>