summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-09-17 18:11:06 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-06 16:41:36 +0200
commitcfa0c9bf9f9477a9ac6102773d96209caa0c3832 (patch)
tree5850c704885c5e9b37ba9bf7ed5415213f26d46f /Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
parent297e293a3f08f07bc1a458ea4f9fefb9a34926b3 (diff)
downloadserenity-cfa0c9bf9f9477a9ac6102773d96209caa0c3832.zip
LibWeb: Implement module type allowed
This patch adds the module type allowed steps given a module type string and an environment settings object.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
index 06f5d4c490..961bc39459 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Environments.cpp
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2022, networkException <networkexception@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -266,6 +267,19 @@ bool EnvironmentSettingsObject::is_scripting_disabled() const
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
EnvironmentSettingsObject& incumbent_settings_object()
{