ladybird/Libraries/LibJS/Tests/computed-property-throws.js
Linus Groh 568d53c9b1 LibJS: Check validity of computed_property_name() result before using it
This fixes two cases obj[expr] and obj[expr]() (MemberExpression and
CallExpression respectively) when expr throws an exception and results
in an empty value, causing a crash by passing the invalid PropertyName
created by computed_property_name() to Object::get() without checking it
first.

Fixes #3459.
2020-09-12 11:29:39 +02:00

8 lines
219 B
JavaScript

test("Issue #3459, exception in computed property expression", () => {
expect(() => {
"foo"[bar];
}).toThrow(ReferenceError);
expect(() => {
"foo"[bar]();
}).toThrow(ReferenceError);
});