mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 20:26:53 +00:00
LibWeb: Implement is_html method for TrustedTypePolicyFactory
This is used to check the legitimacy of a TrustedHTML object.
This commit is contained in:
parent
0a147aa9a1
commit
a73c082f36
Notes:
github-actions[bot]
2025-08-11 11:23:45 +00:00
Author: https://github.com/tete17
Commit: a73c082f36
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5668
Reviewed-by: https://github.com/ADKaster
Reviewed-by: https://github.com/Lubrsi ✅
Reviewed-by: https://github.com/tcl3
3 changed files with 11 additions and 1 deletions
|
@ -15,6 +15,7 @@
|
|||
#include <LibWeb/HTML/WindowEventHandlers.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/SVG/TagNames.h>
|
||||
#include <LibWeb/TrustedTypes/TrustedHTML.h>
|
||||
|
||||
namespace Web::TrustedTypes {
|
||||
|
||||
|
@ -132,6 +133,13 @@ void TrustedTypePolicyFactory::initialize(JS::Realm& realm)
|
|||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#dom-trustedtypepolicyfactory-ishtml
|
||||
bool TrustedTypePolicyFactory::is_html(JS::Value value)
|
||||
{
|
||||
// 1. Returns true if value is an instance of TrustedHTML and has an associated data value set, false otherwise.
|
||||
return value.is_object() && is<TrustedHTML>(value.as_object());
|
||||
}
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#abstract-opdef-get-trusted-type-data-for-attribute
|
||||
Optional<TrustedTypeData> get_trusted_type_data_for_attribute(String const& element, String const& attribute, Optional<String> const& attribute_ns)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
|
||||
virtual ~TrustedTypePolicyFactory() override { }
|
||||
|
||||
bool is_html(JS::Value);
|
||||
|
||||
Optional<String> get_attribute_type(String const& tag_name, String& attribute, Optional<String> element_ns, Optional<String> attr_ns);
|
||||
Optional<String> get_property_type(String const& tag_name, String const& property, Optional<String> element_ns);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
interface TrustedTypePolicyFactory {
|
||||
[FIXME] TrustedTypePolicy createPolicy(
|
||||
DOMString policyName, optional TrustedTypePolicyOptions policyOptions = {});
|
||||
[FIXME] boolean isHTML(any value);
|
||||
boolean isHTML(any value);
|
||||
[FIXME] boolean isScript(any value);
|
||||
[FIXME] boolean isScriptURL(any value);
|
||||
[FIXME] readonly attribute TrustedHTML emptyHTML;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue