Gate reference space creation on requested features

This commit is contained in:
Manish Goregaokar 2020-01-14 18:09:28 +05:30
parent 8cc7c51803
commit 9a04a37c1c
3 changed files with 18 additions and 8 deletions

View file

@ -185,6 +185,8 @@ impl XRMethods for XR {
let mut optional_features = vec![];
let cx = global.get_cx();
// We are supposed to include "viewer" and on immersive devices "local"
// by default here, but this is handled directly in requestReferenceSpace()
if let Some(ref r) = init.requiredFeatures {
for feature in r {
unsafe {

View file

@ -559,10 +559,25 @@ impl XRSessionMethods for XRSession {
p.reject_error(Error::NotSupported)
},
ty => {
if ty != XRReferenceSpaceType::Viewer &&
(!self.is_immersive() || ty != XRReferenceSpaceType::Local)
{
let s = ty.as_str();
if self
.session
.borrow()
.granted_features()
.iter()
.find(|f| &**f == s)
.is_none()
{
p.reject_error(Error::NotSupported);
return p;
}
}
p.resolve_native(&XRReferenceSpace::new(&self.global(), self, ty));
},
}
p
}

View file

@ -1,7 +0,0 @@
[xrSession_requestReferenceSpace_features.https.html]
[Immersive session rejects local-floor space if not requested]
expected: FAIL
[Non-immersive session rejects local space if not requested]
expected: FAIL