mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Ensure that Cmd
/Name
is only initialized with string arguments
Trying to use a non-string argument in either a `Cmd` or a `Name` is not intended, and would basically be an implementation error. Hence we can add a non-PRODUCTION check to enforce this, similar to the existing one used e.g. in the `Dict.set` method.
This commit is contained in:
parent
2bb96a708c
commit
ec87995050
3 changed files with 27 additions and 1 deletions
|
@ -55,6 +55,12 @@ describe("primitives", function () {
|
|||
expect(firstEmpty).toBe(secondEmpty);
|
||||
expect(firstEmpty).not.toBe(normalName);
|
||||
});
|
||||
|
||||
it("should not accept to create a non-string name", function () {
|
||||
expect(function () {
|
||||
Name.get(123);
|
||||
}).toThrow(new Error('Name: The "name" must be a string.'));
|
||||
});
|
||||
});
|
||||
|
||||
describe("Cmd", function () {
|
||||
|
@ -74,6 +80,12 @@ describe("primitives", function () {
|
|||
expect(firstET).toBe(secondET);
|
||||
expect(firstBT).not.toBe(firstET);
|
||||
});
|
||||
|
||||
it("should not accept to create a non-string cmd", function () {
|
||||
expect(function () {
|
||||
Cmd.get(123);
|
||||
}).toThrow(new Error('Cmd: The "cmd" must be a string.'));
|
||||
});
|
||||
});
|
||||
|
||||
describe("Dict", function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue