d7bec1b527
Having just tested PR 17337 locally I noticed that especially the `JpxImage`-test causes a "ridiculous" amount of warning messages to be printed, which doesn't seem helpful. Given that only actual `Error`s should be relevant here, we can easily disable this logging during the tests.
30 lines
624 B
JavaScript
30 lines
624 B
JavaScript
import {
|
|
JpegImage,
|
|
setVerbosityLevel,
|
|
VerbosityLevel,
|
|
} from "../../build/image_decoders/pdf.image_decoders.mjs";
|
|
|
|
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
|
setVerbosityLevel(VerbosityLevel.ERRORS);
|
|
|
|
const ignored = ["Cannot read properties", "JPEG error"];
|
|
|
|
function ignoredError(error) {
|
|
return ignored.some(message => error.message.includes(message));
|
|
}
|
|
|
|
/**
|
|
* @param {Buffer} data
|
|
*/
|
|
function fuzz(data) {
|
|
try {
|
|
new JpegImage().parse(new Uint8Array(data));
|
|
} catch (error) {
|
|
if (error.message && !ignoredError(error)) {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
export { fuzz };
|