ladybird/Libraries/LibJS/Tests/exception-in-catch-block.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

25 lines
816 B
JavaScript

test("Issue #3437, exception thrown in catch {} block", () => {
var tryHasBeenExecuted = false;
var catchHasBeenExecuted = false;
var finallyHasBeenExecuted = false;
expect(() => {
try {
tryHasBeenExecuted = true;
foo();
// execution must not reach this step
expect().fail();
} catch (e) {
catchHasBeenExecuted = true;
bar();
// ...also not this step
expect().fail();
} finally {
finallyHasBeenExecuted = true;
}
// ...or this step
expect().fail();
}).toThrow(ReferenceError, "'bar' is not defined");
expect(tryHasBeenExecuted).toBeTrue();
expect(catchHasBeenExecuted).toBeTrue();
expect(finallyHasBeenExecuted).toBeTrue();
});