Skip to content

Commit 4451460

Browse files
BridgeARdanielleadams
authored andcommitted
assert,util: fix commutativity edge case
Verify that both objects property keys are enumerable. Fixes: #37710 PR-URL: #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>
1 parent 8666d77 commit 4451460

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎lib/internal/util/comparisons.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ function keyCheck(val1, val2, strict, memos, iterationType, aKeys) {
282282
// Cheap key test
283283
leti=0;
284284
for(;i<aKeys.length;i++){
285-
if(!ObjectPrototypeHasOwnProperty(val2,aKeys[i])){
285+
if(!ObjectPrototypePropertyIsEnumerable(val2,aKeys[i])){
286286
returnfalse;
287287
}
288288
}

‎test/parallel/test-assert-deep.js‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,3 +1194,13 @@ assert.throws(
11941194
Object.setPrototypeOf(b,null);
11951195
assertNotDeepOrStrict(a,b,assert.AssertionError);
11961196
}
1197+
1198+
{
1199+
// Verify commutativity
1200+
// Regression test for https://github.com/nodejs/node/issues/37710
1201+
consta={x: 1};
1202+
constb={y: 1};
1203+
Object.defineProperty(b,'x',{value: 1});
1204+
1205+
assertNotDeepOrStrict(a,b);
1206+
}

0 commit comments

Comments
 (0)