Fix Function.prototype.length
Summary: Found by "test262/test/built-ins/Function/prototype/length.js", `Function.prototype.length` should be non-configurable. Also, its default value should be 0 instead of undefined. ``` Object.getOwnPropertyDescriptor(Function.prototype, "length") { value: 0, writable: false, enumerable: false, configurable: true } ``` Reviewed By: avp Differential Revision: D28970136 fbshipit-source-id: 8ea2a98e4494ec49bcd84c4a5918d3de31bc7c7f
This commit is contained in:
Родитель
281d96620f
Коммит
1c23eb4cd8
|
@ -273,6 +273,12 @@ void initGlobalObject(Runtime *runtime, const JSLibFlags &jsLibFlags) {
|
|||
DefinePropertyFlags normalDPF =
|
||||
DefinePropertyFlags::getNewNonEnumerableFlags();
|
||||
|
||||
// Not enumerable, not writable but configurable.
|
||||
DefinePropertyFlags configurableOnlyPDF =
|
||||
DefinePropertyFlags::getDefaultNewPropertyFlags();
|
||||
configurableOnlyPDF.enumerable = 0;
|
||||
configurableOnlyPDF.writable = 0;
|
||||
|
||||
/// Clear the configurable flag.
|
||||
DefinePropertyFlags clearConfigurableDPF{};
|
||||
clearConfigurableDPF.setConfigurable = 1;
|
||||
|
@ -356,8 +362,8 @@ void initGlobalObject(Runtime *runtime, const JSLibFlags &jsLibFlags) {
|
|||
Handle<JSObject>::vmcast(&runtime->functionPrototype),
|
||||
runtime,
|
||||
Predefined::getSymbolID(Predefined::length),
|
||||
clearConfigurableDPF,
|
||||
Runtime::getUndefinedValue()));
|
||||
configurableOnlyPDF,
|
||||
Runtime::getZeroValue()));
|
||||
|
||||
// [[ThrowTypeError]].
|
||||
auto throwTypeErrorFunction = NativeFunction::create(
|
||||
|
|
|
@ -13,7 +13,7 @@ function foo() {}
|
|||
print("foo.length/configurable:", Object.getOwnPropertyDescriptor(foo, "length").configurable);
|
||||
//CHECK: foo.length/configurable: true
|
||||
print("foo.__proto__.length/configurable:", Object.getOwnPropertyDescriptor(foo.__proto__, "length").configurable);
|
||||
//CHECK: foo.__proto__.length/configurable: false
|
||||
//CHECK: foo.__proto__.length/configurable: true
|
||||
print("Function.length/configurable:", Object.getOwnPropertyDescriptor(Function, "length").configurable);
|
||||
//CHECK: Function.length/configurable: true
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ function foo() {}
|
|||
print("foo.length/configurable:", Object.getOwnPropertyDescriptor(foo, "length").configurable);
|
||||
//CHECK: foo.length/configurable: true
|
||||
print("foo.__proto__.length/configurable:", Object.getOwnPropertyDescriptor(foo.__proto__, "length").configurable);
|
||||
//CHECK: foo.__proto__.length/configurable: false
|
||||
//CHECK: foo.__proto__.length/configurable: true
|
||||
print("Function.length/configurable:", Object.getOwnPropertyDescriptor(Function, "length").configurable);
|
||||
//CHECK: Function.length/configurable: true
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ serializeVM(function() {
|
|||
print("foo.length/configurable:", Object.getOwnPropertyDescriptor(foo, "length").configurable);
|
||||
//CHECK: foo.length/configurable: true
|
||||
print("foo.__proto__.length/configurable:", Object.getOwnPropertyDescriptor(foo.__proto__, "length").configurable);
|
||||
//CHECK: foo.__proto__.length/configurable: false
|
||||
//CHECK: foo.__proto__.length/configurable: true
|
||||
print("Function.length/configurable:", Object.getOwnPropertyDescriptor(Function, "length").configurable);
|
||||
//CHECK: Function.length/configurable: true
|
||||
|
||||
|
|
|
@ -838,8 +838,6 @@ SKIP_LIST = [
|
|||
"test262/test/built-ins/Function/prototype/restricted-property-arguments.js",
|
||||
"test262/test/built-ins/Function/prototype/restricted-property-caller.js",
|
||||
"test262/test/built-ins/Function/prototype/bind/BoundFunction_restricted-properties.js",
|
||||
# TODO(T90542855) Function.prototype.length should be configurable
|
||||
"test262/test/built-ins/Function/prototype/length.js",
|
||||
# Object() changes
|
||||
"test262/test/built-ins/Object/prototype/toLocaleString/primitive_this_value.js",
|
||||
"test262/test/built-ins/Object/prototype/toLocaleString/primitive_this_value_getter.js",
|
||||
|
|
Загрузка…
Ссылка в новой задаче