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

Inline the setPDFNetworkStreamFactory functionality in src/display/api.js

Given that this is internal functionality, not exposed in the official API, it's not entirely clear (at least to me) why we can't just initialize this directly in `src/display/api.js` instead.
When testing both the development viewer and all the ways in which we run tests, everthing still appears to work just fine with this patch.
This commit is contained in:
Jonas Jenwald 2023-01-02 18:35:11 +01:00
parent e36564668b
commit 1d5de9f4f4
4 changed files with 33 additions and 80 deletions

View file

@ -15,8 +15,6 @@
import { setVerbosityLevel, VerbosityLevel } from "../../src/shared/util.js";
import { isNodeJS } from "../../src/shared/is_node.js";
import { PDFNodeStream } from "../../src/display/node_stream.js";
import { setPDFNetworkStreamFactory } from "../../src/display/api.js";
// Sets longer timeout, similar to `jasmine-boot.js`.
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
@ -31,8 +29,3 @@ if (!isNodeJS) {
// Reduce the amount of console "spam", by ignoring `info`/`warn` calls,
// when running the unit-tests in Node.js/Travis.
setVerbosityLevel(VerbosityLevel.ERRORS);
// Set the network stream factory for the unit-tests.
setPDFNetworkStreamFactory(function (params) {
return new PDFNodeStream(params);
});

View file

@ -42,10 +42,6 @@
import { GlobalWorkerOptions } from "pdfjs/display/worker_options.js";
import { isNodeJS } from "pdfjs/shared/is_node.js";
import { isValidFetchUrl } from "pdfjs/display/display_utils.js";
import { PDFFetchStream } from "pdfjs/display/fetch_stream.js";
import { PDFNetworkStream } from "pdfjs/display/network.js";
import { setPDFNetworkStreamFactory } from "pdfjs/display/api.js";
import { TestReporter } from "./testreporter.js";
async function initializePDFJS(callback) {
@ -107,14 +103,6 @@ async function initializePDFJS(callback) {
"The `gulp unittest` command cannot be used in Node.js environments."
);
}
// Set the network stream factory for the unit-tests.
setPDFNetworkStreamFactory(params => {
if (isValidFetchUrl(params.url)) {
return new PDFFetchStream(params);
}
return new PDFNetworkStream(params);
});
// Configure the worker.
GlobalWorkerOptions.workerSrc = "../../build/generic/build/pdf.worker.js";