summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 170c0a2e7b..f47bca16cb 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -679,15 +679,17 @@ JS::Interpreter& Document::interpreter()
JS::Value Document::run_javascript(StringView source, StringView filename)
{
- auto parser = JS::Parser(JS::Lexer(source, filename));
- auto program = parser.parse_program();
- if (parser.has_errors()) {
- parser.print_errors(false);
+ // FIXME: The only user of this function now is javascript: URLs. Refactor them to follow the spec: https://html.spec.whatwg.org/multipage/browsing-the-web.html#javascript-protocol
+ auto& interpreter = document().interpreter();
+ auto script_or_error = JS::Script::parse(source, interpreter.realm(), filename);
+ if (script_or_error.is_error()) {
+ // FIXME: Add error logging back.
return JS::js_undefined();
}
- auto& interpreter = document().interpreter();
+
+ auto result = interpreter.run(script_or_error.value());
+
auto& vm = interpreter.vm();
- auto result = interpreter.run(interpreter.global_object(), *program);
if (result.is_error()) {
// FIXME: I'm sure the spec could tell us something about error propagation here!
vm.clear_exception();