mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
LibWeb: Add option to TemporaryExecutionContext to prepare for callbacks
In the cases where spec authors have us directly interact with promises in a task source context, we need to prepare the backup settings object stack as well as push an actual execution context to the JS VM.
This commit is contained in:
parent
2cd93e6b58
commit
1358fe85b0
3 changed files with 14 additions and 3 deletions
|
@ -1067,7 +1067,7 @@ bool Navigation::inner_navigate_event_firing_algorithm(
|
||||||
|
|
||||||
// 31. Prepare to run script given navigation's relevant settings object.
|
// 31. Prepare to run script given navigation's relevant settings object.
|
||||||
// NOTE: There's a massive spec note here
|
// NOTE: There's a massive spec note here
|
||||||
TemporaryExecutionContext execution_context { relevant_settings_object(*this) };
|
TemporaryExecutionContext execution_context { relevant_settings_object(*this), TemporaryExecutionContext::CallbacksEnabled::Yes };
|
||||||
|
|
||||||
// 32. If event's interception state is not "none":
|
// 32. If event's interception state is not "none":
|
||||||
if (event->interception_state() != NavigateEvent::InterceptionState::None) {
|
if (event->interception_state() != NavigateEvent::InterceptionState::None) {
|
||||||
|
|
|
@ -9,15 +9,20 @@
|
||||||
|
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject& environment_settings)
|
TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject& environment_settings, CallbacksEnabled callbacks_enabled)
|
||||||
: m_environment_settings(environment_settings)
|
: m_environment_settings(environment_settings)
|
||||||
|
, m_callbacks_enabled(callbacks_enabled)
|
||||||
{
|
{
|
||||||
m_environment_settings.prepare_to_run_script();
|
m_environment_settings.prepare_to_run_script();
|
||||||
|
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
||||||
|
m_environment_settings.prepare_to_run_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
TemporaryExecutionContext::~TemporaryExecutionContext()
|
TemporaryExecutionContext::~TemporaryExecutionContext()
|
||||||
{
|
{
|
||||||
m_environment_settings.clean_up_after_running_script();
|
m_environment_settings.clean_up_after_running_script();
|
||||||
|
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
||||||
|
m_environment_settings.clean_up_after_running_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,17 @@ namespace Web::HTML {
|
||||||
// this is a workaround to temporarily push an execution context.
|
// this is a workaround to temporarily push an execution context.
|
||||||
class TemporaryExecutionContext {
|
class TemporaryExecutionContext {
|
||||||
public:
|
public:
|
||||||
explicit TemporaryExecutionContext(EnvironmentSettingsObject&);
|
enum class CallbacksEnabled {
|
||||||
|
No,
|
||||||
|
Yes,
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit TemporaryExecutionContext(EnvironmentSettingsObject&, CallbacksEnabled = CallbacksEnabled::No);
|
||||||
~TemporaryExecutionContext();
|
~TemporaryExecutionContext();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EnvironmentSettingsObject& m_environment_settings;
|
EnvironmentSettingsObject& m_environment_settings;
|
||||||
|
CallbacksEnabled m_callbacks_enabled { CallbacksEnabled::No };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue