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

Merge pull request #14597 from Snuffleupagus/Dict-set-validate-key

Ensure that `Dict.set` only accepts string `key`s
This commit is contained in:
Tim van der Meij 2022-02-23 20:31:36 +01:00 committed by GitHub
commit 409cbfc817
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 7 deletions

View file

@ -149,6 +149,17 @@ describe("primitives", function () {
checkInvalidKeyValues(dictWithSizeKey);
});
it("should not accept to set a non-string key", function () {
const dict = new Dict();
expect(function () {
dict.set(123, "val");
}).toThrow(new Error('Dict.set: The "key" must be a string.'));
expect(dict.has(123)).toBeFalsy();
checkInvalidKeyValues(dict);
});
it("should not accept to set a key with an undefined value", function () {
const dict = new Dict();
expect(function () {