LibWeb: Implement whether scripting is disabled based on a realm

Instead of a settings object. This matches updates to the HTML spec as
part of the shadow realm proposal, and begins the refactor of running
scripts on a realm instead of a settings environment object.

Some of the spec steps are slightly messy here (such as in
MainThreadVM.cpp) as this partially implements the ShadowRealm changes
but not other pieces which we have not implemented yet, such as
preparing to run a script also being based on a realm instead of an
environment. But this will be addressed in further commits.
This commit is contained in:
Shannon Booth 2024-10-21 14:24:06 +13:00 committed by Andrew Kaster
commit aef18435fb
Notes: github-actions[bot] 2024-11-01 19:16:37 +00:00
6 changed files with 66 additions and 54 deletions

View file

@ -94,16 +94,12 @@ public:
// https://fetch.spec.whatwg.org/#concept-fetch-group
Vector<JS::NonnullGCPtr<Fetch::Infrastructure::FetchRecord>>& fetch_group() { return m_fetch_group; }
RunScriptDecision can_run_script();
void prepare_to_run_script();
void clean_up_after_running_script();
void prepare_to_run_callback();
void clean_up_after_running_callback();
bool is_scripting_enabled() const;
bool is_scripting_disabled() const;
bool module_type_allowed(StringView module_type) const;
void disallow_further_import_maps();
@ -139,6 +135,10 @@ private:
bool m_discarded { false };
};
RunScriptDecision can_run_script(JS::Realm const&);
bool is_scripting_enabled(JS::Realm const&);
bool is_scripting_disabled(JS::Realm const&);
EnvironmentSettingsObject& incumbent_settings_object();
JS::Realm& incumbent_realm();
JS::Object& incumbent_global_object();