mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 15:21:00 +02:00
*Note:* This is similar to PR 19525, which did the same thing for the OpenJPEG decoder. The advantages of doing this are: - The same JBig2 decoder is used regardless of WASM being supported or not, which means consistent rendering. - The old `Jbig2Image` implementation has various bugs and missing features. - Less code that needs to be maintained in the PDF.js project, since both the CCITT and the JBig2 decoder is replaced. The disadvantage of doing this is: - Slightly larger bundle size, however the effect is limited since a fair amount of PDF.js code can be removed. For the `gulp mozcentral` target the size increase is approximately 54 kilo-bytes (which is small compared to the 452 kilo-bytes for the JS version of the OpenJPEG decoder).
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
/* Copyright 2023 Mozilla Foundation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import {
|
|
getVerbosityLevel,
|
|
setVerbosityLevel,
|
|
VerbosityLevel,
|
|
} from "../../src/shared/util.js";
|
|
import {
|
|
Jbig2Error,
|
|
JBig2CCITTFaxImage as Jbig2Image,
|
|
} from "../../src/core/jbig2_ccittFax.js";
|
|
import { JpegError, JpegImage } from "../../src/core/jpg.js";
|
|
import { JpxError, JpxImage } from "../../src/core/jpx.js";
|
|
|
|
const expectedAPI = Object.freeze({
|
|
getVerbosityLevel,
|
|
Jbig2Error,
|
|
Jbig2Image,
|
|
JpegError,
|
|
JpegImage,
|
|
JpxError,
|
|
JpxImage,
|
|
setVerbosityLevel,
|
|
VerbosityLevel,
|
|
});
|
|
|
|
describe("pdfimage_api", function () {
|
|
it("checks that the *official* PDF.js-image decoders API exposes the expected functionality", async function () {
|
|
// eslint-disable-next-line no-unsanitized/method
|
|
const pdfimageAPI = await import(
|
|
typeof PDFJSDev !== "undefined" && PDFJSDev.test("LIB")
|
|
? "../../pdf.image_decoders.js"
|
|
: "../../src/pdf.image_decoders.js"
|
|
);
|
|
|
|
// The imported Object contains an (automatically) inserted Symbol,
|
|
// hence we copy the data to allow using a simple comparison below.
|
|
expect({ ...pdfimageAPI }).toEqual(expectedAPI);
|
|
|
|
expect(Object.keys(globalThis.pdfjsImageDecoders).sort()).toEqual(
|
|
Object.keys(expectedAPI).sort()
|
|
);
|
|
});
|
|
});
|