mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 04:37:22 +00:00
LibWeb: Add TrustedTypePolicy class
It is mostly a skeleton with no actual implementation.
This commit is contained in:
parent
a73c082f36
commit
90bcc16a7b
Notes:
github-actions[bot]
2025-08-11 11:23:39 +00:00
Author: https://github.com/tete17
Commit: 90bcc16a7b
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
8 changed files with 85 additions and 0 deletions
|
@ -897,6 +897,7 @@ set(SOURCES
|
|||
SVG/TagNames.cpp
|
||||
SVG/ViewBox.cpp
|
||||
TrustedTypes/TrustedHTML.cpp
|
||||
TrustedTypes/TrustedTypePolicy.cpp
|
||||
TrustedTypes/TrustedTypePolicyFactory.cpp
|
||||
UIEvents/CompositionEvent.cpp
|
||||
UIEvents/EventNames.cpp
|
||||
|
|
|
@ -1221,6 +1221,8 @@ ErrorOr<Web::UniqueNodeID> decode(Decoder&);
|
|||
namespace Web::TrustedTypes {
|
||||
|
||||
class TrustedHTML;
|
||||
class TrustedTypePolicy;
|
||||
class TrustedTypePolicyFactory;
|
||||
struct TrustedTypePolicyOptions;
|
||||
|
||||
}
|
||||
|
|
28
Libraries/LibWeb/TrustedTypes/TrustedTypePolicy.cpp
Normal file
28
Libraries/LibWeb/TrustedTypes/TrustedTypePolicy.cpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Miguel Sacristán Izcue <miguel_tete17@hotmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/TrustedTypes/TrustedTypePolicy.h>
|
||||
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
|
||||
namespace Web::TrustedTypes {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(TrustedTypePolicy);
|
||||
|
||||
TrustedTypePolicy::TrustedTypePolicy(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
}
|
||||
|
||||
void TrustedTypePolicy::initialize(JS::Realm& realm)
|
||||
{
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(TrustedTypePolicy);
|
||||
Base::initialize(realm);
|
||||
}
|
||||
|
||||
}
|
33
Libraries/LibWeb/TrustedTypes/TrustedTypePolicy.h
Normal file
33
Libraries/LibWeb/TrustedTypes/TrustedTypePolicy.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Miguel Sacristán Izcue <miguel_tete17@hotmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Bindings/TrustedTypePolicyPrototype.h>
|
||||
|
||||
namespace Web::TrustedTypes {
|
||||
|
||||
struct TrustedTypePolicyOptions {
|
||||
GC::Root<WebIDL::CallbackType> create_html;
|
||||
GC::Root<WebIDL::CallbackType> create_script;
|
||||
GC::Root<WebIDL::CallbackType> create_script_url;
|
||||
};
|
||||
|
||||
class TrustedTypePolicy final : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(TrustedTypePolicy, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(TrustedTypePolicy);
|
||||
|
||||
public:
|
||||
virtual ~TrustedTypePolicy() override = default;
|
||||
|
||||
private:
|
||||
explicit TrustedTypePolicy(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
18
Libraries/LibWeb/TrustedTypes/TrustedTypePolicy.idl
Normal file
18
Libraries/LibWeb/TrustedTypes/TrustedTypePolicy.idl
Normal file
|
@ -0,0 +1,18 @@
|
|||
// https://w3c.github.io/trusted-types/dist/spec/#trusted-type-policy
|
||||
[Exposed=(Window,Worker)]
|
||||
interface TrustedTypePolicy {
|
||||
[FIXME] readonly attribute DOMString name;
|
||||
[FIXME] TrustedHTML createHTML(DOMString input, any... arguments);
|
||||
[FIXME] TrustedScript createScript(DOMString input, any... arguments);
|
||||
[FIXME] TrustedScriptURL createScriptURL(DOMString input, any... arguments);
|
||||
};
|
||||
|
||||
// https://w3c.github.io/trusted-types/dist/spec/#trusted-type-policy-options
|
||||
dictionary TrustedTypePolicyOptions {
|
||||
CreateHTMLCallback createHTML;
|
||||
CreateScriptCallback createScript;
|
||||
CreateScriptURLCallback createScriptURL;
|
||||
};
|
||||
callback CreateHTMLCallback = DOMString? (DOMString input, any... arguments);
|
||||
callback CreateScriptCallback = DOMString? (DOMString input, any... arguments);
|
||||
callback CreateScriptURLCallback = USVString? (DOMString input, any... arguments);
|
|
@ -329,6 +329,7 @@ libweb_js_bindings(Streams/WritableStream)
|
|||
libweb_js_bindings(Streams/WritableStreamDefaultController)
|
||||
libweb_js_bindings(Streams/WritableStreamDefaultWriter)
|
||||
libweb_js_bindings(TrustedTypes/TrustedHTML)
|
||||
libweb_js_bindings(TrustedTypes/TrustedTypePolicy)
|
||||
libweb_js_bindings(TrustedTypes/TrustedTypePolicyFactory)
|
||||
libweb_js_bindings(SVG/SVGAElement)
|
||||
libweb_js_bindings(SVG/SVGAnimatedEnumeration)
|
||||
|
|
|
@ -117,6 +117,7 @@ static bool is_platform_object(Type const& type)
|
|||
"TextTrack"sv,
|
||||
"TimeRanges"sv,
|
||||
"TrustedHTML"sv,
|
||||
"TrustedTypePolicy"sv,
|
||||
"TrustedTypePolicyFactory"sv,
|
||||
"URLSearchParams"sv,
|
||||
"VTTRegion"sv,
|
||||
|
|
|
@ -433,6 +433,7 @@ TransformStreamDefaultController
|
|||
TransitionEvent
|
||||
TreeWalker
|
||||
TrustedHTML
|
||||
TrustedTypePolicy
|
||||
TrustedTypePolicyFactory
|
||||
TypeError
|
||||
UIEvent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue