LibWeb: Don't allow HTMLTextAreaElement
rows and cols to be set to 0
In this case we should fall back to the default value.
This commit is contained in:
parent
ae0c87c747
commit
aafc829e6d
Notes:
github-actions[bot]
2024-11-29 08:50:08 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/aafc829e6de Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2619 Reviewed-by: https://github.com/stelar7
4 changed files with 40 additions and 12 deletions
|
@ -299,16 +299,16 @@ unsigned HTMLTextAreaElement::cols() const
|
|||
return 20;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_cols(unsigned cols)
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_cols(WebIDL::UnsignedLong cols)
|
||||
{
|
||||
if (cols > 2147483647)
|
||||
if (cols == 0 || cols > 2147483647)
|
||||
cols = 20;
|
||||
|
||||
return set_attribute(HTML::AttributeNames::cols, String::number(cols));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-rows
|
||||
unsigned HTMLTextAreaElement::rows() const
|
||||
WebIDL::UnsignedLong HTMLTextAreaElement::rows() const
|
||||
{
|
||||
// The cols and rows attributes are limited to only positive numbers with fallback. The rows IDL attribute's default value is 2.
|
||||
if (auto rows_string = get_attribute(HTML::AttributeNames::rows); rows_string.has_value()) {
|
||||
|
@ -318,9 +318,9 @@ unsigned HTMLTextAreaElement::rows() const
|
|||
return 2;
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_rows(unsigned rows)
|
||||
WebIDL::ExceptionOr<void> HTMLTextAreaElement::set_rows(WebIDL::UnsignedLong rows)
|
||||
{
|
||||
if (rows > 2147483647)
|
||||
if (rows == 0 || rows > 2147483647)
|
||||
rows = 2;
|
||||
|
||||
return set_attribute(HTML::AttributeNames::rows, String::number(rows));
|
||||
|
|
|
@ -102,11 +102,11 @@ public:
|
|||
WebIDL::Long min_length() const;
|
||||
WebIDL::ExceptionOr<void> set_min_length(WebIDL::Long);
|
||||
|
||||
unsigned cols() const;
|
||||
WebIDL::UnsignedLong cols() const;
|
||||
WebIDL::ExceptionOr<void> set_cols(unsigned);
|
||||
|
||||
unsigned rows() const;
|
||||
WebIDL::ExceptionOr<void> set_rows(unsigned);
|
||||
WebIDL::UnsignedLong rows() const;
|
||||
WebIDL::ExceptionOr<void> set_rows(WebIDL::UnsignedLong);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-selectionstart
|
||||
WebIDL::UnsignedLong selection_start_binding() const;
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
img.getAttribute("hspace") after img.setAttribute("hspace", "0"): 0
|
||||
img.hspace after img.setAttribute("hspace", "0"): 0
|
||||
img.getAttribute("hspace") after img.hspace = 0: 0
|
||||
img.hspace after img.hspace = 0: 0
|
||||
img.getAttribute("hspace") after img.setAttribute("hspace", "1"): 1
|
||||
img.hspace after img.setAttribute("hspace", "1"): 1
|
||||
img.getAttribute("hspace") after img.hspace = 1: 1
|
||||
|
@ -14,6 +18,9 @@ img.getAttribute("hspace") after img.setAttribute("hspace", "4294967295"): 42949
|
|||
img.hspace after img.setAttribute("hspace", "4294967295"): 0
|
||||
img.getAttribute("hspace") after img.hspace = 4294967295: 0
|
||||
img.hspace after img.hspace = 4294967295: 0
|
||||
input.getAttribute("size") after input.setAttribute("size", "0"): 0
|
||||
input.size after input.setAttribute("size", "0"): 20
|
||||
input.size = 0 threw exception of type IndexSizeError
|
||||
input.getAttribute("size") after input.setAttribute("size", "1"): 1
|
||||
input.size after input.setAttribute("size", "1"): 1
|
||||
input.getAttribute("size") after input.size = 1: 1
|
||||
|
@ -30,6 +37,10 @@ input.getAttribute("size") after input.setAttribute("size", "4294967295"): 42949
|
|||
input.size after input.setAttribute("size", "4294967295"): 20
|
||||
input.getAttribute("size") after input.size = 4294967295: 20
|
||||
input.size after input.size = 4294967295: 20
|
||||
marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount", "0"): 0
|
||||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "0"): 0
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 0: 0
|
||||
marquee.scrollAmount after marquee.scrollAmount = 0: 0
|
||||
marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount", "1"): 1
|
||||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "1"): 1
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 1: 1
|
||||
|
@ -46,6 +57,10 @@ marquee.getAttribute("scrollamount") after marquee.setAttribute("scrollAmount",
|
|||
marquee.scrollAmount after marquee.setAttribute("scrollamount", "4294967295"): 6
|
||||
marquee.getAttribute("scrollamount") after marquee.scrollAmount = 4294967295: 6
|
||||
marquee.scrollAmount after marquee.scrollAmount = 4294967295: 6
|
||||
marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "0"): 0
|
||||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "0"): 0
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 0: 0
|
||||
marquee.scrollDelay after marquee.scrollDelay = 0: 0
|
||||
marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "1"): 1
|
||||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "1"): 1
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 1: 1
|
||||
|
@ -62,6 +77,10 @@ marquee.getAttribute("scrolldelay") after marquee.setAttribute("scrollDelay", "4
|
|||
marquee.scrollDelay after marquee.setAttribute("scrolldelay", "4294967295"): 85
|
||||
marquee.getAttribute("scrolldelay") after marquee.scrollDelay = 4294967295: 85
|
||||
marquee.scrollDelay after marquee.scrollDelay = 4294967295: 85
|
||||
textarea.getAttribute("rows") after textarea.setAttribute("rows", "0"): 0
|
||||
textarea.rows after textarea.setAttribute("rows", "0"): 2
|
||||
textarea.getAttribute("rows") after textarea.rows = 0: 2
|
||||
textarea.rows after textarea.rows = 0: 2
|
||||
textarea.getAttribute("rows") after textarea.setAttribute("rows", "1"): 1
|
||||
textarea.rows after textarea.setAttribute("rows", "1"): 1
|
||||
textarea.getAttribute("rows") after textarea.rows = 1: 1
|
||||
|
@ -78,6 +97,10 @@ textarea.getAttribute("rows") after textarea.setAttribute("rows", "4294967295"):
|
|||
textarea.rows after textarea.setAttribute("rows", "4294967295"): 2
|
||||
textarea.getAttribute("rows") after textarea.rows = 4294967295: 2
|
||||
textarea.rows after textarea.rows = 4294967295: 2
|
||||
textarea.getAttribute("cols") after textarea.setAttribute("cols", "0"): 0
|
||||
textarea.cols after textarea.setAttribute("cols", "0"): 20
|
||||
textarea.getAttribute("cols") after textarea.cols = 0: 20
|
||||
textarea.cols after textarea.cols = 0: 20
|
||||
textarea.getAttribute("cols") after textarea.setAttribute("cols", "1"): 1
|
||||
textarea.cols after textarea.setAttribute("cols", "1"): 1
|
||||
textarea.getAttribute("cols") after textarea.cols = 1: 1
|
||||
|
@ -93,4 +116,4 @@ textarea.cols after textarea.cols = 2147483648: 20
|
|||
textarea.getAttribute("cols") after textarea.setAttribute("cols", "4294967295"): 4294967295
|
||||
textarea.cols after textarea.setAttribute("cols", "4294967295"): 20
|
||||
textarea.getAttribute("cols") after textarea.cols = 4294967295: 20
|
||||
textarea.cols after textarea.cols = 4294967295: 20
|
||||
textarea.cols after textarea.cols = 4294967295: 20
|
|
@ -11,11 +11,16 @@
|
|||
println(`${elementName}.${propertyName} after ${elementName}.setAttribute("${attributeName}", "${value}"): ${propertyGetter(element)}`);
|
||||
|
||||
element = document.createElement(elementName);
|
||||
propertySetter(element, value);
|
||||
println(`${elementName}.getAttribute("${attributeName}") after ${elementName}.${propertyName} = ${value}: ${element.getAttribute(attributeName)}`);
|
||||
println(`${elementName}.${propertyName} after ${elementName}.${propertyName} = ${value}: ${propertyGetter(element)}`);
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue