10000 Add test for indirectly merging `Object` properties. · lodash/lodash@d8ddc1a · GitHub
[go: up one dir, main page]

Skip to content

Commit d8ddc1a

Browse files
committed
Add test for indirectly merging Object properties.
1 parent e5f9af5 commit d8ddc1a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

test/test.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7555,16 +7555,34 @@
75557555
}
75567556
});
75577557

7558-
QUnit.test('should not merge `Object.prototype` properties', function(assert) {
7559-
assert.expect(1);
7558+
QUnit.test('should not indirectly merge builtin prototype properties', function(assert) {
7559+
assert.expect(2);
7560+
7561+
_.merge({}, { 'toString': { 'constructor': { 'prototype': { 'a': 1 } } } });
7562+
7563+
var actual = 'a' in funcProto;
7564+
delete funcProto.a;
7565+
7566+
assert.notOk(actual);
75607567

75617568
_.merge({}, { 'constructor': { 'prototype': { 'a': 1 } } });
75627569

7563-
var actual = 'a' in objectProto;
7570+
actual = 'a' in objectProto;
75647571
delete objectProto.a;
75657572

75667573
assert.notOk(actual);
75677574
});
7575+
7576+
QUnit.test('should not indirectly merge `Object` properties', function(assert) {
7577+
assert.expect(1);
7578+
7579+
_.merge({}, { 'constructor': { 'a': 1 } });
7580+
7581+
var actual = 'a' in Object;
7582+
delete Object.a;
7583+
7584+
assert.notOk(actual);
7585+
});
75687586
}());
75697587

75707588
/*--------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)
0