mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
LibWeb: Implement module type allowed
This patch adds the module type allowed steps given a module type string and an environment settings object.
This commit is contained in:
parent
297e293a3f
commit
cfa0c9bf9f
2 changed files with 16 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||||
|
* Copyright (c) 2022, networkException <networkexception@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -266,6 +267,19 @@ bool EnvironmentSettingsObject::is_scripting_disabled() const
|
||||||
return !is_scripting_enabled();
|
return !is_scripting_enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/webappapis.html#module-type-allowed
|
||||||
|
bool EnvironmentSettingsObject::module_type_allowed(AK::String const& module_type) const
|
||||||
|
{
|
||||||
|
// 1. If moduleType is not "javascript", "css", or "json", then return false.
|
||||||
|
if (module_type != "javascript"sv && module_type != "css"sv && module_type != "json"sv)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// FIXME: 2. If moduleType is "css" and the CSSStyleSheet interface is not exposed in settings's Realm, then return false.
|
||||||
|
|
||||||
|
// 3. Return true.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object
|
// https://html.spec.whatwg.org/multipage/webappapis.html#incumbent-settings-object
|
||||||
EnvironmentSettingsObject& incumbent_settings_object()
|
EnvironmentSettingsObject& incumbent_settings_object()
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,8 @@ struct EnvironmentSettingsObject
|
||||||
bool is_scripting_enabled() const;
|
bool is_scripting_enabled() const;
|
||||||
bool is_scripting_disabled() const;
|
bool is_scripting_disabled() const;
|
||||||
|
|
||||||
|
bool module_type_allowed(String const& module_type) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit EnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext>);
|
explicit EnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue