1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Limit PDFFetchStream to http(s) in the Chrome extension

The `fetch` API is only supported for http(s), even in Chrome extensions.
Because of this limitation, we should use the XMLHttpRequest API when the
requested URL is not a http(s) URL.

Fixes #9361
This commit is contained in:
Rob Wu 2018-01-14 00:34:46 +01:00
parent a7cb560f17
commit 1c8cacd6b9
3 changed files with 51 additions and 17 deletions

View file

@ -85,9 +85,13 @@ function initializePDFJS(callback) {
// Set network stream class for unit tests.
if (typeof Response !== 'undefined' && 'body' in Response.prototype &&
typeof ReadableStream !== 'undefined') {
displayApi.setPDFNetworkStreamClass(PDFFetchStream);
displayApi.setPDFNetworkStreamFactory(function(params) {
return new PDFFetchStream(params);
});
} else {
displayApi.setPDFNetworkStreamClass(PDFNetworkStream);
displayApi.setPDFNetworkStreamFactory(function(params) {
return new PDFNetworkStream(params);
});
}
// Configure the worker.