angular/aio/content/examples/http/src
Paul Gschwendtner 489cf42cd0 fix(common): incorrect error type for XHR errors in TestRequest (#36082)
Currently the `HttpClient` always wraps errors from XHR requests, but
the underlying errors are always of type `ProgressEvent`, or don't have
a native error if the status code is just indicating failure (e.g. 404).

This behavior does not match in the `TestRequest` class provided by
`@angular/common/http/testing` where errors are considered being
of type `ErrorEvent`. This is incorrect because `ErrorEvent`s provide
information for errors in scripts or files which are evaluated. Since
the `HttpClient` never evaluates scripts/files, and also since XHR requests
clearly are documented to emit `ProgressEvent`'s, we should change the
`TestSupport` to retrieve such `ProgressEvent`'s instead of incompatible
objects of type `ErrorEvent`.

In favor of having a deprecation period, we keep supporting `ErrorEvent`
in the `TestRequest.error` signature. Eventually, we can remove this
signature in the future.

Resources:
  * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/error_event
  * https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent
  * https://xhr.spec.whatwg.org/#event-xhr-errpr

Related to: https://github.com/angular/angular/issues/34748.

DEPRECATED: `TestRequest` from `@angular/common/http/testing` no longer
accepts `ErrorEvent` when simulating XHR errors. Instead instances of
`ProgressEvent` should be passed, matching with the native browser behavior.

PR Close #36082
2021-11-19 21:26:52 +00:00
..
app docs: use correct service name when creating error handler in http example (#43767) 2021-10-08 20:17:58 +00:00
assets docs(http): add custom JSONParser example (#40645) 2021-02-16 08:03:33 -08:00
testing fix(common): incorrect error type for XHR errors in TestRequest (#36082) 2021-11-19 21:26:52 +00:00
browser-test-shim.js docs: migrate examples from @angular/http to @angular/common/http (#28296) 2019-03-11 10:52:17 -07:00
index-specs.html Revert "docs: add testing styles in index.html, remove additional configuration" (#25892) 2018-10-09 17:04:19 -07:00
index.html docs: improve accessibility of http example (#41057) 2021-04-26 09:11:07 -07:00
main-specs.ts fix(docs-infra): fix example compilation issues (#42199) 2021-05-21 18:07:44 +00:00
main.ts fix(docs-infra): fix StackBlitz and zipped http examples (#33941) 2019-11-20 14:44:31 -08:00
test.css Revert "docs: add testing styles in index.html, remove additional configuration" (#25892) 2018-10-09 17:04:19 -07:00