mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +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
45
components/script/dom/trustedscripturl.rs
Normal file
45
components/script/dom/trustedscripturl.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::TrustedScriptURLBinding::TrustedScriptURLMethods;
|
||||
use crate::dom::bindings::reflector::{Reflector, reflect_dom_object};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::CanGc;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct TrustedScriptURL {
|
||||
reflector_: Reflector,
|
||||
|
||||
data: String,
|
||||
}
|
||||
|
||||
impl TrustedScriptURL {
|
||||
fn new_inherited(data: String) -> Self {
|
||||
Self {
|
||||
reflector_: Reflector::new(),
|
||||
data,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
|
||||
pub(crate) fn new(data: String, global: &GlobalScope, can_gc: CanGc) -> DomRoot<Self> {
|
||||
reflect_dom_object(Box::new(Self::new_inherited(data)), global, can_gc)
|
||||
}
|
||||
}
|
||||
|
||||
impl TrustedScriptURLMethods<crate::DomTypeHolder> for TrustedScriptURL {
|
||||
/// <https://www.w3.org/TR/trusted-types/#trustedscripturl-stringification-behavior>
|
||||
fn Stringifier(&self) -> DOMString {
|
||||
DOMString::from(&*self.data)
|
||||
}
|
||||
|
||||
/// <https://www.w3.org/TR/trusted-types/#dom-trustedscripturl-tojson>
|
||||
fn ToJSON(&self) -> DOMString {
|
||||
DOMString::from(&*self.data)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue