mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Ensure that Dict.set
only accepts string key
s
Trying to use a non-string `key` in a `Dict` is not intended, and would basically be an implementation error. Hence we can add a non-PRODUCTION check to enforce this, complementing the existing `value` check added in PR 11672.
This commit is contained in:
parent
b2f6844ce3
commit
a2f9031e9a
4 changed files with 20 additions and 7 deletions
|
@ -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 () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue