mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
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>
This commit is contained in:
parent
3f24b44e15
commit
b87bf0b806
145 changed files with 3377 additions and 559 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue