diff options
Diffstat (limited to 'Libraries/LibWeb/DOM/Document.cpp')
-rw-r--r-- | Libraries/LibWeb/DOM/Document.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 430d51590e..79b6d72cb8 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -31,6 +31,7 @@ #include <LibGUI/DisplayLink.h> #include <LibGUI/MessageBox.h> #include <LibJS/Interpreter.h> +#include <LibJS/Parser.h> #include <LibJS/Runtime/Function.h> #include <LibJS/Runtime/GlobalObject.h> #include <LibWeb/Bindings/DocumentWrapper.h> @@ -365,4 +366,12 @@ JS::Interpreter& Document::interpreter() return *m_interpreter; } +JS::Value Document::run_javascript(const StringView& source) +{ + auto program = JS::Parser(JS::Lexer(source)).parse_program(); + dbg() << "Document::run_javascript('" << source << "') will run:"; + program->dump(0); + return document().interpreter().run(*program); +} + } |