mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:28:12 +00:00
LibWeb: Update workarounds for the empty execution context stack
Use the new helper class to perform this workaround.
This commit is contained in:
parent
8ec7b4401a
commit
f57310999d
7 changed files with 30 additions and 88 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/HTMLOptionsCollection.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/WebDriver/Contexts.h>
|
||||
|
@ -325,18 +326,13 @@ ExecuteScriptResultSerialized execute_script(Web::Page& page, DeprecatedString c
|
|||
ExecuteScriptResultSerialized execute_async_script(Web::Page& page, DeprecatedString const& body, JS::MarkedVector<JS::Value> arguments, Optional<u64> const& timeout)
|
||||
{
|
||||
auto* document = page.top_level_browsing_context().active_document();
|
||||
auto& settings_object = document->relevant_settings_object();
|
||||
auto* window = page.top_level_browsing_context().active_window();
|
||||
auto& realm = window->realm();
|
||||
auto& vm = window->vm();
|
||||
auto start = MonotonicTime::now();
|
||||
|
||||
// NOTE: We need to push an execution context in order to make create_resolving_functions() succeed.
|
||||
vm.push_execution_context(settings_object.realm_execution_context());
|
||||
ScopeGuard pop_guard = [&] {
|
||||
VERIFY(&settings_object.realm_execution_context() == &vm.running_execution_context());
|
||||
vm.pop_execution_context();
|
||||
};
|
||||
// AD-HOC: An execution context is required for Promise creation hooks.
|
||||
HTML::TemporaryExecutionContext execution_context { document->relevant_settings_object() };
|
||||
|
||||
// 4. Let promise be a new Promise.
|
||||
auto promise_capability = WebIDL::create_promise(realm);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue