diff --git a/Libraries/LibWeb/HTML/DOMStringList.cpp b/Libraries/LibWeb/HTML/DOMStringList.cpp index 036f5174eb6..4e69f6b1fe4 100644 --- a/Libraries/LibWeb/HTML/DOMStringList.cpp +++ b/Libraries/LibWeb/HTML/DOMStringList.cpp @@ -43,7 +43,7 @@ Optional DOMStringList::item(u32 index) const { // The item(index) method steps are to return the indexth item in this's associated list, or null if index plus one // is greater than this's associated list's size. - if (index + 1 > m_list.size()) + if (index >= m_list.size()) return {}; return m_list.at(index); @@ -58,7 +58,7 @@ bool DOMStringList::contains(StringView string) Optional DOMStringList::item_value(size_t index) const { - if (index + 1 > m_list.size()) + if (index >= m_list.size()) return {}; return JS::PrimitiveString::create(vm(), m_list.at(index)); diff --git a/Tests/LibWeb/Text/expected/wpt-import/html/infrastructure/common-dom-interfaces/collections/domstringlist.txt b/Tests/LibWeb/Text/expected/wpt-import/html/infrastructure/common-dom-interfaces/collections/domstringlist.txt new file mode 100644 index 00000000000..ecce788eebf --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/html/infrastructure/common-dom-interfaces/collections/domstringlist.txt @@ -0,0 +1,9 @@ +Harness status: OK + +Found 4 tests + +4 Pass +Pass DOMStringList: length attribute +Pass DOMStringList: item() method +Pass DOMStringList: indexed getter +Pass DOMStringList: contains() method \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/html/infrastructure/common-dom-interfaces/collections/domstringlist.html b/Tests/LibWeb/Text/input/wpt-import/html/infrastructure/common-dom-interfaces/collections/domstringlist.html new file mode 100644 index 00000000000..b426a13c331 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/html/infrastructure/common-dom-interfaces/collections/domstringlist.html @@ -0,0 +1,61 @@ + +DOMStringList + + +