File tree Expand file tree Collapse file tree 11 files changed +116
-0
lines changed
Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator
Tests/LibWeb/Text/expected Expand file tree Collapse file tree 11 files changed +116
-0
lines changed Original file line number Diff line number Diff line change @@ -878,6 +878,7 @@ set(SOURCES
878
878
SVG/SVGViewElement.cpp
879
879
SVG/TagNames.cpp
880
880
SVG/ViewBox.cpp
881
+ TrustedTypes/TrustedTypePolicyFactory.cpp
881
882
UIEvents/CompositionEvent.cpp
882
883
UIEvents/EventNames.cpp
883
884
UIEvents/FocusEvent.cpp
Original file line number Diff line number Diff line change @@ -1183,3 +1183,9 @@ template<>
1183
1183
ErrorOr<Web::UniqueNodeID> decode (Decoder&);
1184
1184
1185
1185
}
1186
+
1187
+ namespace Web ::TrustedTypes {
1188
+
1189
+ class TrustedTypePolicyFactory ;
1190
+
1191
+ }
Original file line number Diff line number Diff line change 43
43
#include < LibWeb/Platform/ImageCodecPlugin.h>
44
44
#include < LibWeb/ResourceTiming/PerformanceResourceTiming.h>
45
45
#include < LibWeb/ServiceWorker/CacheStorage.h>
46
+ #include < LibWeb/TrustedTypes/TrustedTypePolicyFactory.h>
46
47
#include < LibWeb/UserTiming/PerformanceMark.h>
47
48
#include < LibWeb/UserTiming/PerformanceMeasure.h>
48
49
#include < LibWeb/WebIDL/AbstractOperations.h>
@@ -82,6 +83,7 @@ void WindowOrWorkerGlobalScopeMixin::visit_edges(JS::Cell::Visitor& visitor)
82
83
visitor.visit (m_crypto);
83
84
visitor.visit (m_cache_storage);
84
85
visitor.visit (m_resource_timing_secondary_buffer);
86
+ visitor.visit (m_trusted_type_policy_factory);
85
87
}
86
88
87
89
void WindowOrWorkerGlobalScopeMixin::finalize ()
@@ -1122,4 +1124,15 @@ GC::Ref<ServiceWorker::CacheStorage> WindowOrWorkerGlobalScopeMixin::caches()
1122
1124
return GC::Ref { *m_cache_storage };
1123
1125
}
1124
1126
1127
+ // https://w3c.github.io/trusted-types/dist/spec/#extensions-to-the-windoworworkerglobalscope-interface
1128
+ GC::Ref<TrustedTypes::TrustedTypePolicyFactory> WindowOrWorkerGlobalScopeMixin::trusted_types ()
1129
+ {
1130
+ auto const & platform_object = this_impl ();
1131
+ auto & realm = platform_object.realm ();
1132
+
1133
+ if (!m_trusted_type_policy_factory)
1134
+ m_trusted_type_policy_factory = realm.create <TrustedTypes::TrustedTypePolicyFactory>(realm);
1135
+ return *m_trusted_type_policy_factory;
1136
+ }
1137
+
1125
1138
}
Original file line number Diff line number Diff line change @@ -103,6 +103,8 @@ class WindowOrWorkerGlobalScopeMixin {
103
103
104
104
[[nodiscard]] GC::Ref<ServiceWorker::CacheStorage> caches ();
105
105
106
+ [[nodiscard]] GC::Ref<TrustedTypes::TrustedTypePolicyFactory> trusted_types ();
107
+
106
108
protected:
107
109
void initialize (JS::Realm&);
108
110
void visit_edges (JS::Cell::Visitor&);
@@ -151,6 +153,8 @@ class WindowOrWorkerGlobalScopeMixin {
151
153
152
154
GC::Ptr<ServiceWorker::CacheStorage> m_cache_storage;
153
155
156
+ GC::Ptr<TrustedTypes::TrustedTypePolicyFactory> m_trusted_type_policy_factory;
157
+
154
158
bool m_error_reporting_mode { false };
155
159
156
160
WebSockets::WebSocket::List m_registered_web_sockets;
Original file line number Diff line number Diff line change 6
6
#import <HTML/MessagePort.idl>
7
7
#import <IndexedDB/IDBFactory.idl>
8
8
#import <ServiceWorker/CacheStorage.idl>
9
+ #import <TrustedTypes/TrustedTypePolicyFactory.idl>
9
10
10
11
// https://html.spec.whatwg.org/multipage/webappapis.html#timerhandler
11
12
typedef (DOMString or Function) TimerHandler;
@@ -43,4 +44,7 @@ interface mixin WindowOrWorkerGlobalScope {
43
44
44
45
// https://w3c.github.io/ServiceWorker/#cache-storage-interface
45
46
[SecureContext, SameObject] readonly attribute CacheStorage caches;
47
+
48
+ // https://w3c.github.io/trusted-types/dist/spec/#extensions-to-the-windoworworkerglobalscope-interface
49
+ readonly attribute TrustedTypePolicyFactory trustedTypes;
46
50
};
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2025, Miguel Sacristán Izcue <miguel_tete17@hotmail.com>
3
+ *
4
+ * SPDX-License-Identifier: BSD-2-Clause
5
+ */
6
+
7
+ #include < LibWeb/TrustedTypes/TrustedTypePolicyFactory.h>
8
+
9
+ #include < LibJS/Runtime/Realm.h>
10
+ #include < LibWeb/Bindings/Intrinsics.h>
11
+
12
+ namespace Web ::TrustedTypes {
13
+
14
+ GC_DEFINE_ALLOCATOR (TrustedTypePolicyFactory);
15
+
16
+ GC::Ref<TrustedTypePolicyFactory> TrustedTypePolicyFactory::create (JS::Realm& realm)
17
+ {
18
+ return realm.create <TrustedTypePolicyFactory>(realm);
19
+ }
20
+
21
+ TrustedTypePolicyFactory::TrustedTypePolicyFactory (JS::Realm& realm)
22
+ : PlatformObject(realm)
23
+ {
24
+ }
25
+
26
+ void TrustedTypePolicyFactory::initialize (JS::Realm& realm)
27
+ {
28
+ WEB_SET_PROTOTYPE_FOR_INTERFACE (TrustedTypePolicyFactory);
29
+ Base::initialize (realm);
30
+ }
31
+
32
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2025, Miguel Sacristán Izcue <miguel_tete17@hotmail.com>
3
+ *
4
+ * SPDX-License-Identifier: BSD-2-Clause
5
+ */
6
+
7
+ #pragma once
8
+
9
+ #include < LibJS/Forward.h>
10
+ #include < LibWeb/Bindings/PlatformObject.h>
11
+ #include < LibWeb/Bindings/TrustedTypePolicyFactoryPrototype.h>
12
+
13
+ namespace Web ::TrustedTypes {
14
+
15
+ class TrustedTypePolicyFactory final : public Bindings::PlatformObject {
16
+ WEB_PLATFORM_OBJECT (TrustedTypePolicyFactory, Bindings::PlatformObject);
17
+ GC_DECLARE_ALLOCATOR (TrustedTypePolicyFactory);
18
+
19
+ public:
20
+ [[nodiscard]] static GC::Ref<TrustedTypePolicyFactory> create (JS::Realm&);
21
+
22
+ virtual ~TrustedTypePolicyFactory () override { }
23
+
24
+ private:
25
+ explicit TrustedTypePolicyFactory (JS::Realm&);
26
+ virtual void initialize (JS::Realm&) override ;
27
+
28
+ Vector<String> m_created_policy_names;
29
+ };
30
+
31
+ }
Original file line number Diff line number Diff line change
1
+ // https://w3c.github.io/trusted-types/dist/spec/#trustedtypepolicyfactory
2
+ [Exposed=(Window,Worker)]
3
+ interface TrustedTypePolicyFactory {
4
+ [FIXME] TrustedTypePolicy createPolicy(
5
+ DOMString policyName, optional TrustedTypePolicyOptions policyOptions = {});
6
+ [FIXME] boolean isHTML(any value);
7
+ [FIXME] boolean isScript(any value);
8
+ [FIXME] boolean isScriptURL(any value);
9
+ [FIXME] readonly attribute TrustedHTML emptyHTML;
10
+ [FIXME] readonly attribute TrustedScript emptyScript;
11
+ [FIXME] DOMString? getAttributeType(
12
+ DOMString tagName,
13
+ DOMString attribute,
14
+ optional DOMString? elementNs = "",
15
+ optional DOMString? attrNs = "");
16
+ [FIXME] DOMString? getPropertyType(
17
+ DOMString tagName,
18
+ DOMString property,
19
+ optional DOMString? elementNs = "");
20
+ [FIXME] readonly attribute TrustedTypePolicy? defaultPolicy;
21
+ };
Original file line number Diff line number Diff line change @@ -324,6 +324,7 @@ libweb_js_bindings(Streams/TransformStreamDefaultController)
324
324
libweb_js_bindings(Streams/WritableStream)
325
325
libweb_js_bindings(Streams/WritableStreamDefaultController)
326
326
libweb_js_bindings(Streams/WritableStreamDefaultWriter)
327
+ libweb_js_bindings(TrustedTypes/TrustedTypePolicyFactory)
327
328
libweb_js_bindings(SVG/SVGAElement)
328
329
libweb_js_bindings(SVG/SVGAnimatedEnumeration)
329
330
libweb_js_bindings(SVG/SVGAnimatedLength)
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ static bool is_platform_object(Type const& type)
116
116
" TextMetrics" sv,
117
117
" TextTrack" sv,
118
118
" TimeRanges" sv,
119
+ " TrustedTypePolicyFactory" sv,
119
120
" URLSearchParams" sv,
120
121
" VTTRegion" sv,
121
122
" VideoTrack" sv,
@@ -4840,6 +4841,7 @@ using namespace Web::ServiceWorker;
4840
4841
using namespace Web::StorageAPI;
4841
4842
using namespace Web::Streams;
4842
4843
using namespace Web::SVG;
4844
+ using namespace Web::TrustedTypes;
4843
4845
using namespace Web::UIEvents;
4844
4846
using namespace Web::URLPattern;
4845
4847
using namespace Web::UserTiming;
You can’t perform that action at this time.
0 commit comments