mirror of
https://github.com/servo/servo.git
synced 2025-06-14 11:24:33 +00:00
bindings: Add test for keywords in dictionaries
This commit is contained in:
parent
203898c941
commit
f893a2eaac
5 changed files with 97 additions and 1 deletions
|
@ -6,7 +6,9 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
|
||||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||||
use dom::bindings::codegen::Bindings::TestBindingBinding::{self, TestBindingMethods, TestEnum};
|
use dom::bindings::codegen::Bindings::TestBindingBinding;
|
||||||
|
use dom::bindings::codegen::Bindings::TestBindingBinding::{TestBindingMethods, TestDictionary};
|
||||||
|
use dom::bindings::codegen::Bindings::TestBindingBinding::{TestDictionaryDefaults, TestEnum};
|
||||||
use dom::bindings::codegen::UnionTypes::{BlobOrBoolean, BlobOrBlobSequence};
|
use dom::bindings::codegen::UnionTypes::{BlobOrBoolean, BlobOrBlobSequence};
|
||||||
use dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString};
|
use dom::bindings::codegen::UnionTypes::{BlobOrString, BlobOrUnsignedLong, EventOrString};
|
||||||
use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong};
|
use dom::bindings::codegen::UnionTypes::{EventOrUSVString, HTMLElementOrLong};
|
||||||
|
@ -286,6 +288,71 @@ impl TestBindingMethods for TestBinding {
|
||||||
Some(UnsignedLongOrBoolean::UnsignedLong(0u32))
|
Some(UnsignedLongOrBoolean::UnsignedLong(0u32))
|
||||||
}
|
}
|
||||||
fn ReceiveNullableSequence(&self) -> Option<Vec<i32>> { Some(vec![1]) }
|
fn ReceiveNullableSequence(&self) -> Option<Vec<i32>> { Some(vec![1]) }
|
||||||
|
fn ReceiveTestDictionaryWithSuccessOnKeyword(&self) -> TestDictionary {
|
||||||
|
TestDictionary {
|
||||||
|
anyValue: NullValue(),
|
||||||
|
booleanValue: None,
|
||||||
|
byteValue: None,
|
||||||
|
dict: TestDictionaryDefaults {
|
||||||
|
UnrestrictedDoubleValue: 0.0,
|
||||||
|
anyValue: NullValue(),
|
||||||
|
booleanValue: false,
|
||||||
|
byteValue: 0,
|
||||||
|
doubleValue: Finite::new(1.0).unwrap(),
|
||||||
|
enumValue: TestEnum::Foo,
|
||||||
|
floatValue: Finite::new(1.0).unwrap(),
|
||||||
|
longLongValue: 54,
|
||||||
|
longValue: 12,
|
||||||
|
nullableBooleanValue: None,
|
||||||
|
nullableByteValue: None,
|
||||||
|
nullableDoubleValue: None,
|
||||||
|
nullableFloatValue: None,
|
||||||
|
nullableLongLongValue: None,
|
||||||
|
nullableLongValue: None,
|
||||||
|
nullableObjectValue: ptr::null_mut(),
|
||||||
|
nullableOctetValue: None,
|
||||||
|
nullableShortValue: None,
|
||||||
|
nullableStringValue: None,
|
||||||
|
nullableUnrestrictedDoubleValue: None,
|
||||||
|
nullableUnrestrictedFloatValue: None,
|
||||||
|
nullableUnsignedLongLongValue: None,
|
||||||
|
nullableUnsignedLongValue: None,
|
||||||
|
nullableUnsignedShortValue: None,
|
||||||
|
nullableUsvstringValue: None,
|
||||||
|
octetValue: 0,
|
||||||
|
shortValue: 0,
|
||||||
|
stringValue: DOMString::new(),
|
||||||
|
unrestrictedFloatValue: 0.0,
|
||||||
|
unsignedLongLongValue: 0,
|
||||||
|
unsignedLongValue: 0,
|
||||||
|
unsignedShortValue: 0,
|
||||||
|
usvstringValue: USVString("".to_owned()),
|
||||||
|
},
|
||||||
|
doubleValue: None,
|
||||||
|
enumValue: None,
|
||||||
|
floatValue: None,
|
||||||
|
interfaceValue: None,
|
||||||
|
longLongValue: None,
|
||||||
|
longValue: None,
|
||||||
|
objectValue: None,
|
||||||
|
octetValue: None,
|
||||||
|
requiredValue: true,
|
||||||
|
seqDict: None,
|
||||||
|
shortValue: None,
|
||||||
|
stringValue: None,
|
||||||
|
type_: Some(DOMString::from("success")),
|
||||||
|
unrestrictedDoubleValue: None,
|
||||||
|
unrestrictedFloatValue: None,
|
||||||
|
unsignedLongLongValue: None,
|
||||||
|
unsignedLongValue: None,
|
||||||
|
unsignedShortValue: None,
|
||||||
|
usvstringValue: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn TypeKeywordIsSuccess(&self, arg: &TestDictionary) -> bool {
|
||||||
|
arg.type_.as_ref().map(|s| s == "success").unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
fn PassBoolean(&self, _: bool) {}
|
fn PassBoolean(&self, _: bool) {}
|
||||||
fn PassByte(&self, _: i8) {}
|
fn PassByte(&self, _: i8) {}
|
||||||
|
|
|
@ -30,6 +30,8 @@ dictionary TestDictionary {
|
||||||
object objectValue;
|
object objectValue;
|
||||||
TestDictionaryDefaults dict;
|
TestDictionaryDefaults dict;
|
||||||
sequence<TestDictionaryDefaults> seqDict;
|
sequence<TestDictionaryDefaults> seqDict;
|
||||||
|
// Reserved rust keyword
|
||||||
|
DOMString type;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary TestDictionaryDefaults {
|
dictionary TestDictionaryDefaults {
|
||||||
|
@ -196,6 +198,8 @@ interface TestBinding {
|
||||||
(sequence<long> or boolean)? receiveNullableUnion4();
|
(sequence<long> or boolean)? receiveNullableUnion4();
|
||||||
(unsigned long or boolean)? receiveNullableUnion5();
|
(unsigned long or boolean)? receiveNullableUnion5();
|
||||||
sequence<long>? receiveNullableSequence();
|
sequence<long>? receiveNullableSequence();
|
||||||
|
TestDictionary receiveTestDictionaryWithSuccessOnKeyword();
|
||||||
|
boolean typeKeywordIsSuccess(TestDictionary arg);
|
||||||
|
|
||||||
void passBoolean(boolean arg);
|
void passBoolean(boolean arg);
|
||||||
void passByte(byte arg);
|
void passByte(byte arg);
|
||||||
|
|
|
@ -6064,6 +6064,12 @@
|
||||||
"url": "/_mozilla/mozilla/bad_cert_detected.html"
|
"url": "/_mozilla/mozilla/bad_cert_detected.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/binding_keyword.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/binding_keyword.html",
|
||||||
|
"url": "/_mozilla/mozilla/binding_keyword.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/blob.html": [
|
"mozilla/blob.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/blob.html",
|
"path": "mozilla/blob.html",
|
||||||
|
|
3
tests/wpt/mozilla/meta/mozilla/binding_keyword.html.ini
Normal file
3
tests/wpt/mozilla/meta/mozilla/binding_keyword.html.ini
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[binding_keyword.html]
|
||||||
|
type: testharness
|
||||||
|
prefs: [dom.testbinding.enabled:true]
|
16
tests/wpt/mozilla/tests/mozilla/binding_keyword.html
Normal file
16
tests/wpt/mozilla/tests/mozilla/binding_keyword.html
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test for conversions from and to dictionary properties with keywords</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script>
|
||||||
|
test(function() {
|
||||||
|
var t = new TestBinding();
|
||||||
|
|
||||||
|
var dict = t.receiveTestDictionaryWithSuccessOnKeyword();
|
||||||
|
assert_equals(dict.type, "success");
|
||||||
|
|
||||||
|
var is_success = t.typeKeywordIsSuccess(dict);
|
||||||
|
assert_true(is_success);
|
||||||
|
}, "Conversion of dictionary elements with rust keywords works")
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue