Merge pull request #14341 from Snuffleupagus/shadow-prop-assert

Ensure that the `shadow` helper function is passed a valid property (PR 14152 follow-up)
This commit is contained in:
Tim van der Meij 2021-12-04 13:17:14 +01:00 committed by GitHub
commit bceed26e67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -488,6 +488,15 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
}
function shadow(obj, prop, value) {
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || TESTING")
) {
assert(
prop in obj,
`shadow: Property "${prop && prop.toString()}" not found in object.`
);
}
Object.defineProperty(obj, prop, {
value,
enumerable: true,