assert,util: fix commutativity edge case

Verify that both objects property keys are enumerable.

Fixes: https://github.com/nodejs/node/issues/37710

PR-URL: https://github.com/nodejs/node/pull/37711
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Ruben Bridgewater authored and Antoine du Hamel committed 2021-03-13 13:44:06 +01:00
1 parent a97f01ea8c
commit 5ff2e582cd
2 files changed
+11 -1

No files matched your search

+1 -1
View File
@@ -282,7 +282,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
// Cheap key test
let i = 0;
for (; i < aKeys.length; i++) {
if (!ObjectPrototypeHasOwnProperty(val2, aKeys[i])) {
if (!ObjectPrototypePropertyIsEnumerable(val2, aKeys[i])) {
return false;
}
}
+10
View File
@@ -1194,3 +1194,13 @@ assert.throws(
Object.setPrototypeOf(b, null);
assertNotDeepOrStrict(a, b, assert.AssertionError);
}
{
// Verify commutativity
// Regression test for https://github.com/nodejs/node/issues/37710
const a = { x: 1 };
const b = { y: 1 };
Object.defineProperty(b, 'x', { value: 1 });
assertNotDeepOrStrict(a, b);
}