Fix typos in calls to verifyProperty

And update verifyProperty to catch misspelled descriptor fields.
This commit is contained in:
André Bargull 2023-09-11 15:48:27 +02:00 committed by Ms2ger
parent b4f72feb52
commit 534decc36d
6 changed files with 18 additions and 5 deletions

View File

@ -45,6 +45,19 @@ function verifyProperty(obj, name, desc, options) {
return true;
}
var names = Object.getOwnPropertyNames(desc);
for (var i = 0; i < names.length; i++) {
assert(
names[i] === "value" ||
names[i] === "writable" ||
names[i] === "enumerable" ||
names[i] === "configurable" ||
names[i] === "get" ||
names[i] === "set",
"Invalid descriptor field: " + names[i],
);
}
assert(
Object.prototype.hasOwnProperty.call(obj, name),
"obj should have an own property " + nameStr

View File

@ -22,6 +22,6 @@ includes: [propertyHelper.js]
verifyProperty(ArrayBuffer.prototype.transfer, 'name', {
value: 'transfer',
enumerable: false,
wrtiable: false,
writable: false,
configurable: true
});

View File

@ -22,6 +22,6 @@ includes: [propertyHelper.js]
verifyProperty(ArrayBuffer.prototype.transferToFixedLength, 'name', {
value: 'transferToFixedLength',
enumerable: false,
wrtiable: false,
writable: false,
configurable: true
});

View File

@ -29,7 +29,7 @@ var error = new Error(message, { cause });
verifyProperty(error, "cause", {
configurable: true,
enumerable: false,
writeable: true,
writable: true,
value: cause,
});

View File

@ -31,7 +31,7 @@ var error = new AggregateError(errors, message, { cause });
verifyProperty(error, "cause", {
configurable: true,
enumerable: false,
writeable: true,
writable: true,
value: cause,
});

View File

@ -36,7 +36,7 @@ for (var i = 0; i < nativeErrors.length; ++i) {
verifyProperty(error, "cause", {
configurable: true,
enumerable: false,
writeable: true,
writable: true,
value: cause,
});