1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-24 09:08:07 +02:00

Slightly improve validation of (some) parameters in getDocument

There's a couple of `getDocument` parameters that should be numbers, but which are currently not *fully* validated to prevent issues elsewhere in the code-base.
Also, improves validation of the `ownerDocument` parameter since we currently accept more-or-less anything here.
This commit is contained in:
Jonas Jenwald 2022-03-21 12:55:54 +01:00
parent feea2b78fa
commit 849de5a508
3 changed files with 27 additions and 6 deletions

View file

@ -26,10 +26,18 @@ import {
describe("network_utils", function () {
describe("validateRangeRequestCapabilities", function () {
it("rejects range chunk sizes that are not larger than zero", function () {
it("rejects invalid rangeChunkSize", function () {
expect(function () {
validateRangeRequestCapabilities({ rangeChunkSize: "abc" });
}).toThrow(
new Error("rangeChunkSize must be an integer larger than zero.")
);
expect(function () {
validateRangeRequestCapabilities({ rangeChunkSize: 0 });
}).toThrow(new Error("Range chunk size must be larger than zero"));
}).toThrow(
new Error("rangeChunkSize must be an integer larger than zero.")
);
});
it("rejects disabled or non-HTTP range requests", function () {