mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-09 23:04:02 +02:00
Merge pull request #20927 from Snuffleupagus/Firefox-enforce-worker-binary-fetch
[Firefox] Ensure that worker-thread fetching is used for built-in CMap, standard font, and wasm data
This commit is contained in:
commit
dabb2b960d
@ -408,6 +408,9 @@ class PartialEvaluator {
|
||||
isCompressed: true,
|
||||
};
|
||||
} else {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error("Only worker-thread fetching supported.");
|
||||
}
|
||||
// Get the data on the main-thread instead.
|
||||
data = await this.handler.sendWithPromise("FetchBinaryData", {
|
||||
type: "cMapReaderFactory",
|
||||
@ -446,6 +449,9 @@ class PartialEvaluator {
|
||||
`${this.options.standardFontDataUrl}${filename}`
|
||||
);
|
||||
} else {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error("Only worker-thread fetching supported.");
|
||||
}
|
||||
// Get the data on the main-thread instead.
|
||||
data = await this.handler.sendWithPromise("FetchBinaryData", {
|
||||
type: "standardFontDataFactory",
|
||||
|
||||
@ -48,6 +48,9 @@ class JBig2CCITTFaxWasmImage {
|
||||
if (this.#useWorkerFetch) {
|
||||
this.#buffer = await fetchBinaryData(`${this.#wasmUrl}${filename}`);
|
||||
} else {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error("Only worker-thread fetching supported.");
|
||||
}
|
||||
this.#buffer = await this.#handler.sendWithPromise(
|
||||
"FetchBinaryData",
|
||||
{ type: "wasmFactory", filename }
|
||||
|
||||
@ -72,6 +72,9 @@ class JpxImage {
|
||||
if (this.#useWorkerFetch) {
|
||||
this.#buffer = await fetchBinaryData(`${this.#wasmUrl}${filename}`);
|
||||
} else {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error("Only worker-thread fetching supported.");
|
||||
}
|
||||
this.#buffer = await this.#handler.sendWithPromise(
|
||||
"FetchBinaryData",
|
||||
{ type: "wasmFactory", filename }
|
||||
|
||||
@ -2468,17 +2468,18 @@ class WorkerTransport {
|
||||
|
||||
this.canvasFactory = factory.canvasFactory;
|
||||
this.filterFactory = factory.filterFactory;
|
||||
this.cMapReaderFactory = factory.cMapReaderFactory;
|
||||
this.standardFontDataFactory = factory.standardFontDataFactory;
|
||||
this.wasmFactory = factory.wasmFactory;
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
this.cMapReaderFactory = factory.cMapReaderFactory;
|
||||
this.standardFontDataFactory = factory.standardFontDataFactory;
|
||||
this.wasmFactory = factory.wasmFactory;
|
||||
}
|
||||
this.pagesMapper = pagesMapper;
|
||||
|
||||
this.destroyed = false;
|
||||
this.destroyCapability = null;
|
||||
|
||||
this.setupMessageHandler();
|
||||
|
||||
this.pagesMapper = pagesMapper;
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||
// For testing purposes.
|
||||
Object.defineProperty(this, "getNetworkStreamName", {
|
||||
@ -2925,22 +2926,21 @@ class WorkerTransport {
|
||||
this.#onProgress(data);
|
||||
});
|
||||
|
||||
messageHandler.on("FetchBinaryData", async data => {
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
throw new Error("Not implemented: FetchBinaryData");
|
||||
}
|
||||
if (this.destroyed) {
|
||||
throw new Error("Worker was destroyed.");
|
||||
}
|
||||
const factory = this[data.type];
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
||||
messageHandler.on("FetchBinaryData", async data => {
|
||||
if (this.destroyed) {
|
||||
throw new Error("Worker was destroyed.");
|
||||
}
|
||||
const factory = this[data.type];
|
||||
|
||||
if (!factory) {
|
||||
throw new Error(
|
||||
`${data.type} not initialized, see the \`useWorkerFetch\` parameter.`
|
||||
);
|
||||
}
|
||||
return factory.fetch(data);
|
||||
});
|
||||
if (!factory) {
|
||||
throw new Error(
|
||||
`${data.type} not initialized, see the \`useWorkerFetch\` parameter.`
|
||||
);
|
||||
}
|
||||
return factory.fetch(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getData() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user