script(webdriver): Element send keys append to the end of filelist if Multiple (#38407)

Step 8.6 of [Element Send
Keys](https://w3c.github.io/webdriver/#dfn-element-send-keys) remote
end's implementation.
> 6. Complete implementation specific steps equivalent to setting the
[selected files](https://w3c.github.io/webdriver/#dfn-selected-files) on
the [input](https://w3c.github.io/webdriver/#dfn-input) element. **If
multiple is true files are be appended to element's [selected
files](https://w3c.github.io/webdriver/#dfn-selected-files).**

Testing: `webdriver/tests/classic/element_send_keys/file_upload.py`
Fixes: https://github.com/servo/servo/issues/38190

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Co-authored-by: Euclid Ye <euclid.ye@huawei.com>
This commit is contained in:
Kenzie Raditya Tirtarahardja 2025-08-21 03:10:07 +08:00 committed by GitHub
parent 011b314478
commit a75f3fd09b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 6 deletions

View file

@ -31,6 +31,7 @@ use net_traits::filemanager_thread::{FileManagerResult, FileManagerThreadMsg};
use net_traits::{CoreResourceMsg, IpcSend};
use script_bindings::codegen::GenericBindings::CharacterDataBinding::CharacterDataMethods;
use script_bindings::codegen::GenericBindings::DocumentBinding::DocumentMethods;
use servo_config::pref;
use style::attr::AttrValue;
use style::selector_parser::PseudoElement;
use style::str::{split_commas, str_join};
@ -2293,6 +2294,21 @@ impl HTMLInputElement {
let target = self.upcast::<EventTarget>();
if self.Multiple() {
// When using WebDriver command element send keys,
// we are expected to append the files to the existing filelist.
if pref!(dom_testing_html_input_element_select_files_enabled) {
let filelist = self.filelist.get();
if let Some(filelist) = filelist {
for i in 0..filelist.Length() {
files.push(
filelist
.Item(i)
.expect("We should have iterate within filelist length"),
);
}
}
}
let opt_test_paths = opt_test_paths.map(|paths| {
paths
.iter()

View file

@ -1,10 +1,4 @@
[file_upload.py]
[test_multiple_files_send_twice]
expected: FAIL
[test_single_file_appends_with_multiple_attribute]
expected: FAIL
[test_strict_hidden]
expected: FAIL