fix: Use Object.getPrototypeOf to get prototype in `__proto__-fn-name.js` (#4205)

This commit is contained in:
Aapo Alasuutari 2024-09-09 15:37:00 +03:00 committed by GitHub
parent d9b10790bc
commit cff5a6012f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 13 deletions

View File

@ -2,25 +2,23 @@
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.
/*--- /*---
es6id: B.3.1 esid: sec-runtime-semantics-propertydefinitionevaluation
description: Function name is not assigned based on the property name description: Function name is not assigned based on the __proto__ property name
info: | info: |
[...] [...]
6. If propKey is the String value "__proto__" and if 3. Else if propKey is "__proto__" and IsComputedPropertyKey of PropertyName is false, then
IsComputedPropertyKey(propKey) is false, then a. Let isProtoSetter be true.
a. If Type(propValue) is either Object or Null, then [...]
i. Return object.[[SetPrototypeOf]](propValue). 5. If IsAnonymousFunctionDefinition(AssignmentExpression) is true and isProtoSetter is false, then
b. Return NormalCompletion(empty). a. Let propValue be ? NamedEvaluation of AssignmentExpression with argument propKey.
7. If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then 6. Else,
a. Let hasNameProperty be HasOwnProperty(propValue, "name"). a. Let exprValueRef be ? Evaluation of AssignmentExpression.
b. ReturnIfAbrupt(hasNameProperty).
c. If hasNameProperty is false, perform SetFunctionName(propValue, propKey).
---*/ ---*/
var o; var o;
o = { o = {
__proto__: function() {} __proto__: function () {},
}; };
assert(o.__proto__.name !== '__proto__'); assert(Object.getPrototypeOf(o).name !== "__proto__");