-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Disclaimer: I might be wrong!
According to the spec, the loadend
event is synchronously fired right after the load
event is dispatched. This all happens inside a single "queue a task". This means that the load
and loadend
events should be fired in the same turn of the event loop. There is no separate "queue a task" for the dispatching of the loadend
event.
The WPT test for this does not agree however. It tests that the loadend
event is dispatched one turn of the event loop later (note the await point between eventWatcher.wait_for('load')
and eventWatcher.wait_for('loadend')
):
// wpt/FileAPI/reading-data-section/filereader_events.any.js
var reader = new FileReader();
var eventWatcher = new EventWatcher(t, reader, ['loadstart', 'progress', 'abort', 'error', 'load', 'loadend']);
reader.readAsText(new Blob(['a']));
await eventWatcher.wait_for('loadstart');
await eventWatcher.wait_for('progress');
await eventWatcher.wait_for('load');
await eventWatcher.wait_for('loadend');
The test that would agree with spec behaviour would be the following:
var reader = new FileReader();
var eventWatcher = new EventWatcher(t, reader, ['loadstart', 'progress', 'abort', 'error', 'load', 'loadend']);
reader.readAsText(new Blob(['a']));
await eventWatcher.wait_for('loadstart');
await eventWatcher.wait_for('progress');
await eventWatcher.wait_for(['load', 'loadend']);
All of Chrome, Firefox and Safari implement this according to the current WPT test: https://wpt.fyi/results/FileAPI/reading-data-section/filereader_events.any.html?label=master&label=experimental&product=chrome&product=firefox&product=safari&aligned
So my question: as all browsers agree to disagree here, should the spec be updated? Alternatively I can file issues with all vendors to get this aligned to spec (and correct the test).