1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Ensure that Errors are handled correctly when using postMessage with Streams in MessageHandler

Having recently worked with this code, it struck me that most of the `postMessage` calls where `Error`s are involved have never been correctly implemented (i.e. missing `wrapReason` calls).
This commit is contained in:
Jonas Jenwald 2019-09-02 13:18:39 +02:00
parent e59b11860d
commit 02bdacef42
2 changed files with 11 additions and 9 deletions

View file

@ -142,11 +142,13 @@ describe('message_handler', function () {
sink.onCancel = function (reason) {
log += 'c';
};
log += '0';
sink.ready.then(() => {
log += '1';
sink.enqueue([1, 2, 3, 4], 4);
return sink.ready;
}).then(() => {
log += 'error';
log += 'e';
sink.error('error');
});
});
@ -161,14 +163,14 @@ describe('message_handler', function () {
let reader = readable.getReader();
sleep(10).then(() => {
expect(log).toEqual('');
expect(log).toEqual('01');
return reader.read();
}).then((result) => {
expect(result.value).toEqual([1, 2, 3, 4]);
expect(result.done).toEqual(false);
return reader.read();
}).then(() => {
}, (reason) => {
}).catch((reason) => {
expect(log).toEqual('01pe');
expect(reason).toEqual('error');
done();
});