LibWeb: Insert newlines around WebDriver scripts
This allows the script to end with a comment, which is tested by WPT. Otherwise, an ending comment would create a function of the form: function() { return 1; // comment } And the script would fail to parse.
This commit is contained in:
parent
371ddf9dc3
commit
3cc7118bf4
Notes:
github-actions[bot]
2024-11-02 10:10:55 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/3cc7118bf4a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2100
1 changed files with 6 additions and 1 deletions
|
@ -268,7 +268,12 @@ JS::ThrowCompletionOr<JS::Value> execute_a_function_body(HTML::Window const& win
|
|||
if (environment_override_object)
|
||||
scope = JS::new_object_environment(*environment_override_object, true, &global_scope);
|
||||
|
||||
auto source_text = ByteString::formatted("function() {{ {} }}", body);
|
||||
auto source_text = ByteString::formatted(
|
||||
R"~~~(function() {{
|
||||
{}
|
||||
}})~~~",
|
||||
body);
|
||||
|
||||
auto parser = JS::Parser { JS::Lexer { source_text } };
|
||||
auto function_expression = parser.parse_function_node<JS::FunctionExpression>();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue