mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:27:35 +00:00
Ladybird+LibWeb+WebContent: Parse the <input type=file> accept attribute
This parses the accept attribute value for file input types and passes it along to the browser chromes.
This commit is contained in:
parent
e4213f5767
commit
6760d236e4
20 changed files with 267 additions and 24 deletions
12
Tests/LibWeb/Text/expected/input-file-accept.txt
Normal file
12
Tests/LibWeb/Text/expected/input-file-accept.txt
Normal file
|
@ -0,0 +1,12 @@
|
|||
Select file...file1 Select files...4 files selected. Select file...file1.cpp Select files...2 files selected. input1:
|
||||
file1: text/plain: Contents for file1
|
||||
input2:
|
||||
file1: text/plain: Contents for file1
|
||||
file2: text/plain: Contents for file2
|
||||
file3: text/plain: Contents for file3
|
||||
file4: text/plain: Contents for file4
|
||||
input3:
|
||||
file1.cpp: text/plain: int main() {{ return 1; }}
|
||||
input4:
|
||||
file1.cpp: text/plain: int main() {{ return 1; }}
|
||||
file2.cpp: text/plain: int main() {{ return 2; }}
|
34
Tests/LibWeb/Text/input/input-file-accept.html
Normal file
34
Tests/LibWeb/Text/input/input-file-accept.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
<input id="input1" type="file" accept="text/plain" />
|
||||
<input id="input2" type="file" accept="text/plain" multiple />
|
||||
<input id="input3" type="file" accept=".cpp" />
|
||||
<input id="input4" type="file" accept=".cpp" multiple />
|
||||
<script src="./include.js"></script>
|
||||
<script type="text/javascript">
|
||||
const runTest = async id => {
|
||||
let input = document.getElementById(id);
|
||||
|
||||
return new Promise(resolve => {
|
||||
input.addEventListener("input", async () => {
|
||||
println(`${id}:`);
|
||||
|
||||
for (let file of input.files) {
|
||||
const text = await file.text();
|
||||
println(`${file.name}: ${file.type}: ${text}`);
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
|
||||
internals.dispatchUserActivatedEvent(input, new Event("mousedown"));
|
||||
input.showPicker();
|
||||
});
|
||||
};
|
||||
|
||||
asyncTest(async done => {
|
||||
await runTest("input1");
|
||||
await runTest("input2");
|
||||
await runTest("input3");
|
||||
await runTest("input4");
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue