avm2: Stub `LoaderInfo.contentType`

This commit is contained in:
David Wendt 2021-03-20 22:38:47 -04:00 committed by kmeisthax
parent 76c563146d
commit cbd167fd6c
1 changed files with 23 additions and 0 deletions

View File

@ -122,6 +122,25 @@ pub fn content<'gc>(
Ok(Value::Undefined)
}
/// `contentType` getter
pub fn content_type<'gc>(
_activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> {
if let Some(this) = this {
if let Some(loader_stream) = this.as_loader_stream() {
match &*loader_stream {
LoaderStream::SWF(_, _) => {
return Ok("application/x-shockwave-flash".into());
}
}
}
}
Ok(Value::Undefined)
}
/// Derive `LoaderInfoObject` impls.
pub fn loaderinfo_deriver<'gc>(
base_proto: Object<'gc>,
@ -166,6 +185,10 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
QName::new(Namespace::public(), "content"),
Method::from_builtin(content),
));
write.define_instance_trait(Trait::from_getter(
QName::new(Namespace::public(), "contentType"),
Method::from_builtin(content_type),
));
class
}