mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 04:39:06 +00:00
LibWeb: Make FileReader fire progress event
Fixes wpt/FileAPI/reading-data-section/filereader_events.any.html :)
This commit is contained in:
parent
c0102aa818
commit
7a92b47a35
Notes:
github-actions[bot]
2024-10-15 06:43:27 +00:00
Author: https://github.com/justus2510
Commit: 7a92b47a35
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1805
3 changed files with 44 additions and 1 deletions
27
Tests/LibWeb/Text/input/FileAPI/filereader-events.html
Normal file
27
Tests/LibWeb/Text/input/FileAPI/filereader-events.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(async (done) => {
|
||||
let testsDone = 0;
|
||||
|
||||
const eventTestDone = (events, expect) => {
|
||||
println(events === expect ? "PASS" : "FAIL");
|
||||
if (++testsDone == 2) {
|
||||
done();
|
||||
}
|
||||
};
|
||||
|
||||
const runEventTest = (blob, expect) => {
|
||||
let reader = new FileReader();
|
||||
let events = "";
|
||||
reader.onloadstart = () => events += "loadstart";
|
||||
reader.onprogress = () => events += ", progress";
|
||||
reader.onload = () => events += ", load";
|
||||
reader.onloadend = () => { events += ", loadend"; eventTestDone(events, expect); };
|
||||
reader.readAsText(blob);
|
||||
};
|
||||
|
||||
runEventTest(new Blob(["someRandomData"]), "loadstart, progress, load, loadend");
|
||||
runEventTest(new Blob([]), "loadstart, load, loadend");
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue