mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
LibWeb: Fix empty value attribute for 'file' input returning fakepath
It should be returning the empty string for this case.
This commit is contained in:
parent
c03e025a32
commit
fc4fd6cb02
3 changed files with 11 additions and 1 deletions
1
Tests/LibWeb/Text/expected/input-element-file-value.txt
Normal file
1
Tests/LibWeb/Text/expected/input-element-file-value.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
value = ''
|
8
Tests/LibWeb/Text/input/input-element-file-value.html
Normal file
8
Tests/LibWeb/Text/input/input-element-file-value.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<script src="include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const input = document.createElement("input");
|
||||||
|
input.type = 'file';
|
||||||
|
println(`value = '${input.value}'`);
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -304,9 +304,10 @@ DeprecatedString HTMLInputElement::value() const
|
||||||
if (type_state() == TypeAttributeState::FileUpload) {
|
if (type_state() == TypeAttributeState::FileUpload) {
|
||||||
// NOTE: This "fakepath" requirement is a sad accident of history. See the example in the File Upload state section for more information.
|
// NOTE: This "fakepath" requirement is a sad accident of history. See the example in the File Upload state section for more information.
|
||||||
// NOTE: Since path components are not permitted in filenames in the list of selected files, the "\fakepath\" cannot be mistaken for a path component.
|
// NOTE: Since path components are not permitted in filenames in the list of selected files, the "\fakepath\" cannot be mistaken for a path component.
|
||||||
|
// On getting, return the string "C:\fakepath\" followed by the name of the first file in the list of selected files, if any, or the empty string if the list is empty.
|
||||||
if (m_selected_files && m_selected_files->item(0))
|
if (m_selected_files && m_selected_files->item(0))
|
||||||
return DeprecatedString::formatted("C:\\fakepath\\{}", m_selected_files->item(0)->name());
|
return DeprecatedString::formatted("C:\\fakepath\\{}", m_selected_files->item(0)->name());
|
||||||
return "C:\\fakepath\\"sv;
|
return DeprecatedString::empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue