Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually set the prototype when using a __proto__ property (#4112)
- Loading branch information
1 parent
edae1ba
commit 1dd8ba7
Showing
6 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'handles getters and setters on __proto__ properties' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
console.log('retained'); | ||
console.log('retained'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const a = { __proto__: null }; | ||
if (a.hasOwnProperty) console.log('removed'); | ||
else console.log('retained'); | ||
if (a.foo) console.log('removed'); | ||
else console.log('retained'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
description: 'handles getters and setters on __proto__ properties' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
let getter_effect = 'FAIL'; | ||
let setter_effect = 'FAIL'; | ||
let proto = { | ||
get foo() { | ||
getter_effect = 'PASS'; | ||
}, | ||
set bar(value) { | ||
setter_effect = 'PASS'; | ||
} | ||
}; | ||
let obj1 = { | ||
__proto__: proto | ||
}; | ||
let obj2 = { | ||
__proto__: proto | ||
}; | ||
let unused = obj1.foo; | ||
obj2.bar = 0; | ||
|
||
assert.strictEqual(getter_effect, 'PASS'); | ||
assert.strictEqual(setter_effect, 'PASS'); |