aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/testbinding.rs
diff options
context:
space:
mode:
authoryvt <i@yvt.jp>2021-07-10 17:24:27 +0900
committeryvt <i@yvt.jp>2021-07-10 17:55:42 +0900
commit01a7de50ab1843d85295f9dccad7f4c099e7208c (patch)
treeee53fb6e8889deb7b880ee969e6c662e6128d210 /components/script/dom/testbinding.rs
parentff8d2cdbbfc7a9dc7f38b7dd47cb350fde39388f (diff)
parent94b613fbdaa2b98f2179fc0bbda13c64e6fa0d38 (diff)
downloadservo-01a7de50ab1843d85295f9dccad7f4c099e7208c.tar.gz
servo-01a7de50ab1843d85295f9dccad7f4c099e7208c.zip
Merge remote-tracking branch 'upstream/master' into feat-cow-infra
`tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` was reverted to the upstream version.
Diffstat (limited to 'components/script/dom/testbinding.rs')
-rw-r--r--components/script/dom/testbinding.rs896
1 files changed, 606 insertions, 290 deletions
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index f08629c3861..34c25c40449 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -1,49 +1,73 @@
/* 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 http://mozilla.org/MPL/2.0/. */
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
// check-tidy: no specs after this line
-use core::nonzero::NonZero;
-use dom::bindings::callback::ExceptionHandling;
-use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
-use dom::bindings::codegen::Bindings::FunctionBinding::Function;
-use dom::bindings::codegen::Bindings::TestBindingBinding::{self, SimpleCallback};
-use dom::bindings::codegen::Bindings::TestBindingBinding::{TestBindingMethods, TestDictionary};
-use dom::bindings::codegen::Bindings::TestBindingBinding::{TestDictionaryDefaults, TestEnum};
-use dom::bindings::codegen::UnionTypes;
-use dom::bindings::codegen::UnionTypes::{BlobOrBoolean, BlobOrBlobSequence, LongOrLongSequenceSequence};
-use dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString};
-use dom::bindings::codegen::UnionTypes::{ByteStringOrLong, ByteStringSequenceOrLongOrString};
-use dom::bindings::codegen::UnionTypes::{ByteStringSequenceOrLong, DocumentOrTestTypedef};
-use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong, LongSequenceOrTestTypedef};
-use dom::bindings::codegen::UnionTypes::{HTMLElementOrUnsignedLongOrStringOrBoolean, LongSequenceOrBoolean};
-use dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence, StringSequenceOrUnsignedLong};
-use dom::bindings::codegen::UnionTypes::{StringOrUnsignedLong, StringOrBoolean, UnsignedLongOrBoolean};
-use dom::bindings::error::{Error, Fallible};
-use dom::bindings::js::Root;
-use dom::bindings::mozmap::MozMap;
-use dom::bindings::num::Finite;
-use dom::bindings::refcounted::TrustedPromise;
-use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object};
-use dom::bindings::str::{ByteString, DOMString, USVString};
-use dom::bindings::trace::RootedTraceableBox;
-use dom::bindings::weakref::MutableWeakRef;
-use dom::blob::{Blob, BlobImpl};
-use dom::globalscope::GlobalScope;
-use dom::promise::Promise;
-use dom::promisenativehandler::{PromiseNativeHandler, Callback};
-use dom::url::URL;
+use crate::dom::bindings::callback::ExceptionHandling;
+use crate::dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
+use crate::dom::bindings::codegen::Bindings::FunctionBinding::Function;
+use crate::dom::bindings::codegen::Bindings::TestBindingBinding::SimpleCallback;
+use crate::dom::bindings::codegen::Bindings::TestBindingBinding::TestDictionaryParent;
+use crate::dom::bindings::codegen::Bindings::TestBindingBinding::TestDictionaryWithParent;
+use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{
+ TestBindingMethods, TestDictionary,
+};
+use crate::dom::bindings::codegen::Bindings::TestBindingBinding::{
+ TestDictionaryDefaults, TestEnum, TestURLLike,
+};
+use crate::dom::bindings::codegen::UnionTypes;
+use crate::dom::bindings::codegen::UnionTypes::{
+ BlobOrBlobSequence, BlobOrBoolean, LongOrLongSequenceSequence,
+};
+use crate::dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString};
+use crate::dom::bindings::codegen::UnionTypes::{
+ ByteStringOrLong, ByteStringSequenceOrLongOrString,
+};
+use crate::dom::bindings::codegen::UnionTypes::{ByteStringSequenceOrLong, DocumentOrTestTypedef};
+use crate::dom::bindings::codegen::UnionTypes::{
+ EventOrUSVString, HTMLElementOrLong, LongSequenceOrTestTypedef,
+};
+use crate::dom::bindings::codegen::UnionTypes::{
+ HTMLElementOrUnsignedLongOrStringOrBoolean, LongSequenceOrBoolean,
+};
+use crate::dom::bindings::codegen::UnionTypes::{StringOrBoolean, UnsignedLongOrBoolean};
+use crate::dom::bindings::codegen::UnionTypes::{StringOrLongSequence, StringOrStringSequence};
+use crate::dom::bindings::codegen::UnionTypes::{
+ StringOrUnsignedLong, StringSequenceOrUnsignedLong,
+};
+use crate::dom::bindings::error::{Error, Fallible};
+use crate::dom::bindings::num::Finite;
+use crate::dom::bindings::record::Record;
+use crate::dom::bindings::refcounted::TrustedPromise;
+use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::bindings::str::{ByteString, DOMString, USVString};
+use crate::dom::bindings::trace::RootedTraceableBox;
+use crate::dom::bindings::weakref::MutableWeakRef;
+use crate::dom::blob::Blob;
+use crate::dom::globalscope::GlobalScope;
+use crate::dom::node::Node;
+use crate::dom::promise::Promise;
+use crate::dom::promisenativehandler::{Callback, PromiseNativeHandler};
+use crate::dom::url::URL;
+use crate::realms::InRealm;
+use crate::script_runtime::JSContext as SafeJSContext;
+use crate::timers::OneshotTimerCallback;
use dom_struct::dom_struct;
-use js::jsapi::{HandleObject, HandleValue, Heap, JSContext, JSObject, JSAutoCompartment};
+use js::jsapi::{Heap, JSObject};
use js::jsapi::{JS_NewPlainObject, JS_NewUint8ClampedArray};
use js::jsval::{JSVal, NullValue};
+use js::rust::CustomAutoRooterGuard;
+use js::rust::{HandleObject, HandleValue};
+use js::typedarray;
+use script_traits::serializable::BlobImpl;
use script_traits::MsDuration;
-use servo_config::prefs::PREFS;
+use servo_config::prefs;
use std::borrow::ToOwned;
use std::ptr;
+use std::ptr::NonNull;
use std::rc::Rc;
-use timers::OneshotTimerCallback;
#[dom_struct]
pub struct TestBinding {
@@ -51,6 +75,7 @@ pub struct TestBinding {
url: MutableWeakRef<URL>,
}
+#[allow(non_snake_case)]
impl TestBinding {
fn new_inherited() -> TestBinding {
TestBinding {
@@ -59,68 +84,108 @@ impl TestBinding {
}
}
- pub fn new(global: &GlobalScope) -> Root<TestBinding> {
- reflect_dom_object(box TestBinding::new_inherited(),
- global, TestBindingBinding::Wrap)
+ pub fn new(global: &GlobalScope) -> DomRoot<TestBinding> {
+ reflect_dom_object(Box::new(TestBinding::new_inherited()), global)
}
- pub fn Constructor(global: &GlobalScope) -> Fallible<Root<TestBinding>> {
+ pub fn Constructor(global: &GlobalScope) -> Fallible<DomRoot<TestBinding>> {
Ok(TestBinding::new(global))
}
#[allow(unused_variables)]
- pub fn Constructor_(global: &GlobalScope, nums: Vec<f64>) -> Fallible<Root<TestBinding>> {
+ pub fn Constructor_(global: &GlobalScope, nums: Vec<f64>) -> Fallible<DomRoot<TestBinding>> {
Ok(TestBinding::new(global))
}
#[allow(unused_variables)]
- pub fn Constructor__(global: &GlobalScope, num: f64) -> Fallible<Root<TestBinding>> {
+ pub fn Constructor__(global: &GlobalScope, num: f64) -> Fallible<DomRoot<TestBinding>> {
Ok(TestBinding::new(global))
}
}
impl TestBindingMethods for TestBinding {
- fn BooleanAttribute(&self) -> bool { false }
+ fn BooleanAttribute(&self) -> bool {
+ false
+ }
fn SetBooleanAttribute(&self, _: bool) {}
- fn ByteAttribute(&self) -> i8 { 0 }
+ fn ByteAttribute(&self) -> i8 {
+ 0
+ }
fn SetByteAttribute(&self, _: i8) {}
- fn OctetAttribute(&self) -> u8 { 0 }
+ fn OctetAttribute(&self) -> u8 {
+ 0
+ }
fn SetOctetAttribute(&self, _: u8) {}
- fn ShortAttribute(&self) -> i16 { 0 }
+ fn ShortAttribute(&self) -> i16 {
+ 0
+ }
fn SetShortAttribute(&self, _: i16) {}
- fn UnsignedShortAttribute(&self) -> u16 { 0 }
+ fn UnsignedShortAttribute(&self) -> u16 {
+ 0
+ }
fn SetUnsignedShortAttribute(&self, _: u16) {}
- fn LongAttribute(&self) -> i32 { 0 }
+ fn LongAttribute(&self) -> i32 {
+ 0
+ }
fn SetLongAttribute(&self, _: i32) {}
- fn UnsignedLongAttribute(&self) -> u32 { 0 }
+ fn UnsignedLongAttribute(&self) -> u32 {
+ 0
+ }
fn SetUnsignedLongAttribute(&self, _: u32) {}
- fn LongLongAttribute(&self) -> i64 { 0 }
+ fn LongLongAttribute(&self) -> i64 {
+ 0
+ }
fn SetLongLongAttribute(&self, _: i64) {}
- fn UnsignedLongLongAttribute(&self) -> u64 { 0 }
+ fn UnsignedLongLongAttribute(&self) -> u64 {
+ 0
+ }
fn SetUnsignedLongLongAttribute(&self, _: u64) {}
- fn UnrestrictedFloatAttribute(&self) -> f32 { 0. }
+ fn UnrestrictedFloatAttribute(&self) -> f32 {
+ 0.
+ }
fn SetUnrestrictedFloatAttribute(&self, _: f32) {}
- fn FloatAttribute(&self) -> Finite<f32> { Finite::wrap(0.) }
+ fn FloatAttribute(&self) -> Finite<f32> {
+ Finite::wrap(0.)
+ }
fn SetFloatAttribute(&self, _: Finite<f32>) {}
- fn UnrestrictedDoubleAttribute(&self) -> f64 { 0. }
+ fn UnrestrictedDoubleAttribute(&self) -> f64 {
+ 0.
+ }
fn SetUnrestrictedDoubleAttribute(&self, _: f64) {}
- fn DoubleAttribute(&self) -> Finite<f64> { Finite::wrap(0.) }
+ fn DoubleAttribute(&self) -> Finite<f64> {
+ Finite::wrap(0.)
+ }
fn SetDoubleAttribute(&self, _: Finite<f64>) {}
- fn StringAttribute(&self) -> DOMString { DOMString::new() }
+ fn StringAttribute(&self) -> DOMString {
+ DOMString::new()
+ }
fn SetStringAttribute(&self, _: DOMString) {}
- fn UsvstringAttribute(&self) -> USVString { USVString("".to_owned()) }
+ fn UsvstringAttribute(&self) -> USVString {
+ USVString("".to_owned())
+ }
fn SetUsvstringAttribute(&self, _: USVString) {}
- fn ByteStringAttribute(&self) -> ByteString { ByteString::new(vec!()) }
+ fn ByteStringAttribute(&self) -> ByteString {
+ ByteString::new(vec![])
+ }
fn SetByteStringAttribute(&self, _: ByteString) {}
- fn EnumAttribute(&self) -> TestEnum { TestEnum::_empty }
+ fn EnumAttribute(&self) -> TestEnum {
+ TestEnum::_empty
+ }
fn SetEnumAttribute(&self, _: TestEnum) {}
- fn InterfaceAttribute(&self) -> Root<Blob> {
- Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
+ fn InterfaceAttribute(&self) -> DomRoot<Blob> {
+ Blob::new(
+ &self.global(),
+ BlobImpl::new_from_bytes(vec![], "".to_owned()),
+ )
}
fn SetInterfaceAttribute(&self, _: &Blob) {}
- fn UnionAttribute(&self) -> HTMLElementOrLong { HTMLElementOrLong::Long(0) }
+ fn UnionAttribute(&self) -> HTMLElementOrLong {
+ HTMLElementOrLong::Long(0)
+ }
fn SetUnionAttribute(&self, _: HTMLElementOrLong) {}
- fn Union2Attribute(&self) -> EventOrString { EventOrString::String(DOMString::new()) }
+ fn Union2Attribute(&self) -> EventOrString {
+ EventOrString::String(DOMString::new())
+ }
fn SetUnion2Attribute(&self, _: EventOrString) {}
fn Union3Attribute(&self) -> EventOrUSVString {
EventOrUSVString::USVString(USVString("".to_owned()))
@@ -147,82 +212,128 @@ impl TestBindingMethods for TestBinding {
}
fn SetUnion8Attribute(&self, _: BlobOrUnsignedLong) {}
fn Union9Attribute(&self) -> ByteStringOrLong {
- ByteStringOrLong::ByteString(ByteString::new(vec!()))
+ ByteStringOrLong::ByteString(ByteString::new(vec![]))
}
fn SetUnion9Attribute(&self, _: ByteStringOrLong) {}
#[allow(unsafe_code)]
- unsafe fn ArrayAttribute(&self, cx: *mut JSContext) -> NonZero<*mut JSObject> {
- rooted!(in(cx) let array = JS_NewUint8ClampedArray(cx, 16));
- assert!(!array.is_null());
- NonZero::new(array.get())
+ fn ArrayAttribute(&self, cx: SafeJSContext) -> NonNull<JSObject> {
+ unsafe {
+ rooted!(in(*cx) let array = JS_NewUint8ClampedArray(*cx, 16));
+ NonNull::new(array.get()).expect("got a null pointer")
+ }
}
- #[allow(unsafe_code)]
- unsafe fn AnyAttribute(&self, _: *mut JSContext) -> JSVal { NullValue() }
- #[allow(unsafe_code)]
- unsafe fn SetAnyAttribute(&self, _: *mut JSContext, _: HandleValue) {}
- #[allow(unsafe_code)]
- unsafe fn ObjectAttribute(&self, cx: *mut JSContext) -> NonZero<*mut JSObject> {
- rooted!(in(cx) let obj = JS_NewPlainObject(cx));
- assert!(!obj.is_null());
- NonZero::new(obj.get())
+ fn AnyAttribute(&self, _: SafeJSContext) -> JSVal {
+ NullValue()
}
+ fn SetAnyAttribute(&self, _: SafeJSContext, _: HandleValue) {}
#[allow(unsafe_code)]
- unsafe fn SetObjectAttribute(&self, _: *mut JSContext, _: *mut JSObject) {}
+ fn ObjectAttribute(&self, cx: SafeJSContext) -> NonNull<JSObject> {
+ unsafe {
+ rooted!(in(*cx) let obj = JS_NewPlainObject(*cx));
+ NonNull::new(obj.get()).expect("got a null pointer")
+ }
+ }
+ fn SetObjectAttribute(&self, _: SafeJSContext, _: *mut JSObject) {}
- fn GetBooleanAttributeNullable(&self) -> Option<bool> { Some(false) }
+ fn GetBooleanAttributeNullable(&self) -> Option<bool> {
+ Some(false)
+ }
fn SetBooleanAttributeNullable(&self, _: Option<bool>) {}
- fn GetByteAttributeNullable(&self) -> Option<i8> { Some(0) }
+ fn GetByteAttributeNullable(&self) -> Option<i8> {
+ Some(0)
+ }
fn SetByteAttributeNullable(&self, _: Option<i8>) {}
- fn GetOctetAttributeNullable(&self) -> Option<u8> { Some(0) }
+ fn GetOctetAttributeNullable(&self) -> Option<u8> {
+ Some(0)
+ }
fn SetOctetAttributeNullable(&self, _: Option<u8>) {}
- fn GetShortAttributeNullable(&self) -> Option<i16> { Some(0) }
+ fn GetShortAttributeNullable(&self) -> Option<i16> {
+ Some(0)
+ }
fn SetShortAttributeNullable(&self, _: Option<i16>) {}
- fn GetUnsignedShortAttributeNullable(&self) -> Option<u16> { Some(0) }
+ fn GetUnsignedShortAttributeNullable(&self) -> Option<u16> {
+ Some(0)
+ }
fn SetUnsignedShortAttributeNullable(&self, _: Option<u16>) {}
- fn GetLongAttributeNullable(&self) -> Option<i32> { Some(0) }
+ fn GetLongAttributeNullable(&self) -> Option<i32> {
+ Some(0)
+ }
fn SetLongAttributeNullable(&self, _: Option<i32>) {}
- fn GetUnsignedLongAttributeNullable(&self) -> Option<u32> { Some(0) }
+ fn GetUnsignedLongAttributeNullable(&self) -> Option<u32> {
+ Some(0)
+ }
fn SetUnsignedLongAttributeNullable(&self, _: Option<u32>) {}
- fn GetLongLongAttributeNullable(&self) -> Option<i64> { Some(0) }
+ fn GetLongLongAttributeNullable(&self) -> Option<i64> {
+ Some(0)
+ }
fn SetLongLongAttributeNullable(&self, _: Option<i64>) {}
- fn GetUnsignedLongLongAttributeNullable(&self) -> Option<u64> { Some(0) }
+ fn GetUnsignedLongLongAttributeNullable(&self) -> Option<u64> {
+ Some(0)
+ }
fn SetUnsignedLongLongAttributeNullable(&self, _: Option<u64>) {}
- fn GetUnrestrictedFloatAttributeNullable(&self) -> Option<f32> { Some(0.) }
+ fn GetUnrestrictedFloatAttributeNullable(&self) -> Option<f32> {
+ Some(0.)
+ }
fn SetUnrestrictedFloatAttributeNullable(&self, _: Option<f32>) {}
- fn GetFloatAttributeNullable(&self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
+ fn GetFloatAttributeNullable(&self) -> Option<Finite<f32>> {
+ Some(Finite::wrap(0.))
+ }
fn SetFloatAttributeNullable(&self, _: Option<Finite<f32>>) {}
- fn GetUnrestrictedDoubleAttributeNullable(&self) -> Option<f64> { Some(0.) }
+ fn GetUnrestrictedDoubleAttributeNullable(&self) -> Option<f64> {
+ Some(0.)
+ }
fn SetUnrestrictedDoubleAttributeNullable(&self, _: Option<f64>) {}
- fn GetDoubleAttributeNullable(&self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
+ fn GetDoubleAttributeNullable(&self) -> Option<Finite<f64>> {
+ Some(Finite::wrap(0.))
+ }
fn SetDoubleAttributeNullable(&self, _: Option<Finite<f64>>) {}
- fn GetByteStringAttributeNullable(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
+ fn GetByteStringAttributeNullable(&self) -> Option<ByteString> {
+ Some(ByteString::new(vec![]))
+ }
fn SetByteStringAttributeNullable(&self, _: Option<ByteString>) {}
- fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some(DOMString::new()) }
+ fn GetStringAttributeNullable(&self) -> Option<DOMString> {
+ Some(DOMString::new())
+ }
fn SetStringAttributeNullable(&self, _: Option<DOMString>) {}
- fn GetUsvstringAttributeNullable(&self) -> Option<USVString> { Some(USVString("".to_owned())) }
+ fn GetUsvstringAttributeNullable(&self) -> Option<USVString> {
+ Some(USVString("".to_owned()))
+ }
fn SetUsvstringAttributeNullable(&self, _: Option<USVString>) {}
fn SetBinaryRenamedAttribute(&self, _: DOMString) {}
- fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) }
- fn BinaryRenamedAttribute(&self) -> DOMString { DOMString::new() }
+ fn ForwardedAttribute(&self) -> DomRoot<TestBinding> {
+ DomRoot::from_ref(self)
+ }
+ fn BinaryRenamedAttribute(&self) -> DOMString {
+ DOMString::new()
+ }
fn SetBinaryRenamedAttribute2(&self, _: DOMString) {}
- fn BinaryRenamedAttribute2(&self) -> DOMString { DOMString::new() }
- fn Attr_to_automatically_rename(&self) -> DOMString { DOMString::new() }
+ fn BinaryRenamedAttribute2(&self) -> DOMString {
+ DOMString::new()
+ }
+ fn Attr_to_automatically_rename(&self) -> DOMString {
+ DOMString::new()
+ }
fn SetAttr_to_automatically_rename(&self, _: DOMString) {}
- fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
- fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
- Some(Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
+ fn GetEnumAttributeNullable(&self) -> Option<TestEnum> {
+ Some(TestEnum::_empty)
+ }
+ fn GetInterfaceAttributeNullable(&self) -> Option<DomRoot<Blob>> {
+ Some(Blob::new(
+ &self.global(),
+ BlobImpl::new_from_bytes(vec![], "".to_owned()),
+ ))
}
fn SetInterfaceAttributeNullable(&self, _: Option<&Blob>) {}
- fn GetInterfaceAttributeWeak(&self) -> Option<Root<URL>> {
+ fn GetInterfaceAttributeWeak(&self) -> Option<DomRoot<URL>> {
self.url.root()
}
fn SetInterfaceAttributeWeak(&self, url: Option<&URL>) {
self.url.set(url);
}
- #[allow(unsafe_code)]
- unsafe fn GetObjectAttributeNullable(&self, _: *mut JSContext) -> Option<NonZero<*mut JSObject>> { None }
- #[allow(unsafe_code)]
- unsafe fn SetObjectAttributeNullable(&self, _: *mut JSContext, _: *mut JSObject) {}
+ fn GetObjectAttributeNullable(&self, _: SafeJSContext) -> Option<NonNull<JSObject>> {
+ None
+ }
+ fn SetObjectAttributeNullable(&self, _: SafeJSContext, _: *mut JSObject) {}
fn GetUnionAttributeNullable(&self) -> Option<HTMLElementOrLong> {
Some(HTMLElementOrLong::Long(0))
}
@@ -244,79 +355,182 @@ impl TestBindingMethods for TestBinding {
}
fn SetUnion5AttributeNullable(&self, _: Option<StringOrBoolean>) {}
fn GetUnion6AttributeNullable(&self) -> Option<ByteStringOrLong> {
- Some(ByteStringOrLong::ByteString(ByteString::new(vec!())))
+ Some(ByteStringOrLong::ByteString(ByteString::new(vec![])))
}
fn SetUnion6AttributeNullable(&self, _: Option<ByteStringOrLong>) {}
fn BinaryRenamedMethod(&self) {}
fn ReceiveVoid(&self) {}
- fn ReceiveBoolean(&self) -> bool { false }
- fn ReceiveByte(&self) -> i8 { 0 }
- fn ReceiveOctet(&self) -> u8 { 0 }
- fn ReceiveShort(&self) -> i16 { 0 }
- fn ReceiveUnsignedShort(&self) -> u16 { 0 }
- fn ReceiveLong(&self) -> i32 { 0 }
- fn ReceiveUnsignedLong(&self) -> u32 { 0 }
- fn ReceiveLongLong(&self) -> i64 { 0 }
- fn ReceiveUnsignedLongLong(&self) -> u64 { 0 }
- fn ReceiveUnrestrictedFloat(&self) -> f32 { 0. }
- fn ReceiveFloat(&self) -> Finite<f32> { Finite::wrap(0.) }
- fn ReceiveUnrestrictedDouble(&self) -> f64 { 0. }
- fn ReceiveDouble(&self) -> Finite<f64> { Finite::wrap(0.) }
- fn ReceiveString(&self) -> DOMString { DOMString::new() }
- fn ReceiveUsvstring(&self) -> USVString { USVString("".to_owned()) }
- fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
- fn ReceiveEnum(&self) -> TestEnum { TestEnum::_empty }
- fn ReceiveInterface(&self) -> Root<Blob> {
- Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())
+ fn ReceiveBoolean(&self) -> bool {
+ false
}
- #[allow(unsafe_code)]
- unsafe fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
- #[allow(unsafe_code)]
- unsafe fn ReceiveObject(&self, cx: *mut JSContext) -> NonZero<*mut JSObject> {
+ fn ReceiveByte(&self) -> i8 {
+ 0
+ }
+ fn ReceiveOctet(&self) -> u8 {
+ 0
+ }
+ fn ReceiveShort(&self) -> i16 {
+ 0
+ }
+ fn ReceiveUnsignedShort(&self) -> u16 {
+ 0
+ }
+ fn ReceiveLong(&self) -> i32 {
+ 0
+ }
+ fn ReceiveUnsignedLong(&self) -> u32 {
+ 0
+ }
+ fn ReceiveLongLong(&self) -> i64 {
+ 0
+ }
+ fn ReceiveUnsignedLongLong(&self) -> u64 {
+ 0
+ }
+ fn ReceiveUnrestrictedFloat(&self) -> f32 {
+ 0.
+ }
+ fn ReceiveFloat(&self) -> Finite<f32> {
+ Finite::wrap(0.)
+ }
+ fn ReceiveUnrestrictedDouble(&self) -> f64 {
+ 0.
+ }
+ fn ReceiveDouble(&self) -> Finite<f64> {
+ Finite::wrap(0.)
+ }
+ fn ReceiveString(&self) -> DOMString {
+ DOMString::new()
+ }
+ fn ReceiveUsvstring(&self) -> USVString {
+ USVString("".to_owned())
+ }
+ fn ReceiveByteString(&self) -> ByteString {
+ ByteString::new(vec![])
+ }
+ fn ReceiveEnum(&self) -> TestEnum {
+ TestEnum::_empty
+ }
+ fn ReceiveInterface(&self) -> DomRoot<Blob> {
+ Blob::new(
+ &self.global(),
+ BlobImpl::new_from_bytes(vec![], "".to_owned()),
+ )
+ }
+ fn ReceiveAny(&self, _: SafeJSContext) -> JSVal {
+ NullValue()
+ }
+ fn ReceiveObject(&self, cx: SafeJSContext) -> NonNull<JSObject> {
self.ObjectAttribute(cx)
}
- fn ReceiveUnion(&self) -> HTMLElementOrLong { HTMLElementOrLong::Long(0) }
- fn ReceiveUnion2(&self) -> EventOrString { EventOrString::String(DOMString::new()) }
- fn ReceiveUnion3(&self) -> StringOrLongSequence { StringOrLongSequence::LongSequence(vec![]) }
- fn ReceiveUnion4(&self) -> StringOrStringSequence { StringOrStringSequence::StringSequence(vec![]) }
- fn ReceiveUnion5(&self) -> BlobOrBlobSequence { BlobOrBlobSequence::BlobSequence(vec![]) }
- fn ReceiveUnion6(&self) -> StringOrUnsignedLong { StringOrUnsignedLong::String(DOMString::new()) }
- fn ReceiveUnion7(&self) -> StringOrBoolean { StringOrBoolean::Boolean(true) }
- fn ReceiveUnion8(&self) -> UnsignedLongOrBoolean { UnsignedLongOrBoolean::UnsignedLong(0u32) }
+ fn ReceiveUnion(&self) -> HTMLElementOrLong {
+ HTMLElementOrLong::Long(0)
+ }
+ fn ReceiveUnion2(&self) -> EventOrString {
+ EventOrString::String(DOMString::new())
+ }
+ fn ReceiveUnion3(&self) -> StringOrLongSequence {
+ StringOrLongSequence::LongSequence(vec![])
+ }
+ fn ReceiveUnion4(&self) -> StringOrStringSequence {
+ StringOrStringSequence::StringSequence(vec![])
+ }
+ fn ReceiveUnion5(&self) -> BlobOrBlobSequence {
+ BlobOrBlobSequence::BlobSequence(vec![])
+ }
+ fn ReceiveUnion6(&self) -> StringOrUnsignedLong {
+ StringOrUnsignedLong::String(DOMString::new())
+ }
+ fn ReceiveUnion7(&self) -> StringOrBoolean {
+ StringOrBoolean::Boolean(true)
+ }
+ fn ReceiveUnion8(&self) -> UnsignedLongOrBoolean {
+ UnsignedLongOrBoolean::UnsignedLong(0u32)
+ }
fn ReceiveUnion9(&self) -> HTMLElementOrUnsignedLongOrStringOrBoolean {
HTMLElementOrUnsignedLongOrStringOrBoolean::Boolean(true)
}
- fn ReceiveUnion10(&self) -> ByteStringOrLong { ByteStringOrLong::ByteString(ByteString::new(vec!())) }
+ fn ReceiveUnion10(&self) -> ByteStringOrLong {
+ ByteStringOrLong::ByteString(ByteString::new(vec![]))
+ }
fn ReceiveUnion11(&self) -> ByteStringSequenceOrLongOrString {
- ByteStringSequenceOrLongOrString::ByteStringSequence(vec!(ByteString::new(vec!())))
- }
- fn ReceiveSequence(&self) -> Vec<i32> { vec![1] }
- fn ReceiveInterfaceSequence(&self) -> Vec<Root<Blob>> {
- vec![Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())]
- }
-
- fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
- fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }
- fn ReceiveNullableOctet(&self) -> Option<u8> { Some(0) }
- fn ReceiveNullableShort(&self) -> Option<i16> { Some(0) }
- fn ReceiveNullableUnsignedShort(&self) -> Option<u16> { Some(0) }
- fn ReceiveNullableLong(&self) -> Option<i32> { Some(0) }
- fn ReceiveNullableUnsignedLong(&self) -> Option<u32> { Some(0) }
- fn ReceiveNullableLongLong(&self) -> Option<i64> { Some(0) }
- fn ReceiveNullableUnsignedLongLong(&self) -> Option<u64> { Some(0) }
- fn ReceiveNullableUnrestrictedFloat(&self) -> Option<f32> { Some(0.) }
- fn ReceiveNullableFloat(&self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
- fn ReceiveNullableUnrestrictedDouble(&self) -> Option<f64> { Some(0.) }
- fn ReceiveNullableDouble(&self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
- fn ReceiveNullableString(&self) -> Option<DOMString> { Some(DOMString::new()) }
- fn ReceiveNullableUsvstring(&self) -> Option<USVString> { Some(USVString("".to_owned())) }
- fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
- fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(TestEnum::_empty) }
- fn ReceiveNullableInterface(&self) -> Option<Root<Blob>> {
- Some(Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned()))
+ ByteStringSequenceOrLongOrString::ByteStringSequence(vec![ByteString::new(vec![])])
}
- #[allow(unsafe_code)]
- unsafe fn ReceiveNullableObject(&self, cx: *mut JSContext) -> Option<NonZero<*mut JSObject>> {
+ fn ReceiveSequence(&self) -> Vec<i32> {
+ vec![1]
+ }
+ fn ReceiveInterfaceSequence(&self) -> Vec<DomRoot<Blob>> {
+ vec![Blob::new(
+ &self.global(),
+ BlobImpl::new_from_bytes(vec![], "".to_owned()),
+ )]
+ }
+ fn ReceiveUnionIdentity(
+ &self,
+ _: SafeJSContext,
+ arg: UnionTypes::StringOrObject,
+ ) -> UnionTypes::StringOrObject {
+ arg
+ }
+
+ fn ReceiveNullableBoolean(&self) -> Option<bool> {
+ Some(false)
+ }
+ fn ReceiveNullableByte(&self) -> Option<i8> {
+ Some(0)
+ }
+ fn ReceiveNullableOctet(&self) -> Option<u8> {
+ Some(0)
+ }
+ fn ReceiveNullableShort(&self) -> Option<i16> {
+ Some(0)
+ }
+ fn ReceiveNullableUnsignedShort(&self) -> Option<u16> {
+ Some(0)
+ }
+ fn ReceiveNullableLong(&self) -> Option<i32> {
+ Some(0)
+ }
+ fn ReceiveNullableUnsignedLong(&self) -> Option<u32> {
+ Some(0)
+ }
+ fn ReceiveNullableLongLong(&self) -> Option<i64> {
+ Some(0)
+ }
+ fn ReceiveNullableUnsignedLongLong(&self) -> Option<u64> {
+ Some(0)
+ }
+ fn ReceiveNullableUnrestrictedFloat(&self) -> Option<f32> {
+ Some(0.)
+ }
+ fn ReceiveNullableFloat(&self) -> Option<Finite<f32>> {
+ Some(Finite::wrap(0.))
+ }
+ fn ReceiveNullableUnrestrictedDouble(&self) -> Option<f64> {
+ Some(0.)
+ }
+ fn ReceiveNullableDouble(&self) -> Option<Finite<f64>> {
+ Some(Finite::wrap(0.))
+ }
+ fn ReceiveNullableString(&self) -> Option<DOMString> {
+ Some(DOMString::new())
+ }
+ fn ReceiveNullableUsvstring(&self) -> Option<USVString> {
+ Some(USVString("".to_owned()))
+ }
+ fn ReceiveNullableByteString(&self) -> Option<ByteString> {
+ Some(ByteString::new(vec![]))
+ }
+ fn ReceiveNullableEnum(&self) -> Option<TestEnum> {
+ Some(TestEnum::_empty)
+ }
+ fn ReceiveNullableInterface(&self) -> Option<DomRoot<Blob>> {
+ Some(Blob::new(
+ &self.global(),
+ BlobImpl::new_from_bytes(vec![], "".to_owned()),
+ ))
+ }
+ fn ReceiveNullableObject(&self, cx: SafeJSContext) -> Option<NonNull<JSObject>> {
self.GetObjectAttributeNullable(cx)
}
fn ReceiveNullableUnion(&self) -> Option<HTMLElementOrLong> {
@@ -335,17 +549,20 @@ impl TestBindingMethods for TestBinding {
Some(UnsignedLongOrBoolean::UnsignedLong(0u32))
}
fn ReceiveNullableUnion6(&self) -> Option<ByteStringOrLong> {
- Some(ByteStringOrLong::ByteString(ByteString::new(vec!())))
+ Some(ByteStringOrLong::ByteString(ByteString::new(vec![])))
+ }
+ fn ReceiveNullableSequence(&self) -> Option<Vec<i32>> {
+ Some(vec![1])
}
- fn ReceiveNullableSequence(&self) -> Option<Vec<i32>> { Some(vec![1]) }
- fn ReceiveTestDictionaryWithSuccessOnKeyword(&self) -> TestDictionary {
- TestDictionary {
- anyValue: Heap::new(NullValue()),
+ fn ReceiveTestDictionaryWithSuccessOnKeyword(&self) -> RootedTraceableBox<TestDictionary> {
+ RootedTraceableBox::new(TestDictionary {
+ anyValue: RootedTraceableBox::new(Heap::default()),
booleanValue: None,
byteValue: None,
- dict: TestDictionaryDefaults {
+ dict: RootedTraceableBox::new(TestDictionaryDefaults {
UnrestrictedDoubleValue: 0.0,
- anyValue: Heap::new(NullValue()),
+ anyValue: RootedTraceableBox::new(Heap::default()),
+ arrayValue: Vec::new(),
booleanValue: false,
bytestringValue: ByteString::new(vec![]),
byteValue: 0,
@@ -361,7 +578,7 @@ impl TestBindingMethods for TestBinding {
nullableFloatValue: None,
nullableLongLongValue: None,
nullableLongValue: None,
- nullableObjectValue: Heap::new(ptr::null_mut()),
+ nullableObjectValue: RootedTraceableBox::new(Heap::default()),
nullableOctetValue: None,
nullableShortValue: None,
nullableStringValue: None,
@@ -379,7 +596,7 @@ impl TestBindingMethods for TestBinding {
unsignedLongValue: 0,
unsignedShortValue: 0,
usvstringValue: USVString("".to_owned()),
- },
+ }),
doubleValue: None,
enumValue: None,
floatValue: None,
@@ -390,6 +607,7 @@ impl TestBindingMethods for TestBinding {
octetValue: None,
requiredValue: true,
seqDict: None,
+ elementSequence: None,
shortValue: None,
stringValue: None,
type_: Some(DOMString::from("success")),
@@ -401,7 +619,7 @@ impl TestBindingMethods for TestBinding {
usvstringValue: None,
nonRequiredNullable: None,
nonRequiredNullable2: Some(None), // null
- }
+ })
}
fn DictMatchesPassedValues(&self, arg: RootedTraceableBox<TestDictionary>) -> bool {
@@ -428,6 +646,9 @@ impl TestBindingMethods for TestBinding {
fn PassByteString(&self, _: ByteString) {}
fn PassEnum(&self, _: TestEnum) {}
fn PassInterface(&self, _: &Blob) {}
+ fn PassTypedArray(&self, _: CustomAutoRooterGuard<typedarray::Int8Array>) {}
+ fn PassTypedArray2(&self, _: CustomAutoRooterGuard<typedarray::ArrayBuffer>) {}
+ fn PassTypedArray3(&self, _: CustomAutoRooterGuard<typedarray::ArrayBufferView>) {}
fn PassUnion(&self, _: HTMLElementOrLong) {}
fn PassUnion2(&self, _: EventOrString) {}
fn PassUnion3(&self, _: BlobOrString) {}
@@ -436,20 +657,38 @@ impl TestBindingMethods for TestBinding {
fn PassUnion6(&self, _: UnsignedLongOrBoolean) {}
fn PassUnion7(&self, _: StringSequenceOrUnsignedLong) {}
fn PassUnion8(&self, _: ByteStringSequenceOrLong) {}
- fn PassUnion9(&self, _: RootedTraceableBox<UnionTypes::TestDictionaryOrLong>) {}
- #[allow(unsafe_code)]
- unsafe fn PassUnion10(&self, _: *mut JSContext, _: RootedTraceableBox<UnionTypes::StringOrObject>) {}
+ fn PassUnion9(&self, _: UnionTypes::TestDictionaryOrLong) {}
+ fn PassUnion10(&self, _: SafeJSContext, _: UnionTypes::StringOrObject) {}
+ fn PassUnion11(&self, _: UnionTypes::ArrayBufferOrArrayBufferView) {}
fn PassUnionWithTypedef(&self, _: DocumentOrTestTypedef) {}
fn PassUnionWithTypedef2(&self, _: LongSequenceOrTestTypedef) {}
- #[allow(unsafe_code)]
- unsafe fn PassAny(&self, _: *mut JSContext, _: HandleValue) {}
- #[allow(unsafe_code)]
- unsafe fn PassObject(&self, _: *mut JSContext, _: *mut JSObject) {}
+ fn PassAny(&self, _: SafeJSContext, _: HandleValue) {}
+ fn PassObject(&self, _: SafeJSContext, _: *mut JSObject) {}
fn PassCallbackFunction(&self, _: Rc<Function>) {}
fn PassCallbackInterface(&self, _: Rc<EventListener>) {}
fn PassSequence(&self, _: Vec<i32>) {}
+ fn PassAnySequence(&self, _: SafeJSContext, _: CustomAutoRooterGuard<Vec<JSVal>>) {}
+ fn AnySequencePassthrough(
+ &self,
+ _: SafeJSContext,
+ seq: CustomAutoRooterGuard<Vec<JSVal>>,
+ ) -> Vec<JSVal> {
+ (*seq).clone()
+ }
+ fn PassObjectSequence(&self, _: SafeJSContext, _: CustomAutoRooterGuard<Vec<*mut JSObject>>) {}
fn PassStringSequence(&self, _: Vec<DOMString>) {}
- fn PassInterfaceSequence(&self, _: Vec<Root<Blob>>) {}
+ fn PassInterfaceSequence(&self, _: Vec<DomRoot<Blob>>) {}
+
+ fn PassOverloaded(&self, _: CustomAutoRooterGuard<typedarray::ArrayBuffer>) {}
+ fn PassOverloaded_(&self, _: DOMString) {}
+
+ fn PassOverloadedDict(&self, _: &Node) -> DOMString {
+ "node".into()
+ }
+
+ fn PassOverloadedDict_(&self, u: &TestURLLike) -> DOMString {
+ u.href.clone()
+ }
fn PassNullableBoolean(&self, _: Option<bool>) {}
fn PassNullableByte(&self, _: Option<i8>) {}
@@ -469,8 +708,8 @@ impl TestBindingMethods for TestBinding {
fn PassNullableByteString(&self, _: Option<ByteString>) {}
// fn PassNullableEnum(self, _: Option<TestEnum>) {}
fn PassNullableInterface(&self, _: Option<&Blob>) {}
- #[allow(unsafe_code)]
- unsafe fn PassNullableObject(&self, _: *mut JSContext, _: *mut JSObject) {}
+ fn PassNullableObject(&self, _: SafeJSContext, _: *mut JSObject) {}
+ fn PassNullableTypedArray(&self, _: CustomAutoRooterGuard<Option<typedarray::Int8Array>>) {}
fn PassNullableUnion(&self, _: Option<HTMLElementOrLong>) {}
fn PassNullableUnion2(&self, _: Option<EventOrString>) {}
fn PassNullableUnion3(&self, _: Option<StringOrLongSequence>) {}
@@ -505,10 +744,8 @@ impl TestBindingMethods for TestBinding {
fn PassOptionalUnion4(&self, _: Option<LongSequenceOrBoolean>) {}
fn PassOptionalUnion5(&self, _: Option<UnsignedLongOrBoolean>) {}
fn PassOptionalUnion6(&self, _: Option<ByteStringOrLong>) {}
- #[allow(unsafe_code)]
- unsafe fn PassOptionalAny(&self, _: *mut JSContext, _: HandleValue) {}
- #[allow(unsafe_code)]
- unsafe fn PassOptionalObject(&self, _: *mut JSContext, _: Option<*mut JSObject>) {}
+ fn PassOptionalAny(&self, _: SafeJSContext, _: HandleValue) {}
+ fn PassOptionalObject(&self, _: SafeJSContext, _: Option<*mut JSObject>) {}
fn PassOptionalCallbackFunction(&self, _: Option<Rc<Function>>) {}
fn PassOptionalCallbackInterface(&self, _: Option<Rc<EventListener>>) {}
fn PassOptionalSequence(&self, _: Option<Vec<i32>>) {}
@@ -531,8 +768,7 @@ impl TestBindingMethods for TestBinding {
fn PassOptionalNullableByteString(&self, _: Option<Option<ByteString>>) {}
// fn PassOptionalNullableEnum(self, _: Option<Option<TestEnum>>) {}
fn PassOptionalNullableInterface(&self, _: Option<Option<&Blob>>) {}
- #[allow(unsafe_code)]
- unsafe fn PassOptionalNullableObject(&self, _: *mut JSContext, _: Option<*mut JSObject>) {}
+ fn PassOptionalNullableObject(&self, _: SafeJSContext, _: Option<*mut JSObject>) {}
fn PassOptionalNullableUnion(&self, _: Option<Option<HTMLElementOrLong>>) {}
fn PassOptionalNullableUnion2(&self, _: Option<Option<EventOrString>>) {}
fn PassOptionalNullableUnion3(&self, _: Option<Option<StringOrLongSequence>>) {}
@@ -556,6 +792,7 @@ impl TestBindingMethods for TestBinding {
fn PassOptionalUsvstringWithDefault(&self, _: USVString) {}
fn PassOptionalBytestringWithDefault(&self, _: ByteString) {}
fn PassOptionalEnumWithDefault(&self, _: TestEnum) {}
+ fn PassOptionalSequenceWithDefault(&self, _: Vec<i32>) {}
fn PassOptionalNullableBooleanWithDefault(&self, _: Option<bool>) {}
fn PassOptionalNullableByteWithDefault(&self, _: Option<i8>) {}
@@ -575,14 +812,12 @@ impl TestBindingMethods for TestBinding {
fn PassOptionalNullableByteStringWithDefault(&self, _: Option<ByteString>) {}
// fn PassOptionalNullableEnumWithDefault(self, _: Option<TestEnum>) {}
fn PassOptionalNullableInterfaceWithDefault(&self, _: Option<&Blob>) {}
- #[allow(unsafe_code)]
- unsafe fn PassOptionalNullableObjectWithDefault(&self, _: *mut JSContext, _: *mut JSObject) {}
+ fn PassOptionalNullableObjectWithDefault(&self, _: SafeJSContext, _: *mut JSObject) {}
fn PassOptionalNullableUnionWithDefault(&self, _: Option<HTMLElementOrLong>) {}
fn PassOptionalNullableUnion2WithDefault(&self, _: Option<EventOrString>) {}
// fn PassOptionalNullableCallbackFunctionWithDefault(self, _: Option<Function>) {}
fn PassOptionalNullableCallbackInterfaceWithDefault(&self, _: Option<Rc<EventListener>>) {}
- #[allow(unsafe_code)]
- unsafe fn PassOptionalAnyWithDefault(&self, _: *mut JSContext, _: HandleValue) {}
+ fn PassOptionalAnyWithDefault(&self, _: SafeJSContext, _: HandleValue) {}
fn PassOptionalNullableBooleanWithNonNullDefault(&self, _: Option<bool>) {}
fn PassOptionalNullableByteWithNonNullDefault(&self, _: Option<i8>) {}
@@ -600,6 +835,10 @@ impl TestBindingMethods for TestBinding {
fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option<DOMString>) {}
fn PassOptionalNullableUsvstringWithNonNullDefault(&self, _: Option<USVString>) {}
// fn PassOptionalNullableEnumWithNonNullDefault(self, _: Option<TestEnum>) {}
+ fn PassOptionalOverloaded(&self, a: &TestBinding, _: u32, _: u32) -> DomRoot<TestBinding> {
+ DomRoot::from_ref(a)
+ }
+ fn PassOptionalOverloaded_(&self, _: &Blob, _: u32) {}
fn PassVariadicBoolean(&self, _: Vec<bool>) {}
fn PassVariadicBooleanAndDefault(&self, _: bool, _: Vec<bool>) {}
@@ -627,75 +866,118 @@ impl TestBindingMethods for TestBinding {
fn PassVariadicUnion5(&self, _: Vec<StringOrUnsignedLong>) {}
fn PassVariadicUnion6(&self, _: Vec<UnsignedLongOrBoolean>) {}
fn PassVariadicUnion7(&self, _: Vec<ByteStringOrLong>) {}
- #[allow(unsafe_code)]
- unsafe fn PassVariadicAny(&self, _: *mut JSContext, _: Vec<HandleValue>) {}
- #[allow(unsafe_code)]
- unsafe fn PassVariadicObject(&self, _: *mut JSContext, _: Vec<*mut JSObject>) {}
+ fn PassVariadicAny(&self, _: SafeJSContext, _: Vec<HandleValue>) {}
+ fn PassVariadicObject(&self, _: SafeJSContext, _: Vec<*mut JSObject>) {}
fn BooleanMozPreference(&self, pref_name: DOMString) -> bool {
- PREFS.get(pref_name.as_ref()).as_boolean().unwrap_or(false)
+ prefs::pref_map()
+ .get(pref_name.as_ref())
+ .as_bool()
+ .unwrap_or(false)
}
fn StringMozPreference(&self, pref_name: DOMString) -> DOMString {
- PREFS.get(pref_name.as_ref()).as_string().map(|s| DOMString::from(s)).unwrap_or_else(|| DOMString::new())
+ prefs::pref_map()
+ .get(pref_name.as_ref())
+ .as_str()
+ .map(|s| DOMString::from(s))
+ .unwrap_or_else(|| DOMString::new())
+ }
+ fn PrefControlledAttributeDisabled(&self) -> bool {
+ false
+ }
+ fn PrefControlledAttributeEnabled(&self) -> bool {
+ false
}
- fn PrefControlledAttributeDisabled(&self) -> bool { false }
- fn PrefControlledAttributeEnabled(&self) -> bool { false }
fn PrefControlledMethodDisabled(&self) {}
fn PrefControlledMethodEnabled(&self) {}
- fn FuncControlledAttributeDisabled(&self) -> bool { false }
- fn FuncControlledAttributeEnabled(&self) -> bool { false }
+ fn FuncControlledAttributeDisabled(&self) -> bool {
+ false
+ }
+ fn FuncControlledAttributeEnabled(&self) -> bool {
+ false
+ }
fn FuncControlledMethodDisabled(&self) {}
fn FuncControlledMethodEnabled(&self) {}
- fn PassMozMap(&self, _: MozMap<i32>) {}
- fn PassNullableMozMap(&self, _: Option<MozMap<i32> >) {}
- fn PassMozMapOfNullableInts(&self, _: MozMap<Option<i32>>) {}
- fn PassOptionalMozMapOfNullableInts(&self, _: Option<MozMap<Option<i32>>>) {}
- fn PassOptionalNullableMozMapOfNullableInts(&self, _: Option<Option<MozMap<Option<i32>> >>) {}
- fn PassCastableObjectMozMap(&self, _: MozMap<Root<TestBinding>>) {}
- fn PassNullableCastableObjectMozMap(&self, _: MozMap<Option<Root<TestBinding>>>) {}
- fn PassCastableObjectNullableMozMap(&self, _: Option<MozMap<Root<TestBinding>>>) {}
- fn PassNullableCastableObjectNullableMozMap(&self, _: Option<MozMap<Option<Root<TestBinding>>>>) {}
- fn PassOptionalMozMap(&self, _: Option<MozMap<i32>>) {}
- fn PassOptionalNullableMozMap(&self, _: Option<Option<MozMap<i32>>>) {}
- fn PassOptionalNullableMozMapWithDefaultValue(&self, _: Option<MozMap<i32>>) {}
- fn PassOptionalObjectMozMap(&self, _: Option<MozMap<Root<TestBinding>>>) {}
- fn PassStringMozMap(&self, _: MozMap<DOMString>) {}
- fn PassByteStringMozMap(&self, _: MozMap<ByteString>) {}
- fn PassMozMapOfMozMaps(&self, _: MozMap<MozMap<i32>>) {}
- fn PassMozMapUnion(&self, _: UnionTypes::LongOrByteStringMozMap) {}
- fn PassMozMapUnion2(&self, _: UnionTypes::TestBindingOrByteStringMozMap) {}
- fn PassMozMapUnion3(&self, _: UnionTypes::TestBindingOrByteStringSequenceSequenceOrByteStringMozMap) {}
- fn ReceiveMozMap(&self) -> MozMap<i32> { MozMap::new() }
- fn ReceiveNullableMozMap(&self) -> Option<MozMap<i32>> { Some(MozMap::new()) }
- fn ReceiveMozMapOfNullableInts(&self) -> MozMap<Option<i32>> { MozMap::new() }
- fn ReceiveNullableMozMapOfNullableInts(&self) -> Option<MozMap<Option<i32>>> { Some(MozMap::new()) }
- fn ReceiveMozMapOfMozMaps(&self) -> MozMap<MozMap<i32>> { MozMap::new() }
- fn ReceiveAnyMozMap(&self) -> MozMap<JSVal> { MozMap::new() }
+ fn PassRecord(&self, _: Record<DOMString, i32>) {}
+ fn PassRecordWithUSVStringKey(&self, _: Record<USVString, i32>) {}
+ fn PassRecordWithByteStringKey(&self, _: Record<ByteString, i32>) {}
+ fn PassNullableRecord(&self, _: Option<Record<DOMString, i32>>) {}
+ fn PassRecordOfNullableInts(&self, _: Record<DOMString, Option<i32>>) {}
+ fn PassOptionalRecordOfNullableInts(&self, _: Option<Record<DOMString, Option<i32>>>) {}
+ fn PassOptionalNullableRecordOfNullableInts(
+ &self,
+ _: Option<Option<Record<DOMString, Option<i32>>>>,
+ ) {
+ }
+ fn PassCastableObjectRecord(&self, _: Record<DOMString, DomRoot<TestBinding>>) {}
+ fn PassNullableCastableObjectRecord(&self, _: Record<DOMString, Option<DomRoot<TestBinding>>>) {
+ }
+ fn PassCastableObjectNullableRecord(&self, _: Option<Record<DOMString, DomRoot<TestBinding>>>) {
+ }
+ fn PassNullableCastableObjectNullableRecord(
+ &self,
+ _: Option<Record<DOMString, Option<DomRoot<TestBinding>>>>,
+ ) {
+ }
+ fn PassOptionalRecord(&self, _: Option<Record<DOMString, i32>>) {}
+ fn PassOptionalNullableRecord(&self, _: Option<Option<Record<DOMString, i32>>>) {}
+ fn PassOptionalNullableRecordWithDefaultValue(&self, _: Option<Record<DOMString, i32>>) {}
+ fn PassOptionalObjectRecord(&self, _: Option<Record<DOMString, DomRoot<TestBinding>>>) {}
+ fn PassStringRecord(&self, _: Record<DOMString, DOMString>) {}
+ fn PassByteStringRecord(&self, _: Record<DOMString, ByteString>) {}
+ fn PassRecordOfRecords(&self, _: Record<DOMString, Record<DOMString, i32>>) {}
+ fn PassRecordUnion(&self, _: UnionTypes::LongOrStringByteStringRecord) {}
+ fn PassRecordUnion2(&self, _: UnionTypes::TestBindingOrStringByteStringRecord) {}
+ fn PassRecordUnion3(
+ &self,
+ _: UnionTypes::TestBindingOrByteStringSequenceSequenceOrStringByteStringRecord,
+ ) {
+ }
+ fn ReceiveRecord(&self) -> Record<DOMString, i32> {
+ Record::new()
+ }
+ fn ReceiveRecordWithUSVStringKey(&self) -> Record<USVString, i32> {
+ Record::new()
+ }
+ fn ReceiveRecordWithByteStringKey(&self) -> Record<ByteString, i32> {
+ Record::new()
+ }
+ fn ReceiveNullableRecord(&self) -> Option<Record<DOMString, i32>> {
+ Some(Record::new())
+ }
+ fn ReceiveRecordOfNullableInts(&self) -> Record<DOMString, Option<i32>> {
+ Record::new()
+ }
+ fn ReceiveNullableRecordOfNullableInts(&self) -> Option<Record<DOMString, Option<i32>>> {
+ Some(Record::new())
+ }
+ fn ReceiveRecordOfRecords(&self) -> Record<DOMString, Record<DOMString, i32>> {
+ Record::new()
+ }
+ fn ReceiveAnyRecord(&self) -> Record<DOMString, JSVal> {
+ Record::new()
+ }
#[allow(unrooted_must_root)]
- #[allow(unsafe_code)]
- unsafe fn ReturnResolvedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
- Promise::Resolve(&self.global(), cx, v)
+ fn ReturnResolvedPromise(&self, cx: SafeJSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
+ Promise::new_resolved(&self.global(), cx, v)
}
#[allow(unrooted_must_root)]
- #[allow(unsafe_code)]
- unsafe fn ReturnRejectedPromise(&self, cx: *mut JSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
- Promise::Reject(&self.global(), cx, v)
+ fn ReturnRejectedPromise(&self, cx: SafeJSContext, v: HandleValue) -> Fallible<Rc<Promise>> {
+ Promise::new_rejected(&self.global(), cx, v)
}
- #[allow(unsafe_code)]
- unsafe fn PromiseResolveNative(&self, cx: *mut JSContext, p: &Promise, v: HandleValue) {
+ fn PromiseResolveNative(&self, cx: SafeJSContext, p: &Promise, v: HandleValue) {
p.resolve(cx, v);
}
- #[allow(unsafe_code)]
- unsafe fn PromiseRejectNative(&self, cx: *mut JSContext, p: &Promise, v: HandleValue) {
+ fn PromiseRejectNative(&self, cx: SafeJSContext, p: &Promise, v: HandleValue) {
p.reject(cx, v);
}
fn PromiseRejectWithTypeError(&self, p: &Promise, s: USVString) {
- p.reject_error(self.global().get_cx(), Error::Type(s.0));
+ p.reject_error(Error::Type(s.0));
}
#[allow(unrooted_must_root)]
@@ -705,62 +987,62 @@ impl TestBindingMethods for TestBinding {
promise: TrustedPromise::new(promise),
value: value,
};
- let _ = self.global()
- .schedule_callback(
- OneshotTimerCallback::TestBindingCallback(cb),
- MsDuration::new(delay));
+ let _ = self.global().schedule_callback(
+ OneshotTimerCallback::TestBindingCallback(cb),
+ MsDuration::new(delay),
+ );
}
- #[allow(unrooted_must_root)]
- fn PromiseNativeHandler(&self,
- resolve: Option<Rc<SimpleCallback>>,
- reject: Option<Rc<SimpleCallback>>) -> Rc<Promise> {
+ fn PromiseNativeHandler(
+ &self,
+ resolve: Option<Rc<SimpleCallback>>,
+ reject: Option<Rc<SimpleCallback>>,
+ comp: InRealm,
+ ) -> Rc<Promise> {
let global = self.global();
- let handler = PromiseNativeHandler::new(&global,
- resolve.map(SimpleHandler::new),
- reject.map(SimpleHandler::new));
- let p = Promise::new(&global);
- p.append_native_handler(&handler);
+ let handler = PromiseNativeHandler::new(
+ &global,
+ resolve.map(SimpleHandler::new),
+ reject.map(SimpleHandler::new),
+ );
+ let p = Promise::new_in_current_realm(&global, comp.clone());
+ p.append_native_handler(&handler, comp);
return p;
- #[derive(JSTraceable, HeapSizeOf)]
+ #[derive(JSTraceable, MallocSizeOf)]
struct SimpleHandler {
- #[ignore_heap_size_of = "Rc has unclear ownership semantics"]
+ #[ignore_malloc_size_of = "Rc has unclear ownership semantics"]
handler: Rc<SimpleCallback>,
}
impl SimpleHandler {
- fn new(callback: Rc<SimpleCallback>) -> Box<Callback> {
- box SimpleHandler { handler: callback }
+ fn new(callback: Rc<SimpleCallback>) -> Box<dyn Callback> {
+ Box::new(SimpleHandler { handler: callback })
}
}
impl Callback for SimpleHandler {
- #[allow(unsafe_code)]
- fn callback(&self, cx: *mut JSContext, v: HandleValue) {
- let global = unsafe { GlobalScope::from_context(cx) };
+ fn callback(&self, cx: SafeJSContext, v: HandleValue, realm: InRealm) {
+ let global = GlobalScope::from_safe_context(cx, realm);
let _ = self.handler.Call_(&*global, v, ExceptionHandling::Report);
}
}
}
- #[allow(unrooted_must_root)]
- fn PromiseAttribute(&self) -> Rc<Promise> {
- Promise::new(&self.global())
+ fn PromiseAttribute(&self, comp: InRealm) -> Rc<Promise> {
+ Promise::new_in_current_realm(&self.global(), comp)
}
- fn AcceptPromise(&self, _promise: &Promise) {
- }
-
- fn AcceptNullablePromise(&self, _promise: Option<&Promise>) {
- }
+ fn AcceptPromise(&self, _promise: &Promise) {}
fn PassSequenceSequence(&self, _seq: Vec<Vec<i32>>) {}
- fn ReturnSequenceSequence(&self) -> Vec<Vec<i32>> { vec![] }
+ fn ReturnSequenceSequence(&self) -> Vec<Vec<i32>> {
+ vec![]
+ }
fn PassUnionSequenceSequence(&self, seq: LongOrLongSequenceSequence) {
match seq {
LongOrLongSequenceSequence::Long(_) => (),
LongOrLongSequenceSequence::LongSequenceSequence(seq) => {
let _seq: Vec<Vec<i32>> = seq;
- }
+ },
}
}
@@ -773,43 +1055,80 @@ impl TestBindingMethods for TestBinding {
}
}
- fn AdvanceClock(&self, ms: i32, tick: bool) {
- self.global().as_window().advance_animation_clock(ms, tick);
+ fn AdvanceClock(&self, ms: i32) {
+ self.global().as_window().advance_animation_clock(ms);
}
- fn Panic(&self) { panic!("explicit panic from script") }
+ fn Panic(&self) {
+ panic!("explicit panic from script")
+ }
- fn EntryGlobal(&self) -> Root<GlobalScope> {
+ fn EntryGlobal(&self) -> DomRoot<GlobalScope> {
GlobalScope::entry()
}
- fn IncumbentGlobal(&self) -> Root<GlobalScope> {
+ fn IncumbentGlobal(&self) -> DomRoot<GlobalScope> {
GlobalScope::incumbent().unwrap()
}
+
+ fn SemiExposedBoolFromInterface(&self) -> bool {
+ true
+ }
+
+ fn BoolFromSemiExposedPartialInterface(&self) -> bool {
+ true
+ }
+
+ fn SemiExposedBoolFromPartialInterface(&self) -> bool {
+ true
+ }
+
+ fn GetDictionaryWithParent(&self, s1: DOMString, s2: DOMString) -> TestDictionaryWithParent {
+ TestDictionaryWithParent {
+ parent: TestDictionaryParent {
+ parentStringMember: Some(s1),
+ },
+ stringMember: Some(s2),
+ }
+ }
}
+#[allow(non_snake_case)]
impl TestBinding {
- pub fn BooleanAttributeStatic(_: &GlobalScope) -> bool { false }
+ pub fn BooleanAttributeStatic(_: &GlobalScope) -> bool {
+ false
+ }
pub fn SetBooleanAttributeStatic(_: &GlobalScope, _: bool) {}
pub fn ReceiveVoidStatic(_: &GlobalScope) {}
- pub fn PrefControlledStaticAttributeDisabled(_: &GlobalScope) -> bool { false }
- pub fn PrefControlledStaticAttributeEnabled(_: &GlobalScope) -> bool { false }
+ pub fn PrefControlledStaticAttributeDisabled(_: &GlobalScope) -> bool {
+ false
+ }
+ pub fn PrefControlledStaticAttributeEnabled(_: &GlobalScope) -> bool {
+ false
+ }
pub fn PrefControlledStaticMethodDisabled(_: &GlobalScope) {}
pub fn PrefControlledStaticMethodEnabled(_: &GlobalScope) {}
- pub fn FuncControlledStaticAttributeDisabled(_: &GlobalScope) -> bool { false }
- pub fn FuncControlledStaticAttributeEnabled(_: &GlobalScope) -> bool { false }
+ pub fn FuncControlledStaticAttributeDisabled(_: &GlobalScope) -> bool {
+ false
+ }
+ pub fn FuncControlledStaticAttributeEnabled(_: &GlobalScope) -> bool {
+ false
+ }
pub fn FuncControlledStaticMethodDisabled(_: &GlobalScope) {}
pub fn FuncControlledStaticMethodEnabled(_: &GlobalScope) {}
}
-#[allow(unsafe_code)]
impl TestBinding {
- pub unsafe fn condition_satisfied(_: *mut JSContext, _: HandleObject) -> bool { true }
- pub unsafe fn condition_unsatisfied(_: *mut JSContext, _: HandleObject) -> bool { false }
+ pub fn condition_satisfied(_: SafeJSContext, _: HandleObject) -> bool {
+ true
+ }
+ pub fn condition_unsatisfied(_: SafeJSContext, _: HandleObject) -> bool {
+ false
+ }
}
-#[derive(JSTraceable, HeapSizeOf)]
+#[derive(JSTraceable, MallocSizeOf)]
pub struct TestBindingCallback {
- #[ignore_heap_size_of = "unclear ownership semantics"]
+ #[ignore_malloc_size_of = "unclear ownership semantics"]
promise: TrustedPromise,
value: DOMString,
}
@@ -817,9 +1136,6 @@ pub struct TestBindingCallback {
impl TestBindingCallback {
#[allow(unrooted_must_root)]
pub fn invoke(self) {
- let p = self.promise.root();
- let cx = p.global().get_cx();
- let _ac = JSAutoCompartment::new(cx, p.reflector().get_jsobject().get());
- p.resolve_native(cx, &self.value);
+ self.promise.root().resolve_native(&self.value);
}
}