LibWeb: Reverse check for whether a FilesList index is supported

This fixes for..of iteration of a FilesList object.
This commit is contained in:
Timothy Flynn 2024-03-13 15:29:32 -04:00 committed by Andreas Kling
parent c2ef506b4a
commit 0cc8698a62
Notes: sideshowbarker 2024-07-17 10:05:47 +09:00
3 changed files with 18 additions and 7 deletions

View File

@ -1,7 +1,12 @@
Select file...file1 Select files...4 files selected. input1:
file1: Contents for file1
file1 (index iteration): Contents for file1
file1 (for..of iteration): Contents for file1
input2:
file1: Contents for file1
file2: Contents for file2
file3: Contents for file3
file4: Contents for file4
file1 (index iteration): Contents for file1
file2 (index iteration): Contents for file2
file3 (index iteration): Contents for file3
file4 (index iteration): Contents for file4
file1 (for..of iteration): Contents for file1
file2 (for..of iteration): Contents for file2
file3 (for..of iteration): Contents for file3
file4 (for..of iteration): Contents for file4

View File

@ -13,7 +13,13 @@
const file = input.files.item(i);
const text = await file.text();
println(`${file.name}: ${text}`);
println(`${file.name} (index iteration): ${text}`);
}
for (let file of input.files) {
const text = await file.text();
println(`${file.name} (for..of iteration): ${text}`);
}
resolve();

View File

@ -41,7 +41,7 @@ bool FileList::is_supported_property_index(u32 index) const
if (m_files.is_empty())
return false;
return m_files.size() < index;
return index < m_files.size();
}
WebIDL::ExceptionOr<JS::Value> FileList::item_value(size_t index) const