Ensure that ReadableStreams are cancelled with actual Errors

There's a number of spots in the current code, and tests, where `cancel` methods are not called with appropriate arguments (leading to Promises not being rejected with Errors as intended).
In some cases the cancel `reason` is implicitly set to `undefined`, and in others the cancel `reason` is just a plain String. To address this inconsistency, the patch changes things such that cancelling is done with `AbortException`s everywhere instead.
This commit is contained in:
Jonas Jenwald 2019-08-01 16:31:32 +02:00
parent d909b86b28
commit a3150166ec
8 changed files with 32 additions and 29 deletions

View file

@ -16,10 +16,11 @@
/* eslint no-var: error */
import {
assert, createPromiseCapability, getVerbosityLevel, info, InvalidPDFException,
isArrayBuffer, isSameOrigin, MissingPDFException, NativeImageDecoding,
PasswordException, setVerbosityLevel, shadow, stringToBytes,
UnexpectedResponseException, UnknownErrorException, unreachable, URL, warn
AbortException, assert, createPromiseCapability, getVerbosityLevel, info,
InvalidPDFException, isArrayBuffer, isSameOrigin, MissingPDFException,
NativeImageDecoding, PasswordException, setVerbosityLevel, shadow,
stringToBytes, UnexpectedResponseException, UnknownErrorException,
unreachable, URL, warn
} from '../shared/util';
import {
deprecated, DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer,
@ -1768,7 +1769,8 @@ class WorkerTransport {
Promise.all(waitOn).then(() => {
this.fontLoader.clear();
if (this._networkStream) {
this._networkStream.cancelAllRequests();
this._networkStream.cancelAllRequests(
new AbortException('Worker was terminated.'));
}
if (this.messageHandler) {