Skip to content

XMLHttpRequest: load* + abort dispatched as Event, not ProgressEvent #2290

Description

@rexxars

Describe the bug

XMLHttpRequest dispatches loadstart, load, loadend and abort as plain Event instances. Per the specification, the send() algorithm fires all of these as ProgressEvent, so listeners can read event.loaded, event.total and event.lengthComputable. On happy-dom, those properties are undefined because the events are not ProgressEvent instances at all.

To Reproduce
Steps to reproduce the behavior:

  1. Create an XMLHttpRequest, open and send a request that returns a response with a Content-Length header.
  2. Add a load (or loadstart/loadend/abort) listener.
  3. Inspect the event received by the listener.
const xhr = new XMLHttpRequest();
xhr.addEventListener('load', (event) => {
  console.log(event instanceof ProgressEvent); // false, but should be true
  console.log(event.loaded, event.total); // undefined, undefined
});
xhr.open('GET', '/some-resource');
xhr.send();

https://stackblitz.com/edit/happy-dom-load-progress-events?file=index.js

Expected behavior

loadstart, load, loadend and abort should be dispatched as ProgressEvent instances, with loaded/total/lengthComputable populated the same way they are for the already-supported progress event (0/0/false for loadstart/abort, and the transferred/total byte counts for load/loadend).

Device and details:

  • OS: MacOS 26.6.1
  • Node version: 24.19.0
  • Package version: 20.11.2

Additional context

Relevant spec section: https://xhr.spec.whatwg.org/#the-send()-method ("fire a progress event named ...").

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions