summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibJS/Runtime/Completion.cpp7
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.h2
-rw-r--r--Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Bindings/MainThreadVM.h2
4 files changed, 15 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Completion.cpp b/Userland/Libraries/LibJS/Runtime/Completion.cpp
index bcf39d8f50..7f2ba12152 100644
--- a/Userland/Libraries/LibJS/Runtime/Completion.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Completion.cpp
@@ -97,8 +97,11 @@ ThrowCompletionOr<Value> await(VM& vm, Value value)
// by letting the event loop spin until our promise is no longer pending, and then synchronously
// running all queued promise jobs.
// Note: This is not used by LibJS itself, and is performed for the embedder (i.e. LibWeb).
- if (Core::EventLoop::has_been_instantiated())
- Core::EventLoop::current().spin_until([&] { return success.has_value(); });
+ if (auto* custom_data = vm.custom_data()) {
+ custom_data->spin_event_loop_until([&] {
+ return success.has_value();
+ });
+ }
// 8. Remove asyncContext from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context.
// NOTE: Since we don't push any EC, this step is not performed.
diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h
index d17d078dd0..5d037e8013 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.h
+++ b/Userland/Libraries/LibJS/Runtime/VM.h
@@ -34,6 +34,8 @@ class VM : public RefCounted<VM> {
public:
struct CustomData {
virtual ~CustomData() = default;
+
+ virtual void spin_event_loop_until(Function<bool()> goal_condition) = 0;
};
static NonnullRefPtr<VM> create(OwnPtr<CustomData> = {});
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
index 9635de6397..d74438acbf 100644
--- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
+++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp
@@ -21,6 +21,7 @@
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Scripting/ExceptionReporter.h>
#include <LibWeb/HTML/Window.h>
+#include <LibWeb/Platform/EventLoopPlugin.h>
namespace Web::Bindings {
@@ -413,4 +414,9 @@ NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM& vm, Fu
return realm_execution_context;
}
+void WebEngineCustomData::spin_event_loop_until(Function<bool()> goal_condition)
+{
+ Platform::EventLoopPlugin::the().spin_until(move(goal_condition));
+}
+
}
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h
index d9f10bac27..62eef59b66 100644
--- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h
+++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.h
@@ -20,6 +20,8 @@ namespace Web::Bindings {
struct WebEngineCustomData final : public JS::VM::CustomData {
virtual ~WebEngineCustomData() override = default;
+ virtual void spin_event_loop_until(Function<bool()> goal_condition) override;
+
HTML::EventLoop event_loop;
// FIXME: These should only be on similar-origin window agents, but we don't currently differentiate agent types.