mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Per step 13 of ScriptEvaluation in the ECMA-262 spec, the script body should only be evaluated if GlobalDeclarationInstantiation returned a normal completion. This can't currently be triggered since we always create fresh Script objects, but if we ever start reusing cached executables across evaluations, this would prevent a subtle bug where the script body runs despite GDI failing.
8 lines
348 B
JavaScript
8 lines
348 B
JavaScript
test("script body is not evaluated when GlobalDeclarationInstantiation fails", () => {
|
|
evaluateSource("let x = 1;");
|
|
expect(() => {
|
|
evaluateSource("let x = 2; globalThis.__side_effect = true;");
|
|
}).toThrowWithMessage(SyntaxError, "Redeclaration of top level variable");
|
|
expect(globalThis.__side_effect).toBeUndefined();
|
|
});
|