Skip to content

Commit

Permalink
Merge b9daa0e into b058b2d
Browse files Browse the repository at this point in the history
  • Loading branch information
tofpie authored Dec 18, 2020
2 parents b058b2d + b9daa0e commit 636d4e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 10 additions & 2 deletions boa/src/builtins/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ impl BuiltIn for Array {
)
.name(Self::NAME)
.length(Self::LENGTH)
.property("length", 0, Attribute::all())
.property(
"length",
0,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::PERMANENT,
)
.property(
"values",
values_function.clone(),
Expand Down Expand Up @@ -221,7 +225,11 @@ impl Array {
.as_object()
.expect("array object")
.set_prototype_instance(context.standard_objects().array_object().prototype().into());
array.set_field("length", Value::from(0));
let length = DataDescriptor::new(
Value::from(0),
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::PERMANENT,
);
array.set_property("length", length);
Ok(array)
}

Expand Down
9 changes: 9 additions & 0 deletions boa/src/builtins/array/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1361,3 +1361,12 @@ fn get_relative_end() {
Ok(10)
);
}

#[test]
fn array_length_is_not_enumerable() {
let mut context = Context::new();

let array = Array::new_array(&mut context).unwrap();
let desc = array.get_property("length").unwrap();
assert!(!desc.enumerable());
}

0 comments on commit 636d4e4

Please sign in to comment.