mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-20 09:21:55 +00:00
LibWeb: Cast to the correct type in Element::auto_directionality()
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.
This commit is contained in:
parent
0b0ad5c9db
commit
d6297ec074
Notes:
sideshowbarker
2024-07-16 23:52:22 +09:00
Author: https://github.com/tcl3
Commit: d6297ec074
Pull-request: https://github.com/SerenityOS/serenity/pull/24472
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/trflynn89
5 changed files with 86 additions and 59 deletions
|
@ -0,0 +1,53 @@
|
|||
<!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>
|
Loading…
Add table
Add a link
Reference in a new issue