mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
d6297ec074
Previously, we always cast to a HTMLInputElement when getting the value of an auto directionality form associated element. This caused undefined behavior when determining the directionality of an element that wasn't a HTMLInputElement.
53 lines
1.8 KiB
HTML
53 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<style>
|
|
.test {
|
|
font-size: 12px;
|
|
}
|
|
</style>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
function testSelectorMatch(input, selector) {
|
|
println(`Input matches ${selector}: ${input.matches(selector)}`);
|
|
}
|
|
|
|
function testElementDirectionality(element) {
|
|
element.value = "Well hello friends!"
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
|
|
element.dir = "invalid";
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
|
|
element.dir = "rtl";
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
|
|
element.dir = "auto"
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
|
|
element.value = "حسنًا ، مرحباً أيها الأصدقاء";
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
|
|
element.dir = "ltr"
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
|
|
element.removeAttribute("dir");
|
|
testSelectorMatch(element, ":dir(ltr)");
|
|
testSelectorMatch(element, ":dir(rtl)");
|
|
}
|
|
|
|
println("Testing input element with type=text");
|
|
const textInput = document.createElement("input");
|
|
textInput.type = "text";
|
|
testElementDirectionality(textInput);
|
|
|
|
println("Testing textarea element");
|
|
const textAreaElement = document.createElement("textarea");
|
|
testElementDirectionality(textAreaElement);
|
|
});
|
|
</script>
|