feat(XMLHttpRequest): use proxies to implement request interception #337
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It should be safe migrating to Proxies due to their wide browser support.
Changes
globalThis.XMLHttpRequest
.request.headers
changes of the Fetch API representation of an XMLHttpRequest to update the underlying XHR instance correctly (in the case the "request" listener has modified the request headers).readystatechange
event has been fired twice for XMLHttpRequest: once from the XHR instance itself, and the second time from the underlyinghttp
implementation from JSDOM.credentials
tosame-origin
(previouslyomit
) when thewithCredentials
property of XMLHttpRequest is set tofalse
or not set.InvalidStateError
when reading the request body improperly (e.g. usingresponseText
when theresponseType
is not an empty string or "text"). This also helps to improve some of our tests as they were reading the response body of XMLHttpRequest incorrectly.Roadmap
XMLHttpRequestController
XMLHttpRequestOverride
).X-Request-Id
on the bypassed requests is still needed:interceptors/src/interceptors/XMLHttpRequest/XMLHttpRequestOverride.ts
Lines 472 to 477 in d73624b