Add support for default dict values being boolean, use in MediaStreamConstraints

This commit is contained in:
Manish Goregaokar 2019-02-12 18:38:38 -08:00
parent caa05948bf
commit ce635b715b
2 changed files with 11 additions and 5 deletions

View file

@ -747,7 +747,15 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
for memberType in type.unroll().flatMemberTypes
if memberType.isDictionary()
]
if dictionaries:
if defaultValue and not isinstance(defaultValue, IDLNullValue):
tag = defaultValue.type.tag()
if tag is IDLType.Tags.bool:
default = "%s::Boolean(%s)" % (
union_native_type(type),
"true" if defaultValue.value else "false")
else:
raise("We don't currently support default values that aren't null or boolean")
elif dictionaries:
if defaultValue:
assert isinstance(defaultValue, IDLNullValue)
dictionary, = dictionaries

View file

@ -23,10 +23,8 @@ partial interface MediaDevices {
dictionary MediaStreamConstraints {
(boolean or MediaTrackConstraints) video;
// (boolean or MediaTrackConstraints) video = false;
(boolean or MediaTrackConstraints) audio;
// (boolean or MediaTrackConstraints) audio = false;
(boolean or MediaTrackConstraints) video = false;
(boolean or MediaTrackConstraints) audio = false;
};
dictionary DoubleRange {