aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/workerglobalscope.rs
diff options
context:
space:
mode:
authorTim van der Lippe <TimvdLippe@users.noreply.github.com>2025-04-05 15:08:56 +0200
committerGitHub <noreply@github.com>2025-04-05 13:08:56 +0000
commitb87bf0b806a0dd21136faf04db47af4cb356922e (patch)
tree80dacf222d1ffe23ee626494a32aedcd638f8fb7 /components/script/dom/workerglobalscope.rs
parent3f24b44e1581af01a3fb51c031663d1dd99a790c (diff)
downloadservo-b87bf0b806a0dd21136faf04db47af4cb356922e.tar.gz
servo-b87bf0b806a0dd21136faf04db47af4cb356922e.zip
Stub out Trusted Types interfaces (#36355)
Some methods are implemented fully, while others are implemented partly. With these implementations, there are no observed crashes when running the trusted-types web-platform-tests. Most notably, the tests/wpt/tests/trusted-types/idlharness.window.js is now fully passing. Part of #36258 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Diffstat (limited to 'components/script/dom/workerglobalscope.rs')
-rw-r--r--components/script/dom/workerglobalscope.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 3937f8fbedb..7009f51e29a 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -52,6 +52,7 @@ use crate::dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
use crate::dom::globalscope::GlobalScope;
use crate::dom::performance::Performance;
use crate::dom::promise::Promise;
+use crate::dom::trustedtypepolicyfactory::TrustedTypePolicyFactory;
#[cfg(feature = "webgpu")]
use crate::dom::webgpu::identityhub::IdentityHub;
use crate::dom::window::{base64_atob, base64_btoa};
@@ -122,6 +123,7 @@ pub(crate) struct WorkerGlobalScope {
#[no_trace]
navigation_start: CrossProcessInstant,
performance: MutNullableDom<Performance>,
+ trusted_types: MutNullableDom<TrustedTypePolicyFactory>,
/// A [`TimerScheduler`] used to schedule timers for this [`WorkerGlobalScope`].
/// Timers are handled in the service worker event loop.
@@ -184,6 +186,7 @@ impl WorkerGlobalScope {
performance: Default::default(),
timer_scheduler: RefCell::default(),
insecure_requests_policy,
+ trusted_types: Default::default(),
}
}
@@ -477,6 +480,14 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope {
self.upcast::<GlobalScope>()
.structured_clone(cx, value, options, retval)
}
+
+ /// <https://www.w3.org/TR/trusted-types/#dom-windoworworkerglobalscope-trustedtypes>
+ fn TrustedTypes(&self, can_gc: CanGc) -> DomRoot<TrustedTypePolicyFactory> {
+ self.trusted_types.or_init(|| {
+ let global_scope = self.upcast::<GlobalScope>();
+ TrustedTypePolicyFactory::new(global_scope, can_gc)
+ })
+ }
}
impl WorkerGlobalScope {