From ab8b62e28d12b24774e3cdacd008a9ca64b12a33 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 16 May 2014 12:51:40 +0200 Subject: [PATCH] Add tests for return values of interface methods. --- src/components/script/dom/testbinding.rs | 43 +++++++++++++++++++ .../script/dom/webidls/TestBinding.webidl | 30 +++++++++++++ 2 files changed, 73 insertions(+) diff --git a/src/components/script/dom/testbinding.rs b/src/components/script/dom/testbinding.rs index 7fe109d0176..ce87bceccb8 100644 --- a/src/components/script/dom/testbinding.rs +++ b/src/components/script/dom/testbinding.rs @@ -86,6 +86,41 @@ pub trait TestBindingMethods { fn GetInterfaceAttributeNullable(&self) -> Option>; fn SetInterfaceAttributeNullable(&self, _: Option>) {} + 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 ReceiveFloat(&self) -> f32 { 0. } + fn ReceiveDouble(&self) -> f64 { 0. } + fn ReceiveString(&self) -> DOMString { "".to_owned() } + fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) } + fn ReceiveEnum(&self) -> TestEnum { _empty } + fn ReceiveInterface(&self) -> Temporary; + fn ReceiveAny(&self, _: *JSContext) -> JSVal { NullValue() } + + fn ReceiveNullableBoolean(&self) -> Option { Some(false) } + fn ReceiveNullableByte(&self) -> Option { Some(0) } + fn ReceiveNullableOctet(&self) -> Option { Some(0) } + fn ReceiveNullableShort(&self) -> Option { Some(0) } + fn ReceiveNullableUnsignedShort(&self) -> Option { Some(0) } + fn ReceiveNullableLong(&self) -> Option { Some(0) } + fn ReceiveNullableUnsignedLong(&self) -> Option { Some(0) } + fn ReceiveNullableLongLong(&self) -> Option { Some(0) } + fn ReceiveNullableUnsignedLongLong(&self) -> Option { Some(0) } + fn ReceiveNullableFloat(&self) -> Option { Some(0.) } + fn ReceiveNullableDouble(&self) -> Option { Some(0.) } + fn ReceiveNullableString(&self) -> Option { Some("".to_owned()) } + fn ReceiveNullableByteString(&self) -> Option { Some(ByteString::new(vec!())) } + fn ReceiveNullableEnum(&self) -> Option { Some(_empty) } + fn ReceiveNullableInterface(&self) -> Option>; + fn ReceiveNullableAny(&self, _: *JSContext) -> Option { Some(NullValue()) } + fn PassBoolean(&self, _: bool) {} fn PassByte(&self, _: i8) {} fn PassOctet(&self, _: u8) {} @@ -216,6 +251,14 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> { let window = self.window.root(); Some(Blob::new(&*window)) } + fn ReceiveInterface(&self) -> Temporary { + let window = self.window.root(); + Blob::new(&*window) + } + fn ReceiveNullableInterface(&self) -> Option> { + let window = self.window.root(); + Some(Blob::new(&*window)) + } } impl Reflectable for TestBinding { diff --git a/src/components/script/dom/webidls/TestBinding.webidl b/src/components/script/dom/webidls/TestBinding.webidl index 15dc79bd2aa..101e4d554e5 100644 --- a/src/components/script/dom/webidls/TestBinding.webidl +++ b/src/components/script/dom/webidls/TestBinding.webidl @@ -91,6 +91,36 @@ interface TestBinding { // attribute (HTMLElement or long)? unionAttributeNullable; // attribute (DOMString or FormData)? union2AttributeNullable; + void receiveVoid(); + boolean receiveBoolean(); + byte receiveByte(); + octet receiveOctet(); + short receiveShort(); + unsigned short receiveUnsignedShort(); + long receiveLong(); + unsigned long receiveUnsignedLong(); + long long receiveLongLong(); + unsigned long long receiveUnsignedLongLong(); + DOMString receiveString(); + ByteString receiveByteString(); + TestEnum receiveEnum(); + Blob receiveInterface(); + any receiveAny(); + + byte? receiveNullableByte(); + boolean? receiveNullableBoolean(); + octet? receiveNullableOctet(); + short? receiveNullableShort(); + unsigned short? receiveNullableUnsignedShort(); + long? receiveNullableLong(); + unsigned long? receiveNullableUnsignedLong(); + long long? receiveNullableLongLong(); + unsigned long long? receiveNullableUnsignedLongLong(); + DOMString? receiveNullableString(); + ByteString? receiveNullableByteString(); + TestEnum? receiveNullableEnum(); + Blob? receiveNullableInterface(); + void passBoolean(boolean arg); void passByte(byte arg); void passOctet(octet arg);