Add WPT test for WebIDL union conversion containing object values

This commit is contained in:
Igor Matuszewski 2018-03-13 02:35:25 +01:00
parent 17ecbaf8ff
commit 712812d441
5 changed files with 44 additions and 0 deletions

View file

@ -293,6 +293,14 @@ impl TestBindingMethods for TestBinding {
fn ReceiveInterfaceSequence(&self) -> Vec<DomRoot<Blob>> {
vec![Blob::new(&self.global(), BlobImpl::new_from_bytes(vec![]), "".to_owned())]
}
#[allow(unsafe_code)]
unsafe fn ReceiveUnionIdentity(
&self,
_: *mut JSContext,
arg: UnionTypes::StringOrObject,
) -> UnionTypes::StringOrObject {
arg
}
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }

View file

@ -228,6 +228,8 @@ interface TestBinding {
TestDictionary receiveTestDictionaryWithSuccessOnKeyword();
boolean dictMatchesPassedValues(TestDictionary arg);
(DOMString or object) receiveUnionIdentity((DOMString or object) arg);
void passBoolean(boolean arg);
void passByte(byte arg);
void passOctet(octet arg);

View file

@ -31972,6 +31972,12 @@
{}
]
],
"mozilla/codegen_unions.html": [
[
"/_mozilla/mozilla/codegen_unions.html",
{}
]
],
"mozilla/collections.html": [
[
"/_mozilla/mozilla/collections.html",
@ -64751,6 +64757,10 @@
"5183977a0d29ba4d74d049c9391090e3c27264a8",
"testharness"
],
"mozilla/codegen_unions.html": [
"7f772fffb75acc92f9c949a482d387b3ed18d0ed",
"testharness"
],
"mozilla/collections.html": [
"d0bebe808ebb45b6c853f4b88e1a6ebbf9b91345",
"testharness"

View file

@ -0,0 +1,3 @@
[codegen_unions.html]
type: testharness
prefs: [dom.testbinding.enabled:true]

View file

@ -0,0 +1,21 @@
<!doctype html>
<html>
<meta charset="utf-8">
<title>WebIDL conversions are performed correctly and don't lose values</title>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<script>
test(function() {
var t = new TestBinding;
// (DOMString or object) receiveUnionIdentity((DOMString or object) arg)
var obj = { 'some': 'key', 'num': 42 };
assert_equals(t.receiveUnionIdentity(obj), obj);
var str = "myString";
assert_equals(t.receiveUnionIdentity(str), str);
}, "(DOMString or object) conversion is performed correctly");
</script>
</html>