1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Ensure that the correct data is sent, with the test message, from the worker if typed arrays aren't properly supported

With native typed array support now being mandatory in PDF.js, since version 2.0, this probably isn't a huge problem even though the current code seems wrong (it was changed in PR 6571).

Note how in the `!(data instanceof Uint8Array)` case we're currently attempting to send `handler.send('test', 'main', false);` to the main-thread, which doesn't really make any sense since the signature of the method reads `send(actionName, data, transfers) {`.
Hence the data that's *actually* being sent here is `'main'`, with `false` as the transferList, which just seems weird. On the main-thread, this means that we're in this case checking `data && data.supportTypedArray`, where `data` contains the string `'main'` rather than being falsy. Since a string doesn't have a `supportTypedArray` property, that check still fails as expected but it doesn't seem great nonetheless.
This commit is contained in:
Jonas Jenwald 2018-06-05 20:29:52 +02:00
parent dc6e1b4176
commit eef53347fe
2 changed files with 2 additions and 3 deletions

View file

@ -335,7 +335,7 @@ var WorkerMessageHandler = {
// check if Uint8Array can be sent to worker
if (!(data instanceof Uint8Array)) {
handler.send('test', 'main', false);
handler.send('test', false);
return;
}
// making sure postMessage transfers are working